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