|
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 045.XX |
|
15 // |
|
16 // |
|
17 |
|
18 // EPOC includes |
|
19 #include <e32base.h> |
|
20 #include <commdb.h> |
|
21 #include <d32comm.h> |
|
22 #include <cdbstore.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_045_xx.h" |
|
30 |
|
31 |
|
32 CCommDbTest045_01::CCommDbTest045_01() |
|
33 { |
|
34 // store the name of this test case |
|
35 iTestStepName = _L("step_045_01"); |
|
36 } |
|
37 |
|
38 CCommDbTest045_01::~CCommDbTest045_01() |
|
39 {} |
|
40 |
|
41 TVerdict CCommDbTest045_01::doTestStepL( void ) |
|
42 { |
|
43 if(executeStepL()!=KErrNone) |
|
44 return EFail; |
|
45 return EPass; |
|
46 } |
|
47 |
|
48 TVerdict CCommDbTest045_01::doTestStepPreambleL() |
|
49 { |
|
50 return EPass; |
|
51 } |
|
52 |
|
53 TInt CCommDbTest045_01::executeStepL() |
|
54 { |
|
55 CStoreableOverrideSettings* overSet=CStoreableOverrideSettings::NewL(CStoreableOverrideSettings::EParamListPartial); |
|
56 CleanupStack::PushL(overSet); |
|
57 |
|
58 TUint32 setUint = 5000; |
|
59 User::LeaveIfError(overSet->SetIntOverride(TPtrC(DIAL_OUT_ISP), TPtrC(ISP_IWF_TO_MS), setUint)); |
|
60 |
|
61 TBool setBool = ETrue; |
|
62 User::LeaveIfError(overSet->SetBoolOverride(TPtrC(DIAL_OUT_ISP), TPtrC(SERVICE_IF_CALLBACK_ENABLED), setBool)); |
|
63 |
|
64 TBuf8<KCommsDbSvrMaxFieldLength> set8String(_L8("Hi There!!")); |
|
65 User::LeaveIfError(overSet->SetDesOverride(TPtrC(DIAL_OUT_ISP), TPtrC(ISP_IF_CALLBACK_INFO), set8String)); |
|
66 |
|
67 TBuf<KCommsDbSvrMaxFieldLength> set16String(_L("Hi There!!")); |
|
68 User::LeaveIfError(overSet->SetDesOverride(TPtrC(DIAL_OUT_ISP), TPtrC(ISP_DEFAULT_TEL_NUM), set16String)); |
|
69 |
|
70 TBuf<KCommsDbSvrMaxFieldLength> setLongString(_L("SEND \"hello\"\nWAIT 20\n{\n\"hello back\"\n")); //Lots of stuff, nothing important |
|
71 User::LeaveIfError(overSet->SetLongDesOverride(TPtrC(DIAL_OUT_ISP), TPtrC(ISP_LOGIN_SCRIPT), setLongString)); |
|
72 |
|
73 HBufC8* storeBuf=HBufC8::NewLC(1024); //Create a buf on the heap to use as the store |
|
74 TPtr8 storePtr=storeBuf->Des(); |
|
75 |
|
76 RDesWriteStream writeStream; |
|
77 writeStream.Open(storePtr); |
|
78 writeStream.PushL(); |
|
79 |
|
80 overSet->ExternalizeL(writeStream); |
|
81 writeStream.Close(); |
|
82 CleanupStack::Pop(); //writeStream |
|
83 |
|
84 //Settings have been stored to stream (storeBuf), |
|
85 //now read them into a new settings object and check them |
|
86 |
|
87 CStoreableOverrideSettings* restoreOverSet=CStoreableOverrideSettings::NewL(CStoreableOverrideSettings::EParamListPartial); |
|
88 CleanupStack::PushL(restoreOverSet); |
|
89 |
|
90 RDesReadStream readStream; |
|
91 readStream.Open(storePtr); |
|
92 readStream.PushL(); |
|
93 |
|
94 restoreOverSet->InternalizeL(readStream); |
|
95 readStream.Close(); |
|
96 CleanupStack::Pop(); //readStream |
|
97 |
|
98 //Check we've got the same stuff in the restored object as in the original |
|
99 TUint32 restoredUint; |
|
100 TBool restoredBool; |
|
101 TBuf8<KCommsDbSvrMaxFieldLength> restored8String; |
|
102 TBuf<KCommsDbSvrMaxFieldLength> restored16String; |
|
103 TBuf<KCommsDbSvrMaxFieldLength> restoredLongString; |
|
104 |
|
105 User::LeaveIfError(restoreOverSet->GetIntOverride(TPtrC(DIAL_OUT_ISP), TPtrC(ISP_IWF_TO_MS), restoredUint)); |
|
106 User::LeaveIfError(restoreOverSet->GetBoolOverride(TPtrC(DIAL_OUT_ISP), TPtrC(SERVICE_IF_CALLBACK_ENABLED), restoredBool)); |
|
107 User::LeaveIfError(restoreOverSet->GetDesOverride(TPtrC(DIAL_OUT_ISP), TPtrC(ISP_IF_CALLBACK_INFO), restored8String)); |
|
108 User::LeaveIfError(restoreOverSet->GetDesOverride(TPtrC(DIAL_OUT_ISP), TPtrC(ISP_DEFAULT_TEL_NUM), restored16String)); |
|
109 User::LeaveIfError(restoreOverSet->GetLongDesOverride(TPtrC(DIAL_OUT_ISP), TPtrC(ISP_LOGIN_SCRIPT), restoredLongString)); |
|
110 |
|
111 CleanupStack::PopAndDestroy(restoreOverSet); |
|
112 CleanupStack::PopAndDestroy(storeBuf); |
|
113 CleanupStack::PopAndDestroy(overSet); |
|
114 |
|
115 //Now do a comparison |
|
116 if(restoredUint!=setUint |
|
117 ||restoredBool!=setBool |
|
118 ||restored8String!=set8String |
|
119 ||restored16String!=set16String |
|
120 ||restoredLongString!=setLongString) |
|
121 return KErrGeneral; |
|
122 |
|
123 |
|
124 return KErrNone; |
|
125 } |
|
126 |
|
127 TVerdict CCommDbTest045_01::doTestStepPostambleL() |
|
128 { |
|
129 return EPass; |
|
130 } |
|
131 |
|
132 // |
|
133 |
|
134 CCommDbTest045_02::CCommDbTest045_02() |
|
135 { |
|
136 // store the name of this test case |
|
137 iTestStepName = _L("step_045_02"); |
|
138 } |
|
139 |
|
140 CCommDbTest045_02::~CCommDbTest045_02() |
|
141 {} |
|
142 |
|
143 TVerdict CCommDbTest045_02::doTestStepL( void ) |
|
144 { |
|
145 if(executeStepL()!=KErrEof) |
|
146 return EFail; |
|
147 return EPass; |
|
148 } |
|
149 |
|
150 TVerdict CCommDbTest045_02::doTestStepPreambleL() |
|
151 { |
|
152 return EPass; |
|
153 } |
|
154 |
|
155 TInt CCommDbTest045_02::executeStepL() |
|
156 { |
|
157 HBufC8* storeBuf=HBufC8::NewLC(1024); //Create a buf on the heap to use as the store |
|
158 TPtr8 storePtr=storeBuf->Des(); |
|
159 |
|
160 //Try and restore from a blank stream |
|
161 |
|
162 CStoreableOverrideSettings* restoreOverSet=CStoreableOverrideSettings::NewL(CStoreableOverrideSettings::EParamListPartial); |
|
163 CleanupStack::PushL(restoreOverSet); |
|
164 |
|
165 RDesReadStream readStream; |
|
166 storePtr=storeBuf->Des(); |
|
167 readStream.Open(storePtr); |
|
168 readStream.PushL(); |
|
169 |
|
170 TRAPD(err, restoreOverSet->InternalizeL(readStream)); |
|
171 readStream.Close(); |
|
172 CleanupStack::Pop(); //readStream |
|
173 |
|
174 |
|
175 CleanupStack::PopAndDestroy(restoreOverSet); |
|
176 CleanupStack::PopAndDestroy(storeBuf); |
|
177 |
|
178 return err; |
|
179 } |
|
180 |
|
181 TVerdict CCommDbTest045_02::doTestStepPostambleL() |
|
182 { |
|
183 return EPass; |
|
184 } |
|
185 |
|
186 // |
|
187 |
|
188 CCommDbTest045_03::CCommDbTest045_03() |
|
189 { |
|
190 // store the name of this test case |
|
191 iTestStepName = _L("step_045_03"); |
|
192 } |
|
193 |
|
194 CCommDbTest045_03::~CCommDbTest045_03() |
|
195 {} |
|
196 |
|
197 TVerdict CCommDbTest045_03::doTestStepL( void ) |
|
198 { |
|
199 Log(_L("Step 045.03 called ")); |
|
200 |
|
201 iTestStepResult = EPass; |
|
202 |
|
203 CCommDbTest045_01* step045_01 = new(ELeave) CCommDbTest045_01; |
|
204 CleanupStack::PushL(step045_01); |
|
205 step045_01->iSuite = iSuite; |
|
206 doTestStepWithHeapFailureL( *step045_01, KErrNone); |
|
207 CleanupStack::PopAndDestroy(step045_01); |
|
208 |
|
209 CCommDbTest045_02* step045_02 = new(ELeave) CCommDbTest045_02; |
|
210 CleanupStack::PushL(step045_02); |
|
211 step045_02->iSuite = iSuite; |
|
212 doTestStepWithHeapFailureL( *step045_02, KErrEof); |
|
213 CleanupStack::PopAndDestroy(step045_02); |
|
214 |
|
215 return iTestStepResult; |
|
216 } |