1 // Copyright (c) 2002-2010 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 the License "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 // e32test\power\t_domain.cpp |
|
15 // Overview: |
|
16 // Domain manager tests |
|
17 // API Information: |
|
18 // RDmDomain, RDmDomainManager CDmDomain, CDmDomainManager |
|
19 // Details: |
|
20 // - Test a variety of domain transitions, check the expected number of |
|
21 // notifications and the first expected ordinal. Verify results are |
|
22 // as expected. |
|
23 // - Test system standby, check the expected number of notifications and |
|
24 // the first expected ordinal. Use a timer to request a wakeup event. |
|
25 // Verify results are as expected. |
|
26 // - Test domain related simple error situations, verify results are |
|
27 // as expected. |
|
28 // - Perform platform security tests: launch a separate process with no |
|
29 // capabilities, verify that results are as expected. |
|
30 // - Test domain transitions by connecting to two domain hierarchies |
|
31 // simultaneously, add some test and power hierarchy members, verify |
|
32 // the expected target state, notifications and leaf nodes. Verify results. |
|
33 // - Verify that the same hierarchy can not be connected to more than once. |
|
34 // - Request a positive transition and request that the test domain use |
|
35 // ETraverseParentsFirst. Verify results are as expected and verify |
|
36 // domains are in the correct state. |
|
37 // - Request a negative transition and request that the test domain use |
|
38 // ETraverseChildrenFirst. Verify results are as expected. |
|
39 // - Request a positive transition with zero acknowledgements. Verify |
|
40 // results are as expected. |
|
41 // - Request a positive transition with error acknowledgements. Verify |
|
42 // results are as expected. |
|
43 // - Perform a variety of negative tests and verify results are as expected. |
|
44 // - Perform various tests on domain transitions with activated observer. |
|
45 // Verify results are as expected. |
|
46 // Platforms/Drives/Compatibility: |
|
47 // All. |
|
48 // Assumptions/Requirement/Pre-requisites: |
|
49 // Failures and causes: |
|
50 // Base Port information: |
|
51 // |
|
52 // |
|
53 |
|
54 #include <e32test.h> |
|
55 #include <domainmember.h> |
|
56 #include <domainmanager.h> |
|
57 #include <domainobserver.h> |
|
58 #include "domainpolicytest.h" |
|
59 #include <e32debug.h> |
|
60 #include <f32file.h> |
|
61 #include <e32ldr.h> |
|
62 #include <e32ldr_private.h> |
|
63 |
|
64 LOCAL_D RTest test(_L(" T_DOMAIN ")); |
|
65 _LIT(KThreadName, "t_domain_panic_thread"); |
|
66 |
|
67 #ifdef _DEBUG |
|
68 #define __PRINT(x) {RDebug::Print x;} |
|
69 #else |
|
70 #define __PRINT(x) |
|
71 #endif |
|
72 |
|
73 class CDmTestMember; |
|
74 |
|
75 // interface for test domain memebers. |
|
76 // Any test memeber should derive from this interface |
|
77 class MDmDomainMember |
|
78 { |
|
79 public: |
|
80 virtual TDmHierarchyId HierarchyId() = 0; |
|
81 virtual TDmDomainId DomainId() = 0; |
|
82 virtual TDmDomainState State() = 0; |
|
83 virtual TInt Status() = 0; |
|
84 virtual TUint32 Ordinal() = 0; |
|
85 virtual TInt Notifications() = 0; |
|
86 }; |
|
87 |
|
88 class MDmTest |
|
89 { |
|
90 public: |
|
91 virtual void Perform() = 0; |
|
92 virtual void Release() = 0; |
|
93 virtual TInt TransitionNotification(MDmDomainMember& aDomainMember) = 0; |
|
94 virtual void TransitionRequestComplete() = 0; |
|
95 }; |
|
96 |
|
97 // for the test hierarchy, we generate an ordinal for each domain |
|
98 // each byte of which describes the exact location of the domain in the hierarchy |
|
99 #define ORDINAL_FROM_DOMAINID0(id) (id) |
|
100 #define ORDINAL_FROM_DOMAINID1(parent, id) ((parent << 8) | (id)) |
|
101 #define ORDINAL_FROM_DOMAINID2(grandparent, parent, id) ((grandparent << 16) | (parent << 8) | id) |
|
102 #define ORDINAL_FROM_DOMAINID3(greatgrandparent, grandparent, parent, id) ((greatgrandparent << 24) | (grandparent << 16) | (parent << 8) | id) |
|
103 #define PARENT_ORDINAL(id) (id >> 8) |
|
104 |
|
105 #define ORDINAL_LEVEL(ordinal) \ |
|
106 ((ordinal & 0xFF00) == 0) ? 1 : \ |
|
107 ((ordinal & 0xFF0000) == 0) ? 2 : \ |
|
108 ((ordinal & 0xFF000000) == 0) ? 3 : 4; |
|
109 |
|
110 |
|
111 // get the least significant domain id character (for debugging purposes) |
|
112 TBool GetDomainChar(TDmDomainId aDomainId, TChar& aChar) |
|
113 { |
|
114 TBool found = ETrue; |
|
115 switch(aDomainId) |
|
116 { |
|
117 |
|
118 case KDmIdTestA: aChar = 'A'; break; |
|
119 case KDmIdTestB: aChar = 'B'; break; |
|
120 case KDmIdTestC: aChar = 'C'; break; |
|
121 case KDmIdTestAA: aChar = 'A'; break; |
|
122 case KDmIdTestAB: aChar = 'B'; break; |
|
123 case KDmIdTestBA: aChar = 'A'; break; |
|
124 case KDmIdTestCA: aChar = 'A'; break; |
|
125 case KDmIdTestABA: aChar = 'A'; break; |
|
126 case KDmIdTestABB: aChar = 'B'; break; |
|
127 case KDmIdTestCAA: aChar = 'A'; break; |
|
128 // domain char not found |
|
129 case KDmIdNone: |
|
130 case KDmIdRoot: |
|
131 default: |
|
132 found = EFalse; |
|
133 } |
|
134 return found; |
|
135 } |
|
136 |
|
137 // prints the 4-character domain string into the passed descriptor (for debugging purposes) |
|
138 // e.g. "CAA" for KDmIdTestCAA |
|
139 void GetDomainDesc(TUint32 aOrdinal, TDes& aDes) |
|
140 { |
|
141 if (aOrdinal == KDmIdRoot) |
|
142 { |
|
143 aDes.Append(_L("root")); |
|
144 return; |
|
145 } |
|
146 |
|
147 TUint32 val = aOrdinal; |
|
148 |
|
149 for (TInt n=0; n<4; n++) |
|
150 { |
|
151 TDmDomainId domainId = (TDmDomainId) (val >> 24); |
|
152 TChar ch; |
|
153 TBool found = GetDomainChar(domainId, ch); |
|
154 if (found) |
|
155 aDes.Append(ch); |
|
156 val = val << 8; |
|
157 } |
|
158 |
|
159 } |
|
160 |
|
161 |
|
162 class CDmTestMember : public CActive, public MDmDomainMember |
|
163 { |
|
164 public: |
|
165 // from CActive |
|
166 void RunL(); |
|
167 // from MDmDomainMember |
|
168 inline TDmHierarchyId HierarchyId() {return iHierarchy;}; |
|
169 inline TDmDomainId DomainId() {return iId;}; |
|
170 inline TDmDomainState State() {return iState;}; |
|
171 inline TInt Status() {return iStatus.Int();}; |
|
172 inline TUint32 Ordinal() {return iOrdinal;}; |
|
173 inline TInt Notifications() {return iNotifications;}; |
|
174 |
|
175 CDmTestMember(TDmHierarchyId aHierarchy, TDmDomainId aId, TUint32 aOrdinal, MDmTest*); |
|
176 ~CDmTestMember(); |
|
177 void Acknowledge(); |
|
178 |
|
179 protected: |
|
180 // from CActive |
|
181 virtual void DoCancel(); |
|
182 |
|
183 |
|
184 public: |
|
185 TDmHierarchyId iHierarchy; |
|
186 TDmDomainId iId; |
|
187 TDmDomainState iState; |
|
188 TUint32 iOrdinal; |
|
189 MDmTest* iTest; |
|
190 TInt iNotifications; |
|
191 RDmDomain iDomain; |
|
192 }; |
|
193 |
|
194 |
|
195 |
|
196 CDmTestMember::CDmTestMember(TDmHierarchyId aHierarchy, TDmDomainId aId, TUint32 aOrdinal, MDmTest* aTest) : CActive(CActive::EPriorityStandard), |
|
197 iHierarchy(aHierarchy), iId(aId), iOrdinal(aOrdinal), iTest(aTest) |
|
198 { |
|
199 TInt r; |
|
200 |
|
201 if (iHierarchy == KDmHierarchyIdPower) |
|
202 r = iDomain.Connect(iId); |
|
203 else |
|
204 r = iDomain.Connect(iHierarchy, iId); |
|
205 |
|
206 test(r == KErrNone); |
|
207 |
|
208 CActiveScheduler::Add(this); |
|
209 |
|
210 iDomain.RequestTransitionNotification(CActive::iStatus); |
|
211 CActive::SetActive(); |
|
212 } |
|
213 |
|
214 CDmTestMember::~CDmTestMember() |
|
215 { |
|
216 CActive::Cancel(); |
|
217 iDomain.Close(); |
|
218 } |
|
219 |
|
220 void CDmTestMember::Acknowledge() |
|
221 { |
|
222 iDomain.AcknowledgeLastState(); |
|
223 } |
|
224 |
|
225 void CDmTestMember::RunL() |
|
226 { |
|
227 |
|
228 iNotifications++; |
|
229 |
|
230 iState = iDomain.GetState(); |
|
231 |
|
232 TInt ackError = iTest->TransitionNotification(*this); |
|
233 if (ackError == KErrNone) |
|
234 iDomain.AcknowledgeLastState(); |
|
235 else if (ackError == KErrAbort) // don't acknowledge |
|
236 ; |
|
237 else |
|
238 iDomain.AcknowledgeLastState(ackError); |
|
239 |
|
240 |
|
241 // request another notification (even if we didn't acknowledge the last one) |
|
242 iDomain.RequestTransitionNotification(CActive::iStatus); |
|
243 CActive::SetActive(); |
|
244 } |
|
245 |
|
246 void CDmTestMember::DoCancel() |
|
247 { |
|
248 iDomain.CancelTransitionNotification(); |
|
249 } |
|
250 |
|
251 |
|
252 // CDomainMemberAo |
|
253 class CDomainMemberAo : public CDmDomain, public MDmDomainMember |
|
254 { |
|
255 public: |
|
256 static CDomainMemberAo* NewL(TDmHierarchyId aHierarchy, TDmDomainId aId, TUint32 aOrdinal, MDmTest*); |
|
257 ~CDomainMemberAo(); |
|
258 |
|
259 // from CActive |
|
260 void RunL(); |
|
261 |
|
262 // from MDmDomainMember |
|
263 inline TDmHierarchyId HierarchyId() {return iHierarchy;}; |
|
264 inline TDmDomainId DomainId() {return iId;}; |
|
265 inline TDmDomainState State() {return iState;}; |
|
266 inline TInt Status() {return iStatus.Int();}; |
|
267 inline TUint32 Ordinal() {return iOrdinal;}; |
|
268 inline TInt Notifications() {return iNotifications;}; |
|
269 |
|
270 private: |
|
271 CDomainMemberAo(TDmHierarchyId aHierarchy, TDmDomainId aId, TUint32 aOrdinal, MDmTest*); |
|
272 |
|
273 public: |
|
274 TDmHierarchyId iHierarchy; |
|
275 TDmDomainId iId; |
|
276 TDmDomainState iState; |
|
277 TUint32 iOrdinal; |
|
278 MDmTest* iTest; |
|
279 TInt iNotifications; |
|
280 }; |
|
281 |
|
282 CDomainMemberAo* CDomainMemberAo::NewL(TDmHierarchyId aHierarchy, TDmDomainId aId, TUint32 aOrdinal, MDmTest* aTest) |
|
283 { |
|
284 CDomainMemberAo* self=new (ELeave) CDomainMemberAo(aHierarchy, aId, aOrdinal, aTest); |
|
285 CleanupStack::PushL(self); |
|
286 self->ConstructL(); |
|
287 |
|
288 self->RequestTransitionNotification(); |
|
289 |
|
290 CleanupStack::Pop(); |
|
291 return self; |
|
292 } |
|
293 |
|
294 CDomainMemberAo::CDomainMemberAo(TDmHierarchyId aHierarchy, TDmDomainId aId, TUint32 aOrdinal, MDmTest* aTest) : |
|
295 CDmDomain(aHierarchy, aId), |
|
296 iHierarchy(aHierarchy), iId(aId), iOrdinal(aOrdinal), iTest(aTest) |
|
297 { |
|
298 } |
|
299 |
|
300 CDomainMemberAo::~CDomainMemberAo() |
|
301 { |
|
302 Cancel(); |
|
303 } |
|
304 |
|
305 void CDomainMemberAo::RunL() |
|
306 { |
|
307 iNotifications++; |
|
308 |
|
309 iState = GetState(); |
|
310 |
|
311 TInt ackError = iTest->TransitionNotification(*this); |
|
312 if (ackError == KErrNone) |
|
313 AcknowledgeLastState(ackError); |
|
314 else if (ackError == KErrAbort) // don't acknowledge |
|
315 ; |
|
316 else |
|
317 AcknowledgeLastState(ackError); |
|
318 if (ackError != KErrAbort) |
|
319 AcknowledgeLastState(ackError); |
|
320 |
|
321 |
|
322 // request another notification (even if we didn't acknowledge the last one) |
|
323 RequestTransitionNotification(); |
|
324 } |
|
325 |
|
326 |
|
327 // CDomainManagerAo |
|
328 class CDomainManagerAo : public CDmDomainManager |
|
329 { |
|
330 public: |
|
331 ~CDomainManagerAo(); |
|
332 static CDomainManagerAo* NewL(TDmHierarchyId aHierarchy, MDmTest& aTest); |
|
333 |
|
334 // from CActive |
|
335 void RunL(); |
|
336 |
|
337 private: |
|
338 CDomainManagerAo(TDmHierarchyId aHierarchy, MDmTest& aTest); |
|
339 |
|
340 private: |
|
341 MDmTest& iTest; |
|
342 }; |
|
343 |
|
344 |
|
345 CDomainManagerAo* CDomainManagerAo::NewL(TDmHierarchyId aHierarchy, MDmTest& aTest) |
|
346 { |
|
347 CDomainManagerAo* self=new (ELeave) CDomainManagerAo(aHierarchy, aTest); |
|
348 CleanupStack::PushL(self); |
|
349 |
|
350 self->ConstructL(); |
|
351 CleanupStack::Pop(); |
|
352 return self; |
|
353 } |
|
354 |
|
355 CDomainManagerAo::CDomainManagerAo(TDmHierarchyId aHierarchy, MDmTest& aTest) : |
|
356 CDmDomainManager(aHierarchy), iTest(aTest) |
|
357 { |
|
358 } |
|
359 |
|
360 CDomainManagerAo::~CDomainManagerAo() |
|
361 { |
|
362 } |
|
363 |
|
364 void CDomainManagerAo::RunL() |
|
365 { |
|
366 iTest.TransitionRequestComplete(); |
|
367 } |
|
368 |
|
369 |
|
370 class CDmTest1 : public CActive, public MDmTest |
|
371 { |
|
372 public: // from CActive |
|
373 void RunL(); |
|
374 |
|
375 // from MDmTest |
|
376 void Perform(); |
|
377 void Release(); |
|
378 TInt TransitionNotification(MDmDomainMember& aDomainMember); |
|
379 void TransitionRequestComplete() {}; |
|
380 |
|
381 CDmTest1 (TDmDomainId aId, TDmDomainState aState) : CActive(CActive::EPriorityStandard), iDomainId(aId), iState((TPowerState) aState) {} |
|
382 |
|
383 protected: |
|
384 // from CActive |
|
385 virtual void DoCancel(); |
|
386 |
|
387 private: |
|
388 enum { KMembersMax = 16 }; |
|
389 CDmTestMember* iMembers[KMembersMax]; |
|
390 RDmDomainManager iManager; |
|
391 TDmDomainId iDomainId; |
|
392 TPowerState iState; |
|
393 TBool iAcknowledge; |
|
394 TInt iMembersCount; |
|
395 TInt iCount; |
|
396 TUint32 iOrdinal; |
|
397 }; |
|
398 |
|
399 void CDmTest1::Perform() |
|
400 { |
|
401 // |
|
402 // Test domain transitions |
|
403 // |
|
404 |
|
405 test.Next(_L("Test 1")); |
|
406 test.Printf(_L("Domain id = 0x%x Target State = 0x%x\n"), iDomainId, iState); |
|
407 iMembers[0] = new CDmTestMember(KDmHierarchyIdPower, KDmIdRoot, 0, this); |
|
408 test(iMembers[0] != NULL); |
|
409 iMembers[1] = new CDmTestMember(KDmHierarchyIdPower, KDmIdRoot, 0, this); |
|
410 test(iMembers[1] != NULL); |
|
411 iMembers[2] = new CDmTestMember(KDmHierarchyIdPower, KDmIdApps, 1, this); |
|
412 test(iMembers[2] != NULL); |
|
413 iMembers[3] = new CDmTestMember(KDmHierarchyIdPower, KDmIdApps, 1, this); |
|
414 test(iMembers[3] != NULL); |
|
415 iMembers[4] = new CDmTestMember(KDmHierarchyIdPower, KDmIdUiApps, 1, this); |
|
416 test(iMembers[4] != NULL); |
|
417 iMembers[5] = new CDmTestMember(KDmHierarchyIdPower, KDmIdUiApps, 1, this); |
|
418 test(iMembers[5] != NULL); |
|
419 |
|
420 // expected number of notifications |
|
421 iMembersCount = (iDomainId == KDmIdRoot) ? 6 : 2; |
|
422 // first expected ordinal |
|
423 iOrdinal = (iState == EPwActive) ? 0 : 1; |
|
424 |
|
425 TInt r = iManager.Connect(); |
|
426 test(r == KErrNone); |
|
427 |
|
428 CActiveScheduler::Add(this); |
|
429 |
|
430 iManager.RequestDomainTransition(iDomainId, iState, CActive::iStatus); |
|
431 CActive::SetActive(); |
|
432 |
|
433 CActiveScheduler::Start(); |
|
434 } |
|
435 |
|
436 TInt CDmTest1::TransitionNotification(MDmDomainMember& aDomainMember) |
|
437 { |
|
438 ++iCount; |
|
439 if (aDomainMember.State() == EPwActive) |
|
440 { |
|
441 if(aDomainMember.Ordinal() < iOrdinal) |
|
442 { |
|
443 // Making the test to fail in RunL function inorder to complete the cleanup from domain manager. |
|
444 test.Printf(_L("Making test to fail as Ordinal Mismatch Expected : %d, Returned : %d"), aDomainMember.Ordinal(), iOrdinal); |
|
445 iCount--; |
|
446 } |
|
447 } |
|
448 else |
|
449 { |
|
450 if(aDomainMember.Ordinal() > iOrdinal) |
|
451 { |
|
452 //Making the test to fail in RunL function inorder to complete the cleanup from domain manager. |
|
453 test.Printf(_L("Making test to fail as Ordinal Mismatch Expected : %d, Returned : %d"), aDomainMember.Ordinal(), iOrdinal); |
|
454 iCount--; |
|
455 } |
|
456 } |
|
457 iOrdinal = aDomainMember.Ordinal(); |
|
458 |
|
459 // acknowledge one from two |
|
460 iAcknowledge = !iAcknowledge; |
|
461 return iAcknowledge?KErrNone:KErrGeneral; |
|
462 } |
|
463 |
|
464 void CDmTest1::RunL() |
|
465 { |
|
466 CActiveScheduler::Stop(); |
|
467 |
|
468 iManager.Close(); |
|
469 |
|
470 CDmTestMember** mp; |
|
471 for (mp = iMembers; *mp; ++mp) |
|
472 delete *mp; |
|
473 test(iCount == iMembersCount); |
|
474 } |
|
475 |
|
476 void CDmTest1::DoCancel() |
|
477 { |
|
478 test(0); |
|
479 } |
|
480 |
|
481 void CDmTest1::Release() |
|
482 { |
|
483 delete this; |
|
484 } |
|
485 |
|
486 class CDmTest2Timer : public CTimer |
|
487 { |
|
488 public: // fomr CTimer |
|
489 void RunL(); |
|
490 public: |
|
491 CDmTest2Timer() : CTimer(0) |
|
492 { |
|
493 TRAPD(r, |
|
494 ConstructL()); |
|
495 test(r == KErrNone); |
|
496 CActiveScheduler::Add(this); |
|
497 } |
|
498 }; |
|
499 |
|
500 void CDmTest2Timer::RunL() |
|
501 { |
|
502 test.Printf(_L("Tick count after CDmTest2Timer::RunL() = %d\n"), User::NTickCount()); |
|
503 |
|
504 // kick the timer again in case power down hasn't happened yet |
|
505 TTime wakeup; |
|
506 wakeup.HomeTime(); |
|
507 wakeup += TTimeIntervalSeconds(3); |
|
508 At(wakeup); |
|
509 } |
|
510 |
|
511 class CDmTest2 : public CActive, public MDmTest |
|
512 { |
|
513 public: // from CActive |
|
514 void RunL(); |
|
515 |
|
516 // from MDmTest |
|
517 void Perform(); |
|
518 void Release(); |
|
519 TInt TransitionNotification(MDmDomainMember& aDomainMember); |
|
520 void TransitionRequestComplete() {}; |
|
521 CDmTest2 (TDmDomainState aState) : CActive(CActive::EPriorityStandard), iState((TPowerState) aState) {} |
|
522 |
|
523 protected: |
|
524 // from CActive |
|
525 virtual void DoCancel(); |
|
526 |
|
527 private: |
|
528 enum { KMembersMax = 16 }; |
|
529 CDmTestMember* iMembers[KMembersMax]; |
|
530 RDmDomainManager iManager; |
|
531 TPowerState iState; |
|
532 TBool iAcknowledge; |
|
533 TInt iMembersCount; |
|
534 TInt iCount; |
|
535 TUint32 iOrdinal; |
|
536 CDmTest2Timer* iTimer; |
|
537 }; |
|
538 |
|
539 |
|
540 void CDmTest2::Perform() |
|
541 { |
|
542 // |
|
543 // Test system standby |
|
544 // |
|
545 |
|
546 test.Next(_L("Test 2")); |
|
547 test.Printf(_L("Target State = 0x%x\n"), iState); |
|
548 iMembers[0] = new CDmTestMember(KDmHierarchyIdPower, KDmIdRoot, 0, this); |
|
549 test(iMembers[0] != NULL); |
|
550 iMembers[1] = new CDmTestMember(KDmHierarchyIdPower, KDmIdRoot, 0, this); |
|
551 test(iMembers[1] != NULL); |
|
552 iMembers[2] = new CDmTestMember(KDmHierarchyIdPower, KDmIdApps, 1, this); |
|
553 test(iMembers[2] != NULL); |
|
554 iMembers[3] = new CDmTestMember(KDmHierarchyIdPower, KDmIdApps, 1, this); |
|
555 test(iMembers[3] != NULL); |
|
556 iMembers[4] = new CDmTestMember(KDmHierarchyIdPower, KDmIdUiApps, 1, this); |
|
557 test(iMembers[4] != NULL); |
|
558 iMembers[5] = new CDmTestMember(KDmHierarchyIdPower, KDmIdUiApps, 1, this); |
|
559 test(iMembers[5] != NULL); |
|
560 |
|
561 // expected number of notifications |
|
562 iMembersCount = 12; |
|
563 // first expected ordinal |
|
564 iOrdinal = (iState == EPwActive) ? 0 : 1; |
|
565 |
|
566 TInt r = iManager.Connect(); |
|
567 test(r == KErrNone); |
|
568 |
|
569 CActiveScheduler::Add(this); |
|
570 |
|
571 // Use an absolute timer to request a wakeup event |
|
572 iTimer = new CDmTest2Timer(); |
|
573 TTime wakeup; |
|
574 wakeup.HomeTime(); |
|
575 wakeup += TTimeIntervalSeconds(5); |
|
576 test.Printf(_L("Tick count before timer = %d\n"), User::NTickCount()); |
|
577 iTimer->At(wakeup); |
|
578 |
|
579 iManager.RequestSystemTransition(iState, CActive::iStatus); |
|
580 CActive::SetActive(); |
|
581 |
|
582 CActiveScheduler::Start(); |
|
583 } |
|
584 |
|
585 TInt CDmTest2::TransitionNotification(MDmDomainMember& aDomainMember) |
|
586 { |
|
587 ++iCount; |
|
588 if (aDomainMember.State() == EPwActive) |
|
589 { |
|
590 if(aDomainMember.Ordinal() < iOrdinal) |
|
591 { |
|
592 // Making the test to fail in RunL function inorder to complete the cleanup from domain manager. |
|
593 test.Printf(_L("Making test to fail as Ordinal Mismatch Expected : %d, Returned : %d, State : %d"), |
|
594 aDomainMember.Ordinal(), iOrdinal, aDomainMember.State()); |
|
595 iCount--; |
|
596 } |
|
597 } |
|
598 else |
|
599 { |
|
600 if(aDomainMember.Ordinal() > iOrdinal) |
|
601 { |
|
602 // Making the test to fail in RunL function inorder to complete the cleanup from domain manager. |
|
603 test.Printf(_L("Making test to fail as Ordinal Mismatch Expected : %d, Returned : %d, State: %d"), |
|
604 aDomainMember.Ordinal(), iOrdinal, aDomainMember.State()); |
|
605 iCount--; |
|
606 } |
|
607 } |
|
608 iOrdinal = aDomainMember.Ordinal(); |
|
609 |
|
610 // acknowledge one from two |
|
611 iAcknowledge = !iAcknowledge; |
|
612 return iAcknowledge?KErrNone:KErrAbort; |
|
613 } |
|
614 |
|
615 void CDmTest2::RunL() |
|
616 { |
|
617 test.Printf(_L("Tick count after CDmTest2::RunL() = %d\n"), User::NTickCount()); |
|
618 |
|
619 iTimer->Cancel(); |
|
620 CActiveScheduler::Stop(); |
|
621 |
|
622 iManager.Close(); |
|
623 |
|
624 CDmTestMember** mp; |
|
625 for (mp = iMembers; *mp; ++mp) |
|
626 delete *mp; |
|
627 test(CActive::iStatus == KErrTimedOut); |
|
628 test(iCount == iMembersCount); |
|
629 } |
|
630 |
|
631 void CDmTest2::DoCancel() |
|
632 { |
|
633 test(0); |
|
634 } |
|
635 |
|
636 void CDmTest2::Release() |
|
637 { |
|
638 if (iTimer) |
|
639 { |
|
640 iTimer->Cancel(); |
|
641 delete iTimer; |
|
642 } |
|
643 delete this; |
|
644 } |
|
645 |
|
646 class CDmTest3 : public MDmTest |
|
647 { |
|
648 public: |
|
649 // from MDmTest |
|
650 void Perform(); |
|
651 void Release(); |
|
652 TInt TransitionNotification(MDmDomainMember& aDomainMember); |
|
653 void TransitionRequestComplete() {}; |
|
654 }; |
|
655 |
|
656 void CDmTest3::Perform() |
|
657 { |
|
658 // |
|
659 // Test simple error situation |
|
660 // |
|
661 RDmDomainManager manager; |
|
662 TInt r = manager.Connect(); |
|
663 test(r == KErrNone); |
|
664 |
|
665 RDmDomainManager manager1; |
|
666 r = manager1.Connect(); |
|
667 test(r == KErrInUse); |
|
668 |
|
669 RDmDomain domain; |
|
670 r = domain.Connect(KDmIdNone); |
|
671 test(r == KDmErrBadDomainId); |
|
672 CDmTestMember* testMember; |
|
673 testMember = new CDmTestMember(KDmHierarchyIdPower, KDmIdApps, 1, this); |
|
674 test (testMember != NULL); |
|
675 |
|
676 TRequestStatus status; |
|
677 manager.RequestDomainTransition(KDmIdApps, EPwStandby, status); |
|
678 test(status.Int() == KRequestPending); |
|
679 |
|
680 TRequestStatus status1; |
|
681 manager.RequestDomainTransition(KDmIdApps, EPwActive, status1); |
|
682 User::WaitForRequest(status1); |
|
683 test(status1.Int() == KDmErrBadSequence); |
|
684 User::WaitForRequest(status); |
|
685 test(status.Int() == KErrTimedOut); |
|
686 |
|
687 // Since this test doesn't start the active scheduler, a domain member's RunL() will |
|
688 // not get called so we need to re-request a domain transition notification manually |
|
689 User::WaitForRequest(testMember->iStatus); |
|
690 test(testMember->iStatus.Int() == KErrNone); |
|
691 testMember->iDomain.RequestTransitionNotification(testMember->iStatus); |
|
692 |
|
693 manager.RequestDomainTransition(KDmIdApps, EPwActive, status); |
|
694 test(status.Int() == KRequestPending); |
|
695 manager.CancelTransition(); |
|
696 test(status.Int() == KErrCancel); |
|
697 manager.CancelTransition(); |
|
698 User::WaitForRequest(status); |
|
699 test(status.Int() == KErrCancel); |
|
700 |
|
701 testMember->iDomain.CancelTransitionNotification(); |
|
702 |
|
703 delete testMember; |
|
704 |
|
705 domain.Close(); |
|
706 manager.Close(); |
|
707 } |
|
708 |
|
709 TInt CDmTest3::TransitionNotification(MDmDomainMember& /*aDomainMember*/) |
|
710 { |
|
711 test(0); |
|
712 return KErrAbort; // don't acknowledge |
|
713 } |
|
714 |
|
715 void CDmTest3::Release() |
|
716 { |
|
717 delete this; |
|
718 } |
|
719 |
|
720 class CDmTest4 : public MDmTest |
|
721 { |
|
722 public: |
|
723 // from MDmTest |
|
724 void Perform(); |
|
725 void Release(); |
|
726 TInt TransitionNotification(MDmDomainMember& aDomainMember); |
|
727 void TransitionRequestComplete() {}; |
|
728 private: |
|
729 void ExecSlave(TUint arg); |
|
730 }; |
|
731 |
|
732 _LIT(KSecuritySlavePath, "t_domain_slave.exe"); |
|
733 |
|
734 void CDmTest4::ExecSlave(TUint aArg) |
|
735 { |
|
736 RProcess proc; |
|
737 TInt r = proc.Create(KSecuritySlavePath, TPtrC((TUint16*) &aArg, sizeof(aArg)/sizeof(TUint16))); |
|
738 test(r == KErrNone); |
|
739 TRequestStatus status; |
|
740 proc.Logon(status); |
|
741 proc.Resume(); |
|
742 User::WaitForRequest(status); |
|
743 |
|
744 RDebug::Printf("CDmTest4::ExecSlave(%d) ExitType %d", aArg, proc.ExitType() ); |
|
745 RDebug::Printf("CDmTest4::ExecSlave(%d) ExitReason %d", aArg, proc.ExitReason() ); |
|
746 test(proc.ExitType() == EExitKill); |
|
747 // test(proc.ExitReason() == KErrPermissionDenied); |
|
748 |
|
749 CLOSE_AND_WAIT(proc); |
|
750 } |
|
751 |
|
752 //! @SYMTestCaseID PBASE-T_DOMAIN-4 |
|
753 //! @SYMTestType CT |
|
754 //! @SYMTestCaseDesc Dmain manager security tests |
|
755 //! @SYMREQ 3722 |
|
756 //! @SYMTestActions Launches a separate process with no capabilities |
|
757 //! @SYMTestExpectedResults DM APIs should fail with KErrPermissionDenied |
|
758 //! @SYMTestPriority High |
|
759 //! @SYMTestStatus Defined |
|
760 void CDmTest4::Perform() |
|
761 { |
|
762 // |
|
763 // Security tests |
|
764 // |
|
765 |
|
766 ExecSlave(0); |
|
767 |
|
768 ExecSlave(1); |
|
769 |
|
770 } |
|
771 |
|
772 TInt CDmTest4::TransitionNotification(MDmDomainMember& /*aDomainMember*/) |
|
773 { |
|
774 test(0); |
|
775 return KErrNone; |
|
776 } |
|
777 |
|
778 void CDmTest4::Release() |
|
779 { |
|
780 delete this; |
|
781 } |
|
782 |
|
783 // Test hierarchy tests |
|
784 class CDmTestStartupMember : public CDmTestMember |
|
785 { |
|
786 public: |
|
787 CDmTestStartupMember(TDmHierarchyId aHierarchy, TDmDomainId aId, TUint32 aOrdinal, MDmTest*); |
|
788 |
|
789 public: |
|
790 private: |
|
791 }; |
|
792 |
|
793 CDmTestStartupMember::CDmTestStartupMember(TDmHierarchyId aHierarchy, TDmDomainId aId, TUint32 aOrdinal, MDmTest* aTest) |
|
794 : CDmTestMember(aHierarchy, aId, aOrdinal, aTest) |
|
795 { |
|
796 } |
|
797 |
|
798 // Simultaneously testing of test domain defined in DomainPolicy99.dll |
|
799 // and the power domain defined in DomainPolicy.dll |
|
800 class CDmTest5 : public CActive, public MDmTest |
|
801 { |
|
802 public: |
|
803 // from CActive |
|
804 void RunL(); |
|
805 // from MDmTest |
|
806 void Perform(); |
|
807 void Release(); |
|
808 TInt TransitionNotification(MDmDomainMember& aDomainMember); |
|
809 void TransitionRequestComplete(); |
|
810 void RunTestOnGetTransitionFailures(RArray<const TTransitionFailure>& aTransitionFailure); |
|
811 |
|
812 CDmTest5(TDmDomainId aPowerId, TDmDomainId aTestId, TDmDomainState aPowerState, TDmDomainState aTestState) : |
|
813 CActive(CActive::EPriorityStandard), |
|
814 iPowerDomainId(aPowerId), iTestDomainId(aTestId), iPowerState(aPowerState), iTestState(aTestState) {} |
|
815 protected: |
|
816 // from CActive |
|
817 virtual void DoCancel(); |
|
818 |
|
819 private: |
|
820 enum { KMembersMax = 16 }; |
|
821 enum TAckMode{ KAckAlways, KAckNever, KAckError, KAckOddDomainsOnly }; |
|
822 |
|
823 CDmTestMember* iTestMembers[KMembersMax]; |
|
824 CDomainMemberAo* iPowerMembers[KMembersMax]; |
|
825 |
|
826 RDmDomainManager iTestDomainManager; |
|
827 |
|
828 TDmDomainId iPowerDomainId; |
|
829 TDmDomainId iTestDomainId; |
|
830 |
|
831 TDmDomainState iPowerState; |
|
832 TDmDomainState iTestState; |
|
833 |
|
834 // level number for iTestDomainId. E.g 1 for KDmIdRoot, 2 for KDmIdTestA, etc. |
|
835 TInt iTestDomainLevel; |
|
836 |
|
837 TDmTraverseDirection iTraverseDirection; |
|
838 |
|
839 TAckMode iAckMode; |
|
840 |
|
841 public: |
|
842 TInt iTestNotifications; |
|
843 TInt iPowerNotifications; |
|
844 TInt iTestNotificationsExpected; |
|
845 TInt iPowerNotificationsExpected; |
|
846 |
|
847 TInt iTransitionsCompleted; |
|
848 TInt iTransitionsExpected; |
|
849 }; |
|
850 |
|
851 void CDmTest5::RunTestOnGetTransitionFailures(RArray<const TTransitionFailure>& aTransitionFailure) |
|
852 { |
|
853 //************************************************* |
|
854 // Test - OOM Testing on GetTransitionFailures() |
|
855 // Simulates heap failure in GetTransitionFailures() |
|
856 //************************************************* |
|
857 TInt error = 0; |
|
858 TInt count = 0; |
|
859 do |
|
860 { |
|
861 __UHEAP_SETFAIL(RHeap::EFailNext, ++count); |
|
862 error = iTestDomainManager.GetTransitionFailures(aTransitionFailure); |
|
863 test.Printf( _L( "CDmTest5::RunTestOnGetTransitionFailures, simulating heap failure on GetTransitionFailures(), Error=%d, Run=%d\n" ), error, count ); |
|
864 }while(error == KErrNoMemory); |
|
865 |
|
866 __UHEAP_RESET; |
|
867 |
|
868 //Actual count of heap failure as the final iteration which terminates the loop would not return KErrNoMemory |
|
869 --count; |
|
870 test(count > 0); |
|
871 test.Printf( _L( "Out of memory tests on GetTransitionFailures() succeeded at heap failure rate of %i\n" ), count ); |
|
872 } |
|
873 |
|
874 //! @SYMTestCaseID PBASE-T_DOMAIN-5 |
|
875 //! @SYMTestType CT |
|
876 //! @SYMTestCaseDesc Connects to two domain hierarchies simulteneously and perform various tests |
|
877 //! @SYMREQ 3704,3705,3706,3707,3708,3709,3710,3711,3720,3721,3724,3725,3726,3727 |
|
878 //! @SYMTestActions Open two hiearchies simultaneously and perform various actions. |
|
879 //! @SYMTestExpectedResults All tests should pass |
|
880 //! @SYMTestPriority High |
|
881 //! @SYMTestStatus Defined |
|
882 void CDmTest5::Perform() |
|
883 { |
|
884 |
|
885 __UHEAP_MARK; |
|
886 |
|
887 // |
|
888 // Test domain transitions |
|
889 // |
|
890 CActiveScheduler::Add(this); |
|
891 |
|
892 TInt r = RDmDomainManager::AddDomainHierarchy(KDmHierarchyIdTest); |
|
893 |
|
894 RDebug::Printf("RDmDomainManager::AddDomainHierarchy returns %d", r ); |
|
895 |
|
896 test(r == KErrNone); |
|
897 |
|
898 CDomainManagerAo* powerDomainManager = NULL; |
|
899 TRAP(r, powerDomainManager = CDomainManagerAo::NewL(KDmHierarchyIdPower, *this)); |
|
900 test (powerDomainManager != NULL); |
|
901 |
|
902 r = CDomainManagerAo::AddDomainHierarchy(KDmHierarchyIdPower); |
|
903 test(r == KErrNone); |
|
904 |
|
905 //************************************************* |
|
906 // Test 5a - connect to two domain hierarchies simultaneously |
|
907 //************************************************* |
|
908 test.Next(_L("Test 5a - connect to two domain hierarchies simultaneously")); |
|
909 |
|
910 test.Printf(_L("Domain id = 0x%x, Target State = 0x%x\n"), iTestDomainId, iTestState); |
|
911 |
|
912 TInt testMemberCount = 0; |
|
913 |
|
914 // Add some test hierarchy members - these use the RDmDomain API |
|
915 iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdRoot, ORDINAL_FROM_DOMAINID0(KDmIdRoot), this); |
|
916 test(iTestMembers[testMemberCount++] != NULL); |
|
917 iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdRoot, ORDINAL_FROM_DOMAINID0(KDmIdRoot), this); |
|
918 test(iTestMembers[testMemberCount++] != NULL); |
|
919 |
|
920 // row 1 |
|
921 iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdTestA, ORDINAL_FROM_DOMAINID1(KDmIdRoot, KDmIdTestA), this); |
|
922 test(iTestMembers[testMemberCount++] != NULL); |
|
923 iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdTestB, ORDINAL_FROM_DOMAINID1(KDmIdRoot, KDmIdTestB), this); |
|
924 test(iTestMembers[testMemberCount++] != NULL); |
|
925 iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdTestC, ORDINAL_FROM_DOMAINID1(KDmIdRoot, KDmIdTestC), this); |
|
926 test(iTestMembers[testMemberCount++] != NULL); |
|
927 |
|
928 // row2 |
|
929 iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdTestAA, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestA, KDmIdTestAA), this); |
|
930 test(iTestMembers[testMemberCount++] != NULL); |
|
931 iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdTestAB, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestA, KDmIdTestAB), this); |
|
932 test(iTestMembers[testMemberCount++] != NULL); |
|
933 iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdTestBA, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestB, KDmIdTestBA), this); |
|
934 test(iTestMembers[testMemberCount++] != NULL); |
|
935 iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdTestCA, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestC, KDmIdTestCA), this); |
|
936 test(iTestMembers[testMemberCount++] != NULL); |
|
937 |
|
938 // row 3 |
|
939 iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdTestABA, ORDINAL_FROM_DOMAINID3(KDmIdRoot, KDmIdTestA, KDmIdTestAB, KDmIdTestABA), this); |
|
940 test(iTestMembers[testMemberCount++] != NULL); |
|
941 iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdTestABB, ORDINAL_FROM_DOMAINID3(KDmIdRoot, KDmIdTestA, KDmIdTestAB, KDmIdTestABB), this); |
|
942 test(iTestMembers[testMemberCount++] != NULL); |
|
943 iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdTestCAA, ORDINAL_FROM_DOMAINID3(KDmIdRoot, KDmIdTestC, KDmIdTestCA, KDmIdTestCAA), this); |
|
944 test(iTestMembers[testMemberCount++] != NULL); |
|
945 |
|
946 // add some power hierarchy members - these use the CDmDomain AO API |
|
947 TInt powerMemberCount = 0; |
|
948 TRAP(r, iPowerMembers[powerMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdPower, KDmIdRoot, KDmIdRoot, this)); |
|
949 test(iTestMembers[powerMemberCount++] != NULL); |
|
950 TRAP(r, iPowerMembers[powerMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdPower, KDmIdApps, KDmIdApps, this)); |
|
951 test(iTestMembers[powerMemberCount++] != NULL); |
|
952 TRAP(r, iPowerMembers[powerMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdPower, KDmIdUiApps, KDmIdUiApps, this)); |
|
953 test(iTestMembers[powerMemberCount++] != NULL); |
|
954 |
|
955 |
|
956 RArray<const TTransitionFailure> testFailures; |
|
957 TInt testFailureCount; |
|
958 RArray<const TTransitionFailure> powerFailures; |
|
959 TInt powerFailureCount; |
|
960 |
|
961 |
|
962 |
|
963 // calculate the expected number of notifications |
|
964 TInt expectedTestNotifications = 0; |
|
965 TInt leafNodes = 0; |
|
966 |
|
967 |
|
968 // work out the domain level, the number of leaf nodes and the expected number of |
|
969 // notifications for the domain that is being transitioned |
|
970 switch(iTestDomainId) |
|
971 { |
|
972 case KDmIdRoot : iTestDomainLevel = 1; leafNodes = 5; expectedTestNotifications = testMemberCount; break; |
|
973 case KDmIdTestA : iTestDomainLevel = 2; leafNodes = 3; expectedTestNotifications = 5; break; |
|
974 case KDmIdTestB : iTestDomainLevel = 2; leafNodes = 1; expectedTestNotifications = 2; break; |
|
975 case KDmIdTestC : iTestDomainLevel = 2; leafNodes = 1; expectedTestNotifications = 3; break; |
|
976 |
|
977 case KDmIdTestAA : iTestDomainLevel = 3; leafNodes = 1; expectedTestNotifications = 1; break; |
|
978 case KDmIdTestAB : iTestDomainLevel = 3; leafNodes = 2; expectedTestNotifications = 3; break; |
|
979 case KDmIdTestBA : iTestDomainLevel = 3; leafNodes = 1; expectedTestNotifications = 1; break; |
|
980 case KDmIdTestCA : iTestDomainLevel = 3; leafNodes = 1; expectedTestNotifications = 2; break; |
|
981 |
|
982 case KDmIdTestABA : iTestDomainLevel = 4; leafNodes = 1; expectedTestNotifications = 1; break; |
|
983 case KDmIdTestABB : iTestDomainLevel = 4; leafNodes = 1; expectedTestNotifications = 1; break; |
|
984 case KDmIdTestCAA : iTestDomainLevel = 4; leafNodes = 1; expectedTestNotifications = 1; break; |
|
985 default: |
|
986 test(0); |
|
987 } |
|
988 test.Printf(_L("Test Domain id = 0x%x, Level = %d, Target State = 0x%x, expected notifications = %d, leafNodes = %d\n"), |
|
989 iTestDomainId, iTestDomainLevel, iTestState, expectedTestNotifications, leafNodes); |
|
990 |
|
991 TInt expectedPowerNotifications = 0; |
|
992 switch(iPowerDomainId) |
|
993 { |
|
994 case KDmIdRoot : expectedPowerNotifications = powerMemberCount; break; |
|
995 case KDmIdApps : expectedPowerNotifications = 1; break; |
|
996 case KDmIdUiApps : expectedPowerNotifications = 1; break; |
|
997 default: |
|
998 test(0); |
|
999 } |
|
1000 |
|
1001 |
|
1002 |
|
1003 // connect to the test hierarchy |
|
1004 r = iTestDomainManager.Connect(KDmHierarchyIdTest); |
|
1005 test(r == KErrNone); |
|
1006 |
|
1007 // verify that we can't connect to the same hierarchy more than once |
|
1008 RDmDomainManager domainManager; |
|
1009 r = domainManager.Connect(KDmHierarchyIdTest); |
|
1010 test(r == KErrInUse); |
|
1011 |
|
1012 |
|
1013 |
|
1014 //************************************************* |
|
1015 // Test 5b - request a positive transition |
|
1016 // issue a positive transition (i.e. transition state increases) |
|
1017 // and request that the test domain use ETraverseParentsFirst |
|
1018 //************************************************* |
|
1019 test.Next(_L("Test 5b - request a positive transition")); |
|
1020 iAckMode = KAckAlways; |
|
1021 |
|
1022 iTransitionsCompleted = iTestNotifications = iPowerNotifications = 0; |
|
1023 iPowerNotificationsExpected = 0; |
|
1024 iTestNotificationsExpected = expectedTestNotifications; |
|
1025 iTransitionsExpected = 1; |
|
1026 |
|
1027 // DON'T request any domain transition on the power hierarchy |
|
1028 // powerDomainManager->RequestDomainTransition(iPowerDomainId, EPwActive); |
|
1029 // request a domain transition on the test hierarchy |
|
1030 iTraverseDirection = ETraverseParentsFirst; |
|
1031 if (iTestDomainId == KDmIdRoot) |
|
1032 iTestDomainManager.RequestSystemTransition(iTestState, ETraverseDefault, CActive::iStatus); |
|
1033 else |
|
1034 iTestDomainManager.RequestDomainTransition(iTestDomainId, iTestState, ETraverseDefault, CActive::iStatus); |
|
1035 CActive::SetActive(); |
|
1036 |
|
1037 CActiveScheduler::Start(); |
|
1038 test(powerDomainManager->iStatus == KErrNone); |
|
1039 test(iStatus == KErrNone); |
|
1040 test(iTestNotifications == iTestNotificationsExpected); |
|
1041 test(iPowerNotifications == iPowerNotificationsExpected); |
|
1042 |
|
1043 //************************************************* |
|
1044 // Test 5c- verify domains are in correct state |
|
1045 //************************************************* |
|
1046 test.Next(_L("Test 5c- verify domains are in correct state")); |
|
1047 RDmDomain domainMember; |
|
1048 r = domainMember.Connect(KDmHierarchyIdTest, iTestDomainId); |
|
1049 test (r == KErrNone); |
|
1050 TDmDomainState state = domainMember.GetState(); |
|
1051 domainMember.Close(); |
|
1052 test (state == iTestState); |
|
1053 |
|
1054 // if the transition request is not on the root, verify that that |
|
1055 // the root domain and the transition domain are in different states |
|
1056 if (iTestDomainId != KDmIdRoot && iTestState != EStartupCriticalStatic) |
|
1057 { |
|
1058 r = domainMember.Connect(KDmHierarchyIdTest, KDmIdRoot); |
|
1059 test (r == KErrNone); |
|
1060 TDmDomainState state = domainMember.GetState(); |
|
1061 domainMember.Close(); |
|
1062 test (state != iTestState); |
|
1063 } |
|
1064 |
|
1065 |
|
1066 //************************************************* |
|
1067 // Test 5d- request a negative transition |
|
1068 // issue a negative transition (i.e. transition state decreases) |
|
1069 // and request that the test domain use ETraverseChildrenFirst |
|
1070 //************************************************* |
|
1071 test.Next(_L("Test 5d- request a negative transition")); |
|
1072 iAckMode = KAckAlways; |
|
1073 iTestState--; // EStartupCriticalStatic; |
|
1074 iPowerState--; // EPwStandby |
|
1075 |
|
1076 iTransitionsCompleted = iTestNotifications = iPowerNotifications = 0; |
|
1077 iPowerNotificationsExpected = expectedPowerNotifications; |
|
1078 iTestNotificationsExpected = expectedTestNotifications; |
|
1079 iTransitionsExpected = 2; |
|
1080 |
|
1081 // DO request a domain transition on the power hierarchy |
|
1082 powerDomainManager->RequestDomainTransition(iPowerDomainId, iPowerState, ETraverseDefault); |
|
1083 |
|
1084 // request a domain transition on the test hierarchy |
|
1085 iTraverseDirection = ETraverseChildrenFirst; |
|
1086 iTestDomainManager.RequestDomainTransition(iTestDomainId, iTestState, iTraverseDirection, CActive::iStatus); |
|
1087 CActive::SetActive(); |
|
1088 |
|
1089 // wait for all test & power transitions to complete |
|
1090 CActiveScheduler::Start(); |
|
1091 test(powerDomainManager->iStatus == KErrNone); |
|
1092 test(iStatus == KErrNone); |
|
1093 test(iTestNotifications == iTestNotificationsExpected); |
|
1094 test(iPowerNotifications == iPowerNotificationsExpected); |
|
1095 |
|
1096 |
|
1097 //************************************************* |
|
1098 // Test 5e- request a positive transition, with zero acknowledgements |
|
1099 // issue a positive transition with no members acknowledging the transition |
|
1100 //************************************************* |
|
1101 test.Next(_L("Test 5e- request a positive transition, with zero acknowledgements")); |
|
1102 iAckMode = KAckNever; |
|
1103 iTestState++; // EStartupCriticalDynamic; |
|
1104 iPowerState++; // EPwActive |
|
1105 |
|
1106 // power hierarchy should continue on failure, so we all power domains should transition |
|
1107 // test hierarchy should stop on failure, so should get notifications from all leaf nodes |
|
1108 iTransitionsCompleted = iTestNotifications = iPowerNotifications = 0; |
|
1109 iPowerNotificationsExpected = expectedPowerNotifications; |
|
1110 iTestNotificationsExpected = leafNodes; // 5 leaf nodes for root domain |
|
1111 iTransitionsExpected = 2; |
|
1112 |
|
1113 // DO request a domain transition on the power hierarchy |
|
1114 powerDomainManager->RequestDomainTransition(iPowerDomainId, iPowerState, ETraverseDefault); |
|
1115 |
|
1116 // request a domain transition on the test hierarchy |
|
1117 iTraverseDirection = ETraverseChildrenFirst; |
|
1118 iTestDomainManager.RequestDomainTransition(iTestDomainId, iTestState, iTraverseDirection, CActive::iStatus); |
|
1119 CActive::SetActive(); |
|
1120 |
|
1121 // wait for all test & power transitions to complete |
|
1122 CActiveScheduler::Start(); |
|
1123 test(powerDomainManager->iStatus == KErrTimedOut); |
|
1124 test(iStatus == KErrTimedOut); |
|
1125 test(iTestNotifications == iTestNotificationsExpected); |
|
1126 test(iPowerNotifications == iPowerNotificationsExpected); |
|
1127 |
|
1128 // get the failures on the test hierarchy |
|
1129 testFailureCount = iTestDomainManager.GetTransitionFailureCount(); |
|
1130 test (testFailureCount == 1); |
|
1131 |
|
1132 #ifdef _DEBUG |
|
1133 //*************************************************************** |
|
1134 // OOM Testing: Simulates heap failure in GetTransitionFailures() |
|
1135 //*************************************************************** |
|
1136 __UHEAP_MARK; |
|
1137 RArray<const TTransitionFailure> oomTestFailures; |
|
1138 RunTestOnGetTransitionFailures(oomTestFailures); |
|
1139 test(oomTestFailures.Count()==1); |
|
1140 oomTestFailures.Close(); |
|
1141 __UHEAP_MARKEND; |
|
1142 #endif |
|
1143 |
|
1144 r = iTestDomainManager.GetTransitionFailures(testFailures); |
|
1145 test(r == KErrNone); |
|
1146 test(testFailureCount == testFailures.Count()); |
|
1147 |
|
1148 test.Printf(_L("Test failures = %d\n"), testFailureCount); |
|
1149 TInt i; |
|
1150 for (i=0; i<testFailureCount; i++) |
|
1151 { |
|
1152 test.Printf(_L("%d: iDomainId %d, iError %d\n"), |
|
1153 i, testFailures[i].iDomainId, testFailures[i].iError); |
|
1154 test(testFailures[i].iError == KErrTimedOut); |
|
1155 } |
|
1156 |
|
1157 // get the failures on the power hierarchy |
|
1158 powerFailureCount = powerDomainManager->GetTransitionFailureCount(); |
|
1159 test (powerFailureCount == expectedPowerNotifications); |
|
1160 |
|
1161 r = powerDomainManager->GetTransitionFailures(powerFailures); |
|
1162 test(r == KErrNone); |
|
1163 test(powerFailureCount == powerFailures.Count()); |
|
1164 |
|
1165 test.Printf(_L("Power failures = %d\n"), powerFailureCount); |
|
1166 for (i=0; i<powerFailureCount; i++) |
|
1167 { |
|
1168 test.Printf(_L("%d: iDomainId %d, iError %d\n"), |
|
1169 i, powerFailures[i].iDomainId, powerFailures[i].iError); |
|
1170 test(powerFailures[i].iError == KErrTimedOut); |
|
1171 } |
|
1172 |
|
1173 |
|
1174 //************************************************* |
|
1175 // Test 5f- request a positive transition, with error acknowledgements |
|
1176 // issue a positive transition with all members nack'ing the transition |
|
1177 //************************************************* |
|
1178 test.Next(_L("Test 5f- request a positive transition, with error acknowledgements")); |
|
1179 iAckMode = KAckError; |
|
1180 iTestState++; |
|
1181 iPowerState++; |
|
1182 |
|
1183 // power hierarchy should continue on failure, so all power domains should transition |
|
1184 // test hierarchy should stop on failure, so should get notifications from |
|
1185 // anything from 1 to all the leaf nodes |
|
1186 iTransitionsCompleted = iTestNotifications = iPowerNotifications = 0; |
|
1187 iPowerNotificationsExpected = expectedPowerNotifications; |
|
1188 iTestNotificationsExpected = leafNodes; // 5 leaf nodes for root domain |
|
1189 iTransitionsExpected = 2; |
|
1190 |
|
1191 // DO request a domain transition on the power hierarchy |
|
1192 powerDomainManager->RequestDomainTransition(iPowerDomainId, iPowerState, ETraverseDefault); |
|
1193 |
|
1194 // request a domain transition on the test hierarchy |
|
1195 iTraverseDirection = ETraverseChildrenFirst; |
|
1196 iTestDomainManager.RequestDomainTransition(iTestDomainId, iTestState, iTraverseDirection, CActive::iStatus); |
|
1197 CActive::SetActive(); |
|
1198 |
|
1199 // wait for all test & power transitions to complete |
|
1200 CActiveScheduler::Start(); |
|
1201 test(powerDomainManager->iStatus == KErrGeneral); |
|
1202 test(iStatus == KErrGeneral); |
|
1203 test(iTestNotifications <= iTestNotificationsExpected); |
|
1204 test(iPowerNotifications == iPowerNotificationsExpected); |
|
1205 |
|
1206 // get the failures on the test hierarchy |
|
1207 testFailureCount = iTestDomainManager.GetTransitionFailureCount(); |
|
1208 test (testFailureCount == 1); |
|
1209 |
|
1210 r = iTestDomainManager.GetTransitionFailures(testFailures); |
|
1211 test(r == KErrNone); |
|
1212 test(testFailureCount == testFailures.Count()); |
|
1213 |
|
1214 test.Printf(_L("Test failures = %d\n"), testFailureCount); |
|
1215 for (i=0; i<testFailureCount; i++) |
|
1216 { |
|
1217 test.Printf(_L("%d: iDomainId %d, iError %d\n"), |
|
1218 i, testFailures[i].iDomainId, testFailures[i].iError); |
|
1219 test(testFailures[i].iError == KErrGeneral); |
|
1220 } |
|
1221 |
|
1222 // get the failures on the power hierarchy |
|
1223 powerFailureCount = powerDomainManager->GetTransitionFailureCount(); |
|
1224 test (powerFailureCount == expectedPowerNotifications); |
|
1225 |
|
1226 r = powerDomainManager->GetTransitionFailures(powerFailures); |
|
1227 test(r == KErrNone); |
|
1228 test(powerFailureCount == powerFailures.Count()); |
|
1229 |
|
1230 test.Printf(_L("Power failures = %d\n"), powerFailureCount); |
|
1231 for (i=0; i<powerFailureCount; i++) |
|
1232 { |
|
1233 test.Printf(_L("%d: iDomainId %d, iError %d\n"), |
|
1234 i, powerFailures[i].iDomainId, powerFailures[i].iError); |
|
1235 test(powerFailures[i].iError == KErrGeneral); |
|
1236 } |
|
1237 |
|
1238 |
|
1239 // cleanup |
|
1240 |
|
1241 testFailures.Reset(); |
|
1242 powerFailures.Reset(); |
|
1243 |
|
1244 iTestDomainManager.Close(); |
|
1245 delete powerDomainManager; |
|
1246 powerDomainManager = NULL; |
|
1247 |
|
1248 CDmTestMember** mt; |
|
1249 for (mt = iTestMembers; *mt; ++mt) |
|
1250 delete *mt; |
|
1251 |
|
1252 CDomainMemberAo** mp; |
|
1253 for (mp = iPowerMembers; *mp; ++mp) |
|
1254 delete *mp; |
|
1255 |
|
1256 |
|
1257 // restore the domain hierarchies to their initial state so as not to |
|
1258 // upset any subsequent tests which rely on this |
|
1259 { |
|
1260 RDmDomainManager manager; |
|
1261 TInt r = manager.Connect(); |
|
1262 test (r == KErrNone); |
|
1263 TRequestStatus status; |
|
1264 manager.RequestDomainTransition(KDmIdRoot, EPwActive, status); |
|
1265 test(status.Int() == KRequestPending); |
|
1266 User::WaitForRequest(status); |
|
1267 test(status.Int() == KErrNone); |
|
1268 manager.Close(); |
|
1269 |
|
1270 r = manager.Connect(KDmHierarchyIdTest); |
|
1271 test (r == KErrNone); |
|
1272 manager.RequestDomainTransition(KDmIdRoot, EStartupCriticalStatic, ETraverseDefault, status); |
|
1273 test(status.Int() == KRequestPending); |
|
1274 User::WaitForRequest(status); |
|
1275 test(status.Int() == KErrNone); |
|
1276 manager.Close(); |
|
1277 } |
|
1278 |
|
1279 __UHEAP_MARKEND; |
|
1280 } |
|
1281 |
|
1282 // This handles a transition notification from either a power domain member or |
|
1283 // a test domain member. |
|
1284 // Verifies that the domain state is as expected. |
|
1285 // Updates the number of notifications for each hierarchy and verifies that all parent |
|
1286 // domains have transitioned already (for parent-to-child transitions) or that all child |
|
1287 // domains have been transitioned already (for child-to-parent transitions). |
|
1288 |
|
1289 TInt CDmTest5::TransitionNotification(MDmDomainMember& aDomainMember) |
|
1290 { |
|
1291 if (aDomainMember.HierarchyId() == KDmHierarchyIdPower) |
|
1292 iPowerNotifications++; |
|
1293 else |
|
1294 iTestNotifications++; |
|
1295 |
|
1296 if (aDomainMember.HierarchyId() == KDmHierarchyIdPower) |
|
1297 { |
|
1298 __PRINT((_L("CDmTest5::TransitionNotification(), Hierarchy = %d, iOrdinal = 0x%08X, state = 0x%x, status = %d\n"), |
|
1299 aDomainMember.HierarchyId(), aDomainMember.Ordinal(), aDomainMember.State(), aDomainMember.Status())); |
|
1300 test(aDomainMember.State() == iPowerState); |
|
1301 } |
|
1302 else if (aDomainMember.HierarchyId() == KDmHierarchyIdTest) |
|
1303 { |
|
1304 TBuf16<4> buf; |
|
1305 GetDomainDesc(aDomainMember.Ordinal(), buf); |
|
1306 |
|
1307 __PRINT((_L("CDmTest5::TransitionNotification(), Hierarchy = %d, domain = %S, iOrdinal = 0x%08X, state = 0x%x, status = %d\n"), |
|
1308 aDomainMember.HierarchyId(), &buf, aDomainMember.Ordinal(), aDomainMember.State(), aDomainMember.Status())); |
|
1309 test(aDomainMember.State() == iTestState); |
|
1310 } |
|
1311 else |
|
1312 { |
|
1313 test(0); |
|
1314 } |
|
1315 |
|
1316 // if we're going from parent to child, |
|
1317 // check that each parent domain has received a notification already |
|
1318 // if not, check that each child domain has received a notification already |
|
1319 |
|
1320 CDmTestMember** mp; |
|
1321 |
|
1322 if (aDomainMember.HierarchyId() == KDmHierarchyIdTest && iAckMode == KAckAlways) |
|
1323 { |
|
1324 |
|
1325 if (iTraverseDirection == ETraverseParentsFirst) |
|
1326 { |
|
1327 TUint ordThis = aDomainMember.Ordinal(); |
|
1328 TUint ordParent = PARENT_ORDINAL(ordThis); |
|
1329 |
|
1330 TInt levelParent = ORDINAL_LEVEL(ordParent); |
|
1331 |
|
1332 TBuf16<4> buf; |
|
1333 GetDomainDesc(ordParent, buf); |
|
1334 if (levelParent >= iTestDomainLevel) |
|
1335 { |
|
1336 __PRINT((_L("Searching for parent domain = %S, ordinal = %08X \n"), &buf, ordParent)); |
|
1337 for (mp = iTestMembers; *mp; ++mp) |
|
1338 { |
|
1339 if ((*mp)->Ordinal() == ordParent) |
|
1340 { |
|
1341 TBuf16<4> buf; |
|
1342 GetDomainDesc((*mp)->Ordinal(), buf); |
|
1343 __PRINT((_L("Found parent (%S). notification = %d\n"), &buf, (*mp)->Notifications())); |
|
1344 test ((*mp)->Notifications() == aDomainMember.Notifications()); |
|
1345 break; |
|
1346 } |
|
1347 } |
|
1348 } |
|
1349 } |
|
1350 else |
|
1351 { |
|
1352 __PRINT((_L("Searching for children\n"))); |
|
1353 for (mp = iTestMembers; *mp; ++mp) |
|
1354 { |
|
1355 |
|
1356 TUint ordParent = PARENT_ORDINAL((*mp)->Ordinal()); |
|
1357 if (ordParent == aDomainMember.Ordinal()) |
|
1358 { |
|
1359 TBuf16<4> buf; |
|
1360 GetDomainDesc((*mp)->Ordinal(), buf); |
|
1361 __PRINT((_L("Found child (%S). notification = %d\n"), &buf, (*mp)->Notifications())); |
|
1362 test ((*mp)->Notifications() == aDomainMember.Notifications()); |
|
1363 } |
|
1364 } |
|
1365 } |
|
1366 } |
|
1367 |
|
1368 TInt ackError; |
|
1369 switch (iAckMode) |
|
1370 { |
|
1371 case KAckNever: |
|
1372 ackError = KErrAbort; |
|
1373 break; |
|
1374 case KAckError: // return an error to the DM |
|
1375 ackError = KErrGeneral; |
|
1376 break; |
|
1377 case KAckOddDomainsOnly: |
|
1378 ackError = (aDomainMember.DomainId() & 1)?KErrNone:KErrAbort; |
|
1379 break; |
|
1380 case KAckAlways: |
|
1381 default: |
|
1382 ackError = KErrNone; |
|
1383 break; |
|
1384 } |
|
1385 return ackError; |
|
1386 } |
|
1387 |
|
1388 void CDmTest5::RunL() |
|
1389 { |
|
1390 iTransitionsCompleted++; |
|
1391 |
|
1392 __PRINT((_L("CDmTest5::RunL(), error = %d, iTestNotifications %d, iPowerNotifications %d\n"), |
|
1393 iStatus.Int(), iTestNotifications , iPowerNotifications)); |
|
1394 |
|
1395 if (iTransitionsCompleted == iTransitionsExpected) |
|
1396 CActiveScheduler::Stop(); |
|
1397 } |
|
1398 |
|
1399 void CDmTest5::TransitionRequestComplete() |
|
1400 { |
|
1401 iTransitionsCompleted++; |
|
1402 |
|
1403 __PRINT((_L("CDmTest5::TransitionRequestComplete(), error = %d, iTestNotifications %d, iPowerNotifications %d\n"), |
|
1404 iStatus.Int(), iTestNotifications , iPowerNotifications)); |
|
1405 |
|
1406 if (iTransitionsCompleted == iTransitionsExpected) |
|
1407 CActiveScheduler::Stop(); |
|
1408 } |
|
1409 |
|
1410 void CDmTest5::DoCancel() |
|
1411 { |
|
1412 test(0); |
|
1413 } |
|
1414 |
|
1415 void CDmTest5::Release() |
|
1416 { |
|
1417 delete this; |
|
1418 } |
|
1419 |
|
1420 const TInt KMembersMax = 16; |
|
1421 |
|
1422 // Negative testing |
|
1423 class CDmTest6 : public CActive, public MDmTest |
|
1424 { |
|
1425 public: |
|
1426 enum |
|
1427 { |
|
1428 ENegTestTransitionNoConnect, |
|
1429 ENegTestGetStateNoConnect, |
|
1430 ENegTestTransitionInvalidMode |
|
1431 }; |
|
1432 |
|
1433 class TData |
|
1434 { |
|
1435 public: |
|
1436 inline TData(TInt aTest) : iTest(aTest){}; |
|
1437 TInt iTest; |
|
1438 }; |
|
1439 |
|
1440 public: |
|
1441 // from CActive |
|
1442 void RunL(); |
|
1443 |
|
1444 // from MDmTest |
|
1445 void Perform(); |
|
1446 void Release(); |
|
1447 TInt TransitionNotification(MDmDomainMember& aDomainMember); |
|
1448 void TransitionRequestComplete(); |
|
1449 |
|
1450 |
|
1451 CDmTest6() : CActive(CActive::EPriorityStandard) {} |
|
1452 |
|
1453 protected: |
|
1454 // from CActive |
|
1455 virtual void DoCancel(); |
|
1456 |
|
1457 private: |
|
1458 static TInt PanicThreadFunc(TAny* aData); |
|
1459 void PanicTest(TInt aTestNumber); |
|
1460 |
|
1461 |
|
1462 CDomainMemberAo* iTestMembers[KMembersMax]; |
|
1463 CDomainManagerAo* iTestDomainManager; |
|
1464 |
|
1465 TDmDomainId iTestDomainId; |
|
1466 TDmDomainState iTestState; |
|
1467 |
|
1468 public: |
|
1469 TInt iTestNotifications; |
|
1470 TInt iTestNotificationsExpected; |
|
1471 |
|
1472 TInt iTransitionsCompleted; |
|
1473 TInt iTransitionsExpected; |
|
1474 }; |
|
1475 |
|
1476 TInt CDmTest6::PanicThreadFunc(TAny* aData) |
|
1477 { |
|
1478 const TData* data = (const TData*)aData; |
|
1479 switch (data->iTest) |
|
1480 { |
|
1481 case ENegTestTransitionNoConnect: |
|
1482 { |
|
1483 // request a transition notification without connecting first (should panic) |
|
1484 RDmDomain domainMember; |
|
1485 TRequestStatus status; |
|
1486 User::SetJustInTime(EFalse); |
|
1487 domainMember.RequestTransitionNotification(status); |
|
1488 } |
|
1489 break; |
|
1490 case ENegTestGetStateNoConnect: |
|
1491 { |
|
1492 // Get the domain state without connecting (should panic) |
|
1493 RDmDomain domainMember; |
|
1494 User::SetJustInTime(EFalse); |
|
1495 domainMember.GetState(); |
|
1496 } |
|
1497 break; |
|
1498 case ENegTestTransitionInvalidMode: |
|
1499 { |
|
1500 RDmDomainManager manager; |
|
1501 TRequestStatus status; |
|
1502 TInt r = manager.Connect(KDmHierarchyIdTest); |
|
1503 test(r == KErrNone); |
|
1504 |
|
1505 User::SetJustInTime(EFalse); |
|
1506 manager.RequestDomainTransition(KDmIdRoot, 0, TDmTraverseDirection(-1), status); |
|
1507 } |
|
1508 break; |
|
1509 default: |
|
1510 break; |
|
1511 } |
|
1512 return KErrNone; |
|
1513 } |
|
1514 |
|
1515 void CDmTest6::PanicTest(TInt aTestNumber) |
|
1516 { |
|
1517 test.Printf(_L("panic test number %d\n"), aTestNumber); |
|
1518 |
|
1519 TBool jit = User::JustInTime(); |
|
1520 |
|
1521 TData data(aTestNumber); |
|
1522 |
|
1523 TInt KHeapSize=0x2000; |
|
1524 |
|
1525 RThread thread; |
|
1526 TInt ret = thread.Create(KThreadName, PanicThreadFunc, KDefaultStackSize, KHeapSize, KHeapSize, &data); |
|
1527 test(KErrNone == ret); |
|
1528 TRequestStatus stat; |
|
1529 thread.Logon(stat); |
|
1530 thread.Resume(); |
|
1531 User::WaitForRequest(stat); |
|
1532 |
|
1533 User::SetJustInTime(jit); |
|
1534 |
|
1535 // The thread must panic |
|
1536 test(thread.ExitType() == EExitPanic); |
|
1537 TInt exitReason = thread.ExitReason(); |
|
1538 test.Printf(_L("panic test exit reason = %d\n"), exitReason); |
|
1539 |
|
1540 switch(aTestNumber) |
|
1541 { |
|
1542 case ENegTestTransitionNoConnect: |
|
1543 test (exitReason == EBadHandle); |
|
1544 break; |
|
1545 case ENegTestGetStateNoConnect: |
|
1546 test (exitReason == EBadHandle); |
|
1547 break; |
|
1548 case ENegTestTransitionInvalidMode: |
|
1549 break; |
|
1550 default: |
|
1551 break; |
|
1552 } |
|
1553 |
|
1554 CLOSE_AND_WAIT(thread); |
|
1555 } |
|
1556 |
|
1557 |
|
1558 //! @SYMTestCaseID PBASE-T_DOMAIN-6 |
|
1559 //! @SYMTestType CT |
|
1560 //! @SYMTestCaseDesc Negative testing |
|
1561 //! @SYMPREQ 810 |
|
1562 //! @SYMTestActions Various negative tests |
|
1563 //! @SYMTestExpectedResults All tests should pass |
|
1564 //! @SYMTestPriority High |
|
1565 //! @SYMTestStatus Defined |
|
1566 void CDmTest6::Perform() |
|
1567 { |
|
1568 |
|
1569 __UHEAP_MARK; |
|
1570 |
|
1571 CActiveScheduler::Add(this); |
|
1572 |
|
1573 CDomainManagerAo* iTestDomainManager = NULL; |
|
1574 TRAP_IGNORE(iTestDomainManager = CDomainManagerAo::NewL(KDmHierarchyIdTest, *this)); |
|
1575 test (iTestDomainManager != NULL); |
|
1576 |
|
1577 TInt r = CDomainManagerAo::AddDomainHierarchy(KDmHierarchyIdTest); |
|
1578 test(r == KErrNone); |
|
1579 |
|
1580 //************************************************* |
|
1581 // Test 6a - Connect to the same hierarchy twice |
|
1582 //************************************************* |
|
1583 test.Next(_L("Test 6a - Connect to the same hierarchy twice")); |
|
1584 |
|
1585 // verify that we can't connect to the same hierarchy more than once |
|
1586 CDomainManagerAo* testDomainManager = NULL; |
|
1587 TRAP(r, testDomainManager = CDomainManagerAo::NewL(KDmHierarchyIdTest, *this)); |
|
1588 test(r == KErrInUse); |
|
1589 test (testDomainManager == NULL); |
|
1590 |
|
1591 |
|
1592 TInt testMemberCount = 0; |
|
1593 |
|
1594 // Add some test hierarchy members |
|
1595 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdRoot, ORDINAL_FROM_DOMAINID0(KDmIdRoot), this)); |
|
1596 test(iTestMembers[testMemberCount++] != NULL); |
|
1597 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdRoot, ORDINAL_FROM_DOMAINID0(KDmIdRoot), this)); |
|
1598 test(iTestMembers[testMemberCount++] != NULL); |
|
1599 |
|
1600 // row 1 |
|
1601 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestA, ORDINAL_FROM_DOMAINID1(KDmIdRoot, KDmIdTestA), this)); |
|
1602 test(iTestMembers[testMemberCount++] != NULL); |
|
1603 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestB, ORDINAL_FROM_DOMAINID1(KDmIdRoot, KDmIdTestB), this)); |
|
1604 test(iTestMembers[testMemberCount++] != NULL); |
|
1605 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestC, ORDINAL_FROM_DOMAINID1(KDmIdRoot, KDmIdTestC), this)); |
|
1606 test(iTestMembers[testMemberCount++] != NULL); |
|
1607 |
|
1608 // row2 |
|
1609 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestAA, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestA, KDmIdTestAA), this)); |
|
1610 test(iTestMembers[testMemberCount++] != NULL); |
|
1611 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestAB, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestA, KDmIdTestAB), this)); |
|
1612 test(iTestMembers[testMemberCount++] != NULL); |
|
1613 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestBA, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestB, KDmIdTestBA), this)); |
|
1614 test(iTestMembers[testMemberCount++] != NULL); |
|
1615 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestCA, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestC, KDmIdTestCA), this)); |
|
1616 test(iTestMembers[testMemberCount++] != NULL); |
|
1617 |
|
1618 // row 3 |
|
1619 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestABA, ORDINAL_FROM_DOMAINID3(KDmIdRoot, KDmIdTestA, KDmIdTestAB, KDmIdTestABA), this)); |
|
1620 test(iTestMembers[testMemberCount++] != NULL); |
|
1621 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestABB, ORDINAL_FROM_DOMAINID3(KDmIdRoot, KDmIdTestA, KDmIdTestAB, KDmIdTestABB), this)); |
|
1622 test(iTestMembers[testMemberCount++] != NULL); |
|
1623 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestCAA, ORDINAL_FROM_DOMAINID3(KDmIdRoot, KDmIdTestC, KDmIdTestCA, KDmIdTestCAA), this)); |
|
1624 test(iTestMembers[testMemberCount++] != NULL); |
|
1625 |
|
1626 |
|
1627 //************************************************* |
|
1628 // Test 6b change to current state |
|
1629 //************************************************* |
|
1630 test.Next(_L("Test 6b change to current state")); |
|
1631 iTestState = EStartupCriticalStatic; |
|
1632 iTestDomainId = KDmIdRoot; |
|
1633 |
|
1634 iTransitionsCompleted = iTestNotifications = 0; |
|
1635 iTestNotificationsExpected = testMemberCount; |
|
1636 iTransitionsExpected = 1; |
|
1637 |
|
1638 // request a domain transition |
|
1639 iTestDomainManager->RequestDomainTransition(iTestDomainId, iTestState, ETraverseDefault); |
|
1640 |
|
1641 // wait for test transitions to complete |
|
1642 CActiveScheduler::Start(); |
|
1643 test(iStatus == KErrNone); |
|
1644 test(iTestNotifications == iTestNotificationsExpected); |
|
1645 |
|
1646 |
|
1647 // cancel a member notification request |
|
1648 //************************************************* |
|
1649 // Test 6c cancel a member notification request |
|
1650 //************************************************* |
|
1651 test.Next(_L("Test 6c cancel a member notification request")); |
|
1652 RDmDomain domainMember; |
|
1653 TRequestStatus status; |
|
1654 domainMember.Connect(KDmHierarchyIdTest, iTestDomainId); |
|
1655 domainMember.RequestTransitionNotification(status); |
|
1656 domainMember.CancelTransitionNotification(); |
|
1657 User::WaitForRequest(status); |
|
1658 domainMember.Close(); |
|
1659 |
|
1660 //************************************************* |
|
1661 // Test 6d cancel a member notification request without having first requested a notification |
|
1662 //************************************************* |
|
1663 test.Next(_L("Test 6d cancel a member notification request without having first requested a notification")); |
|
1664 domainMember.Connect(KDmHierarchyIdTest, iTestDomainId); |
|
1665 domainMember.CancelTransitionNotification(); |
|
1666 domainMember.Close(); |
|
1667 |
|
1668 //************************************************* |
|
1669 // Test 6e domain controller adds invalid hierarchy |
|
1670 //************************************************* |
|
1671 test.Next(_L("Test 6e domain controller connects to invalid hierarchy")); |
|
1672 r = RDmDomainManager::AddDomainHierarchy(TDmHierarchyId(-1)); |
|
1673 test(r == KErrBadHierarchyId); |
|
1674 |
|
1675 //************************************************* |
|
1676 // Test 6f domain member connects to invalid hierarchy |
|
1677 //************************************************* |
|
1678 test.Next(_L("Test 6f domain member connects to invalid hierarchy")); |
|
1679 r = domainMember.Connect(TDmHierarchyId(-1), TDmDomainId(KDmIdRoot)); |
|
1680 test (r == KErrBadHierarchyId); |
|
1681 |
|
1682 //************************************************* |
|
1683 // Test 6g domain member connects to valid hierarchy but invalid domain |
|
1684 //************************************************* |
|
1685 test.Next(_L("Test 6g domain member connects to valid hierarchy but invalid domain")); |
|
1686 r = domainMember.Connect(KDmHierarchyIdTest, TDmDomainId(-1)); |
|
1687 test (r == KDmErrBadDomainId); |
|
1688 |
|
1689 delete iTestDomainManager; |
|
1690 iTestDomainManager = NULL; |
|
1691 |
|
1692 // Panic tests |
|
1693 |
|
1694 //************************************************* |
|
1695 // Test 6h request a transition notification without connecting first |
|
1696 //************************************************* |
|
1697 test.Next(_L("Test 6h request a transition notification without connecting first")); |
|
1698 PanicTest(ENegTestTransitionNoConnect); |
|
1699 |
|
1700 //************************************************* |
|
1701 // Test 6i Get the domain state without connecting |
|
1702 //************************************************* |
|
1703 test.Next(_L("Test 6i Get the domain state without connecting")); |
|
1704 PanicTest(ENegTestGetStateNoConnect); |
|
1705 |
|
1706 //************************************************* |
|
1707 // Test 6j request a transition notification with an invalid transition mode |
|
1708 //************************************************* |
|
1709 test.Next(_L("Test 6j request a transition notification with an invalid transition mode")); |
|
1710 PanicTest(ENegTestTransitionInvalidMode); |
|
1711 |
|
1712 |
|
1713 // cleanup |
|
1714 |
|
1715 CDomainMemberAo** mt; |
|
1716 for (mt = iTestMembers; *mt; ++mt) |
|
1717 delete *mt; |
|
1718 |
|
1719 __UHEAP_MARKEND; |
|
1720 } |
|
1721 |
|
1722 // This handles a transition notification from a test domain member. |
|
1723 TInt CDmTest6::TransitionNotification(MDmDomainMember& aDomainMember) |
|
1724 { |
|
1725 TInt status = aDomainMember.Status(); |
|
1726 |
|
1727 iTestNotifications++; |
|
1728 |
|
1729 test (aDomainMember.HierarchyId() == KDmHierarchyIdTest); |
|
1730 |
|
1731 TBuf16<4> buf; |
|
1732 GetDomainDesc(aDomainMember.Ordinal(), buf); |
|
1733 |
|
1734 test.Printf(_L("CDmTest6::TransitionNotification(), Hierarchy = %d, domain = %S, iOrdinal = 0x%08X, state = 0x%x, status = %d\n"), |
|
1735 aDomainMember.HierarchyId(), &buf, aDomainMember.Ordinal(), aDomainMember.State(), status); |
|
1736 |
|
1737 |
|
1738 return KErrNone; |
|
1739 } |
|
1740 |
|
1741 void CDmTest6::RunL() |
|
1742 { |
|
1743 iTransitionsCompleted++; |
|
1744 |
|
1745 TInt error = iStatus.Int(); |
|
1746 |
|
1747 test.Printf(_L("CDmTest6::RunL(), error = %d, iTestNotifications %d\n"), |
|
1748 error, iTestNotifications); |
|
1749 |
|
1750 if (iTransitionsCompleted == iTransitionsExpected) |
|
1751 CActiveScheduler::Stop(); |
|
1752 } |
|
1753 |
|
1754 void CDmTest6::TransitionRequestComplete() |
|
1755 { |
|
1756 iTransitionsCompleted++; |
|
1757 |
|
1758 TInt error = iStatus.Int(); |
|
1759 |
|
1760 test.Printf(_L("CDmTest6::TransitionRequestComplete(), error = %d, iTestNotifications %d\n"), |
|
1761 error, iTestNotifications); |
|
1762 |
|
1763 if (iTransitionsCompleted == iTransitionsExpected) |
|
1764 CActiveScheduler::Stop(); |
|
1765 } |
|
1766 |
|
1767 void CDmTest6::DoCancel() |
|
1768 { |
|
1769 test(0); |
|
1770 } |
|
1771 |
|
1772 void CDmTest6::Release() |
|
1773 { |
|
1774 delete this; |
|
1775 } |
|
1776 |
|
1777 // Transition progress Observer testing |
|
1778 class CDmTest7 : public CActive, public MDmTest, public MHierarchyObserver |
|
1779 { |
|
1780 public: |
|
1781 // from CActive |
|
1782 void RunL(); |
|
1783 |
|
1784 // from MDmTest |
|
1785 void Perform(); |
|
1786 void Release(); |
|
1787 TInt TransitionNotification(MDmDomainMember& aDomainMember); |
|
1788 void TransitionRequestComplete(); |
|
1789 |
|
1790 // from MHierarchyObserver |
|
1791 virtual void TransProgEvent(TDmDomainId aDomainId, TDmDomainState aState); |
|
1792 virtual void TransFailEvent(TDmDomainId aDomainId, TDmDomainState aState, TInt aError); |
|
1793 virtual void TransReqEvent(TDmDomainId aDomainId, TDmDomainState aState); |
|
1794 |
|
1795 |
|
1796 |
|
1797 CDmTest7(TDmDomainId aDomainId) : CActive(CActive::EPriorityStandard), iObservedDomainId(aDomainId) {} |
|
1798 |
|
1799 protected: |
|
1800 // from CActive |
|
1801 virtual void DoCancel(); |
|
1802 |
|
1803 private: |
|
1804 void TestForCompletion(); |
|
1805 |
|
1806 |
|
1807 private: |
|
1808 |
|
1809 enum { KMembersMax = 16 }; |
|
1810 |
|
1811 CDomainMemberAo* iTestMembers[KMembersMax]; |
|
1812 CDomainManagerAo* iTestDomainManager; |
|
1813 |
|
1814 TDmDomainId iTestDomainId; |
|
1815 TDmDomainState iTestState; |
|
1816 TDmDomainId iObservedDomainId; |
|
1817 |
|
1818 public: |
|
1819 TInt iTestNotifications; |
|
1820 TInt iTestNotificationsExpected; |
|
1821 |
|
1822 TInt iTransitionsCompleted; |
|
1823 TInt iTransitionsExpected; |
|
1824 |
|
1825 TInt iTransProgEvents; |
|
1826 TInt iTransFailEvents; |
|
1827 TInt iTransReqEvents; |
|
1828 |
|
1829 TInt iTransProgEventsExpected; |
|
1830 TInt iTransFailEventsExpected; |
|
1831 TInt iTransReqEventsExpected; |
|
1832 }; |
|
1833 |
|
1834 //! @SYMTestCaseID PBASE-T_DOMAIN-7 |
|
1835 //! @SYMTestType CT |
|
1836 //! @SYMTestCaseDesc Transition progress Observer testing |
|
1837 //! @SYMREQ REQ3723 |
|
1838 //! @SYMTestActions Various negative tests |
|
1839 //! @SYMTestExpectedResults All tests should pass |
|
1840 //! @SYMTestPriority High |
|
1841 //! @SYMTestStatus Defined |
|
1842 void CDmTest7::Perform() |
|
1843 { |
|
1844 |
|
1845 __UHEAP_MARK; |
|
1846 |
|
1847 // |
|
1848 // Test domain transitions with activated observer |
|
1849 // |
|
1850 CActiveScheduler::Add(this); |
|
1851 |
|
1852 TInt r = RDmDomainManager::AddDomainHierarchy(KDmHierarchyIdTest); |
|
1853 test(r == KErrNone); |
|
1854 |
|
1855 CDomainManagerAo* iTestDomainManager = NULL; |
|
1856 TRAP_IGNORE(iTestDomainManager = CDomainManagerAo::NewL(KDmHierarchyIdTest, *this)); |
|
1857 test (iTestDomainManager != NULL); |
|
1858 |
|
1859 r = CDomainManagerAo::AddDomainHierarchy(KDmHierarchyIdTest); |
|
1860 test(r == KErrNone); |
|
1861 |
|
1862 //************************************************* |
|
1863 // Test 7a - Testing observer notifications |
|
1864 //************************************************* |
|
1865 |
|
1866 test.Next(_L("Test 7a - Testing observer notifications")); |
|
1867 |
|
1868 TInt testMemberCount = 0; |
|
1869 |
|
1870 // Add some test hierarchy members |
|
1871 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdRoot, ORDINAL_FROM_DOMAINID0(KDmIdRoot), this)); |
|
1872 test(iTestMembers[testMemberCount++] != NULL); |
|
1873 |
|
1874 // row 1 |
|
1875 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestA, ORDINAL_FROM_DOMAINID1(KDmIdRoot, KDmIdTestA), this)); |
|
1876 test(iTestMembers[testMemberCount++] != NULL); |
|
1877 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestB, ORDINAL_FROM_DOMAINID1(KDmIdRoot, KDmIdTestB), this)); |
|
1878 test(iTestMembers[testMemberCount++] != NULL); |
|
1879 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestC, ORDINAL_FROM_DOMAINID1(KDmIdRoot, KDmIdTestC), this)); |
|
1880 test(iTestMembers[testMemberCount++] != NULL); |
|
1881 |
|
1882 // row2 |
|
1883 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestAA, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestA, KDmIdTestAA), this)); |
|
1884 test(iTestMembers[testMemberCount++] != NULL); |
|
1885 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestAB, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestA, KDmIdTestAB), this)); |
|
1886 test(iTestMembers[testMemberCount++] != NULL); |
|
1887 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestBA, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestB, KDmIdTestBA), this)); |
|
1888 test(iTestMembers[testMemberCount++] != NULL); |
|
1889 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestCA, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestC, KDmIdTestCA), this)); |
|
1890 test(iTestMembers[testMemberCount++] != NULL); |
|
1891 |
|
1892 // row 3 |
|
1893 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestABA, ORDINAL_FROM_DOMAINID3(KDmIdRoot, KDmIdTestA, KDmIdTestAB, KDmIdTestABA), this)); |
|
1894 test(iTestMembers[testMemberCount++] != NULL); |
|
1895 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestABB, ORDINAL_FROM_DOMAINID3(KDmIdRoot, KDmIdTestA, KDmIdTestAB, KDmIdTestABB), this)); |
|
1896 test(iTestMembers[testMemberCount++] != NULL); |
|
1897 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestCAA, ORDINAL_FROM_DOMAINID3(KDmIdRoot, KDmIdTestC, KDmIdTestCA, KDmIdTestCAA), this)); |
|
1898 test(iTestMembers[testMemberCount++] != NULL); |
|
1899 |
|
1900 // create an observer |
|
1901 CHierarchyObserver* observer = NULL; |
|
1902 TRAP(r, observer = CHierarchyObserver::NewL(*this, KDmHierarchyIdTest)); |
|
1903 test (r == KErrNone); |
|
1904 test(observer != NULL); |
|
1905 observer->StartObserver(iObservedDomainId, EDmNotifyAll); |
|
1906 |
|
1907 // request a state change |
|
1908 iTestState = EStartupCriticalDynamic; |
|
1909 iTestDomainId = KDmIdRoot; |
|
1910 iTransitionsCompleted = iTestNotifications = 0; |
|
1911 iTestNotificationsExpected = testMemberCount; |
|
1912 iTransitionsExpected = 1; |
|
1913 |
|
1914 iTransProgEvents = iTransFailEvents = iTransReqEvents = 0; |
|
1915 |
|
1916 iTransReqEventsExpected = iTransProgEventsExpected = observer->ObserverDomainCount(); |
|
1917 iTransFailEventsExpected = 0; |
|
1918 |
|
1919 |
|
1920 iTestDomainManager->RequestDomainTransition(iTestDomainId, iTestState, ETraverseDefault); |
|
1921 |
|
1922 // wait for test transitions to complete |
|
1923 CActiveScheduler::Start(); |
|
1924 test(iStatus == KErrNone); |
|
1925 test(iTestNotifications == iTestNotificationsExpected); |
|
1926 test (iTransProgEvents == iTransProgEventsExpected); |
|
1927 test (iTransFailEvents == iTransFailEventsExpected); |
|
1928 test (iTransReqEvents == iTransReqEventsExpected); |
|
1929 |
|
1930 |
|
1931 // cleanup |
|
1932 delete observer; |
|
1933 observer = NULL; |
|
1934 |
|
1935 //************************************************* |
|
1936 // Test 7b - start & stop the observer |
|
1937 //************************************************* |
|
1938 test.Next(_L("Test 7b - start & stop the observer")); |
|
1939 |
|
1940 // create an observer, start it stop and then start it again |
|
1941 TRAP(r, observer = CHierarchyObserver::NewL(*this, KDmHierarchyIdTest)); |
|
1942 test (r == KErrNone); |
|
1943 test(observer != NULL); |
|
1944 observer->StartObserver(iObservedDomainId, EDmNotifyAll); |
|
1945 observer->StopObserver(); |
|
1946 observer->StartObserver(iObservedDomainId, EDmNotifyAll); |
|
1947 |
|
1948 // request a state change |
|
1949 iTestState++; |
|
1950 iTestDomainId = KDmIdRoot; |
|
1951 iTransitionsCompleted = iTestNotifications = 0; |
|
1952 iTestNotificationsExpected = testMemberCount; |
|
1953 iTransitionsExpected = 1; |
|
1954 |
|
1955 iTransProgEvents = iTransFailEvents = iTransReqEvents = 0; |
|
1956 |
|
1957 iTransProgEventsExpected = iTransReqEventsExpected = observer->ObserverDomainCount(); |
|
1958 iTransFailEventsExpected = 0; |
|
1959 |
|
1960 iTestDomainManager->RequestDomainTransition(iTestDomainId, iTestState, ETraverseDefault); |
|
1961 |
|
1962 // wait for test transitions to complete |
|
1963 CActiveScheduler::Start(); |
|
1964 test(iStatus == KErrNone); |
|
1965 test(iTestNotifications == iTestNotificationsExpected); |
|
1966 test (iTransProgEvents == iTransProgEventsExpected); |
|
1967 test (iTransFailEvents == iTransFailEventsExpected); |
|
1968 test (iTransReqEvents == iTransReqEventsExpected); |
|
1969 |
|
1970 // stop the observer & request another state change |
|
1971 observer->StopObserver(); |
|
1972 iTestState++; |
|
1973 iTestDomainId = KDmIdRoot; |
|
1974 iTransitionsCompleted = iTestNotifications = 0; |
|
1975 iTestNotificationsExpected = testMemberCount; |
|
1976 iTransitionsExpected = 1; |
|
1977 |
|
1978 iTransProgEvents = iTransFailEvents = iTransReqEvents = 0; |
|
1979 |
|
1980 iTransProgEventsExpected = 0; |
|
1981 iTransFailEventsExpected = 0; |
|
1982 iTransReqEventsExpected = 0; |
|
1983 |
|
1984 iTestDomainManager->RequestDomainTransition(iTestDomainId, iTestState, ETraverseDefault); |
|
1985 // wait for test transitions to complete |
|
1986 CActiveScheduler::Start(); |
|
1987 test(iStatus == KErrNone); |
|
1988 test(iTestNotifications == iTestNotificationsExpected); |
|
1989 test (iTransProgEvents == iTransProgEventsExpected); |
|
1990 test (iTransFailEvents == iTransFailEventsExpected); |
|
1991 test (iTransReqEvents == iTransReqEventsExpected); |
|
1992 |
|
1993 // Start the observer again on a different domain and only ask for transition requests |
|
1994 // Then request another state change |
|
1995 observer->StartObserver((iObservedDomainId == KDmIdRoot)?KDmIdTestCA:KDmIdRoot, EDmNotifyTransRequest); |
|
1996 iTestState++; |
|
1997 iTestDomainId = KDmIdRoot; |
|
1998 iTransitionsCompleted = iTestNotifications = 0; |
|
1999 iTestNotificationsExpected = testMemberCount; |
|
2000 iTransitionsExpected = 1; |
|
2001 |
|
2002 iTransProgEvents = iTransFailEvents = iTransReqEvents = 0; |
|
2003 |
|
2004 iTransReqEventsExpected = observer->ObserverDomainCount(); |
|
2005 iTransProgEventsExpected = 0; |
|
2006 iTransFailEventsExpected = 0; |
|
2007 |
|
2008 |
|
2009 iTestDomainManager->RequestDomainTransition(iTestDomainId, iTestState, ETraverseDefault); |
|
2010 // wait for test transitions to complete |
|
2011 CActiveScheduler::Start(); |
|
2012 test(iStatus == KErrNone); |
|
2013 test(iTestNotifications == iTestNotificationsExpected); |
|
2014 test (iTransProgEvents == iTransProgEventsExpected); |
|
2015 test (iTransFailEvents == iTransFailEventsExpected); |
|
2016 test (iTransReqEvents == iTransReqEventsExpected); |
|
2017 |
|
2018 delete observer; |
|
2019 observer = NULL; |
|
2020 |
|
2021 //************************************************* |
|
2022 // Test 7c - invalid arguments testing for observer |
|
2023 //************************************************* |
|
2024 test.Next(_L("Test 7c - Invalid arguments testing for observer")); |
|
2025 |
|
2026 const TDmHierarchyId KDmHierarchyIdInvalid = 110; |
|
2027 |
|
2028 test.Printf(_L("Test 7c.1 - create observer with invalid hierarchy Id\n")); |
|
2029 |
|
2030 // create an observer |
|
2031 TRAP(r, observer = CHierarchyObserver::NewL(*this, KDmHierarchyIdInvalid)); |
|
2032 test (r == KErrBadHierarchyId); |
|
2033 |
|
2034 |
|
2035 test.Printf(_L("Test 7c.2 - Starting the observer with wrong domain Id\n")); |
|
2036 TRAP(r, observer = CHierarchyObserver::NewL(*this, KDmHierarchyIdTest)); |
|
2037 test (r == KErrNone); |
|
2038 test(observer != NULL); |
|
2039 |
|
2040 //Wrong domain Id |
|
2041 const TDmDomainId KDmIdInvalid = 0x0f; |
|
2042 r= observer->StartObserver(KDmIdInvalid, EDmNotifyAll); |
|
2043 test(r==KDmErrBadDomainId); |
|
2044 |
|
2045 test.Printf(_L("Test 7c.3 - Trying to create second observer on the same hierarchy\n")); |
|
2046 TRAP(r, CHierarchyObserver::NewL(*this, KDmHierarchyIdTest)); |
|
2047 test (r == KDmErrBadSequence); |
|
2048 |
|
2049 |
|
2050 |
|
2051 //************************************************* |
|
2052 // Test 7d - Wrong sequence of API calls for observer |
|
2053 //************************************************* |
|
2054 test.Next(_L("Test 7d - Observer wrong sequence of calls")); |
|
2055 |
|
2056 test.Printf(_L("Test 7d.1 - Stopping Observer before starting it\n")); |
|
2057 r = observer->StopObserver(); |
|
2058 test(r==KDmErrBadSequence); |
|
2059 |
|
2060 test.Printf(_L("Test 7d.2 - Starting Observer twice\n")); |
|
2061 r= observer->StartObserver(KDmIdRoot, EDmNotifyAll); |
|
2062 test(r==KErrNone); |
|
2063 |
|
2064 r= observer->StartObserver(KDmIdRoot, EDmNotifyAll); |
|
2065 test(r==KDmErrBadSequence); |
|
2066 |
|
2067 |
|
2068 delete observer; |
|
2069 |
|
2070 /***************************************/ |
|
2071 |
|
2072 delete iTestDomainManager; |
|
2073 iTestDomainManager = NULL; |
|
2074 |
|
2075 CDomainMemberAo** mt; |
|
2076 for (mt = iTestMembers; *mt; ++mt) |
|
2077 delete *mt; |
|
2078 |
|
2079 |
|
2080 // restore the domain hierarchies to their initial state so as not to |
|
2081 // upset any subsequent tests which rely on this |
|
2082 { |
|
2083 RDmDomainManager manager; |
|
2084 TRequestStatus status; |
|
2085 TInt r = manager.Connect(KDmHierarchyIdTest); |
|
2086 test (r == KErrNone); |
|
2087 manager.RequestDomainTransition(KDmIdRoot, EStartupCriticalStatic, ETraverseDefault, status); |
|
2088 test(status.Int() == KRequestPending); |
|
2089 User::WaitForRequest(status); |
|
2090 test(status.Int() == KErrNone); |
|
2091 manager.Close(); |
|
2092 } |
|
2093 |
|
2094 __UHEAP_MARKEND; |
|
2095 } |
|
2096 |
|
2097 // This handles a transition notification from a test domain member. |
|
2098 TInt CDmTest7::TransitionNotification(MDmDomainMember& aDomainMember) |
|
2099 { |
|
2100 |
|
2101 iTestNotifications++; |
|
2102 |
|
2103 test (aDomainMember.HierarchyId() == KDmHierarchyIdTest); |
|
2104 |
|
2105 TBuf16<4> buf; |
|
2106 GetDomainDesc(aDomainMember.Ordinal(), buf); |
|
2107 |
|
2108 __PRINT((_L("CDmTest7::TransitionNotification(), Hierarchy = %d, domain = %S, iOrdinal = 0x%08X, state = 0x%x, status = %d\n"), |
|
2109 aDomainMember.HierarchyId(), &buf, aDomainMember.Ordinal(), aDomainMember.State(), aDomainMember.Status())); |
|
2110 |
|
2111 return KErrNone; |
|
2112 } |
|
2113 |
|
2114 void CDmTest7::RunL() |
|
2115 { |
|
2116 iTransitionsCompleted++; |
|
2117 |
|
2118 __PRINT((_L("CDmTest7::RunL(), error = %d, iTestNotifications %d\n"), |
|
2119 iStatus.Int(), iTestNotifications)); |
|
2120 |
|
2121 TestForCompletion(); |
|
2122 } |
|
2123 |
|
2124 void CDmTest7::TransitionRequestComplete() |
|
2125 { |
|
2126 iTransitionsCompleted++; |
|
2127 |
|
2128 __PRINT((_L("CDmTest7::TransitionRequestComplete(), error = %d, iTestNotifications %d\n"), |
|
2129 iStatus.Int(), iTestNotifications)); |
|
2130 |
|
2131 TestForCompletion(); |
|
2132 } |
|
2133 |
|
2134 void CDmTest7::DoCancel() |
|
2135 { |
|
2136 test(0); |
|
2137 } |
|
2138 |
|
2139 void CDmTest7::Release() |
|
2140 { |
|
2141 delete this; |
|
2142 } |
|
2143 |
|
2144 void CDmTest7::TestForCompletion() |
|
2145 { |
|
2146 |
|
2147 if (iTransitionsCompleted == iTransitionsExpected && |
|
2148 iTransProgEvents == iTransProgEventsExpected && |
|
2149 iTransFailEvents == iTransFailEventsExpected && |
|
2150 iTransReqEvents == iTransReqEventsExpected) |
|
2151 { |
|
2152 CActiveScheduler::Stop(); |
|
2153 } |
|
2154 } |
|
2155 |
|
2156 #ifdef _DEBUG |
|
2157 void CDmTest7::TransProgEvent(TDmDomainId aDomainId, TDmDomainState aState) |
|
2158 #else |
|
2159 void CDmTest7::TransProgEvent(TDmDomainId /*aDomainId*/, TDmDomainState /*aState*/) |
|
2160 #endif |
|
2161 { |
|
2162 iTransProgEvents++; |
|
2163 __PRINT((_L("CDmTest7::TransProgEvent(), aDomainId = %d, aState %d, iTransProgEvents %d\n"), |
|
2164 aDomainId, aState, iTransProgEvents)); |
|
2165 TestForCompletion(); |
|
2166 } |
|
2167 |
|
2168 #ifdef _DEBUG |
|
2169 void CDmTest7::TransFailEvent(TDmDomainId aDomainId, TDmDomainState aState, TInt aError) |
|
2170 #else |
|
2171 void CDmTest7::TransFailEvent(TDmDomainId /*aDomainId*/, TDmDomainState /*aState*/, TInt /*aError*/) |
|
2172 #endif |
|
2173 |
|
2174 { |
|
2175 iTransFailEvents++; |
|
2176 __PRINT((_L("CDmTest7::TransFailEvent(), aDomainId = %d, aState %d aError %d, iTransFailEvents %d\n"), |
|
2177 aDomainId, aState, iTransFailEvents, aError)); |
|
2178 TestForCompletion(); |
|
2179 } |
|
2180 |
|
2181 #ifdef _DEBUG |
|
2182 void CDmTest7::TransReqEvent(TDmDomainId aDomainId, TDmDomainState aState) |
|
2183 #else |
|
2184 void CDmTest7::TransReqEvent(TDmDomainId /*aDomainId*/, TDmDomainState /*aState*/) |
|
2185 #endif |
|
2186 { |
|
2187 iTransReqEvents++; |
|
2188 __PRINT((_L("CDmTest7::TransReqEvent(), aDomainId = %d, aState %d, iTransReqEvents %d\n"), |
|
2189 aDomainId, aState, iTransReqEvents)); |
|
2190 TestForCompletion(); |
|
2191 } |
|
2192 |
|
2193 GLDEF_C TInt E32Main() |
|
2194 { |
|
2195 CTrapCleanup* trapHandler=CTrapCleanup::New(); |
|
2196 test(trapHandler!=NULL); |
|
2197 |
|
2198 CActiveScheduler* scheduler = new CActiveScheduler(); |
|
2199 test(scheduler != NULL); |
|
2200 CActiveScheduler::Install(scheduler); |
|
2201 |
|
2202 // Turn off evil lazy dll unloading |
|
2203 RLoader l; |
|
2204 test(l.Connect()==KErrNone); |
|
2205 test(l.CancelLazyDllUnload()==KErrNone); |
|
2206 l.Close(); |
|
2207 |
|
2208 // |
|
2209 // Perform the number of iterations specifed by the command line argument. |
|
2210 // |
|
2211 // If no arguments - perform two iterations |
|
2212 // |
|
2213 // TInt iter = 2; |
|
2214 TInt iter = 1; |
|
2215 |
|
2216 TInt len = User::CommandLineLength(); |
|
2217 if (len) |
|
2218 { |
|
2219 // Copy the command line in a buffer |
|
2220 HBufC* hb = HBufC::NewMax(len); |
|
2221 test(hb != NULL); |
|
2222 TPtr cmd((TUint16*) hb->Ptr(), len); |
|
2223 User::CommandLine(cmd); |
|
2224 // Extract the number of iterations |
|
2225 TLex l(cmd); |
|
2226 TInt i; |
|
2227 TInt r = l.Val(i); |
|
2228 if (r == KErrNone) |
|
2229 iter = i; |
|
2230 else |
|
2231 // strange command - silently ignore |
|
2232 {} |
|
2233 delete hb; |
|
2234 } |
|
2235 |
|
2236 test.Title(); |
|
2237 test.Start(_L("Testing")); |
|
2238 |
|
2239 test.Printf(_L("Go for %d iterations\n"), iter); |
|
2240 |
|
2241 // Remember the number of open handles. Just for a sanity check .... |
|
2242 TInt start_thc, start_phc; |
|
2243 RThread().HandleCount(start_phc, start_thc); |
|
2244 |
|
2245 while (iter--) |
|
2246 { |
|
2247 MDmTest* tests[] = |
|
2248 { |
|
2249 new CDmTest1(KDmIdRoot, EPwStandby), |
|
2250 new CDmTest1(KDmIdRoot, EPwOff), |
|
2251 new CDmTest1(KDmIdRoot, EPwActive), |
|
2252 new CDmTest1(KDmIdApps, EPwStandby), |
|
2253 new CDmTest1(KDmIdApps, EPwOff), |
|
2254 new CDmTest1(KDmIdApps, EPwActive), |
|
2255 new CDmTest1(KDmIdUiApps, EPwStandby), |
|
2256 new CDmTest1(KDmIdUiApps, EPwOff), |
|
2257 new CDmTest1(KDmIdUiApps, EPwActive), |
|
2258 new CDmTest2(EPwStandby), |
|
2259 new CDmTest3(), |
|
2260 |
|
2261 // platform security tests |
|
2262 new CDmTest4(), |
|
2263 |
|
2264 // PREQ810 tests : |
|
2265 // note that we use a fictitious power state to prevent any |
|
2266 new CDmTest5(KDmIdRoot, KDmIdRoot, EPwActive+10, EStartupCriticalDynamic), |
|
2267 new CDmTest5(KDmIdUiApps, KDmIdTestAB, EPwActive+10, EStartupCriticalDynamic), |
|
2268 |
|
2269 // negative tests |
|
2270 new CDmTest6(), |
|
2271 |
|
2272 |
|
2273 // observer tests |
|
2274 new CDmTest7(KDmIdTestA), |
|
2275 new CDmTest7(KDmIdRoot), |
|
2276 |
|
2277 }; |
|
2278 |
|
2279 for (unsigned int i = 0; i < sizeof(tests)/sizeof(*tests); ++i) |
|
2280 { |
|
2281 test(tests[i] != NULL); |
|
2282 tests[i]->Perform(); |
|
2283 tests[i]->Release(); |
|
2284 } |
|
2285 |
|
2286 } |
|
2287 |
|
2288 test.End(); |
|
2289 |
|
2290 // Sanity check for open handles and for pending requests ... |
|
2291 TInt end_thc, end_phc; |
|
2292 RThread().HandleCount(end_phc, end_thc); |
|
2293 test(start_thc == end_thc); |
|
2294 test(start_phc == end_phc); |
|
2295 test(RThread().RequestCount() >= 0); |
|
2296 |
|
2297 delete scheduler; |
|
2298 delete trapHandler; |
|
2299 |
|
2300 return KErrNone; |
|
2301 } |
|