Update contrib.
1 // Copyright (c) 2002-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 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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\power\t_domain.cpp
16 // Domain manager tests
18 // RDmDomain, RDmDomainManager CDmDomain, CDmDomainManager
20 // - Test a variety of domain transitions, check the expected number of
21 // notifications and the first expected ordinal. Verify results are
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
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:
48 // Assumptions/Requirement/Pre-requisites:
49 // Failures and causes:
50 // Base Port information:
55 #include <domainmember.h>
56 #include <domainmanager.h>
57 #include <domainobserver.h>
58 #include "domainpolicytest.h"
62 #include <e32ldr_private.h>
64 LOCAL_D RTest test(_L(" T_DOMAIN "));
65 _LIT(KThreadName, "t_domain_panic_thread");
68 #define __PRINT(x) {RDebug::Print x;}
75 // interface for test domain memebers.
76 // Any test memeber should derive from this interface
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;
91 virtual void Perform() = 0;
92 virtual void Release() = 0;
93 virtual TInt TransitionNotification(MDmDomainMember& aDomainMember) = 0;
94 virtual void TransitionRequestComplete() = 0;
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)
105 #define ORDINAL_LEVEL(ordinal) \
106 ((ordinal & 0xFF00) == 0) ? 1 : \
107 ((ordinal & 0xFF0000) == 0) ? 2 : \
108 ((ordinal & 0xFF000000) == 0) ? 3 : 4;
111 // get the least significant domain id character (for debugging purposes)
112 TBool GetDomainChar(TDmDomainId aDomainId, TChar& aChar)
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
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)
141 if (aOrdinal == KDmIdRoot)
143 aDes.Append(_L("root"));
147 TUint32 val = aOrdinal;
149 for (TInt n=0; n<4; n++)
151 TDmDomainId domainId = (TDmDomainId) (val >> 24);
153 TBool found = GetDomainChar(domainId, ch);
162 class CDmTestMember : public CActive, public MDmDomainMember
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;};
175 CDmTestMember(TDmHierarchyId aHierarchy, TDmDomainId aId, TUint32 aOrdinal, MDmTest*);
181 virtual void DoCancel();
185 TDmHierarchyId iHierarchy;
187 TDmDomainState iState;
196 CDmTestMember::CDmTestMember(TDmHierarchyId aHierarchy, TDmDomainId aId, TUint32 aOrdinal, MDmTest* aTest) : CActive(CActive::EPriorityStandard),
197 iHierarchy(aHierarchy), iId(aId), iOrdinal(aOrdinal), iTest(aTest)
201 if (iHierarchy == KDmHierarchyIdPower)
202 r = iDomain.Connect(iId);
204 r = iDomain.Connect(iHierarchy, iId);
208 CActiveScheduler::Add(this);
210 iDomain.RequestTransitionNotification(CActive::iStatus);
211 CActive::SetActive();
214 CDmTestMember::~CDmTestMember()
220 void CDmTestMember::Acknowledge()
222 iDomain.AcknowledgeLastState();
225 void CDmTestMember::RunL()
230 iState = iDomain.GetState();
232 TInt ackError = iTest->TransitionNotification(*this);
233 if (ackError == KErrNone)
234 iDomain.AcknowledgeLastState();
235 else if (ackError == KErrAbort) // don't acknowledge
238 iDomain.AcknowledgeLastState(ackError);
241 // request another notification (even if we didn't acknowledge the last one)
242 iDomain.RequestTransitionNotification(CActive::iStatus);
243 CActive::SetActive();
246 void CDmTestMember::DoCancel()
248 iDomain.CancelTransitionNotification();
253 class CDomainMemberAo : public CDmDomain, public MDmDomainMember
256 static CDomainMemberAo* NewL(TDmHierarchyId aHierarchy, TDmDomainId aId, TUint32 aOrdinal, MDmTest*);
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;};
271 CDomainMemberAo(TDmHierarchyId aHierarchy, TDmDomainId aId, TUint32 aOrdinal, MDmTest*);
274 TDmHierarchyId iHierarchy;
276 TDmDomainState iState;
282 CDomainMemberAo* CDomainMemberAo::NewL(TDmHierarchyId aHierarchy, TDmDomainId aId, TUint32 aOrdinal, MDmTest* aTest)
284 CDomainMemberAo* self=new (ELeave) CDomainMemberAo(aHierarchy, aId, aOrdinal, aTest);
285 CleanupStack::PushL(self);
288 self->RequestTransitionNotification();
294 CDomainMemberAo::CDomainMemberAo(TDmHierarchyId aHierarchy, TDmDomainId aId, TUint32 aOrdinal, MDmTest* aTest) :
295 CDmDomain(aHierarchy, aId),
296 iHierarchy(aHierarchy), iId(aId), iOrdinal(aOrdinal), iTest(aTest)
300 CDomainMemberAo::~CDomainMemberAo()
305 void CDomainMemberAo::RunL()
311 TInt ackError = iTest->TransitionNotification(*this);
312 if (ackError == KErrNone)
313 AcknowledgeLastState(ackError);
314 else if (ackError == KErrAbort) // don't acknowledge
317 AcknowledgeLastState(ackError);
318 if (ackError != KErrAbort)
319 AcknowledgeLastState(ackError);
322 // request another notification (even if we didn't acknowledge the last one)
323 RequestTransitionNotification();
328 class CDomainManagerAo : public CDmDomainManager
332 static CDomainManagerAo* NewL(TDmHierarchyId aHierarchy, MDmTest& aTest);
338 CDomainManagerAo(TDmHierarchyId aHierarchy, MDmTest& aTest);
345 CDomainManagerAo* CDomainManagerAo::NewL(TDmHierarchyId aHierarchy, MDmTest& aTest)
347 CDomainManagerAo* self=new (ELeave) CDomainManagerAo(aHierarchy, aTest);
348 CleanupStack::PushL(self);
355 CDomainManagerAo::CDomainManagerAo(TDmHierarchyId aHierarchy, MDmTest& aTest) :
356 CDmDomainManager(aHierarchy), iTest(aTest)
360 CDomainManagerAo::~CDomainManagerAo()
364 void CDomainManagerAo::RunL()
366 iTest.TransitionRequestComplete();
370 class CDmTest1 : public CActive, public MDmTest
372 public: // from CActive
378 TInt TransitionNotification(MDmDomainMember& aDomainMember);
379 void TransitionRequestComplete() {};
381 CDmTest1 (TDmDomainId aId, TDmDomainState aState) : CActive(CActive::EPriorityStandard), iDomainId(aId), iState((TPowerState) aState) {}
385 virtual void DoCancel();
388 enum { KMembersMax = 16 };
389 CDmTestMember* iMembers[KMembersMax];
390 RDmDomainManager iManager;
391 TDmDomainId iDomainId;
399 void CDmTest1::Perform()
402 // Test domain transitions
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);
420 // expected number of notifications
421 iMembersCount = (iDomainId == KDmIdRoot) ? 6 : 2;
422 // first expected ordinal
423 iOrdinal = (iState == EPwActive) ? 0 : 1;
425 TInt r = iManager.Connect();
428 CActiveScheduler::Add(this);
430 iManager.RequestDomainTransition(iDomainId, iState, CActive::iStatus);
431 CActive::SetActive();
433 CActiveScheduler::Start();
436 TInt CDmTest1::TransitionNotification(MDmDomainMember& aDomainMember)
439 if (aDomainMember.State() == EPwActive)
441 if(aDomainMember.Ordinal() < iOrdinal)
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);
450 if(aDomainMember.Ordinal() > iOrdinal)
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);
457 iOrdinal = aDomainMember.Ordinal();
459 // acknowledge one from two
460 iAcknowledge = !iAcknowledge;
461 return iAcknowledge?KErrNone:KErrGeneral;
464 void CDmTest1::RunL()
466 CActiveScheduler::Stop();
471 for (mp = iMembers; *mp; ++mp)
473 test(iCount == iMembersCount);
476 void CDmTest1::DoCancel()
481 void CDmTest1::Release()
486 class CDmTest2Timer : public CTimer
488 public: // fomr CTimer
491 CDmTest2Timer() : CTimer(0)
496 CActiveScheduler::Add(this);
500 void CDmTest2Timer::RunL()
502 test.Printf(_L("Tick count after CDmTest2Timer::RunL() = %d\n"), User::NTickCount());
504 // kick the timer again in case power down hasn't happened yet
507 wakeup += TTimeIntervalSeconds(3);
511 class CDmTest2 : public CActive, public MDmTest
513 public: // from CActive
519 TInt TransitionNotification(MDmDomainMember& aDomainMember);
520 void TransitionRequestComplete() {};
521 CDmTest2 (TDmDomainState aState) : CActive(CActive::EPriorityStandard), iState((TPowerState) aState) {}
525 virtual void DoCancel();
528 enum { KMembersMax = 16 };
529 CDmTestMember* iMembers[KMembersMax];
530 RDmDomainManager iManager;
536 CDmTest2Timer* iTimer;
540 void CDmTest2::Perform()
543 // Test system standby
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);
561 // expected number of notifications
563 // first expected ordinal
564 iOrdinal = (iState == EPwActive) ? 0 : 1;
566 TInt r = iManager.Connect();
569 CActiveScheduler::Add(this);
571 // Use an absolute timer to request a wakeup event
572 iTimer = new CDmTest2Timer();
575 wakeup += TTimeIntervalSeconds(5);
576 test.Printf(_L("Tick count before timer = %d\n"), User::NTickCount());
579 iManager.RequestSystemTransition(iState, CActive::iStatus);
580 CActive::SetActive();
582 CActiveScheduler::Start();
585 TInt CDmTest2::TransitionNotification(MDmDomainMember& aDomainMember)
588 if (aDomainMember.State() == EPwActive)
590 if(aDomainMember.Ordinal() < iOrdinal)
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());
600 if(aDomainMember.Ordinal() > iOrdinal)
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());
608 iOrdinal = aDomainMember.Ordinal();
610 // acknowledge one from two
611 iAcknowledge = !iAcknowledge;
612 return iAcknowledge?KErrNone:KErrAbort;
615 void CDmTest2::RunL()
617 test.Printf(_L("Tick count after CDmTest2::RunL() = %d\n"), User::NTickCount());
620 CActiveScheduler::Stop();
625 for (mp = iMembers; *mp; ++mp)
627 test(CActive::iStatus == KErrTimedOut);
628 test(iCount == iMembersCount);
631 void CDmTest2::DoCancel()
636 void CDmTest2::Release()
646 class CDmTest3 : public MDmTest
652 TInt TransitionNotification(MDmDomainMember& aDomainMember);
653 void TransitionRequestComplete() {};
656 void CDmTest3::Perform()
659 // Test simple error situation
661 RDmDomainManager manager;
662 TInt r = manager.Connect();
665 RDmDomainManager manager1;
666 r = manager1.Connect();
667 test(r == KErrInUse);
670 r = domain.Connect(KDmIdNone);
671 test(r == KDmErrBadDomainId);
672 CDmTestMember* testMember;
673 testMember = new CDmTestMember(KDmHierarchyIdPower, KDmIdApps, 1, this);
674 test (testMember != NULL);
676 TRequestStatus status;
677 manager.RequestDomainTransition(KDmIdApps, EPwStandby, status);
678 test(status.Int() == KRequestPending);
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);
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);
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);
701 testMember->iDomain.CancelTransitionNotification();
709 TInt CDmTest3::TransitionNotification(MDmDomainMember& /*aDomainMember*/)
712 return KErrAbort; // don't acknowledge
715 void CDmTest3::Release()
720 class CDmTest4 : public MDmTest
726 TInt TransitionNotification(MDmDomainMember& aDomainMember);
727 void TransitionRequestComplete() {};
729 void ExecSlave(TUint arg);
732 _LIT(KSecuritySlavePath, "t_domain_slave.exe");
734 void CDmTest4::ExecSlave(TUint aArg)
737 TInt r = proc.Create(KSecuritySlavePath, TPtrC((TUint16*) &aArg, sizeof(aArg)/sizeof(TUint16)));
739 TRequestStatus status;
742 User::WaitForRequest(status);
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);
749 CLOSE_AND_WAIT(proc);
752 //! @SYMTestCaseID PBASE-T_DOMAIN-4
754 //! @SYMTestCaseDesc Dmain manager security tests
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()
772 TInt CDmTest4::TransitionNotification(MDmDomainMember& /*aDomainMember*/)
778 void CDmTest4::Release()
783 // Test hierarchy tests
784 class CDmTestStartupMember : public CDmTestMember
787 CDmTestStartupMember(TDmHierarchyId aHierarchy, TDmDomainId aId, TUint32 aOrdinal, MDmTest*);
793 CDmTestStartupMember::CDmTestStartupMember(TDmHierarchyId aHierarchy, TDmDomainId aId, TUint32 aOrdinal, MDmTest* aTest)
794 : CDmTestMember(aHierarchy, aId, aOrdinal, aTest)
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
808 TInt TransitionNotification(MDmDomainMember& aDomainMember);
809 void TransitionRequestComplete();
810 CDmTest5(TDmDomainId aPowerId, TDmDomainId aTestId, TDmDomainState aPowerState, TDmDomainState aTestState) :
811 CActive(CActive::EPriorityStandard),
812 iPowerDomainId(aPowerId), iTestDomainId(aTestId), iPowerState(aPowerState), iTestState(aTestState) {}
815 virtual void DoCancel();
818 enum { KMembersMax = 16 };
819 enum TAckMode{ KAckAlways, KAckNever, KAckError, KAckOddDomainsOnly };
821 CDmTestMember* iTestMembers[KMembersMax];
822 CDomainMemberAo* iPowerMembers[KMembersMax];
824 RDmDomainManager iTestDomainManager;
826 TDmDomainId iPowerDomainId;
827 TDmDomainId iTestDomainId;
829 TDmDomainState iPowerState;
830 TDmDomainState iTestState;
832 // level number for iTestDomainId. E.g 1 for KDmIdRoot, 2 for KDmIdTestA, etc.
833 TInt iTestDomainLevel;
835 TDmTraverseDirection iTraverseDirection;
840 TInt iTestNotifications;
841 TInt iPowerNotifications;
842 TInt iTestNotificationsExpected;
843 TInt iPowerNotificationsExpected;
845 TInt iTransitionsCompleted;
846 TInt iTransitionsExpected;
851 //! @SYMTestCaseID PBASE-T_DOMAIN-5
853 //! @SYMTestCaseDesc Connects to two domain hierarchies simulteneously and perform various tests
854 //! @SYMREQ 3704,3705,3706,3707,3708,3709,3710,3711,3720,3721,3724,3725,3726,3727
855 //! @SYMTestActions Open two hiearchies simultaneously and perform various actions.
856 //! @SYMTestExpectedResults All tests should pass
857 //! @SYMTestPriority High
858 //! @SYMTestStatus Defined
859 void CDmTest5::Perform()
865 // Test domain transitions
867 CActiveScheduler::Add(this);
869 TInt r = RDmDomainManager::AddDomainHierarchy(KDmHierarchyIdTest);
871 RDebug::Printf("RDmDomainManager::AddDomainHierarchy returns %d", r );
875 CDomainManagerAo* powerDomainManager = NULL;
876 TRAP(r, powerDomainManager = CDomainManagerAo::NewL(KDmHierarchyIdPower, *this));
877 test (powerDomainManager != NULL);
879 r = CDomainManagerAo::AddDomainHierarchy(KDmHierarchyIdPower);
882 //*************************************************
883 // Test 5a - connect to two domain hierarchies simultaneously
884 //*************************************************
885 test.Next(_L("Test 5a - connect to two domain hierarchies simultaneously"));
887 test.Printf(_L("Domain id = 0x%x, Target State = 0x%x\n"), iTestDomainId, iTestState);
889 TInt testMemberCount = 0;
891 // Add some test hierarchy members - these use the RDmDomain API
892 iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdRoot, ORDINAL_FROM_DOMAINID0(KDmIdRoot), this);
893 test(iTestMembers[testMemberCount++] != NULL);
894 iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdRoot, ORDINAL_FROM_DOMAINID0(KDmIdRoot), this);
895 test(iTestMembers[testMemberCount++] != NULL);
898 iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdTestA, ORDINAL_FROM_DOMAINID1(KDmIdRoot, KDmIdTestA), this);
899 test(iTestMembers[testMemberCount++] != NULL);
900 iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdTestB, ORDINAL_FROM_DOMAINID1(KDmIdRoot, KDmIdTestB), this);
901 test(iTestMembers[testMemberCount++] != NULL);
902 iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdTestC, ORDINAL_FROM_DOMAINID1(KDmIdRoot, KDmIdTestC), this);
903 test(iTestMembers[testMemberCount++] != NULL);
906 iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdTestAA, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestA, KDmIdTestAA), this);
907 test(iTestMembers[testMemberCount++] != NULL);
908 iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdTestAB, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestA, KDmIdTestAB), this);
909 test(iTestMembers[testMemberCount++] != NULL);
910 iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdTestBA, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestB, KDmIdTestBA), this);
911 test(iTestMembers[testMemberCount++] != NULL);
912 iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdTestCA, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestC, KDmIdTestCA), this);
913 test(iTestMembers[testMemberCount++] != NULL);
916 iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdTestABA, ORDINAL_FROM_DOMAINID3(KDmIdRoot, KDmIdTestA, KDmIdTestAB, KDmIdTestABA), this);
917 test(iTestMembers[testMemberCount++] != NULL);
918 iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdTestABB, ORDINAL_FROM_DOMAINID3(KDmIdRoot, KDmIdTestA, KDmIdTestAB, KDmIdTestABB), this);
919 test(iTestMembers[testMemberCount++] != NULL);
920 iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdTestCAA, ORDINAL_FROM_DOMAINID3(KDmIdRoot, KDmIdTestC, KDmIdTestCA, KDmIdTestCAA), this);
921 test(iTestMembers[testMemberCount++] != NULL);
923 // add some power hierarchy members - these use the CDmDomain AO API
924 TInt powerMemberCount = 0;
925 TRAP(r, iPowerMembers[powerMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdPower, KDmIdRoot, KDmIdRoot, this));
926 test(iTestMembers[powerMemberCount++] != NULL);
927 TRAP(r, iPowerMembers[powerMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdPower, KDmIdApps, KDmIdApps, this));
928 test(iTestMembers[powerMemberCount++] != NULL);
929 TRAP(r, iPowerMembers[powerMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdPower, KDmIdUiApps, KDmIdUiApps, this));
930 test(iTestMembers[powerMemberCount++] != NULL);
933 RArray<const TTransitionFailure> testFailures;
934 TInt testFailureCount;
935 RArray<const TTransitionFailure> powerFailures;
936 TInt powerFailureCount;
940 // calculate the expected number of notifications
941 TInt expectedTestNotifications = 0;
945 // work out the domain level, the number of leaf nodes and the expected number of
946 // notifications for the domain that is being transitioned
947 switch(iTestDomainId)
949 case KDmIdRoot : iTestDomainLevel = 1; leafNodes = 5; expectedTestNotifications = testMemberCount; break;
950 case KDmIdTestA : iTestDomainLevel = 2; leafNodes = 3; expectedTestNotifications = 5; break;
951 case KDmIdTestB : iTestDomainLevel = 2; leafNodes = 1; expectedTestNotifications = 2; break;
952 case KDmIdTestC : iTestDomainLevel = 2; leafNodes = 1; expectedTestNotifications = 3; break;
954 case KDmIdTestAA : iTestDomainLevel = 3; leafNodes = 1; expectedTestNotifications = 1; break;
955 case KDmIdTestAB : iTestDomainLevel = 3; leafNodes = 2; expectedTestNotifications = 3; break;
956 case KDmIdTestBA : iTestDomainLevel = 3; leafNodes = 1; expectedTestNotifications = 1; break;
957 case KDmIdTestCA : iTestDomainLevel = 3; leafNodes = 1; expectedTestNotifications = 2; break;
959 case KDmIdTestABA : iTestDomainLevel = 4; leafNodes = 1; expectedTestNotifications = 1; break;
960 case KDmIdTestABB : iTestDomainLevel = 4; leafNodes = 1; expectedTestNotifications = 1; break;
961 case KDmIdTestCAA : iTestDomainLevel = 4; leafNodes = 1; expectedTestNotifications = 1; break;
965 test.Printf(_L("Test Domain id = 0x%x, Level = %d, Target State = 0x%x, expected notifications = %d, leafNodes = %d\n"),
966 iTestDomainId, iTestDomainLevel, iTestState, expectedTestNotifications, leafNodes);
968 TInt expectedPowerNotifications = 0;
969 switch(iPowerDomainId)
971 case KDmIdRoot : expectedPowerNotifications = powerMemberCount; break;
972 case KDmIdApps : expectedPowerNotifications = 1; break;
973 case KDmIdUiApps : expectedPowerNotifications = 1; break;
980 // connect to the test hierarchy
981 r = iTestDomainManager.Connect(KDmHierarchyIdTest);
984 // verify that we can't connect to the same hierarchy more than once
985 RDmDomainManager domainManager;
986 r = domainManager.Connect(KDmHierarchyIdTest);
987 test(r == KErrInUse);
991 //*************************************************
992 // Test 5b - request a positive transition
993 // issue a positive transition (i.e. transition state increases)
994 // and request that the test domain use ETraverseParentsFirst
995 //*************************************************
996 test.Next(_L("Test 5b - request a positive transition"));
997 iAckMode = KAckAlways;
999 iTransitionsCompleted = iTestNotifications = iPowerNotifications = 0;
1000 iPowerNotificationsExpected = 0;
1001 iTestNotificationsExpected = expectedTestNotifications;
1002 iTransitionsExpected = 1;
1004 // DON'T request any domain transition on the power hierarchy
1005 // powerDomainManager->RequestDomainTransition(iPowerDomainId, EPwActive);
1006 // request a domain transition on the test hierarchy
1007 iTraverseDirection = ETraverseParentsFirst;
1008 if (iTestDomainId == KDmIdRoot)
1009 iTestDomainManager.RequestSystemTransition(iTestState, ETraverseDefault, CActive::iStatus);
1011 iTestDomainManager.RequestDomainTransition(iTestDomainId, iTestState, ETraverseDefault, CActive::iStatus);
1012 CActive::SetActive();
1014 CActiveScheduler::Start();
1015 test(powerDomainManager->iStatus == KErrNone);
1016 test(iStatus == KErrNone);
1017 test(iTestNotifications == iTestNotificationsExpected);
1018 test(iPowerNotifications == iPowerNotificationsExpected);
1020 //*************************************************
1021 // Test 5c- verify domains are in correct state
1022 //*************************************************
1023 test.Next(_L("Test 5c- verify domains are in correct state"));
1024 RDmDomain domainMember;
1025 r = domainMember.Connect(KDmHierarchyIdTest, iTestDomainId);
1026 test (r == KErrNone);
1027 TDmDomainState state = domainMember.GetState();
1028 domainMember.Close();
1029 test (state == iTestState);
1031 // if the transition request is not on the root, verify that that
1032 // the root domain and the transition domain are in different states
1033 if (iTestDomainId != KDmIdRoot && iTestState != EStartupCriticalStatic)
1035 r = domainMember.Connect(KDmHierarchyIdTest, KDmIdRoot);
1036 test (r == KErrNone);
1037 TDmDomainState state = domainMember.GetState();
1038 domainMember.Close();
1039 test (state != iTestState);
1043 //*************************************************
1044 // Test 5d- request a negative transition
1045 // issue a negative transition (i.e. transition state decreases)
1046 // and request that the test domain use ETraverseChildrenFirst
1047 //*************************************************
1048 test.Next(_L("Test 5d- request a negative transition"));
1049 iAckMode = KAckAlways;
1050 iTestState--; // EStartupCriticalStatic;
1051 iPowerState--; // EPwStandby
1053 iTransitionsCompleted = iTestNotifications = iPowerNotifications = 0;
1054 iPowerNotificationsExpected = expectedPowerNotifications;
1055 iTestNotificationsExpected = expectedTestNotifications;
1056 iTransitionsExpected = 2;
1058 // DO request a domain transition on the power hierarchy
1059 powerDomainManager->RequestDomainTransition(iPowerDomainId, iPowerState, ETraverseDefault);
1061 // request a domain transition on the test hierarchy
1062 iTraverseDirection = ETraverseChildrenFirst;
1063 iTestDomainManager.RequestDomainTransition(iTestDomainId, iTestState, iTraverseDirection, CActive::iStatus);
1064 CActive::SetActive();
1066 // wait for all test & power transitions to complete
1067 CActiveScheduler::Start();
1068 test(powerDomainManager->iStatus == KErrNone);
1069 test(iStatus == KErrNone);
1070 test(iTestNotifications == iTestNotificationsExpected);
1071 test(iPowerNotifications == iPowerNotificationsExpected);
1074 //*************************************************
1075 // Test 5e- request a positive transition, with zero acknowledgements
1076 // issue a positive transition with no members acknowledging the transition
1077 //*************************************************
1078 test.Next(_L("Test 5e- request a positive transition, with zero acknowledgements"));
1079 iAckMode = KAckNever;
1080 iTestState++; // EStartupCriticalDynamic;
1081 iPowerState++; // EPwActive
1083 // power hierarchy should continue on failure, so we all power domains should transition
1084 // test hierarchy should stop on failure, so should get notifications from all leaf nodes
1085 iTransitionsCompleted = iTestNotifications = iPowerNotifications = 0;
1086 iPowerNotificationsExpected = expectedPowerNotifications;
1087 iTestNotificationsExpected = leafNodes; // 5 leaf nodes for root domain
1088 iTransitionsExpected = 2;
1090 // DO request a domain transition on the power hierarchy
1091 powerDomainManager->RequestDomainTransition(iPowerDomainId, iPowerState, ETraverseDefault);
1093 // request a domain transition on the test hierarchy
1094 iTraverseDirection = ETraverseChildrenFirst;
1095 iTestDomainManager.RequestDomainTransition(iTestDomainId, iTestState, iTraverseDirection, CActive::iStatus);
1096 CActive::SetActive();
1098 // wait for all test & power transitions to complete
1099 CActiveScheduler::Start();
1100 test(powerDomainManager->iStatus == KErrTimedOut);
1101 test(iStatus == KErrTimedOut);
1102 test(iTestNotifications == iTestNotificationsExpected);
1103 test(iPowerNotifications == iPowerNotificationsExpected);
1105 // get the failures on the test hierarchy
1106 testFailureCount = iTestDomainManager.GetTransitionFailureCount();
1107 test (testFailureCount == 1);
1109 r = iTestDomainManager.GetTransitionFailures(testFailures);
1110 test(r == KErrNone);
1111 test(testFailureCount == testFailures.Count());
1113 test.Printf(_L("Test failures = %d\n"), testFailureCount);
1115 for (i=0; i<testFailureCount; i++)
1117 test.Printf(_L("%d: iDomainId %d, iError %d\n"),
1118 i, testFailures[i].iDomainId, testFailures[i].iError);
1119 test(testFailures[i].iError == KErrTimedOut);
1122 // get the failures on the power hierarchy
1123 powerFailureCount = powerDomainManager->GetTransitionFailureCount();
1124 test (powerFailureCount == expectedPowerNotifications);
1126 r = powerDomainManager->GetTransitionFailures(powerFailures);
1127 test(r == KErrNone);
1128 test(powerFailureCount == powerFailures.Count());
1130 test.Printf(_L("Power failures = %d\n"), powerFailureCount);
1131 for (i=0; i<powerFailureCount; i++)
1133 test.Printf(_L("%d: iDomainId %d, iError %d\n"),
1134 i, powerFailures[i].iDomainId, powerFailures[i].iError);
1135 test(powerFailures[i].iError == KErrTimedOut);
1139 //*************************************************
1140 // Test 5f- request a positive transition, with error acknowledgements
1141 // issue a positive transition with all members nack'ing the transition
1142 //*************************************************
1143 test.Next(_L("Test 5f- request a positive transition, with error acknowledgements"));
1144 iAckMode = KAckError;
1148 // power hierarchy should continue on failure, so all power domains should transition
1149 // test hierarchy should stop on failure, so should get notifications from
1150 // anything from 1 to all the leaf nodes
1151 iTransitionsCompleted = iTestNotifications = iPowerNotifications = 0;
1152 iPowerNotificationsExpected = expectedPowerNotifications;
1153 iTestNotificationsExpected = leafNodes; // 5 leaf nodes for root domain
1154 iTransitionsExpected = 2;
1156 // DO request a domain transition on the power hierarchy
1157 powerDomainManager->RequestDomainTransition(iPowerDomainId, iPowerState, ETraverseDefault);
1159 // request a domain transition on the test hierarchy
1160 iTraverseDirection = ETraverseChildrenFirst;
1161 iTestDomainManager.RequestDomainTransition(iTestDomainId, iTestState, iTraverseDirection, CActive::iStatus);
1162 CActive::SetActive();
1164 // wait for all test & power transitions to complete
1165 CActiveScheduler::Start();
1166 test(powerDomainManager->iStatus == KErrGeneral);
1167 test(iStatus == KErrGeneral);
1168 test(iTestNotifications <= iTestNotificationsExpected);
1169 test(iPowerNotifications == iPowerNotificationsExpected);
1171 // get the failures on the test hierarchy
1172 testFailureCount = iTestDomainManager.GetTransitionFailureCount();
1173 test (testFailureCount == 1);
1175 r = iTestDomainManager.GetTransitionFailures(testFailures);
1176 test(r == KErrNone);
1177 test(testFailureCount == testFailures.Count());
1179 test.Printf(_L("Test failures = %d\n"), testFailureCount);
1180 for (i=0; i<testFailureCount; i++)
1182 test.Printf(_L("%d: iDomainId %d, iError %d\n"),
1183 i, testFailures[i].iDomainId, testFailures[i].iError);
1184 test(testFailures[i].iError == KErrGeneral);
1187 // get the failures on the power hierarchy
1188 powerFailureCount = powerDomainManager->GetTransitionFailureCount();
1189 test (powerFailureCount == expectedPowerNotifications);
1191 r = powerDomainManager->GetTransitionFailures(powerFailures);
1192 test(r == KErrNone);
1193 test(powerFailureCount == powerFailures.Count());
1195 test.Printf(_L("Power failures = %d\n"), powerFailureCount);
1196 for (i=0; i<powerFailureCount; i++)
1198 test.Printf(_L("%d: iDomainId %d, iError %d\n"),
1199 i, powerFailures[i].iDomainId, powerFailures[i].iError);
1200 test(powerFailures[i].iError == KErrGeneral);
1206 testFailures.Reset();
1207 powerFailures.Reset();
1209 iTestDomainManager.Close();
1210 delete powerDomainManager;
1211 powerDomainManager = NULL;
1214 for (mt = iTestMembers; *mt; ++mt)
1217 CDomainMemberAo** mp;
1218 for (mp = iPowerMembers; *mp; ++mp)
1222 // restore the domain hierarchies to their initial state so as not to
1223 // upset any subsequent tests which rely on this
1225 RDmDomainManager manager;
1226 TInt r = manager.Connect();
1227 test (r == KErrNone);
1228 TRequestStatus status;
1229 manager.RequestDomainTransition(KDmIdRoot, EPwActive, status);
1230 test(status.Int() == KRequestPending);
1231 User::WaitForRequest(status);
1232 test(status.Int() == KErrNone);
1235 r = manager.Connect(KDmHierarchyIdTest);
1236 test (r == KErrNone);
1237 manager.RequestDomainTransition(KDmIdRoot, EStartupCriticalStatic, ETraverseDefault, status);
1238 test(status.Int() == KRequestPending);
1239 User::WaitForRequest(status);
1240 test(status.Int() == KErrNone);
1247 // This handles a transition notification from either a power domain member or
1248 // a test domain member.
1249 // Verifies that the domain state is as expected.
1250 // Updates the number of notifications for each hierarchy and verifies that all parent
1251 // domains have transitioned already (for parent-to-child transitions) or that all child
1252 // domains have been transitioned already (for child-to-parent transitions).
1254 TInt CDmTest5::TransitionNotification(MDmDomainMember& aDomainMember)
1256 if (aDomainMember.HierarchyId() == KDmHierarchyIdPower)
1257 iPowerNotifications++;
1259 iTestNotifications++;
1261 if (aDomainMember.HierarchyId() == KDmHierarchyIdPower)
1263 __PRINT((_L("CDmTest5::TransitionNotification(), Hierarchy = %d, iOrdinal = 0x%08X, state = 0x%x, status = %d\n"),
1264 aDomainMember.HierarchyId(), aDomainMember.Ordinal(), aDomainMember.State(), aDomainMember.Status()));
1265 test(aDomainMember.State() == iPowerState);
1267 else if (aDomainMember.HierarchyId() == KDmHierarchyIdTest)
1270 GetDomainDesc(aDomainMember.Ordinal(), buf);
1272 __PRINT((_L("CDmTest5::TransitionNotification(), Hierarchy = %d, domain = %S, iOrdinal = 0x%08X, state = 0x%x, status = %d\n"),
1273 aDomainMember.HierarchyId(), &buf, aDomainMember.Ordinal(), aDomainMember.State(), aDomainMember.Status()));
1274 test(aDomainMember.State() == iTestState);
1281 // if we're going from parent to child,
1282 // check that each parent domain has received a notification already
1283 // if not, check that each child domain has received a notification already
1287 if (aDomainMember.HierarchyId() == KDmHierarchyIdTest && iAckMode == KAckAlways)
1290 if (iTraverseDirection == ETraverseParentsFirst)
1292 TUint ordThis = aDomainMember.Ordinal();
1293 TUint ordParent = PARENT_ORDINAL(ordThis);
1295 TInt levelParent = ORDINAL_LEVEL(ordParent);
1298 GetDomainDesc(ordParent, buf);
1299 if (levelParent >= iTestDomainLevel)
1301 __PRINT((_L("Searching for parent domain = %S, ordinal = %08X \n"), &buf, ordParent));
1302 for (mp = iTestMembers; *mp; ++mp)
1304 if ((*mp)->Ordinal() == ordParent)
1307 GetDomainDesc((*mp)->Ordinal(), buf);
1308 __PRINT((_L("Found parent (%S). notification = %d\n"), &buf, (*mp)->Notifications()));
1309 test ((*mp)->Notifications() == aDomainMember.Notifications());
1317 __PRINT((_L("Searching for children\n")));
1318 for (mp = iTestMembers; *mp; ++mp)
1321 TUint ordParent = PARENT_ORDINAL((*mp)->Ordinal());
1322 if (ordParent == aDomainMember.Ordinal())
1325 GetDomainDesc((*mp)->Ordinal(), buf);
1326 __PRINT((_L("Found child (%S). notification = %d\n"), &buf, (*mp)->Notifications()));
1327 test ((*mp)->Notifications() == aDomainMember.Notifications());
1337 ackError = KErrAbort;
1339 case KAckError: // return an error to the DM
1340 ackError = KErrGeneral;
1342 case KAckOddDomainsOnly:
1343 ackError = (aDomainMember.DomainId() & 1)?KErrNone:KErrAbort;
1347 ackError = KErrNone;
1353 void CDmTest5::RunL()
1355 iTransitionsCompleted++;
1357 __PRINT((_L("CDmTest5::RunL(), error = %d, iTestNotifications %d, iPowerNotifications %d\n"),
1358 iStatus.Int(), iTestNotifications , iPowerNotifications));
1360 if (iTransitionsCompleted == iTransitionsExpected)
1361 CActiveScheduler::Stop();
1364 void CDmTest5::TransitionRequestComplete()
1366 iTransitionsCompleted++;
1368 __PRINT((_L("CDmTest5::TransitionRequestComplete(), error = %d, iTestNotifications %d, iPowerNotifications %d\n"),
1369 iStatus.Int(), iTestNotifications , iPowerNotifications));
1371 if (iTransitionsCompleted == iTransitionsExpected)
1372 CActiveScheduler::Stop();
1375 void CDmTest5::DoCancel()
1380 void CDmTest5::Release()
1385 const TInt KMembersMax = 16;
1388 class CDmTest6 : public CActive, public MDmTest
1393 ENegTestTransitionNoConnect,
1394 ENegTestGetStateNoConnect,
1395 ENegTestTransitionInvalidMode
1401 inline TData(TInt aTest) : iTest(aTest){};
1412 TInt TransitionNotification(MDmDomainMember& aDomainMember);
1413 void TransitionRequestComplete();
1416 CDmTest6() : CActive(CActive::EPriorityStandard) {}
1420 virtual void DoCancel();
1423 static TInt PanicThreadFunc(TAny* aData);
1424 void PanicTest(TInt aTestNumber);
1427 CDomainMemberAo* iTestMembers[KMembersMax];
1428 CDomainManagerAo* iTestDomainManager;
1430 TDmDomainId iTestDomainId;
1431 TDmDomainState iTestState;
1434 TInt iTestNotifications;
1435 TInt iTestNotificationsExpected;
1437 TInt iTransitionsCompleted;
1438 TInt iTransitionsExpected;
1441 TInt CDmTest6::PanicThreadFunc(TAny* aData)
1443 const TData* data = (const TData*)aData;
1444 switch (data->iTest)
1446 case ENegTestTransitionNoConnect:
1448 // request a transition notification without connecting first (should panic)
1449 RDmDomain domainMember;
1450 TRequestStatus status;
1451 User::SetJustInTime(EFalse);
1452 domainMember.RequestTransitionNotification(status);
1455 case ENegTestGetStateNoConnect:
1457 // Get the domain state without connecting (should panic)
1458 RDmDomain domainMember;
1459 User::SetJustInTime(EFalse);
1460 domainMember.GetState();
1463 case ENegTestTransitionInvalidMode:
1465 RDmDomainManager manager;
1466 TRequestStatus status;
1467 TInt r = manager.Connect(KDmHierarchyIdTest);
1468 test(r == KErrNone);
1470 User::SetJustInTime(EFalse);
1471 manager.RequestDomainTransition(KDmIdRoot, 0, TDmTraverseDirection(-1), status);
1480 void CDmTest6::PanicTest(TInt aTestNumber)
1482 test.Printf(_L("panic test number %d\n"), aTestNumber);
1484 TBool jit = User::JustInTime();
1486 TData data(aTestNumber);
1488 TInt KHeapSize=0x2000;
1491 TInt ret = thread.Create(KThreadName, PanicThreadFunc, KDefaultStackSize, KHeapSize, KHeapSize, &data);
1492 test(KErrNone == ret);
1493 TRequestStatus stat;
1496 User::WaitForRequest(stat);
1498 User::SetJustInTime(jit);
1500 // The thread must panic
1501 test(thread.ExitType() == EExitPanic);
1502 TInt exitReason = thread.ExitReason();
1503 test.Printf(_L("panic test exit reason = %d\n"), exitReason);
1507 case ENegTestTransitionNoConnect:
1508 test (exitReason == EBadHandle);
1510 case ENegTestGetStateNoConnect:
1511 test (exitReason == EBadHandle);
1513 case ENegTestTransitionInvalidMode:
1519 CLOSE_AND_WAIT(thread);
1523 //! @SYMTestCaseID PBASE-T_DOMAIN-6
1525 //! @SYMTestCaseDesc Negative testing
1527 //! @SYMTestActions Various negative tests
1528 //! @SYMTestExpectedResults All tests should pass
1529 //! @SYMTestPriority High
1530 //! @SYMTestStatus Defined
1531 void CDmTest6::Perform()
1536 CActiveScheduler::Add(this);
1538 CDomainManagerAo* iTestDomainManager = NULL;
1539 TRAP_IGNORE(iTestDomainManager = CDomainManagerAo::NewL(KDmHierarchyIdTest, *this));
1540 test (iTestDomainManager != NULL);
1542 TInt r = CDomainManagerAo::AddDomainHierarchy(KDmHierarchyIdTest);
1543 test(r == KErrNone);
1545 //*************************************************
1546 // Test 6a - Connect to the same hierarchy twice
1547 //*************************************************
1548 test.Next(_L("Test 6a - Connect to the same hierarchy twice"));
1550 // verify that we can't connect to the same hierarchy more than once
1551 CDomainManagerAo* testDomainManager = NULL;
1552 TRAP(r, testDomainManager = CDomainManagerAo::NewL(KDmHierarchyIdTest, *this));
1553 test(r == KErrInUse);
1554 test (testDomainManager == NULL);
1557 TInt testMemberCount = 0;
1559 // Add some test hierarchy members
1560 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdRoot, ORDINAL_FROM_DOMAINID0(KDmIdRoot), this));
1561 test(iTestMembers[testMemberCount++] != NULL);
1562 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdRoot, ORDINAL_FROM_DOMAINID0(KDmIdRoot), this));
1563 test(iTestMembers[testMemberCount++] != NULL);
1566 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestA, ORDINAL_FROM_DOMAINID1(KDmIdRoot, KDmIdTestA), this));
1567 test(iTestMembers[testMemberCount++] != NULL);
1568 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestB, ORDINAL_FROM_DOMAINID1(KDmIdRoot, KDmIdTestB), this));
1569 test(iTestMembers[testMemberCount++] != NULL);
1570 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestC, ORDINAL_FROM_DOMAINID1(KDmIdRoot, KDmIdTestC), this));
1571 test(iTestMembers[testMemberCount++] != NULL);
1574 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestAA, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestA, KDmIdTestAA), this));
1575 test(iTestMembers[testMemberCount++] != NULL);
1576 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestAB, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestA, KDmIdTestAB), this));
1577 test(iTestMembers[testMemberCount++] != NULL);
1578 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestBA, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestB, KDmIdTestBA), this));
1579 test(iTestMembers[testMemberCount++] != NULL);
1580 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestCA, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestC, KDmIdTestCA), this));
1581 test(iTestMembers[testMemberCount++] != NULL);
1584 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestABA, ORDINAL_FROM_DOMAINID3(KDmIdRoot, KDmIdTestA, KDmIdTestAB, KDmIdTestABA), this));
1585 test(iTestMembers[testMemberCount++] != NULL);
1586 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestABB, ORDINAL_FROM_DOMAINID3(KDmIdRoot, KDmIdTestA, KDmIdTestAB, KDmIdTestABB), this));
1587 test(iTestMembers[testMemberCount++] != NULL);
1588 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestCAA, ORDINAL_FROM_DOMAINID3(KDmIdRoot, KDmIdTestC, KDmIdTestCA, KDmIdTestCAA), this));
1589 test(iTestMembers[testMemberCount++] != NULL);
1592 //*************************************************
1593 // Test 6b change to current state
1594 //*************************************************
1595 test.Next(_L("Test 6b change to current state"));
1596 iTestState = EStartupCriticalStatic;
1597 iTestDomainId = KDmIdRoot;
1599 iTransitionsCompleted = iTestNotifications = 0;
1600 iTestNotificationsExpected = testMemberCount;
1601 iTransitionsExpected = 1;
1603 // request a domain transition
1604 iTestDomainManager->RequestDomainTransition(iTestDomainId, iTestState, ETraverseDefault);
1606 // wait for test transitions to complete
1607 CActiveScheduler::Start();
1608 test(iStatus == KErrNone);
1609 test(iTestNotifications == iTestNotificationsExpected);
1612 // cancel a member notification request
1613 //*************************************************
1614 // Test 6c cancel a member notification request
1615 //*************************************************
1616 test.Next(_L("Test 6c cancel a member notification request"));
1617 RDmDomain domainMember;
1618 TRequestStatus status;
1619 domainMember.Connect(KDmHierarchyIdTest, iTestDomainId);
1620 domainMember.RequestTransitionNotification(status);
1621 domainMember.CancelTransitionNotification();
1622 User::WaitForRequest(status);
1623 domainMember.Close();
1625 //*************************************************
1626 // Test 6d cancel a member notification request without having first requested a notification
1627 //*************************************************
1628 test.Next(_L("Test 6d cancel a member notification request without having first requested a notification"));
1629 domainMember.Connect(KDmHierarchyIdTest, iTestDomainId);
1630 domainMember.CancelTransitionNotification();
1631 domainMember.Close();
1633 //*************************************************
1634 // Test 6e domain controller adds invalid hierarchy
1635 //*************************************************
1636 test.Next(_L("Test 6e domain controller connects to invalid hierarchy"));
1637 r = RDmDomainManager::AddDomainHierarchy(TDmHierarchyId(-1));
1638 test(r == KErrBadHierarchyId);
1640 //*************************************************
1641 // Test 6f domain member connects to invalid hierarchy
1642 //*************************************************
1643 test.Next(_L("Test 6f domain member connects to invalid hierarchy"));
1644 r = domainMember.Connect(TDmHierarchyId(-1), TDmDomainId(KDmIdRoot));
1645 test (r == KErrBadHierarchyId);
1647 //*************************************************
1648 // Test 6g domain member connects to valid hierarchy but invalid domain
1649 //*************************************************
1650 test.Next(_L("Test 6g domain member connects to valid hierarchy but invalid domain"));
1651 r = domainMember.Connect(KDmHierarchyIdTest, TDmDomainId(-1));
1652 test (r == KDmErrBadDomainId);
1654 delete iTestDomainManager;
1655 iTestDomainManager = NULL;
1659 //*************************************************
1660 // Test 6h request a transition notification without connecting first
1661 //*************************************************
1662 test.Next(_L("Test 6h request a transition notification without connecting first"));
1663 PanicTest(ENegTestTransitionNoConnect);
1665 //*************************************************
1666 // Test 6i Get the domain state without connecting
1667 //*************************************************
1668 test.Next(_L("Test 6i Get the domain state without connecting"));
1669 PanicTest(ENegTestGetStateNoConnect);
1671 //*************************************************
1672 // Test 6j request a transition notification with an invalid transition mode
1673 //*************************************************
1674 test.Next(_L("Test 6j request a transition notification with an invalid transition mode"));
1675 PanicTest(ENegTestTransitionInvalidMode);
1680 CDomainMemberAo** mt;
1681 for (mt = iTestMembers; *mt; ++mt)
1687 // This handles a transition notification from a test domain member.
1688 TInt CDmTest6::TransitionNotification(MDmDomainMember& aDomainMember)
1690 TInt status = aDomainMember.Status();
1692 iTestNotifications++;
1694 test (aDomainMember.HierarchyId() == KDmHierarchyIdTest);
1697 GetDomainDesc(aDomainMember.Ordinal(), buf);
1699 test.Printf(_L("CDmTest6::TransitionNotification(), Hierarchy = %d, domain = %S, iOrdinal = 0x%08X, state = 0x%x, status = %d\n"),
1700 aDomainMember.HierarchyId(), &buf, aDomainMember.Ordinal(), aDomainMember.State(), status);
1706 void CDmTest6::RunL()
1708 iTransitionsCompleted++;
1710 TInt error = iStatus.Int();
1712 test.Printf(_L("CDmTest6::RunL(), error = %d, iTestNotifications %d\n"),
1713 error, iTestNotifications);
1715 if (iTransitionsCompleted == iTransitionsExpected)
1716 CActiveScheduler::Stop();
1719 void CDmTest6::TransitionRequestComplete()
1721 iTransitionsCompleted++;
1723 TInt error = iStatus.Int();
1725 test.Printf(_L("CDmTest6::TransitionRequestComplete(), error = %d, iTestNotifications %d\n"),
1726 error, iTestNotifications);
1728 if (iTransitionsCompleted == iTransitionsExpected)
1729 CActiveScheduler::Stop();
1732 void CDmTest6::DoCancel()
1737 void CDmTest6::Release()
1742 // Transition progress Observer testing
1743 class CDmTest7 : public CActive, public MDmTest, public MHierarchyObserver
1752 TInt TransitionNotification(MDmDomainMember& aDomainMember);
1753 void TransitionRequestComplete();
1755 // from MHierarchyObserver
1756 virtual void TransProgEvent(TDmDomainId aDomainId, TDmDomainState aState);
1757 virtual void TransFailEvent(TDmDomainId aDomainId, TDmDomainState aState, TInt aError);
1758 virtual void TransReqEvent(TDmDomainId aDomainId, TDmDomainState aState);
1762 CDmTest7(TDmDomainId aDomainId) : CActive(CActive::EPriorityStandard), iObservedDomainId(aDomainId) {}
1766 virtual void DoCancel();
1769 void TestForCompletion();
1774 enum { KMembersMax = 16 };
1776 CDomainMemberAo* iTestMembers[KMembersMax];
1777 CDomainManagerAo* iTestDomainManager;
1779 TDmDomainId iTestDomainId;
1780 TDmDomainState iTestState;
1781 TDmDomainId iObservedDomainId;
1784 TInt iTestNotifications;
1785 TInt iTestNotificationsExpected;
1787 TInt iTransitionsCompleted;
1788 TInt iTransitionsExpected;
1790 TInt iTransProgEvents;
1791 TInt iTransFailEvents;
1792 TInt iTransReqEvents;
1794 TInt iTransProgEventsExpected;
1795 TInt iTransFailEventsExpected;
1796 TInt iTransReqEventsExpected;
1799 //! @SYMTestCaseID PBASE-T_DOMAIN-7
1801 //! @SYMTestCaseDesc Transition progress Observer testing
1803 //! @SYMTestActions Various negative tests
1804 //! @SYMTestExpectedResults All tests should pass
1805 //! @SYMTestPriority High
1806 //! @SYMTestStatus Defined
1807 void CDmTest7::Perform()
1813 // Test domain transitions with activated observer
1815 CActiveScheduler::Add(this);
1817 TInt r = RDmDomainManager::AddDomainHierarchy(KDmHierarchyIdTest);
1818 test(r == KErrNone);
1820 CDomainManagerAo* iTestDomainManager = NULL;
1821 TRAP_IGNORE(iTestDomainManager = CDomainManagerAo::NewL(KDmHierarchyIdTest, *this));
1822 test (iTestDomainManager != NULL);
1824 r = CDomainManagerAo::AddDomainHierarchy(KDmHierarchyIdTest);
1825 test(r == KErrNone);
1827 //*************************************************
1828 // Test 7a - Testing observer notifications
1829 //*************************************************
1831 test.Next(_L("Test 7a - Testing observer notifications"));
1833 TInt testMemberCount = 0;
1835 // Add some test hierarchy members
1836 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdRoot, ORDINAL_FROM_DOMAINID0(KDmIdRoot), this));
1837 test(iTestMembers[testMemberCount++] != NULL);
1840 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestA, ORDINAL_FROM_DOMAINID1(KDmIdRoot, KDmIdTestA), this));
1841 test(iTestMembers[testMemberCount++] != NULL);
1842 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestB, ORDINAL_FROM_DOMAINID1(KDmIdRoot, KDmIdTestB), this));
1843 test(iTestMembers[testMemberCount++] != NULL);
1844 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestC, ORDINAL_FROM_DOMAINID1(KDmIdRoot, KDmIdTestC), this));
1845 test(iTestMembers[testMemberCount++] != NULL);
1848 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestAA, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestA, KDmIdTestAA), this));
1849 test(iTestMembers[testMemberCount++] != NULL);
1850 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestAB, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestA, KDmIdTestAB), this));
1851 test(iTestMembers[testMemberCount++] != NULL);
1852 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestBA, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestB, KDmIdTestBA), this));
1853 test(iTestMembers[testMemberCount++] != NULL);
1854 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestCA, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestC, KDmIdTestCA), this));
1855 test(iTestMembers[testMemberCount++] != NULL);
1858 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestABA, ORDINAL_FROM_DOMAINID3(KDmIdRoot, KDmIdTestA, KDmIdTestAB, KDmIdTestABA), this));
1859 test(iTestMembers[testMemberCount++] != NULL);
1860 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestABB, ORDINAL_FROM_DOMAINID3(KDmIdRoot, KDmIdTestA, KDmIdTestAB, KDmIdTestABB), this));
1861 test(iTestMembers[testMemberCount++] != NULL);
1862 TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestCAA, ORDINAL_FROM_DOMAINID3(KDmIdRoot, KDmIdTestC, KDmIdTestCA, KDmIdTestCAA), this));
1863 test(iTestMembers[testMemberCount++] != NULL);
1865 // create an observer
1866 CHierarchyObserver* observer = NULL;
1867 TRAP(r, observer = CHierarchyObserver::NewL(*this, KDmHierarchyIdTest));
1868 test (r == KErrNone);
1869 test(observer != NULL);
1870 observer->StartObserver(iObservedDomainId, EDmNotifyAll);
1872 // request a state change
1873 iTestState = EStartupCriticalDynamic;
1874 iTestDomainId = KDmIdRoot;
1875 iTransitionsCompleted = iTestNotifications = 0;
1876 iTestNotificationsExpected = testMemberCount;
1877 iTransitionsExpected = 1;
1879 iTransProgEvents = iTransFailEvents = iTransReqEvents = 0;
1881 iTransReqEventsExpected = iTransProgEventsExpected = observer->ObserverDomainCount();
1882 iTransFailEventsExpected = 0;
1885 iTestDomainManager->RequestDomainTransition(iTestDomainId, iTestState, ETraverseDefault);
1887 // wait for test transitions to complete
1888 CActiveScheduler::Start();
1889 test(iStatus == KErrNone);
1890 test(iTestNotifications == iTestNotificationsExpected);
1891 test (iTransProgEvents == iTransProgEventsExpected);
1892 test (iTransFailEvents == iTransFailEventsExpected);
1893 test (iTransReqEvents == iTransReqEventsExpected);
1900 //*************************************************
1901 // Test 7b - start & stop the observer
1902 //*************************************************
1903 test.Next(_L("Test 7b - start & stop the observer"));
1905 // create an observer, start it stop and then start it again
1906 TRAP(r, observer = CHierarchyObserver::NewL(*this, KDmHierarchyIdTest));
1907 test (r == KErrNone);
1908 test(observer != NULL);
1909 observer->StartObserver(iObservedDomainId, EDmNotifyAll);
1910 observer->StopObserver();
1911 observer->StartObserver(iObservedDomainId, EDmNotifyAll);
1913 // request a state change
1915 iTestDomainId = KDmIdRoot;
1916 iTransitionsCompleted = iTestNotifications = 0;
1917 iTestNotificationsExpected = testMemberCount;
1918 iTransitionsExpected = 1;
1920 iTransProgEvents = iTransFailEvents = iTransReqEvents = 0;
1922 iTransProgEventsExpected = iTransReqEventsExpected = observer->ObserverDomainCount();
1923 iTransFailEventsExpected = 0;
1925 iTestDomainManager->RequestDomainTransition(iTestDomainId, iTestState, ETraverseDefault);
1927 // wait for test transitions to complete
1928 CActiveScheduler::Start();
1929 test(iStatus == KErrNone);
1930 test(iTestNotifications == iTestNotificationsExpected);
1931 test (iTransProgEvents == iTransProgEventsExpected);
1932 test (iTransFailEvents == iTransFailEventsExpected);
1933 test (iTransReqEvents == iTransReqEventsExpected);
1935 // stop the observer & request another state change
1936 observer->StopObserver();
1938 iTestDomainId = KDmIdRoot;
1939 iTransitionsCompleted = iTestNotifications = 0;
1940 iTestNotificationsExpected = testMemberCount;
1941 iTransitionsExpected = 1;
1943 iTransProgEvents = iTransFailEvents = iTransReqEvents = 0;
1945 iTransProgEventsExpected = 0;
1946 iTransFailEventsExpected = 0;
1947 iTransReqEventsExpected = 0;
1949 iTestDomainManager->RequestDomainTransition(iTestDomainId, iTestState, ETraverseDefault);
1950 // wait for test transitions to complete
1951 CActiveScheduler::Start();
1952 test(iStatus == KErrNone);
1953 test(iTestNotifications == iTestNotificationsExpected);
1954 test (iTransProgEvents == iTransProgEventsExpected);
1955 test (iTransFailEvents == iTransFailEventsExpected);
1956 test (iTransReqEvents == iTransReqEventsExpected);
1958 // Start the observer again on a different domain and only ask for transition requests
1959 // Then request another state change
1960 observer->StartObserver((iObservedDomainId == KDmIdRoot)?KDmIdTestCA:KDmIdRoot, EDmNotifyTransRequest);
1962 iTestDomainId = KDmIdRoot;
1963 iTransitionsCompleted = iTestNotifications = 0;
1964 iTestNotificationsExpected = testMemberCount;
1965 iTransitionsExpected = 1;
1967 iTransProgEvents = iTransFailEvents = iTransReqEvents = 0;
1969 iTransReqEventsExpected = observer->ObserverDomainCount();
1970 iTransProgEventsExpected = 0;
1971 iTransFailEventsExpected = 0;
1974 iTestDomainManager->RequestDomainTransition(iTestDomainId, iTestState, ETraverseDefault);
1975 // wait for test transitions to complete
1976 CActiveScheduler::Start();
1977 test(iStatus == KErrNone);
1978 test(iTestNotifications == iTestNotificationsExpected);
1979 test (iTransProgEvents == iTransProgEventsExpected);
1980 test (iTransFailEvents == iTransFailEventsExpected);
1981 test (iTransReqEvents == iTransReqEventsExpected);
1986 //*************************************************
1987 // Test 7c - invalid arguments testing for observer
1988 //*************************************************
1989 test.Next(_L("Test 7c - Invalid arguments testing for observer"));
1991 const TDmHierarchyId KDmHierarchyIdInvalid = 110;
1993 test.Printf(_L("Test 7c.1 - create observer with invalid hierarchy Id\n"));
1995 // create an observer
1996 TRAP(r, observer = CHierarchyObserver::NewL(*this, KDmHierarchyIdInvalid));
1997 test (r == KErrBadHierarchyId);
2000 test.Printf(_L("Test 7c.2 - Starting the observer with wrong domain Id\n"));
2001 TRAP(r, observer = CHierarchyObserver::NewL(*this, KDmHierarchyIdTest));
2002 test (r == KErrNone);
2003 test(observer != NULL);
2006 const TDmDomainId KDmIdInvalid = 0x0f;
2007 r= observer->StartObserver(KDmIdInvalid, EDmNotifyAll);
2008 test(r==KDmErrBadDomainId);
2010 test.Printf(_L("Test 7c.3 - Trying to create second observer on the same hierarchy\n"));
2011 TRAP(r, CHierarchyObserver::NewL(*this, KDmHierarchyIdTest));
2012 test (r == KDmErrBadSequence);
2016 //*************************************************
2017 // Test 7d - Wrong sequence of API calls for observer
2018 //*************************************************
2019 test.Next(_L("Test 7d - Observer wrong sequence of calls"));
2021 test.Printf(_L("Test 7d.1 - Stopping Observer before starting it\n"));
2022 r = observer->StopObserver();
2023 test(r==KDmErrBadSequence);
2025 test.Printf(_L("Test 7d.2 - Starting Observer twice\n"));
2026 r= observer->StartObserver(KDmIdRoot, EDmNotifyAll);
2029 r= observer->StartObserver(KDmIdRoot, EDmNotifyAll);
2030 test(r==KDmErrBadSequence);
2035 /***************************************/
2037 delete iTestDomainManager;
2038 iTestDomainManager = NULL;
2040 CDomainMemberAo** mt;
2041 for (mt = iTestMembers; *mt; ++mt)
2045 // restore the domain hierarchies to their initial state so as not to
2046 // upset any subsequent tests which rely on this
2048 RDmDomainManager manager;
2049 TRequestStatus status;
2050 TInt r = manager.Connect(KDmHierarchyIdTest);
2051 test (r == KErrNone);
2052 manager.RequestDomainTransition(KDmIdRoot, EStartupCriticalStatic, ETraverseDefault, status);
2053 test(status.Int() == KRequestPending);
2054 User::WaitForRequest(status);
2055 test(status.Int() == KErrNone);
2062 // This handles a transition notification from a test domain member.
2063 TInt CDmTest7::TransitionNotification(MDmDomainMember& aDomainMember)
2066 iTestNotifications++;
2068 test (aDomainMember.HierarchyId() == KDmHierarchyIdTest);
2071 GetDomainDesc(aDomainMember.Ordinal(), buf);
2073 __PRINT((_L("CDmTest7::TransitionNotification(), Hierarchy = %d, domain = %S, iOrdinal = 0x%08X, state = 0x%x, status = %d\n"),
2074 aDomainMember.HierarchyId(), &buf, aDomainMember.Ordinal(), aDomainMember.State(), aDomainMember.Status()));
2079 void CDmTest7::RunL()
2081 iTransitionsCompleted++;
2083 __PRINT((_L("CDmTest7::RunL(), error = %d, iTestNotifications %d\n"),
2084 iStatus.Int(), iTestNotifications));
2086 TestForCompletion();
2089 void CDmTest7::TransitionRequestComplete()
2091 iTransitionsCompleted++;
2093 __PRINT((_L("CDmTest7::TransitionRequestComplete(), error = %d, iTestNotifications %d\n"),
2094 iStatus.Int(), iTestNotifications));
2096 TestForCompletion();
2099 void CDmTest7::DoCancel()
2104 void CDmTest7::Release()
2109 void CDmTest7::TestForCompletion()
2112 if (iTransitionsCompleted == iTransitionsExpected &&
2113 iTransProgEvents == iTransProgEventsExpected &&
2114 iTransFailEvents == iTransFailEventsExpected &&
2115 iTransReqEvents == iTransReqEventsExpected)
2117 CActiveScheduler::Stop();
2122 void CDmTest7::TransProgEvent(TDmDomainId aDomainId, TDmDomainState aState)
2124 void CDmTest7::TransProgEvent(TDmDomainId /*aDomainId*/, TDmDomainState /*aState*/)
2128 __PRINT((_L("CDmTest7::TransProgEvent(), aDomainId = %d, aState %d, iTransProgEvents %d\n"),
2129 aDomainId, aState, iTransProgEvents));
2130 TestForCompletion();
2134 void CDmTest7::TransFailEvent(TDmDomainId aDomainId, TDmDomainState aState, TInt aError)
2136 void CDmTest7::TransFailEvent(TDmDomainId /*aDomainId*/, TDmDomainState /*aState*/, TInt /*aError*/)
2141 __PRINT((_L("CDmTest7::TransFailEvent(), aDomainId = %d, aState %d aError %d, iTransFailEvents %d\n"),
2142 aDomainId, aState, iTransFailEvents, aError));
2143 TestForCompletion();
2147 void CDmTest7::TransReqEvent(TDmDomainId aDomainId, TDmDomainState aState)
2149 void CDmTest7::TransReqEvent(TDmDomainId /*aDomainId*/, TDmDomainState /*aState*/)
2153 __PRINT((_L("CDmTest7::TransReqEvent(), aDomainId = %d, aState %d, iTransReqEvents %d\n"),
2154 aDomainId, aState, iTransReqEvents));
2155 TestForCompletion();
2158 GLDEF_C TInt E32Main()
2160 CTrapCleanup* trapHandler=CTrapCleanup::New();
2161 test(trapHandler!=NULL);
2163 CActiveScheduler* scheduler = new CActiveScheduler();
2164 test(scheduler != NULL);
2165 CActiveScheduler::Install(scheduler);
2167 // Turn off evil lazy dll unloading
2169 test(l.Connect()==KErrNone);
2170 test(l.CancelLazyDllUnload()==KErrNone);
2174 // Perform the number of iterations specifed by the command line argument.
2176 // If no arguments - perform two iterations
2181 TInt len = User::CommandLineLength();
2184 // Copy the command line in a buffer
2185 HBufC* hb = HBufC::NewMax(len);
2187 TPtr cmd((TUint16*) hb->Ptr(), len);
2188 User::CommandLine(cmd);
2189 // Extract the number of iterations
2196 // strange command - silently ignore
2202 test.Start(_L("Testing"));
2204 test.Printf(_L("Go for %d iterations\n"), iter);
2206 // Remember the number of open handles. Just for a sanity check ....
2207 TInt start_thc, start_phc;
2208 RThread().HandleCount(start_phc, start_thc);
2215 new CDmTest1(KDmIdRoot, EPwStandby),
2216 new CDmTest1(KDmIdRoot, EPwOff),
2217 new CDmTest1(KDmIdRoot, EPwActive),
2218 new CDmTest1(KDmIdApps, EPwStandby),
2219 new CDmTest1(KDmIdApps, EPwOff),
2220 new CDmTest1(KDmIdApps, EPwActive),
2221 new CDmTest1(KDmIdUiApps, EPwStandby),
2222 new CDmTest1(KDmIdUiApps, EPwOff),
2223 new CDmTest1(KDmIdUiApps, EPwActive),
2224 new CDmTest2(EPwStandby),
2227 // platform security tests
2231 // note that we use a fictitious power state to prevent any
2232 new CDmTest5(KDmIdRoot, KDmIdRoot, EPwActive+10, EStartupCriticalDynamic),
2233 new CDmTest5(KDmIdUiApps, KDmIdTestAB, EPwActive+10, EStartupCriticalDynamic),
2240 new CDmTest7(KDmIdTestA),
2241 new CDmTest7(KDmIdRoot),
2245 for (unsigned int i = 0; i < sizeof(tests)/sizeof(*tests); ++i)
2247 test(tests[i] != NULL);
2248 tests[i]->Perform();
2249 tests[i]->Release();
2256 // Sanity check for open handles and for pending requests ...
2257 TInt end_thc, end_phc;
2258 RThread().HandleCount(end_phc, end_thc);
2259 test(start_thc == end_thc);
2260 test(start_phc == end_phc);
2261 test(RThread().RequestCount() >= 0);