|
1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // This contains CommDb Unit Test Cases 038.XX |
|
15 // |
|
16 // |
|
17 |
|
18 // EPOC includes |
|
19 #include <e32base.h> |
|
20 #include <commdb.h> |
|
21 #include <d32comm.h> |
|
22 #include <cdbtemp.h> |
|
23 |
|
24 // Test system includes |
|
25 #include <networking/log.h> |
|
26 #include <networking/teststep.h> |
|
27 #include "Teststepcommdb.h" |
|
28 #include "TestSuiteCommdb.h" |
|
29 #include "Step_038_xx.h" |
|
30 |
|
31 |
|
32 |
|
33 CCommDbTest038_01::CCommDbTest038_01() |
|
34 { |
|
35 // store the name of this test case |
|
36 iTestStepName = _L("step_038_01"); |
|
37 } |
|
38 |
|
39 CCommDbTest038_01::~CCommDbTest038_01() |
|
40 {} |
|
41 |
|
42 TVerdict CCommDbTest038_01::doTestStepL( void ) |
|
43 { |
|
44 if(executeStepL()!=KErrNone) |
|
45 return EFail; |
|
46 return EPass; |
|
47 } |
|
48 |
|
49 TVerdict CCommDbTest038_01::doTestStepPreambleL() |
|
50 { |
|
51 iTheDb=CCommsDatabase::NewL(); |
|
52 |
|
53 return EPass; |
|
54 } |
|
55 |
|
56 TInt CCommDbTest038_01::executeStepL() |
|
57 { |
|
58 CCommsDbTemplateRecord* templateRecord = CCommsDbTemplateRecord::NewL(iTheDb, TPtrC(MODEM_BEARER)); |
|
59 CleanupStack::PushL(templateRecord); |
|
60 User::LeaveIfError( templateRecord->Modify()); |
|
61 templateRecord->WriteTextL(TPtrC(COMMDB_NAME), _L("DummyName")); |
|
62 User::LeaveIfError(templateRecord->StoreModifications()); |
|
63 |
|
64 //delete the template |
|
65 User::LeaveIfError(templateRecord->Delete()); |
|
66 |
|
67 TInt ret(KErrNone); |
|
68 |
|
69 if(templateRecord->TemplateRecordExists()) |
|
70 ret = KErrGeneral; |
|
71 |
|
72 CleanupStack::PopAndDestroy(templateRecord); |
|
73 |
|
74 return ret; |
|
75 } |
|
76 |
|
77 TVerdict CCommDbTest038_01::doTestStepPostambleL() |
|
78 { |
|
79 delete iTheDb; |
|
80 iTheDb=NULL; |
|
81 return EPass; |
|
82 } |
|
83 |
|
84 // |
|
85 |
|
86 CCommDbTest038_02::CCommDbTest038_02() |
|
87 { |
|
88 // store the name of this test case |
|
89 iTestStepName = _L("step_038_02"); |
|
90 } |
|
91 |
|
92 CCommDbTest038_02::~CCommDbTest038_02() |
|
93 {} |
|
94 |
|
95 TVerdict CCommDbTest038_02::doTestStepL( void ) |
|
96 { |
|
97 if(executeStepL()!=KErrNotFound) |
|
98 return EFail; |
|
99 return EPass; |
|
100 } |
|
101 |
|
102 TVerdict CCommDbTest038_02::doTestStepPreambleL() |
|
103 { |
|
104 iTheDb=CCommsDatabase::NewL(); |
|
105 |
|
106 return EPass; |
|
107 } |
|
108 |
|
109 TInt CCommDbTest038_02::executeStepL() |
|
110 { |
|
111 CCommsDbTemplateRecord* templateRecord = CCommsDbTemplateRecord::NewL(iTheDb, TPtrC(MODEM_BEARER)); |
|
112 CleanupStack::PushL(templateRecord); |
|
113 |
|
114 User::LeaveIfError( templateRecord->Modify()); |
|
115 templateRecord->WriteTextL(TPtrC(COMMDB_NAME), _L("DummyName")); |
|
116 User::LeaveIfError(templateRecord->StoreModifications()); |
|
117 |
|
118 //delete the template |
|
119 User::LeaveIfError(templateRecord->Delete()); |
|
120 |
|
121 TInt ret = templateRecord->Delete(); |
|
122 |
|
123 CleanupStack::PopAndDestroy(templateRecord); |
|
124 |
|
125 return ret; |
|
126 } |
|
127 |
|
128 TVerdict CCommDbTest038_02::doTestStepPostambleL() |
|
129 { |
|
130 delete iTheDb; |
|
131 iTheDb=NULL; |
|
132 return EPass; |
|
133 } |
|
134 |
|
135 // |
|
136 |
|
137 CCommDbTest038_03::CCommDbTest038_03() |
|
138 { |
|
139 // store the name of this test case |
|
140 iTestStepName = _L("step_038_03"); |
|
141 } |
|
142 |
|
143 CCommDbTest038_03::~CCommDbTest038_03() |
|
144 {} |
|
145 |
|
146 TVerdict CCommDbTest038_03::doTestStepL( void ) |
|
147 { |
|
148 Log(_L("Step 038.03 called ")); |
|
149 |
|
150 iTestStepResult = EPass; |
|
151 |
|
152 CCommDbTest038_01* step038_01 = new(ELeave) CCommDbTest038_01; |
|
153 CleanupStack::PushL(step038_01); |
|
154 step038_01->iSuite = iSuite; |
|
155 doTestStepWithHeapFailureL( *step038_01, KErrNone); |
|
156 CleanupStack::PopAndDestroy(step038_01); |
|
157 |
|
158 CCommDbTest038_02* step038_02 = new(ELeave) CCommDbTest038_02; |
|
159 CleanupStack::PushL(step038_02); |
|
160 step038_02->iSuite = iSuite; |
|
161 doTestStepWithHeapFailureL( *step038_02, KErrNotFound); |
|
162 CleanupStack::PopAndDestroy(step038_02); |
|
163 |
|
164 return iTestStepResult; |
|
165 } |