|
1 // Copyright (c) 2007-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\resourceman\t_rescontrolcli.cpp |
|
15 // TestCase Description: |
|
16 // This tests is intended to test the generic layer of PRM. It consists of unit testing and regression testing. |
|
17 // Unit testing validates each of the API's. Regression testing performs random operation on random resource and |
|
18 // currently executes 500 operations and returns. |
|
19 // To run regression testing, test must be invoked with -R option. |
|
20 // Testing runs only on simulated PSL. |
|
21 // |
|
22 // |
|
23 |
|
24 #include <e32test.h> |
|
25 #include <e32hal.h> |
|
26 #include <e32math.h> |
|
27 #include <e32def.h> |
|
28 #include <e32def_private.h> |
|
29 #include "d_rescontrolcli.h" |
|
30 |
|
31 #define MAX_STATIC_RESOURCE_NUM 24 //Maximum number of static resources in simulated PSL |
|
32 #define MAX_STATIC_DEPENDENCY_RESOURCE_NUM 7 //Maximum number of static dependency resources in simulated PSL |
|
33 #define DEPENDENCY_RESOURCE_BIT_MASK 0x00010000 |
|
34 #define DYNAMIC_RESOURCE_BIT_MASK 0x00020000 |
|
35 #define CUSTOM_RESOURCE_NUMBER 20 |
|
36 |
|
37 /** Macro to push the item into the specified list. Item are pushed to the head of the list. */ |
|
38 #define LIST_PUSH(list,item,link) \ |
|
39 { \ |
|
40 (item)->link = (list); \ |
|
41 (list) = (item); \ |
|
42 } |
|
43 |
|
44 /** Macro to pop the item from the specified list. Item are poped from the head of the list. */ |
|
45 #define LIST_POP(list,item,link) \ |
|
46 { \ |
|
47 (item) = (list); \ |
|
48 if ((item)) \ |
|
49 { \ |
|
50 (list) = (item)->link; \ |
|
51 (item)->link = NULL; \ |
|
52 } \ |
|
53 } |
|
54 |
|
55 /** Macro to remove the item from the list. */ |
|
56 #define LIST_REMOVE(list,item,link,className) \ |
|
57 if (list) \ |
|
58 { \ |
|
59 className* current = (list); \ |
|
60 if (current==(item)) \ |
|
61 { \ |
|
62 (list) = (item)->link; \ |
|
63 (item)->link = NULL; \ |
|
64 } \ |
|
65 else \ |
|
66 { \ |
|
67 className* next = current->link; \ |
|
68 while (next) \ |
|
69 { \ |
|
70 if ((item)==next) \ |
|
71 { \ |
|
72 current->link=next->link; \ |
|
73 next->link = NULL; \ |
|
74 break; \ |
|
75 } \ |
|
76 current = next; \ |
|
77 next = next->link; \ |
|
78 } \ |
|
79 } \ |
|
80 } |
|
81 |
|
82 #ifndef PRM_ENABLE_EXTENDED_VERSION |
|
83 _LIT(KLddFileName, "D_RESCONTROLCLI.LDD"); |
|
84 _LIT(KPddFileName, "resourcecontroller.pdd"); |
|
85 #else |
|
86 _LIT(KExtLddFileName, "D_EXTENDEDRESCONTROLCLI.LDD"); |
|
87 _LIT(KExtPddFileName, "resourcecontrollerextended.pdd"); |
|
88 #endif |
|
89 |
|
90 LOCAL_D RTest test(_L("RESOURCE_MANAGER_TEST")); |
|
91 TBuf8<32> SpecialResName(_L8("SymbianSimulResource")); |
|
92 |
|
93 //Enum definition for resource classification. |
|
94 enum TType {EMultiLevel = 0x1, EMultiProperty}; |
|
95 enum TUsage {ESingle, EShared}; |
|
96 enum TLatency {EInstantaneous, ELongLatency}; |
|
97 enum TClass {EPhysical, ELogical}; |
|
98 enum TSense {EPositive, ENegative, ECustom}; |
|
99 |
|
100 //Structure to get resource information |
|
101 class TPowerResourceInfoV01 |
|
102 { |
|
103 public: |
|
104 TClass iClass; |
|
105 TLatency iLatencyGet; |
|
106 TLatency iLatencySet; |
|
107 TType iType; |
|
108 TUsage iUsage; |
|
109 TSense iSense; |
|
110 TDesC8* iResourceName; |
|
111 TUint iResourceId; |
|
112 TInt iDefaultLevel; |
|
113 TInt iMinLevel; |
|
114 TInt iMaxLevel; |
|
115 TInt iReserved1; |
|
116 TInt iReserved2; |
|
117 TInt iReserved3; |
|
118 TInt iPslReserved1; |
|
119 TInt iPslReserved2; |
|
120 TInt iPslReserved3; |
|
121 }; |
|
122 |
|
123 //Structure to get client information |
|
124 struct TPowerClientInfoV01 |
|
125 { |
|
126 TUint iClientId; |
|
127 TDesC8* iClientName; |
|
128 }; |
|
129 |
|
130 //Structure for holding client information |
|
131 struct RMClientInfo |
|
132 { |
|
133 TUint iClientId; |
|
134 TUint iNumResources; |
|
135 TUint iResourceIds[MAX_STATIC_RESOURCE_NUM]; //Each bit corresponds to a static resource. |
|
136 }; |
|
137 |
|
138 //Structure for holding notification information |
|
139 struct NotiInfo |
|
140 { |
|
141 TUint iClientId; |
|
142 TInt iThreshold; |
|
143 TInt iDirection; |
|
144 TInt iPreviousLevel; |
|
145 NotiInfo *iNext; |
|
146 }; |
|
147 |
|
148 // Structure for holding client level |
|
149 struct SPowerResourceClientLevel |
|
150 { |
|
151 TUint iClientId; |
|
152 TUint iResourceId; |
|
153 TInt iLevel; |
|
154 SPowerResourceClientLevel* iNextInList; |
|
155 }; |
|
156 |
|
157 //Structure for capturing resource information to be used by Idle thread. |
|
158 struct SIdleResourceInfo |
|
159 { |
|
160 TUint iResourceId; |
|
161 TInt iLevelOwnerId; |
|
162 TInt iCurrentLevel; |
|
163 TInt iReserved1; //Reserved for future use. |
|
164 TInt iReserved2; //Reserved for future use. |
|
165 TInt iReserved3; //Reserved for future use. |
|
166 }; |
|
167 |
|
168 //Structure for holding resource information |
|
169 struct RMResInfo |
|
170 { |
|
171 TBuf8<32> iName; |
|
172 TUint iResourceId; |
|
173 TInt iMaxLevel; |
|
174 TInt iMinLevel; |
|
175 TInt iDefaultLevel; |
|
176 TInt iCurrentLevel; |
|
177 TInt iCurrentClient; |
|
178 TUint iNumClients; |
|
179 TSense iSense; |
|
180 TType iType; |
|
181 TLatency iLatencyGet; |
|
182 TLatency iLatencySet; |
|
183 TUsage iUsage; |
|
184 TUint iUnCondNotiCount; |
|
185 NotiInfo *iCondNoti; |
|
186 NotiInfo *iUncondNoti; |
|
187 SPowerResourceClientLevel *iLevel; |
|
188 }; |
|
189 |
|
190 //Test class. |
|
191 class TestRM |
|
192 { |
|
193 private: |
|
194 //Possible resource operation. |
|
195 enum Operation |
|
196 { |
|
197 ERegisterClient = 0, |
|
198 EGetClientName = 1, |
|
199 EGetAllClientName = 2, |
|
200 EGetClientId = 3, |
|
201 EGetResourceId = 4, |
|
202 EGetResourceInfo = 5, |
|
203 EGetNumReosourceInUseByClient = 6, |
|
204 EGetInfoOnResourceInUseByClient = 7, |
|
205 EGetNumClientsUsingResource = 8, |
|
206 EGetInfoOnClientsUsingResource = 9, |
|
207 EChangeResourceStateSync = 10, |
|
208 EChangeResourceStateAsync = 11, |
|
209 EGetResourceStateSync = 12, |
|
210 EGetResourceStateAsync = 13, |
|
211 ERequestNotificationCond = 14, |
|
212 ERequestNotificationUnCond = 15, |
|
213 ECancelNotificationCond = 16, |
|
214 ECancelNotificationUnCond = 17, |
|
215 EOperationEnd = 18 |
|
216 }; |
|
217 public: |
|
218 TestRM(); |
|
219 void RegisterClient(); |
|
220 void DeRegisterClient(TUint aClientId); |
|
221 void GetClientName(TUint aClientId); |
|
222 void GetClientId(TUint aClientId); |
|
223 void GetResourceId(TUint aResId); |
|
224 void GetResourceInfo(TUint aResId); |
|
225 void GetNumResourcesInUseByClient(TInt aClientId); |
|
226 void GetInfoOnResourcesInUseByClient(TInt aClientId, TUint aNumRes); |
|
227 void GetNumClientsUsingResource(TUint aClientId, TUint aResId); |
|
228 void GetInfoOnClientsUsingResource(TUint aResId, TUint aNumCli); |
|
229 void AllocReserve(TUint aClientId); |
|
230 void CheckNotification(TUint aResId, TInt newState); |
|
231 void AddClientLevel(TUint aResId, TInt newState); |
|
232 void UpdateClientInformation(TUint aResId, TInt aNewState); |
|
233 void ChangeResourceStateSync(TUint aResId); |
|
234 void ChangeResourceStateAsync(TUint aResId, TBool aReqCancel=EFalse); |
|
235 void GetResourceStateSync(TUint aResId); |
|
236 void GetResourceStateAsync(TUint aResId, TBool aReqCancel=EFalse); |
|
237 void RequestNotification(TUint aResId); |
|
238 void RequestNotificationCon(TUint aResId); |
|
239 void ValidateClient(TUint aNumClients, TOwnerType aContext); |
|
240 void CancelNotification(TUint aResId, TBool Cond); |
|
241 void APIValidationTest(); |
|
242 void SharedBinaryPositiveResourceTesting(TUint aResId); |
|
243 void SharedBinaryNegativeResourceTesting(TUint aResId); |
|
244 void CustomResourceTesting(TUint aResId); |
|
245 void DeRegisterClientLevelFromResource(TInt aClientId, TUint aResId); |
|
246 void RegressionTest(); |
|
247 void TestStaticResourceWithDependency(); |
|
248 void GetExtendedResStateAsyncAndVerify(TUint aResId, TInt aState, TInt aLevelOwnerId, TBool aReqCancel = EFalse); |
|
249 void GetExtendedResStateAndVerify(TUint aResId, TInt aState, TInt aLevelOwnerId); |
|
250 void TestDynamicResource(); |
|
251 void TestDynamicResourceDependency(); |
|
252 void CheckForDependencyInformation(TUint aClientId, TUint aResourceId, TUint aNumDependents, SResourceDependencyInfo* aDepResIdArray); |
|
253 void SharedMultilevelNegativeResourceTesting(TUint aResId); |
|
254 void SharedMultilevelPositiveResourceTesting(TUint aResId); |
|
255 private: |
|
256 RArray<RMClientInfo> Clients; |
|
257 RMResInfo Resources[MAX_STATIC_RESOURCE_NUM]; |
|
258 TUint iStaticDependencyResources[MAX_STATIC_DEPENDENCY_RESOURCE_NUM]; |
|
259 TInt iCurrentClientId; |
|
260 TUint iMaxClientId; |
|
261 TUint iMaxClients; |
|
262 TUint iMaxStaticResources; |
|
263 TUint iMaxStaticDependentResources; |
|
264 TUint iPowerControllerId; |
|
265 TUint iTestingExtendedVersion; |
|
266 }; |
|
267 |
|
268 TBool NegativeTesting; //If true enables negative testing of API's |
|
269 TInt r = KErrNone; |
|
270 TBuf8<32> ClientName(_L8("Client?")); |
|
271 RTestResMan lddChan; |
|
272 TestRM RmTest; |
|
273 |
|
274 //Class constructor |
|
275 TestRM::TestRM(): iCurrentClientId(-1),iMaxClientId(0), iMaxClients(0),iMaxStaticResources(0), iMaxStaticDependentResources(0), iTestingExtendedVersion(0) |
|
276 { |
|
277 test.Printf(_L("TestRM::TestRM()\n")); |
|
278 } |
|
279 |
|
280 //---------------------------------------------------------------------------------------------- |
|
281 //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0573 |
|
282 //! @SYMTestType UT |
|
283 //! @SYMPREQ PREQ1398 |
|
284 //! @SYMTestCaseDesc This test case tests the client registeration functionality of resource |
|
285 //! manager.It registeres a client with resource manager and stores the relevant |
|
286 //! information in Clients array. Currently allows only maximum of 50 client |
|
287 //! registration. |
|
288 //! @SYMTestActions 0 Returns if already maximum allowable clients are registered. |
|
289 //! 1 Register a client with the resource manager with a unique name. |
|
290 //! 2 Appends the client information to an array for futher reference. |
|
291 //! |
|
292 //! @SYMTestExpectedResults client registration is successful, panics otherwise. |
|
293 //! @SYMTestPriority High |
|
294 //! @SYMTestStatus Implemented |
|
295 //---------------------------------------------------------------------------------------------- |
|
296 void TestRM::RegisterClient() |
|
297 { |
|
298 TUint clientId = 0; |
|
299 RMClientInfo info; |
|
300 if(iMaxClientId > MAX_CLIENTS) |
|
301 { |
|
302 test.Printf(_L("Reached maximum client allocation. Can't allocate more\n")); |
|
303 return; |
|
304 } |
|
305 ClientName[6] = (TUint8)('0' + iMaxClientId); |
|
306 r = lddChan.RegisterClient(clientId, (const TDesC*)&ClientName); |
|
307 if(r != KErrNone) |
|
308 test.Printf(_L("Register Client failed with %d\n"), r); |
|
309 test(r == KErrNone); |
|
310 info.iClientId = clientId; |
|
311 info.iNumResources = 0; |
|
312 for(TUint c = 0; c< MAX_STATIC_RESOURCE_NUM; c++) |
|
313 info.iResourceIds[c] = 0; |
|
314 iMaxClientId++; |
|
315 iMaxClients++; |
|
316 r = Clients.Append(info); |
|
317 if(r != KErrNone) |
|
318 test.Printf(_L("Client Append failed with %d\n"), r); |
|
319 test(r == KErrNone); |
|
320 } |
|
321 |
|
322 //---------------------------------------------------------------------------------------------- |
|
323 //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0574 |
|
324 //! @SYMTestType UT |
|
325 //! @SYMPREQ PREQ1398 |
|
326 //! @SYMTestCaseDesc This test case tests the client deregisteration functionality of resource |
|
327 //! manager.It deregisteres a client with the resource manager, calculates |
|
328 //! the resource level of each resource that the client was having requirement and |
|
329 //! checks the resource level change after client deregistration. |
|
330 //! @SYMTestActions 0 Deregister a client from resource manager |
|
331 //! 1 Calculates the resource level of each resource the client was having requirement. |
|
332 //! 2 Checks the resource level change of each resource for correctness. |
|
333 //! 3 Zeros the clientId stored internally to make sure it is not referenced again. |
|
334 //! |
|
335 //! @SYMTestExpectedResults client deregistration is successful and also the resource level of |
|
336 //! each resource the client was holding the resource level is checked |
|
337 //! for correctness, panics otherwise |
|
338 //! @SYMTestPriority High |
|
339 //! @SYMTestStatus Implemented |
|
340 //---------------------------------------------------------------------------------------------- |
|
341 void TestRM::DeRegisterClient(TUint aClientId) |
|
342 { |
|
343 r = lddChan.DeRegisterClient(Clients[aClientId].iClientId); |
|
344 if(r != KErrNone) |
|
345 test.Printf(_L("Client deregistration of %d failed with %d\n"), Clients[aClientId].iClientId, r); |
|
346 test(r == KErrNone); |
|
347 TUint count; |
|
348 for(count = 0; count < iMaxStaticResources; count++) |
|
349 { |
|
350 RMResInfo *pR = &Resources[count]; |
|
351 NotiInfo* pI = pR->iCondNoti; |
|
352 NotiInfo* ptr = NULL; |
|
353 //Remove any conditional notification that this client has on resource. |
|
354 while(pI != NULL) |
|
355 { |
|
356 if(pI->iClientId == aClientId) |
|
357 { |
|
358 ptr = pI; |
|
359 pI = pI->iNext; |
|
360 LIST_REMOVE(pR->iCondNoti, ptr, iNext, NotiInfo); |
|
361 delete ptr; |
|
362 } |
|
363 else |
|
364 pI = pI->iNext; |
|
365 } |
|
366 |
|
367 //Remove any unconditional notification that this client has on resource. |
|
368 pI = pR->iUncondNoti; |
|
369 ptr = NULL; |
|
370 while(pI != NULL) |
|
371 { |
|
372 if(pI->iClientId == aClientId) |
|
373 { |
|
374 ptr = pI; |
|
375 pI = pI->iNext; |
|
376 LIST_REMOVE(pR->iUncondNoti, ptr, iNext, NotiInfo); |
|
377 delete ptr; |
|
378 } |
|
379 else |
|
380 pI = pI->iNext; |
|
381 } |
|
382 } |
|
383 //Remove client level |
|
384 TUint res = 0; |
|
385 for(count = 0; count < Clients[aClientId].iNumResources; count++) |
|
386 { |
|
387 res = Clients[aClientId].iResourceIds[count]; |
|
388 if(res == 0) |
|
389 continue; |
|
390 for(TUint c = 0; c< iMaxStaticResources; c++) |
|
391 { |
|
392 if(Resources[c].iResourceId == res) |
|
393 { |
|
394 res = c; |
|
395 break; |
|
396 } |
|
397 } |
|
398 if(Resources[res].iCurrentClient == (TInt)aClientId) |
|
399 { |
|
400 if(!Resources[res].iUsage) |
|
401 { |
|
402 Resources[res].iCurrentLevel = Resources[res].iDefaultLevel; |
|
403 Resources[res].iCurrentClient = -1; |
|
404 Resources[res].iNumClients = 0; |
|
405 } |
|
406 else if(Resources[res].iSense == ECustom) |
|
407 continue; |
|
408 else |
|
409 { |
|
410 TInt maxLevel = KMinTInt; |
|
411 TInt id = -1; |
|
412 for(SPowerResourceClientLevel* pCL = Resources[res].iLevel; pCL != NULL; pCL = pCL->iNextInList) |
|
413 { |
|
414 if(pCL->iClientId == aClientId) |
|
415 continue; |
|
416 if((maxLevel == KMinTInt) || (maxLevel == pCL->iLevel)) |
|
417 { |
|
418 maxLevel = pCL->iLevel; |
|
419 id = pCL->iClientId; |
|
420 continue; |
|
421 } |
|
422 if(Resources[res].iSense == EPositive && pCL->iLevel > maxLevel) |
|
423 { |
|
424 maxLevel = pCL->iLevel; |
|
425 id = pCL->iClientId; |
|
426 } |
|
427 else if(Resources[res].iSense == ENegative && pCL->iLevel < maxLevel) |
|
428 { |
|
429 maxLevel = pCL->iLevel; |
|
430 id = pCL->iClientId; |
|
431 } |
|
432 } |
|
433 if(id == -1) |
|
434 { |
|
435 Resources[res].iCurrentLevel = Resources[res].iDefaultLevel; |
|
436 Resources[res].iCurrentClient = -1; |
|
437 Resources[res].iNumClients = 0; |
|
438 } |
|
439 else |
|
440 { |
|
441 Resources[res].iCurrentLevel = maxLevel; |
|
442 Resources[res].iCurrentClient = id; |
|
443 Resources[res].iNumClients--; |
|
444 } |
|
445 } |
|
446 } |
|
447 //Remove client list entry from resource |
|
448 for(SPowerResourceClientLevel* pCL = Resources[res].iLevel; pCL != NULL; pCL = pCL->iNextInList) |
|
449 { |
|
450 if(pCL->iClientId == aClientId) |
|
451 { |
|
452 LIST_REMOVE(Resources[res].iLevel, pCL, iNextInList, SPowerResourceClientLevel); |
|
453 delete pCL; |
|
454 break; |
|
455 } |
|
456 } |
|
457 } |
|
458 //Verify the resource state consistency |
|
459 res = 0; |
|
460 TInt newState; |
|
461 TInt levelOwnerId; |
|
462 if(iMaxClients > 1) |
|
463 { |
|
464 for(TUint id = 0; id < Clients[aClientId].iNumResources; id++) |
|
465 { |
|
466 res = Clients[aClientId].iResourceIds[id]; |
|
467 if(res == 0) |
|
468 continue; |
|
469 for(TUint c = 0; c< iMaxStaticResources; c++) |
|
470 { |
|
471 if(Resources[c].iResourceId == res) |
|
472 { |
|
473 res = c; |
|
474 break; |
|
475 } |
|
476 } |
|
477 r = lddChan.GetResourceStateSync(Clients[0].iClientId, Resources[res].iResourceId, ETrue, newState, levelOwnerId); |
|
478 if(r != KErrNone) |
|
479 test.Printf(_L("GetResourceStateSync returned with %d"), r); |
|
480 test(r == KErrNone); |
|
481 if(newState != Resources[res].iCurrentLevel) |
|
482 test.Printf(_L("newState = %d, Resources[%d].iCurrentLevel = %d"), newState, Resources[res].iResourceId, Resources[res].iCurrentLevel); |
|
483 test(newState == Resources[res].iCurrentLevel); |
|
484 if(Resources[res].iCurrentClient == -1) |
|
485 test(levelOwnerId == -1); |
|
486 else if (levelOwnerId != (TInt)Clients[Resources[res].iCurrentClient].iClientId) |
|
487 { |
|
488 test.Printf(_L("levelOwnerId = 0x%x, iCurrentClient = 0x%x\n"), levelOwnerId, Resources[res].iCurrentClient); |
|
489 test(0); |
|
490 } |
|
491 } |
|
492 } |
|
493 Clients[aClientId].iClientId = 0; |
|
494 iMaxClients--; |
|
495 } |
|
496 |
|
497 //---------------------------------------------------------------------------------------------- |
|
498 //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0575 |
|
499 //! @SYMTestType UT |
|
500 //! @SYMPREQ PREQ1398 |
|
501 //! @SYMTestCaseDesc This test case tests the retrieval of client name functionality of resource |
|
502 //! manager and compares for correctness. There are negative and positive tests. |
|
503 //! @SYMTestActions If negative testing is enabled then following tests are done |
|
504 //! 0 Call the API with invalid client Id (calling client Id). |
|
505 //! 1 Call the API with invalid instance count of calling client Id. |
|
506 //! 2 Call the API with invalid target client Id. |
|
507 //! 3 Call the API with invalid instance count of target client Id. |
|
508 //! Positive tests |
|
509 //! 4 Call the API with valid client Ids (both calling and target client ID) |
|
510 //! |
|
511 //! @SYMTestExpectedResults 0 API should return with KErrAccessDenied, panics otherwise |
|
512 //! 1 API should return with KErrAccessDenied, panics otherwise |
|
513 //! 2 API should return with KErrNotFound, panics otherwise |
|
514 //! 3 API should return with KErrNotFound, panics otherwise |
|
515 //! 4 API should return KErrNone with name updated and also name |
|
516 //! is checked for correctness, panics otherwise |
|
517 //! @SYMTestPriority High |
|
518 //! @SYMTestStatus Implemented |
|
519 //---------------------------------------------------------------------------------------------- |
|
520 void TestRM::GetClientName(TUint aClientId) |
|
521 { |
|
522 ClientName[6] = (TUint8)('0' + aClientId); |
|
523 TBuf8<32> name; |
|
524 if(NegativeTesting) |
|
525 { |
|
526 //Pass illegal client Id |
|
527 r = lddChan.GetClientName(0, Clients[aClientId].iClientId, (TDes8*)&name); |
|
528 test(r == KErrAccessDenied); |
|
529 |
|
530 //Pass illegal instance count |
|
531 TUint id = Clients[aClientId].iClientId; |
|
532 id = id ^ (3<<16); |
|
533 r = lddChan.GetClientName(id, Clients[aClientId].iClientId, (TDes8*)&name); |
|
534 test(r == KErrAccessDenied); |
|
535 |
|
536 //Pass illegal target client id |
|
537 r = lddChan.GetClientName(Clients[aClientId].iClientId, iMaxClients, (TDes8*)&name); |
|
538 test(r == KErrNotFound); |
|
539 |
|
540 //Pass illegal instance count of target client id |
|
541 id = id ^ (1<<16); |
|
542 r = lddChan.GetClientName(Clients[aClientId].iClientId, 0 ,(TDes8*)&name); |
|
543 test(r == KErrNotFound); |
|
544 } |
|
545 r = lddChan.GetClientName(Clients[aClientId].iClientId, Clients[aClientId].iClientId, (TDes8*)&name); |
|
546 if(r != KErrNone) |
|
547 test.Printf(_L("GetClientName of ClientId 0x%x returned with %d"), Clients[aClientId].iClientId, r); |
|
548 test(r == KErrNone); |
|
549 if(name.Compare(ClientName)) |
|
550 test(0); |
|
551 } |
|
552 |
|
553 |
|
554 //---------------------------------------------------------------------------------------------- |
|
555 //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0576 |
|
556 //! @SYMTestType UT |
|
557 //! @SYMPREQ PREQ1398 |
|
558 //! @SYMTestCaseDesc This test case tests the retrieval of client ID functionality of resource |
|
559 //! manager and compares for correctness. There are negative and positive tests. |
|
560 //! @SYMTestActions If negative testing is enabled then following tests are done |
|
561 //! 0 Call the API with invalid client Id (calling client Id). |
|
562 //! 1 Call the API with invalid instance count of calling client Id. |
|
563 //! 2 Call the API with client name greater than maximum allowable |
|
564 //! client name (32 characters). |
|
565 //! 3 Call the API with name not registered with resource manager |
|
566 //! (non-existing name). |
|
567 //! Positive tests |
|
568 //! 4 Call the API with valid client Id. |
|
569 //! |
|
570 //! @SYMTestExpectedResults 0 API should return with KErrAccessDenied, panics otherwise |
|
571 //! 1 API should return with KErrAccessDenied, panics otherwise |
|
572 //! 2 API should return with KErrTooBig, panics otherwise |
|
573 //! 3 API should return with KErrNotFound, panics otherwise |
|
574 //! 4 API should return KErrNone with client Id updated and also Id |
|
575 //! is checked for correctness, panics otherwise |
|
576 //! @SYMTestPriority High |
|
577 //! @SYMTestStatus Implemented |
|
578 //---------------------------------------------------------------------------------------------- |
|
579 void TestRM::GetClientId(TUint aClientId) |
|
580 { |
|
581 TUint clientId; |
|
582 ClientName[6] = (TUint8)('0' + aClientId); |
|
583 if(NegativeTesting) |
|
584 { |
|
585 //Pass illegial client Id |
|
586 r = lddChan.GetClientId(0, (TDesC8&)ClientName, Clients[aClientId].iClientId); |
|
587 test(r == KErrAccessDenied); |
|
588 |
|
589 //Pass illegal instance count |
|
590 TUint id = Clients[aClientId].iClientId; |
|
591 id = id ^ (3<<16); |
|
592 r = lddChan.GetClientId(id, (TDesC8&)ClientName, Clients[aClientId].iClientId); |
|
593 test(r == KErrAccessDenied); |
|
594 |
|
595 TBuf8<50> badName = _L8("Clientnamegreaterthan32characters"); |
|
596 r = lddChan.GetClientId(Clients[aClientId].iClientId, (TDesC8&)badName, clientId); |
|
597 test(r == KErrTooBig); |
|
598 |
|
599 ClientName[6] = (TUint8)('0' + iMaxClients + 1); |
|
600 r = lddChan.GetClientId(Clients[aClientId].iClientId, (TDesC8&)ClientName, clientId); |
|
601 test(r == KErrNotFound); |
|
602 } |
|
603 ClientName[6] = (TUint8)('0' + aClientId); |
|
604 r = lddChan.GetClientId(Clients[aClientId].iClientId, (TDesC8&)ClientName, clientId); |
|
605 if(r != KErrNone) |
|
606 test.Printf(_L("GetClientId returned with %d"), r); |
|
607 test(r == KErrNone); |
|
608 if(clientId != Clients[aClientId].iClientId) |
|
609 test.Printf(_L("ClientId = 0x%x, Expected ClientId = 0x%x"), clientId, Clients[aClientId].iClientId); |
|
610 test(clientId == Clients[aClientId].iClientId); |
|
611 } |
|
612 |
|
613 //---------------------------------------------------------------------------------------------- |
|
614 //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0577 |
|
615 //! @SYMTestType UT |
|
616 //! @SYMPREQ PREQ1398 |
|
617 //! @SYMTestCaseDesc This test case tests the retrieval of resource ID functionality of resource |
|
618 //! manager and compares for correctness. There are negative and positive tests. |
|
619 //! @SYMTestActions If negative testing is enabled then following tests are done |
|
620 //! 0 Call the API with invalid client Id (calling client Id). |
|
621 //! 1 Call the API with invalid instance count of calling client Id. |
|
622 //! 2 Call the API with resource name greater than maximum allowable |
|
623 //! resource name (32 characters). |
|
624 //! 3 Call the API with name not registered with resource manager |
|
625 //! (non-existing name). |
|
626 //! Positive tests |
|
627 //! 4 Call the API with valid client Id and resource name. |
|
628 //! |
|
629 //! @SYMTestExpectedResults 0 API should return with KErrAccessDenied, panics otherwise |
|
630 //! 1 API should return with KErrAccessDenied, panics otherwise |
|
631 //! 2 API should return with KErrTooBig, panics otherwise |
|
632 //! 3 API should return with KErrNotFound, panics otherwise |
|
633 //! 4 API should return KErrNone with resource Id updated and also Id |
|
634 //! is checked for correctness, panics otherwise |
|
635 //! @SYMTestPriority High |
|
636 //! @SYMTestStatus Implemented |
|
637 //---------------------------------------------------------------------------------------------- |
|
638 void TestRM::GetResourceId(TUint aResId) |
|
639 { |
|
640 TUint resId; |
|
641 if(NegativeTesting) |
|
642 { |
|
643 r = lddChan.GetResourceId(iMaxClients, Resources[aResId].iName, resId); |
|
644 test(r == KErrAccessDenied); |
|
645 |
|
646 //Pass illegal instance count |
|
647 TUint id = Clients[iCurrentClientId].iClientId; |
|
648 id = id ^ (3<<17); |
|
649 r = lddChan.GetResourceId(id, (TDesC8&)Resources[aResId].iName, resId); |
|
650 test(r == KErrAccessDenied); |
|
651 |
|
652 TBuf8<50> badName = _L8("Resourcenamegreaterthen32characters"); |
|
653 r = lddChan.GetResourceId(Clients[iCurrentClientId].iClientId, (TDesC8&)badName, resId); |
|
654 test(r == KErrTooBig); |
|
655 badName = Resources[aResId].iName; |
|
656 badName[0] = '0' + 1; |
|
657 r = lddChan.GetResourceId(Clients[iCurrentClientId].iClientId, (TDesC8&)badName, resId); |
|
658 test(r == KErrNotFound); |
|
659 } |
|
660 r = lddChan.GetResourceId(Clients[iCurrentClientId].iClientId, (TDesC8&)Resources[aResId].iName, resId); |
|
661 if(r != KErrNone) |
|
662 test.Printf(_L("Return value of GetResourceId %d"), r); |
|
663 test(r == KErrNone); |
|
664 if(resId != Resources[aResId].iResourceId) |
|
665 test.Printf(_L("resId = %d ... aResId = %d"), resId, Resources[aResId].iResourceId); |
|
666 test(resId == Resources[aResId].iResourceId); |
|
667 } |
|
668 |
|
669 |
|
670 //---------------------------------------------------------------------------------------------- |
|
671 //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0578 |
|
672 //! @SYMTestType UT |
|
673 //! @SYMPREQ PREQ1398 |
|
674 //! @SYMTestCaseDesc This test case tests the retrieval of resource information of a specified |
|
675 //! resource functionality of resource manager and compares each info for correctness. |
|
676 //! There are negative and positive tests. |
|
677 //! @SYMTestActions If negative testing is enabled then following tests are done |
|
678 //! 0 Call the API with invalid client Id (calling client Id). |
|
679 //! 1 Call the API with invalid instance count of calling client Id. |
|
680 //! 2 Call the API with invalid resource id. |
|
681 //! Positive tests |
|
682 //! 3 Call the API with valid client Id and resource id. |
|
683 //! |
|
684 //! @SYMTestExpectedResults 0 API should return with KErrAccessDenied, panics otherwise |
|
685 //! 1 API should return with KErrAccessDenied, panics otherwise |
|
686 //! 2 API should return with KErrNotFound, panics otherwise |
|
687 //! 3 API should return KErrNone with resource information updated and also |
|
688 //! each information is checked for correctness, panics otherwise |
|
689 //! @SYMTestPriority High |
|
690 //! @SYMTestStatus Implemented |
|
691 //---------------------------------------------------------------------------------------------- |
|
692 void TestRM::GetResourceInfo(TUint aResId) |
|
693 { |
|
694 RBuf8 infoBuf; |
|
695 infoBuf.Create(sizeof(TPowerResourceInfoV01)); |
|
696 if(NegativeTesting) |
|
697 { |
|
698 r = lddChan.GetResourceInfo(iMaxClients-5, aResId+1, (TAny*)(TDes8*)&infoBuf); |
|
699 test(r == KErrAccessDenied); |
|
700 |
|
701 //Pass illegal instance count |
|
702 TUint id = Clients[iCurrentClientId].iClientId; |
|
703 id = id ^ (5<<17); |
|
704 r = lddChan.GetResourceInfo(id, aResId+1, (TAny*)infoBuf.Ptr()); |
|
705 test(r == KErrAccessDenied); |
|
706 |
|
707 r = lddChan.GetResourceInfo(Clients[iCurrentClientId].iClientId, iMaxStaticResources + 30, (TAny*)(TDes8*)&infoBuf); |
|
708 test(r == KErrNotFound); |
|
709 r = lddChan.GetResourceInfo(Clients[iCurrentClientId].iClientId, 26, (TAny*)(TDes8*)&infoBuf); |
|
710 test(r == KErrNotFound); |
|
711 } |
|
712 r = lddChan.GetResourceInfo(Clients[iCurrentClientId].iClientId, Resources[aResId].iResourceId, (TAny*)(TDes8*)&infoBuf); |
|
713 if(r != KErrNone) |
|
714 test.Printf(_L("GetResourceInfo returned with %d"), r); |
|
715 test(r == KErrNone); |
|
716 TPowerResourceInfoV01 *ptr = (TPowerResourceInfoV01*)infoBuf.Ptr(); |
|
717 //Compare results. |
|
718 test(ptr->iResourceId == Resources[aResId].iResourceId); |
|
719 test(ptr->iLatencyGet == Resources[aResId].iLatencyGet); |
|
720 test(ptr->iLatencySet == Resources[aResId].iLatencySet); |
|
721 test(ptr->iType == Resources[aResId].iType); |
|
722 test(ptr->iUsage == Resources[aResId].iUsage); |
|
723 test(ptr->iSense == Resources[aResId].iSense); |
|
724 test(ptr->iMaxLevel == Resources[aResId].iMaxLevel); |
|
725 test(ptr->iMinLevel == Resources[aResId].iMinLevel); |
|
726 test(ptr->iDefaultLevel == Resources[aResId].iDefaultLevel); |
|
727 if(ptr->iUsage == ESingle && Resources[aResId].iNumClients >1) //Single user resource cannot have more than 1 client. |
|
728 test(0); |
|
729 infoBuf.Close(); |
|
730 } |
|
731 |
|
732 //---------------------------------------------------------------------------------------------- |
|
733 //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0579 |
|
734 //! @SYMTestType UT |
|
735 //! @SYMPREQ PREQ1398 |
|
736 //! @SYMTestCaseDesc This test case tests retrieval of number of resources the requested client has |
|
737 //! requirement functionality of resource manager and compares with stored information |
|
738 //! for correctness.There are negative and positive tests. |
|
739 //! @SYMTestActions If negative testing is enabled then following tests are done |
|
740 //! 0 Call the API with invalid client Id (calling client Id). |
|
741 //! 1 Call the API with invalid instance count of calling client Id. |
|
742 //! 2 Call the API with invalid target client Id. |
|
743 //! 3 Call the API with invalid instance count of target client Id. |
|
744 //! Positive tests |
|
745 //! 4 Call the API with valid calling and target client Id. |
|
746 //! |
|
747 //! @SYMTestExpectedResults 0 API should return with KErrAccessDenied, panics otherwise |
|
748 //! 1 API should return with KErrAccessDenied, panics otherwise |
|
749 //! 2 API should return with KErrNotFound, panics otherwise |
|
750 //! 3 API should return with KErrNotFound, panics otherwise |
|
751 //! 4 API should return KErrNone with number of resources the requested client has |
|
752 //! requirement updated and also is checked for correctness, panics otherwise |
|
753 //! @SYMTestPriority High |
|
754 //! @SYMTestStatus Implemented |
|
755 //---------------------------------------------------------------------------------------------- |
|
756 void TestRM::GetNumResourcesInUseByClient(TInt aClientId) |
|
757 { |
|
758 TUint numRes; |
|
759 if(NegativeTesting) |
|
760 { |
|
761 //Pass illegial client Id |
|
762 r = lddChan.GetNumResourcesInUseByClient(23, Clients[aClientId].iClientId, numRes); |
|
763 test(r == KErrAccessDenied); |
|
764 |
|
765 //Pass illegal instance count |
|
766 TUint id = Clients[aClientId].iClientId; |
|
767 id = id ^ (1<<16); |
|
768 r = lddChan.GetNumResourcesInUseByClient(id, Clients[aClientId].iClientId, numRes); |
|
769 test(r == KErrAccessDenied); |
|
770 |
|
771 //Pass illegal target client id |
|
772 r = lddChan.GetNumResourcesInUseByClient(Clients[aClientId].iClientId, iMaxClients, numRes); |
|
773 test(r == KErrNotFound); |
|
774 |
|
775 //Pass illegal instance count of target client id |
|
776 id = id ^ (3<<16); |
|
777 r = lddChan.GetNumResourcesInUseByClient(Clients[aClientId].iClientId, id ,numRes); |
|
778 test(r == KErrNotFound); |
|
779 } |
|
780 |
|
781 if(aClientId == -1) |
|
782 { |
|
783 r = lddChan.GetNumResourcesInUseByClient(Clients[0].iClientId, 0, numRes); |
|
784 if(r != KErrNone) |
|
785 test.Printf(_L("GetNumResourcesInUseByClient returned with %d"), r); |
|
786 test(r == KErrNone); |
|
787 if((!iTestingExtendedVersion) && (numRes > MAX_STATIC_RESOURCE_NUM)) |
|
788 test(0); |
|
789 if(iMaxStaticResources == 0) |
|
790 iMaxStaticResources = numRes; |
|
791 else |
|
792 test(numRes == (iMaxStaticResources + iMaxStaticDependentResources)); |
|
793 } |
|
794 else |
|
795 { |
|
796 r = lddChan.GetNumResourcesInUseByClient(Clients[aClientId].iClientId, Clients[aClientId].iClientId, numRes); |
|
797 if(r != KErrNone) |
|
798 test.Printf(_L("GetNumResourceInUseByClient returned with %d"), r); |
|
799 test(r == KErrNone); |
|
800 if(numRes != Clients[aClientId].iNumResources) |
|
801 test.Printf(_L("numRes = %d, iNumResources = %d"), numRes, Clients[aClientId].iNumResources); |
|
802 test(numRes == Clients[aClientId].iNumResources); |
|
803 } |
|
804 } |
|
805 |
|
806 //---------------------------------------------------------------------------------------------- |
|
807 //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0580 |
|
808 //! @SYMTestType UT |
|
809 //! @SYMPREQ PREQ1398 |
|
810 //! @SYMTestCaseDesc This test case tests retrieval of information about resources the requested client has |
|
811 //! requirement functionality of resource manager and compares with stored information |
|
812 //! for correctness.There are negative and positive tests. |
|
813 //! @SYMTestActions If negative testing is enabled then following tests are done |
|
814 //! 0 Call the API with invalid client Id (calling client Id). |
|
815 //! 1 Call the API with invalid instance count of calling client Id. |
|
816 //! 2 Call the API with invalid target client Id. |
|
817 //! 3 Call the API with invalid instance count of target client Id. |
|
818 //! 4 Call the API with null buffer (buffer where the resource information will be updated). |
|
819 //! 5 Call the API with the number of resource information to be updated as 0 (specifies the |
|
820 //! size of the buffer). |
|
821 //! Positive tests |
|
822 //! 6 Call the API with valid calling and target client Id, buffer and its size. |
|
823 //! |
|
824 //! @SYMTestExpectedResults 0 API should return with KErrAccessDenied, panics otherwise |
|
825 //! 1 API should return with KErrAccessDenied, panics otherwise |
|
826 //! 2 API should return with KErrNotFound, panics otherwise |
|
827 //! 3 API should return with KErrNotFound, panics otherwise |
|
828 //! 4 API should return with KErrArgument, panics otherwise |
|
829 //! 5 API should return with KErrArgument, panics otherwise |
|
830 //! 6 API should return KErrNone with resource information about resources the requested |
|
831 //! client has requirement updated and also is checked for correctness, panics otherwise |
|
832 //! @SYMTestPriority High |
|
833 //! @SYMTestStatus Implemented |
|
834 //---------------------------------------------------------------------------------------------- |
|
835 void TestRM::GetInfoOnResourcesInUseByClient(TInt aClientId, TUint aNumRes) |
|
836 { |
|
837 RBuf8 info; |
|
838 info.Create(aNumRes * sizeof(TPowerResourceInfoV01)); |
|
839 if(NegativeTesting) |
|
840 { |
|
841 //Pass illegial client Id |
|
842 r = lddChan.GetInfoOnResourcesInUseByClient(32, Clients[aClientId].iClientId, aNumRes, (TAny*)(TDes8*)&info); |
|
843 test(r == KErrAccessDenied); |
|
844 |
|
845 //Pass illegal instance count |
|
846 TUint id = Clients[aClientId].iClientId; |
|
847 id = id ^ (1<<16); |
|
848 r = lddChan.GetInfoOnResourcesInUseByClient(id, Clients[aClientId].iClientId, aNumRes, (TAny*)(TDes8*)&info); |
|
849 test(r == KErrAccessDenied); |
|
850 |
|
851 //Pass illegal target client id |
|
852 r = lddChan.GetInfoOnResourcesInUseByClient(Clients[aClientId].iClientId, iMaxClients, aNumRes, (TAny*)(TDes8*)&info); |
|
853 test(r == KErrNotFound); |
|
854 |
|
855 //Pass illegal instance count of target client id |
|
856 id = id ^ (3<<16); |
|
857 r = lddChan.GetInfoOnResourcesInUseByClient(Clients[aClientId].iClientId, id ,aNumRes,(TAny*)(TDes8*)&info); |
|
858 test(r == KErrNotFound); |
|
859 |
|
860 //Pass null buffer |
|
861 r = lddChan.GetInfoOnResourcesInUseByClient(Clients[aClientId].iClientId, Clients[aClientId].iClientId ,aNumRes, (TAny*)NULL); |
|
862 test(r == KErrArgument); |
|
863 |
|
864 //Pass required resources as 0 |
|
865 TUint tempRes = 0; |
|
866 r = lddChan.GetInfoOnResourcesInUseByClient(Clients[aClientId].iClientId, Clients[aClientId].iClientId, tempRes, (TAny*)(TDes8*)&info); |
|
867 test(r == KErrArgument); |
|
868 } |
|
869 |
|
870 if(aClientId == -1) |
|
871 { |
|
872 r = lddChan.GetInfoOnResourcesInUseByClient(Clients[0].iClientId, 0, aNumRes, (TAny*)(TDes8*)&info); |
|
873 if(r != KErrNone) |
|
874 test.Printf(_L("GetInfoOnResourceInUseByClient returned with %d"), r); |
|
875 test(r == KErrNone); |
|
876 if(aNumRes != (iMaxStaticResources + iMaxStaticDependentResources)) |
|
877 test.Printf(_L("aNumRes = %d, iMaxStaticResources = %d"), aNumRes, iMaxStaticResources); |
|
878 test(aNumRes == (iMaxStaticResources + iMaxStaticDependentResources)); |
|
879 |
|
880 //Fill in the resource information |
|
881 TInt newState, levelOwnerId; |
|
882 TPowerResourceInfoV01 *ptr = (TPowerResourceInfoV01*)info.Ptr(); |
|
883 |
|
884 TUint extCount = 0; |
|
885 for(TUint count = 0; count < aNumRes; count++) |
|
886 { |
|
887 r = lddChan.GetResourceStateSync(Clients[0].iClientId, ptr->iResourceId, ETrue, newState, levelOwnerId); |
|
888 if(r != KErrNone) |
|
889 test.Printf(_L("GetResourceStateSync failed for ClientId = %d, resourceId = %d with return value %d\n"), Clients[0].iClientId, count+1, r); |
|
890 test(r == KErrNone); |
|
891 test.Printf(_L("Info of Resource %d\n"), count+1); |
|
892 test.Printf(_L("Resource Id %d\n"), ptr->iResourceId); |
|
893 test.Printf(_L("Resource Type %d\n"), ptr->iType); |
|
894 test.Printf(_L("Resource Sense %d\n"), ptr->iSense); |
|
895 test.Printf(_L("Resource Latency Get %d\n"), ptr->iLatencyGet); |
|
896 test.Printf(_L("Resource Latency Set %d\n"), ptr->iLatencySet); |
|
897 test.Printf(_L("Resource usage %d\n"), ptr->iUsage); |
|
898 test.Printf(_L("Resource MinLevel %d\n"), ptr->iMinLevel); |
|
899 test.Printf(_L("Resource MaxLevel %d\n"), ptr->iMaxLevel); |
|
900 test.Printf(_L("Resource DefaultLevel %d\n"), ptr->iDefaultLevel); |
|
901 |
|
902 if(iTestingExtendedVersion && (ptr->iResourceId & DEPENDENCY_RESOURCE_BIT_MASK)) |
|
903 { |
|
904 iStaticDependencyResources[extCount++] = ptr->iResourceId; |
|
905 ptr++; |
|
906 continue; |
|
907 } |
|
908 if(iTestingExtendedVersion && (ptr->iResourceId & DYNAMIC_RESOURCE_BIT_MASK)) |
|
909 { |
|
910 ptr++; |
|
911 continue; |
|
912 } |
|
913 Resources[count].iName.Copy(*ptr->iResourceName); |
|
914 Resources[count].iResourceId = ptr->iResourceId; |
|
915 Resources[count].iMaxLevel = ptr->iMaxLevel; |
|
916 Resources[count].iMinLevel = ptr->iMinLevel; |
|
917 Resources[count].iDefaultLevel = ptr->iDefaultLevel; |
|
918 Resources[count].iNumClients = 0; |
|
919 Resources[count].iCurrentClient = -1; |
|
920 Resources[count].iCurrentLevel = newState; |
|
921 Resources[count].iType = ptr->iType; |
|
922 Resources[count].iSense = ptr->iSense; |
|
923 Resources[count].iLatencyGet = ptr->iLatencyGet; |
|
924 Resources[count].iLatencySet = ptr->iLatencySet; |
|
925 Resources[count].iUsage = ptr->iUsage; |
|
926 Resources[count].iUnCondNotiCount = 0; |
|
927 Resources[count].iCondNoti = NULL; |
|
928 Resources[count].iUncondNoti = NULL; |
|
929 Resources[count].iLevel = NULL; |
|
930 ptr++; |
|
931 } |
|
932 iMaxStaticResources -= extCount; |
|
933 iMaxStaticDependentResources = extCount; |
|
934 info.Close(); |
|
935 return; |
|
936 } |
|
937 r = lddChan.GetInfoOnResourcesInUseByClient(Clients[aClientId].iClientId, Clients[aClientId].iClientId, aNumRes, (TAny*)&info); |
|
938 if(aNumRes != Clients[aClientId].iNumResources) |
|
939 { |
|
940 test.Printf(_L("Expected Resource Num = %d, Returned = %d\n"), Clients[aClientId].iNumResources, aNumRes); |
|
941 test(0); |
|
942 } |
|
943 if(aNumRes == 0) |
|
944 { |
|
945 test((r == KErrArgument) || (r == KErrNone)); |
|
946 info.Close(); |
|
947 return; |
|
948 } |
|
949 else |
|
950 test(r == KErrNone); |
|
951 TPowerResourceInfoV01 *ptr = (TPowerResourceInfoV01*)info.Ptr(); |
|
952 for(TUint count = 0; count < Clients[aClientId].iNumResources; count++) |
|
953 { |
|
954 if(Clients[aClientId].iResourceIds[count] == 0) |
|
955 continue; |
|
956 TUint c; |
|
957 for(c = 0; c < Clients[aClientId].iNumResources; c++) |
|
958 { |
|
959 if(Clients[aClientId].iResourceIds[c] == ptr->iResourceId) |
|
960 break; |
|
961 } |
|
962 if(c == Clients[aClientId].iNumResources) |
|
963 test(0); |
|
964 //Find the resource from resource list |
|
965 for(c = 0; c < iMaxStaticResources; c++) |
|
966 { |
|
967 if(Resources[c].iResourceId == ptr->iResourceId) |
|
968 break; |
|
969 } |
|
970 if(c == iMaxStaticResources) |
|
971 test(0); |
|
972 test(Resources[c].iResourceId == ptr->iResourceId); |
|
973 test(Resources[c].iMaxLevel == ptr->iMaxLevel); |
|
974 test(Resources[c].iMinLevel == ptr->iMinLevel); |
|
975 test(Resources[c].iDefaultLevel == ptr->iDefaultLevel); |
|
976 test(Resources[c].iType == ptr->iType); |
|
977 test(Resources[c].iSense == ptr->iSense); |
|
978 test(Resources[c].iLatencyGet == ptr->iLatencyGet); |
|
979 test(Resources[c].iLatencySet == ptr->iLatencySet); |
|
980 test(Resources[c].iUsage == ptr->iUsage); |
|
981 test(!Resources[c].iName.Compare(*ptr->iResourceName)); |
|
982 ptr++; |
|
983 } |
|
984 info.Close(); |
|
985 } |
|
986 |
|
987 //---------------------------------------------------------------------------------------------- |
|
988 //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0581 |
|
989 //! @SYMTestType UT |
|
990 //! @SYMPREQ PREQ1398 |
|
991 //! @SYMTestCaseDesc This test case tests retrieval of number of clients holding requirement on |
|
992 //! the requested resource functionality of resource manager and compares with stored |
|
993 //! information for correctness.There are negative and positive tests. |
|
994 //! @SYMTestActions If negative testing is enabled then following tests are done |
|
995 //! 0 Call the API with invalid client Id (calling client Id). |
|
996 //! 1 Call the API with invalid instance count of calling client Id. |
|
997 //! 2 Call the API with invalid resource Id. |
|
998 //! Positive tests |
|
999 //! 3 Call the API with valid calling client Id and resource Id. |
|
1000 //! |
|
1001 //! @SYMTestExpectedResults 0 API should return with KErrAccessDenied, panics otherwise |
|
1002 //! 1 API should return with KErrAccessDenied, panics otherwise |
|
1003 //! 2 API should return with KErrNotFound, panics otherwise |
|
1004 //! 3 API should return KErrNone with number of clients holding requirement on |
|
1005 //! the requested resource updated and also is checked for correctness, panics otherwise |
|
1006 //! @SYMTestPriority High |
|
1007 //! @SYMTestStatus Implemented |
|
1008 //---------------------------------------------------------------------------------------------- |
|
1009 void TestRM::GetNumClientsUsingResource(TUint aClientId, TUint aResId) |
|
1010 { |
|
1011 TUint clientNum = 0; |
|
1012 if(NegativeTesting) |
|
1013 { |
|
1014 //Pass illegial client Id |
|
1015 r = lddChan.GetNumClientsUsingResource(32, 1, clientNum); |
|
1016 test(r == KErrAccessDenied); |
|
1017 |
|
1018 //Pass illegal instance count |
|
1019 TUint id = Clients[aClientId].iClientId; |
|
1020 id = id ^ (1<<16); |
|
1021 r = lddChan.GetNumClientsUsingResource(id, 1, clientNum); |
|
1022 test(r == KErrAccessDenied); |
|
1023 |
|
1024 //Invalid resource id |
|
1025 r = lddChan.GetNumClientsUsingResource(Clients[aClientId].iClientId, iMaxStaticResources+40, clientNum); |
|
1026 test(r == KErrNotFound); |
|
1027 } |
|
1028 if((TInt)aResId == -1) |
|
1029 r = lddChan.GetNumClientsUsingResource(Clients[aClientId].iClientId, 0, clientNum); |
|
1030 else |
|
1031 r = lddChan.GetNumClientsUsingResource(Clients[aClientId].iClientId, Resources[aResId].iResourceId, clientNum); |
|
1032 if(r != KErrNone) |
|
1033 test.Printf(_L("GetNumClientsUsingResource for client 0x%x failed with %d"), Clients[aClientId].iClientId, r); |
|
1034 test(r==KErrNone); |
|
1035 if((TInt)aResId == -1) |
|
1036 { |
|
1037 if(clientNum != (TUint)(Clients.Count() + 1)) |
|
1038 test.Printf(_L("ClientNum = %d, Expected clientNum = %d"), clientNum, Clients.Count()+1); |
|
1039 test(clientNum == (TUint)(Clients.Count() + 1)); |
|
1040 } |
|
1041 else |
|
1042 { |
|
1043 test(Resources[aResId].iNumClients == clientNum); |
|
1044 if(!Resources[aResId].iUsage && clientNum > 1) //Single user resource cannot have more that one client |
|
1045 test(0); |
|
1046 } |
|
1047 } |
|
1048 |
|
1049 //---------------------------------------------------------------------------------------------- |
|
1050 //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0582 |
|
1051 //! @SYMTestType UT |
|
1052 //! @SYMPREQ PREQ1398 |
|
1053 //! @SYMTestCaseDesc This test case tests retrieval of information about clients holding requirement on |
|
1054 //! the passed resource functionality of resource manager and compares with stored information |
|
1055 //! for correctness.There are negative and positive tests. |
|
1056 //! @SYMTestActions If negative testing is enabled then following tests are done |
|
1057 //! 0 Call the API with invalid client Id (calling client Id). |
|
1058 //! 1 Call the API with invalid instance count of calling client Id. |
|
1059 //! 2 Call the API with invalid resource Id. |
|
1060 //! 3 Call the API with null buffer (buffer where the resource information will be updated). |
|
1061 //! 4 Call the API with the number of resource information to be updated as 0 (specifies the |
|
1062 //! size of the buffer). |
|
1063 //! Positive tests |
|
1064 //! 5 Call the API with valid calling and target client Id, buffer and its size. |
|
1065 //! |
|
1066 //! @SYMTestExpectedResults 0 API should return with KErrAccessDenied, panics otherwise |
|
1067 //! 1 API should return with KErrAccessDenied, panics otherwise |
|
1068 //! 2 API should return with KErrNotFound, panics otherwise |
|
1069 //! 3 API should return with KErrArgument, panics otherwise |
|
1070 //! 4 API should return with KErrArgument, panics otherwise |
|
1071 //! 5 API should return KErrNone with resource information about clients holding requirement |
|
1072 //! on the passed resource and also is checked for correctness, panics otherwise |
|
1073 //! @SYMTestPriority High |
|
1074 //! @SYMTestStatus Implemented |
|
1075 //---------------------------------------------------------------------------------------------- |
|
1076 void TestRM::GetInfoOnClientsUsingResource(TUint aResId, TUint aNumCli) |
|
1077 { |
|
1078 RBuf8 info; |
|
1079 info.Create(aNumCli * sizeof(TPowerClientInfoV01)); |
|
1080 if(NegativeTesting) |
|
1081 { |
|
1082 //Pass illegial client Id |
|
1083 r = lddChan.GetInfoOnClientsUsingResource(2, 1, aNumCli, (TAny*)(TDes8*)&info); |
|
1084 test(r == KErrAccessDenied); |
|
1085 |
|
1086 //Pass illegal instance count |
|
1087 TUint id = Clients[iCurrentClientId].iClientId; |
|
1088 id = id ^ (1<<16); |
|
1089 r = lddChan.GetInfoOnClientsUsingResource(id, 1, aNumCli, (TAny*)(TDes8*)&info); |
|
1090 test(r == KErrAccessDenied); |
|
1091 |
|
1092 //Invalid resource id |
|
1093 r = lddChan.GetInfoOnClientsUsingResource(Clients[iCurrentClientId].iClientId, iMaxStaticResources+40, aNumCli, (TAny*)(TDes8*)&info); |
|
1094 test(r == KErrNotFound); |
|
1095 |
|
1096 //Pass null buffer |
|
1097 r = lddChan.GetInfoOnClientsUsingResource(Clients[iCurrentClientId].iClientId, 1 ,aNumCli, (TAny*)NULL); |
|
1098 test(r == KErrArgument); |
|
1099 |
|
1100 //Pass required resources as 0 |
|
1101 TUint tempCli = 0; |
|
1102 r = lddChan.GetInfoOnClientsUsingResource(Clients[iCurrentClientId].iClientId, 1 ,tempCli, (TAny*)(TDes8*)&info); |
|
1103 test(r == KErrArgument); |
|
1104 } |
|
1105 if((TInt)aResId == -1) |
|
1106 r = lddChan.GetInfoOnClientsUsingResource(Clients[iCurrentClientId].iClientId, 0, aNumCli, (TAny*)(TDes8*)&info); |
|
1107 else |
|
1108 r = lddChan.GetInfoOnClientsUsingResource(Clients[iCurrentClientId].iClientId, Resources[aResId].iResourceId, aNumCli, (TAny*)(TDes8*)&info); |
|
1109 if(r == KErrArgument) |
|
1110 { |
|
1111 if(aResId != 0) |
|
1112 test(Resources[aResId].iNumClients == 0); |
|
1113 info.Close(); |
|
1114 return; |
|
1115 } |
|
1116 test(r == KErrNone); |
|
1117 TPowerClientInfoV01 *ptr = (TPowerClientInfoV01*)info.Ptr(); |
|
1118 if((TInt)aResId == -1) |
|
1119 { |
|
1120 test(aNumCli == (TUint)(Clients.Count() + 1)); |
|
1121 TUint c = 0; |
|
1122 for(TUint count = 0; count < aNumCli; count++) |
|
1123 { |
|
1124 //Skip comparision of first client as that will be PowerController. |
|
1125 if(ptr->iClientId == iPowerControllerId) |
|
1126 { |
|
1127 ptr++; |
|
1128 continue; |
|
1129 } |
|
1130 for(c = 0; c< iMaxClients; c++) |
|
1131 { |
|
1132 if(ptr->iClientId == Clients[c].iClientId) |
|
1133 break; |
|
1134 } |
|
1135 if(c == iMaxClients) |
|
1136 test(0); |
|
1137 ptr++; |
|
1138 } |
|
1139 } |
|
1140 else |
|
1141 { |
|
1142 if(aNumCli != Resources[aResId].iNumClients) |
|
1143 test.Printf(_L("aNumCli = %d, Expected numClients = %d\n"), aNumCli, Resources[aResId].iNumClients); |
|
1144 test(aNumCli == Resources[aResId].iNumClients); |
|
1145 //Compare results |
|
1146 SPowerResourceClientLevel *level = Resources[aResId].iLevel; |
|
1147 TUint c = 0; |
|
1148 for(TUint count = 0; count < aNumCli; count++) |
|
1149 { |
|
1150 SPowerResourceClientLevel *pL = Resources[aResId].iLevel; |
|
1151 for(c =0;c<aNumCli;c++) |
|
1152 { |
|
1153 if(Clients[pL->iClientId].iClientId == ptr->iClientId) |
|
1154 break; |
|
1155 pL = pL->iNextInList; |
|
1156 } |
|
1157 if(c == aNumCli) |
|
1158 { |
|
1159 test.Printf(_L("Client Id %d is not in the resource clientlevel list\n"), Clients[level->iClientId].iClientId); |
|
1160 test(0); |
|
1161 } |
|
1162 level = level->iNextInList; |
|
1163 ptr++; |
|
1164 } |
|
1165 } |
|
1166 info.Close(); |
|
1167 } |
|
1168 |
|
1169 //---------------------------------------------------------------------------------------------- |
|
1170 //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0583 |
|
1171 //! @SYMTestType UT |
|
1172 //! @SYMPREQ PREQ1398 |
|
1173 //! @SYMTestCaseDesc This test case tests preallocation of memory for resource manager internal |
|
1174 //! structure.There are negative and positive tests. |
|
1175 //! @SYMTestActions If negative testing is enabled then following tests are done |
|
1176 //! 0 Call the API with invalid client Id |
|
1177 //! 1 Call the API with invalid instance count of client Id. |
|
1178 //! Positive tests |
|
1179 //! 2 Call the API with valid client Id. |
|
1180 //! |
|
1181 //! @SYMTestExpectedResults 0 API should return with KErrAccessDenied, panics otherwise |
|
1182 //! 1 API should return with KErrAccessDenied, panics otherwise |
|
1183 //! 2 API should return with KErrNone, panic otherwise. Really cannot |
|
1184 //! test this for correctness. |
|
1185 //! @SYMTestPriority High |
|
1186 //! @SYMTestStatus Implemented |
|
1187 //---------------------------------------------------------------------------------------------- |
|
1188 void TestRM::AllocReserve(TUint aClientId) |
|
1189 { |
|
1190 if(NegativeTesting) |
|
1191 { |
|
1192 //Pass illegial client Id |
|
1193 r = lddChan.AllocReserve(11, 0, 3); |
|
1194 test(r == KErrAccessDenied); |
|
1195 |
|
1196 //Pass illegal instance count |
|
1197 TUint id = Clients[aClientId].iClientId; |
|
1198 id = id ^ (1<<16); |
|
1199 r = lddChan.AllocReserve(id, 0, 0); |
|
1200 test(r == KErrAccessDenied); |
|
1201 |
|
1202 } |
|
1203 r = lddChan.AllocReserve(Clients[iCurrentClientId].iClientId, 1, 0); |
|
1204 if(r != KErrNone) |
|
1205 test.Printf(_L("Alloc Reserve failed with %d"), r); |
|
1206 test(r == KErrNone); |
|
1207 } |
|
1208 |
|
1209 //This function validates the conditional and unconditional notification for the |
|
1210 //specified resource state change. |
|
1211 void TestRM::CheckNotification(TUint aResId, TInt newState) |
|
1212 { |
|
1213 if(newState == Resources[aResId].iCurrentLevel) |
|
1214 return; |
|
1215 //Return if the newState is in decreasing order with respect to sense. |
|
1216 if(Resources[aResId].iUsage == EShared && Resources[aResId].iCurrentClient != -1) |
|
1217 { |
|
1218 if(Resources[aResId].iSense == EPositive) |
|
1219 { |
|
1220 if(newState <= Resources[aResId].iCurrentLevel && Resources[aResId].iCurrentClient != iCurrentClientId) |
|
1221 return; |
|
1222 } |
|
1223 else |
|
1224 { |
|
1225 if(newState >= Resources[aResId].iCurrentLevel && Resources[aResId].iCurrentClient != iCurrentClientId) |
|
1226 return; |
|
1227 } |
|
1228 } |
|
1229 TUint notificationUnCon = Resources[aResId].iUnCondNotiCount; |
|
1230 TUint notificationCon =0; |
|
1231 for(NotiInfo* info = Resources[aResId].iCondNoti; info != NULL; info = info->iNext) |
|
1232 { |
|
1233 if((info->iDirection && (info->iPreviousLevel < info->iThreshold) && (newState >= info->iThreshold)) || |
|
1234 (!info->iDirection && (info->iPreviousLevel > info->iThreshold) && (newState <= info->iThreshold))) |
|
1235 notificationCon++; |
|
1236 info->iPreviousLevel = newState; |
|
1237 } |
|
1238 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, notificationUnCon, notificationCon); |
|
1239 if(r != KErrNone) |
|
1240 test.Printf(_L("Check Notifications failed with %d"), r); |
|
1241 test(r == KErrNone); |
|
1242 } |
|
1243 |
|
1244 //This function updates the client level.This will be used by other functions for validation. |
|
1245 void TestRM::AddClientLevel(TUint aResId, TInt newState) |
|
1246 { |
|
1247 SPowerResourceClientLevel *pCL = NULL; |
|
1248 if(Resources[aResId].iUsage == EShared) |
|
1249 { |
|
1250 for(pCL = Resources[aResId].iLevel;pCL != NULL; pCL = pCL->iNextInList) |
|
1251 { |
|
1252 if((TInt)pCL->iClientId == iCurrentClientId) |
|
1253 { |
|
1254 pCL->iLevel = newState; |
|
1255 return; |
|
1256 } |
|
1257 } |
|
1258 pCL = new SPowerResourceClientLevel; |
|
1259 test(pCL != NULL); |
|
1260 pCL->iClientId = iCurrentClientId; |
|
1261 pCL->iResourceId = Resources[aResId].iResourceId; |
|
1262 pCL->iLevel = newState; |
|
1263 LIST_PUSH(Resources[aResId].iLevel, pCL, iNextInList); |
|
1264 Resources[aResId].iNumClients++; |
|
1265 } |
|
1266 else |
|
1267 { |
|
1268 if(Resources[aResId].iCurrentClient == -1) |
|
1269 { |
|
1270 pCL = new SPowerResourceClientLevel; |
|
1271 test(pCL != NULL); |
|
1272 pCL->iClientId = iCurrentClientId; |
|
1273 pCL->iResourceId = Resources[aResId].iResourceId; |
|
1274 pCL->iLevel = newState; |
|
1275 LIST_PUSH(Resources[aResId].iLevel, pCL, iNextInList); |
|
1276 Resources[aResId].iNumClients++; |
|
1277 } |
|
1278 else |
|
1279 { |
|
1280 SPowerResourceClientLevel* pCL = Resources[aResId].iLevel; |
|
1281 pCL->iLevel = newState; |
|
1282 } |
|
1283 } |
|
1284 } |
|
1285 |
|
1286 //This function updates the current level and client information in corresponding resource array. |
|
1287 void TestRM::UpdateClientInformation(TUint aResId, TInt aNewState) |
|
1288 { |
|
1289 if(Resources[aResId].iCurrentClient == -1) |
|
1290 { |
|
1291 Resources[aResId].iCurrentLevel = aNewState; |
|
1292 Resources[aResId].iCurrentClient = iCurrentClientId; |
|
1293 return; |
|
1294 } |
|
1295 if(!Resources[aResId].iUsage) |
|
1296 { |
|
1297 Resources[aResId].iCurrentLevel = aNewState; |
|
1298 return; |
|
1299 } |
|
1300 if(Resources[aResId].iSense == EPositive) |
|
1301 { |
|
1302 if(aNewState > Resources[aResId].iCurrentLevel) |
|
1303 { |
|
1304 Resources[aResId].iCurrentLevel = aNewState; |
|
1305 Resources[aResId].iCurrentClient = iCurrentClientId; |
|
1306 } |
|
1307 else if(Resources[aResId].iCurrentClient == iCurrentClientId) |
|
1308 { |
|
1309 SPowerResourceClientLevel *pCL = NULL; |
|
1310 for(pCL = Resources[aResId].iLevel;pCL != NULL; pCL = pCL->iNextInList) |
|
1311 { |
|
1312 if(pCL->iLevel > aNewState) |
|
1313 { |
|
1314 Resources[aResId].iCurrentLevel = pCL->iLevel; |
|
1315 Resources[aResId].iCurrentClient = pCL->iClientId; |
|
1316 return; |
|
1317 } |
|
1318 } |
|
1319 Resources[aResId].iCurrentLevel = aNewState; |
|
1320 Resources[aResId].iCurrentClient = iCurrentClientId; |
|
1321 } |
|
1322 return; |
|
1323 } |
|
1324 if(Resources[aResId].iSense == ENegative) |
|
1325 { |
|
1326 if(aNewState < Resources[aResId].iCurrentLevel) |
|
1327 { |
|
1328 Resources[aResId].iCurrentLevel = aNewState; |
|
1329 Resources[aResId].iCurrentClient = iCurrentClientId; |
|
1330 } |
|
1331 else if(Resources[aResId].iCurrentClient == iCurrentClientId) |
|
1332 { |
|
1333 SPowerResourceClientLevel *pCL = NULL; |
|
1334 for(pCL = Resources[aResId].iLevel;pCL != NULL; pCL = pCL->iNextInList) |
|
1335 { |
|
1336 if(pCL->iLevel < aNewState) |
|
1337 { |
|
1338 Resources[aResId].iCurrentLevel = pCL->iLevel; |
|
1339 Resources[aResId].iCurrentClient = pCL->iClientId; |
|
1340 return; |
|
1341 } |
|
1342 } |
|
1343 Resources[aResId].iCurrentLevel = aNewState; |
|
1344 Resources[aResId].iCurrentClient = iCurrentClientId; |
|
1345 } |
|
1346 } |
|
1347 return; |
|
1348 } |
|
1349 |
|
1350 //---------------------------------------------------------------------------------------------- |
|
1351 //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0584 |
|
1352 //! @SYMTestType UT |
|
1353 //! @SYMPREQ PREQ1398 |
|
1354 //! @SYMTestCaseDesc This test case tests change resource state functionality of resource manager |
|
1355 //! by changing the state of the resource to random value between resource minimum |
|
1356 //! and maximum value synchronously.This function will add the client level if required |
|
1357 //! and update resource information and will check notification for correctness.There are |
|
1358 //! postive and negative tests. |
|
1359 //! @SYMTestActions If negative testing is enabled then following tests are done |
|
1360 //! 0 Call the API with invalid client Id |
|
1361 //! 1 Call the API with invalid instance count of client Id. |
|
1362 //! 2 Call the API with invalid resource Id |
|
1363 //! Positive tests |
|
1364 //! 3 Call the API with valid client and resource Id. |
|
1365 //! |
|
1366 //! @SYMTestExpectedResults 0 API should return with KErrAccessDenied, panics otherwise |
|
1367 //! 1 API should return with KErrAccessDenied, panics otherwise |
|
1368 //! 2 API should return with KErrNotFound, panic otherwise. |
|
1369 //! 3 API should return with KErrNone, panic otherwise. |
|
1370 //! This also checks for notifications revceived as a result of this |
|
1371 //! resource change and checks for correctness. |
|
1372 //! @SYMTestPriority High |
|
1373 //! @SYMTestStatus Implemented |
|
1374 //---------------------------------------------------------------------------------------------- |
|
1375 void TestRM::ChangeResourceStateSync(TUint aResId) |
|
1376 { |
|
1377 TInt newState = 0; |
|
1378 if(NegativeTesting) |
|
1379 { |
|
1380 //Pass illegial client Id |
|
1381 r = lddChan.ChangeResourceStateSync(434224, Resources[aResId].iResourceId, newState); |
|
1382 test(r == KErrAccessDenied); |
|
1383 |
|
1384 //Pass illegal instance count |
|
1385 TUint id = Clients[iCurrentClientId].iClientId; |
|
1386 id = id ^ (1<<16); |
|
1387 r = lddChan.ChangeResourceStateSync(id, Resources[aResId].iResourceId, newState); |
|
1388 test(r == KErrAccessDenied); |
|
1389 |
|
1390 //Invalid resource id |
|
1391 r = lddChan.ChangeResourceStateSync(Clients[iCurrentClientId].iClientId, iMaxStaticResources+40, newState); |
|
1392 test(r == KErrNotFound); |
|
1393 |
|
1394 r = lddChan.ChangeResourceStateSync(Clients[iCurrentClientId].iClientId, 26, newState); |
|
1395 test(r == KErrNotFound); |
|
1396 } |
|
1397 TInt maxLevel = Resources[aResId].iMaxLevel; |
|
1398 TInt minLevel = Resources[aResId].iNumClients? Resources[aResId].iCurrentLevel : Resources[aResId].iMinLevel; |
|
1399 //Toggle current state for binary resources |
|
1400 if(!Resources[aResId].iType) |
|
1401 newState = !Resources[aResId].iCurrentLevel; |
|
1402 else if (Resources[aResId].iType == EMultiLevel) |
|
1403 { |
|
1404 TInt diff = Abs(maxLevel - minLevel); |
|
1405 if(Resources[aResId].iSense == EPositive) |
|
1406 { |
|
1407 if(minLevel == maxLevel) |
|
1408 newState = maxLevel - Math::Random() % diff; |
|
1409 else |
|
1410 newState = minLevel + Math::Random() % diff; |
|
1411 } |
|
1412 else |
|
1413 { |
|
1414 if(minLevel == maxLevel) |
|
1415 newState = maxLevel + Math::Random() % diff; |
|
1416 else |
|
1417 newState = minLevel - Math::Random() % diff; |
|
1418 } |
|
1419 } |
|
1420 TInt reqState = newState; |
|
1421 r = lddChan.ChangeResourceStateSync(Clients[iCurrentClientId].iClientId, Resources[aResId].iResourceId, newState); |
|
1422 if(r == KErrAccessDenied) |
|
1423 return; |
|
1424 if(r != KErrNone) |
|
1425 test.Printf(_L("Synchronous resource change returned with %d"), r); |
|
1426 test(r == KErrNone); |
|
1427 if(newState != reqState) |
|
1428 test.Printf(_L("NewState = %d, Expected state = %d"), newState, reqState); |
|
1429 if(!Resources[aResId].iUsage) |
|
1430 test(newState == reqState); |
|
1431 CheckNotification(aResId, reqState); |
|
1432 AddClientLevel(aResId, reqState); |
|
1433 UpdateClientInformation(aResId, reqState); |
|
1434 TUint c = 0; |
|
1435 for(c = 0; c< Clients[iCurrentClientId].iNumResources; c++) |
|
1436 { |
|
1437 if(Clients[iCurrentClientId].iResourceIds[c] == Resources[aResId].iResourceId) |
|
1438 return; |
|
1439 } |
|
1440 Clients[iCurrentClientId].iResourceIds[c] = Resources[aResId].iResourceId; |
|
1441 Clients[iCurrentClientId].iNumResources++; |
|
1442 return; |
|
1443 } |
|
1444 |
|
1445 //---------------------------------------------------------------------------------------------- |
|
1446 //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0585 |
|
1447 //! @SYMTestType UT |
|
1448 //! @SYMPREQ PREQ1398 |
|
1449 //! @SYMTestCaseDesc This test case tests change resource state functionality of resource manager |
|
1450 //! by changing the state of the resource to random value between resource minimum |
|
1451 //! and maximum value asynchronously.This function will add the client level if required |
|
1452 //! and update resource information and will check notification for correctness.This |
|
1453 //! also tests the cancellation of asynchronous function by immediately cancelling the |
|
1454 //! operation after requesting resource state change. This is taken care in the driver. |
|
1455 //! There are postive and negative tests. |
|
1456 //! @SYMTestActions If negative testing is enabled then following tests are done |
|
1457 //! 0 Call the API with invalid client Id |
|
1458 //! 1 Call the API with invalid instance count of client Id. |
|
1459 //! 2 Call the API with invalid resource Id |
|
1460 //! Positive tests |
|
1461 //! 3 Call the API with valid client and resource Id. |
|
1462 //! |
|
1463 //! @SYMTestExpectedResults 0 API should return with KErrAccessDenied, panics otherwise |
|
1464 //! 1 API should return with KErrAccessDenied, panics otherwise |
|
1465 //! 2 API should return with KErrNotFound, panic otherwise. |
|
1466 //! 3 API should return with KErrNone or if cancellation of this |
|
1467 //! API is tested then will return with KErrCancel, panic otherwise. |
|
1468 //! This also checks for notifications received as a result of this |
|
1469 //! resource change and checks for correctness. |
|
1470 //! @SYMTestPriority High |
|
1471 //! @SYMTestStatus Implemented |
|
1472 //---------------------------------------------------------------------------------------------- |
|
1473 void TestRM::ChangeResourceStateAsync(TUint aResId, TBool aReqCancel) |
|
1474 { |
|
1475 TRequestStatus resChange; |
|
1476 TInt newState = 0; |
|
1477 if(NegativeTesting) |
|
1478 { |
|
1479 //Pass illegial client Id |
|
1480 lddChan.ChangeResourceStateAsync(434224, Resources[aResId].iResourceId, newState, resChange); |
|
1481 User::WaitForRequest(resChange); |
|
1482 test(resChange.Int() == KErrAccessDenied); |
|
1483 |
|
1484 //Pass illegal instance count |
|
1485 TUint id = Clients[iCurrentClientId].iClientId; |
|
1486 id = id ^ (1<<16); |
|
1487 lddChan.ChangeResourceStateAsync(id, Resources[aResId].iResourceId, newState, resChange); |
|
1488 User::WaitForRequest(resChange); |
|
1489 test(resChange.Int() == KErrAccessDenied); |
|
1490 |
|
1491 //Invalid resource id |
|
1492 lddChan.ChangeResourceStateAsync(Clients[iCurrentClientId].iClientId, iMaxStaticResources+40, newState, resChange); |
|
1493 User::WaitForRequest(resChange); |
|
1494 test(resChange.Int() == KErrNotFound); |
|
1495 |
|
1496 lddChan.ChangeResourceStateAsync(Clients[iCurrentClientId].iClientId, 19, newState, resChange); |
|
1497 User::WaitForRequest(resChange); |
|
1498 test(resChange.Int() == KErrNotFound); |
|
1499 } |
|
1500 TInt maxLevel = Resources[aResId].iMaxLevel; |
|
1501 TInt minLevel = (Resources[aResId].iCurrentClient != -1)? Resources[aResId].iCurrentLevel : Resources[aResId].iMinLevel; |
|
1502 //Check if the resource is positive |
|
1503 if(!Resources[aResId].iType) |
|
1504 newState = !Resources[aResId].iCurrentLevel; |
|
1505 else if (Resources[aResId].iType == EMultiLevel) |
|
1506 { |
|
1507 TInt diff = Abs(maxLevel - minLevel); |
|
1508 if( diff == 0) |
|
1509 diff = Abs(Resources[aResId].iMaxLevel - Resources[aResId].iMinLevel); |
|
1510 if(Resources[aResId].iSense == EPositive) |
|
1511 { |
|
1512 if(minLevel == maxLevel) |
|
1513 newState = maxLevel - Math::Random() % diff; |
|
1514 else |
|
1515 newState = minLevel + Math::Random() % diff; |
|
1516 } |
|
1517 else |
|
1518 { |
|
1519 if(minLevel == maxLevel) |
|
1520 newState = maxLevel + Math::Random() % diff; |
|
1521 else |
|
1522 newState = minLevel - Math::Random() % diff; |
|
1523 } |
|
1524 } |
|
1525 TInt reqState = newState; |
|
1526 //Long latency resource |
|
1527 lddChan.ChangeResourceStateAsync(Clients[iCurrentClientId].iClientId, Resources[aResId].iResourceId, newState, resChange, aReqCancel); |
|
1528 User::WaitForRequest(resChange); |
|
1529 if(aReqCancel && (resChange.Int() != KErrNone)) |
|
1530 { |
|
1531 test(resChange.Int() == KErrCancel || resChange.Int() == KErrCompletion); |
|
1532 return; |
|
1533 } |
|
1534 if(resChange.Int() == KErrAccessDenied) |
|
1535 return; |
|
1536 if(!Resources[aResId].iUsage) |
|
1537 test(newState == reqState); |
|
1538 CheckNotification(aResId, reqState); |
|
1539 AddClientLevel(aResId, reqState); |
|
1540 UpdateClientInformation(aResId, reqState); |
|
1541 TUint c = 0; |
|
1542 for(c = 0; c< Clients[iCurrentClientId].iNumResources; c++) |
|
1543 { |
|
1544 if(Clients[iCurrentClientId].iResourceIds[c] == Resources[aResId].iResourceId) |
|
1545 return; |
|
1546 } |
|
1547 Clients[iCurrentClientId].iResourceIds[c] = Resources[aResId].iResourceId; |
|
1548 Clients[iCurrentClientId].iNumResources++; |
|
1549 return; |
|
1550 } |
|
1551 |
|
1552 //---------------------------------------------------------------------------------------------- |
|
1553 //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0586 |
|
1554 //! @SYMTestType UT |
|
1555 //! @SYMPREQ PREQ1398 |
|
1556 //! @SYMTestCaseDesc This test case tests synchronous version of get resource state functionality of |
|
1557 //! resource manager by getting the state of the resource checks for correctness. |
|
1558 //! There are positive and negative tests. |
|
1559 //! @SYMTestActions If negative testing is enabled then following tests are done |
|
1560 //! 0 Call the API with invalid client Id |
|
1561 //! 1 Call the API with invalid instance count of client Id. |
|
1562 //! 2 Call the API with invalid resource Id |
|
1563 //! Positive tests |
|
1564 //! 3 Call the API with valid client and resource Id. |
|
1565 //! |
|
1566 //! @SYMTestExpectedResults 0 API should return with KErrAccessDenied, panics otherwise |
|
1567 //! 1 API should return with KErrAccessDenied, panics otherwise |
|
1568 //! 2 API should return with KErrNotFound, panic otherwise. |
|
1569 //! 3 API should return with KErrNone and also the state and Owner Id are checked |
|
1570 //! for correctness, panic otherwise. |
|
1571 //! @SYMTestPriority High |
|
1572 //! @SYMTestStatus Implemented |
|
1573 //---------------------------------------------------------------------------------------------- |
|
1574 void TestRM::GetResourceStateSync(TUint aResId) |
|
1575 { |
|
1576 static TBool Cached; |
|
1577 TInt state = 0, levelOwnerId = 0; |
|
1578 if(NegativeTesting) |
|
1579 { |
|
1580 //Pass illegial client Id |
|
1581 r = lddChan.GetResourceStateSync(4342241, Resources[aResId].iResourceId, Cached, state, levelOwnerId); |
|
1582 test(r == KErrAccessDenied); |
|
1583 |
|
1584 //Pass illegal instance count |
|
1585 TUint id = Clients[iCurrentClientId].iClientId; |
|
1586 id = id ^ (1<<30); |
|
1587 r = lddChan.GetResourceStateSync(id, Resources[aResId].iResourceId, Cached, state, levelOwnerId); |
|
1588 test(r == KErrAccessDenied); |
|
1589 |
|
1590 //Invalid resource id |
|
1591 r = lddChan.GetResourceStateSync(Clients[iCurrentClientId].iClientId, iMaxStaticResources+40, Cached, state, levelOwnerId); |
|
1592 test(r == KErrNotFound); |
|
1593 |
|
1594 r = lddChan.GetResourceStateSync(Clients[iCurrentClientId].iClientId, 20, Cached, state, levelOwnerId); |
|
1595 test(r == KErrNotFound); |
|
1596 } |
|
1597 r = lddChan.GetResourceStateSync(Clients[iCurrentClientId].iClientId, Resources[aResId].iResourceId, Cached, state, levelOwnerId); |
|
1598 test(r == KErrNone); |
|
1599 test(state == Resources[aResId].iCurrentLevel); |
|
1600 if(Resources[aResId].iCurrentClient == -1) |
|
1601 test(levelOwnerId == -1); |
|
1602 else if (levelOwnerId != (TInt)Clients[Resources[aResId].iCurrentClient].iClientId) |
|
1603 { |
|
1604 test.Printf(_L("Expected ClientId = 0x%x, Returned ClientId = 0x%x\n"), Resources[aResId].iCurrentClient, levelOwnerId); |
|
1605 test(0); |
|
1606 } |
|
1607 Cached = !Cached; |
|
1608 return; |
|
1609 } |
|
1610 |
|
1611 //---------------------------------------------------------------------------------------------- |
|
1612 //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0587 |
|
1613 //! @SYMTestType UT |
|
1614 //! @SYMPREQ PREQ1398 |
|
1615 //! @SYMTestCaseDesc This test case tests get resource state functionality of resource manager |
|
1616 //! by getting the state of the resource asynchronously and checking for correctness. |
|
1617 //! This also tests the cancellation of asynchronous function by immediately cancelling the |
|
1618 //! operation after requesting get resource state. This is taken care in the driver. |
|
1619 //! There are positive and negative tests. |
|
1620 //! @SYMTestActions If negative testing is enabled then following tests are done |
|
1621 //! 0 Call the API with invalid client Id |
|
1622 //! 1 Call the API with invalid instance count of client Id. |
|
1623 //! 2 Call the API with invalid resource Id |
|
1624 //! Positive tests |
|
1625 //! 3 Call the API with valid client and resource Id. |
|
1626 //! |
|
1627 //! @SYMTestExpectedResults 0 API should return with KErrAccessDenied, panics otherwise |
|
1628 //! 1 API should return with KErrAccessDenied, panics otherwise |
|
1629 //! 2 API should return with KErrNotFound, panic otherwise. |
|
1630 //! 3 API should return with KErrNone or if cancellation of this |
|
1631 //! API is tested then will return with KErrCancel, panic otherwise. |
|
1632 //! This also checks the updated level and owner Id for correctness, |
|
1633 //! panics otherwise. |
|
1634 //! @SYMTestPriority High |
|
1635 //! @SYMTestStatus Implemented |
|
1636 //---------------------------------------------------------------------------------------------- |
|
1637 void TestRM::GetResourceStateAsync(TUint aResId, TBool aReqCancel) |
|
1638 { |
|
1639 static TBool Cached; |
|
1640 TRequestStatus resGet; |
|
1641 TInt state, levelOwnerId; |
|
1642 if(NegativeTesting) |
|
1643 { |
|
1644 //Pass illegial client Id |
|
1645 lddChan.GetResourceStateAsync(4342241, Resources[aResId].iResourceId, Cached, resGet, state, levelOwnerId); |
|
1646 User::WaitForRequest(resGet); |
|
1647 test(resGet.Int() == KErrAccessDenied); |
|
1648 |
|
1649 //Pass illegal instance count |
|
1650 TUint id = Clients[iCurrentClientId].iClientId; |
|
1651 id = id ^ (1<<30); |
|
1652 lddChan.GetResourceStateAsync(id, Resources[aResId].iResourceId, Cached, resGet, state, levelOwnerId); |
|
1653 User::WaitForRequest(resGet); |
|
1654 test(resGet.Int() == KErrAccessDenied); |
|
1655 |
|
1656 //Invalid resource id |
|
1657 lddChan.GetResourceStateAsync(Clients[iCurrentClientId].iClientId, iMaxStaticResources+48, Cached, resGet, state, levelOwnerId); |
|
1658 User::WaitForRequest(resGet); |
|
1659 test(resGet.Int() == KErrNotFound); |
|
1660 |
|
1661 lddChan.GetResourceStateAsync(Clients[iCurrentClientId].iClientId, 20, Cached, resGet, state, levelOwnerId); |
|
1662 User::WaitForRequest(resGet); |
|
1663 test(resGet.Int() == KErrNotFound); |
|
1664 } |
|
1665 lddChan.GetResourceStateAsync(Clients[iCurrentClientId].iClientId, Resources[aResId].iResourceId, Cached, resGet, state, levelOwnerId, aReqCancel); |
|
1666 User::WaitForRequest(resGet); |
|
1667 if(aReqCancel && (resGet.Int() != KErrNone)) |
|
1668 { |
|
1669 test(resGet.Int() == KErrCancel || resGet.Int() == KErrCompletion); |
|
1670 return; |
|
1671 } |
|
1672 test(state == Resources[aResId].iCurrentLevel); |
|
1673 if(Resources[aResId].iCurrentClient == -1) |
|
1674 test(levelOwnerId == -1); |
|
1675 else if (levelOwnerId != (TInt)Clients[Resources[aResId].iCurrentClient].iClientId) |
|
1676 { |
|
1677 test.Printf(_L("Expected ClientId = 0x%x, Returned ClientId = 0x%x\n"), Resources[aResId].iCurrentClient, levelOwnerId); |
|
1678 test(0); |
|
1679 } |
|
1680 Cached = !Cached; |
|
1681 } |
|
1682 |
|
1683 //---------------------------------------------------------------------------------------------- |
|
1684 //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0588 |
|
1685 //! @SYMTestType UT |
|
1686 //! @SYMPREQ PREQ1398 |
|
1687 //! @SYMTestCaseDesc This test case tests unconditional notification request functionality of resource manager. |
|
1688 //! @SYMTestActions Call the API with valid client and resource Id. |
|
1689 //! |
|
1690 //! @SYMTestExpectedResults API should return with KErrNone, panics otherwise. |
|
1691 //! @SYMTestPriority High |
|
1692 //! @SYMTestStatus Implemented |
|
1693 //---------------------------------------------------------------------------------------------- |
|
1694 void TestRM::RequestNotification(TUint aResId) |
|
1695 { |
|
1696 //If unconditional notification is already queued for this client then dont request another one. |
|
1697 for(NotiInfo *pN = Resources[aResId].iUncondNoti; pN != NULL; pN = pN->iNext) |
|
1698 { |
|
1699 if((TInt)pN->iClientId == iCurrentClientId) |
|
1700 return; |
|
1701 } |
|
1702 r = lddChan.RequestNotification(Clients[iCurrentClientId].iClientId, Resources[aResId].iResourceId); |
|
1703 if(r != KErrNone) |
|
1704 test.Printf(_L("Request Notification returned with %d"), r); |
|
1705 test(r == KErrNone); |
|
1706 //Add to resource list |
|
1707 NotiInfo *info = new NotiInfo; |
|
1708 test(info != NULL); |
|
1709 info->iClientId = iCurrentClientId; |
|
1710 LIST_PUSH(Resources[aResId].iUncondNoti, info, iNext); |
|
1711 Resources[aResId].iUnCondNotiCount++; |
|
1712 } |
|
1713 |
|
1714 //---------------------------------------------------------------------------------------------- |
|
1715 //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0589 |
|
1716 //! @SYMTestType UT |
|
1717 //! @SYMPREQ PREQ1398 |
|
1718 //! @SYMTestCaseDesc This test case tests conditional notification request functionality of resource manager. |
|
1719 //! Threshold and direction are chosen randomly for each resource based on the resource information. |
|
1720 //! @SYMTestActions Call the API with valid client and resource Id. |
|
1721 //! |
|
1722 //! @SYMTestExpectedResults API should return with KErrNone, panics otherwise. |
|
1723 //! @SYMTestPriority High |
|
1724 //! @SYMTestStatus Implemented |
|
1725 //---------------------------------------------------------------------------------------------- |
|
1726 void TestRM::RequestNotificationCon(TUint aResId) |
|
1727 { |
|
1728 //Allow only one notification per client. |
|
1729 static TBool direction; |
|
1730 TInt threshold = direction; |
|
1731 for(NotiInfo *pN = Resources[aResId].iCondNoti; pN != NULL; pN = pN->iNext) |
|
1732 { |
|
1733 if((TInt)pN->iClientId == iCurrentClientId) |
|
1734 return; |
|
1735 } |
|
1736 if(Resources[aResId].iType) |
|
1737 { |
|
1738 if(Resources[aResId].iSense == EPositive) |
|
1739 { |
|
1740 threshold = Math::Random() % Resources[aResId].iMaxLevel; |
|
1741 if(threshold < Resources[aResId].iMinLevel) |
|
1742 threshold += Resources[aResId].iMinLevel; |
|
1743 } |
|
1744 else if(Resources[aResId].iSense == ENegative) |
|
1745 { |
|
1746 threshold = Math::Random() % Resources[aResId].iMinLevel; |
|
1747 if(threshold < Resources[aResId].iMaxLevel) |
|
1748 threshold += Resources[aResId].iMaxLevel; |
|
1749 } |
|
1750 } |
|
1751 r = lddChan.RequestNotification(Clients[iCurrentClientId].iClientId, Resources[aResId].iResourceId, direction, threshold); |
|
1752 if(r != KErrNone) |
|
1753 test.Printf(_L("Request Notification returned with %d for direction = %d, threshold = %d"), r, direction, threshold); |
|
1754 test(r == KErrNone); |
|
1755 NotiInfo *info = new NotiInfo; |
|
1756 test(info != NULL); |
|
1757 info->iClientId = iCurrentClientId; |
|
1758 info->iThreshold = threshold; |
|
1759 info->iDirection = direction; |
|
1760 info->iPreviousLevel = Resources[aResId].iCurrentLevel; |
|
1761 LIST_PUSH(Resources[aResId].iCondNoti, info, iNext); |
|
1762 direction = !direction; |
|
1763 } |
|
1764 |
|
1765 //---------------------------------------------------------------------------------------------- |
|
1766 //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0590 |
|
1767 //! @SYMTestType UT |
|
1768 //! @SYMPREQ PREQ1398 |
|
1769 //! @SYMTestCaseDesc This test case tests cancellation of notification functionality of resource manager. |
|
1770 //! @SYMTestActions Call the API with valid client and resource Id. |
|
1771 //! |
|
1772 //! @SYMTestExpectedResults API should return with KErrCancel, panics otherwise. |
|
1773 //! @SYMTestPriority High |
|
1774 //! @SYMTestStatus Implemented |
|
1775 //---------------------------------------------------------------------------------------------- |
|
1776 void TestRM::CancelNotification(TUint aResId, TBool Cond) |
|
1777 { |
|
1778 RMResInfo *pR = &Resources[aResId]; |
|
1779 TBool found = EFalse; |
|
1780 if(Cond) |
|
1781 { |
|
1782 //Remove any conditional notification this client has on resource. |
|
1783 for(NotiInfo* pI = pR->iCondNoti; pI != NULL; pI = pI->iNext) |
|
1784 { |
|
1785 if((TInt)pI->iClientId == iCurrentClientId) |
|
1786 { |
|
1787 LIST_REMOVE(pR->iCondNoti, pI, iNext, NotiInfo); |
|
1788 delete pI; |
|
1789 found = ETrue; |
|
1790 break; |
|
1791 } |
|
1792 } |
|
1793 } |
|
1794 else |
|
1795 { |
|
1796 //Remove any unconditional notification this client has on resource. |
|
1797 for(NotiInfo* pI = pR->iUncondNoti; pI != NULL; pI = pI->iNext) |
|
1798 { |
|
1799 if((TInt)pI->iClientId == iCurrentClientId) |
|
1800 { |
|
1801 LIST_REMOVE(pR->iUncondNoti, pI, iNext, NotiInfo); |
|
1802 pR->iUnCondNotiCount--; |
|
1803 delete pI; |
|
1804 found = ETrue; |
|
1805 break; |
|
1806 } |
|
1807 } |
|
1808 } |
|
1809 if(found) |
|
1810 { |
|
1811 r = lddChan.CancelNotification(Clients[iCurrentClientId].iClientId, Resources[aResId].iResourceId, Cond); |
|
1812 if(r != KErrCancel) |
|
1813 test.Printf(_L("CancelNotification Clients %d, return value = %d"), iCurrentClientId, r); |
|
1814 test(r == KErrCancel); |
|
1815 } |
|
1816 } |
|
1817 |
|
1818 //---------------------------------------------------------------------------------------------- |
|
1819 //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0591 |
|
1820 //! @SYMTestType UT |
|
1821 //! @SYMPREQ PREQ1398 |
|
1822 //! @SYMTestCaseDesc This test case tests client registration and deregistration API of resource manager. |
|
1823 //! There are positive and negative tests. |
|
1824 //! @SYMTestActions 0 Call the client registration API with valid client name to register |
|
1825 //! 1 Call the client name updation API with valid client Id to get the client name |
|
1826 //! 2 Call the client name updation API with invalid client id. |
|
1827 //! 3 Call the client registration API with client name greater than maximum |
|
1828 //! allowable name length (32 characters) |
|
1829 //! 4 Call the client deregistration API by passing invalid client Id. |
|
1830 //! 5 Call the client deregistration API by passing invalid instance count. |
|
1831 //! 6 Call the client deregistration API by passing valid client Id. |
|
1832 //! |
|
1833 //! @SYMTestExpectedResults 0 API should return with KErrNone, panics otherwise. |
|
1834 //! 1 API should return with KErrNone and updated name is checked for |
|
1835 //! correctness, panics otherwise. |
|
1836 //! 2 API should return with KErrAccessDenied, panics otherwise. |
|
1837 //! 3 API should return with KErrTooBig, panics otherwise. |
|
1838 //! 4 API should return with KErrNotFound, panics otherwise. |
|
1839 //! 5 API should return with KErrNotFound, panics otherwise. |
|
1840 //! 6 API should return with KErrNone, panics otherwise. |
|
1841 //! @SYMTestPriority High |
|
1842 //! @SYMTestStatus Implemented |
|
1843 //---------------------------------------------------------------------------------------------- |
|
1844 void TestRM::ValidateClient(TUint aNumClients, TOwnerType aContext) |
|
1845 { |
|
1846 TInt r = KErrNone; |
|
1847 TBuf8<32> ClientName; |
|
1848 ClientName.Zero(); |
|
1849 ClientName.Append(_L8("Clients?")); |
|
1850 TUint clientId[MAX_CLIENTS]; |
|
1851 if(aNumClients > MAX_CLIENTS) |
|
1852 return; |
|
1853 TUint c; |
|
1854 for(c = 0; c < aNumClients; c++) |
|
1855 { |
|
1856 ClientName[7] = (TUint8)('0' + c); |
|
1857 r = lddChan.RegisterClient(clientId[c], (const TDesC*)&ClientName, aContext); |
|
1858 if(r != KErrNone) |
|
1859 { |
|
1860 test.Printf(_L("Client registration failed with %d"), r); |
|
1861 test(0); |
|
1862 } |
|
1863 } |
|
1864 |
|
1865 //Validate Client |
|
1866 TBuf8<32> aName; |
|
1867 |
|
1868 for(c = 0; c < aNumClients; c++) |
|
1869 { |
|
1870 ClientName[7] = (TUint8)('0' + c); |
|
1871 r = lddChan.GetClientName(clientId[c], clientId[c], (TDes8*)&aName); |
|
1872 if(r != KErrNone) |
|
1873 { |
|
1874 test.Printf(_L("GetClientName API failed with error %d"), r); |
|
1875 test(0); |
|
1876 } |
|
1877 r = aName.Compare(ClientName); |
|
1878 if(r != KErrNone) |
|
1879 { |
|
1880 test.Printf(_L("Client Name is not as expected")); |
|
1881 test(0); |
|
1882 } |
|
1883 } |
|
1884 //Invalid tests |
|
1885 ClientName[7] = (TUint8)('0' + aNumClients+1); |
|
1886 r = lddChan.GetClientName(aNumClients, clientId[0], &aName); |
|
1887 if(r != KErrAccessDenied) |
|
1888 { |
|
1889 test.Printf(_L("RM allows illegal clients")); |
|
1890 test(0); |
|
1891 } |
|
1892 |
|
1893 //Long filename |
|
1894 TBuf8<50> name; |
|
1895 name.Zero(); |
|
1896 name.Append(_L8("RegisteringClientNameGreaterThan32Characters")); |
|
1897 TUint id =0; |
|
1898 r = lddChan.RegisterClient(id, (const TDesC*)&name, aContext); |
|
1899 if(r != KErrTooBig) |
|
1900 { |
|
1901 test.Printf(_L("RM allows big names !!!")); |
|
1902 test(0); |
|
1903 } |
|
1904 test.Printf(_L("Client Deregistration")); |
|
1905 //Deregistration of non-existing client |
|
1906 id = 0; |
|
1907 r = lddChan.DeRegisterClient(id); |
|
1908 if(r != KErrNotFound) |
|
1909 { |
|
1910 test.Printf(_L("RM allows invalid client ID deregistration!!!")); |
|
1911 test(0); |
|
1912 } |
|
1913 |
|
1914 //Get client Name by passing invalid client Id (changing a bit in instance count) |
|
1915 id = clientId[0] ^ (1<<16); |
|
1916 r = lddChan.DeRegisterClient(id); |
|
1917 if(r != KErrNotFound) |
|
1918 { |
|
1919 test.Printf(_L("RM allows invalid client ID deregistation!!!")); |
|
1920 test(0); |
|
1921 } |
|
1922 |
|
1923 //Deregister the client registered at the start of this function |
|
1924 for(c = 0; c < aNumClients; c++) |
|
1925 { |
|
1926 r = lddChan.DeRegisterClient(clientId[c]); |
|
1927 if(r != KErrNone) |
|
1928 { |
|
1929 test.Printf(_L("Deregistration of client id 0x%x failed"), clientId[c]); |
|
1930 test(0); |
|
1931 } |
|
1932 } |
|
1933 return; |
|
1934 } |
|
1935 |
|
1936 #ifdef PRM_ENABLE_EXTENDED_VERSION |
|
1937 //---------------------------------------------------------------------------------------------- |
|
1938 //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0597 |
|
1939 //! @SYMTestType UT |
|
1940 //! @SYMPREQ PREQ1398 |
|
1941 //! @SYMTestCaseDesc This test case tests dynamic resources with dependency. |
|
1942 //! @SYMTestActions 0 Register clients |
|
1943 //! 1 Register dynamic resource with dependency |
|
1944 //! 2 Establish dependency between resources |
|
1945 //! 3 Register notifications |
|
1946 //! 4 Check dependency information for correctness |
|
1947 //! 5 Change Resource State of each resource |
|
1948 //! 6 Get state of the resources and verify them for correctness |
|
1949 //! 7 Check notification count for correctness |
|
1950 //! 8 Deregister dependency between resources |
|
1951 //! 9 Deregister client level |
|
1952 //! 10 Deregister dynamic resource with dependency |
|
1953 //! 11 Deregister clients |
|
1954 //! |
|
1955 //! @SYMTestExpectedResults 0 API should return with KErrNone, panics otherwise. |
|
1956 //! 1 API should return with KErrNone, panics otherwise. |
|
1957 //! 2 API should return with KErrNone, panics otherwise. |
|
1958 //! 3 API should return with KErrNone, panics otherwise. |
|
1959 //! 4 API should return with KErrNone, panics otherwise. |
|
1960 //! 5 API should return with KErrNone, panics otherwise. |
|
1961 //! 6 API should return with KErrNone, panics otherwise. |
|
1962 //! 7 API should return with KErrNone, panics otherwise. |
|
1963 //! 8 API should return with KErrNone, panics otherwise. |
|
1964 //! 9 API should return with KErrNone, panics otherwise. |
|
1965 //! 10 API should return with KErrNone, panics otherwise. |
|
1966 //! 11 API should return with KErrNone, panics otherwise. |
|
1967 //! @SYMTestPriority High |
|
1968 //! @SYMTestStatus Implemented |
|
1969 //---------------------------------------------------------------------------------------------- |
|
1970 /*This tests dynamic dependency resource. It also creates a dependency between static resource. |
|
1971 Below is the dependency tree |
|
1972 ResourceA <----------------> ResourceD <------------->ResourceE <--------------> ResourceC |
|
1973 | | |
|
1974 | | |
|
1975 | | |
|
1976 | | |
|
1977 | | |
|
1978 | | |
|
1979 ResourceF ResourceG <-------------> Resource H <------->Resource I |
|
1980 ¦ (Dynamic) (Dynamic) |
|
1981 ¦ |
|
1982 ¦ |
|
1983 ¦ |
|
1984 Resource J <-------->Resource K |
|
1985 (Dynamic) (Dynamic) |
|
1986 */ |
|
1987 void TestRM::TestDynamicResourceDependency() |
|
1988 { |
|
1989 TInt state; |
|
1990 TRequestStatus req; |
|
1991 SResourceDependencyInfo info1, info2; |
|
1992 SResourceDependencyInfo sResDepInfo; |
|
1993 RArray<SResourceDependencyInfo>depResArray; |
|
1994 |
|
1995 TUint dynamicDepResId[4]; |
|
1996 |
|
1997 test.Next(_L("Testing Dynamic + static resource dependency")); |
|
1998 RmTest.RegisterClient(); /* Register Client 1 */ |
|
1999 |
|
2000 //Register dependency resource |
|
2001 dynamicDepResId[0] = 5; |
|
2002 r = lddChan.RegisterDynamicResource(Clients[0].iClientId, dynamicDepResId[0]); |
|
2003 test(r == KErrNone); |
|
2004 |
|
2005 info1.iResourceId = iStaticDependencyResources[5]; |
|
2006 info1.iDependencyPriority = 3; |
|
2007 |
|
2008 info2.iResourceId = dynamicDepResId[0]; |
|
2009 info2.iDependencyPriority = 2; |
|
2010 |
|
2011 r = lddChan.RegisterResourceDependency(Clients[0].iClientId, info1, info2); |
|
2012 test(r == KErrNone); |
|
2013 |
|
2014 //Check for correctness of dependency resource information |
|
2015 sResDepInfo.iResourceId = iStaticDependencyResources[3]; |
|
2016 sResDepInfo.iDependencyPriority = 1; |
|
2017 depResArray.Append(sResDepInfo); |
|
2018 sResDepInfo.iResourceId = dynamicDepResId[0]; |
|
2019 sResDepInfo.iDependencyPriority = 2; |
|
2020 depResArray.Append(sResDepInfo); |
|
2021 RmTest.CheckForDependencyInformation(Clients[0].iClientId, iStaticDependencyResources[5], 2, &depResArray[0]); |
|
2022 |
|
2023 depResArray[0].iResourceId = iStaticDependencyResources[5]; |
|
2024 depResArray[0].iDependencyPriority = 3; |
|
2025 RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[0], 1, &depResArray[0]); |
|
2026 |
|
2027 //Change Static dependency resource to -50 |
|
2028 RmTest.RegisterClient(); /* Register Client 2 */ |
|
2029 state = -50; |
|
2030 lddChan.ChangeResourceStateAsync(Clients[1].iClientId, iStaticDependencyResources[0], state, req); |
|
2031 User::WaitForRequest(req); |
|
2032 test(req.Int() == KErrNone); |
|
2033 |
|
2034 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[0], -50, Clients[1].iClientId, EFalse); |
|
2035 GetExtendedResStateAndVerify(iStaticDependencyResources[1], -11, iStaticDependencyResources[0]); |
|
2036 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, iStaticDependencyResources[0], EFalse); |
|
2037 GetExtendedResStateAndVerify(iStaticDependencyResources[3], 13, iStaticDependencyResources[0]); |
|
2038 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3], EFalse); |
|
2039 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 73, iStaticDependencyResources[3]); |
|
2040 GetExtendedResStateAndVerify(dynamicDepResId[0], 80, iStaticDependencyResources[5]); |
|
2041 |
|
2042 //Register dynamic dependency resource I |
|
2043 dynamicDepResId[1] = 6; |
|
2044 r = lddChan.RegisterDynamicResource(Clients[0].iClientId, dynamicDepResId[1]); |
|
2045 test(r == KErrNone); |
|
2046 |
|
2047 //Register dynamic dependency resource J |
|
2048 dynamicDepResId[2] = 7; |
|
2049 r = lddChan.RegisterDynamicResource(Clients[0].iClientId, dynamicDepResId[2]); |
|
2050 test(r == KErrNone); |
|
2051 |
|
2052 //Register dynamic dependency resource K |
|
2053 dynamicDepResId[3] = 8; |
|
2054 r = lddChan.RegisterDynamicResource(Clients[0].iClientId, dynamicDepResId[3]); |
|
2055 test(r == KErrNone); |
|
2056 |
|
2057 RmTest.RegisterClient(); /* Register Client3 */ |
|
2058 RmTest.RegisterClient(); /* Register Client4 */ |
|
2059 |
|
2060 //Register notifications |
|
2061 r = lddChan.RequestNotification(Clients[1].iClientId, iStaticDependencyResources[5]); |
|
2062 test(r == KErrNone); |
|
2063 r = lddChan.RequestNotification(Clients[2].iClientId, dynamicDepResId[0]); |
|
2064 test(r == KErrNone); |
|
2065 r = lddChan.RequestNotification(Clients[1].iClientId, dynamicDepResId[1]); |
|
2066 test(r == KErrNone); |
|
2067 r = lddChan.RequestNotification(Clients[2].iClientId, dynamicDepResId[2]); |
|
2068 test(r == KErrNone); |
|
2069 r = lddChan.RequestNotification(Clients[1].iClientId, dynamicDepResId[3]); |
|
2070 test(r == KErrNone); |
|
2071 |
|
2072 //Create depedency between H and I |
|
2073 info1.iResourceId = dynamicDepResId[0]; |
|
2074 info1.iDependencyPriority = 1; |
|
2075 |
|
2076 info2.iResourceId = dynamicDepResId[1]; |
|
2077 info2.iDependencyPriority = 1; |
|
2078 |
|
2079 //Register dependency between resource H and I |
|
2080 r = lddChan.RegisterResourceDependency(Clients[0].iClientId, info1, info2); |
|
2081 test(r == KErrNone); |
|
2082 //Validate dependency information |
|
2083 depResArray[0].iResourceId = dynamicDepResId[1]; |
|
2084 depResArray[0].iDependencyPriority = 1; |
|
2085 depResArray[1].iResourceId = iStaticDependencyResources[5]; |
|
2086 depResArray[1].iDependencyPriority = 3; |
|
2087 RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[0], 2, &depResArray[0]); |
|
2088 |
|
2089 depResArray[0].iResourceId = dynamicDepResId[0]; |
|
2090 depResArray[0].iDependencyPriority = 1; |
|
2091 RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[1], 1, &depResArray[0]); |
|
2092 |
|
2093 //Create depedency between H and J |
|
2094 info1.iResourceId = dynamicDepResId[0]; |
|
2095 info1.iDependencyPriority = 1; |
|
2096 |
|
2097 info2.iResourceId = dynamicDepResId[2]; |
|
2098 info2.iDependencyPriority = 2; |
|
2099 |
|
2100 //Register dependency between resource H and J |
|
2101 r = lddChan.RegisterResourceDependency(Clients[0].iClientId, info1, info2); |
|
2102 test(r == KErrNone); |
|
2103 |
|
2104 depResArray[0].iResourceId = dynamicDepResId[1]; |
|
2105 depResArray[0].iDependencyPriority = 1; |
|
2106 depResArray[1].iResourceId = dynamicDepResId[2]; |
|
2107 depResArray[1].iDependencyPriority = 2; |
|
2108 sResDepInfo.iResourceId = iStaticDependencyResources[5]; |
|
2109 sResDepInfo.iDependencyPriority = 3; |
|
2110 depResArray.Append(sResDepInfo); |
|
2111 RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[0], 3, &depResArray[0]); |
|
2112 |
|
2113 depResArray[0].iResourceId = dynamicDepResId[0]; |
|
2114 depResArray[0].iDependencyPriority = 1; |
|
2115 RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[2], 1, &depResArray[0]); |
|
2116 |
|
2117 // Check if the priority for a new dependency is already existing. |
|
2118 //Create dependency between J and K |
|
2119 info1.iResourceId = dynamicDepResId[2]; |
|
2120 info1.iDependencyPriority = 1; |
|
2121 |
|
2122 info2.iResourceId = dynamicDepResId[3]; |
|
2123 info2.iDependencyPriority = 1; |
|
2124 |
|
2125 //Register dependency between resource J and K |
|
2126 r = lddChan.RegisterResourceDependency(Clients[0].iClientId, info1, info2); |
|
2127 test(r == KErrAlreadyExists); |
|
2128 |
|
2129 //Create depedency between J and K |
|
2130 info1.iResourceId = dynamicDepResId[2]; |
|
2131 info1.iDependencyPriority = 1; |
|
2132 |
|
2133 info2.iResourceId = dynamicDepResId[3]; |
|
2134 info2.iDependencyPriority = 2; |
|
2135 |
|
2136 //Register dependency between resource J and K |
|
2137 r = lddChan.RegisterResourceDependency(Clients[0].iClientId, info1, info2); |
|
2138 test(r == KErrNone); |
|
2139 |
|
2140 depResArray[0].iResourceId = dynamicDepResId[2]; |
|
2141 depResArray[0].iDependencyPriority = 1; |
|
2142 RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[3], 1, &depResArray[0]); |
|
2143 |
|
2144 depResArray[0].iResourceId = dynamicDepResId[0]; |
|
2145 depResArray[0].iDependencyPriority = 1; |
|
2146 depResArray[1].iResourceId = dynamicDepResId[3]; |
|
2147 depResArray[1].iDependencyPriority = 2; |
|
2148 RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[2], 2, &depResArray[0]); |
|
2149 |
|
2150 RmTest.RegisterClient(); /* Client5 registration */ |
|
2151 //Change H to 85 |
|
2152 r = lddChan.ChangeResourceStateSync(Clients[2].iClientId, dynamicDepResId[0], 85); |
|
2153 test(r == KErrNone); |
|
2154 |
|
2155 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[0], -50, Clients[1].iClientId, EFalse); |
|
2156 GetExtendedResStateAndVerify(iStaticDependencyResources[1], -11, iStaticDependencyResources[0]); |
|
2157 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, iStaticDependencyResources[0], EFalse); |
|
2158 GetExtendedResStateAndVerify(iStaticDependencyResources[3], 13, iStaticDependencyResources[0]); |
|
2159 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3], EFalse); |
|
2160 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 71, dynamicDepResId[0]); |
|
2161 GetExtendedResStateAndVerify(dynamicDepResId[0], 85, Clients[2].iClientId); |
|
2162 GetExtendedResStateAsyncAndVerify(dynamicDepResId[1], 1, dynamicDepResId[0]); |
|
2163 GetExtendedResStateAsyncAndVerify(dynamicDepResId[2], 18, dynamicDepResId[0], EFalse); |
|
2164 GetExtendedResStateAndVerify(dynamicDepResId[3], 1, dynamicDepResId[2]); |
|
2165 |
|
2166 //Check notifications |
|
2167 r = lddChan.CheckNotifications(iStaticDependencyResources[5], 1, 0); |
|
2168 test(r == KErrNone); |
|
2169 r = lddChan.CheckNotifications(dynamicDepResId[0], 1, 0); |
|
2170 test(r == KErrNone); |
|
2171 r = lddChan.CheckNotifications(dynamicDepResId[1], 1, 0); |
|
2172 test(r == KErrNone); |
|
2173 r = lddChan.CheckNotifications(dynamicDepResId[2], 1, 0); |
|
2174 test(r == KErrNone); |
|
2175 |
|
2176 //Change K to 1 |
|
2177 state= 1; |
|
2178 lddChan.ChangeResourceStateAsync(Clients[2].iClientId, dynamicDepResId[3], state, req); |
|
2179 User::WaitForRequest(req); |
|
2180 test(req.Int() == KErrNone); |
|
2181 |
|
2182 GetExtendedResStateAsyncAndVerify(dynamicDepResId[2], 18, dynamicDepResId[0], EFalse); |
|
2183 GetExtendedResStateAsyncAndVerify(dynamicDepResId[3], 1, Clients[2].iClientId, EFalse); |
|
2184 |
|
2185 //Check notifications |
|
2186 r = lddChan.CheckNotifications(dynamicDepResId[2], 0, 0); |
|
2187 test(r == KErrNone); |
|
2188 r = lddChan.CheckNotifications(dynamicDepResId[3], 0, 0); |
|
2189 test(r == KErrNone); |
|
2190 |
|
2191 //Change J to 12 |
|
2192 r = lddChan.ChangeResourceStateSync(Clients[2].iClientId, dynamicDepResId[2],12); |
|
2193 test(r == KErrNone); |
|
2194 |
|
2195 GetExtendedResStateAsyncAndVerify(dynamicDepResId[2], 12, Clients[2].iClientId, EFalse); |
|
2196 |
|
2197 //Check notifications |
|
2198 r = lddChan.CheckNotifications(dynamicDepResId[0], 0, 0); |
|
2199 test(r == KErrNone); |
|
2200 r = lddChan.CheckNotifications(dynamicDepResId[2], 1, 0); |
|
2201 test(r == KErrNone); |
|
2202 r = lddChan.CheckNotifications(dynamicDepResId[3], 0, 0); |
|
2203 test(r == KErrNone); |
|
2204 |
|
2205 //Change H to 90 |
|
2206 TRequestStatus reqSet; |
|
2207 state = 90; |
|
2208 lddChan.CheckParallelExecutionForChangeResState(Clients[2].iClientId, |
|
2209 dynamicDepResId[0],state, |
|
2210 5, 0, reqSet); |
|
2211 User::WaitForRequest(reqSet); |
|
2212 test(reqSet.Int() == KErrNone); |
|
2213 |
|
2214 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[0], -50, Clients[1].iClientId, EFalse); |
|
2215 GetExtendedResStateAndVerify(iStaticDependencyResources[1], -11, iStaticDependencyResources[0]); |
|
2216 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, iStaticDependencyResources[0], EFalse); |
|
2217 GetExtendedResStateAndVerify(iStaticDependencyResources[3], 13, iStaticDependencyResources[0]); |
|
2218 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3], EFalse); |
|
2219 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 69, dynamicDepResId[0]); |
|
2220 GetExtendedResStateAndVerify(dynamicDepResId[0], 90, Clients[2].iClientId); |
|
2221 GetExtendedResStateAsyncAndVerify(dynamicDepResId[1], 1, dynamicDepResId[0]); |
|
2222 GetExtendedResStateAsyncAndVerify(dynamicDepResId[2], 11, dynamicDepResId[0], EFalse); |
|
2223 GetExtendedResStateAndVerify(dynamicDepResId[3], 1, Clients[2].iClientId); |
|
2224 |
|
2225 //Check notifications |
|
2226 r = lddChan.CheckNotifications(iStaticDependencyResources[5], 1, 0); |
|
2227 test(r == KErrNone); |
|
2228 r = lddChan.CheckNotifications(dynamicDepResId[0], 1, 0); |
|
2229 test(r == KErrNone); |
|
2230 r = lddChan.CheckNotifications(dynamicDepResId[1], 0, 0); |
|
2231 test(r == KErrNone); |
|
2232 r = lddChan.CheckNotifications(dynamicDepResId[2], 1, 0); |
|
2233 test(r == KErrNone); |
|
2234 r = lddChan.CheckNotifications(dynamicDepResId[3], 0, 0); |
|
2235 test(r == KErrNone); |
|
2236 |
|
2237 state = 9; |
|
2238 lddChan.ChangeResourceStateAsync(Clients[1].iClientId, dynamicDepResId[2], state, req); |
|
2239 User::WaitForRequest(req); |
|
2240 test(req.Int() == KErrNone); |
|
2241 |
|
2242 GetExtendedResStateAndVerify(dynamicDepResId[0], 90, Clients[2].iClientId); |
|
2243 GetExtendedResStateAsyncAndVerify(dynamicDepResId[1], 1, dynamicDepResId[0]); |
|
2244 GetExtendedResStateAsyncAndVerify(dynamicDepResId[2], 9, Clients[1].iClientId, EFalse); |
|
2245 GetExtendedResStateAndVerify(dynamicDepResId[3], 1, Clients[2].iClientId); |
|
2246 |
|
2247 //Check notifications |
|
2248 r = lddChan.CheckNotifications(dynamicDepResId[0], 0, 0); |
|
2249 test(r == KErrNone); |
|
2250 r = lddChan.CheckNotifications(dynamicDepResId[1], 0, 0); |
|
2251 test(r == KErrNone); |
|
2252 r = lddChan.CheckNotifications(dynamicDepResId[2], 1, 0); |
|
2253 test(r == KErrNone); |
|
2254 r = lddChan.CheckNotifications(dynamicDepResId[3], 0, 0); |
|
2255 test(r == KErrNone); |
|
2256 |
|
2257 //Change D to 50 |
|
2258 state = 50; |
|
2259 lddChan.ChangeResourceStateAsync(Clients[1].iClientId, iStaticDependencyResources[0], state, req); |
|
2260 User::WaitForRequest(req); |
|
2261 test(req.Int() == KErrNone); |
|
2262 |
|
2263 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[0], 50, Clients[1].iClientId, EFalse); |
|
2264 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -12, iStaticDependencyResources[0], EFalse); |
|
2265 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, iStaticDependencyResources[0], EFalse); |
|
2266 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[3], 16, iStaticDependencyResources[0], EFalse); |
|
2267 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3], EFalse); |
|
2268 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[5], 67, iStaticDependencyResources[3], EFalse); |
|
2269 GetExtendedResStateAndVerify(dynamicDepResId[0], 90, Clients[2].iClientId); |
|
2270 GetExtendedResStateAsyncAndVerify(dynamicDepResId[1], 1, dynamicDepResId[0]); |
|
2271 GetExtendedResStateAsyncAndVerify(dynamicDepResId[2], 9, Clients[1].iClientId, EFalse); |
|
2272 GetExtendedResStateAndVerify(dynamicDepResId[3], 1, Clients[2].iClientId); |
|
2273 |
|
2274 //Check notifications |
|
2275 r = lddChan.CheckNotifications(iStaticDependencyResources[5], 1, 0); |
|
2276 test(r == KErrNone); |
|
2277 //DeRegister dependency between J and K |
|
2278 r = lddChan.DeRegisterResourceDependency(Clients[0].iClientId, dynamicDepResId[3], dynamicDepResId[2]); |
|
2279 test(r == KErrNone); |
|
2280 |
|
2281 RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[3], 0, &depResArray[0]); |
|
2282 |
|
2283 depResArray[0].iResourceId = dynamicDepResId[0]; |
|
2284 depResArray[0].iDependencyPriority = 1; |
|
2285 RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[2], 1, &depResArray[0]); |
|
2286 |
|
2287 //Change J t0 13 |
|
2288 r = lddChan.ChangeResourceStateSync(Clients[1].iClientId, dynamicDepResId[2], 13); |
|
2289 test(r == KErrNone); |
|
2290 |
|
2291 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[0], 50, Clients[1].iClientId, EFalse); |
|
2292 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -12, iStaticDependencyResources[0], EFalse); |
|
2293 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, iStaticDependencyResources[0], EFalse); |
|
2294 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[3], 16, iStaticDependencyResources[0], EFalse); |
|
2295 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3], EFalse); |
|
2296 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[5], 67, iStaticDependencyResources[3], EFalse); |
|
2297 GetExtendedResStateAndVerify(dynamicDepResId[0], 90, Clients[2].iClientId); |
|
2298 GetExtendedResStateAsyncAndVerify(dynamicDepResId[1], 1, dynamicDepResId[0]); |
|
2299 GetExtendedResStateAsyncAndVerify(dynamicDepResId[2], 12, Clients[2].iClientId, EFalse); |
|
2300 GetExtendedResStateAndVerify(dynamicDepResId[3], 1, Clients[2].iClientId); |
|
2301 //Check notifications |
|
2302 r = lddChan.CheckNotifications(dynamicDepResId[2], 1, 0); |
|
2303 test(r == KErrNone); |
|
2304 /* Remove client level from resource 7 */ |
|
2305 r = lddChan.DeRegisterClientLevelFromResource(Clients[2].iClientId, dynamicDepResId[3]); |
|
2306 test(r == KErrNone); |
|
2307 |
|
2308 GetExtendedResStateAndVerify(dynamicDepResId[3], 0, -1); |
|
2309 //Check notifications |
|
2310 r = lddChan.CheckNotifications(dynamicDepResId[3], 1, 0); |
|
2311 test(r == KErrNone); |
|
2312 |
|
2313 r = lddChan.DeRegisterDynamicResource(Clients[0].iClientId, dynamicDepResId[3], NULL); |
|
2314 test(r == KErrNone); |
|
2315 //Check notifications |
|
2316 r = lddChan.CheckNotifications(dynamicDepResId[3], 1, 0); |
|
2317 test(r == KErrNone); |
|
2318 |
|
2319 //Deregister dependency between H and J |
|
2320 r = lddChan.DeRegisterResourceDependency(Clients[0].iClientId, dynamicDepResId[2], dynamicDepResId[0]); |
|
2321 test(r == KErrNone); |
|
2322 |
|
2323 RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[2], 0, &depResArray[0]); |
|
2324 |
|
2325 depResArray[0].iResourceId = dynamicDepResId[1]; |
|
2326 depResArray[0].iDependencyPriority = 1; |
|
2327 depResArray[1].iResourceId = iStaticDependencyResources[5]; |
|
2328 depResArray[1].iDependencyPriority = 3; |
|
2329 RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[0], 2, &depResArray[0]); |
|
2330 |
|
2331 /* Remove client level from resource 7 */ |
|
2332 r = lddChan.DeRegisterClientLevelFromResource(Clients[1].iClientId, dynamicDepResId[2]); |
|
2333 test(r == KErrNone); |
|
2334 |
|
2335 GetExtendedResStateAndVerify(dynamicDepResId[2], 12, Clients[2].iClientId); |
|
2336 //Check notifications |
|
2337 r = lddChan.CheckNotifications(dynamicDepResId[2], 0, 0); |
|
2338 test(r == KErrNone); |
|
2339 |
|
2340 r = lddChan.DeRegisterClient(Clients[2].iClientId); |
|
2341 test(r == KErrNone); |
|
2342 |
|
2343 GetExtendedResStateAsyncAndVerify(dynamicDepResId[2], 19, -1, EFalse); |
|
2344 |
|
2345 //Deregister dependency between G and H |
|
2346 r = lddChan.DeRegisterResourceDependency(Clients[1].iClientId, iStaticDependencyResources[5], dynamicDepResId[0]); |
|
2347 test(r == KErrNone); |
|
2348 |
|
2349 depResArray[0].iResourceId = dynamicDepResId[1]; |
|
2350 depResArray[0].iDependencyPriority = 1; |
|
2351 RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[0], 1, &depResArray[0]); |
|
2352 |
|
2353 depResArray[0].iResourceId = iStaticDependencyResources[3]; |
|
2354 depResArray[0].iDependencyPriority = 1; |
|
2355 RmTest.CheckForDependencyInformation(Clients[0].iClientId, iStaticDependencyResources[5], 1, &depResArray[0]); |
|
2356 |
|
2357 GetExtendedResStateAndVerify(dynamicDepResId[0], 75, -1); |
|
2358 GetExtendedResStateAsyncAndVerify(dynamicDepResId[1], 0, dynamicDepResId[0]); |
|
2359 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[5], 67, iStaticDependencyResources[3], EFalse); |
|
2360 |
|
2361 //Deregister dependency between I and H |
|
2362 r = lddChan.DeRegisterResourceDependency(Clients[1].iClientId, dynamicDepResId[1], dynamicDepResId[0]); |
|
2363 test(r == KErrNone); |
|
2364 |
|
2365 RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[0], 0, &depResArray[0]); |
|
2366 |
|
2367 RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[1], 0, &depResArray[0]); |
|
2368 |
|
2369 GetExtendedResStateAndVerify(dynamicDepResId[0], 75, -1); |
|
2370 GetExtendedResStateAsyncAndVerify(dynamicDepResId[1], 0, -1); |
|
2371 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[5], 67, iStaticDependencyResources[3], EFalse); |
|
2372 //Check notifications |
|
2373 r = lddChan.CheckNotifications(iStaticDependencyResources[5], 0, 0); |
|
2374 test(r == KErrNone); |
|
2375 r = lddChan.CheckNotifications(dynamicDepResId[1], 1, 0); |
|
2376 test(r == KErrNone); |
|
2377 |
|
2378 r = lddChan.DeRegisterDynamicResource(Clients[0].iClientId, dynamicDepResId[2], NULL); |
|
2379 test(r == KErrNone); |
|
2380 r = lddChan.DeRegisterDynamicResource(Clients[0].iClientId, dynamicDepResId[1], NULL); |
|
2381 test(r == KErrNone); |
|
2382 //Check notifications |
|
2383 r = lddChan.CheckNotifications(dynamicDepResId[1], 1, 0); |
|
2384 test(r == KErrNone); |
|
2385 r = lddChan.DeRegisterDynamicResource(Clients[0].iClientId, dynamicDepResId[0], NULL); |
|
2386 test(r == KErrNone); |
|
2387 r = lddChan.DeRegisterClient(Clients[1].iClientId); |
|
2388 test(r == KErrNone); |
|
2389 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[0], -100, -1, EFalse); |
|
2390 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -10, iStaticDependencyResources[0], EFalse); |
|
2391 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 0, iStaticDependencyResources[0], EFalse); |
|
2392 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[3], 10, iStaticDependencyResources[0], EFalse); |
|
2393 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 1, iStaticDependencyResources[3], EFalse); |
|
2394 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[5], 75, iStaticDependencyResources[3], EFalse); |
|
2395 r = lddChan.DeRegisterClient(Clients[3].iClientId); |
|
2396 test(r == KErrNone); |
|
2397 |
|
2398 r = lddChan.DeRegisterClient(Clients[0].iClientId); |
|
2399 test(r == KErrNone); |
|
2400 |
|
2401 r = lddChan.DeRegisterClient(Clients[4].iClientId); |
|
2402 test(r == KErrNone); |
|
2403 |
|
2404 depResArray.Close(); |
|
2405 return; |
|
2406 } |
|
2407 |
|
2408 //---------------------------------------------------------------------------------------------- |
|
2409 //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0596 |
|
2410 //! @SYMTestType UT |
|
2411 //! @SYMPREQ PREQ1398 |
|
2412 //! @SYMTestCaseDesc This test case tests dynamic resources which does not support dependency |
|
2413 //! @SYMTestActions 0 Register clients |
|
2414 //! 1 Register dynamic resource |
|
2415 //! 2 Register notifications |
|
2416 //! 3 Change Resource State of each static resource with dependency |
|
2417 //! 4 Get state of the resource and check for correctness |
|
2418 //! 5 Check notification count for correctness |
|
2419 //! 6 Deregister client level |
|
2420 //! 7 Deregister dynamic resource |
|
2421 //! 8 Deregister clients |
|
2422 //! |
|
2423 //! @SYMTestExpectedResults 0 API should return with KErrNone, panics otherwise. |
|
2424 //! 1 API should return with KErrNone, panics otherwise. |
|
2425 //! 2 API should return with KErrNone, panics otherwise. |
|
2426 //! 3 API should return with KErrNone, panics otherwise. |
|
2427 //! 4 API should return with KErrNone, panics otherwise. |
|
2428 //! 5 API should return with KErrNone, panics otherwise. |
|
2429 //! 6 API should return with KErrNone, panics otherwise. |
|
2430 //! 7 API should return with KErrNone, panics otherwise. |
|
2431 //! 8 API should return with KErrNone, panics otherwise. |
|
2432 //! @SYMTestPriority High |
|
2433 //! @SYMTestStatus Implemented |
|
2434 //---------------------------------------------------------------------------------------------- |
|
2435 void TestRM::TestDynamicResource() |
|
2436 { |
|
2437 TInt state; |
|
2438 TRequestStatus req; |
|
2439 TUint dynamicResId[4]; |
|
2440 |
|
2441 test.Next(_L("Testing dynamic resource")); |
|
2442 //Register client 1 |
|
2443 RmTest.RegisterClient(); |
|
2444 //Register client 2 |
|
2445 RmTest.RegisterClient(); |
|
2446 //Register client 3 |
|
2447 RmTest.RegisterClient(); |
|
2448 |
|
2449 NegativeTesting = EFalse; |
|
2450 dynamicResId[0] = 1; |
|
2451 //Register dynamic resource 1 |
|
2452 r = lddChan.RegisterDynamicResource(Clients[0].iClientId, dynamicResId[0]); |
|
2453 test(r == KErrNone); |
|
2454 //Deregister dynamic resource with different client id |
|
2455 r = lddChan.DeRegisterDynamicResource(Clients[1].iClientId, dynamicResId[0], NULL); |
|
2456 test(r == KErrAccessDenied); |
|
2457 dynamicResId[1] = 2; |
|
2458 //Register dynamic resource 2 |
|
2459 r = lddChan.RegisterDynamicResource(Clients[1].iClientId, dynamicResId[1]); |
|
2460 test(r == KErrNone); |
|
2461 RmTest.GetNumResourcesInUseByClient(iCurrentClientId); |
|
2462 RmTest.GetInfoOnResourcesInUseByClient(iCurrentClientId, iMaxStaticResources); |
|
2463 |
|
2464 TUint numClients; |
|
2465 r = lddChan.GetNumClientsUsingResource(Clients[0].iClientId, dynamicResId[0], numClients); |
|
2466 test(r == KErrNone); |
|
2467 test(numClients == 0); |
|
2468 |
|
2469 r = lddChan.RequestNotification(Clients[1].iClientId, dynamicResId[0]); |
|
2470 test(r == KErrNone); |
|
2471 //Register client 4 |
|
2472 RmTest.RegisterClient(); |
|
2473 r = lddChan.RequestNotification(Clients[2].iClientId, dynamicResId[0], 1, 1); |
|
2474 test(r == KErrNone); |
|
2475 //Change state of dynamic resource 1 and verify |
|
2476 state = 1; |
|
2477 lddChan.ChangeResourceStateAsync(Clients[0].iClientId, dynamicResId[0], state, req); |
|
2478 User::WaitForRequest(req); |
|
2479 test(req.Int() == KErrNone); |
|
2480 |
|
2481 r = lddChan.CheckNotifications(dynamicResId[0], 1, 1); |
|
2482 test(r == KErrNone); |
|
2483 |
|
2484 GetExtendedResStateAsyncAndVerify(dynamicResId[0], 1, Clients[0].iClientId, EFalse); |
|
2485 |
|
2486 r = lddChan.GetNumClientsUsingResource(Clients[0].iClientId, dynamicResId[0], numClients); |
|
2487 test(r == KErrNone); |
|
2488 test(numClients == 1); |
|
2489 //Change state of dynamic resource 1. |
|
2490 r = lddChan.ChangeResourceStateSync(Clients[1].iClientId, dynamicResId[0], 0); |
|
2491 test(r == KErrAccessDenied); |
|
2492 //Deregister dynamic resource 1 and set the resource to 1. |
|
2493 state = 1; |
|
2494 r = lddChan.DeRegisterDynamicResource(Clients[0].iClientId, dynamicResId[0], &state); |
|
2495 test(r == KErrNone); |
|
2496 |
|
2497 r = lddChan.CheckNotifications(dynamicResId[0], 1, 1); |
|
2498 test(r == KErrNone); |
|
2499 |
|
2500 r = lddChan.GetNumClientsUsingResource(Clients[0].iClientId, dynamicResId[0], numClients); |
|
2501 test(r == KErrNotFound); |
|
2502 //Register client 5 |
|
2503 RmTest.RegisterClient(); |
|
2504 |
|
2505 GetExtendedResStateAndVerify(dynamicResId[1], -5, -1); |
|
2506 |
|
2507 r = lddChan.RequestNotification(Clients[1].iClientId, dynamicResId[1]); |
|
2508 test(r == KErrNone); |
|
2509 |
|
2510 r = lddChan.RequestNotification(Clients[2].iClientId, dynamicResId[1], 0, -8); |
|
2511 test(r == KErrNone); |
|
2512 //Change state of dynamic resource 1 and verify |
|
2513 state = -7; |
|
2514 lddChan.ChangeResourceStateAsync(Clients[2].iClientId, dynamicResId[1], state, req); |
|
2515 User::WaitForRequest(req); |
|
2516 test(req.Int() == KErrNone); |
|
2517 |
|
2518 r = lddChan.CheckNotifications(dynamicResId[1], 1, 0); |
|
2519 test(r == KErrNone); |
|
2520 |
|
2521 GetExtendedResStateAndVerify(dynamicResId[1], -7, Clients[2].iClientId); |
|
2522 //Register client 6 |
|
2523 RmTest.RegisterClient(); |
|
2524 //Register client 7 |
|
2525 RmTest.RegisterClient(); |
|
2526 //Change state of dynamic resource 2 and verify |
|
2527 state = -9; |
|
2528 lddChan.ChangeResourceStateAsync(Clients[3].iClientId, dynamicResId[1], state, req); |
|
2529 User::WaitForRequest(req); |
|
2530 test(req.Int() == KErrNone); |
|
2531 |
|
2532 r = lddChan.CheckNotifications(dynamicResId[1], 1, 1); |
|
2533 test(r == KErrNone); |
|
2534 |
|
2535 GetExtendedResStateAsyncAndVerify(dynamicResId[1], -9, Clients[3].iClientId, EFalse); |
|
2536 //Change state of dynamic resource 1 and verify |
|
2537 state = -10; |
|
2538 lddChan.ChangeResourceStateAsync(Clients[4].iClientId, dynamicResId[1], state, req); |
|
2539 User::WaitForRequest(req); |
|
2540 test(req.Int() == KErrNone); |
|
2541 |
|
2542 r = lddChan.CheckNotifications(dynamicResId[1], 1, 0); |
|
2543 test(r == KErrNone); |
|
2544 |
|
2545 GetExtendedResStateAsyncAndVerify(dynamicResId[1], -10, Clients[4].iClientId, EFalse); |
|
2546 |
|
2547 lddChan.ChangeResourceStateSync(Clients[5].iClientId, dynamicResId[1], state); |
|
2548 test(r == KErrNone); |
|
2549 |
|
2550 r = lddChan.CheckNotifications(dynamicResId[1], 0, 0); |
|
2551 test(r == KErrNone); |
|
2552 |
|
2553 GetExtendedResStateAsyncAndVerify(dynamicResId[1], -10, Clients[4].iClientId, EFalse); |
|
2554 //Change state of dynamic resource 1 and verify |
|
2555 state = -6; |
|
2556 lddChan.ChangeResourceStateSync(Clients[6].iClientId, dynamicResId[1], state); |
|
2557 test(r == KErrNone); |
|
2558 |
|
2559 r = lddChan.CheckNotifications(dynamicResId[1], 0, 0); |
|
2560 test(r == KErrNone); |
|
2561 |
|
2562 GetExtendedResStateAsyncAndVerify(dynamicResId[1], -10, Clients[4].iClientId, EFalse); |
|
2563 |
|
2564 r = lddChan.DeRegisterClientLevelFromResource(Clients[4].iClientId, dynamicResId[1]); |
|
2565 test(r == KErrNone); |
|
2566 |
|
2567 GetExtendedResStateAsyncAndVerify(dynamicResId[1], -10, Clients[5].iClientId, EFalse); |
|
2568 |
|
2569 r = lddChan.DeRegisterClientLevelFromResource(Clients[5].iClientId, dynamicResId[1]); |
|
2570 test(r == KErrNone); |
|
2571 |
|
2572 r = lddChan.CheckNotifications(dynamicResId[1], 1, 0); |
|
2573 test(r == KErrNone); |
|
2574 GetExtendedResStateAsyncAndVerify(dynamicResId[1], -9, Clients[3].iClientId, EFalse); |
|
2575 //Deregister client 4 |
|
2576 r = lddChan.DeRegisterClient(Clients[3].iClientId); |
|
2577 test(r == KErrNone); |
|
2578 |
|
2579 r = lddChan.CheckNotifications(dynamicResId[1], 1, 0); |
|
2580 test(r == KErrNone); |
|
2581 GetExtendedResStateAsyncAndVerify(dynamicResId[1], -7, Clients[2].iClientId, EFalse); |
|
2582 |
|
2583 r = lddChan.DeRegisterClientLevelFromResource(Clients[2].iClientId, dynamicResId[1]); |
|
2584 test(r == KErrNone); |
|
2585 |
|
2586 r = lddChan.CheckNotifications(dynamicResId[1], 1, 0); |
|
2587 test(r == KErrNone); |
|
2588 GetExtendedResStateAsyncAndVerify(dynamicResId[1], -6, Clients[6].iClientId, EFalse); |
|
2589 |
|
2590 r = lddChan.DeRegisterClientLevelFromResource(Clients[6].iClientId, dynamicResId[1]); |
|
2591 test(r == KErrNone); |
|
2592 |
|
2593 r = lddChan.CheckNotifications(dynamicResId[1], 1, 0); |
|
2594 test(r == KErrNone); |
|
2595 GetExtendedResStateAsyncAndVerify(dynamicResId[1], -5, -1, EFalse); |
|
2596 //Deregister dynamic resource 2 |
|
2597 r = lddChan.DeRegisterDynamicResource(Clients[1].iClientId, dynamicResId[1], NULL); |
|
2598 test(r == KErrNone); |
|
2599 |
|
2600 r = lddChan.CheckNotifications(dynamicResId[1], 1, 1); |
|
2601 test(r == KErrNone); |
|
2602 //Register dynamic resource 3 |
|
2603 dynamicResId[2] = 3; |
|
2604 r = lddChan.RegisterDynamicResource(Clients[2].iClientId, dynamicResId[2]); |
|
2605 test(r == KErrNone); |
|
2606 //Register dynamic resource 4 |
|
2607 dynamicResId[3] = 4; |
|
2608 r = lddChan.RegisterDynamicResource(Clients[6].iClientId, dynamicResId[3]); |
|
2609 test(r == KErrNone); |
|
2610 //Change state of dynamic resource 3 to 0 |
|
2611 r = lddChan.ChangeResourceStateSync(Clients[4].iClientId, dynamicResId[2], 0); |
|
2612 test(r == KErrNone); |
|
2613 GetExtendedResStateAndVerify(dynamicResId[2], 0, Clients[4].iClientId); |
|
2614 //Change state of dynamic resource 3 to 1 |
|
2615 r = lddChan.ChangeResourceStateSync(Clients[5].iClientId, dynamicResId[2], 1); |
|
2616 test(r == KErrNone); |
|
2617 GetExtendedResStateAndVerify(dynamicResId[2], 0, Clients[4].iClientId); |
|
2618 //Deregister client 5 |
|
2619 r = lddChan.DeRegisterClient(Clients[4].iClientId); |
|
2620 test(r == KErrNone); |
|
2621 GetExtendedResStateAndVerify(dynamicResId[2], 1, Clients[5].iClientId); |
|
2622 //Deregister dynamic resource 3 |
|
2623 r = lddChan.DeRegisterDynamicResource(Clients[2].iClientId, dynamicResId[2], NULL); |
|
2624 test(r == KErrInUse); |
|
2625 //Deregister client 6 |
|
2626 r = lddChan.DeRegisterClient(Clients[5].iClientId); |
|
2627 test(r == KErrNone); |
|
2628 GetExtendedResStateAndVerify(dynamicResId[2], 1, -1); |
|
2629 //Deregister dynamic resource 3 |
|
2630 r = lddChan.DeRegisterDynamicResource(Clients[2].iClientId, dynamicResId[2], NULL); |
|
2631 test(r == KErrNone); |
|
2632 //Change state of dynamic resource 4 to 15 |
|
2633 r = lddChan.ChangeResourceStateSync(Clients[6].iClientId, dynamicResId[3], 15); |
|
2634 test(r == KErrNone); |
|
2635 GetExtendedResStateAndVerify(dynamicResId[3], 15, Clients[6].iClientId); |
|
2636 //Change state of resource and try to deregister the resource while the change is taking place |
|
2637 state = 17; |
|
2638 lddChan.ChangeResStateAndDeRegisterDynamicRes(Clients[6].iClientId, dynamicResId[3], state, req); |
|
2639 User::WaitForRequest(req); |
|
2640 test(req.Int() == KErrNone); |
|
2641 test(state == 17); |
|
2642 GetExtendedResStateAndVerify(dynamicResId[3], 17, Clients[6].iClientId); |
|
2643 //Deregister dynamic resource 4 with some other client which is not owner |
|
2644 r = lddChan.DeRegisterDynamicResource(Clients[2].iClientId, dynamicResId[3], NULL); |
|
2645 test(r == KErrAccessDenied); |
|
2646 //Deregister dynamic resource 4 |
|
2647 r = lddChan.DeRegisterDynamicResource(Clients[6].iClientId, dynamicResId[3], NULL); |
|
2648 test(r == KErrNone); |
|
2649 //Deregister client 7 |
|
2650 r = lddChan.DeRegisterClient(Clients[6].iClientId); |
|
2651 test(r == KErrNone); |
|
2652 //Deregister client 3 |
|
2653 r = lddChan.DeRegisterClient(Clients[2].iClientId); |
|
2654 test(r == KErrNone); |
|
2655 //Deregister client 2 |
|
2656 r = lddChan.DeRegisterClient(Clients[1].iClientId); |
|
2657 test(r == KErrNone); |
|
2658 //Deregister client 1 |
|
2659 r = lddChan.DeRegisterClient(Clients[0].iClientId); |
|
2660 test(r == KErrNone); |
|
2661 Clients.Close(); |
|
2662 } |
|
2663 |
|
2664 //This function gets extended resource state synchronously and verifies for correctness |
|
2665 void TestRM::GetExtendedResStateAndVerify(TUint aResId, TInt aState, TInt aLevelOwnerId) |
|
2666 { |
|
2667 static TBool cached = ETrue; |
|
2668 TInt state; |
|
2669 TInt levelOwnerId; |
|
2670 r = lddChan.GetResourceStateSync(Clients[0].iClientId, aResId, cached, state, levelOwnerId); |
|
2671 test(r == KErrNone); |
|
2672 test(state == aState); |
|
2673 test(levelOwnerId == aLevelOwnerId); |
|
2674 return; |
|
2675 } |
|
2676 |
|
2677 //This function gets extended resource state asynchronously and verifies for correctness |
|
2678 void TestRM::GetExtendedResStateAsyncAndVerify(TUint aResId, TInt aState, TInt aLevelOwnerId, TBool aReqCancel) |
|
2679 { |
|
2680 static TBool cached = ETrue; |
|
2681 TRequestStatus resGet; |
|
2682 TInt levelOwnerId; |
|
2683 TInt state; |
|
2684 lddChan.GetResourceStateAsync(Clients[0].iClientId, aResId, cached, resGet, state, levelOwnerId, aReqCancel); |
|
2685 User::WaitForRequest(resGet); |
|
2686 if(aReqCancel && (resGet.Int() != KErrNone)) |
|
2687 { |
|
2688 test((resGet.Int() == KErrCompletion) || (resGet.Int() == KErrCancel)); |
|
2689 return; |
|
2690 } |
|
2691 test(resGet.Int() == KErrNone); |
|
2692 test(state == aState); |
|
2693 test(levelOwnerId == aLevelOwnerId); |
|
2694 } |
|
2695 |
|
2696 //This function validates number of dependency resource and their id's for correctness |
|
2697 void TestRM::CheckForDependencyInformation(TUint aClientId, TUint aResourceId, TUint aNumDependents, SResourceDependencyInfo* aDepResIdArray) |
|
2698 { |
|
2699 TUint numDepResources; |
|
2700 |
|
2701 //Get the number of dependent's for the resource |
|
2702 r = lddChan.GetNumDependentsForResource(aClientId, aResourceId, numDepResources); |
|
2703 if(r != KErrNone) |
|
2704 test.Printf(_L("GetNumDependentsForResource returned with %d\n"), r); |
|
2705 test(r == KErrNone); |
|
2706 if(aNumDependents != numDepResources) |
|
2707 test.Printf(_L("aNumDependents = %d, numDepResource = %d\n"), aNumDependents, numDepResources); |
|
2708 test(aNumDependents == numDepResources); |
|
2709 if(numDepResources == 0) |
|
2710 return; |
|
2711 //Get the dependent's id |
|
2712 RBuf8 info; |
|
2713 info.Create(aNumDependents * sizeof(SResourceDependencyInfo)); |
|
2714 r = lddChan.GetDependentsIdForResource(aClientId, aResourceId, (TAny*)&info, numDepResources); |
|
2715 if(r != KErrNone) |
|
2716 { |
|
2717 test.Printf(_L("GetDependentsIdForResource returned with %d\n"), r); |
|
2718 info.Close(); |
|
2719 } |
|
2720 test(r == KErrNone); |
|
2721 if(aNumDependents != numDepResources) |
|
2722 { |
|
2723 test.Printf(_L("aNumDependents = %d, numDepResource = %d\n"), aNumDependents, numDepResources); |
|
2724 info.Close(); |
|
2725 } |
|
2726 test(aNumDependents == numDepResources); |
|
2727 SResourceDependencyInfo* sResDepInfoPtr = (SResourceDependencyInfo*)info.Ptr(); |
|
2728 for(TUint count = 0; count < aNumDependents; count++, sResDepInfoPtr++) |
|
2729 { |
|
2730 if(sResDepInfoPtr->iResourceId != aDepResIdArray[count].iResourceId) |
|
2731 { |
|
2732 test.Printf(_L("Expected resourceId : %d, Returned ResourceId = %d\n"),sResDepInfoPtr->iResourceId, |
|
2733 aDepResIdArray[count].iResourceId); |
|
2734 info.Close(); |
|
2735 test(0); |
|
2736 } |
|
2737 if(sResDepInfoPtr->iDependencyPriority != aDepResIdArray[count].iDependencyPriority) |
|
2738 { |
|
2739 test.Printf(_L("Expected resource priority : %d, Returned resource priority = %d\n"),sResDepInfoPtr->iDependencyPriority, |
|
2740 aDepResIdArray[count].iDependencyPriority); |
|
2741 info.Close(); |
|
2742 test(0); |
|
2743 } |
|
2744 } |
|
2745 info.Close(); |
|
2746 return; |
|
2747 } |
|
2748 |
|
2749 //---------------------------------------------------------------------------------------------- |
|
2750 //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0595 |
|
2751 //! @SYMTestType UT |
|
2752 //! @SYMPREQ PREQ1398 |
|
2753 //! @SYMTestCaseDesc This test case tests static resources with dependency. |
|
2754 //! @SYMTestActions 0 Register clients |
|
2755 //! 1 Check dependency information of each resource |
|
2756 //! 2 Register notifications |
|
2757 //! 3 Change Resource State of each static resource with dependency |
|
2758 //! 4 Get state of the resources and verify them for correctness |
|
2759 //! 5 Check notification count for correctness |
|
2760 //! 6 Deregister client level |
|
2761 //! 7 Deregister clients |
|
2762 //! |
|
2763 //! @SYMTestExpectedResults 0 API should return with KErrNone, panics otherwise. |
|
2764 //! 1 API should return with KErrNone, panics otherwise. |
|
2765 //! 2 API should return with KErrNone, panics otherwise. |
|
2766 //! 3 API should return with KErrNone, panics otherwise. |
|
2767 //! 4 API should return with KErrNone, panics otherwise. |
|
2768 //! 5 API should return with KErrNone, panics otherwise. |
|
2769 //! 6 API should return with KErrNone, panics otherwise. |
|
2770 //! 7 API should return with KErrNone, panics otherwise. |
|
2771 //! @SYMTestPriority High |
|
2772 //! @SYMTestStatus Implemented |
|
2773 //---------------------------------------------------------------------------------------------- |
|
2774 void TestRM::TestStaticResourceWithDependency() |
|
2775 { |
|
2776 TUint count; |
|
2777 RArray<SResourceDependencyInfo>depResArray; |
|
2778 SResourceDependencyInfo sResDepInfo; |
|
2779 TUint numClients; // The maximum no. of dependents in the dependency tree. |
|
2780 |
|
2781 |
|
2782 //Register client 1. |
|
2783 RmTest.RegisterClient(); |
|
2784 iCurrentClientId = -1; |
|
2785 TInt state; |
|
2786 TRequestStatus reqSet; |
|
2787 |
|
2788 NegativeTesting = EFalse; |
|
2789 test.Next(_L("\nTesting static resource with dependency....")); |
|
2790 |
|
2791 //Check for resource dependency information of Resource D |
|
2792 sResDepInfo.iResourceId = iStaticDependencyResources[1]; |
|
2793 sResDepInfo.iDependencyPriority = 1; |
|
2794 depResArray.Append(sResDepInfo); |
|
2795 sResDepInfo.iResourceId = iStaticDependencyResources[3]; |
|
2796 sResDepInfo.iDependencyPriority = 2; |
|
2797 depResArray.Append(sResDepInfo); |
|
2798 sResDepInfo.iResourceId = iStaticDependencyResources[2]; |
|
2799 sResDepInfo.iDependencyPriority = 3; |
|
2800 depResArray.Append(sResDepInfo); |
|
2801 RmTest.CheckForDependencyInformation(Clients[0].iClientId, iStaticDependencyResources[0], 3, &depResArray[0]); |
|
2802 |
|
2803 //Check for resource dependency information of Resource E |
|
2804 depResArray[0].iResourceId = iStaticDependencyResources[4]; |
|
2805 depResArray[0].iDependencyPriority = 1; |
|
2806 depResArray[1].iResourceId = iStaticDependencyResources[5]; |
|
2807 depResArray[1].iDependencyPriority = 2; |
|
2808 depResArray[2].iResourceId = iStaticDependencyResources[0]; |
|
2809 depResArray[2].iDependencyPriority = 3; |
|
2810 RmTest.CheckForDependencyInformation(Clients[0].iClientId, iStaticDependencyResources[3], 3, &depResArray[0]); |
|
2811 |
|
2812 //Check for resource dependency information of Resource C |
|
2813 depResArray[0].iResourceId = iStaticDependencyResources[3]; |
|
2814 depResArray[0].iDependencyPriority = 1; |
|
2815 RmTest.CheckForDependencyInformation(Clients[0].iClientId, iStaticDependencyResources[4], 1, &depResArray[0]); |
|
2816 |
|
2817 //Check for resource dependency information of Resource G |
|
2818 RmTest.CheckForDependencyInformation(Clients[0].iClientId, iStaticDependencyResources[5], 1, &depResArray[0]); |
|
2819 |
|
2820 //Check for resource dependency information of Resource F |
|
2821 depResArray[0].iResourceId = iStaticDependencyResources[0]; |
|
2822 depResArray[0].iDependencyPriority = 1; |
|
2823 RmTest.CheckForDependencyInformation(Clients[0].iClientId, iStaticDependencyResources[2], 1, &depResArray[0]); |
|
2824 |
|
2825 //Check for resource dependency information of Resource A |
|
2826 RmTest.CheckForDependencyInformation(Clients[0].iClientId, iStaticDependencyResources[1], 1, &depResArray[0]); |
|
2827 |
|
2828 RmTest.GetNumResourcesInUseByClient(iCurrentClientId); |
|
2829 RmTest.GetInfoOnResourcesInUseByClient(iCurrentClientId, iMaxStaticResources + iMaxStaticDependentResources); |
|
2830 iCurrentClientId = 0; |
|
2831 //Get resource state of all dependent resource and verify |
|
2832 GetExtendedResStateAndVerify(iStaticDependencyResources[0], -50, -1); |
|
2833 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -11, iStaticDependencyResources[0]); |
|
2834 GetExtendedResStateAndVerify(iStaticDependencyResources[2], 1, iStaticDependencyResources[0]); |
|
2835 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[3], 13, iStaticDependencyResources[0]); |
|
2836 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); |
|
2837 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 73, iStaticDependencyResources[3]); |
|
2838 |
|
2839 r = lddChan.GetNumClientsUsingResource(Clients[0].iClientId, iStaticDependencyResources[3], numClients); |
|
2840 test(r == KErrNone); |
|
2841 test(numClients == 0); |
|
2842 //Request notification |
|
2843 for(count = 0; count < iMaxStaticDependentResources; count++) |
|
2844 { |
|
2845 r = lddChan.RequestNotification(Clients[0].iClientId, iStaticDependencyResources[count]); |
|
2846 test(r == KErrNone); |
|
2847 } |
|
2848 //Change state of resource A to -11 and verify |
|
2849 r = lddChan.ChangeResourceStateSync(Clients[0].iClientId, iStaticDependencyResources[1], -11); |
|
2850 test(r == KErrNone); |
|
2851 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -11, Clients[0].iClientId); |
|
2852 //Change state of resource A to -12 and verify |
|
2853 state = -12; |
|
2854 lddChan.ChangeResourceStateAsync(Clients[0].iClientId, iStaticDependencyResources[1], state, reqSet); |
|
2855 User::WaitForRequest(reqSet); |
|
2856 test(reqSet.Int() == KErrNone); |
|
2857 r = lddChan.CheckNotifications(iStaticDependencyResources[1], 1, 0); |
|
2858 test(r == KErrNone); |
|
2859 //Register client2 |
|
2860 RmTest.RegisterClient(); |
|
2861 //Change state of resource D to -49 and verify |
|
2862 state = -49; |
|
2863 lddChan.ChangeResourceStateAsync(Clients[1].iClientId, iStaticDependencyResources[0], state, reqSet); |
|
2864 User::WaitForRequest(reqSet); |
|
2865 test(reqSet.Int() == KErrNone); |
|
2866 //Check for notifications |
|
2867 r = lddChan.CheckNotifications(iStaticDependencyResources[0], 1, 0); |
|
2868 test(r == KErrNone); |
|
2869 r = lddChan.CheckNotifications(iStaticDependencyResources[1], 1, 0); |
|
2870 test(r == KErrNone); |
|
2871 r = lddChan.CheckNotifications(iStaticDependencyResources[3], 1, 0); |
|
2872 test(r == KErrNone); |
|
2873 r = lddChan.CheckNotifications(iStaticDependencyResources[5], 1, 0); |
|
2874 test(r == KErrNone); |
|
2875 //Get the state and verify for correctness |
|
2876 GetExtendedResStateAndVerify(iStaticDependencyResources[0], -49, Clients[1].iClientId); |
|
2877 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -13, iStaticDependencyResources[0]); |
|
2878 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, iStaticDependencyResources[0]); |
|
2879 GetExtendedResStateAndVerify(iStaticDependencyResources[3], 16, iStaticDependencyResources[0]); |
|
2880 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); |
|
2881 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 71, iStaticDependencyResources[3]); |
|
2882 //Change state of resource F to 1 and verify |
|
2883 r = lddChan.ChangeResourceStateSync(Clients[1].iClientId, iStaticDependencyResources[2], 1); |
|
2884 test(r == KErrNone); |
|
2885 r = lddChan.CheckNotifications(iStaticDependencyResources[2], 0, 0); |
|
2886 test(r == KErrNone); |
|
2887 GetExtendedResStateAndVerify(iStaticDependencyResources[2], 1, Clients[1].iClientId); |
|
2888 //Register client 3 |
|
2889 RmTest.RegisterClient(); |
|
2890 //Change state of resource E to 19 and verify |
|
2891 r = lddChan.ChangeResourceStateSync(Clients[2].iClientId, iStaticDependencyResources[3], 19); |
|
2892 test(r == KErrNone); |
|
2893 r = lddChan.CheckNotifications(iStaticDependencyResources[3], 1, 0); |
|
2894 test(r == KErrNone); |
|
2895 r = lddChan.CheckNotifications(iStaticDependencyResources[5], 1, 0); |
|
2896 test(r == KErrNone); |
|
2897 GetExtendedResStateAndVerify(iStaticDependencyResources[0], -49, Clients[1].iClientId); |
|
2898 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -13, iStaticDependencyResources[0]); |
|
2899 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, Clients[1].iClientId); |
|
2900 GetExtendedResStateAndVerify(iStaticDependencyResources[3], 19, Clients[2].iClientId); |
|
2901 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); |
|
2902 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 69, iStaticDependencyResources[3]); |
|
2903 //Register client 4 |
|
2904 RmTest.RegisterClient(); |
|
2905 //Change state of resource C to 0 and verify |
|
2906 r = lddChan.ChangeResourceStateSync(Clients[3].iClientId, iStaticDependencyResources[4], 0); |
|
2907 test(r == KErrNone); |
|
2908 r = lddChan.CheckNotifications(iStaticDependencyResources[4], 0, 0); |
|
2909 test(r == KErrNone); |
|
2910 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); |
|
2911 //Change state of resource C to 1 and verify |
|
2912 r = lddChan.ChangeResourceStateSync(Clients[2].iClientId, iStaticDependencyResources[4], 1); |
|
2913 test(r == KErrNone); |
|
2914 r = lddChan.CheckNotifications(iStaticDependencyResources[4], 0, 0); |
|
2915 test(r == KErrNone); |
|
2916 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); |
|
2917 //Change state of resource G to 67 and verify |
|
2918 r = lddChan.ChangeResourceStateSync(Clients[2].iClientId, iStaticDependencyResources[5], 67); |
|
2919 test(r == KErrNone); |
|
2920 r = lddChan.CheckNotifications(iStaticDependencyResources[5], 1, 0); |
|
2921 test(r == KErrNone); |
|
2922 GetExtendedResStateAndVerify(iStaticDependencyResources[0], -49, Clients[1].iClientId); |
|
2923 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -13, iStaticDependencyResources[0]); |
|
2924 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, Clients[1].iClientId); |
|
2925 GetExtendedResStateAndVerify(iStaticDependencyResources[3], 19, Clients[2].iClientId); |
|
2926 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); |
|
2927 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 67, Clients[2].iClientId); |
|
2928 //Change state of resource G to 67 and verify |
|
2929 r = lddChan.ChangeResourceStateSync(Clients[3].iClientId, iStaticDependencyResources[5], 67); |
|
2930 test(r == KErrNone); |
|
2931 r = lddChan.CheckNotifications(iStaticDependencyResources[5], 0, 0); |
|
2932 test(r == KErrNone); |
|
2933 GetExtendedResStateAndVerify(iStaticDependencyResources[0], -49, Clients[1].iClientId); |
|
2934 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -13, iStaticDependencyResources[0]); |
|
2935 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, Clients[1].iClientId); |
|
2936 GetExtendedResStateAndVerify(iStaticDependencyResources[3], 19, Clients[2].iClientId); |
|
2937 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); |
|
2938 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 67, Clients[2].iClientId); |
|
2939 |
|
2940 //Change the state of the resource E to 24 |
|
2941 state = 24; |
|
2942 //Register client 5 |
|
2943 RmTest.RegisterClient(); |
|
2944 lddChan.ChangeResourceStateAsync(Clients[4].iClientId, iStaticDependencyResources[3], state, reqSet); |
|
2945 User::WaitForRequest(reqSet); |
|
2946 test(reqSet.Int() == KErrNone); |
|
2947 r = lddChan.CheckNotifications(iStaticDependencyResources[3], 1, 0); |
|
2948 test(r == KErrNone); |
|
2949 r = lddChan.CheckNotifications(iStaticDependencyResources[5], 1, 0); |
|
2950 test(r == KErrNone); |
|
2951 GetExtendedResStateAndVerify(iStaticDependencyResources[0], -49, Clients[1].iClientId); |
|
2952 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -13, iStaticDependencyResources[0]); |
|
2953 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, Clients[1].iClientId); |
|
2954 GetExtendedResStateAndVerify(iStaticDependencyResources[3], 24, Clients[4].iClientId); |
|
2955 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); |
|
2956 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 65, iStaticDependencyResources[3]); |
|
2957 |
|
2958 //Change resource state of Resource D to -51 |
|
2959 r = lddChan.ChangeResourceStateSync(Clients[2].iClientId, iStaticDependencyResources[0], -51); |
|
2960 test(r == KErrAccessDenied); |
|
2961 GetExtendedResStateAndVerify(iStaticDependencyResources[0], -49, Clients[1].iClientId); |
|
2962 |
|
2963 //DeregisterClient 5 |
|
2964 r = lddChan.DeRegisterClient(Clients[4].iClientId); |
|
2965 test(r == KErrNone); |
|
2966 |
|
2967 r = lddChan.CheckNotifications(iStaticDependencyResources[3], 1, 0); |
|
2968 test(r == KErrNone); |
|
2969 r = lddChan.CheckNotifications(iStaticDependencyResources[5], 1, 0); |
|
2970 test(r == KErrNone); |
|
2971 |
|
2972 GetExtendedResStateAndVerify(iStaticDependencyResources[3], 19, Clients[2].iClientId); |
|
2973 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 63, iStaticDependencyResources[3]); |
|
2974 |
|
2975 //Change resource state of resource D to 50 |
|
2976 state = 50; |
|
2977 lddChan.ChangeResourceStateAsync(Clients[1].iClientId, iStaticDependencyResources[0], state, reqSet); |
|
2978 User::WaitForRequest(reqSet); |
|
2979 test(reqSet.Int() == KErrNone); |
|
2980 r = lddChan.CheckNotifications(iStaticDependencyResources[0], 1, 0); |
|
2981 test(r == KErrNone); |
|
2982 r = lddChan.CheckNotifications(iStaticDependencyResources[1], 1, 0); |
|
2983 test(r == KErrNone); |
|
2984 r = lddChan.CheckNotifications(iStaticDependencyResources[3], 1, 0); |
|
2985 test(r == KErrNone); |
|
2986 r = lddChan.CheckNotifications(iStaticDependencyResources[5], 1, 0); |
|
2987 test(r == KErrNone); |
|
2988 |
|
2989 GetExtendedResStateAndVerify(iStaticDependencyResources[0], 50, Clients[1].iClientId); |
|
2990 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -14, iStaticDependencyResources[0]); |
|
2991 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, Clients[1].iClientId); |
|
2992 GetExtendedResStateAndVerify(iStaticDependencyResources[3], 22, iStaticDependencyResources[0]); |
|
2993 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); |
|
2994 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 61, iStaticDependencyResources[3]); |
|
2995 |
|
2996 //Change resource state of resource G to 61 |
|
2997 r = lddChan.ChangeResourceStateSync(Clients[3].iClientId, iStaticDependencyResources[5], 61); |
|
2998 test(r == KErrNone); |
|
2999 |
|
3000 r = lddChan.CheckNotifications(iStaticDependencyResources[5], 0, 0); |
|
3001 test(r == KErrNone); |
|
3002 |
|
3003 GetExtendedResStateAndVerify(iStaticDependencyResources[0], 50, Clients[1].iClientId); |
|
3004 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -14, iStaticDependencyResources[0]); |
|
3005 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, Clients[1].iClientId); |
|
3006 GetExtendedResStateAndVerify(iStaticDependencyResources[3], 22, iStaticDependencyResources[0]); |
|
3007 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); |
|
3008 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 61, iStaticDependencyResources[3]); |
|
3009 |
|
3010 //Deregister client 4; |
|
3011 r = lddChan.DeRegisterClient(Clients[3].iClientId); |
|
3012 test(r == KErrNone); |
|
3013 |
|
3014 r = lddChan.CheckNotifications(iStaticDependencyResources[5], 0, 0); |
|
3015 test(r == KErrNone); |
|
3016 |
|
3017 GetExtendedResStateAndVerify(iStaticDependencyResources[0], 50, Clients[1].iClientId); |
|
3018 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -14, iStaticDependencyResources[0]); |
|
3019 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, Clients[1].iClientId); |
|
3020 GetExtendedResStateAndVerify(iStaticDependencyResources[3], 22, iStaticDependencyResources[0]); |
|
3021 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); |
|
3022 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 61, iStaticDependencyResources[3]); |
|
3023 |
|
3024 //Deregister client 3. |
|
3025 r = lddChan.DeRegisterClient(Clients[2].iClientId); |
|
3026 test(r == KErrNone); |
|
3027 |
|
3028 GetExtendedResStateAndVerify(iStaticDependencyResources[0], 50, Clients[1].iClientId); |
|
3029 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -14, iStaticDependencyResources[0]); |
|
3030 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, Clients[1].iClientId); |
|
3031 GetExtendedResStateAndVerify(iStaticDependencyResources[3], 22, iStaticDependencyResources[0]); |
|
3032 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); |
|
3033 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 61, iStaticDependencyResources[3]); |
|
3034 |
|
3035 //Deregister client 0 from Resource A |
|
3036 r = lddChan.DeRegisterClientLevelFromResource(Clients[0].iClientId, iStaticDependencyResources[1]); |
|
3037 test(r == KErrNone); |
|
3038 |
|
3039 r = lddChan.CheckNotifications(iStaticDependencyResources[1], 0, 0); |
|
3040 test(r == KErrNone); |
|
3041 |
|
3042 GetExtendedResStateAndVerify(iStaticDependencyResources[0], 50, Clients[1].iClientId); |
|
3043 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -14, iStaticDependencyResources[0]); |
|
3044 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, Clients[1].iClientId); |
|
3045 GetExtendedResStateAndVerify(iStaticDependencyResources[3], 22, iStaticDependencyResources[0]); |
|
3046 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); |
|
3047 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 61, iStaticDependencyResources[3]); |
|
3048 |
|
3049 //Move Resource D to default |
|
3050 r = lddChan.ChangeResourceStateSync(Clients[1].iClientId, iStaticDependencyResources[0], -100); |
|
3051 test(r == KErrPermissionDenied); |
|
3052 |
|
3053 //Deregister client 1 from Resource F |
|
3054 r = lddChan.DeRegisterClientLevelFromResource(Clients[1].iClientId, iStaticDependencyResources[2]); |
|
3055 test(r == KErrNone); |
|
3056 |
|
3057 r = lddChan.CheckNotifications(iStaticDependencyResources[1], 0, 0); |
|
3058 test(r == KErrNone); |
|
3059 |
|
3060 GetExtendedResStateAndVerify(iStaticDependencyResources[0], 50, Clients[1].iClientId); |
|
3061 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -14, iStaticDependencyResources[0]); |
|
3062 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, iStaticDependencyResources[0]); |
|
3063 GetExtendedResStateAndVerify(iStaticDependencyResources[3], 22, iStaticDependencyResources[0]); |
|
3064 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); |
|
3065 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 61, iStaticDependencyResources[3]); |
|
3066 |
|
3067 //Deregister client 2 |
|
3068 r = lddChan.DeRegisterClient(Clients[1].iClientId); |
|
3069 test(r == KErrNone); |
|
3070 |
|
3071 GetExtendedResStateAndVerify(iStaticDependencyResources[0], -100, -1); |
|
3072 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -10, iStaticDependencyResources[0]); |
|
3073 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 0, iStaticDependencyResources[0]); |
|
3074 GetExtendedResStateAndVerify(iStaticDependencyResources[3], 10, iStaticDependencyResources[0]); |
|
3075 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 1, iStaticDependencyResources[3]); |
|
3076 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 75, iStaticDependencyResources[3]); |
|
3077 //Deregister client 1 |
|
3078 r = lddChan.DeRegisterClient(Clients[0].iClientId); |
|
3079 test(r == KErrNone); |
|
3080 Clients.Close(); //Close the array and release memory |
|
3081 |
|
3082 //Test parallel execution of RC and Dependency resource DFC's |
|
3083 //Register client 1 |
|
3084 RmTest.RegisterClient(); |
|
3085 //Register client 2 |
|
3086 RmTest.RegisterClient(); |
|
3087 |
|
3088 state = 50; |
|
3089 /* CheckParallelExecutionForResChageStateWithDependency */ |
|
3090 lddChan.CheckParallelExecutionForChangeResState(Clients[1].iClientId, |
|
3091 iStaticDependencyResources[0],state,5,0,reqSet); |
|
3092 |
|
3093 User::WaitForRequest(reqSet); |
|
3094 test(reqSet.Int() == KErrNone); |
|
3095 |
|
3096 GetExtendedResStateAndVerify(iStaticDependencyResources[0], 50, Clients[1].iClientId); |
|
3097 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -11, iStaticDependencyResources[0]); |
|
3098 GetExtendedResStateAndVerify(iStaticDependencyResources[2], 1, iStaticDependencyResources[0]); |
|
3099 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[3], 13, iStaticDependencyResources[0]); |
|
3100 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); |
|
3101 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 73, iStaticDependencyResources[3]); |
|
3102 |
|
3103 TInt owner; |
|
3104 TBool cached = ETrue; |
|
3105 r = lddChan.GetResourceStateSync(Clients[1].iClientId, 4, cached, state, owner); |
|
3106 test(r == KErrNone); |
|
3107 test(state == 75); |
|
3108 test(owner == -1); |
|
3109 |
|
3110 r = lddChan.DeRegisterClient(Clients[1].iClientId); |
|
3111 test(r == KErrNone); |
|
3112 |
|
3113 GetExtendedResStateAndVerify(iStaticDependencyResources[0], -100, -1); |
|
3114 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -10, iStaticDependencyResources[0]); |
|
3115 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 0, iStaticDependencyResources[0]); |
|
3116 GetExtendedResStateAndVerify(iStaticDependencyResources[3], 10, iStaticDependencyResources[0]); |
|
3117 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 1, iStaticDependencyResources[3]); |
|
3118 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 75, iStaticDependencyResources[3]); |
|
3119 |
|
3120 r = lddChan.GetResourceStateSync(Clients[0].iClientId, 4, cached, state, owner); |
|
3121 test(r == KErrNone); |
|
3122 test(state == 75); |
|
3123 test(owner == -1); |
|
3124 |
|
3125 r = lddChan.DeRegisterClient(Clients[0].iClientId); |
|
3126 test(r == KErrNone); |
|
3127 |
|
3128 Clients.Close(); //Close the array and release memory |
|
3129 depResArray.Close(); //Close the array and release memory |
|
3130 } |
|
3131 #endif |
|
3132 |
|
3133 //This function validates each of the resource manager API's |
|
3134 void TestRM::APIValidationTest() |
|
3135 { |
|
3136 test.Next(_L("\nStarting API validation Test....")); |
|
3137 RmTest.RegisterClient(); |
|
3138 r = lddChan.GetResourceControllerVersion(Clients[0].iClientId, iTestingExtendedVersion); |
|
3139 test(r == KErrNone); |
|
3140 if(!iTestingExtendedVersion) |
|
3141 test.Printf(_L("Testing Basic Version only....")); |
|
3142 else |
|
3143 test.Printf(_L("Testing basic & extended version....")); |
|
3144 RmTest.ValidateClient(5, EOwnerProcess); |
|
3145 iCurrentClientId = -1; |
|
3146 RmTest.GetNumResourcesInUseByClient(iCurrentClientId); |
|
3147 RmTest.GetInfoOnResourcesInUseByClient(iCurrentClientId, iMaxStaticResources); |
|
3148 iCurrentClientId = 0; |
|
3149 NegativeTesting = ETrue; |
|
3150 if(Resources[0].iName.Compare(*(const TDesC8*)&SpecialResName)) |
|
3151 { |
|
3152 test.Printf(_L("Test runs only on simulated PSL\n")); |
|
3153 RmTest.DeRegisterClient(Clients[0].iClientId); |
|
3154 return; |
|
3155 } |
|
3156 TBuf8<32> PowerController = _L8("PowerController"); |
|
3157 r = lddChan.GetClientId(Clients[0].iClientId, (TDesC8&)PowerController, iPowerControllerId); |
|
3158 test(r == KErrNone); |
|
3159 |
|
3160 RBuf8 info; |
|
3161 TUint c; |
|
3162 r = info.Create((iMaxStaticResources) * sizeof(SIdleResourceInfo)); |
|
3163 test(r == KErrNone); |
|
3164 SIdleResourceInfo* pI = (SIdleResourceInfo*)info.Ptr(); |
|
3165 for(c = 0; c < iMaxStaticResources; c++) |
|
3166 { |
|
3167 pI->iResourceId = Resources[c].iResourceId; |
|
3168 pI++; |
|
3169 } |
|
3170 pI = (SIdleResourceInfo*)info.Ptr(); |
|
3171 |
|
3172 r = lddChan.RegisterForIdleResourcesInfo(iPowerControllerId, iMaxStaticResources, (TAny*)info.Ptr()); |
|
3173 |
|
3174 test(r == KErrNone); |
|
3175 RmTest.GetClientName(iCurrentClientId); |
|
3176 RmTest.GetClientId(iCurrentClientId); |
|
3177 RmTest.GetResourceId(2); |
|
3178 RmTest.GetResourceInfo(19); |
|
3179 RmTest.GetNumResourcesInUseByClient(iCurrentClientId); |
|
3180 RmTest.GetInfoOnResourcesInUseByClient(iCurrentClientId, 3); |
|
3181 RmTest.GetNumClientsUsingResource(iCurrentClientId, (TUint)-1); |
|
3182 RmTest.GetNumClientsUsingResource(iCurrentClientId, 10); |
|
3183 RmTest.GetInfoOnClientsUsingResource((TUint)-1, 4); |
|
3184 RmTest.GetInfoOnClientsUsingResource(5, 3); |
|
3185 |
|
3186 for(c = 0; c < iMaxStaticResources; c++) |
|
3187 { |
|
3188 if(Resources[c].iSense == ECustom) |
|
3189 continue; |
|
3190 RmTest.GetResourceStateAsync(c, ETrue); |
|
3191 } |
|
3192 User::After(2000000); //Add delay to make sure that the asynchronous request is processed in controller thread |
|
3193 |
|
3194 for(c = 0; c < iMaxStaticResources; c++) |
|
3195 { |
|
3196 if(Resources[c].iSense == ECustom) |
|
3197 continue; |
|
3198 iCurrentClientId = c; |
|
3199 RmTest.RegisterClient(); |
|
3200 RmTest.AllocReserve(c); |
|
3201 RmTest.GetResourceStateAsync(c); |
|
3202 RmTest.RequestNotification(c); |
|
3203 RmTest.RequestNotificationCon(c); |
|
3204 } |
|
3205 |
|
3206 for(c=0; c< iMaxStaticResources; c++) |
|
3207 { |
|
3208 if(Resources[c].iSense == ECustom) |
|
3209 continue; |
|
3210 iCurrentClientId = c; |
|
3211 RmTest.ChangeResourceStateAsync(c); |
|
3212 RmTest.GetResourceStateAsync(c); |
|
3213 RmTest.GetResourceStateSync(c); |
|
3214 RmTest.ChangeResourceStateSync(c); |
|
3215 } |
|
3216 for(c = 0; c < iMaxStaticResources; c++) |
|
3217 { |
|
3218 if(Resources[c].iSense == ECustom) |
|
3219 continue; |
|
3220 iCurrentClientId = c; |
|
3221 RmTest.GetClientName(c); |
|
3222 RmTest.GetClientId(c); |
|
3223 RmTest.GetResourceId(c); |
|
3224 RmTest.GetResourceInfo(c); |
|
3225 RmTest.GetNumResourcesInUseByClient(c); |
|
3226 RmTest.GetInfoOnResourcesInUseByClient(c, Clients[c].iNumResources); |
|
3227 RmTest.GetNumClientsUsingResource(c, c); |
|
3228 RmTest.GetInfoOnClientsUsingResource(c, Resources[c].iNumClients); |
|
3229 RmTest.CancelNotification(c, ETrue); |
|
3230 RmTest.CancelNotification(c, EFalse); |
|
3231 } |
|
3232 |
|
3233 TInt clientCount = Clients.Count(); |
|
3234 for(c = clientCount-1; ((TInt)c) >=0; c--) |
|
3235 { |
|
3236 test.Printf(_L("DeRegister ClientId %d\n"), Clients[c].iClientId); |
|
3237 RmTest.DeRegisterClient(c); |
|
3238 } |
|
3239 Clients.Close(); |
|
3240 //Find any shared binary resource |
|
3241 for(c = 0; c < iMaxStaticResources; c++) |
|
3242 { |
|
3243 if(Resources[c].iSense == ECustom) |
|
3244 continue; |
|
3245 if((Resources[c].iUsage == EShared) && (Resources[c].iSense == ENegative)) |
|
3246 { |
|
3247 if(Resources[c].iType == 0x0) //Binary Resource |
|
3248 RmTest.SharedBinaryNegativeResourceTesting(c); |
|
3249 else |
|
3250 RmTest.SharedMultilevelNegativeResourceTesting(c); |
|
3251 } |
|
3252 else if((Resources[c].iUsage == EShared) && (Resources[c].iSense == EPositive)) |
|
3253 { |
|
3254 if(Resources[c].iType == 0x0) //Binary Resource |
|
3255 RmTest.SharedBinaryPositiveResourceTesting(c); |
|
3256 else |
|
3257 RmTest.SharedMultilevelPositiveResourceTesting(c); |
|
3258 } |
|
3259 } |
|
3260 |
|
3261 RmTest.CustomResourceTesting(CUSTOM_RESOURCE_NUMBER); |
|
3262 |
|
3263 //Testing of Deregistration of client level for binary resource |
|
3264 RmTest.RegisterClient(); |
|
3265 for(c = 0; c < iMaxStaticResources; c++) |
|
3266 { |
|
3267 if(Resources[c].iSense == ECustom) |
|
3268 continue; |
|
3269 RmTest.DeRegisterClientLevelFromResource(-1, c); |
|
3270 } |
|
3271 for(c = 0; c < iMaxStaticResources; c++) |
|
3272 { |
|
3273 iCurrentClientId = 0; |
|
3274 RmTest.ChangeResourceStateSync(c); |
|
3275 RmTest.DeRegisterClientLevelFromResource(0, c); |
|
3276 } |
|
3277 RmTest.RegisterClient(); |
|
3278 for(c = 0; c < iMaxStaticResources; c++) //Test valid only for shared resources. |
|
3279 { |
|
3280 if((Resources[c].iSense == ECustom) || (Resources[c].iUsage == ESingle)) |
|
3281 continue; |
|
3282 iCurrentClientId = 0; |
|
3283 RmTest.ChangeResourceStateSync(c); |
|
3284 iCurrentClientId = 1; |
|
3285 RmTest.ChangeResourceStateSync(c); |
|
3286 if(Resources[c].iCurrentClient == 0) |
|
3287 { |
|
3288 RmTest.DeRegisterClientLevelFromResource(0, c); |
|
3289 RmTest.DeRegisterClientLevelFromResource(1, c); |
|
3290 } |
|
3291 else |
|
3292 { |
|
3293 RmTest.DeRegisterClientLevelFromResource(1, c); |
|
3294 RmTest.DeRegisterClientLevelFromResource(0, c); |
|
3295 } |
|
3296 } |
|
3297 //Testing of Deregistration of client level for shared resource |
|
3298 for(c = 0; c < iMaxStaticResources; c++) |
|
3299 { |
|
3300 if((Resources[c].iSense == ECustom) || (!Resources[c].iUsage)) |
|
3301 continue; |
|
3302 RmTest.DeRegisterClientLevelFromResource(-1, c); |
|
3303 } |
|
3304 |
|
3305 RmTest.DeRegisterClient(1); |
|
3306 RmTest.DeRegisterClient(0); |
|
3307 info.Create(15 * sizeof(SIdleResourceInfo)); |
|
3308 r = lddChan.GetIdleResourcesInfo(15, (TAny*)(TDes8*)&info); |
|
3309 test(r == KErrNone); |
|
3310 pI = (SIdleResourceInfo*)info.Ptr(); |
|
3311 for(c = 0; c< 15; c++) |
|
3312 { |
|
3313 test(Resources[c].iCurrentClient == pI->iLevelOwnerId); |
|
3314 test(Resources[c].iCurrentLevel == pI->iCurrentLevel); |
|
3315 test(Resources[c].iResourceId == pI->iResourceId); |
|
3316 pI++; |
|
3317 } |
|
3318 info.Close(); |
|
3319 Clients.Close(); |
|
3320 #ifdef PRM_ENABLE_EXTENDED_VERSION |
|
3321 if(iTestingExtendedVersion) |
|
3322 { |
|
3323 TestStaticResourceWithDependency(); |
|
3324 TestDynamicResource(); |
|
3325 TestDynamicResourceDependency(); |
|
3326 } |
|
3327 #endif |
|
3328 Clients.Close(); |
|
3329 return; |
|
3330 } |
|
3331 |
|
3332 //---------------------------------------------------------------------------------------------- |
|
3333 //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0592 |
|
3334 //! @SYMTestType UT |
|
3335 //! @SYMPREQ PREQ1398 |
|
3336 //! @SYMTestCaseDesc This test case tests deregistration of client level functionality. |
|
3337 //! @SYMTestActions 0 Register client |
|
3338 //! 1 Change Resource State |
|
3339 //! 2 Deregister client level |
|
3340 //! 3 Deregister client |
|
3341 //! |
|
3342 //! @SYMTestExpectedResults 0 API should return with KErrNone, panics otherwise. |
|
3343 //! 1 API should return with KErrNone, panics otherwise. |
|
3344 //! 2 API should return with KErrNone, panics otherwise. |
|
3345 //! 3 API should return with KErrNone, panics otherwise. |
|
3346 //! @SYMTestPriority High |
|
3347 //! @SYMTestStatus Implemented |
|
3348 //---------------------------------------------------------------------------------------------- |
|
3349 void TestRM::DeRegisterClientLevelFromResource(TInt aClientId, TUint aResId) |
|
3350 { |
|
3351 TInt state; |
|
3352 TInt newState; |
|
3353 TInt levelOwnerId; |
|
3354 r = lddChan.GetResourceStateSync(Clients[0].iClientId, Resources[aResId].iResourceId, ETrue, newState, levelOwnerId); |
|
3355 test(r == KErrNone); |
|
3356 if((levelOwnerId != -1) && (levelOwnerId != (TInt)Clients[aClientId].iClientId)) |
|
3357 { |
|
3358 test.Printf(_L("Client Id does not match so not testing Deregistration of client level\n")); |
|
3359 return; |
|
3360 } |
|
3361 if(Resources[aResId].iUsage == ESingle) //Single user resource |
|
3362 { |
|
3363 if(levelOwnerId == -1) |
|
3364 { |
|
3365 TUint ClientId; |
|
3366 ClientName[6] = (TUint8)('0' + iMaxClientId+1); |
|
3367 r = lddChan.RegisterClient(ClientId, (const TDesC*)&ClientName); |
|
3368 test(r == KErrNone); |
|
3369 newState = Resources[aResId].iMaxLevel; |
|
3370 r = lddChan.ChangeResourceStateSync(ClientId, Resources[aResId].iResourceId, newState); |
|
3371 test(r == KErrNone); |
|
3372 r = lddChan.GetResourceStateSync(ClientId, Resources[aResId].iResourceId, ETrue, state, levelOwnerId); |
|
3373 test(r == KErrNone); |
|
3374 test(state == newState); |
|
3375 test(levelOwnerId == (TInt)ClientId); |
|
3376 r = lddChan.DeRegisterClientLevelFromResource(ClientId, Resources[aResId].iResourceId); |
|
3377 test(r == KErrNone); |
|
3378 r = lddChan.GetResourceStateSync(ClientId, Resources[aResId].iResourceId, ETrue, state, levelOwnerId); |
|
3379 test(r == KErrNone); |
|
3380 test(levelOwnerId == -1); |
|
3381 r = lddChan.DeRegisterClient(ClientId); |
|
3382 test(r == KErrNone); |
|
3383 return; |
|
3384 } |
|
3385 r = lddChan.DeRegisterClientLevelFromResource(Clients[aClientId].iClientId, Resources[aResId].iResourceId); |
|
3386 test(r == KErrNone); |
|
3387 r = lddChan.GetResourceStateSync(Clients[aClientId].iClientId, Resources[aResId].iResourceId, ETrue, state, levelOwnerId); |
|
3388 test(r == KErrNone); |
|
3389 test(levelOwnerId == -1); |
|
3390 //Update the local |
|
3391 Resources[aResId].iCurrentClient = -1; |
|
3392 Resources[aResId].iCurrentLevel = state; |
|
3393 Resources[aResId].iNumClients = 0; |
|
3394 delete Resources[aResId].iLevel; |
|
3395 Resources[aResId].iLevel = NULL; |
|
3396 return; |
|
3397 } |
|
3398 //Handle for Shared resources |
|
3399 if(levelOwnerId == -1) |
|
3400 { |
|
3401 TUint ClientId[2]; |
|
3402 ClientName[6] = (TUint8)('0' + iMaxClientId+1); |
|
3403 r = lddChan.RegisterClient(ClientId[0], (const TDesC*)&ClientName); |
|
3404 test(r == KErrNone); |
|
3405 ClientName[6] = (TUint8)('0' + iMaxClientId+2); |
|
3406 r = lddChan.RegisterClient(ClientId[1], (const TDesC*)&ClientName); |
|
3407 test(r == KErrNone); |
|
3408 newState = Resources[aResId].iMinLevel; |
|
3409 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3410 test(r == KErrNone); |
|
3411 r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, ETrue, state, levelOwnerId); |
|
3412 test(r == KErrNone); |
|
3413 test(levelOwnerId == (TInt)ClientId[0]); |
|
3414 r = lddChan.ChangeResourceStateSync(ClientId[1], Resources[aResId].iResourceId, newState); |
|
3415 test(r == KErrNone); |
|
3416 r = lddChan.DeRegisterClientLevelFromResource(ClientId[0], Resources[aResId].iResourceId); |
|
3417 test(r == KErrNone); |
|
3418 r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, ETrue, state, levelOwnerId); |
|
3419 test(r == KErrNone); |
|
3420 test(levelOwnerId == (TInt)ClientId[1]); |
|
3421 r = lddChan.DeRegisterClientLevelFromResource(ClientId[1], Resources[aResId].iResourceId); |
|
3422 test(r == KErrNone); |
|
3423 r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, ETrue, state, levelOwnerId); |
|
3424 test(r == KErrNone); |
|
3425 test(levelOwnerId == -1); |
|
3426 r = lddChan.DeRegisterClient(ClientId[0]); |
|
3427 test(r == KErrNone); |
|
3428 r = lddChan.DeRegisterClient(ClientId[1]); |
|
3429 test(r == KErrNone); |
|
3430 return; |
|
3431 } |
|
3432 r = lddChan.DeRegisterClientLevelFromResource(Clients[aClientId].iClientId, Resources[aResId].iResourceId); |
|
3433 test(r == KErrNone); |
|
3434 r = lddChan.GetResourceStateSync(Clients[aClientId].iClientId, Resources[aResId].iResourceId, ETrue, state, levelOwnerId); |
|
3435 test(r == KErrNone); |
|
3436 test(levelOwnerId != (TInt)Clients[aClientId].iClientId); |
|
3437 if(Resources[aResId].iNumClients == 1) |
|
3438 { |
|
3439 Resources[aResId].iNumClients--; |
|
3440 Resources[aResId].iCurrentClient = -1; |
|
3441 r = lddChan.GetResourceStateSync(Clients[aClientId].iClientId, Resources[aResId].iResourceId, ETrue, state, levelOwnerId); |
|
3442 test(r == KErrNone); |
|
3443 Resources[aResId].iCurrentLevel = state; |
|
3444 delete Resources[aResId].iLevel; |
|
3445 Resources[aResId].iLevel = NULL; |
|
3446 } |
|
3447 else |
|
3448 { |
|
3449 Resources[aResId].iNumClients--; |
|
3450 SPowerResourceClientLevel *pCL = NULL; |
|
3451 TInt level = KMinTInt; |
|
3452 TInt clientId = 0; |
|
3453 for(SPowerResourceClientLevel* pL = Resources[aResId].iLevel; pL != NULL; pL = pL->iNextInList) |
|
3454 { |
|
3455 if(pL->iClientId == Clients[aClientId].iClientId) |
|
3456 { |
|
3457 pCL = pL; |
|
3458 continue; |
|
3459 } |
|
3460 if(level == KMinTInt) |
|
3461 { |
|
3462 level = pL->iLevel; |
|
3463 clientId = pL->iClientId; |
|
3464 continue; |
|
3465 } |
|
3466 if(((Resources[aResId].iSense == EPositive) && (pL->iLevel > level)) || ((Resources[aResId].iSense == ENegative) && (pL->iLevel < level))) |
|
3467 { |
|
3468 level = pL->iLevel; |
|
3469 clientId = pL->iClientId; |
|
3470 } |
|
3471 } |
|
3472 delete pCL; |
|
3473 Resources[aResId].iCurrentClient = clientId; |
|
3474 Resources[aResId].iCurrentLevel = level; |
|
3475 } |
|
3476 return; |
|
3477 } |
|
3478 |
|
3479 //---------------------------------------------------------------------------------------------- |
|
3480 //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0593 |
|
3481 //! @SYMTestType UT |
|
3482 //! @SYMPREQ PREQ1398 |
|
3483 //! @SYMTestCaseDesc This test case tests changing resource state of shared positive resource. |
|
3484 //! @SYMTestActions 0 Register client1 |
|
3485 //! 1 Register client2 |
|
3486 //! 2 Register client3 |
|
3487 //! 3 Register client4 |
|
3488 //! 4 Client1 change resource state. |
|
3489 //! 5 Client2 change resource state. |
|
3490 //! 6 Client3 change resource state. |
|
3491 //! 7 Client4 change resource state. |
|
3492 //! 8 Client1 change resource state. |
|
3493 //! 9 Client2 change resource state. |
|
3494 //! 10 Deregister client2 |
|
3495 //! 11 Client3 change resource state. |
|
3496 //! 12 Deregister client1 |
|
3497 //! 13 Deregister client3 |
|
3498 //! 14 Deregister client4 |
|
3499 //! |
|
3500 //! @SYMTestExpectedResults 0 Client registered |
|
3501 //! 1 Client registered |
|
3502 //! 2 Client registered |
|
3503 //! 3 Client registered |
|
3504 //! 4 Resource state changed |
|
3505 //! 5 Resource state changed |
|
3506 //! 6 Resource state changed |
|
3507 //! 7 Resource state changed |
|
3508 //! 8 Resource state changed |
|
3509 //! 9 Resource state changed |
|
3510 //! 10 Client2 deregistered |
|
3511 //! 11 Resource state changed |
|
3512 //! 12 Client1 deregistered |
|
3513 //! 13 Client3 deregistered |
|
3514 //! 14 Client4 deregistered |
|
3515 //! @SYMTestPriority High |
|
3516 //! @SYMTestStatus Implemented |
|
3517 //---------------------------------------------------------------------------------------------- |
|
3518 void TestRM::SharedBinaryPositiveResourceTesting(TUint aResId) |
|
3519 { |
|
3520 TInt newState, levelOwnerId; |
|
3521 TRequestStatus req; |
|
3522 TUint ClientId[5]; |
|
3523 |
|
3524 ClientName[6] = (TUint8)('0' + iMaxClientId+1); |
|
3525 r = lddChan.RegisterClient(ClientId[0], (const TDesC*)&ClientName); |
|
3526 test(r == KErrNone); |
|
3527 |
|
3528 r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, ETrue, newState, levelOwnerId); |
|
3529 test(r == KErrNone); |
|
3530 if(levelOwnerId != -1) |
|
3531 { |
|
3532 test.Printf(_L("Not testing the shared resource as some other client is currently holding the resource\n")); |
|
3533 r = lddChan.DeRegisterClient(ClientId[0]); |
|
3534 test(r == KErrNone); |
|
3535 return; |
|
3536 } |
|
3537 |
|
3538 ClientName[6] = (TUint8)('0' + iMaxClientId +2); |
|
3539 r = lddChan.RegisterClient(ClientId[1], (const TDesC*)&ClientName); |
|
3540 test(r == KErrNone); |
|
3541 ClientName[6] = (TUint8)('0' + iMaxClientId +3); |
|
3542 r = lddChan.RegisterClient(ClientId[2], (const TDesC*)&ClientName); |
|
3543 test(r == KErrNone); |
|
3544 ClientName[6] = (TUint8)('0' + iMaxClientId +4); |
|
3545 r = lddChan.RegisterClient(ClientId[3], (const TDesC*)&ClientName); |
|
3546 test(r == KErrNone); |
|
3547 ClientName[6] = (TUint8)('0' + iMaxClientId +5); |
|
3548 r = lddChan.RegisterClient(ClientId[4], (const TDesC*)&ClientName); |
|
3549 test(r == KErrNone); |
|
3550 |
|
3551 newState = 1; |
|
3552 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3553 test(r == KErrNone); |
|
3554 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); |
|
3555 test(r == KErrNone); |
|
3556 r = lddChan.RequestNotification(ClientId[1], Resources[aResId].iResourceId); |
|
3557 test(r == KErrNone); |
|
3558 r = lddChan.RequestNotification(ClientId[2], Resources[aResId].iResourceId); |
|
3559 test(r == KErrNone); |
|
3560 r = lddChan.RequestNotification(ClientId[3], Resources[aResId].iResourceId, 1, ETrue); |
|
3561 test(r == KErrNone); |
|
3562 r = lddChan.RequestNotification(ClientId[2], Resources[aResId].iResourceId, 0, EFalse); |
|
3563 test(r == KErrNone); |
|
3564 newState = !newState; //State 0 |
|
3565 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3566 test(r == KErrNone); |
|
3567 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 2, 1); |
|
3568 test(r == KErrNone); |
|
3569 newState = !newState; //State 1 |
|
3570 r = lddChan.ChangeResourceStateSync(ClientId[1], Resources[aResId].iResourceId, newState); |
|
3571 test(r == KErrNone); |
|
3572 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 2, 1); |
|
3573 test(r == KErrNone); |
|
3574 lddChan.ChangeResourceStateAsync(ClientId[2], Resources[aResId].iResourceId, newState, req); |
|
3575 User::WaitForRequest(req); //State 1 |
|
3576 test(req.Int() == KErrNone); |
|
3577 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); |
|
3578 test(r == KErrNone); |
|
3579 newState = !newState; //State 0 |
|
3580 r = lddChan.ChangeResourceStateSync(ClientId[3], Resources[aResId].iResourceId, newState); |
|
3581 test(r == KErrNone); |
|
3582 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); |
|
3583 test(r == KErrNone); |
|
3584 newState = !newState; //state 1 |
|
3585 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3586 test(r == KErrNone); |
|
3587 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); |
|
3588 newState = !newState; //state 0 |
|
3589 r = lddChan.ChangeResourceStateSync(ClientId[1], Resources[aResId].iResourceId, newState); |
|
3590 test(r == KErrNone); |
|
3591 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0,0); |
|
3592 test(r == KErrNone); |
|
3593 r = lddChan.DeRegisterClient(ClientId[1]); |
|
3594 test(r == KErrNone); |
|
3595 newState = 0; |
|
3596 r = lddChan.ChangeResourceStateSync(ClientId[2], Resources[aResId].iResourceId, newState); |
|
3597 test(r == KErrNone); |
|
3598 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0,0); |
|
3599 test(r == KErrNone); |
|
3600 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3601 test(r == KErrNone); |
|
3602 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 1,1); |
|
3603 test(r == KErrNone); |
|
3604 r = lddChan.CancelNotification(ClientId[2], Resources[aResId].iResourceId, EFalse); |
|
3605 test(r == KErrCancel); |
|
3606 r = lddChan.CancelNotification(ClientId[3], Resources[aResId].iResourceId, ETrue); |
|
3607 test(r == KErrCancel); |
|
3608 newState = 1; |
|
3609 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3610 test(r == KErrNone); |
|
3611 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); |
|
3612 test(r == KErrNone); |
|
3613 r = lddChan.CancelNotification(ClientId[2], Resources[aResId].iResourceId, ETrue); |
|
3614 test(r == KErrCancel); |
|
3615 newState = 1; |
|
3616 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3617 test(r == KErrNone); |
|
3618 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); |
|
3619 test(r == KErrNone); |
|
3620 r = lddChan.DeRegisterClient(ClientId[0]); |
|
3621 test(r == KErrNone); |
|
3622 r = lddChan.DeRegisterClient(ClientId[2]); |
|
3623 test(r == KErrNone); |
|
3624 r = lddChan.DeRegisterClient(ClientId[3]); |
|
3625 test(r == KErrNone); |
|
3626 r = lddChan.GetResourceStateSync(ClientId[4], Resources[aResId].iResourceId, ETrue, newState, levelOwnerId); |
|
3627 test(r == KErrNone); |
|
3628 test(levelOwnerId == -1); |
|
3629 r = lddChan.DeRegisterClient(ClientId[4]); |
|
3630 test(r == KErrNone); |
|
3631 return; |
|
3632 } |
|
3633 |
|
3634 //---------------------------------------------------------------------------------------------- |
|
3635 //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0594 |
|
3636 //! @SYMTestType UT |
|
3637 //! @SYMPREQ PREQ1398 |
|
3638 //! @SYMTestCaseDesc This test case tests changing resource state of shared negative resource. |
|
3639 //! @SYMTestActions 0 Register client1 |
|
3640 //! 1 Register client2 |
|
3641 //! 2 Register client3 |
|
3642 //! 3 Register client4 |
|
3643 //! 4 Client1 change resource state. |
|
3644 //! 5 Client2 change resource state. |
|
3645 //! 6 Client3 change resource state. |
|
3646 //! 7 Client4 change resource state. |
|
3647 //! 8 Client1 change resource state. |
|
3648 //! 9 Client2 change resource state. |
|
3649 //! 10 Deregister client2 |
|
3650 //! 11 Client3 change resource state. |
|
3651 //! 12 Deregister client1 |
|
3652 //! 13 Deregister client3 |
|
3653 //! 14 Deregister client4 |
|
3654 //! |
|
3655 //! @SYMTestExpectedResults 0 Client registered |
|
3656 //! 1 Client registered |
|
3657 //! 2 Client registered |
|
3658 //! 3 Client registered |
|
3659 //! 4 Resource state changed |
|
3660 //! 5 Resource state changed |
|
3661 //! 6 Resource state changed |
|
3662 //! 7 Resource state changed |
|
3663 //! 8 Resource state changed |
|
3664 //! 9 Resource state changed |
|
3665 //! 10 Client2 deregistered |
|
3666 //! 11 Resource state changed |
|
3667 //! 12 Client1 deregistered |
|
3668 //! 13 Client3 deregistered |
|
3669 //! 14 Client4 deregistered |
|
3670 //! @SYMTestPriority High |
|
3671 //! @SYMTestStatus Implemented |
|
3672 //---------------------------------------------------------------------------------------------- |
|
3673 void TestRM::SharedBinaryNegativeResourceTesting(TUint aResId) |
|
3674 { |
|
3675 TInt newState; |
|
3676 TInt levelOwnerId; |
|
3677 TRequestStatus req; |
|
3678 TUint ClientId[5]; |
|
3679 |
|
3680 ClientName[6] = (TUint8)('0' + iMaxClientId+1); |
|
3681 r = lddChan.RegisterClient(ClientId[0], (const TDesC*)&ClientName); |
|
3682 test(r == KErrNone); |
|
3683 |
|
3684 r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, ETrue, newState, levelOwnerId); |
|
3685 test(r == KErrNone); |
|
3686 if(levelOwnerId != -1) |
|
3687 { |
|
3688 test.Printf(_L("Not testing the shared resource as some other client is currently holding the resource\n")); |
|
3689 r = lddChan.DeRegisterClient(ClientId[0]); |
|
3690 test(r == KErrNone); |
|
3691 return; |
|
3692 } |
|
3693 |
|
3694 ClientName[6] = (TUint8)('0' + iMaxClientId +2); |
|
3695 r = lddChan.RegisterClient(ClientId[1], (const TDesC*)&ClientName); |
|
3696 test(r == KErrNone); |
|
3697 ClientName[6] = (TUint8)('0' + iMaxClientId +3); |
|
3698 r = lddChan.RegisterClient(ClientId[2], (const TDesC*)&ClientName); |
|
3699 test(r == KErrNone); |
|
3700 ClientName[6] = (TUint8)('0' + iMaxClientId +4); |
|
3701 r = lddChan.RegisterClient(ClientId[3], (const TDesC*)&ClientName); |
|
3702 test(r == KErrNone); |
|
3703 ClientName[6] = (TUint8)('0' + iMaxClientId +5); |
|
3704 r = lddChan.RegisterClient(ClientId[4], (const TDesC*)&ClientName); |
|
3705 test(r == KErrNone); |
|
3706 |
|
3707 newState = 0; |
|
3708 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3709 test(r == KErrNone); |
|
3710 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); |
|
3711 test(r == KErrNone); |
|
3712 r = lddChan.RequestNotification(ClientId[1], Resources[aResId].iResourceId); |
|
3713 test(r == KErrNone); |
|
3714 r = lddChan.RequestNotification(ClientId[2], Resources[aResId].iResourceId); |
|
3715 test(r == KErrNone); |
|
3716 r = lddChan.RequestNotification(ClientId[3], Resources[aResId].iResourceId, 1, ETrue); |
|
3717 test(r == KErrNone); |
|
3718 r = lddChan.RequestNotification(ClientId[2], Resources[aResId].iResourceId, 0, EFalse); |
|
3719 test(r == KErrNone); |
|
3720 newState = !newState; //State 1 |
|
3721 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3722 test(r == KErrNone); |
|
3723 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 2, 1); |
|
3724 test(r == KErrNone); |
|
3725 newState = !newState; //State 0 |
|
3726 r = lddChan.ChangeResourceStateSync(ClientId[1], Resources[aResId].iResourceId, newState); |
|
3727 test(r == KErrNone); |
|
3728 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 2, 1); |
|
3729 test(r == KErrNone); |
|
3730 lddChan.ChangeResourceStateAsync(ClientId[2], Resources[aResId].iResourceId, newState, req); |
|
3731 User::WaitForRequest(req); //State 0 |
|
3732 test(req.Int() == KErrNone); |
|
3733 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); |
|
3734 test(r == KErrNone); |
|
3735 newState = !newState; //State 1 |
|
3736 r = lddChan.ChangeResourceStateSync(ClientId[3], Resources[aResId].iResourceId, newState); |
|
3737 test(r == KErrNone); |
|
3738 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); |
|
3739 test(r == KErrNone); |
|
3740 newState = !newState; //state 0 |
|
3741 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3742 test(r == KErrNone); |
|
3743 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); |
|
3744 newState = !newState; //state 1 |
|
3745 r = lddChan.ChangeResourceStateSync(ClientId[1], Resources[aResId].iResourceId, newState); |
|
3746 test(r == KErrNone); |
|
3747 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0,0); |
|
3748 test(r == KErrNone); |
|
3749 r = lddChan.DeRegisterClient(ClientId[1]); |
|
3750 test(r == KErrNone); |
|
3751 newState = 1; |
|
3752 r = lddChan.ChangeResourceStateSync(ClientId[2], Resources[aResId].iResourceId, newState); |
|
3753 test(r == KErrNone); |
|
3754 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0,0); |
|
3755 test(r == KErrNone); |
|
3756 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3757 test(r == KErrNone); |
|
3758 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 1,1); |
|
3759 test(r == KErrNone); |
|
3760 r = lddChan.CancelNotification(ClientId[2], Resources[aResId].iResourceId, EFalse); |
|
3761 test(r == KErrCancel); |
|
3762 r = lddChan.CancelNotification(ClientId[3], Resources[aResId].iResourceId, ETrue); |
|
3763 test(r == KErrCancel); |
|
3764 newState = 1; |
|
3765 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3766 test(r == KErrNone); |
|
3767 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); |
|
3768 test(r == KErrNone); |
|
3769 r = lddChan.CancelNotification(ClientId[2], Resources[aResId].iResourceId, ETrue); |
|
3770 test(r == KErrCancel); |
|
3771 newState = 1; |
|
3772 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3773 test(r == KErrNone); |
|
3774 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); |
|
3775 test(r == KErrNone); |
|
3776 r = lddChan.DeRegisterClient(ClientId[0]); |
|
3777 test(r == KErrNone); |
|
3778 r = lddChan.DeRegisterClient(ClientId[2]); |
|
3779 test(r == KErrNone); |
|
3780 r = lddChan.DeRegisterClient(ClientId[3]); |
|
3781 test(r == KErrNone); |
|
3782 r = lddChan.GetResourceStateSync(ClientId[4], Resources[aResId].iResourceId, ETrue, newState, levelOwnerId); |
|
3783 test(r == KErrNone); |
|
3784 test(levelOwnerId == -1); |
|
3785 r = lddChan.DeRegisterClient(ClientId[4]); |
|
3786 test(r == KErrNone); |
|
3787 return; |
|
3788 } |
|
3789 |
|
3790 //Test cases to test the shared multilevel negative resources |
|
3791 void TestRM::SharedMultilevelNegativeResourceTesting(TUint aResId) |
|
3792 { |
|
3793 TInt newState; |
|
3794 TInt levelOwnerId; |
|
3795 TRequestStatus req; |
|
3796 TUint ClientId[2]; |
|
3797 |
|
3798 //Register 1st client |
|
3799 ClientName[6] = (TUint8)('0' + iMaxClientId+1); |
|
3800 r = lddChan.RegisterClient(ClientId[0], (const TDesC*)&ClientName); |
|
3801 test(r == KErrNone); |
|
3802 |
|
3803 r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, ETrue, newState, levelOwnerId); |
|
3804 test(r == KErrNone); |
|
3805 if(levelOwnerId != -1) |
|
3806 { |
|
3807 test.Printf(_L("Not testing the shared resource as some other client is currently holding the resource\n")); |
|
3808 r = lddChan.DeRegisterClient(ClientId[0]); |
|
3809 test(r == KErrNone); |
|
3810 return; |
|
3811 } |
|
3812 |
|
3813 test.Printf(_L("Testing %d Shared Multilevel Negative Resource\n"), Resources[aResId].iResourceId); |
|
3814 |
|
3815 //Register 2nd client |
|
3816 ClientName[6] = (TUint8)('0' + iMaxClientId+2); |
|
3817 r = lddChan.RegisterClient(ClientId[1], (const TDesC*)&ClientName); |
|
3818 test(r == KErrNone); |
|
3819 |
|
3820 //Change the resource and ClientId[0] becomes the owner of the resource |
|
3821 newState = Resources[aResId].iMaxLevel + 10; |
|
3822 |
|
3823 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3824 test(r == KErrNone); |
|
3825 |
|
3826 TInt state; |
|
3827 r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, ETrue, state, levelOwnerId); |
|
3828 test(r == KErrNone); |
|
3829 test(state == newState); |
|
3830 test(levelOwnerId = (TInt)ClientId[0]); |
|
3831 |
|
3832 //Second client(clientId[1]) trying to change the resource, but still |
|
3833 newState = state +5; |
|
3834 lddChan.ChangeResourceStateAsync(ClientId[1], Resources[aResId].iResourceId, newState, req); |
|
3835 User::WaitForRequest(req); |
|
3836 test(req.Int() == KErrNone); |
|
3837 |
|
3838 lddChan.GetResourceStateAsync(ClientId[0], Resources[aResId].iResourceId, EFalse, req, newState, levelOwnerId); |
|
3839 User::WaitForRequest(req); |
|
3840 test(req.Int() == KErrNone); |
|
3841 test(state = newState); |
|
3842 test(levelOwnerId == (TInt)ClientId[0]); |
|
3843 |
|
3844 newState = state + 10; |
|
3845 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3846 test(r == KErrNone); |
|
3847 |
|
3848 r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, EFalse, state, levelOwnerId); |
|
3849 test(r == KErrNone); |
|
3850 newState = Resources[aResId].iMaxLevel + 15; |
|
3851 test(state == newState); |
|
3852 test(levelOwnerId == (TInt)ClientId[1]); |
|
3853 |
|
3854 r = lddChan.DeRegisterClientLevelFromResource(ClientId[1], Resources[aResId].iResourceId); |
|
3855 test(r == KErrNone); |
|
3856 |
|
3857 state = Resources[aResId].iMaxLevel + 20; |
|
3858 lddChan.GetResourceStateAsync(ClientId[1], Resources[aResId].iResourceId, ETrue, req, newState, levelOwnerId); |
|
3859 User::WaitForRequest(req); |
|
3860 test(req.Int() == KErrNone); |
|
3861 test(state == newState); |
|
3862 test(levelOwnerId == (TInt)ClientId[0]); |
|
3863 |
|
3864 newState = Resources[aResId].iMaxLevel + 10; |
|
3865 lddChan.ChangeResourceStateAsync(ClientId[1], Resources[aResId].iResourceId, newState, req); |
|
3866 User::WaitForRequest(req); |
|
3867 test(req.Int() == KErrNone); |
|
3868 |
|
3869 |
|
3870 lddChan.GetResourceStateAsync(ClientId[0], Resources[aResId].iResourceId, EFalse, req, state, levelOwnerId); |
|
3871 User::WaitForRequest(req); |
|
3872 test(req.Int() == KErrNone); |
|
3873 test(state == newState); |
|
3874 test(levelOwnerId == (TInt)ClientId[1]); |
|
3875 |
|
3876 r = lddChan.DeRegisterClient(ClientId[1]); |
|
3877 test(r == KErrNone); |
|
3878 |
|
3879 r = lddChan.DeRegisterClientLevelFromResource(ClientId[0], Resources[aResId].iResourceId); |
|
3880 test(r == KErrNone); |
|
3881 |
|
3882 r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, EFalse, state, levelOwnerId); |
|
3883 test(r == KErrNone); |
|
3884 test(state == Resources[aResId].iDefaultLevel); |
|
3885 test(levelOwnerId == -1); |
|
3886 |
|
3887 r = lddChan.DeRegisterClient(ClientId[0]); |
|
3888 test(r == KErrNone); |
|
3889 |
|
3890 return; |
|
3891 } |
|
3892 |
|
3893 //Test cases to test the shared multilevel positive resources |
|
3894 void TestRM::SharedMultilevelPositiveResourceTesting(TUint aResId) |
|
3895 { |
|
3896 TInt newState; |
|
3897 TInt levelOwnerId; |
|
3898 TRequestStatus req; |
|
3899 TUint ClientId[2]; |
|
3900 |
|
3901 //Register 1st client |
|
3902 ClientName[6] = (TUint8)('0' + iMaxClientId+1); |
|
3903 r = lddChan.RegisterClient(ClientId[0], (const TDesC*)&ClientName); |
|
3904 test(r == KErrNone); |
|
3905 |
|
3906 r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, ETrue, newState, levelOwnerId); |
|
3907 test(r == KErrNone); |
|
3908 if(levelOwnerId != -1) |
|
3909 { |
|
3910 test.Printf(_L("Not testing the shared resource as some other client is currently holding the resource\n")); |
|
3911 r = lddChan.DeRegisterClient(ClientId[0]); |
|
3912 test(r == KErrNone); |
|
3913 return; |
|
3914 } |
|
3915 |
|
3916 test.Printf(_L("Testing %d Shared Multilevel positive Resource\n"), Resources[aResId].iResourceId); |
|
3917 |
|
3918 //Register 2nd client |
|
3919 ClientName[6] = (TUint8)('0' + iMaxClientId+2); |
|
3920 r = lddChan.RegisterClient(ClientId[1], (const TDesC*)&ClientName); |
|
3921 test(r == KErrNone); |
|
3922 |
|
3923 //Change the resource and ClientId[0] becomes the owner of the resource |
|
3924 newState = Resources[aResId].iMinLevel + 20; |
|
3925 |
|
3926 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3927 test(r == KErrNone); |
|
3928 |
|
3929 TInt state; |
|
3930 r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, ETrue, state, levelOwnerId); |
|
3931 test(r == KErrNone); |
|
3932 test(state == newState); |
|
3933 test(levelOwnerId = (TInt)ClientId[0]); |
|
3934 |
|
3935 //Second client(clientId[1]) trying to change the resource, but still |
|
3936 newState = Resources[aResId].iMinLevel +10; |
|
3937 lddChan.ChangeResourceStateAsync(ClientId[1], Resources[aResId].iResourceId, newState, req); |
|
3938 User::WaitForRequest(req); |
|
3939 test(req.Int() == KErrNone); |
|
3940 |
|
3941 lddChan.GetResourceStateAsync(ClientId[0], Resources[aResId].iResourceId, EFalse, req, newState, levelOwnerId); |
|
3942 User::WaitForRequest(req); |
|
3943 test(req.Int() == KErrNone); |
|
3944 test(state = newState); |
|
3945 test(levelOwnerId == (TInt)ClientId[0]); |
|
3946 |
|
3947 newState = Resources[aResId].iMinLevel + 5; |
|
3948 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3949 test(r == KErrNone); |
|
3950 |
|
3951 r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, EFalse, state, levelOwnerId); |
|
3952 test(r == KErrNone); |
|
3953 test(state == Resources[aResId].iMinLevel+10); |
|
3954 test(levelOwnerId == (TInt)ClientId[1]); |
|
3955 |
|
3956 r = lddChan.DeRegisterClientLevelFromResource(ClientId[1], Resources[aResId].iResourceId); |
|
3957 test(r == KErrNone); |
|
3958 |
|
3959 newState = Resources[aResId].iMinLevel + 5; |
|
3960 lddChan.GetResourceStateAsync(ClientId[1], Resources[aResId].iResourceId, ETrue, req, state, levelOwnerId); |
|
3961 User::WaitForRequest(req); |
|
3962 test(req.Int() == KErrNone); |
|
3963 test(state == newState); |
|
3964 test(levelOwnerId == (TInt)ClientId[0]); |
|
3965 |
|
3966 newState = Resources[aResId].iMinLevel + 10; |
|
3967 lddChan.ChangeResourceStateAsync(ClientId[1], Resources[aResId].iResourceId, newState, req); |
|
3968 User::WaitForRequest(req); |
|
3969 test(req.Int() == KErrNone); |
|
3970 |
|
3971 |
|
3972 lddChan.GetResourceStateAsync(ClientId[0], Resources[aResId].iResourceId, EFalse, req, state, levelOwnerId); |
|
3973 User::WaitForRequest(req); |
|
3974 test(req.Int() == KErrNone); |
|
3975 test(state == newState); |
|
3976 test(levelOwnerId == (TInt)ClientId[1]); |
|
3977 |
|
3978 r = lddChan.DeRegisterClient(ClientId[1]); |
|
3979 test(r == KErrNone); |
|
3980 |
|
3981 r = lddChan.DeRegisterClientLevelFromResource(ClientId[0], Resources[aResId].iResourceId); |
|
3982 test(r == KErrNone); |
|
3983 |
|
3984 r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, EFalse, state, levelOwnerId); |
|
3985 test(r == KErrNone); |
|
3986 test(state == Resources[aResId].iDefaultLevel); |
|
3987 test(levelOwnerId == -1); |
|
3988 |
|
3989 r = lddChan.DeRegisterClient(ClientId[0]); |
|
3990 test(r == KErrNone); |
|
3991 |
|
3992 return; |
|
3993 } |
|
3994 |
|
3995 //Custom resource testing. This testing is done only with simulated resources. |
|
3996 //Testing of shared binary positive resource. |
|
3997 //---------------------------------------------------------------------------------------------- |
|
3998 //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0593 |
|
3999 //! @SYMTestType UT |
|
4000 //! @SYMPREQ PREQ1398 |
|
4001 //! @SYMTestCaseDesc This test case tests changing resource state of shared positive resource. |
|
4002 //! @SYMTestActions 0 Register client1 |
|
4003 //! 1 Register client2 |
|
4004 //! 2 Register client3 |
|
4005 //! 3 Register client4 |
|
4006 //! 4 Client1 change resource state. |
|
4007 //! 5 Client2 change resource state. |
|
4008 //! 6 Client3 get resource state. |
|
4009 //! 7 Client4 get resource state. |
|
4010 //! 8 Client1 change resource state. |
|
4011 //! 9 Client2 get resource state. |
|
4012 //! 10 Deregister client2 |
|
4013 //! 11 Deregister client1 |
|
4014 //! 12 Deregister client3 |
|
4015 //! 13 Deregister client4 |
|
4016 //! |
|
4017 //! @SYMTestExpectedResults 0 Client registered |
|
4018 //! 1 Client registered |
|
4019 //! 2 Client registered |
|
4020 //! 3 Client registered |
|
4021 //! 4 Resource state changed |
|
4022 //! 5 Resource state changed |
|
4023 //! 6 Resource state read and compared for correctness |
|
4024 //! 7 Resource state read and compared for correctness |
|
4025 //! 8 Resource state changed |
|
4026 //! 9 Resource state read and compared for correctness |
|
4027 //! 10 Client2 deregistered |
|
4028 //! 11 Client1 deregistered |
|
4029 //! 12 Client3 deregistered |
|
4030 //! 13 Client4 deregistered |
|
4031 //! @SYMTestPriority High |
|
4032 //! @SYMTestStatus Implemented |
|
4033 //---------------------------------------------------------------------------------------------- |
|
4034 void TestRM::CustomResourceTesting(TUint aResId) |
|
4035 { |
|
4036 test.Printf(_L("Testing custom function\n")); |
|
4037 TInt r = KErrNone; |
|
4038 TRequestStatus req; |
|
4039 TInt state; |
|
4040 TInt newState; |
|
4041 TInt levelOwnerId; |
|
4042 TUint ClientId[4]; |
|
4043 ClientName[6] = (TUint8)('0' + iMaxClientId +1); |
|
4044 r = lddChan.RegisterClient(ClientId[0], (const TDesC*)&ClientName); |
|
4045 test(r == KErrNone); |
|
4046 ClientName[6] = (TUint8)('0' + iMaxClientId +2); |
|
4047 r = lddChan.RegisterClient(ClientId[1], (const TDesC*)&ClientName); |
|
4048 test(r == KErrNone); |
|
4049 ClientName[6] = (TUint8)('0' + iMaxClientId +3); |
|
4050 r = lddChan.RegisterClient(ClientId[2], (const TDesC*)&ClientName); |
|
4051 test(r == KErrNone); |
|
4052 ClientName[6] = (TUint8)('0' + iMaxClientId +4); |
|
4053 r = lddChan.RegisterClient(ClientId[3], (const TDesC*)&ClientName); |
|
4054 test(r == KErrNone); |
|
4055 r = lddChan.RequestNotification(ClientId[0], Resources[aResId].iResourceId); |
|
4056 test(r == KErrNone); |
|
4057 r = lddChan.RequestNotification(ClientId[1], Resources[aResId].iResourceId); |
|
4058 test(r == KErrNone); |
|
4059 newState = 1; |
|
4060 state = 1; |
|
4061 lddChan.ChangeResourceStateAsync(ClientId[2], Resources[aResId].iResourceId, state, req); |
|
4062 User::WaitForRequest(req); //State 1 |
|
4063 test(req.Int() == KErrNone); |
|
4064 test(state == newState); |
|
4065 test(r == KErrNone); |
|
4066 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 2, 0); |
|
4067 test(r == KErrNone); |
|
4068 state = 0; |
|
4069 lddChan.ChangeResourceStateAsync(ClientId[1], Resources[aResId].iResourceId, state, req); |
|
4070 User::WaitForRequest(req); |
|
4071 test(req.Int() == KErrNone); |
|
4072 test(state == newState); |
|
4073 r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, EFalse, state, levelOwnerId); |
|
4074 test(r == KErrNone); |
|
4075 test(state == 1); |
|
4076 lddChan.ChangeResourceStateAsync(ClientId[0], Resources[aResId].iResourceId, state, req); |
|
4077 User::WaitForRequest(req); |
|
4078 test(req.Int() == KErrNone); |
|
4079 test(state == newState); |
|
4080 r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, ETrue, state, levelOwnerId); |
|
4081 test(r == KErrNone); |
|
4082 test((TUint)levelOwnerId == ClientId[2]); |
|
4083 r = lddChan.ChangeResourceStateSync(ClientId[2], Resources[aResId].iResourceId, 0); |
|
4084 test(r == KErrNone); |
|
4085 r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, EFalse, state, levelOwnerId); |
|
4086 test(r == KErrNone); |
|
4087 test(state == 1); |
|
4088 test((TUint)levelOwnerId == ClientId[0]); |
|
4089 r = lddChan.DeRegisterClient(ClientId[0]); |
|
4090 test(r == KErrNone); |
|
4091 r = lddChan.DeRegisterClientLevelFromResource(ClientId[1], Resources[aResId].iResourceId); |
|
4092 test(r == KErrNone); |
|
4093 r= lddChan.DeRegisterClient(ClientId[2]); |
|
4094 test(r == KErrNone); |
|
4095 r = lddChan.GetResourceStateSync(ClientId[3], Resources[aResId].iResourceId, ETrue, state, levelOwnerId); |
|
4096 test(r == KErrNone); |
|
4097 test(levelOwnerId == -1); |
|
4098 r = lddChan.DeRegisterClient(ClientId[3]); |
|
4099 test(r == KErrNone); |
|
4100 r = lddChan.DeRegisterClient(ClientId[1]); |
|
4101 test(r == KErrNone); |
|
4102 return; |
|
4103 } |
|
4104 |
|
4105 //Resource manager operations are chosen randomly and tested for correctness. This is done only in |
|
4106 //simulated resources. Currently this runs for 500 iteration. |
|
4107 //NOTE: Increasing the iteration to more than 500 may fail due to insufficient internal buffers. |
|
4108 void TestRM::RegressionTest() |
|
4109 { |
|
4110 TUint operation = 0; |
|
4111 TUint resourceId; |
|
4112 TUint count; |
|
4113 NegativeTesting = 0; |
|
4114 iMaxClientId = 0; |
|
4115 iMaxStaticResources = 0; |
|
4116 iMaxStaticDependentResources = 0; |
|
4117 iMaxClients = 0; |
|
4118 RmTest.RegisterClient(); |
|
4119 iCurrentClientId = -1; |
|
4120 r = lddChan.GetResourceControllerVersion(Clients[0].iClientId, iTestingExtendedVersion); |
|
4121 if(r != KErrNone) |
|
4122 test.Printf(_L("Return value of GetResourceControllerVersion %d\n"), r); |
|
4123 test(r == KErrNone); |
|
4124 if(!iTestingExtendedVersion) |
|
4125 test.Printf(_L("Testing Basic Version only....")); |
|
4126 else |
|
4127 test.Printf(_L("Testing basic & extended version....")); |
|
4128 RmTest.GetNumResourcesInUseByClient(iCurrentClientId); |
|
4129 RmTest.GetInfoOnResourcesInUseByClient(iCurrentClientId, iMaxStaticResources); |
|
4130 if(!(Resources[0].iName.Compare(*(const TDesC8*)&SpecialResName))) |
|
4131 { |
|
4132 TBuf8<32> PowerController = _L8("PowerController"); |
|
4133 r = lddChan.GetClientId(Clients[0].iClientId, (TDesC8&)PowerController, iPowerControllerId); |
|
4134 test(r == KErrNone); |
|
4135 } |
|
4136 else |
|
4137 { |
|
4138 test.Printf(_L("Regression testing is run only on simulator")); |
|
4139 return; |
|
4140 } |
|
4141 |
|
4142 for(count = 0; count < 500; count++) |
|
4143 { |
|
4144 operation = Math::Random() % EOperationEnd; |
|
4145 iCurrentClientId = Math::Random() % iMaxClients; |
|
4146 resourceId = Math::Random() % iMaxStaticResources; |
|
4147 if(operation != ERegisterClient) |
|
4148 { |
|
4149 if(Clients[iCurrentClientId].iClientId == 0) //Not a valid client |
|
4150 continue; |
|
4151 } |
|
4152 if(Resources[resourceId].iSense == ECustom) |
|
4153 continue; |
|
4154 test.Printf(_L("\nOperation = %d, ClientId = %d, ResourceId = %d\n"), operation, iCurrentClientId, resourceId); |
|
4155 switch (operation) |
|
4156 { |
|
4157 case ERegisterClient: |
|
4158 RmTest.RegisterClient(); |
|
4159 break; |
|
4160 case EGetClientName: |
|
4161 RmTest.GetClientName(iCurrentClientId); |
|
4162 break; |
|
4163 case EGetAllClientName: |
|
4164 RmTest.GetClientName(0); |
|
4165 break; |
|
4166 case EGetClientId: |
|
4167 RmTest.GetClientId(iCurrentClientId); |
|
4168 break; |
|
4169 case EGetResourceId: |
|
4170 RmTest.GetResourceId(resourceId); |
|
4171 break; |
|
4172 case EGetResourceInfo: |
|
4173 RmTest.GetResourceInfo(resourceId); |
|
4174 break; |
|
4175 case EGetNumReosourceInUseByClient: |
|
4176 RmTest.GetNumResourcesInUseByClient(iCurrentClientId); |
|
4177 break; |
|
4178 case EGetInfoOnResourceInUseByClient: |
|
4179 test.Printf(_L("NumResources = %d\n"), Clients[iCurrentClientId].iNumResources); |
|
4180 RmTest.GetInfoOnResourcesInUseByClient(iCurrentClientId, Clients[iCurrentClientId].iNumResources); |
|
4181 break; |
|
4182 case EGetNumClientsUsingResource: |
|
4183 if(resourceId == 0) |
|
4184 { |
|
4185 RmTest.GetNumClientsUsingResource(iCurrentClientId, (TUint)-1); |
|
4186 } |
|
4187 else |
|
4188 { |
|
4189 RmTest.GetNumClientsUsingResource(iCurrentClientId, resourceId); |
|
4190 } |
|
4191 break; |
|
4192 case EGetInfoOnClientsUsingResource: |
|
4193 if(resourceId == 0) |
|
4194 RmTest.GetInfoOnClientsUsingResource((TUint)-1, iMaxClients+1); |
|
4195 else |
|
4196 { |
|
4197 test.Printf(_L("NumResources = %d\n"), Resources[resourceId].iNumClients); |
|
4198 RmTest.GetInfoOnClientsUsingResource(resourceId, Resources[resourceId].iNumClients); |
|
4199 } |
|
4200 break; |
|
4201 case EChangeResourceStateSync: |
|
4202 RmTest.ChangeResourceStateSync(resourceId); |
|
4203 break; |
|
4204 case EChangeResourceStateAsync: |
|
4205 RmTest.ChangeResourceStateAsync(resourceId); |
|
4206 break; |
|
4207 case EGetResourceStateSync: |
|
4208 RmTest.GetResourceStateSync(resourceId); |
|
4209 break; |
|
4210 case EGetResourceStateAsync: |
|
4211 RmTest.GetResourceStateAsync(resourceId); |
|
4212 break; |
|
4213 case ERequestNotificationCond: |
|
4214 RmTest.RequestNotificationCon(resourceId); |
|
4215 break; |
|
4216 case ERequestNotificationUnCond: |
|
4217 RmTest.RequestNotification(resourceId); |
|
4218 break; |
|
4219 case ECancelNotificationCond: |
|
4220 RmTest.CancelNotification(resourceId, ETrue); |
|
4221 break; |
|
4222 case ECancelNotificationUnCond: |
|
4223 RmTest.CancelNotification(resourceId, EFalse); |
|
4224 break; |
|
4225 } |
|
4226 } |
|
4227 //CleanUp |
|
4228 test.Printf(_L("Cleanup of all Clients\n")); |
|
4229 TInt clientCount = Clients.Count(); |
|
4230 for(count = clientCount-1; ((TInt)count) >=0; count--) |
|
4231 { |
|
4232 if(Clients[count].iClientId == 0) |
|
4233 continue; |
|
4234 test.Printf(_L("ClientId deregistration of %d\n"), Clients[count].iClientId); |
|
4235 RmTest.DeRegisterClient(count); |
|
4236 } |
|
4237 Clients.Close(); |
|
4238 } |
|
4239 |
|
4240 GLDEF_C TInt E32Main() |
|
4241 { |
|
4242 test.Title(); |
|
4243 test.Start(_L("Testing Resource Manager...\n")); |
|
4244 test.Next(_L("Load Physical device")); |
|
4245 #ifndef PRM_ENABLE_EXTENDED_VERSION |
|
4246 r = User::LoadPhysicalDevice(KPddFileName); |
|
4247 test(r==KErrNone || r==KErrAlreadyExists); |
|
4248 test.Next(_L("Load Logical Device")); |
|
4249 r=User::LoadLogicalDevice(KLddFileName); |
|
4250 test(r==KErrNone || r==KErrAlreadyExists); |
|
4251 __KHEAP_MARK; //Heap testing is done only for basic version |
|
4252 #else |
|
4253 r = User::LoadPhysicalDevice(KExtPddFileName); |
|
4254 test(r==KErrNone || r==KErrAlreadyExists); |
|
4255 test.Next(_L("Load Logical Device")); |
|
4256 r=User::LoadLogicalDevice(KExtLddFileName); |
|
4257 test(r==KErrNone || r==KErrAlreadyExists); |
|
4258 #endif |
|
4259 r = lddChan.Open(); |
|
4260 test(r==KErrNone || r==KErrAlreadyExists); |
|
4261 //Check whether the notifications recieved as a result of postboot level setting is as expected. |
|
4262 r = lddChan.CheckPostBootLevelNotifications(); |
|
4263 test(r == KErrNone); |
|
4264 TBool regressionTesting = EFalse; |
|
4265 //Parse the command line arguments. |
|
4266 TBuf<0x50> cmd; |
|
4267 User::CommandLine(cmd); |
|
4268 TLex lex(cmd); |
|
4269 lex.SkipSpace(); |
|
4270 if(lex.Get() == '-') |
|
4271 { |
|
4272 TChar letter = lex.Get(); |
|
4273 if((letter == 'R') || (letter == 'r')) |
|
4274 regressionTesting = ETrue; |
|
4275 } |
|
4276 if(regressionTesting) |
|
4277 RmTest.RegressionTest(); |
|
4278 else |
|
4279 RmTest.APIValidationTest(); |
|
4280 test.Printf(_L("Closing the channel\n")); |
|
4281 lddChan.Close(); |
|
4282 test.Printf(_L("Freeing logical device\n")); |
|
4283 #ifndef PRM_ENABLE_EXTENDED_VERSION |
|
4284 __KHEAP_MARKEND; |
|
4285 r = User::FreeLogicalDevice(KLddFileName); |
|
4286 test(r==KErrNone); |
|
4287 r = User::FreePhysicalDevice(KPddFileName); |
|
4288 test(r==KErrNone); |
|
4289 #else |
|
4290 r = User::FreeLogicalDevice(KExtLddFileName); |
|
4291 test(r==KErrNone); |
|
4292 r = User::FreePhysicalDevice(KExtPddFileName); |
|
4293 test(r==KErrNone); |
|
4294 #endif |
|
4295 User::After(100000); |
|
4296 test.End(); |
|
4297 test.Close(); |
|
4298 return KErrNone; |
|
4299 } |
|
4300 |