|
1 // Copyright (c) 2003-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 ESock Test cases from section 2 |
|
15 // |
|
16 // |
|
17 |
|
18 // EPOC includes |
|
19 #include <e32base.h> |
|
20 |
|
21 // RootServer includes |
|
22 #include <es_mbman.h> |
|
23 |
|
24 // Test system includes |
|
25 //#include <networking/log.h> |
|
26 //#include <networking/teststep.h> |
|
27 //#include <networking/testsuite.h> |
|
28 |
|
29 #include "TestStepRootServer.h" |
|
30 #include "TestAsynchHandler.h" |
|
31 |
|
32 #include "RootServerTestSection2.h" |
|
33 #include "RootServerTest.h" |
|
34 |
|
35 // Test step 2.1 - Enumerate with No Servers |
|
36 CRootServerTest2_1::CRootServerTest2_1(CTE_RootServerServer *aSuite) : CTestStepRootServer(aSuite) |
|
37 { |
|
38 // store the name of this test case |
|
39 SetTestStepName(_L("Test2.1")); |
|
40 } |
|
41 |
|
42 TVerdict CRootServerTest2_1::doTestStepL( void ) |
|
43 { |
|
44 SetTestStepResult(EPass); |
|
45 |
|
46 INFO_PRINTF1(_L("Test Purpose: Enumerate with No Servers")); |
|
47 |
|
48 // enumerate servers |
|
49 INFO_PRINTF1(_L("02 Enumerating servers")); |
|
50 |
|
51 TCFModuleName moduleName; |
|
52 TRSIter position; |
|
53 TInt ret = iRootServerSuite->RootSess().EnumerateModules(position, moduleName); |
|
54 INFO_PRINTF2(_L("Enumerate returned %d"), ret); |
|
55 |
|
56 if (KErrEof != ret) |
|
57 { |
|
58 SetTestStepResult(EFail); |
|
59 } |
|
60 |
|
61 return TestStepResult(); |
|
62 } |
|
63 |
|
64 |
|
65 // Test step 2.2 - Enumerate |
|
66 CRootServerTest2_2::CRootServerTest2_2(CTE_RootServerServer *aSuite) : CTestStepRootServer(aSuite) |
|
67 { |
|
68 // store the name of this test case |
|
69 SetTestStepName(_L("Test2.2")); |
|
70 } |
|
71 |
|
72 TVerdict CRootServerTest2_2::doTestStepL( void ) |
|
73 { |
|
74 SetTestStepResult(EPass); |
|
75 |
|
76 INFO_PRINTF1(_L("Test Purpose: EnumerateModules")); |
|
77 |
|
78 // Create scheduler/active object framework |
|
79 CSelfPopScheduler* scheduler = CSelfPopScheduler::CreateLC(); |
|
80 CTestAsynchHandler* asynchHandler = CTestAsynchHandler::NewLC(&iRootServerSuite->RootSess()); |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 INFO_PRINTF2(_L("01 Loading first cpm: %S"), &KModule1()); |
|
86 |
|
87 |
|
88 |
|
89 LoadNormalModuleL(asynchHandler, KModule1); |
|
90 |
|
91 INFO_PRINTF2(_L("02 Loading second cpm: %S"), &KModule2()); |
|
92 LoadNormalModuleL(asynchHandler, KModule2); |
|
93 |
|
94 // uninstall active scheduler |
|
95 CleanupStack::PopAndDestroy(asynchHandler); |
|
96 CleanupStack::PopAndDestroy(scheduler); |
|
97 |
|
98 // now enumerate |
|
99 INFO_PRINTF1(_L("03 Enumerating once to get first servername")); |
|
100 |
|
101 TCFModuleName moduleName; |
|
102 TPtrC8 expectedModule2; |
|
103 TRSIter position; |
|
104 TInt ret = iRootServerSuite->RootSess().EnumerateModules(position, moduleName); |
|
105 |
|
106 INFO_PRINTF2(_L("Enumerate returned %d"), ret); |
|
107 |
|
108 if (KErrNone != ret) |
|
109 { |
|
110 SetTestStepResult(EFail); |
|
111 } |
|
112 else |
|
113 { |
|
114 if (moduleName == KModule1) |
|
115 { |
|
116 expectedModule2.Set(KModule2); |
|
117 } |
|
118 else if(moduleName == KModule2) |
|
119 { |
|
120 expectedModule2.Set(KModule1); |
|
121 } |
|
122 else |
|
123 { |
|
124 INFO_PRINTF2(_L("%S not found in serverlist"), &moduleName); |
|
125 SetTestStepResult(EFail); |
|
126 } |
|
127 if(expectedModule2.Length()) |
|
128 { |
|
129 INFO_PRINTF1(_L("Found first so enumerating again to get second servername")); |
|
130 ret = iRootServerSuite->RootSess().EnumerateModules(position, moduleName); |
|
131 |
|
132 INFO_PRINTF2(_L("Enumerate returned %d"), ret); |
|
133 |
|
134 if (KErrNone != ret) |
|
135 { |
|
136 SetTestStepResult(EFail); |
|
137 } |
|
138 else if (moduleName != expectedModule2) |
|
139 { |
|
140 INFO_PRINTF2(_L("%S not found in serverlist"), &moduleName); |
|
141 SetTestStepResult(EFail); |
|
142 } |
|
143 else |
|
144 { |
|
145 INFO_PRINTF1(_L("Found second so enumerating again to get EOF")); |
|
146 ret = iRootServerSuite->RootSess().EnumerateModules(position, moduleName); |
|
147 INFO_PRINTF2(_L("Enumerate returned %d"), ret); |
|
148 if(ret != KErrEof) |
|
149 { |
|
150 SetTestStepResult(EFail); |
|
151 } |
|
152 else |
|
153 { |
|
154 INFO_PRINTF1(_L("Found end of enumeration; enumerating again to check stability")); |
|
155 ret = iRootServerSuite->RootSess().EnumerateModules(position, moduleName); |
|
156 INFO_PRINTF2(_L("Enumerate returned %d"), ret); |
|
157 if(ret != KErrEof) |
|
158 { |
|
159 SetTestStepResult(EFail); |
|
160 } |
|
161 } |
|
162 } |
|
163 } |
|
164 } |
|
165 |
|
166 return TestStepResult(); |
|
167 } |
|
168 |
|
169 // Test step 2.3 - Enumerate submodules |
|
170 CRootServerTest2_3::CRootServerTest2_3(CTE_RootServerServer *aSuite) : CTestStepRootServer(aSuite) |
|
171 { |
|
172 // store the name of this test case |
|
173 SetTestStepName(_L("Test2.3")); |
|
174 } |
|
175 |
|
176 TVerdict CRootServerTest2_3::doTestStepL( void ) |
|
177 { |
|
178 SetTestStepResult(EPass); |
|
179 |
|
180 INFO_PRINTF1(_L("Test Purpose: EnumerateSubModules")); |
|
181 |
|
182 // Create scheduler/active object framework |
|
183 CSelfPopScheduler* scheduler = CSelfPopScheduler::CreateLC(); |
|
184 CTestAsynchHandler* asynchHandler = CTestAsynchHandler::NewLC(&iRootServerSuite->RootSess()); |
|
185 |
|
186 INFO_PRINTF2(_L("01 Loading test module: %S"), &KModule1()); |
|
187 LoadNormalModuleL(asynchHandler, KModule1); |
|
188 |
|
189 // uninstall and destroy active scheduler |
|
190 CleanupStack::PopAndDestroy(asynchHandler); |
|
191 CleanupStack::PopAndDestroy(scheduler); |
|
192 |
|
193 TCFSubModuleName subModule; |
|
194 TCFModuleName module(KModule1()); |
|
195 TBuf<0x40> str; |
|
196 TCFSubModuleName expected1(_L8("Test Protocol1")); |
|
197 TCFSubModuleName expected2(_L8("Test Protocol2")); |
|
198 TCFSubModuleName expected3(_L8("Test Protocol3")); |
|
199 TCFSubModuleName* expected[] = { &expected1, &expected2, &expected3 }; |
|
200 const TInt cntExpected = sizeof(expected) / sizeof(expected[0]); |
|
201 TInt idx; |
|
202 TRSIter position; |
|
203 TInt ret; |
|
204 while((ret = iRootServerSuite->RootSess().EnumerateSubModules(module, position, subModule)) == KErrNone) |
|
205 { |
|
206 str.Copy(subModule); |
|
207 |
|
208 INFO_PRINTF2(_L("Got %S"), &str); |
|
209 for(idx = 0; idx < cntExpected; ++idx) |
|
210 { |
|
211 if ((expected[idx] && subModule == *expected[idx])) |
|
212 { |
|
213 expected[idx] = NULL; |
|
214 break; |
|
215 } |
|
216 } |
|
217 if(idx == cntExpected) |
|
218 { |
|
219 INFO_PRINTF1(_L("not an expected sub-module")); |
|
220 SetTestStepResult(EFail); |
|
221 } |
|
222 } |
|
223 |
|
224 if(EPass == TestStepResult() && KErrEof != ret) |
|
225 { |
|
226 INFO_PRINTF1(_L("Enumeration didn't end with expected KErrEof")); |
|
227 SetTestStepResult(EFail); |
|
228 } |
|
229 else if((ret = iRootServerSuite->RootSess().EnumerateSubModules(module, position, subModule)) != KErrEof) |
|
230 { |
|
231 INFO_PRINTF1(_L("Further enumeration didn't return expected KErrEof")); |
|
232 SetTestStepResult(EFail); |
|
233 } |
|
234 |
|
235 for(idx = 0; idx < cntExpected; ++idx) |
|
236 { |
|
237 if (expected[idx]) |
|
238 { |
|
239 INFO_PRINTF2(_L("Expected sub-module %S wasn't enumerated"), expected[idx]); |
|
240 SetTestStepResult(EFail); |
|
241 break; |
|
242 } |
|
243 } |
|
244 |
|
245 return TestStepResult(); |
|
246 } |