1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/power/t_domain.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,2267 @@
1.4 +// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// e32test\power\t_domain.cpp
1.18 +// Overview:
1.19 +// Domain manager tests
1.20 +// API Information:
1.21 +// RDmDomain, RDmDomainManager CDmDomain, CDmDomainManager
1.22 +// Details:
1.23 +// - Test a variety of domain transitions, check the expected number of
1.24 +// notifications and the first expected ordinal. Verify results are
1.25 +// as expected.
1.26 +// - Test system standby, check the expected number of notifications and
1.27 +// the first expected ordinal. Use a timer to request a wakeup event.
1.28 +// Verify results are as expected.
1.29 +// - Test domain related simple error situations, verify results are
1.30 +// as expected.
1.31 +// - Perform platform security tests: launch a separate process with no
1.32 +// capabilities, verify that results are as expected.
1.33 +// - Test domain transitions by connecting to two domain hierarchies
1.34 +// simultaneously, add some test and power hierarchy members, verify
1.35 +// the expected target state, notifications and leaf nodes. Verify results.
1.36 +// - Verify that the same hierarchy can not be connected to more than once.
1.37 +// - Request a positive transition and request that the test domain use
1.38 +// ETraverseParentsFirst. Verify results are as expected and verify
1.39 +// domains are in the correct state.
1.40 +// - Request a negative transition and request that the test domain use
1.41 +// ETraverseChildrenFirst. Verify results are as expected.
1.42 +// - Request a positive transition with zero acknowledgements. Verify
1.43 +// results are as expected.
1.44 +// - Request a positive transition with error acknowledgements. Verify
1.45 +// results are as expected.
1.46 +// - Perform a variety of negative tests and verify results are as expected.
1.47 +// - Perform various tests on domain transitions with activated observer.
1.48 +// Verify results are as expected.
1.49 +// Platforms/Drives/Compatibility:
1.50 +// All.
1.51 +// Assumptions/Requirement/Pre-requisites:
1.52 +// Failures and causes:
1.53 +// Base Port information:
1.54 +//
1.55 +//
1.56 +
1.57 +#include <e32test.h>
1.58 +#include <domainmember.h>
1.59 +#include <domainmanager.h>
1.60 +#include <domainobserver.h>
1.61 +#include "domainpolicytest.h"
1.62 +#include <e32debug.h>
1.63 +#include <f32file.h>
1.64 +#include <e32ldr.h>
1.65 +#include <e32ldr_private.h>
1.66 +
1.67 +LOCAL_D RTest test(_L(" T_DOMAIN "));
1.68 +_LIT(KThreadName, "t_domain_panic_thread");
1.69 +
1.70 +#ifdef _DEBUG
1.71 +#define __PRINT(x) {RDebug::Print x;}
1.72 +#else
1.73 +#define __PRINT(x)
1.74 +#endif
1.75 +
1.76 +class CDmTestMember;
1.77 +
1.78 +// interface for test domain memebers.
1.79 +// Any test memeber should derive from this interface
1.80 +class MDmDomainMember
1.81 + {
1.82 +public:
1.83 + virtual TDmHierarchyId HierarchyId() = 0;
1.84 + virtual TDmDomainId DomainId() = 0;
1.85 + virtual TDmDomainState State() = 0;
1.86 + virtual TInt Status() = 0;
1.87 + virtual TUint32 Ordinal() = 0;
1.88 + virtual TInt Notifications() = 0;
1.89 + };
1.90 +
1.91 +class MDmTest
1.92 + {
1.93 +public:
1.94 + virtual void Perform() = 0;
1.95 + virtual void Release() = 0;
1.96 + virtual TInt TransitionNotification(MDmDomainMember& aDomainMember) = 0;
1.97 + virtual void TransitionRequestComplete() = 0;
1.98 + };
1.99 +
1.100 +// for the test hierarchy, we generate an ordinal for each domain
1.101 +// each byte of which describes the exact location of the domain in the hierarchy
1.102 +#define ORDINAL_FROM_DOMAINID0(id) (id)
1.103 +#define ORDINAL_FROM_DOMAINID1(parent, id) ((parent << 8) | (id))
1.104 +#define ORDINAL_FROM_DOMAINID2(grandparent, parent, id) ((grandparent << 16) | (parent << 8) | id)
1.105 +#define ORDINAL_FROM_DOMAINID3(greatgrandparent, grandparent, parent, id) ((greatgrandparent << 24) | (grandparent << 16) | (parent << 8) | id)
1.106 +#define PARENT_ORDINAL(id) (id >> 8)
1.107 +
1.108 +#define ORDINAL_LEVEL(ordinal) \
1.109 + ((ordinal & 0xFF00) == 0) ? 1 : \
1.110 + ((ordinal & 0xFF0000) == 0) ? 2 : \
1.111 + ((ordinal & 0xFF000000) == 0) ? 3 : 4;
1.112 +
1.113 +
1.114 +// get the least significant domain id character (for debugging purposes)
1.115 +TBool GetDomainChar(TDmDomainId aDomainId, TChar& aChar)
1.116 + {
1.117 + TBool found = ETrue;
1.118 + switch(aDomainId)
1.119 + {
1.120 +
1.121 + case KDmIdTestA: aChar = 'A'; break;
1.122 + case KDmIdTestB: aChar = 'B'; break;
1.123 + case KDmIdTestC: aChar = 'C'; break;
1.124 + case KDmIdTestAA: aChar = 'A'; break;
1.125 + case KDmIdTestAB: aChar = 'B'; break;
1.126 + case KDmIdTestBA: aChar = 'A'; break;
1.127 + case KDmIdTestCA: aChar = 'A'; break;
1.128 + case KDmIdTestABA: aChar = 'A'; break;
1.129 + case KDmIdTestABB: aChar = 'B'; break;
1.130 + case KDmIdTestCAA: aChar = 'A'; break;
1.131 + // domain char not found
1.132 + case KDmIdNone:
1.133 + case KDmIdRoot:
1.134 + default:
1.135 + found = EFalse;
1.136 + }
1.137 + return found;
1.138 + }
1.139 +
1.140 +// prints the 4-character domain string into the passed descriptor (for debugging purposes)
1.141 +// e.g. "CAA" for KDmIdTestCAA
1.142 +void GetDomainDesc(TUint32 aOrdinal, TDes& aDes)
1.143 + {
1.144 + if (aOrdinal == KDmIdRoot)
1.145 + {
1.146 + aDes.Append(_L("root"));
1.147 + return;
1.148 + }
1.149 +
1.150 + TUint32 val = aOrdinal;
1.151 +
1.152 + for (TInt n=0; n<4; n++)
1.153 + {
1.154 + TDmDomainId domainId = (TDmDomainId) (val >> 24);
1.155 + TChar ch;
1.156 + TBool found = GetDomainChar(domainId, ch);
1.157 + if (found)
1.158 + aDes.Append(ch);
1.159 + val = val << 8;
1.160 + }
1.161 +
1.162 + }
1.163 +
1.164 +
1.165 +class CDmTestMember : public CActive, public MDmDomainMember
1.166 + {
1.167 +public:
1.168 + // from CActive
1.169 + void RunL();
1.170 + // from MDmDomainMember
1.171 + inline TDmHierarchyId HierarchyId() {return iHierarchy;};
1.172 + inline TDmDomainId DomainId() {return iId;};
1.173 + inline TDmDomainState State() {return iState;};
1.174 + inline TInt Status() {return iStatus.Int();};
1.175 + inline TUint32 Ordinal() {return iOrdinal;};
1.176 + inline TInt Notifications() {return iNotifications;};
1.177 +
1.178 + CDmTestMember(TDmHierarchyId aHierarchy, TDmDomainId aId, TUint32 aOrdinal, MDmTest*);
1.179 + ~CDmTestMember();
1.180 + void Acknowledge();
1.181 +
1.182 +protected:
1.183 + // from CActive
1.184 + virtual void DoCancel();
1.185 +
1.186 +
1.187 +public:
1.188 + TDmHierarchyId iHierarchy;
1.189 + TDmDomainId iId;
1.190 + TDmDomainState iState;
1.191 + TUint32 iOrdinal;
1.192 + MDmTest* iTest;
1.193 + TInt iNotifications;
1.194 + RDmDomain iDomain;
1.195 + };
1.196 +
1.197 +
1.198 +
1.199 +CDmTestMember::CDmTestMember(TDmHierarchyId aHierarchy, TDmDomainId aId, TUint32 aOrdinal, MDmTest* aTest) : CActive(CActive::EPriorityStandard),
1.200 + iHierarchy(aHierarchy), iId(aId), iOrdinal(aOrdinal), iTest(aTest)
1.201 + {
1.202 + TInt r;
1.203 +
1.204 + if (iHierarchy == KDmHierarchyIdPower)
1.205 + r = iDomain.Connect(iId);
1.206 + else
1.207 + r = iDomain.Connect(iHierarchy, iId);
1.208 +
1.209 + test(r == KErrNone);
1.210 +
1.211 + CActiveScheduler::Add(this);
1.212 +
1.213 + iDomain.RequestTransitionNotification(CActive::iStatus);
1.214 + CActive::SetActive();
1.215 + }
1.216 +
1.217 +CDmTestMember::~CDmTestMember()
1.218 + {
1.219 + CActive::Cancel();
1.220 + iDomain.Close();
1.221 + }
1.222 +
1.223 +void CDmTestMember::Acknowledge()
1.224 + {
1.225 + iDomain.AcknowledgeLastState();
1.226 + }
1.227 +
1.228 +void CDmTestMember::RunL()
1.229 + {
1.230 +
1.231 + iNotifications++;
1.232 +
1.233 + iState = iDomain.GetState();
1.234 +
1.235 + TInt ackError = iTest->TransitionNotification(*this);
1.236 + if (ackError == KErrNone)
1.237 + iDomain.AcknowledgeLastState();
1.238 + else if (ackError == KErrAbort) // don't acknowledge
1.239 + ;
1.240 + else
1.241 + iDomain.AcknowledgeLastState(ackError);
1.242 +
1.243 +
1.244 + // request another notification (even if we didn't acknowledge the last one)
1.245 + iDomain.RequestTransitionNotification(CActive::iStatus);
1.246 + CActive::SetActive();
1.247 + }
1.248 +
1.249 +void CDmTestMember::DoCancel()
1.250 + {
1.251 + iDomain.CancelTransitionNotification();
1.252 + }
1.253 +
1.254 +
1.255 +// CDomainMemberAo
1.256 +class CDomainMemberAo : public CDmDomain, public MDmDomainMember
1.257 + {
1.258 +public:
1.259 + static CDomainMemberAo* NewL(TDmHierarchyId aHierarchy, TDmDomainId aId, TUint32 aOrdinal, MDmTest*);
1.260 + ~CDomainMemberAo();
1.261 +
1.262 + // from CActive
1.263 + void RunL();
1.264 +
1.265 + // from MDmDomainMember
1.266 + inline TDmHierarchyId HierarchyId() {return iHierarchy;};
1.267 + inline TDmDomainId DomainId() {return iId;};
1.268 + inline TDmDomainState State() {return iState;};
1.269 + inline TInt Status() {return iStatus.Int();};
1.270 + inline TUint32 Ordinal() {return iOrdinal;};
1.271 + inline TInt Notifications() {return iNotifications;};
1.272 +
1.273 +private:
1.274 + CDomainMemberAo(TDmHierarchyId aHierarchy, TDmDomainId aId, TUint32 aOrdinal, MDmTest*);
1.275 +
1.276 +public:
1.277 + TDmHierarchyId iHierarchy;
1.278 + TDmDomainId iId;
1.279 + TDmDomainState iState;
1.280 + TUint32 iOrdinal;
1.281 + MDmTest* iTest;
1.282 + TInt iNotifications;
1.283 + };
1.284 +
1.285 +CDomainMemberAo* CDomainMemberAo::NewL(TDmHierarchyId aHierarchy, TDmDomainId aId, TUint32 aOrdinal, MDmTest* aTest)
1.286 + {
1.287 + CDomainMemberAo* self=new (ELeave) CDomainMemberAo(aHierarchy, aId, aOrdinal, aTest);
1.288 + CleanupStack::PushL(self);
1.289 + self->ConstructL();
1.290 +
1.291 + self->RequestTransitionNotification();
1.292 +
1.293 + CleanupStack::Pop();
1.294 + return self;
1.295 + }
1.296 +
1.297 +CDomainMemberAo::CDomainMemberAo(TDmHierarchyId aHierarchy, TDmDomainId aId, TUint32 aOrdinal, MDmTest* aTest) :
1.298 + CDmDomain(aHierarchy, aId),
1.299 + iHierarchy(aHierarchy), iId(aId), iOrdinal(aOrdinal), iTest(aTest)
1.300 + {
1.301 + }
1.302 +
1.303 +CDomainMemberAo::~CDomainMemberAo()
1.304 + {
1.305 + Cancel();
1.306 + }
1.307 +
1.308 +void CDomainMemberAo::RunL()
1.309 + {
1.310 + iNotifications++;
1.311 +
1.312 + iState = GetState();
1.313 +
1.314 + TInt ackError = iTest->TransitionNotification(*this);
1.315 + if (ackError == KErrNone)
1.316 + AcknowledgeLastState(ackError);
1.317 + else if (ackError == KErrAbort) // don't acknowledge
1.318 + ;
1.319 + else
1.320 + AcknowledgeLastState(ackError);
1.321 + if (ackError != KErrAbort)
1.322 + AcknowledgeLastState(ackError);
1.323 +
1.324 +
1.325 + // request another notification (even if we didn't acknowledge the last one)
1.326 + RequestTransitionNotification();
1.327 + }
1.328 +
1.329 +
1.330 +// CDomainManagerAo
1.331 +class CDomainManagerAo : public CDmDomainManager
1.332 + {
1.333 +public:
1.334 + ~CDomainManagerAo();
1.335 + static CDomainManagerAo* NewL(TDmHierarchyId aHierarchy, MDmTest& aTest);
1.336 +
1.337 + // from CActive
1.338 + void RunL();
1.339 +
1.340 +private:
1.341 + CDomainManagerAo(TDmHierarchyId aHierarchy, MDmTest& aTest);
1.342 +
1.343 +private:
1.344 + MDmTest& iTest;
1.345 + };
1.346 +
1.347 +
1.348 +CDomainManagerAo* CDomainManagerAo::NewL(TDmHierarchyId aHierarchy, MDmTest& aTest)
1.349 + {
1.350 + CDomainManagerAo* self=new (ELeave) CDomainManagerAo(aHierarchy, aTest);
1.351 + CleanupStack::PushL(self);
1.352 +
1.353 + self->ConstructL();
1.354 + CleanupStack::Pop();
1.355 + return self;
1.356 + }
1.357 +
1.358 +CDomainManagerAo::CDomainManagerAo(TDmHierarchyId aHierarchy, MDmTest& aTest) :
1.359 + CDmDomainManager(aHierarchy), iTest(aTest)
1.360 + {
1.361 + }
1.362 +
1.363 +CDomainManagerAo::~CDomainManagerAo()
1.364 + {
1.365 + }
1.366 +
1.367 +void CDomainManagerAo::RunL()
1.368 + {
1.369 + iTest.TransitionRequestComplete();
1.370 + }
1.371 +
1.372 +
1.373 +class CDmTest1 : public CActive, public MDmTest
1.374 + {
1.375 +public: // from CActive
1.376 + void RunL();
1.377 +
1.378 + // from MDmTest
1.379 + void Perform();
1.380 + void Release();
1.381 + TInt TransitionNotification(MDmDomainMember& aDomainMember);
1.382 + void TransitionRequestComplete() {};
1.383 +
1.384 + CDmTest1 (TDmDomainId aId, TDmDomainState aState) : CActive(CActive::EPriorityStandard), iDomainId(aId), iState((TPowerState) aState) {}
1.385 +
1.386 +protected:
1.387 + // from CActive
1.388 + virtual void DoCancel();
1.389 +
1.390 +private:
1.391 + enum { KMembersMax = 16 };
1.392 + CDmTestMember* iMembers[KMembersMax];
1.393 + RDmDomainManager iManager;
1.394 + TDmDomainId iDomainId;
1.395 + TPowerState iState;
1.396 + TBool iAcknowledge;
1.397 + TInt iMembersCount;
1.398 + TInt iCount;
1.399 + TUint32 iOrdinal;
1.400 + };
1.401 +
1.402 +void CDmTest1::Perform()
1.403 + {
1.404 + //
1.405 + // Test domain transitions
1.406 + //
1.407 +
1.408 + test.Next(_L("Test 1"));
1.409 + test.Printf(_L("Domain id = 0x%x Target State = 0x%x\n"), iDomainId, iState);
1.410 + iMembers[0] = new CDmTestMember(KDmHierarchyIdPower, KDmIdRoot, 0, this);
1.411 + test(iMembers[0] != NULL);
1.412 + iMembers[1] = new CDmTestMember(KDmHierarchyIdPower, KDmIdRoot, 0, this);
1.413 + test(iMembers[1] != NULL);
1.414 + iMembers[2] = new CDmTestMember(KDmHierarchyIdPower, KDmIdApps, 1, this);
1.415 + test(iMembers[2] != NULL);
1.416 + iMembers[3] = new CDmTestMember(KDmHierarchyIdPower, KDmIdApps, 1, this);
1.417 + test(iMembers[3] != NULL);
1.418 + iMembers[4] = new CDmTestMember(KDmHierarchyIdPower, KDmIdUiApps, 1, this);
1.419 + test(iMembers[4] != NULL);
1.420 + iMembers[5] = new CDmTestMember(KDmHierarchyIdPower, KDmIdUiApps, 1, this);
1.421 + test(iMembers[5] != NULL);
1.422 +
1.423 + // expected number of notifications
1.424 + iMembersCount = (iDomainId == KDmIdRoot) ? 6 : 2;
1.425 + // first expected ordinal
1.426 + iOrdinal = (iState == EPwActive) ? 0 : 1;
1.427 +
1.428 + TInt r = iManager.Connect();
1.429 + test(r == KErrNone);
1.430 +
1.431 + CActiveScheduler::Add(this);
1.432 +
1.433 + iManager.RequestDomainTransition(iDomainId, iState, CActive::iStatus);
1.434 + CActive::SetActive();
1.435 +
1.436 + CActiveScheduler::Start();
1.437 + }
1.438 +
1.439 +TInt CDmTest1::TransitionNotification(MDmDomainMember& aDomainMember)
1.440 + {
1.441 + ++iCount;
1.442 + if (aDomainMember.State() == EPwActive)
1.443 + {
1.444 + if(aDomainMember.Ordinal() < iOrdinal)
1.445 + {
1.446 + // Making the test to fail in RunL function inorder to complete the cleanup from domain manager.
1.447 + test.Printf(_L("Making test to fail as Ordinal Mismatch Expected : %d, Returned : %d"), aDomainMember.Ordinal(), iOrdinal);
1.448 + iCount--;
1.449 + }
1.450 + }
1.451 + else
1.452 + {
1.453 + if(aDomainMember.Ordinal() > iOrdinal)
1.454 + {
1.455 + //Making the test to fail in RunL function inorder to complete the cleanup from domain manager.
1.456 + test.Printf(_L("Making test to fail as Ordinal Mismatch Expected : %d, Returned : %d"), aDomainMember.Ordinal(), iOrdinal);
1.457 + iCount--;
1.458 + }
1.459 + }
1.460 + iOrdinal = aDomainMember.Ordinal();
1.461 +
1.462 + // acknowledge one from two
1.463 + iAcknowledge = !iAcknowledge;
1.464 + return iAcknowledge?KErrNone:KErrGeneral;
1.465 + }
1.466 +
1.467 +void CDmTest1::RunL()
1.468 + {
1.469 + CActiveScheduler::Stop();
1.470 +
1.471 + iManager.Close();
1.472 +
1.473 + CDmTestMember** mp;
1.474 + for (mp = iMembers; *mp; ++mp)
1.475 + delete *mp;
1.476 + test(iCount == iMembersCount);
1.477 + }
1.478 +
1.479 +void CDmTest1::DoCancel()
1.480 + {
1.481 + test(0);
1.482 + }
1.483 +
1.484 +void CDmTest1::Release()
1.485 + {
1.486 + delete this;
1.487 + }
1.488 +
1.489 +class CDmTest2Timer : public CTimer
1.490 + {
1.491 +public: // fomr CTimer
1.492 + void RunL();
1.493 +public:
1.494 + CDmTest2Timer() : CTimer(0)
1.495 + {
1.496 + TRAPD(r,
1.497 + ConstructL());
1.498 + test(r == KErrNone);
1.499 + CActiveScheduler::Add(this);
1.500 + }
1.501 + };
1.502 +
1.503 +void CDmTest2Timer::RunL()
1.504 + {
1.505 + test.Printf(_L("Tick count after CDmTest2Timer::RunL() = %d\n"), User::NTickCount());
1.506 +
1.507 + // kick the timer again in case power down hasn't happened yet
1.508 + TTime wakeup;
1.509 + wakeup.HomeTime();
1.510 + wakeup += TTimeIntervalSeconds(3);
1.511 + At(wakeup);
1.512 + }
1.513 +
1.514 +class CDmTest2 : public CActive, public MDmTest
1.515 + {
1.516 +public: // from CActive
1.517 + void RunL();
1.518 +
1.519 + // from MDmTest
1.520 + void Perform();
1.521 + void Release();
1.522 + TInt TransitionNotification(MDmDomainMember& aDomainMember);
1.523 + void TransitionRequestComplete() {};
1.524 + CDmTest2 (TDmDomainState aState) : CActive(CActive::EPriorityStandard), iState((TPowerState) aState) {}
1.525 +
1.526 +protected:
1.527 + // from CActive
1.528 + virtual void DoCancel();
1.529 +
1.530 +private:
1.531 + enum { KMembersMax = 16 };
1.532 + CDmTestMember* iMembers[KMembersMax];
1.533 + RDmDomainManager iManager;
1.534 + TPowerState iState;
1.535 + TBool iAcknowledge;
1.536 + TInt iMembersCount;
1.537 + TInt iCount;
1.538 + TUint32 iOrdinal;
1.539 + CDmTest2Timer* iTimer;
1.540 + };
1.541 +
1.542 +
1.543 +void CDmTest2::Perform()
1.544 + {
1.545 + //
1.546 + // Test system standby
1.547 + //
1.548 +
1.549 + test.Next(_L("Test 2"));
1.550 + test.Printf(_L("Target State = 0x%x\n"), iState);
1.551 + iMembers[0] = new CDmTestMember(KDmHierarchyIdPower, KDmIdRoot, 0, this);
1.552 + test(iMembers[0] != NULL);
1.553 + iMembers[1] = new CDmTestMember(KDmHierarchyIdPower, KDmIdRoot, 0, this);
1.554 + test(iMembers[1] != NULL);
1.555 + iMembers[2] = new CDmTestMember(KDmHierarchyIdPower, KDmIdApps, 1, this);
1.556 + test(iMembers[2] != NULL);
1.557 + iMembers[3] = new CDmTestMember(KDmHierarchyIdPower, KDmIdApps, 1, this);
1.558 + test(iMembers[3] != NULL);
1.559 + iMembers[4] = new CDmTestMember(KDmHierarchyIdPower, KDmIdUiApps, 1, this);
1.560 + test(iMembers[4] != NULL);
1.561 + iMembers[5] = new CDmTestMember(KDmHierarchyIdPower, KDmIdUiApps, 1, this);
1.562 + test(iMembers[5] != NULL);
1.563 +
1.564 + // expected number of notifications
1.565 + iMembersCount = 12;
1.566 + // first expected ordinal
1.567 + iOrdinal = (iState == EPwActive) ? 0 : 1;
1.568 +
1.569 + TInt r = iManager.Connect();
1.570 + test(r == KErrNone);
1.571 +
1.572 + CActiveScheduler::Add(this);
1.573 +
1.574 + // Use an absolute timer to request a wakeup event
1.575 + iTimer = new CDmTest2Timer();
1.576 + TTime wakeup;
1.577 + wakeup.HomeTime();
1.578 + wakeup += TTimeIntervalSeconds(5);
1.579 + test.Printf(_L("Tick count before timer = %d\n"), User::NTickCount());
1.580 + iTimer->At(wakeup);
1.581 +
1.582 + iManager.RequestSystemTransition(iState, CActive::iStatus);
1.583 + CActive::SetActive();
1.584 +
1.585 + CActiveScheduler::Start();
1.586 + }
1.587 +
1.588 +TInt CDmTest2::TransitionNotification(MDmDomainMember& aDomainMember)
1.589 + {
1.590 + ++iCount;
1.591 + if (aDomainMember.State() == EPwActive)
1.592 + {
1.593 + if(aDomainMember.Ordinal() < iOrdinal)
1.594 + {
1.595 + // Making the test to fail in RunL function inorder to complete the cleanup from domain manager.
1.596 + test.Printf(_L("Making test to fail as Ordinal Mismatch Expected : %d, Returned : %d, State : %d"),
1.597 + aDomainMember.Ordinal(), iOrdinal, aDomainMember.State());
1.598 + iCount--;
1.599 + }
1.600 + }
1.601 + else
1.602 + {
1.603 + if(aDomainMember.Ordinal() > iOrdinal)
1.604 + {
1.605 + // Making the test to fail in RunL function inorder to complete the cleanup from domain manager.
1.606 + test.Printf(_L("Making test to fail as Ordinal Mismatch Expected : %d, Returned : %d, State: %d"),
1.607 + aDomainMember.Ordinal(), iOrdinal, aDomainMember.State());
1.608 + iCount--;
1.609 + }
1.610 + }
1.611 + iOrdinal = aDomainMember.Ordinal();
1.612 +
1.613 + // acknowledge one from two
1.614 + iAcknowledge = !iAcknowledge;
1.615 + return iAcknowledge?KErrNone:KErrAbort;
1.616 + }
1.617 +
1.618 +void CDmTest2::RunL()
1.619 + {
1.620 + test.Printf(_L("Tick count after CDmTest2::RunL() = %d\n"), User::NTickCount());
1.621 +
1.622 + iTimer->Cancel();
1.623 + CActiveScheduler::Stop();
1.624 +
1.625 + iManager.Close();
1.626 +
1.627 + CDmTestMember** mp;
1.628 + for (mp = iMembers; *mp; ++mp)
1.629 + delete *mp;
1.630 + test(CActive::iStatus == KErrTimedOut);
1.631 + test(iCount == iMembersCount);
1.632 + }
1.633 +
1.634 +void CDmTest2::DoCancel()
1.635 + {
1.636 + test(0);
1.637 + }
1.638 +
1.639 +void CDmTest2::Release()
1.640 + {
1.641 + if (iTimer)
1.642 + {
1.643 + iTimer->Cancel();
1.644 + delete iTimer;
1.645 + }
1.646 + delete this;
1.647 + }
1.648 +
1.649 +class CDmTest3 : public MDmTest
1.650 + {
1.651 +public:
1.652 + // from MDmTest
1.653 + void Perform();
1.654 + void Release();
1.655 + TInt TransitionNotification(MDmDomainMember& aDomainMember);
1.656 + void TransitionRequestComplete() {};
1.657 + };
1.658 +
1.659 +void CDmTest3::Perform()
1.660 + {
1.661 + //
1.662 + // Test simple error situation
1.663 + //
1.664 + RDmDomainManager manager;
1.665 + TInt r = manager.Connect();
1.666 + test(r == KErrNone);
1.667 +
1.668 + RDmDomainManager manager1;
1.669 + r = manager1.Connect();
1.670 + test(r == KErrInUse);
1.671 +
1.672 + RDmDomain domain;
1.673 + r = domain.Connect(KDmIdNone);
1.674 + test(r == KDmErrBadDomainId);
1.675 + CDmTestMember* testMember;
1.676 + testMember = new CDmTestMember(KDmHierarchyIdPower, KDmIdApps, 1, this);
1.677 + test (testMember != NULL);
1.678 +
1.679 + TRequestStatus status;
1.680 + manager.RequestDomainTransition(KDmIdApps, EPwStandby, status);
1.681 + test(status.Int() == KRequestPending);
1.682 +
1.683 + TRequestStatus status1;
1.684 + manager.RequestDomainTransition(KDmIdApps, EPwActive, status1);
1.685 + User::WaitForRequest(status1);
1.686 + test(status1.Int() == KDmErrBadSequence);
1.687 + User::WaitForRequest(status);
1.688 + test(status.Int() == KErrTimedOut);
1.689 +
1.690 + // Since this test doesn't start the active scheduler, a domain member's RunL() will
1.691 + // not get called so we need to re-request a domain transition notification manually
1.692 + User::WaitForRequest(testMember->iStatus);
1.693 + test(testMember->iStatus.Int() == KErrNone);
1.694 + testMember->iDomain.RequestTransitionNotification(testMember->iStatus);
1.695 +
1.696 + manager.RequestDomainTransition(KDmIdApps, EPwActive, status);
1.697 + test(status.Int() == KRequestPending);
1.698 + manager.CancelTransition();
1.699 + test(status.Int() == KErrCancel);
1.700 + manager.CancelTransition();
1.701 + User::WaitForRequest(status);
1.702 + test(status.Int() == KErrCancel);
1.703 +
1.704 + testMember->iDomain.CancelTransitionNotification();
1.705 +
1.706 + delete testMember;
1.707 +
1.708 + domain.Close();
1.709 + manager.Close();
1.710 + }
1.711 +
1.712 +TInt CDmTest3::TransitionNotification(MDmDomainMember& /*aDomainMember*/)
1.713 + {
1.714 + test(0);
1.715 + return KErrAbort; // don't acknowledge
1.716 + }
1.717 +
1.718 +void CDmTest3::Release()
1.719 + {
1.720 + delete this;
1.721 + }
1.722 +
1.723 +class CDmTest4 : public MDmTest
1.724 + {
1.725 +public:
1.726 + // from MDmTest
1.727 + void Perform();
1.728 + void Release();
1.729 + TInt TransitionNotification(MDmDomainMember& aDomainMember);
1.730 + void TransitionRequestComplete() {};
1.731 +private:
1.732 + void ExecSlave(TUint arg);
1.733 + };
1.734 +
1.735 +_LIT(KSecuritySlavePath, "t_domain_slave.exe");
1.736 +
1.737 +void CDmTest4::ExecSlave(TUint aArg)
1.738 + {
1.739 + RProcess proc;
1.740 + TInt r = proc.Create(KSecuritySlavePath, TPtrC((TUint16*) &aArg, sizeof(aArg)/sizeof(TUint16)));
1.741 + test(r == KErrNone);
1.742 + TRequestStatus status;
1.743 + proc.Logon(status);
1.744 + proc.Resume();
1.745 + User::WaitForRequest(status);
1.746 +
1.747 + RDebug::Printf("CDmTest4::ExecSlave(%d) ExitType %d", aArg, proc.ExitType() );
1.748 + RDebug::Printf("CDmTest4::ExecSlave(%d) ExitReason %d", aArg, proc.ExitReason() );
1.749 + test(proc.ExitType() == EExitKill);
1.750 +// test(proc.ExitReason() == KErrPermissionDenied);
1.751 +
1.752 + CLOSE_AND_WAIT(proc);
1.753 + }
1.754 +
1.755 +//! @SYMTestCaseID PBASE-T_DOMAIN-4
1.756 +//! @SYMTestType CT
1.757 +//! @SYMTestCaseDesc Dmain manager security tests
1.758 +//! @SYMREQ 3722
1.759 +//! @SYMTestActions Launches a separate process with no capabilities
1.760 +//! @SYMTestExpectedResults DM APIs should fail with KErrPermissionDenied
1.761 +//! @SYMTestPriority High
1.762 +//! @SYMTestStatus Defined
1.763 +void CDmTest4::Perform()
1.764 + {
1.765 + //
1.766 + // Security tests
1.767 + //
1.768 +
1.769 + ExecSlave(0);
1.770 +
1.771 + ExecSlave(1);
1.772 +
1.773 + }
1.774 +
1.775 +TInt CDmTest4::TransitionNotification(MDmDomainMember& /*aDomainMember*/)
1.776 + {
1.777 + test(0);
1.778 + return KErrNone;
1.779 + }
1.780 +
1.781 +void CDmTest4::Release()
1.782 + {
1.783 + delete this;
1.784 + }
1.785 +
1.786 +// Test hierarchy tests
1.787 +class CDmTestStartupMember : public CDmTestMember
1.788 + {
1.789 +public:
1.790 + CDmTestStartupMember(TDmHierarchyId aHierarchy, TDmDomainId aId, TUint32 aOrdinal, MDmTest*);
1.791 +
1.792 +public:
1.793 +private:
1.794 + };
1.795 +
1.796 +CDmTestStartupMember::CDmTestStartupMember(TDmHierarchyId aHierarchy, TDmDomainId aId, TUint32 aOrdinal, MDmTest* aTest)
1.797 + : CDmTestMember(aHierarchy, aId, aOrdinal, aTest)
1.798 + {
1.799 + }
1.800 +
1.801 +// Simultaneously testing of test domain defined in DomainPolicy99.dll
1.802 +// and the power domain defined in DomainPolicy.dll
1.803 +class CDmTest5 : public CActive, public MDmTest
1.804 + {
1.805 +public:
1.806 + // from CActive
1.807 + void RunL();
1.808 + // from MDmTest
1.809 + void Perform();
1.810 + void Release();
1.811 + TInt TransitionNotification(MDmDomainMember& aDomainMember);
1.812 + void TransitionRequestComplete();
1.813 + CDmTest5(TDmDomainId aPowerId, TDmDomainId aTestId, TDmDomainState aPowerState, TDmDomainState aTestState) :
1.814 + CActive(CActive::EPriorityStandard),
1.815 + iPowerDomainId(aPowerId), iTestDomainId(aTestId), iPowerState(aPowerState), iTestState(aTestState) {}
1.816 +protected:
1.817 + // from CActive
1.818 + virtual void DoCancel();
1.819 +
1.820 +private:
1.821 + enum { KMembersMax = 16 };
1.822 + enum TAckMode{ KAckAlways, KAckNever, KAckError, KAckOddDomainsOnly };
1.823 +
1.824 + CDmTestMember* iTestMembers[KMembersMax];
1.825 + CDomainMemberAo* iPowerMembers[KMembersMax];
1.826 +
1.827 + RDmDomainManager iTestDomainManager;
1.828 +
1.829 + TDmDomainId iPowerDomainId;
1.830 + TDmDomainId iTestDomainId;
1.831 +
1.832 + TDmDomainState iPowerState;
1.833 + TDmDomainState iTestState;
1.834 +
1.835 + // level number for iTestDomainId. E.g 1 for KDmIdRoot, 2 for KDmIdTestA, etc.
1.836 + TInt iTestDomainLevel;
1.837 +
1.838 + TDmTraverseDirection iTraverseDirection;
1.839 +
1.840 + TAckMode iAckMode;
1.841 +
1.842 +public:
1.843 + TInt iTestNotifications;
1.844 + TInt iPowerNotifications;
1.845 + TInt iTestNotificationsExpected;
1.846 + TInt iPowerNotificationsExpected;
1.847 +
1.848 + TInt iTransitionsCompleted;
1.849 + TInt iTransitionsExpected;
1.850 + };
1.851 +
1.852 +
1.853 +
1.854 +//! @SYMTestCaseID PBASE-T_DOMAIN-5
1.855 +//! @SYMTestType CT
1.856 +//! @SYMTestCaseDesc Connects to two domain hierarchies simulteneously and perform various tests
1.857 +//! @SYMREQ 3704,3705,3706,3707,3708,3709,3710,3711,3720,3721,3724,3725,3726,3727
1.858 +//! @SYMTestActions Open two hiearchies simultaneously and perform various actions.
1.859 +//! @SYMTestExpectedResults All tests should pass
1.860 +//! @SYMTestPriority High
1.861 +//! @SYMTestStatus Defined
1.862 +void CDmTest5::Perform()
1.863 + {
1.864 +
1.865 + __UHEAP_MARK;
1.866 +
1.867 + //
1.868 + // Test domain transitions
1.869 + //
1.870 + CActiveScheduler::Add(this);
1.871 +
1.872 + TInt r = RDmDomainManager::AddDomainHierarchy(KDmHierarchyIdTest);
1.873 +
1.874 + RDebug::Printf("RDmDomainManager::AddDomainHierarchy returns %d", r );
1.875 +
1.876 + test(r == KErrNone);
1.877 +
1.878 + CDomainManagerAo* powerDomainManager = NULL;
1.879 + TRAP(r, powerDomainManager = CDomainManagerAo::NewL(KDmHierarchyIdPower, *this));
1.880 + test (powerDomainManager != NULL);
1.881 +
1.882 + r = CDomainManagerAo::AddDomainHierarchy(KDmHierarchyIdPower);
1.883 + test(r == KErrNone);
1.884 +
1.885 + //*************************************************
1.886 + // Test 5a - connect to two domain hierarchies simultaneously
1.887 + //*************************************************
1.888 + test.Next(_L("Test 5a - connect to two domain hierarchies simultaneously"));
1.889 +
1.890 + test.Printf(_L("Domain id = 0x%x, Target State = 0x%x\n"), iTestDomainId, iTestState);
1.891 +
1.892 + TInt testMemberCount = 0;
1.893 +
1.894 + // Add some test hierarchy members - these use the RDmDomain API
1.895 + iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdRoot, ORDINAL_FROM_DOMAINID0(KDmIdRoot), this);
1.896 + test(iTestMembers[testMemberCount++] != NULL);
1.897 + iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdRoot, ORDINAL_FROM_DOMAINID0(KDmIdRoot), this);
1.898 + test(iTestMembers[testMemberCount++] != NULL);
1.899 +
1.900 + // row 1
1.901 + iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdTestA, ORDINAL_FROM_DOMAINID1(KDmIdRoot, KDmIdTestA), this);
1.902 + test(iTestMembers[testMemberCount++] != NULL);
1.903 + iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdTestB, ORDINAL_FROM_DOMAINID1(KDmIdRoot, KDmIdTestB), this);
1.904 + test(iTestMembers[testMemberCount++] != NULL);
1.905 + iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdTestC, ORDINAL_FROM_DOMAINID1(KDmIdRoot, KDmIdTestC), this);
1.906 + test(iTestMembers[testMemberCount++] != NULL);
1.907 +
1.908 + // row2
1.909 + iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdTestAA, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestA, KDmIdTestAA), this);
1.910 + test(iTestMembers[testMemberCount++] != NULL);
1.911 + iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdTestAB, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestA, KDmIdTestAB), this);
1.912 + test(iTestMembers[testMemberCount++] != NULL);
1.913 + iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdTestBA, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestB, KDmIdTestBA), this);
1.914 + test(iTestMembers[testMemberCount++] != NULL);
1.915 + iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdTestCA, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestC, KDmIdTestCA), this);
1.916 + test(iTestMembers[testMemberCount++] != NULL);
1.917 +
1.918 + // row 3
1.919 + iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdTestABA, ORDINAL_FROM_DOMAINID3(KDmIdRoot, KDmIdTestA, KDmIdTestAB, KDmIdTestABA), this);
1.920 + test(iTestMembers[testMemberCount++] != NULL);
1.921 + iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdTestABB, ORDINAL_FROM_DOMAINID3(KDmIdRoot, KDmIdTestA, KDmIdTestAB, KDmIdTestABB), this);
1.922 + test(iTestMembers[testMemberCount++] != NULL);
1.923 + iTestMembers[testMemberCount] = new CDmTestMember(KDmHierarchyIdTest, KDmIdTestCAA, ORDINAL_FROM_DOMAINID3(KDmIdRoot, KDmIdTestC, KDmIdTestCA, KDmIdTestCAA), this);
1.924 + test(iTestMembers[testMemberCount++] != NULL);
1.925 +
1.926 + // add some power hierarchy members - these use the CDmDomain AO API
1.927 + TInt powerMemberCount = 0;
1.928 + TRAP(r, iPowerMembers[powerMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdPower, KDmIdRoot, KDmIdRoot, this));
1.929 + test(iTestMembers[powerMemberCount++] != NULL);
1.930 + TRAP(r, iPowerMembers[powerMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdPower, KDmIdApps, KDmIdApps, this));
1.931 + test(iTestMembers[powerMemberCount++] != NULL);
1.932 + TRAP(r, iPowerMembers[powerMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdPower, KDmIdUiApps, KDmIdUiApps, this));
1.933 + test(iTestMembers[powerMemberCount++] != NULL);
1.934 +
1.935 +
1.936 + RArray<const TTransitionFailure> testFailures;
1.937 + TInt testFailureCount;
1.938 + RArray<const TTransitionFailure> powerFailures;
1.939 + TInt powerFailureCount;
1.940 +
1.941 +
1.942 +
1.943 + // calculate the expected number of notifications
1.944 + TInt expectedTestNotifications = 0;
1.945 + TInt leafNodes = 0;
1.946 +
1.947 +
1.948 + // work out the domain level, the number of leaf nodes and the expected number of
1.949 + // notifications for the domain that is being transitioned
1.950 + switch(iTestDomainId)
1.951 + {
1.952 + case KDmIdRoot : iTestDomainLevel = 1; leafNodes = 5; expectedTestNotifications = testMemberCount; break;
1.953 + case KDmIdTestA : iTestDomainLevel = 2; leafNodes = 3; expectedTestNotifications = 5; break;
1.954 + case KDmIdTestB : iTestDomainLevel = 2; leafNodes = 1; expectedTestNotifications = 2; break;
1.955 + case KDmIdTestC : iTestDomainLevel = 2; leafNodes = 1; expectedTestNotifications = 3; break;
1.956 +
1.957 + case KDmIdTestAA : iTestDomainLevel = 3; leafNodes = 1; expectedTestNotifications = 1; break;
1.958 + case KDmIdTestAB : iTestDomainLevel = 3; leafNodes = 2; expectedTestNotifications = 3; break;
1.959 + case KDmIdTestBA : iTestDomainLevel = 3; leafNodes = 1; expectedTestNotifications = 1; break;
1.960 + case KDmIdTestCA : iTestDomainLevel = 3; leafNodes = 1; expectedTestNotifications = 2; break;
1.961 +
1.962 + case KDmIdTestABA : iTestDomainLevel = 4; leafNodes = 1; expectedTestNotifications = 1; break;
1.963 + case KDmIdTestABB : iTestDomainLevel = 4; leafNodes = 1; expectedTestNotifications = 1; break;
1.964 + case KDmIdTestCAA : iTestDomainLevel = 4; leafNodes = 1; expectedTestNotifications = 1; break;
1.965 + default:
1.966 + test(0);
1.967 + }
1.968 + test.Printf(_L("Test Domain id = 0x%x, Level = %d, Target State = 0x%x, expected notifications = %d, leafNodes = %d\n"),
1.969 + iTestDomainId, iTestDomainLevel, iTestState, expectedTestNotifications, leafNodes);
1.970 +
1.971 + TInt expectedPowerNotifications = 0;
1.972 + switch(iPowerDomainId)
1.973 + {
1.974 + case KDmIdRoot : expectedPowerNotifications = powerMemberCount; break;
1.975 + case KDmIdApps : expectedPowerNotifications = 1; break;
1.976 + case KDmIdUiApps : expectedPowerNotifications = 1; break;
1.977 + default:
1.978 + test(0);
1.979 + }
1.980 +
1.981 +
1.982 +
1.983 + // connect to the test hierarchy
1.984 + r = iTestDomainManager.Connect(KDmHierarchyIdTest);
1.985 + test(r == KErrNone);
1.986 +
1.987 + // verify that we can't connect to the same hierarchy more than once
1.988 + RDmDomainManager domainManager;
1.989 + r = domainManager.Connect(KDmHierarchyIdTest);
1.990 + test(r == KErrInUse);
1.991 +
1.992 +
1.993 +
1.994 + //*************************************************
1.995 + // Test 5b - request a positive transition
1.996 + // issue a positive transition (i.e. transition state increases)
1.997 + // and request that the test domain use ETraverseParentsFirst
1.998 + //*************************************************
1.999 + test.Next(_L("Test 5b - request a positive transition"));
1.1000 + iAckMode = KAckAlways;
1.1001 +
1.1002 + iTransitionsCompleted = iTestNotifications = iPowerNotifications = 0;
1.1003 + iPowerNotificationsExpected = 0;
1.1004 + iTestNotificationsExpected = expectedTestNotifications;
1.1005 + iTransitionsExpected = 1;
1.1006 +
1.1007 + // DON'T request any domain transition on the power hierarchy
1.1008 + // powerDomainManager->RequestDomainTransition(iPowerDomainId, EPwActive);
1.1009 + // request a domain transition on the test hierarchy
1.1010 + iTraverseDirection = ETraverseParentsFirst;
1.1011 + if (iTestDomainId == KDmIdRoot)
1.1012 + iTestDomainManager.RequestSystemTransition(iTestState, ETraverseDefault, CActive::iStatus);
1.1013 + else
1.1014 + iTestDomainManager.RequestDomainTransition(iTestDomainId, iTestState, ETraverseDefault, CActive::iStatus);
1.1015 + CActive::SetActive();
1.1016 +
1.1017 + CActiveScheduler::Start();
1.1018 + test(powerDomainManager->iStatus == KErrNone);
1.1019 + test(iStatus == KErrNone);
1.1020 + test(iTestNotifications == iTestNotificationsExpected);
1.1021 + test(iPowerNotifications == iPowerNotificationsExpected);
1.1022 +
1.1023 + //*************************************************
1.1024 + // Test 5c- verify domains are in correct state
1.1025 + //*************************************************
1.1026 + test.Next(_L("Test 5c- verify domains are in correct state"));
1.1027 + RDmDomain domainMember;
1.1028 + r = domainMember.Connect(KDmHierarchyIdTest, iTestDomainId);
1.1029 + test (r == KErrNone);
1.1030 + TDmDomainState state = domainMember.GetState();
1.1031 + domainMember.Close();
1.1032 + test (state == iTestState);
1.1033 +
1.1034 + // if the transition request is not on the root, verify that that
1.1035 + // the root domain and the transition domain are in different states
1.1036 + if (iTestDomainId != KDmIdRoot && iTestState != EStartupCriticalStatic)
1.1037 + {
1.1038 + r = domainMember.Connect(KDmHierarchyIdTest, KDmIdRoot);
1.1039 + test (r == KErrNone);
1.1040 + TDmDomainState state = domainMember.GetState();
1.1041 + domainMember.Close();
1.1042 + test (state != iTestState);
1.1043 + }
1.1044 +
1.1045 +
1.1046 + //*************************************************
1.1047 + // Test 5d- request a negative transition
1.1048 + // issue a negative transition (i.e. transition state decreases)
1.1049 + // and request that the test domain use ETraverseChildrenFirst
1.1050 + //*************************************************
1.1051 + test.Next(_L("Test 5d- request a negative transition"));
1.1052 + iAckMode = KAckAlways;
1.1053 + iTestState--; // EStartupCriticalStatic;
1.1054 + iPowerState--; // EPwStandby
1.1055 +
1.1056 + iTransitionsCompleted = iTestNotifications = iPowerNotifications = 0;
1.1057 + iPowerNotificationsExpected = expectedPowerNotifications;
1.1058 + iTestNotificationsExpected = expectedTestNotifications;
1.1059 + iTransitionsExpected = 2;
1.1060 +
1.1061 + // DO request a domain transition on the power hierarchy
1.1062 + powerDomainManager->RequestDomainTransition(iPowerDomainId, iPowerState, ETraverseDefault);
1.1063 +
1.1064 + // request a domain transition on the test hierarchy
1.1065 + iTraverseDirection = ETraverseChildrenFirst;
1.1066 + iTestDomainManager.RequestDomainTransition(iTestDomainId, iTestState, iTraverseDirection, CActive::iStatus);
1.1067 + CActive::SetActive();
1.1068 +
1.1069 + // wait for all test & power transitions to complete
1.1070 + CActiveScheduler::Start();
1.1071 + test(powerDomainManager->iStatus == KErrNone);
1.1072 + test(iStatus == KErrNone);
1.1073 + test(iTestNotifications == iTestNotificationsExpected);
1.1074 + test(iPowerNotifications == iPowerNotificationsExpected);
1.1075 +
1.1076 +
1.1077 + //*************************************************
1.1078 + // Test 5e- request a positive transition, with zero acknowledgements
1.1079 + // issue a positive transition with no members acknowledging the transition
1.1080 + //*************************************************
1.1081 + test.Next(_L("Test 5e- request a positive transition, with zero acknowledgements"));
1.1082 + iAckMode = KAckNever;
1.1083 + iTestState++; // EStartupCriticalDynamic;
1.1084 + iPowerState++; // EPwActive
1.1085 +
1.1086 + // power hierarchy should continue on failure, so we all power domains should transition
1.1087 + // test hierarchy should stop on failure, so should get notifications from all leaf nodes
1.1088 + iTransitionsCompleted = iTestNotifications = iPowerNotifications = 0;
1.1089 + iPowerNotificationsExpected = expectedPowerNotifications;
1.1090 + iTestNotificationsExpected = leafNodes; // 5 leaf nodes for root domain
1.1091 + iTransitionsExpected = 2;
1.1092 +
1.1093 + // DO request a domain transition on the power hierarchy
1.1094 + powerDomainManager->RequestDomainTransition(iPowerDomainId, iPowerState, ETraverseDefault);
1.1095 +
1.1096 + // request a domain transition on the test hierarchy
1.1097 + iTraverseDirection = ETraverseChildrenFirst;
1.1098 + iTestDomainManager.RequestDomainTransition(iTestDomainId, iTestState, iTraverseDirection, CActive::iStatus);
1.1099 + CActive::SetActive();
1.1100 +
1.1101 + // wait for all test & power transitions to complete
1.1102 + CActiveScheduler::Start();
1.1103 + test(powerDomainManager->iStatus == KErrTimedOut);
1.1104 + test(iStatus == KErrTimedOut);
1.1105 + test(iTestNotifications == iTestNotificationsExpected);
1.1106 + test(iPowerNotifications == iPowerNotificationsExpected);
1.1107 +
1.1108 + // get the failures on the test hierarchy
1.1109 + testFailureCount = iTestDomainManager.GetTransitionFailureCount();
1.1110 + test (testFailureCount == 1);
1.1111 +
1.1112 + r = iTestDomainManager.GetTransitionFailures(testFailures);
1.1113 + test(r == KErrNone);
1.1114 + test(testFailureCount == testFailures.Count());
1.1115 +
1.1116 + test.Printf(_L("Test failures = %d\n"), testFailureCount);
1.1117 + TInt i;
1.1118 + for (i=0; i<testFailureCount; i++)
1.1119 + {
1.1120 + test.Printf(_L("%d: iDomainId %d, iError %d\n"),
1.1121 + i, testFailures[i].iDomainId, testFailures[i].iError);
1.1122 + test(testFailures[i].iError == KErrTimedOut);
1.1123 + }
1.1124 +
1.1125 + // get the failures on the power hierarchy
1.1126 + powerFailureCount = powerDomainManager->GetTransitionFailureCount();
1.1127 + test (powerFailureCount == expectedPowerNotifications);
1.1128 +
1.1129 + r = powerDomainManager->GetTransitionFailures(powerFailures);
1.1130 + test(r == KErrNone);
1.1131 + test(powerFailureCount == powerFailures.Count());
1.1132 +
1.1133 + test.Printf(_L("Power failures = %d\n"), powerFailureCount);
1.1134 + for (i=0; i<powerFailureCount; i++)
1.1135 + {
1.1136 + test.Printf(_L("%d: iDomainId %d, iError %d\n"),
1.1137 + i, powerFailures[i].iDomainId, powerFailures[i].iError);
1.1138 + test(powerFailures[i].iError == KErrTimedOut);
1.1139 + }
1.1140 +
1.1141 +
1.1142 + //*************************************************
1.1143 + // Test 5f- request a positive transition, with error acknowledgements
1.1144 + // issue a positive transition with all members nack'ing the transition
1.1145 + //*************************************************
1.1146 + test.Next(_L("Test 5f- request a positive transition, with error acknowledgements"));
1.1147 + iAckMode = KAckError;
1.1148 + iTestState++;
1.1149 + iPowerState++;
1.1150 +
1.1151 + // power hierarchy should continue on failure, so all power domains should transition
1.1152 + // test hierarchy should stop on failure, so should get notifications from
1.1153 + // anything from 1 to all the leaf nodes
1.1154 + iTransitionsCompleted = iTestNotifications = iPowerNotifications = 0;
1.1155 + iPowerNotificationsExpected = expectedPowerNotifications;
1.1156 + iTestNotificationsExpected = leafNodes; // 5 leaf nodes for root domain
1.1157 + iTransitionsExpected = 2;
1.1158 +
1.1159 + // DO request a domain transition on the power hierarchy
1.1160 + powerDomainManager->RequestDomainTransition(iPowerDomainId, iPowerState, ETraverseDefault);
1.1161 +
1.1162 + // request a domain transition on the test hierarchy
1.1163 + iTraverseDirection = ETraverseChildrenFirst;
1.1164 + iTestDomainManager.RequestDomainTransition(iTestDomainId, iTestState, iTraverseDirection, CActive::iStatus);
1.1165 + CActive::SetActive();
1.1166 +
1.1167 + // wait for all test & power transitions to complete
1.1168 + CActiveScheduler::Start();
1.1169 + test(powerDomainManager->iStatus == KErrGeneral);
1.1170 + test(iStatus == KErrGeneral);
1.1171 + test(iTestNotifications <= iTestNotificationsExpected);
1.1172 + test(iPowerNotifications == iPowerNotificationsExpected);
1.1173 +
1.1174 + // get the failures on the test hierarchy
1.1175 + testFailureCount = iTestDomainManager.GetTransitionFailureCount();
1.1176 + test (testFailureCount == 1);
1.1177 +
1.1178 + r = iTestDomainManager.GetTransitionFailures(testFailures);
1.1179 + test(r == KErrNone);
1.1180 + test(testFailureCount == testFailures.Count());
1.1181 +
1.1182 + test.Printf(_L("Test failures = %d\n"), testFailureCount);
1.1183 + for (i=0; i<testFailureCount; i++)
1.1184 + {
1.1185 + test.Printf(_L("%d: iDomainId %d, iError %d\n"),
1.1186 + i, testFailures[i].iDomainId, testFailures[i].iError);
1.1187 + test(testFailures[i].iError == KErrGeneral);
1.1188 + }
1.1189 +
1.1190 + // get the failures on the power hierarchy
1.1191 + powerFailureCount = powerDomainManager->GetTransitionFailureCount();
1.1192 + test (powerFailureCount == expectedPowerNotifications);
1.1193 +
1.1194 + r = powerDomainManager->GetTransitionFailures(powerFailures);
1.1195 + test(r == KErrNone);
1.1196 + test(powerFailureCount == powerFailures.Count());
1.1197 +
1.1198 + test.Printf(_L("Power failures = %d\n"), powerFailureCount);
1.1199 + for (i=0; i<powerFailureCount; i++)
1.1200 + {
1.1201 + test.Printf(_L("%d: iDomainId %d, iError %d\n"),
1.1202 + i, powerFailures[i].iDomainId, powerFailures[i].iError);
1.1203 + test(powerFailures[i].iError == KErrGeneral);
1.1204 + }
1.1205 +
1.1206 +
1.1207 + // cleanup
1.1208 +
1.1209 + testFailures.Reset();
1.1210 + powerFailures.Reset();
1.1211 +
1.1212 + iTestDomainManager.Close();
1.1213 + delete powerDomainManager;
1.1214 + powerDomainManager = NULL;
1.1215 +
1.1216 + CDmTestMember** mt;
1.1217 + for (mt = iTestMembers; *mt; ++mt)
1.1218 + delete *mt;
1.1219 +
1.1220 + CDomainMemberAo** mp;
1.1221 + for (mp = iPowerMembers; *mp; ++mp)
1.1222 + delete *mp;
1.1223 +
1.1224 +
1.1225 + // restore the domain hierarchies to their initial state so as not to
1.1226 + // upset any subsequent tests which rely on this
1.1227 + {
1.1228 + RDmDomainManager manager;
1.1229 + TInt r = manager.Connect();
1.1230 + test (r == KErrNone);
1.1231 + TRequestStatus status;
1.1232 + manager.RequestDomainTransition(KDmIdRoot, EPwActive, status);
1.1233 + test(status.Int() == KRequestPending);
1.1234 + User::WaitForRequest(status);
1.1235 + test(status.Int() == KErrNone);
1.1236 + manager.Close();
1.1237 +
1.1238 + r = manager.Connect(KDmHierarchyIdTest);
1.1239 + test (r == KErrNone);
1.1240 + manager.RequestDomainTransition(KDmIdRoot, EStartupCriticalStatic, ETraverseDefault, status);
1.1241 + test(status.Int() == KRequestPending);
1.1242 + User::WaitForRequest(status);
1.1243 + test(status.Int() == KErrNone);
1.1244 + manager.Close();
1.1245 + }
1.1246 +
1.1247 + __UHEAP_MARKEND;
1.1248 + }
1.1249 +
1.1250 +// This handles a transition notification from either a power domain member or
1.1251 +// a test domain member.
1.1252 +// Verifies that the domain state is as expected.
1.1253 +// Updates the number of notifications for each hierarchy and verifies that all parent
1.1254 +// domains have transitioned already (for parent-to-child transitions) or that all child
1.1255 +// domains have been transitioned already (for child-to-parent transitions).
1.1256 +
1.1257 +TInt CDmTest5::TransitionNotification(MDmDomainMember& aDomainMember)
1.1258 + {
1.1259 + if (aDomainMember.HierarchyId() == KDmHierarchyIdPower)
1.1260 + iPowerNotifications++;
1.1261 + else
1.1262 + iTestNotifications++;
1.1263 +
1.1264 + if (aDomainMember.HierarchyId() == KDmHierarchyIdPower)
1.1265 + {
1.1266 + __PRINT((_L("CDmTest5::TransitionNotification(), Hierarchy = %d, iOrdinal = 0x%08X, state = 0x%x, status = %d\n"),
1.1267 + aDomainMember.HierarchyId(), aDomainMember.Ordinal(), aDomainMember.State(), aDomainMember.Status()));
1.1268 + test(aDomainMember.State() == iPowerState);
1.1269 + }
1.1270 + else if (aDomainMember.HierarchyId() == KDmHierarchyIdTest)
1.1271 + {
1.1272 + TBuf16<4> buf;
1.1273 + GetDomainDesc(aDomainMember.Ordinal(), buf);
1.1274 +
1.1275 + __PRINT((_L("CDmTest5::TransitionNotification(), Hierarchy = %d, domain = %S, iOrdinal = 0x%08X, state = 0x%x, status = %d\n"),
1.1276 + aDomainMember.HierarchyId(), &buf, aDomainMember.Ordinal(), aDomainMember.State(), aDomainMember.Status()));
1.1277 + test(aDomainMember.State() == iTestState);
1.1278 + }
1.1279 + else
1.1280 + {
1.1281 + test(0);
1.1282 + }
1.1283 +
1.1284 + // if we're going from parent to child,
1.1285 + // check that each parent domain has received a notification already
1.1286 + // if not, check that each child domain has received a notification already
1.1287 +
1.1288 + CDmTestMember** mp;
1.1289 +
1.1290 + if (aDomainMember.HierarchyId() == KDmHierarchyIdTest && iAckMode == KAckAlways)
1.1291 + {
1.1292 +
1.1293 + if (iTraverseDirection == ETraverseParentsFirst)
1.1294 + {
1.1295 + TUint ordThis = aDomainMember.Ordinal();
1.1296 + TUint ordParent = PARENT_ORDINAL(ordThis);
1.1297 +
1.1298 + TInt levelParent = ORDINAL_LEVEL(ordParent);
1.1299 +
1.1300 + TBuf16<4> buf;
1.1301 + GetDomainDesc(ordParent, buf);
1.1302 + if (levelParent >= iTestDomainLevel)
1.1303 + {
1.1304 + __PRINT((_L("Searching for parent domain = %S, ordinal = %08X \n"), &buf, ordParent));
1.1305 + for (mp = iTestMembers; *mp; ++mp)
1.1306 + {
1.1307 + if ((*mp)->Ordinal() == ordParent)
1.1308 + {
1.1309 + TBuf16<4> buf;
1.1310 + GetDomainDesc((*mp)->Ordinal(), buf);
1.1311 + __PRINT((_L("Found parent (%S). notification = %d\n"), &buf, (*mp)->Notifications()));
1.1312 + test ((*mp)->Notifications() == aDomainMember.Notifications());
1.1313 + break;
1.1314 + }
1.1315 + }
1.1316 + }
1.1317 + }
1.1318 + else
1.1319 + {
1.1320 + __PRINT((_L("Searching for children\n")));
1.1321 + for (mp = iTestMembers; *mp; ++mp)
1.1322 + {
1.1323 +
1.1324 + TUint ordParent = PARENT_ORDINAL((*mp)->Ordinal());
1.1325 + if (ordParent == aDomainMember.Ordinal())
1.1326 + {
1.1327 + TBuf16<4> buf;
1.1328 + GetDomainDesc((*mp)->Ordinal(), buf);
1.1329 + __PRINT((_L("Found child (%S). notification = %d\n"), &buf, (*mp)->Notifications()));
1.1330 + test ((*mp)->Notifications() == aDomainMember.Notifications());
1.1331 + }
1.1332 + }
1.1333 + }
1.1334 + }
1.1335 +
1.1336 + TInt ackError;
1.1337 + switch (iAckMode)
1.1338 + {
1.1339 + case KAckNever:
1.1340 + ackError = KErrAbort;
1.1341 + break;
1.1342 + case KAckError: // return an error to the DM
1.1343 + ackError = KErrGeneral;
1.1344 + break;
1.1345 + case KAckOddDomainsOnly:
1.1346 + ackError = (aDomainMember.DomainId() & 1)?KErrNone:KErrAbort;
1.1347 + break;
1.1348 + case KAckAlways:
1.1349 + default:
1.1350 + ackError = KErrNone;
1.1351 + break;
1.1352 + }
1.1353 + return ackError;
1.1354 + }
1.1355 +
1.1356 +void CDmTest5::RunL()
1.1357 + {
1.1358 + iTransitionsCompleted++;
1.1359 +
1.1360 + __PRINT((_L("CDmTest5::RunL(), error = %d, iTestNotifications %d, iPowerNotifications %d\n"),
1.1361 + iStatus.Int(), iTestNotifications , iPowerNotifications));
1.1362 +
1.1363 + if (iTransitionsCompleted == iTransitionsExpected)
1.1364 + CActiveScheduler::Stop();
1.1365 + }
1.1366 +
1.1367 +void CDmTest5::TransitionRequestComplete()
1.1368 + {
1.1369 + iTransitionsCompleted++;
1.1370 +
1.1371 + __PRINT((_L("CDmTest5::TransitionRequestComplete(), error = %d, iTestNotifications %d, iPowerNotifications %d\n"),
1.1372 + iStatus.Int(), iTestNotifications , iPowerNotifications));
1.1373 +
1.1374 + if (iTransitionsCompleted == iTransitionsExpected)
1.1375 + CActiveScheduler::Stop();
1.1376 + }
1.1377 +
1.1378 +void CDmTest5::DoCancel()
1.1379 + {
1.1380 + test(0);
1.1381 + }
1.1382 +
1.1383 +void CDmTest5::Release()
1.1384 + {
1.1385 + delete this;
1.1386 + }
1.1387 +
1.1388 +const TInt KMembersMax = 16;
1.1389 +
1.1390 +// Negative testing
1.1391 +class CDmTest6 : public CActive, public MDmTest
1.1392 + {
1.1393 +public:
1.1394 + enum
1.1395 + {
1.1396 + ENegTestTransitionNoConnect,
1.1397 + ENegTestGetStateNoConnect,
1.1398 + ENegTestTransitionInvalidMode
1.1399 + };
1.1400 +
1.1401 + class TData
1.1402 + {
1.1403 + public:
1.1404 + inline TData(TInt aTest) : iTest(aTest){};
1.1405 + TInt iTest;
1.1406 + };
1.1407 +
1.1408 +public:
1.1409 + // from CActive
1.1410 + void RunL();
1.1411 +
1.1412 + // from MDmTest
1.1413 + void Perform();
1.1414 + void Release();
1.1415 + TInt TransitionNotification(MDmDomainMember& aDomainMember);
1.1416 + void TransitionRequestComplete();
1.1417 +
1.1418 +
1.1419 + CDmTest6() : CActive(CActive::EPriorityStandard) {}
1.1420 +
1.1421 +protected:
1.1422 + // from CActive
1.1423 + virtual void DoCancel();
1.1424 +
1.1425 +private:
1.1426 + static TInt PanicThreadFunc(TAny* aData);
1.1427 + void PanicTest(TInt aTestNumber);
1.1428 +
1.1429 +
1.1430 + CDomainMemberAo* iTestMembers[KMembersMax];
1.1431 + CDomainManagerAo* iTestDomainManager;
1.1432 +
1.1433 + TDmDomainId iTestDomainId;
1.1434 + TDmDomainState iTestState;
1.1435 +
1.1436 +public:
1.1437 + TInt iTestNotifications;
1.1438 + TInt iTestNotificationsExpected;
1.1439 +
1.1440 + TInt iTransitionsCompleted;
1.1441 + TInt iTransitionsExpected;
1.1442 + };
1.1443 +
1.1444 +TInt CDmTest6::PanicThreadFunc(TAny* aData)
1.1445 + {
1.1446 + const TData* data = (const TData*)aData;
1.1447 + switch (data->iTest)
1.1448 + {
1.1449 + case ENegTestTransitionNoConnect:
1.1450 + {
1.1451 + // request a transition notification without connecting first (should panic)
1.1452 + RDmDomain domainMember;
1.1453 + TRequestStatus status;
1.1454 + User::SetJustInTime(EFalse);
1.1455 + domainMember.RequestTransitionNotification(status);
1.1456 + }
1.1457 + break;
1.1458 + case ENegTestGetStateNoConnect:
1.1459 + {
1.1460 + // Get the domain state without connecting (should panic)
1.1461 + RDmDomain domainMember;
1.1462 + User::SetJustInTime(EFalse);
1.1463 + domainMember.GetState();
1.1464 + }
1.1465 + break;
1.1466 + case ENegTestTransitionInvalidMode:
1.1467 + {
1.1468 + RDmDomainManager manager;
1.1469 + TRequestStatus status;
1.1470 + TInt r = manager.Connect(KDmHierarchyIdTest);
1.1471 + test(r == KErrNone);
1.1472 +
1.1473 + User::SetJustInTime(EFalse);
1.1474 + manager.RequestDomainTransition(KDmIdRoot, 0, TDmTraverseDirection(-1), status);
1.1475 + }
1.1476 + break;
1.1477 + default:
1.1478 + break;
1.1479 + }
1.1480 + return KErrNone;
1.1481 + }
1.1482 +
1.1483 +void CDmTest6::PanicTest(TInt aTestNumber)
1.1484 + {
1.1485 + test.Printf(_L("panic test number %d\n"), aTestNumber);
1.1486 +
1.1487 + TBool jit = User::JustInTime();
1.1488 +
1.1489 + TData data(aTestNumber);
1.1490 +
1.1491 + TInt KHeapSize=0x2000;
1.1492 +
1.1493 + RThread thread;
1.1494 + TInt ret = thread.Create(KThreadName, PanicThreadFunc, KDefaultStackSize, KHeapSize, KHeapSize, &data);
1.1495 + test(KErrNone == ret);
1.1496 + TRequestStatus stat;
1.1497 + thread.Logon(stat);
1.1498 + thread.Resume();
1.1499 + User::WaitForRequest(stat);
1.1500 +
1.1501 + User::SetJustInTime(jit);
1.1502 +
1.1503 + // The thread must panic
1.1504 + test(thread.ExitType() == EExitPanic);
1.1505 + TInt exitReason = thread.ExitReason();
1.1506 + test.Printf(_L("panic test exit reason = %d\n"), exitReason);
1.1507 +
1.1508 + switch(aTestNumber)
1.1509 + {
1.1510 + case ENegTestTransitionNoConnect:
1.1511 + test (exitReason == EBadHandle);
1.1512 + break;
1.1513 + case ENegTestGetStateNoConnect:
1.1514 + test (exitReason == EBadHandle);
1.1515 + break;
1.1516 + case ENegTestTransitionInvalidMode:
1.1517 + break;
1.1518 + default:
1.1519 + break;
1.1520 + }
1.1521 +
1.1522 + CLOSE_AND_WAIT(thread);
1.1523 + }
1.1524 +
1.1525 +
1.1526 +//! @SYMTestCaseID PBASE-T_DOMAIN-6
1.1527 +//! @SYMTestType CT
1.1528 +//! @SYMTestCaseDesc Negative testing
1.1529 +//! @SYMPREQ 810
1.1530 +//! @SYMTestActions Various negative tests
1.1531 +//! @SYMTestExpectedResults All tests should pass
1.1532 +//! @SYMTestPriority High
1.1533 +//! @SYMTestStatus Defined
1.1534 +void CDmTest6::Perform()
1.1535 + {
1.1536 +
1.1537 + __UHEAP_MARK;
1.1538 +
1.1539 + CActiveScheduler::Add(this);
1.1540 +
1.1541 + CDomainManagerAo* iTestDomainManager = NULL;
1.1542 + TRAP_IGNORE(iTestDomainManager = CDomainManagerAo::NewL(KDmHierarchyIdTest, *this));
1.1543 + test (iTestDomainManager != NULL);
1.1544 +
1.1545 + TInt r = CDomainManagerAo::AddDomainHierarchy(KDmHierarchyIdTest);
1.1546 + test(r == KErrNone);
1.1547 +
1.1548 + //*************************************************
1.1549 + // Test 6a - Connect to the same hierarchy twice
1.1550 + //*************************************************
1.1551 + test.Next(_L("Test 6a - Connect to the same hierarchy twice"));
1.1552 +
1.1553 + // verify that we can't connect to the same hierarchy more than once
1.1554 + CDomainManagerAo* testDomainManager = NULL;
1.1555 + TRAP(r, testDomainManager = CDomainManagerAo::NewL(KDmHierarchyIdTest, *this));
1.1556 + test(r == KErrInUse);
1.1557 + test (testDomainManager == NULL);
1.1558 +
1.1559 +
1.1560 + TInt testMemberCount = 0;
1.1561 +
1.1562 + // Add some test hierarchy members
1.1563 + TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdRoot, ORDINAL_FROM_DOMAINID0(KDmIdRoot), this));
1.1564 + test(iTestMembers[testMemberCount++] != NULL);
1.1565 + TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdRoot, ORDINAL_FROM_DOMAINID0(KDmIdRoot), this));
1.1566 + test(iTestMembers[testMemberCount++] != NULL);
1.1567 +
1.1568 + // row 1
1.1569 + TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestA, ORDINAL_FROM_DOMAINID1(KDmIdRoot, KDmIdTestA), this));
1.1570 + test(iTestMembers[testMemberCount++] != NULL);
1.1571 + TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestB, ORDINAL_FROM_DOMAINID1(KDmIdRoot, KDmIdTestB), this));
1.1572 + test(iTestMembers[testMemberCount++] != NULL);
1.1573 + TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestC, ORDINAL_FROM_DOMAINID1(KDmIdRoot, KDmIdTestC), this));
1.1574 + test(iTestMembers[testMemberCount++] != NULL);
1.1575 +
1.1576 + // row2
1.1577 + TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestAA, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestA, KDmIdTestAA), this));
1.1578 + test(iTestMembers[testMemberCount++] != NULL);
1.1579 + TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestAB, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestA, KDmIdTestAB), this));
1.1580 + test(iTestMembers[testMemberCount++] != NULL);
1.1581 + TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestBA, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestB, KDmIdTestBA), this));
1.1582 + test(iTestMembers[testMemberCount++] != NULL);
1.1583 + TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestCA, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestC, KDmIdTestCA), this));
1.1584 + test(iTestMembers[testMemberCount++] != NULL);
1.1585 +
1.1586 + // row 3
1.1587 + TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestABA, ORDINAL_FROM_DOMAINID3(KDmIdRoot, KDmIdTestA, KDmIdTestAB, KDmIdTestABA), this));
1.1588 + test(iTestMembers[testMemberCount++] != NULL);
1.1589 + TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestABB, ORDINAL_FROM_DOMAINID3(KDmIdRoot, KDmIdTestA, KDmIdTestAB, KDmIdTestABB), this));
1.1590 + test(iTestMembers[testMemberCount++] != NULL);
1.1591 + TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestCAA, ORDINAL_FROM_DOMAINID3(KDmIdRoot, KDmIdTestC, KDmIdTestCA, KDmIdTestCAA), this));
1.1592 + test(iTestMembers[testMemberCount++] != NULL);
1.1593 +
1.1594 +
1.1595 + //*************************************************
1.1596 + // Test 6b change to current state
1.1597 + //*************************************************
1.1598 + test.Next(_L("Test 6b change to current state"));
1.1599 + iTestState = EStartupCriticalStatic;
1.1600 + iTestDomainId = KDmIdRoot;
1.1601 +
1.1602 + iTransitionsCompleted = iTestNotifications = 0;
1.1603 + iTestNotificationsExpected = testMemberCount;
1.1604 + iTransitionsExpected = 1;
1.1605 +
1.1606 + // request a domain transition
1.1607 + iTestDomainManager->RequestDomainTransition(iTestDomainId, iTestState, ETraverseDefault);
1.1608 +
1.1609 + // wait for test transitions to complete
1.1610 + CActiveScheduler::Start();
1.1611 + test(iStatus == KErrNone);
1.1612 + test(iTestNotifications == iTestNotificationsExpected);
1.1613 +
1.1614 +
1.1615 + // cancel a member notification request
1.1616 + //*************************************************
1.1617 + // Test 6c cancel a member notification request
1.1618 + //*************************************************
1.1619 + test.Next(_L("Test 6c cancel a member notification request"));
1.1620 + RDmDomain domainMember;
1.1621 + TRequestStatus status;
1.1622 + domainMember.Connect(KDmHierarchyIdTest, iTestDomainId);
1.1623 + domainMember.RequestTransitionNotification(status);
1.1624 + domainMember.CancelTransitionNotification();
1.1625 + User::WaitForRequest(status);
1.1626 + domainMember.Close();
1.1627 +
1.1628 + //*************************************************
1.1629 + // Test 6d cancel a member notification request without having first requested a notification
1.1630 + //*************************************************
1.1631 + test.Next(_L("Test 6d cancel a member notification request without having first requested a notification"));
1.1632 + domainMember.Connect(KDmHierarchyIdTest, iTestDomainId);
1.1633 + domainMember.CancelTransitionNotification();
1.1634 + domainMember.Close();
1.1635 +
1.1636 + //*************************************************
1.1637 + // Test 6e domain controller adds invalid hierarchy
1.1638 + //*************************************************
1.1639 + test.Next(_L("Test 6e domain controller connects to invalid hierarchy"));
1.1640 + r = RDmDomainManager::AddDomainHierarchy(TDmHierarchyId(-1));
1.1641 + test(r == KErrBadHierarchyId);
1.1642 +
1.1643 + //*************************************************
1.1644 + // Test 6f domain member connects to invalid hierarchy
1.1645 + //*************************************************
1.1646 + test.Next(_L("Test 6f domain member connects to invalid hierarchy"));
1.1647 + r = domainMember.Connect(TDmHierarchyId(-1), TDmDomainId(KDmIdRoot));
1.1648 + test (r == KErrBadHierarchyId);
1.1649 +
1.1650 + //*************************************************
1.1651 + // Test 6g domain member connects to valid hierarchy but invalid domain
1.1652 + //*************************************************
1.1653 + test.Next(_L("Test 6g domain member connects to valid hierarchy but invalid domain"));
1.1654 + r = domainMember.Connect(KDmHierarchyIdTest, TDmDomainId(-1));
1.1655 + test (r == KDmErrBadDomainId);
1.1656 +
1.1657 + delete iTestDomainManager;
1.1658 + iTestDomainManager = NULL;
1.1659 +
1.1660 + // Panic tests
1.1661 +
1.1662 + //*************************************************
1.1663 + // Test 6h request a transition notification without connecting first
1.1664 + //*************************************************
1.1665 + test.Next(_L("Test 6h request a transition notification without connecting first"));
1.1666 + PanicTest(ENegTestTransitionNoConnect);
1.1667 +
1.1668 + //*************************************************
1.1669 + // Test 6i Get the domain state without connecting
1.1670 + //*************************************************
1.1671 + test.Next(_L("Test 6i Get the domain state without connecting"));
1.1672 + PanicTest(ENegTestGetStateNoConnect);
1.1673 +
1.1674 + //*************************************************
1.1675 + // Test 6j request a transition notification with an invalid transition mode
1.1676 + //*************************************************
1.1677 + test.Next(_L("Test 6j request a transition notification with an invalid transition mode"));
1.1678 + PanicTest(ENegTestTransitionInvalidMode);
1.1679 +
1.1680 +
1.1681 + // cleanup
1.1682 +
1.1683 + CDomainMemberAo** mt;
1.1684 + for (mt = iTestMembers; *mt; ++mt)
1.1685 + delete *mt;
1.1686 +
1.1687 + __UHEAP_MARKEND;
1.1688 + }
1.1689 +
1.1690 +// This handles a transition notification from a test domain member.
1.1691 +TInt CDmTest6::TransitionNotification(MDmDomainMember& aDomainMember)
1.1692 + {
1.1693 + TInt status = aDomainMember.Status();
1.1694 +
1.1695 + iTestNotifications++;
1.1696 +
1.1697 + test (aDomainMember.HierarchyId() == KDmHierarchyIdTest);
1.1698 +
1.1699 + TBuf16<4> buf;
1.1700 + GetDomainDesc(aDomainMember.Ordinal(), buf);
1.1701 +
1.1702 + test.Printf(_L("CDmTest6::TransitionNotification(), Hierarchy = %d, domain = %S, iOrdinal = 0x%08X, state = 0x%x, status = %d\n"),
1.1703 + aDomainMember.HierarchyId(), &buf, aDomainMember.Ordinal(), aDomainMember.State(), status);
1.1704 +
1.1705 +
1.1706 + return KErrNone;
1.1707 + }
1.1708 +
1.1709 +void CDmTest6::RunL()
1.1710 + {
1.1711 + iTransitionsCompleted++;
1.1712 +
1.1713 + TInt error = iStatus.Int();
1.1714 +
1.1715 + test.Printf(_L("CDmTest6::RunL(), error = %d, iTestNotifications %d\n"),
1.1716 + error, iTestNotifications);
1.1717 +
1.1718 + if (iTransitionsCompleted == iTransitionsExpected)
1.1719 + CActiveScheduler::Stop();
1.1720 + }
1.1721 +
1.1722 +void CDmTest6::TransitionRequestComplete()
1.1723 + {
1.1724 + iTransitionsCompleted++;
1.1725 +
1.1726 + TInt error = iStatus.Int();
1.1727 +
1.1728 + test.Printf(_L("CDmTest6::TransitionRequestComplete(), error = %d, iTestNotifications %d\n"),
1.1729 + error, iTestNotifications);
1.1730 +
1.1731 + if (iTransitionsCompleted == iTransitionsExpected)
1.1732 + CActiveScheduler::Stop();
1.1733 + }
1.1734 +
1.1735 +void CDmTest6::DoCancel()
1.1736 + {
1.1737 + test(0);
1.1738 + }
1.1739 +
1.1740 +void CDmTest6::Release()
1.1741 + {
1.1742 + delete this;
1.1743 + }
1.1744 +
1.1745 +// Transition progress Observer testing
1.1746 +class CDmTest7 : public CActive, public MDmTest, public MHierarchyObserver
1.1747 + {
1.1748 +public:
1.1749 + // from CActive
1.1750 + void RunL();
1.1751 +
1.1752 + // from MDmTest
1.1753 + void Perform();
1.1754 + void Release();
1.1755 + TInt TransitionNotification(MDmDomainMember& aDomainMember);
1.1756 + void TransitionRequestComplete();
1.1757 +
1.1758 + // from MHierarchyObserver
1.1759 + virtual void TransProgEvent(TDmDomainId aDomainId, TDmDomainState aState);
1.1760 + virtual void TransFailEvent(TDmDomainId aDomainId, TDmDomainState aState, TInt aError);
1.1761 + virtual void TransReqEvent(TDmDomainId aDomainId, TDmDomainState aState);
1.1762 +
1.1763 +
1.1764 +
1.1765 + CDmTest7(TDmDomainId aDomainId) : CActive(CActive::EPriorityStandard), iObservedDomainId(aDomainId) {}
1.1766 +
1.1767 +protected:
1.1768 + // from CActive
1.1769 + virtual void DoCancel();
1.1770 +
1.1771 +private:
1.1772 + void TestForCompletion();
1.1773 +
1.1774 +
1.1775 +private:
1.1776 +
1.1777 + enum { KMembersMax = 16 };
1.1778 +
1.1779 + CDomainMemberAo* iTestMembers[KMembersMax];
1.1780 + CDomainManagerAo* iTestDomainManager;
1.1781 +
1.1782 + TDmDomainId iTestDomainId;
1.1783 + TDmDomainState iTestState;
1.1784 + TDmDomainId iObservedDomainId;
1.1785 +
1.1786 +public:
1.1787 + TInt iTestNotifications;
1.1788 + TInt iTestNotificationsExpected;
1.1789 +
1.1790 + TInt iTransitionsCompleted;
1.1791 + TInt iTransitionsExpected;
1.1792 +
1.1793 + TInt iTransProgEvents;
1.1794 + TInt iTransFailEvents;
1.1795 + TInt iTransReqEvents;
1.1796 +
1.1797 + TInt iTransProgEventsExpected;
1.1798 + TInt iTransFailEventsExpected;
1.1799 + TInt iTransReqEventsExpected;
1.1800 + };
1.1801 +
1.1802 +//! @SYMTestCaseID PBASE-T_DOMAIN-7
1.1803 +//! @SYMTestType CT
1.1804 +//! @SYMTestCaseDesc Transition progress Observer testing
1.1805 +//! @SYMREQ REQ3723
1.1806 +//! @SYMTestActions Various negative tests
1.1807 +//! @SYMTestExpectedResults All tests should pass
1.1808 +//! @SYMTestPriority High
1.1809 +//! @SYMTestStatus Defined
1.1810 +void CDmTest7::Perform()
1.1811 + {
1.1812 +
1.1813 + __UHEAP_MARK;
1.1814 +
1.1815 + //
1.1816 + // Test domain transitions with activated observer
1.1817 + //
1.1818 + CActiveScheduler::Add(this);
1.1819 +
1.1820 + TInt r = RDmDomainManager::AddDomainHierarchy(KDmHierarchyIdTest);
1.1821 + test(r == KErrNone);
1.1822 +
1.1823 + CDomainManagerAo* iTestDomainManager = NULL;
1.1824 + TRAP_IGNORE(iTestDomainManager = CDomainManagerAo::NewL(KDmHierarchyIdTest, *this));
1.1825 + test (iTestDomainManager != NULL);
1.1826 +
1.1827 + r = CDomainManagerAo::AddDomainHierarchy(KDmHierarchyIdTest);
1.1828 + test(r == KErrNone);
1.1829 +
1.1830 + //*************************************************
1.1831 + // Test 7a - Testing observer notifications
1.1832 + //*************************************************
1.1833 +
1.1834 + test.Next(_L("Test 7a - Testing observer notifications"));
1.1835 +
1.1836 + TInt testMemberCount = 0;
1.1837 +
1.1838 + // Add some test hierarchy members
1.1839 + TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdRoot, ORDINAL_FROM_DOMAINID0(KDmIdRoot), this));
1.1840 + test(iTestMembers[testMemberCount++] != NULL);
1.1841 +
1.1842 + // row 1
1.1843 + TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestA, ORDINAL_FROM_DOMAINID1(KDmIdRoot, KDmIdTestA), this));
1.1844 + test(iTestMembers[testMemberCount++] != NULL);
1.1845 + TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestB, ORDINAL_FROM_DOMAINID1(KDmIdRoot, KDmIdTestB), this));
1.1846 + test(iTestMembers[testMemberCount++] != NULL);
1.1847 + TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestC, ORDINAL_FROM_DOMAINID1(KDmIdRoot, KDmIdTestC), this));
1.1848 + test(iTestMembers[testMemberCount++] != NULL);
1.1849 +
1.1850 + // row2
1.1851 + TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestAA, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestA, KDmIdTestAA), this));
1.1852 + test(iTestMembers[testMemberCount++] != NULL);
1.1853 + TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestAB, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestA, KDmIdTestAB), this));
1.1854 + test(iTestMembers[testMemberCount++] != NULL);
1.1855 + TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestBA, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestB, KDmIdTestBA), this));
1.1856 + test(iTestMembers[testMemberCount++] != NULL);
1.1857 + TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestCA, ORDINAL_FROM_DOMAINID2(KDmIdRoot, KDmIdTestC, KDmIdTestCA), this));
1.1858 + test(iTestMembers[testMemberCount++] != NULL);
1.1859 +
1.1860 + // row 3
1.1861 + TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestABA, ORDINAL_FROM_DOMAINID3(KDmIdRoot, KDmIdTestA, KDmIdTestAB, KDmIdTestABA), this));
1.1862 + test(iTestMembers[testMemberCount++] != NULL);
1.1863 + TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestABB, ORDINAL_FROM_DOMAINID3(KDmIdRoot, KDmIdTestA, KDmIdTestAB, KDmIdTestABB), this));
1.1864 + test(iTestMembers[testMemberCount++] != NULL);
1.1865 + TRAP(r, iTestMembers[testMemberCount] = CDomainMemberAo::NewL(KDmHierarchyIdTest, KDmIdTestCAA, ORDINAL_FROM_DOMAINID3(KDmIdRoot, KDmIdTestC, KDmIdTestCA, KDmIdTestCAA), this));
1.1866 + test(iTestMembers[testMemberCount++] != NULL);
1.1867 +
1.1868 + // create an observer
1.1869 + CHierarchyObserver* observer = NULL;
1.1870 + TRAP(r, observer = CHierarchyObserver::NewL(*this, KDmHierarchyIdTest));
1.1871 + test (r == KErrNone);
1.1872 + test(observer != NULL);
1.1873 + observer->StartObserver(iObservedDomainId, EDmNotifyAll);
1.1874 +
1.1875 + // request a state change
1.1876 + iTestState = EStartupCriticalDynamic;
1.1877 + iTestDomainId = KDmIdRoot;
1.1878 + iTransitionsCompleted = iTestNotifications = 0;
1.1879 + iTestNotificationsExpected = testMemberCount;
1.1880 + iTransitionsExpected = 1;
1.1881 +
1.1882 + iTransProgEvents = iTransFailEvents = iTransReqEvents = 0;
1.1883 +
1.1884 + iTransReqEventsExpected = iTransProgEventsExpected = observer->ObserverDomainCount();
1.1885 + iTransFailEventsExpected = 0;
1.1886 +
1.1887 +
1.1888 + iTestDomainManager->RequestDomainTransition(iTestDomainId, iTestState, ETraverseDefault);
1.1889 +
1.1890 + // wait for test transitions to complete
1.1891 + CActiveScheduler::Start();
1.1892 + test(iStatus == KErrNone);
1.1893 + test(iTestNotifications == iTestNotificationsExpected);
1.1894 + test (iTransProgEvents == iTransProgEventsExpected);
1.1895 + test (iTransFailEvents == iTransFailEventsExpected);
1.1896 + test (iTransReqEvents == iTransReqEventsExpected);
1.1897 +
1.1898 +
1.1899 + // cleanup
1.1900 + delete observer;
1.1901 + observer = NULL;
1.1902 +
1.1903 + //*************************************************
1.1904 + // Test 7b - start & stop the observer
1.1905 + //*************************************************
1.1906 + test.Next(_L("Test 7b - start & stop the observer"));
1.1907 +
1.1908 + // create an observer, start it stop and then start it again
1.1909 + TRAP(r, observer = CHierarchyObserver::NewL(*this, KDmHierarchyIdTest));
1.1910 + test (r == KErrNone);
1.1911 + test(observer != NULL);
1.1912 + observer->StartObserver(iObservedDomainId, EDmNotifyAll);
1.1913 + observer->StopObserver();
1.1914 + observer->StartObserver(iObservedDomainId, EDmNotifyAll);
1.1915 +
1.1916 + // request a state change
1.1917 + iTestState++;
1.1918 + iTestDomainId = KDmIdRoot;
1.1919 + iTransitionsCompleted = iTestNotifications = 0;
1.1920 + iTestNotificationsExpected = testMemberCount;
1.1921 + iTransitionsExpected = 1;
1.1922 +
1.1923 + iTransProgEvents = iTransFailEvents = iTransReqEvents = 0;
1.1924 +
1.1925 + iTransProgEventsExpected = iTransReqEventsExpected = observer->ObserverDomainCount();
1.1926 + iTransFailEventsExpected = 0;
1.1927 +
1.1928 + iTestDomainManager->RequestDomainTransition(iTestDomainId, iTestState, ETraverseDefault);
1.1929 +
1.1930 + // wait for test transitions to complete
1.1931 + CActiveScheduler::Start();
1.1932 + test(iStatus == KErrNone);
1.1933 + test(iTestNotifications == iTestNotificationsExpected);
1.1934 + test (iTransProgEvents == iTransProgEventsExpected);
1.1935 + test (iTransFailEvents == iTransFailEventsExpected);
1.1936 + test (iTransReqEvents == iTransReqEventsExpected);
1.1937 +
1.1938 + // stop the observer & request another state change
1.1939 + observer->StopObserver();
1.1940 + iTestState++;
1.1941 + iTestDomainId = KDmIdRoot;
1.1942 + iTransitionsCompleted = iTestNotifications = 0;
1.1943 + iTestNotificationsExpected = testMemberCount;
1.1944 + iTransitionsExpected = 1;
1.1945 +
1.1946 + iTransProgEvents = iTransFailEvents = iTransReqEvents = 0;
1.1947 +
1.1948 + iTransProgEventsExpected = 0;
1.1949 + iTransFailEventsExpected = 0;
1.1950 + iTransReqEventsExpected = 0;
1.1951 +
1.1952 + iTestDomainManager->RequestDomainTransition(iTestDomainId, iTestState, ETraverseDefault);
1.1953 + // wait for test transitions to complete
1.1954 + CActiveScheduler::Start();
1.1955 + test(iStatus == KErrNone);
1.1956 + test(iTestNotifications == iTestNotificationsExpected);
1.1957 + test (iTransProgEvents == iTransProgEventsExpected);
1.1958 + test (iTransFailEvents == iTransFailEventsExpected);
1.1959 + test (iTransReqEvents == iTransReqEventsExpected);
1.1960 +
1.1961 + // Start the observer again on a different domain and only ask for transition requests
1.1962 + // Then request another state change
1.1963 + observer->StartObserver((iObservedDomainId == KDmIdRoot)?KDmIdTestCA:KDmIdRoot, EDmNotifyTransRequest);
1.1964 + iTestState++;
1.1965 + iTestDomainId = KDmIdRoot;
1.1966 + iTransitionsCompleted = iTestNotifications = 0;
1.1967 + iTestNotificationsExpected = testMemberCount;
1.1968 + iTransitionsExpected = 1;
1.1969 +
1.1970 + iTransProgEvents = iTransFailEvents = iTransReqEvents = 0;
1.1971 +
1.1972 + iTransReqEventsExpected = observer->ObserverDomainCount();
1.1973 + iTransProgEventsExpected = 0;
1.1974 + iTransFailEventsExpected = 0;
1.1975 +
1.1976 +
1.1977 + iTestDomainManager->RequestDomainTransition(iTestDomainId, iTestState, ETraverseDefault);
1.1978 + // wait for test transitions to complete
1.1979 + CActiveScheduler::Start();
1.1980 + test(iStatus == KErrNone);
1.1981 + test(iTestNotifications == iTestNotificationsExpected);
1.1982 + test (iTransProgEvents == iTransProgEventsExpected);
1.1983 + test (iTransFailEvents == iTransFailEventsExpected);
1.1984 + test (iTransReqEvents == iTransReqEventsExpected);
1.1985 +
1.1986 + delete observer;
1.1987 + observer = NULL;
1.1988 +
1.1989 + //*************************************************
1.1990 + // Test 7c - invalid arguments testing for observer
1.1991 + //*************************************************
1.1992 + test.Next(_L("Test 7c - Invalid arguments testing for observer"));
1.1993 +
1.1994 + const TDmHierarchyId KDmHierarchyIdInvalid = 110;
1.1995 +
1.1996 + test.Printf(_L("Test 7c.1 - create observer with invalid hierarchy Id\n"));
1.1997 +
1.1998 + // create an observer
1.1999 + TRAP(r, observer = CHierarchyObserver::NewL(*this, KDmHierarchyIdInvalid));
1.2000 + test (r == KErrBadHierarchyId);
1.2001 +
1.2002 +
1.2003 + test.Printf(_L("Test 7c.2 - Starting the observer with wrong domain Id\n"));
1.2004 + TRAP(r, observer = CHierarchyObserver::NewL(*this, KDmHierarchyIdTest));
1.2005 + test (r == KErrNone);
1.2006 + test(observer != NULL);
1.2007 +
1.2008 + //Wrong domain Id
1.2009 + const TDmDomainId KDmIdInvalid = 0x0f;
1.2010 + r= observer->StartObserver(KDmIdInvalid, EDmNotifyAll);
1.2011 + test(r==KDmErrBadDomainId);
1.2012 +
1.2013 + test.Printf(_L("Test 7c.3 - Trying to create second observer on the same hierarchy\n"));
1.2014 + TRAP(r, CHierarchyObserver::NewL(*this, KDmHierarchyIdTest));
1.2015 + test (r == KDmErrBadSequence);
1.2016 +
1.2017 +
1.2018 +
1.2019 + //*************************************************
1.2020 + // Test 7d - Wrong sequence of API calls for observer
1.2021 + //*************************************************
1.2022 + test.Next(_L("Test 7d - Observer wrong sequence of calls"));
1.2023 +
1.2024 + test.Printf(_L("Test 7d.1 - Stopping Observer before starting it\n"));
1.2025 + r = observer->StopObserver();
1.2026 + test(r==KDmErrBadSequence);
1.2027 +
1.2028 + test.Printf(_L("Test 7d.2 - Starting Observer twice\n"));
1.2029 + r= observer->StartObserver(KDmIdRoot, EDmNotifyAll);
1.2030 + test(r==KErrNone);
1.2031 +
1.2032 + r= observer->StartObserver(KDmIdRoot, EDmNotifyAll);
1.2033 + test(r==KDmErrBadSequence);
1.2034 +
1.2035 +
1.2036 + delete observer;
1.2037 +
1.2038 + /***************************************/
1.2039 +
1.2040 + delete iTestDomainManager;
1.2041 + iTestDomainManager = NULL;
1.2042 +
1.2043 + CDomainMemberAo** mt;
1.2044 + for (mt = iTestMembers; *mt; ++mt)
1.2045 + delete *mt;
1.2046 +
1.2047 +
1.2048 + // restore the domain hierarchies to their initial state so as not to
1.2049 + // upset any subsequent tests which rely on this
1.2050 + {
1.2051 + RDmDomainManager manager;
1.2052 + TRequestStatus status;
1.2053 + TInt r = manager.Connect(KDmHierarchyIdTest);
1.2054 + test (r == KErrNone);
1.2055 + manager.RequestDomainTransition(KDmIdRoot, EStartupCriticalStatic, ETraverseDefault, status);
1.2056 + test(status.Int() == KRequestPending);
1.2057 + User::WaitForRequest(status);
1.2058 + test(status.Int() == KErrNone);
1.2059 + manager.Close();
1.2060 + }
1.2061 +
1.2062 + __UHEAP_MARKEND;
1.2063 + }
1.2064 +
1.2065 +// This handles a transition notification from a test domain member.
1.2066 +TInt CDmTest7::TransitionNotification(MDmDomainMember& aDomainMember)
1.2067 + {
1.2068 +
1.2069 + iTestNotifications++;
1.2070 +
1.2071 + test (aDomainMember.HierarchyId() == KDmHierarchyIdTest);
1.2072 +
1.2073 + TBuf16<4> buf;
1.2074 + GetDomainDesc(aDomainMember.Ordinal(), buf);
1.2075 +
1.2076 + __PRINT((_L("CDmTest7::TransitionNotification(), Hierarchy = %d, domain = %S, iOrdinal = 0x%08X, state = 0x%x, status = %d\n"),
1.2077 + aDomainMember.HierarchyId(), &buf, aDomainMember.Ordinal(), aDomainMember.State(), aDomainMember.Status()));
1.2078 +
1.2079 + return KErrNone;
1.2080 + }
1.2081 +
1.2082 +void CDmTest7::RunL()
1.2083 + {
1.2084 + iTransitionsCompleted++;
1.2085 +
1.2086 + __PRINT((_L("CDmTest7::RunL(), error = %d, iTestNotifications %d\n"),
1.2087 + iStatus.Int(), iTestNotifications));
1.2088 +
1.2089 + TestForCompletion();
1.2090 + }
1.2091 +
1.2092 +void CDmTest7::TransitionRequestComplete()
1.2093 + {
1.2094 + iTransitionsCompleted++;
1.2095 +
1.2096 + __PRINT((_L("CDmTest7::TransitionRequestComplete(), error = %d, iTestNotifications %d\n"),
1.2097 + iStatus.Int(), iTestNotifications));
1.2098 +
1.2099 + TestForCompletion();
1.2100 + }
1.2101 +
1.2102 +void CDmTest7::DoCancel()
1.2103 + {
1.2104 + test(0);
1.2105 + }
1.2106 +
1.2107 +void CDmTest7::Release()
1.2108 + {
1.2109 + delete this;
1.2110 + }
1.2111 +
1.2112 +void CDmTest7::TestForCompletion()
1.2113 + {
1.2114 +
1.2115 + if (iTransitionsCompleted == iTransitionsExpected &&
1.2116 + iTransProgEvents == iTransProgEventsExpected &&
1.2117 + iTransFailEvents == iTransFailEventsExpected &&
1.2118 + iTransReqEvents == iTransReqEventsExpected)
1.2119 + {
1.2120 + CActiveScheduler::Stop();
1.2121 + }
1.2122 + }
1.2123 +
1.2124 +#ifdef _DEBUG
1.2125 +void CDmTest7::TransProgEvent(TDmDomainId aDomainId, TDmDomainState aState)
1.2126 +#else
1.2127 +void CDmTest7::TransProgEvent(TDmDomainId /*aDomainId*/, TDmDomainState /*aState*/)
1.2128 +#endif
1.2129 + {
1.2130 + iTransProgEvents++;
1.2131 + __PRINT((_L("CDmTest7::TransProgEvent(), aDomainId = %d, aState %d, iTransProgEvents %d\n"),
1.2132 + aDomainId, aState, iTransProgEvents));
1.2133 + TestForCompletion();
1.2134 + }
1.2135 +
1.2136 +#ifdef _DEBUG
1.2137 +void CDmTest7::TransFailEvent(TDmDomainId aDomainId, TDmDomainState aState, TInt aError)
1.2138 +#else
1.2139 +void CDmTest7::TransFailEvent(TDmDomainId /*aDomainId*/, TDmDomainState /*aState*/, TInt /*aError*/)
1.2140 +#endif
1.2141 +
1.2142 + {
1.2143 + iTransFailEvents++;
1.2144 + __PRINT((_L("CDmTest7::TransFailEvent(), aDomainId = %d, aState %d aError %d, iTransFailEvents %d\n"),
1.2145 + aDomainId, aState, iTransFailEvents, aError));
1.2146 + TestForCompletion();
1.2147 + }
1.2148 +
1.2149 +#ifdef _DEBUG
1.2150 +void CDmTest7::TransReqEvent(TDmDomainId aDomainId, TDmDomainState aState)
1.2151 +#else
1.2152 +void CDmTest7::TransReqEvent(TDmDomainId /*aDomainId*/, TDmDomainState /*aState*/)
1.2153 +#endif
1.2154 + {
1.2155 + iTransReqEvents++;
1.2156 + __PRINT((_L("CDmTest7::TransReqEvent(), aDomainId = %d, aState %d, iTransReqEvents %d\n"),
1.2157 + aDomainId, aState, iTransReqEvents));
1.2158 + TestForCompletion();
1.2159 + }
1.2160 +
1.2161 +GLDEF_C TInt E32Main()
1.2162 + {
1.2163 + CTrapCleanup* trapHandler=CTrapCleanup::New();
1.2164 + test(trapHandler!=NULL);
1.2165 +
1.2166 + CActiveScheduler* scheduler = new CActiveScheduler();
1.2167 + test(scheduler != NULL);
1.2168 + CActiveScheduler::Install(scheduler);
1.2169 +
1.2170 + // Turn off evil lazy dll unloading
1.2171 + RLoader l;
1.2172 + test(l.Connect()==KErrNone);
1.2173 + test(l.CancelLazyDllUnload()==KErrNone);
1.2174 + l.Close();
1.2175 +
1.2176 + //
1.2177 + // Perform the number of iterations specifed by the command line argument.
1.2178 + //
1.2179 + // If no arguments - perform two iterations
1.2180 + //
1.2181 +// TInt iter = 2;
1.2182 + TInt iter = 1;
1.2183 +
1.2184 + TInt len = User::CommandLineLength();
1.2185 + if (len)
1.2186 + {
1.2187 + // Copy the command line in a buffer
1.2188 + HBufC* hb = HBufC::NewMax(len);
1.2189 + test(hb != NULL);
1.2190 + TPtr cmd((TUint16*) hb->Ptr(), len);
1.2191 + User::CommandLine(cmd);
1.2192 + // Extract the number of iterations
1.2193 + TLex l(cmd);
1.2194 + TInt i;
1.2195 + TInt r = l.Val(i);
1.2196 + if (r == KErrNone)
1.2197 + iter = i;
1.2198 + else
1.2199 + // strange command - silently ignore
1.2200 + {}
1.2201 + delete hb;
1.2202 + }
1.2203 +
1.2204 + test.Title();
1.2205 + test.Start(_L("Testing"));
1.2206 +
1.2207 + test.Printf(_L("Go for %d iterations\n"), iter);
1.2208 +
1.2209 + // Remember the number of open handles. Just for a sanity check ....
1.2210 + TInt start_thc, start_phc;
1.2211 + RThread().HandleCount(start_phc, start_thc);
1.2212 +
1.2213 + while (iter--)
1.2214 + {
1.2215 + MDmTest* tests[] =
1.2216 + {
1.2217 +
1.2218 + new CDmTest1(KDmIdRoot, EPwStandby),
1.2219 + new CDmTest1(KDmIdRoot, EPwOff),
1.2220 + new CDmTest1(KDmIdRoot, EPwActive),
1.2221 + new CDmTest1(KDmIdApps, EPwStandby),
1.2222 + new CDmTest1(KDmIdApps, EPwOff),
1.2223 + new CDmTest1(KDmIdApps, EPwActive),
1.2224 + new CDmTest1(KDmIdUiApps, EPwStandby),
1.2225 + new CDmTest1(KDmIdUiApps, EPwOff),
1.2226 + new CDmTest1(KDmIdUiApps, EPwActive),
1.2227 + new CDmTest2(EPwStandby),
1.2228 + new CDmTest3(),
1.2229 +
1.2230 + // platform security tests
1.2231 + new CDmTest4(),
1.2232 +
1.2233 + // PREQ810 tests :
1.2234 + // note that we use a fictitious power state to prevent any
1.2235 + new CDmTest5(KDmIdRoot, KDmIdRoot, EPwActive+10, EStartupCriticalDynamic),
1.2236 + new CDmTest5(KDmIdUiApps, KDmIdTestAB, EPwActive+10, EStartupCriticalDynamic),
1.2237 +
1.2238 + // negative tests
1.2239 + new CDmTest6(),
1.2240 +
1.2241 +
1.2242 + // observer tests
1.2243 + new CDmTest7(KDmIdTestA),
1.2244 + new CDmTest7(KDmIdRoot),
1.2245 +
1.2246 + };
1.2247 +
1.2248 + for (unsigned int i = 0; i < sizeof(tests)/sizeof(*tests); ++i)
1.2249 + {
1.2250 + test(tests[i] != NULL);
1.2251 + tests[i]->Perform();
1.2252 + tests[i]->Release();
1.2253 + }
1.2254 +
1.2255 + }
1.2256 +
1.2257 + test.End();
1.2258 +
1.2259 + // Sanity check for open handles and for pending requests ...
1.2260 + TInt end_thc, end_phc;
1.2261 + RThread().HandleCount(end_phc, end_thc);
1.2262 + test(start_thc == end_thc);
1.2263 + test(start_phc == end_phc);
1.2264 + test(RThread().RequestCount() >= 0);
1.2265 +
1.2266 + delete scheduler;
1.2267 + delete trapHandler;
1.2268 +
1.2269 + return KErrNone;
1.2270 + }