|
1 // Copyright (c) 2005-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 // Example CTestStep derived implementation |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file loadcpmStep.cpp |
|
20 */ |
|
21 #include "TestAscynHandler.h" |
|
22 #include "unloadcpmStep.h" |
|
23 #include "Te_ConfiguratorSuiteDefs.h" |
|
24 |
|
25 //NET-CONFIGURATOR-I-0013-HP |
|
26 //UnLoading CPM which has been loaded prevesouly |
|
27 |
|
28 CUnloadCpm::~CUnloadCpm() |
|
29 /** |
|
30 * Destructor |
|
31 */ |
|
32 { |
|
33 } |
|
34 |
|
35 CUnloadCpm::CUnloadCpm() |
|
36 /** |
|
37 * Constructor |
|
38 */ |
|
39 { |
|
40 SetTestStepName(KUnloadCpm); |
|
41 } |
|
42 /** |
|
43 * @see UnloadCpm test case NET-CONFIGURATOR-I-0013-HP |
|
44 * |
|
45 * doTestStepL virtual function does the below action |
|
46 * Connect to a configurator server |
|
47 * Configurator Loads the CPMs (Communication provider module) |
|
48 * Configurator unloads the CPMs |
|
49 * close the connection to configuator |
|
50 * Expected:-UnloadCpm return KErrNone |
|
51 */ |
|
52 TVerdict CUnloadCpm::doTestStepL() |
|
53 { |
|
54 SetTestStepResult(EFail); |
|
55 _LIT8(KNameDummyCpm,"DummyCpm"); |
|
56 |
|
57 //Configurator Load the tesCpm CPM |
|
58 iConfigurator.LoadCpm(KNameDummyCpm(), iStatus); |
|
59 //Waits for a specific asynchronous request to complete |
|
60 User::WaitForRequest(iStatus); |
|
61 if(iStatus.Int() == KErrNone) |
|
62 { |
|
63 INFO_PRINTF1(_L("DummyCpm Loaded Successfully \n")); |
|
64 } |
|
65 else if(iStatus.Int() == KErrRSModuleUnknown) |
|
66 { |
|
67 INFO_PRINTF2(_L("LoadCpm (DummyCpm) returned KErrRSModuleUnknown(%d) \n"), iStatus.Int()); |
|
68 SetTestStepResult(EFail); |
|
69 } |
|
70 else |
|
71 { |
|
72 INFO_PRINTF2(_L("LoadCpm (DummyCpm) returned Error (%d) \n"), iStatus.Int()); |
|
73 SetTestStepResult(EFail); |
|
74 } |
|
75 |
|
76 //Configurator to unload the DummyCpm CPM |
|
77 iConfigurator.UnloadCpm(KNameDummyCpm(), EImmediate, iStatus); |
|
78 |
|
79 //Waits for a specific asynchronous request to complete. |
|
80 User::WaitForRequest(iStatus); |
|
81 if(iStatus.Int() == KErrNone) |
|
82 { |
|
83 INFO_PRINTF1(_L("DummyCpm UnLoaded Successfully ")); |
|
84 SetTestStepResult(EPass); |
|
85 } |
|
86 else if(iStatus.Int() == KErrRSModuleUnknown) |
|
87 { |
|
88 INFO_PRINTF2(_L("UnLoaded (DummyCpm) returned KErrRSModuleUnknown(%d) \n"), iStatus.Int()); |
|
89 SetTestStepResult(EFail); |
|
90 } |
|
91 else |
|
92 { |
|
93 INFO_PRINTF2(_L("UnLoaded (DummyCpm) returned Error (%d) \n"), iStatus.Int()); |
|
94 SetTestStepResult(EFail); |
|
95 } |
|
96 return TestStepResult(); |
|
97 } |
|
98 |
|
99 |
|
100 //NET-CONFIGURATOR-I-0014-HP |
|
101 //UnLoading CPM which has not been already loaded |
|
102 |
|
103 CUnloadCpmPreNotLoaded::~CUnloadCpmPreNotLoaded() |
|
104 /** |
|
105 * Destructor |
|
106 */ |
|
107 { |
|
108 } |
|
109 |
|
110 CUnloadCpmPreNotLoaded::CUnloadCpmPreNotLoaded() |
|
111 /** |
|
112 * Constructor |
|
113 */ |
|
114 { |
|
115 SetTestStepName(KUnloadCpmPreNotLoaded); |
|
116 } |
|
117 /** |
|
118 * @see UnloadCpmPreNotLoaded test case NET-CONFIGURATOR-I-0014-HP |
|
119 * |
|
120 * doTestStepL virtual function does the below action |
|
121 * Connect to a configurator server |
|
122 * Configurator unloads the CPM |
|
123 * close the connection to configuator |
|
124 * Expected:-UnloadCpmPreNotLoaded return KErrRSModuleNotLoaded |
|
125 */ |
|
126 TVerdict CUnloadCpmPreNotLoaded::doTestStepL() |
|
127 { |
|
128 SetTestStepResult(EFail); |
|
129 _LIT8(KNameDummyCpm,"DummyCpm"); |
|
130 |
|
131 //Configurator to unload the DummyCpm CPM |
|
132 iConfigurator.UnloadCpm(KNameDummyCpm(), EImmediate, iStatus); |
|
133 //Waits for a specific asynchronous request to complete |
|
134 User::WaitForRequest(iStatus); |
|
135 if(iStatus == KErrNone) |
|
136 { |
|
137 INFO_PRINTF1(_L("DummyCpm UnLoaded Successfully returned \n")); |
|
138 SetTestStepResult(EFail); |
|
139 } |
|
140 else if(iStatus.Int() == KErrRSModuleUnknown) |
|
141 { |
|
142 INFO_PRINTF2(_L("UnLoaded (DummyCpm) returned KErrRSModuleUnknown(%d) \n"), iStatus.Int()); |
|
143 SetTestStepResult(EFail); |
|
144 } |
|
145 else if(iStatus.Int() == KErrRSModuleNotLoaded) |
|
146 { |
|
147 INFO_PRINTF2(_L("UnLoaded (DummyCpm) returned KErrRSModuleNotLoaded(%d) \n"), iStatus.Int()); |
|
148 SetTestStepResult(EPass); |
|
149 } |
|
150 else |
|
151 { |
|
152 INFO_PRINTF2(_L("UnLoaded (DummyCpm) returned Error (%d) \n"), iStatus.Int()); |
|
153 SetTestStepResult(EFail); |
|
154 } |
|
155 return TestStepResult(); |
|
156 } |
|
157 |
|
158 //NET-CONFIGURATOR-I-0015-HP |
|
159 //Loading and unload different combination of cpm |
|
160 // To be modified different combination Loading and unloading existing cpm |
|
161 CLoadUnloadDiffCombination::~CLoadUnloadDiffCombination() |
|
162 /** |
|
163 * Destructor |
|
164 */ |
|
165 { |
|
166 } |
|
167 |
|
168 CLoadUnloadDiffCombination::CLoadUnloadDiffCombination() |
|
169 /** |
|
170 * Constructor |
|
171 */ |
|
172 { |
|
173 SetTestStepName(KLoadUnloadDiffCombination); |
|
174 } |
|
175 /** |
|
176 * @see LoadUnloadDiffCombination test case NET-CONFIGURATOR-I-0015-HP |
|
177 * |
|
178 * doTestStepL virtual function does the below action |
|
179 * Connect to a configurator server |
|
180 * Configurator loads the CPM |
|
181 * Configurator unloads the CPM |
|
182 * Repeat the loading and unloading with different combination |
|
183 * close the connection to configuator |
|
184 * Expected:-LoadUnloadDiffCombination return KErrRSModuleNotLoaded |
|
185 */ |
|
186 TVerdict CLoadUnloadDiffCombination::doTestStepL() |
|
187 { |
|
188 |
|
189 SetTestStepResult(EFail); |
|
190 TRequestStatus status3; |
|
191 TRequestStatus status4; |
|
192 TInt failCount = 0; |
|
193 |
|
194 _LIT8(KNameDummyCpm,"DummyCpm"); |
|
195 |
|
196 //Configurator Load the TesCpm CPM |
|
197 iConfigurator.LoadCpm(KNameDummyCpm(), iStatus); |
|
198 |
|
199 //Waits for a specific asynchronous request to complete |
|
200 User::WaitForRequest(iStatus); |
|
201 |
|
202 if(iStatus.Int() == KErrNone) |
|
203 { |
|
204 INFO_PRINTF1(_L("Cpm Loading Differenent order (DummyCpm) Loaded Successfully \n")); |
|
205 } |
|
206 else if(iStatus.Int() == KErrRSModuleUnknown) |
|
207 { |
|
208 INFO_PRINTF2(_L("Cpm Loading Differenent order (DummyCpm) returned KErrRSModuleUnknown(%d) \n"), iStatus.Int()); |
|
209 failCount++; |
|
210 } |
|
211 else |
|
212 { |
|
213 INFO_PRINTF2(_L("Cpm Loading Differenent order (DummyCpm) returned Error (%d) \n"), iStatus.Int()); |
|
214 failCount++; |
|
215 } |
|
216 |
|
217 _LIT8(KNameDummyCpm3,"DummyCpm3"); |
|
218 |
|
219 //Configurator Load the DummyCpm3 CPM |
|
220 iConfigurator.LoadCpm(KNameDummyCpm3(), status3); |
|
221 |
|
222 //Waits for a specific asynchronous request to complete |
|
223 User::WaitForRequest(status3); |
|
224 if(status3.Int() == KErrNone) |
|
225 { |
|
226 INFO_PRINTF1(_L("Cpm Loading Differenent order (DummyCpm3) Loaded Successfully \n")); |
|
227 } |
|
228 else if(status3.Int() == KErrRSModuleUnknown) |
|
229 { |
|
230 INFO_PRINTF2(_L("Cpm Loading Differenent order (DummyCpm3) returned KErrRSModuleUnknown(%d) \n"), status3.Int()); |
|
231 failCount++; |
|
232 } |
|
233 else |
|
234 { |
|
235 INFO_PRINTF2(_L("Cpm Loading Differenent order (DummyCpm3) returned Error (%d) \n"), status3.Int()); |
|
236 failCount++; |
|
237 } |
|
238 |
|
239 _LIT8(KNameDummyCpm4,"DummyCpm4"); |
|
240 |
|
241 //Configurator Load the TesCpm4 CPM |
|
242 iConfigurator.LoadCpm(KNameDummyCpm4(),status4); |
|
243 |
|
244 //Waits for a specific asynchronous request to complete |
|
245 User::WaitForRequest(status4); |
|
246 |
|
247 if(status4.Int() == KErrNone) |
|
248 { |
|
249 INFO_PRINTF1(_L("Cpm Loading Differenent order (DummyCpm4) Loaded Successfully \n")); |
|
250 } |
|
251 else if(status4.Int() == KErrRSModuleUnknown) |
|
252 { |
|
253 INFO_PRINTF2(_L("Cpm Loading Differenent order (DummyCpm4) returned KErrRSModuleUnknown(%d) \n"), status4.Int()); |
|
254 failCount++; |
|
255 } |
|
256 else |
|
257 { |
|
258 INFO_PRINTF2(_L("Cpm Loading Differenent order (DummyCpm4) returned Error (%d) \n"), status4.Int()); |
|
259 failCount++; |
|
260 } |
|
261 |
|
262 //Configurator to unload the DummyCpm4 CPM |
|
263 iConfigurator.UnloadCpm(KNameDummyCpm4(), EImmediate, status4); |
|
264 User::WaitForRequest(status4); |
|
265 |
|
266 //Configurator to unload the DummyCpm3 CPM |
|
267 iConfigurator.UnloadCpm(KNameDummyCpm3(), EImmediate, status3); |
|
268 User::WaitForRequest(status3); |
|
269 |
|
270 //Configurator to unload the DummyCpm CPM |
|
271 iConfigurator.UnloadCpm(KNameDummyCpm(), EImmediate, iStatus); |
|
272 User::WaitForRequest(iStatus); |
|
273 |
|
274 //Configurator to load the DummyCpm4 CPM |
|
275 iConfigurator.LoadCpm(KNameDummyCpm4(), status4); |
|
276 User::WaitForRequest(status4); |
|
277 |
|
278 if(status4.Int() == KErrNone) |
|
279 { |
|
280 INFO_PRINTF1(_L("Cpm Loading Differenent order (DummyCpm4) Loaded Successfully \n")); |
|
281 } |
|
282 else if(status4.Int() == KErrRSModuleUnknown) |
|
283 { |
|
284 INFO_PRINTF2(_L("Cpm Loading Differenent order (DummyCpm4) returned KErrRSModuleUnknown(%d) \n"), status4.Int()); |
|
285 failCount++; |
|
286 } |
|
287 else |
|
288 { |
|
289 INFO_PRINTF2(_L("Cpm Loading Differenent order (DummyCpm4) returned Error (%d) \n"), status4.Int()); |
|
290 failCount++; |
|
291 } |
|
292 |
|
293 //Configurator to unload the DummyCpm4 |
|
294 iConfigurator.UnloadCpm(KNameDummyCpm4(), EImmediate, status4); |
|
295 User::WaitForRequest(status4); |
|
296 |
|
297 //Configurator to load the DummyCpm3 |
|
298 iConfigurator.LoadCpm(KNameDummyCpm3(), status3); |
|
299 User::WaitForRequest(status3); |
|
300 |
|
301 if(status3.Int() == KErrNone) |
|
302 { |
|
303 INFO_PRINTF1(_L("Cpm Loading Differenent order (DummyCpm3) Loaded Successfully \n")); |
|
304 } |
|
305 else if(status3.Int() == KErrRSModuleUnknown) |
|
306 { |
|
307 INFO_PRINTF2(_L("Cpm Loading Differenent order (DummyCpm3) returned KErrRSModuleUnknown(%d) \n"), status3.Int()); |
|
308 failCount++; |
|
309 } |
|
310 else |
|
311 { |
|
312 INFO_PRINTF2(_L("Cpm Loading Differenent order (DummyCpm3) returned Error (%d) \n"), status3.Int()); |
|
313 failCount++; |
|
314 } |
|
315 |
|
316 //Configurator to unload the DummyCpm3 CPM |
|
317 iConfigurator.UnloadCpm(KNameDummyCpm3(), EImmediate, status3); |
|
318 User::WaitForRequest(status3); |
|
319 if(failCount == 0) |
|
320 { |
|
321 SetTestStepResult(EPass); |
|
322 } |
|
323 |
|
324 return TestStepResult(); |
|
325 } |
|
326 |
|
327 // NET-CONFIGURATOR-I-0016-HP |
|
328 //Cancelling the Loading CPM before and after loading |
|
329 CCancelLoadCpm::~CCancelLoadCpm() |
|
330 /** |
|
331 * Destructor |
|
332 */ |
|
333 { |
|
334 } |
|
335 |
|
336 CCancelLoadCpm::CCancelLoadCpm() |
|
337 /** |
|
338 * Constructor |
|
339 */ |
|
340 { |
|
341 SetTestStepName(KCancelLoadCpm); |
|
342 } |
|
343 /** |
|
344 * @see CancelLoadCpm test case NET-CONFIGURATOR-I-0016-HP |
|
345 * |
|
346 * doTestStepL virtual function does the below action |
|
347 * Connect to a configurator server |
|
348 * Configurator loads the CPM |
|
349 * Configurator unloads the CPM |
|
350 * Configurator call Cancel load to cancel the preveous load request |
|
351 * close the connection to configuator |
|
352 * Expected:-CancelLoadCpm return KErrNone or KerrCancelled |
|
353 * Expected result may not be always true it is wrote below mentioned in the production code |
|
354 * There is no guarantee the module loading is canceled. |
|
355 A best effort is made and the asynchronous request waiting for the module |
|
356 to load returns with KErrCanceled on success. |
|
357 */ |
|
358 TVerdict CCancelLoadCpm::doTestStepL() |
|
359 { |
|
360 SetTestStepResult(EFail); |
|
361 |
|
362 // Construct and install the active scheduler |
|
363 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
364 // Push onto the cleanup stack |
|
365 CleanupStack::PushL(scheduler); |
|
366 // Install as the active scheduler |
|
367 CActiveScheduler::Install(scheduler); |
|
368 |
|
369 CCanceledLoadCpm* synchHandler = CCanceledLoadCpm::NewL(); |
|
370 CleanupStack::PushL(synchHandler); |
|
371 _LIT8(KNameDummyCpm,"DummyCpm"); |
|
372 |
|
373 // issuing the Load request |
|
374 INFO_PRINTF1(_L("DummyCpm Trying to Load")); |
|
375 synchHandler->TryLoad(KNameDummyCpm()); |
|
376 //synchHandler->Cancel(); |
|
377 iConfigurator.CancelLoadCpm(KNameDummyCpm()); |
|
378 |
|
379 CActiveScheduler::Start(); |
|
380 if ((KErrCancel == synchHandler->iStatus.Int()) || (KErrNone == synchHandler->iStatus.Int())) |
|
381 { |
|
382 INFO_PRINTF2(_L("LoadCpm Success %d \n"),synchHandler->iStatus.Int()); |
|
383 SetTestStepResult(EPass); |
|
384 } |
|
385 |
|
386 // Unload the CPM anyway in case we were too late to cancel the load. |
|
387 TRequestStatus status; |
|
388 iConfigurator.UnloadCpm(KNameDummyCpm(), EImmediate, status); |
|
389 User::WaitForRequest(status); |
|
390 |
|
391 CleanupStack::PopAndDestroy(synchHandler); |
|
392 CleanupStack::PopAndDestroy(scheduler); |
|
393 return TestStepResult(); |
|
394 } |
|
395 |
|
396 //NET-CONFIGURATOR-I-0017-HP |
|
397 CCancelUnLoadCpm::~CCancelUnLoadCpm() |
|
398 /** |
|
399 * Destructor |
|
400 */ |
|
401 { |
|
402 } |
|
403 |
|
404 CCancelUnLoadCpm::CCancelUnLoadCpm() |
|
405 /** |
|
406 * Constructor |
|
407 */ |
|
408 { |
|
409 } |
|
410 |
|
411 /** |
|
412 * @see CancelUnLoadCpm test case NET-CONFIGURATOR-I-0017-HP |
|
413 * |
|
414 * doTestStepL virtual function does the below action |
|
415 * Connect to a configurator server |
|
416 * Configurator loads the CPM |
|
417 * Configurator unloads the CPM |
|
418 * Configurator call Cancel unload to cancel the preveous unload request |
|
419 * close the connection to configuator |
|
420 * Expected:-CancelUnLoadCpm return KErrCancel or KErrNone |
|
421 * Expected result may not be always true it is wrote below mentioned in the production code |
|
422 * There is no guarantee the module loading is canceled. |
|
423 A best effort is made and the asynchronous request waiting for the module |
|
424 to load returns with KErrCanceled on success. |
|
425 */ |
|
426 TVerdict CCancelUnLoadCpm::doTestStepL() |
|
427 { |
|
428 |
|
429 SetTestStepResult(EFail); |
|
430 |
|
431 // Construct and install the active scheduler |
|
432 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
433 |
|
434 // Push into the cleanup stack |
|
435 CleanupStack::PushL(scheduler); |
|
436 |
|
437 // Install as the active scheduler |
|
438 CActiveScheduler::Install(scheduler); |
|
439 |
|
440 // create a CanceledLoadCpm active objects |
|
441 CCanceledLoadCpm* synchHandler = CCanceledLoadCpm::NewL(); |
|
442 CleanupStack::PushL(synchHandler); |
|
443 _LIT8(KNameDummyCpm,"DummyCpm"); |
|
444 |
|
445 INFO_PRINTF1(_L("DummyCpm Trying to Load")); |
|
446 iConfigurator.LoadCpm(KNameDummyCpm(), iStatus); |
|
447 User::WaitForRequest(iStatus); |
|
448 |
|
449 synchHandler->TryUnLoad(KNameDummyCpm(), EImmediate); |
|
450 iConfigurator.CancelUnloadCpm(KNameDummyCpm()); |
|
451 CActiveScheduler::Start(); |
|
452 if ((KErrCancel == synchHandler->iStatus.Int()) || |
|
453 (KErrNone == synchHandler->iStatus.Int()) || |
|
454 (KErrRSModuleNotLoaded == synchHandler->iStatus.Int())) |
|
455 { |
|
456 INFO_PRINTF2(_L("Cancel UnloadCpm Success %d \n"), synchHandler->iStatus.Int()); |
|
457 SetTestStepResult(EPass); |
|
458 } |
|
459 else |
|
460 { |
|
461 INFO_PRINTF2(_L("Cancel UnloadCpm Fail %d \n"), synchHandler->iStatus.Int()); |
|
462 } |
|
463 |
|
464 CleanupStack::PopAndDestroy(synchHandler); |
|
465 CleanupStack::PopAndDestroy(scheduler); |
|
466 return TestStepResult(); |
|
467 } |
|
468 |