|
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 test(r == KErrNone); |
|
2180 |
|
2181 GetExtendedResStateAsyncAndVerify(dynamicDepResId[2], 18, dynamicDepResId[0], EFalse); |
|
2182 GetExtendedResStateAsyncAndVerify(dynamicDepResId[3], 1, Clients[2].iClientId, EFalse); |
|
2183 |
|
2184 //Check notifications |
|
2185 r = lddChan.CheckNotifications(dynamicDepResId[2], 0, 0); |
|
2186 test(r == KErrNone); |
|
2187 r = lddChan.CheckNotifications(dynamicDepResId[3], 0, 0); |
|
2188 test(r == KErrNone); |
|
2189 |
|
2190 //Change J to 12 |
|
2191 r = lddChan.ChangeResourceStateSync(Clients[2].iClientId, dynamicDepResId[2],12); |
|
2192 test(r == KErrNone); |
|
2193 |
|
2194 GetExtendedResStateAsyncAndVerify(dynamicDepResId[2], 12, Clients[2].iClientId, EFalse); |
|
2195 |
|
2196 //Check notifications |
|
2197 r = lddChan.CheckNotifications(dynamicDepResId[0], 0, 0); |
|
2198 test(r == KErrNone); |
|
2199 r = lddChan.CheckNotifications(dynamicDepResId[2], 1, 0); |
|
2200 test(r == KErrNone); |
|
2201 r = lddChan.CheckNotifications(dynamicDepResId[3], 0, 0); |
|
2202 test(r == KErrNone); |
|
2203 |
|
2204 //Change H to 90 |
|
2205 TRequestStatus reqSet; |
|
2206 state = 90; |
|
2207 lddChan.CheckParallelExecutionForChangeResState(Clients[2].iClientId, |
|
2208 dynamicDepResId[0],state, |
|
2209 5, 0, reqSet); |
|
2210 User::WaitForRequest(reqSet); |
|
2211 test(reqSet.Int() == KErrNone); |
|
2212 |
|
2213 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[0], -50, Clients[1].iClientId, EFalse); |
|
2214 GetExtendedResStateAndVerify(iStaticDependencyResources[1], -11, iStaticDependencyResources[0]); |
|
2215 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, iStaticDependencyResources[0], EFalse); |
|
2216 GetExtendedResStateAndVerify(iStaticDependencyResources[3], 13, iStaticDependencyResources[0]); |
|
2217 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3], EFalse); |
|
2218 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 69, dynamicDepResId[0]); |
|
2219 GetExtendedResStateAndVerify(dynamicDepResId[0], 90, Clients[2].iClientId); |
|
2220 GetExtendedResStateAsyncAndVerify(dynamicDepResId[1], 1, dynamicDepResId[0]); |
|
2221 GetExtendedResStateAsyncAndVerify(dynamicDepResId[2], 11, dynamicDepResId[0], EFalse); |
|
2222 GetExtendedResStateAndVerify(dynamicDepResId[3], 1, Clients[2].iClientId); |
|
2223 |
|
2224 //Check notifications |
|
2225 r = lddChan.CheckNotifications(iStaticDependencyResources[5], 1, 0); |
|
2226 test(r == KErrNone); |
|
2227 r = lddChan.CheckNotifications(dynamicDepResId[0], 1, 0); |
|
2228 test(r == KErrNone); |
|
2229 r = lddChan.CheckNotifications(dynamicDepResId[1], 0, 0); |
|
2230 test(r == KErrNone); |
|
2231 r = lddChan.CheckNotifications(dynamicDepResId[2], 1, 0); |
|
2232 test(r == KErrNone); |
|
2233 r = lddChan.CheckNotifications(dynamicDepResId[3], 0, 0); |
|
2234 test(r == KErrNone); |
|
2235 |
|
2236 state = 9; |
|
2237 lddChan.ChangeResourceStateAsync(Clients[1].iClientId, dynamicDepResId[2], state, req); |
|
2238 User::WaitForRequest(req); |
|
2239 test(req.Int() == KErrNone); |
|
2240 |
|
2241 GetExtendedResStateAndVerify(dynamicDepResId[0], 90, Clients[2].iClientId); |
|
2242 GetExtendedResStateAsyncAndVerify(dynamicDepResId[1], 1, dynamicDepResId[0]); |
|
2243 GetExtendedResStateAsyncAndVerify(dynamicDepResId[2], 9, Clients[1].iClientId, EFalse); |
|
2244 GetExtendedResStateAndVerify(dynamicDepResId[3], 1, Clients[2].iClientId); |
|
2245 |
|
2246 //Check notifications |
|
2247 r = lddChan.CheckNotifications(dynamicDepResId[0], 0, 0); |
|
2248 test(r == KErrNone); |
|
2249 r = lddChan.CheckNotifications(dynamicDepResId[1], 0, 0); |
|
2250 test(r == KErrNone); |
|
2251 r = lddChan.CheckNotifications(dynamicDepResId[2], 1, 0); |
|
2252 test(r == KErrNone); |
|
2253 r = lddChan.CheckNotifications(dynamicDepResId[3], 0, 0); |
|
2254 test(r == KErrNone); |
|
2255 |
|
2256 //Change D to 50 |
|
2257 state = 50; |
|
2258 lddChan.ChangeResourceStateAsync(Clients[1].iClientId, iStaticDependencyResources[0], state, req); |
|
2259 User::WaitForRequest(req); |
|
2260 test(req.Int() == KErrNone); |
|
2261 |
|
2262 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[0], 50, Clients[1].iClientId, EFalse); |
|
2263 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -12, iStaticDependencyResources[0], EFalse); |
|
2264 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, iStaticDependencyResources[0], EFalse); |
|
2265 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[3], 16, iStaticDependencyResources[0], EFalse); |
|
2266 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3], EFalse); |
|
2267 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[5], 67, iStaticDependencyResources[3], EFalse); |
|
2268 GetExtendedResStateAndVerify(dynamicDepResId[0], 90, Clients[2].iClientId); |
|
2269 GetExtendedResStateAsyncAndVerify(dynamicDepResId[1], 1, dynamicDepResId[0]); |
|
2270 GetExtendedResStateAsyncAndVerify(dynamicDepResId[2], 9, Clients[1].iClientId, EFalse); |
|
2271 GetExtendedResStateAndVerify(dynamicDepResId[3], 1, Clients[2].iClientId); |
|
2272 |
|
2273 //Check notifications |
|
2274 r = lddChan.CheckNotifications(iStaticDependencyResources[5], 1, 0); |
|
2275 test(r == KErrNone); |
|
2276 //DeRegister dependency between J and K |
|
2277 r = lddChan.DeRegisterResourceDependency(Clients[0].iClientId, dynamicDepResId[3], dynamicDepResId[2]); |
|
2278 test(r == KErrNone); |
|
2279 |
|
2280 RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[3], 0, &depResArray[0]); |
|
2281 |
|
2282 depResArray[0].iResourceId = dynamicDepResId[0]; |
|
2283 depResArray[0].iDependencyPriority = 1; |
|
2284 RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[2], 1, &depResArray[0]); |
|
2285 |
|
2286 //Change J t0 13 |
|
2287 r = lddChan.ChangeResourceStateSync(Clients[1].iClientId, dynamicDepResId[2], 13); |
|
2288 test(r == KErrNone); |
|
2289 |
|
2290 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[0], 50, Clients[1].iClientId, EFalse); |
|
2291 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -12, iStaticDependencyResources[0], EFalse); |
|
2292 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, iStaticDependencyResources[0], EFalse); |
|
2293 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[3], 16, iStaticDependencyResources[0], EFalse); |
|
2294 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3], EFalse); |
|
2295 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[5], 67, iStaticDependencyResources[3], EFalse); |
|
2296 GetExtendedResStateAndVerify(dynamicDepResId[0], 90, Clients[2].iClientId); |
|
2297 GetExtendedResStateAsyncAndVerify(dynamicDepResId[1], 1, dynamicDepResId[0]); |
|
2298 GetExtendedResStateAsyncAndVerify(dynamicDepResId[2], 12, Clients[2].iClientId, EFalse); |
|
2299 GetExtendedResStateAndVerify(dynamicDepResId[3], 1, Clients[2].iClientId); |
|
2300 //Check notifications |
|
2301 r = lddChan.CheckNotifications(dynamicDepResId[2], 1, 0); |
|
2302 test(r == KErrNone); |
|
2303 /* Remove client level from resource 7 */ |
|
2304 r = lddChan.DeRegisterClientLevelFromResource(Clients[2].iClientId, dynamicDepResId[3]); |
|
2305 test(r == KErrNone); |
|
2306 |
|
2307 GetExtendedResStateAndVerify(dynamicDepResId[3], 0, -1); |
|
2308 //Check notifications |
|
2309 r = lddChan.CheckNotifications(dynamicDepResId[3], 1, 0); |
|
2310 test(r == KErrNone); |
|
2311 |
|
2312 r = lddChan.DeRegisterDynamicResource(Clients[0].iClientId, dynamicDepResId[3], NULL); |
|
2313 test(r == KErrNone); |
|
2314 //Check notifications |
|
2315 r = lddChan.CheckNotifications(dynamicDepResId[3], 1, 0); |
|
2316 test(r == KErrNone); |
|
2317 |
|
2318 //Deregister dependency between H and J |
|
2319 r = lddChan.DeRegisterResourceDependency(Clients[0].iClientId, dynamicDepResId[2], dynamicDepResId[0]); |
|
2320 test(r == KErrNone); |
|
2321 |
|
2322 RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[2], 0, &depResArray[0]); |
|
2323 |
|
2324 depResArray[0].iResourceId = dynamicDepResId[1]; |
|
2325 depResArray[0].iDependencyPriority = 1; |
|
2326 depResArray[1].iResourceId = iStaticDependencyResources[5]; |
|
2327 depResArray[1].iDependencyPriority = 3; |
|
2328 RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[0], 2, &depResArray[0]); |
|
2329 |
|
2330 /* Remove client level from resource 7 */ |
|
2331 r = lddChan.DeRegisterClientLevelFromResource(Clients[1].iClientId, dynamicDepResId[2]); |
|
2332 test(r == KErrNone); |
|
2333 |
|
2334 GetExtendedResStateAndVerify(dynamicDepResId[2], 12, Clients[2].iClientId); |
|
2335 //Check notifications |
|
2336 r = lddChan.CheckNotifications(dynamicDepResId[2], 0, 0); |
|
2337 test(r == KErrNone); |
|
2338 |
|
2339 r = lddChan.DeRegisterClient(Clients[2].iClientId); |
|
2340 test(r == KErrNone); |
|
2341 |
|
2342 GetExtendedResStateAsyncAndVerify(dynamicDepResId[2], 19, -1, EFalse); |
|
2343 |
|
2344 //Deregister dependency between G and H |
|
2345 r = lddChan.DeRegisterResourceDependency(Clients[1].iClientId, iStaticDependencyResources[5], dynamicDepResId[0]); |
|
2346 test(r == KErrNone); |
|
2347 |
|
2348 depResArray[0].iResourceId = dynamicDepResId[1]; |
|
2349 depResArray[0].iDependencyPriority = 1; |
|
2350 RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[0], 1, &depResArray[0]); |
|
2351 |
|
2352 depResArray[0].iResourceId = iStaticDependencyResources[3]; |
|
2353 depResArray[0].iDependencyPriority = 1; |
|
2354 RmTest.CheckForDependencyInformation(Clients[0].iClientId, iStaticDependencyResources[5], 1, &depResArray[0]); |
|
2355 |
|
2356 GetExtendedResStateAndVerify(dynamicDepResId[0], 75, -1); |
|
2357 GetExtendedResStateAsyncAndVerify(dynamicDepResId[1], 0, dynamicDepResId[0]); |
|
2358 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[5], 67, iStaticDependencyResources[3], EFalse); |
|
2359 |
|
2360 //Deregister dependency between I and H |
|
2361 r = lddChan.DeRegisterResourceDependency(Clients[1].iClientId, dynamicDepResId[1], dynamicDepResId[0]); |
|
2362 test(r == KErrNone); |
|
2363 |
|
2364 RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[0], 0, &depResArray[0]); |
|
2365 |
|
2366 RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[1], 0, &depResArray[0]); |
|
2367 |
|
2368 GetExtendedResStateAndVerify(dynamicDepResId[0], 75, -1); |
|
2369 GetExtendedResStateAsyncAndVerify(dynamicDepResId[1], 0, -1); |
|
2370 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[5], 67, iStaticDependencyResources[3], EFalse); |
|
2371 //Check notifications |
|
2372 r = lddChan.CheckNotifications(iStaticDependencyResources[5], 0, 0); |
|
2373 test(r == KErrNone); |
|
2374 r = lddChan.CheckNotifications(dynamicDepResId[1], 1, 0); |
|
2375 test(r == KErrNone); |
|
2376 |
|
2377 r = lddChan.DeRegisterDynamicResource(Clients[0].iClientId, dynamicDepResId[2], NULL); |
|
2378 test(r == KErrNone); |
|
2379 r = lddChan.DeRegisterDynamicResource(Clients[0].iClientId, dynamicDepResId[1], NULL); |
|
2380 test(r == KErrNone); |
|
2381 //Check notifications |
|
2382 r = lddChan.CheckNotifications(dynamicDepResId[1], 1, 0); |
|
2383 test(r == KErrNone); |
|
2384 r = lddChan.DeRegisterDynamicResource(Clients[0].iClientId, dynamicDepResId[0], NULL); |
|
2385 test(r == KErrNone); |
|
2386 r = lddChan.DeRegisterClient(Clients[1].iClientId); |
|
2387 test(r == KErrNone); |
|
2388 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[0], -100, -1, EFalse); |
|
2389 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -10, iStaticDependencyResources[0], EFalse); |
|
2390 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 0, iStaticDependencyResources[0], EFalse); |
|
2391 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[3], 10, iStaticDependencyResources[0], EFalse); |
|
2392 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 1, iStaticDependencyResources[3], EFalse); |
|
2393 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[5], 75, iStaticDependencyResources[3], EFalse); |
|
2394 r = lddChan.DeRegisterClient(Clients[3].iClientId); |
|
2395 test(r == KErrNone); |
|
2396 |
|
2397 r = lddChan.DeRegisterClient(Clients[0].iClientId); |
|
2398 test(r == KErrNone); |
|
2399 |
|
2400 r = lddChan.DeRegisterClient(Clients[4].iClientId); |
|
2401 test(r == KErrNone); |
|
2402 |
|
2403 depResArray.Close(); |
|
2404 return; |
|
2405 } |
|
2406 |
|
2407 //---------------------------------------------------------------------------------------------- |
|
2408 //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0596 |
|
2409 //! @SYMTestType UT |
|
2410 //! @SYMPREQ PREQ1398 |
|
2411 //! @SYMTestCaseDesc This test case tests dynamic resources which does not support dependency |
|
2412 //! @SYMTestActions 0 Register clients |
|
2413 //! 1 Register dynamic resource |
|
2414 //! 2 Register notifications |
|
2415 //! 3 Change Resource State of each static resource with dependency |
|
2416 //! 4 Get state of the resource and check for correctness |
|
2417 //! 5 Check notification count for correctness |
|
2418 //! 6 Deregister client level |
|
2419 //! 7 Deregister dynamic resource |
|
2420 //! 8 Deregister clients |
|
2421 //! |
|
2422 //! @SYMTestExpectedResults 0 API should return with KErrNone, panics otherwise. |
|
2423 //! 1 API should return with KErrNone, panics otherwise. |
|
2424 //! 2 API should return with KErrNone, panics otherwise. |
|
2425 //! 3 API should return with KErrNone, panics otherwise. |
|
2426 //! 4 API should return with KErrNone, panics otherwise. |
|
2427 //! 5 API should return with KErrNone, panics otherwise. |
|
2428 //! 6 API should return with KErrNone, panics otherwise. |
|
2429 //! 7 API should return with KErrNone, panics otherwise. |
|
2430 //! 8 API should return with KErrNone, panics otherwise. |
|
2431 //! @SYMTestPriority High |
|
2432 //! @SYMTestStatus Implemented |
|
2433 //---------------------------------------------------------------------------------------------- |
|
2434 void TestRM::TestDynamicResource() |
|
2435 { |
|
2436 TInt state; |
|
2437 TRequestStatus req; |
|
2438 TUint dynamicResId[4]; |
|
2439 |
|
2440 test.Next(_L("Testing dynamic resource")); |
|
2441 //Register client 1 |
|
2442 RmTest.RegisterClient(); |
|
2443 //Register client 2 |
|
2444 RmTest.RegisterClient(); |
|
2445 //Register client 3 |
|
2446 RmTest.RegisterClient(); |
|
2447 |
|
2448 NegativeTesting = EFalse; |
|
2449 dynamicResId[0] = 1; |
|
2450 //Register dynamic resource 1 |
|
2451 r = lddChan.RegisterDynamicResource(Clients[0].iClientId, dynamicResId[0]); |
|
2452 test(r == KErrNone); |
|
2453 //Deregister dynamic resource with different client id |
|
2454 r = lddChan.DeRegisterDynamicResource(Clients[1].iClientId, dynamicResId[0], NULL); |
|
2455 test(r == KErrAccessDenied); |
|
2456 dynamicResId[1] = 2; |
|
2457 //Register dynamic resource 2 |
|
2458 r = lddChan.RegisterDynamicResource(Clients[1].iClientId, dynamicResId[1]); |
|
2459 test(r == KErrNone); |
|
2460 RmTest.GetNumResourcesInUseByClient(iCurrentClientId); |
|
2461 RmTest.GetInfoOnResourcesInUseByClient(iCurrentClientId, iMaxStaticResources); |
|
2462 |
|
2463 TUint numClients; |
|
2464 r = lddChan.GetNumClientsUsingResource(Clients[0].iClientId, dynamicResId[0], numClients); |
|
2465 test(r == KErrNone); |
|
2466 test(numClients == 0); |
|
2467 |
|
2468 r = lddChan.RequestNotification(Clients[1].iClientId, dynamicResId[0]); |
|
2469 test(r == KErrNone); |
|
2470 //Register client 4 |
|
2471 RmTest.RegisterClient(); |
|
2472 r = lddChan.RequestNotification(Clients[2].iClientId, dynamicResId[0], 1, 1); |
|
2473 test(r == KErrNone); |
|
2474 //Change state of dynamic resource 1 and verify |
|
2475 state = 1; |
|
2476 lddChan.ChangeResourceStateAsync(Clients[0].iClientId, dynamicResId[0], state, req); |
|
2477 User::WaitForRequest(req); |
|
2478 test(req.Int() == KErrNone); |
|
2479 |
|
2480 r = lddChan.CheckNotifications(dynamicResId[0], 1, 1); |
|
2481 test(r == KErrNone); |
|
2482 |
|
2483 GetExtendedResStateAsyncAndVerify(dynamicResId[0], 1, Clients[0].iClientId, EFalse); |
|
2484 |
|
2485 r = lddChan.GetNumClientsUsingResource(Clients[0].iClientId, dynamicResId[0], numClients); |
|
2486 test(r == KErrNone); |
|
2487 test(numClients == 1); |
|
2488 //Change state of dynamic resource 1. |
|
2489 r = lddChan.ChangeResourceStateSync(Clients[1].iClientId, dynamicResId[0], 0); |
|
2490 test(r == KErrAccessDenied); |
|
2491 //Deregister dynamic resource 1 and set the resource to 1. |
|
2492 state = 1; |
|
2493 r = lddChan.DeRegisterDynamicResource(Clients[0].iClientId, dynamicResId[0], &state); |
|
2494 test(r == KErrNone); |
|
2495 |
|
2496 r = lddChan.CheckNotifications(dynamicResId[0], 1, 1); |
|
2497 test(r == KErrNone); |
|
2498 |
|
2499 r = lddChan.GetNumClientsUsingResource(Clients[0].iClientId, dynamicResId[0], numClients); |
|
2500 test(r == KErrNotFound); |
|
2501 //Register client 5 |
|
2502 RmTest.RegisterClient(); |
|
2503 |
|
2504 GetExtendedResStateAndVerify(dynamicResId[1], -5, -1); |
|
2505 |
|
2506 r = lddChan.RequestNotification(Clients[1].iClientId, dynamicResId[1]); |
|
2507 test(r == KErrNone); |
|
2508 |
|
2509 r = lddChan.RequestNotification(Clients[2].iClientId, dynamicResId[1], 0, -8); |
|
2510 test(r == KErrNone); |
|
2511 //Change state of dynamic resource 1 and verify |
|
2512 state = -7; |
|
2513 lddChan.ChangeResourceStateAsync(Clients[2].iClientId, dynamicResId[1], state, req); |
|
2514 User::WaitForRequest(req); |
|
2515 test(req.Int() == KErrNone); |
|
2516 |
|
2517 r = lddChan.CheckNotifications(dynamicResId[1], 1, 0); |
|
2518 test(r == KErrNone); |
|
2519 |
|
2520 GetExtendedResStateAndVerify(dynamicResId[1], -7, Clients[2].iClientId); |
|
2521 //Register client 6 |
|
2522 RmTest.RegisterClient(); |
|
2523 //Register client 7 |
|
2524 RmTest.RegisterClient(); |
|
2525 //Change state of dynamic resource 2 and verify |
|
2526 state = -9; |
|
2527 lddChan.ChangeResourceStateAsync(Clients[3].iClientId, dynamicResId[1], state, req); |
|
2528 User::WaitForRequest(req); |
|
2529 test(req.Int() == KErrNone); |
|
2530 |
|
2531 r = lddChan.CheckNotifications(dynamicResId[1], 1, 1); |
|
2532 test(r == KErrNone); |
|
2533 |
|
2534 GetExtendedResStateAsyncAndVerify(dynamicResId[1], -9, Clients[3].iClientId, EFalse); |
|
2535 //Change state of dynamic resource 1 and verify |
|
2536 state = -10; |
|
2537 lddChan.ChangeResourceStateAsync(Clients[4].iClientId, dynamicResId[1], state, req); |
|
2538 User::WaitForRequest(req); |
|
2539 test(req.Int() == KErrNone); |
|
2540 |
|
2541 r = lddChan.CheckNotifications(dynamicResId[1], 1, 0); |
|
2542 test(r == KErrNone); |
|
2543 |
|
2544 GetExtendedResStateAsyncAndVerify(dynamicResId[1], -10, Clients[4].iClientId, EFalse); |
|
2545 |
|
2546 lddChan.ChangeResourceStateSync(Clients[5].iClientId, dynamicResId[1], state); |
|
2547 test(r == KErrNone); |
|
2548 |
|
2549 r = lddChan.CheckNotifications(dynamicResId[1], 0, 0); |
|
2550 test(r == KErrNone); |
|
2551 |
|
2552 GetExtendedResStateAsyncAndVerify(dynamicResId[1], -10, Clients[4].iClientId, EFalse); |
|
2553 //Change state of dynamic resource 1 and verify |
|
2554 state = -6; |
|
2555 lddChan.ChangeResourceStateSync(Clients[6].iClientId, dynamicResId[1], state); |
|
2556 test(r == KErrNone); |
|
2557 |
|
2558 r = lddChan.CheckNotifications(dynamicResId[1], 0, 0); |
|
2559 test(r == KErrNone); |
|
2560 |
|
2561 GetExtendedResStateAsyncAndVerify(dynamicResId[1], -10, Clients[4].iClientId, EFalse); |
|
2562 |
|
2563 r = lddChan.DeRegisterClientLevelFromResource(Clients[4].iClientId, dynamicResId[1]); |
|
2564 test(r == KErrNone); |
|
2565 |
|
2566 GetExtendedResStateAsyncAndVerify(dynamicResId[1], -10, Clients[5].iClientId, EFalse); |
|
2567 |
|
2568 r = lddChan.DeRegisterClientLevelFromResource(Clients[5].iClientId, dynamicResId[1]); |
|
2569 test(r == KErrNone); |
|
2570 |
|
2571 r = lddChan.CheckNotifications(dynamicResId[1], 1, 0); |
|
2572 test(r == KErrNone); |
|
2573 GetExtendedResStateAsyncAndVerify(dynamicResId[1], -9, Clients[3].iClientId, EFalse); |
|
2574 //Deregister client 4 |
|
2575 r = lddChan.DeRegisterClient(Clients[3].iClientId); |
|
2576 test(r == KErrNone); |
|
2577 |
|
2578 r = lddChan.CheckNotifications(dynamicResId[1], 1, 0); |
|
2579 test(r == KErrNone); |
|
2580 GetExtendedResStateAsyncAndVerify(dynamicResId[1], -7, Clients[2].iClientId, EFalse); |
|
2581 |
|
2582 r = lddChan.DeRegisterClientLevelFromResource(Clients[2].iClientId, dynamicResId[1]); |
|
2583 test(r == KErrNone); |
|
2584 |
|
2585 r = lddChan.CheckNotifications(dynamicResId[1], 1, 0); |
|
2586 test(r == KErrNone); |
|
2587 GetExtendedResStateAsyncAndVerify(dynamicResId[1], -6, Clients[6].iClientId, EFalse); |
|
2588 |
|
2589 r = lddChan.DeRegisterClientLevelFromResource(Clients[6].iClientId, dynamicResId[1]); |
|
2590 test(r == KErrNone); |
|
2591 |
|
2592 r = lddChan.CheckNotifications(dynamicResId[1], 1, 0); |
|
2593 test(r == KErrNone); |
|
2594 GetExtendedResStateAsyncAndVerify(dynamicResId[1], -5, -1, EFalse); |
|
2595 //Deregister dynamic resource 2 |
|
2596 r = lddChan.DeRegisterDynamicResource(Clients[1].iClientId, dynamicResId[1], NULL); |
|
2597 test(r == KErrNone); |
|
2598 |
|
2599 r = lddChan.CheckNotifications(dynamicResId[1], 1, 1); |
|
2600 test(r == KErrNone); |
|
2601 //Register dynamic resource 3 |
|
2602 dynamicResId[2] = 3; |
|
2603 r = lddChan.RegisterDynamicResource(Clients[2].iClientId, dynamicResId[2]); |
|
2604 test(r == KErrNone); |
|
2605 //Register dynamic resource 4 |
|
2606 dynamicResId[3] = 4; |
|
2607 r = lddChan.RegisterDynamicResource(Clients[6].iClientId, dynamicResId[3]); |
|
2608 test(r == KErrNone); |
|
2609 //Change state of dynamic resource 3 to 0 |
|
2610 r = lddChan.ChangeResourceStateSync(Clients[4].iClientId, dynamicResId[2], 0); |
|
2611 test(r == KErrNone); |
|
2612 GetExtendedResStateAndVerify(dynamicResId[2], 0, Clients[4].iClientId); |
|
2613 //Change state of dynamic resource 3 to 1 |
|
2614 r = lddChan.ChangeResourceStateSync(Clients[5].iClientId, dynamicResId[2], 1); |
|
2615 test(r == KErrNone); |
|
2616 GetExtendedResStateAndVerify(dynamicResId[2], 0, Clients[4].iClientId); |
|
2617 //Deregister client 5 |
|
2618 r = lddChan.DeRegisterClient(Clients[4].iClientId); |
|
2619 test(r == KErrNone); |
|
2620 GetExtendedResStateAndVerify(dynamicResId[2], 1, Clients[5].iClientId); |
|
2621 //Deregister dynamic resource 3 |
|
2622 r = lddChan.DeRegisterDynamicResource(Clients[2].iClientId, dynamicResId[2], NULL); |
|
2623 test(r == KErrInUse); |
|
2624 //Deregister client 6 |
|
2625 r = lddChan.DeRegisterClient(Clients[5].iClientId); |
|
2626 test(r == KErrNone); |
|
2627 GetExtendedResStateAndVerify(dynamicResId[2], 1, -1); |
|
2628 //Deregister dynamic resource 3 |
|
2629 r = lddChan.DeRegisterDynamicResource(Clients[2].iClientId, dynamicResId[2], NULL); |
|
2630 test(r == KErrNone); |
|
2631 //Change state of dynamic resource 4 to 15 |
|
2632 r = lddChan.ChangeResourceStateSync(Clients[6].iClientId, dynamicResId[3], 15); |
|
2633 test(r == KErrNone); |
|
2634 GetExtendedResStateAndVerify(dynamicResId[3], 15, Clients[6].iClientId); |
|
2635 //Change state of resource and try to deregister the resource while the change is taking place |
|
2636 state = 17; |
|
2637 lddChan.ChangeResStateAndDeRegisterDynamicRes(Clients[6].iClientId, dynamicResId[3], state, req); |
|
2638 User::WaitForRequest(req); |
|
2639 test(req.Int() == KErrNone); |
|
2640 test(state == 17); |
|
2641 GetExtendedResStateAndVerify(dynamicResId[3], 17, Clients[6].iClientId); |
|
2642 //Deregister dynamic resource 4 with some other client which is not owner |
|
2643 r = lddChan.DeRegisterDynamicResource(Clients[2].iClientId, dynamicResId[3], NULL); |
|
2644 test(r == KErrAccessDenied); |
|
2645 //Deregister dynamic resource 4 |
|
2646 r = lddChan.DeRegisterDynamicResource(Clients[6].iClientId, dynamicResId[3], NULL); |
|
2647 test(r == KErrNone); |
|
2648 //Deregister client 7 |
|
2649 r = lddChan.DeRegisterClient(Clients[6].iClientId); |
|
2650 test(r == KErrNone); |
|
2651 //Deregister client 3 |
|
2652 r = lddChan.DeRegisterClient(Clients[2].iClientId); |
|
2653 test(r == KErrNone); |
|
2654 //Deregister client 2 |
|
2655 r = lddChan.DeRegisterClient(Clients[1].iClientId); |
|
2656 test(r == KErrNone); |
|
2657 //Deregister client 1 |
|
2658 r = lddChan.DeRegisterClient(Clients[0].iClientId); |
|
2659 test(r == KErrNone); |
|
2660 Clients.Close(); |
|
2661 } |
|
2662 |
|
2663 //This function gets extended resource state synchronously and verifies for correctness |
|
2664 void TestRM::GetExtendedResStateAndVerify(TUint aResId, TInt aState, TInt aLevelOwnerId) |
|
2665 { |
|
2666 static TBool cached = ETrue; |
|
2667 TInt state; |
|
2668 TInt levelOwnerId; |
|
2669 r = lddChan.GetResourceStateSync(Clients[0].iClientId, aResId, cached, state, levelOwnerId); |
|
2670 test(r == KErrNone); |
|
2671 test(state == aState); |
|
2672 test(levelOwnerId == aLevelOwnerId); |
|
2673 return; |
|
2674 } |
|
2675 |
|
2676 //This function gets extended resource state asynchronously and verifies for correctness |
|
2677 void TestRM::GetExtendedResStateAsyncAndVerify(TUint aResId, TInt aState, TInt aLevelOwnerId, TBool aReqCancel) |
|
2678 { |
|
2679 static TBool cached = ETrue; |
|
2680 TRequestStatus resGet; |
|
2681 TInt levelOwnerId; |
|
2682 TInt state; |
|
2683 lddChan.GetResourceStateAsync(Clients[0].iClientId, aResId, cached, resGet, state, levelOwnerId, aReqCancel); |
|
2684 User::WaitForRequest(resGet); |
|
2685 if(aReqCancel && (resGet.Int() != KErrNone)) |
|
2686 { |
|
2687 test((resGet.Int() == KErrCompletion) || (resGet.Int() == KErrCancel)); |
|
2688 return; |
|
2689 } |
|
2690 test(resGet.Int() == KErrNone); |
|
2691 test(state == aState); |
|
2692 test(levelOwnerId == aLevelOwnerId); |
|
2693 } |
|
2694 |
|
2695 //This function validates number of dependency resource and their id's for correctness |
|
2696 void TestRM::CheckForDependencyInformation(TUint aClientId, TUint aResourceId, TUint aNumDependents, SResourceDependencyInfo* aDepResIdArray) |
|
2697 { |
|
2698 TUint numDepResources; |
|
2699 |
|
2700 //Get the number of dependent's for the resource |
|
2701 r = lddChan.GetNumDependentsForResource(aClientId, aResourceId, numDepResources); |
|
2702 if(r != KErrNone) |
|
2703 test.Printf(_L("GetNumDependentsForResource returned with %d\n"), r); |
|
2704 test(r == KErrNone); |
|
2705 if(aNumDependents != numDepResources) |
|
2706 test.Printf(_L("aNumDependents = %d, numDepResource = %d\n"), aNumDependents, numDepResources); |
|
2707 test(aNumDependents == numDepResources); |
|
2708 if(numDepResources == 0) |
|
2709 return; |
|
2710 //Get the dependent's id |
|
2711 RBuf8 info; |
|
2712 info.Create(aNumDependents * sizeof(SResourceDependencyInfo)); |
|
2713 r = lddChan.GetDependentsIdForResource(aClientId, aResourceId, (TAny*)&info, numDepResources); |
|
2714 if(r != KErrNone) |
|
2715 { |
|
2716 test.Printf(_L("GetDependentsIdForResource returned with %d\n"), r); |
|
2717 info.Close(); |
|
2718 } |
|
2719 test(r == KErrNone); |
|
2720 if(aNumDependents != numDepResources) |
|
2721 { |
|
2722 test.Printf(_L("aNumDependents = %d, numDepResource = %d\n"), aNumDependents, numDepResources); |
|
2723 info.Close(); |
|
2724 } |
|
2725 test(aNumDependents == numDepResources); |
|
2726 SResourceDependencyInfo* sResDepInfoPtr = (SResourceDependencyInfo*)info.Ptr(); |
|
2727 for(TUint count = 0; count < aNumDependents; count++, sResDepInfoPtr++) |
|
2728 { |
|
2729 if(sResDepInfoPtr->iResourceId != aDepResIdArray[count].iResourceId) |
|
2730 { |
|
2731 test.Printf(_L("Expected resourceId : %d, Returned ResourceId = %d\n"),sResDepInfoPtr->iResourceId, |
|
2732 aDepResIdArray[count].iResourceId); |
|
2733 info.Close(); |
|
2734 test(0); |
|
2735 } |
|
2736 if(sResDepInfoPtr->iDependencyPriority != aDepResIdArray[count].iDependencyPriority) |
|
2737 { |
|
2738 test.Printf(_L("Expected resource priority : %d, Returned resource priority = %d\n"),sResDepInfoPtr->iDependencyPriority, |
|
2739 aDepResIdArray[count].iDependencyPriority); |
|
2740 info.Close(); |
|
2741 test(0); |
|
2742 } |
|
2743 } |
|
2744 info.Close(); |
|
2745 return; |
|
2746 } |
|
2747 |
|
2748 //---------------------------------------------------------------------------------------------- |
|
2749 //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0595 |
|
2750 //! @SYMTestType UT |
|
2751 //! @SYMPREQ PREQ1398 |
|
2752 //! @SYMTestCaseDesc This test case tests static resources with dependency. |
|
2753 //! @SYMTestActions 0 Register clients |
|
2754 //! 1 Check dependency information of each resource |
|
2755 //! 2 Register notifications |
|
2756 //! 3 Change Resource State of each static resource with dependency |
|
2757 //! 4 Get state of the resources and verify them for correctness |
|
2758 //! 5 Check notification count for correctness |
|
2759 //! 6 Deregister client level |
|
2760 //! 7 Deregister clients |
|
2761 //! |
|
2762 //! @SYMTestExpectedResults 0 API should return with KErrNone, panics otherwise. |
|
2763 //! 1 API should return with KErrNone, panics otherwise. |
|
2764 //! 2 API should return with KErrNone, panics otherwise. |
|
2765 //! 3 API should return with KErrNone, panics otherwise. |
|
2766 //! 4 API should return with KErrNone, panics otherwise. |
|
2767 //! 5 API should return with KErrNone, panics otherwise. |
|
2768 //! 6 API should return with KErrNone, panics otherwise. |
|
2769 //! 7 API should return with KErrNone, panics otherwise. |
|
2770 //! @SYMTestPriority High |
|
2771 //! @SYMTestStatus Implemented |
|
2772 //---------------------------------------------------------------------------------------------- |
|
2773 void TestRM::TestStaticResourceWithDependency() |
|
2774 { |
|
2775 TUint count; |
|
2776 RArray<SResourceDependencyInfo>depResArray; |
|
2777 SResourceDependencyInfo sResDepInfo; |
|
2778 TUint numClients; // The maximum no. of dependents in the dependency tree. |
|
2779 |
|
2780 |
|
2781 //Register client 1. |
|
2782 RmTest.RegisterClient(); |
|
2783 iCurrentClientId = -1; |
|
2784 TInt state; |
|
2785 TRequestStatus reqSet; |
|
2786 |
|
2787 NegativeTesting = EFalse; |
|
2788 test.Next(_L("\nTesting static resource with dependency....")); |
|
2789 |
|
2790 //Check for resource dependency information of Resource D |
|
2791 sResDepInfo.iResourceId = iStaticDependencyResources[1]; |
|
2792 sResDepInfo.iDependencyPriority = 1; |
|
2793 depResArray.Append(sResDepInfo); |
|
2794 sResDepInfo.iResourceId = iStaticDependencyResources[3]; |
|
2795 sResDepInfo.iDependencyPriority = 2; |
|
2796 depResArray.Append(sResDepInfo); |
|
2797 sResDepInfo.iResourceId = iStaticDependencyResources[2]; |
|
2798 sResDepInfo.iDependencyPriority = 3; |
|
2799 depResArray.Append(sResDepInfo); |
|
2800 RmTest.CheckForDependencyInformation(Clients[0].iClientId, iStaticDependencyResources[0], 3, &depResArray[0]); |
|
2801 |
|
2802 //Check for resource dependency information of Resource E |
|
2803 depResArray[0].iResourceId = iStaticDependencyResources[4]; |
|
2804 depResArray[0].iDependencyPriority = 1; |
|
2805 depResArray[1].iResourceId = iStaticDependencyResources[5]; |
|
2806 depResArray[1].iDependencyPriority = 2; |
|
2807 depResArray[2].iResourceId = iStaticDependencyResources[0]; |
|
2808 depResArray[2].iDependencyPriority = 3; |
|
2809 RmTest.CheckForDependencyInformation(Clients[0].iClientId, iStaticDependencyResources[3], 3, &depResArray[0]); |
|
2810 |
|
2811 //Check for resource dependency information of Resource C |
|
2812 depResArray[0].iResourceId = iStaticDependencyResources[3]; |
|
2813 depResArray[0].iDependencyPriority = 1; |
|
2814 RmTest.CheckForDependencyInformation(Clients[0].iClientId, iStaticDependencyResources[4], 1, &depResArray[0]); |
|
2815 |
|
2816 //Check for resource dependency information of Resource G |
|
2817 RmTest.CheckForDependencyInformation(Clients[0].iClientId, iStaticDependencyResources[5], 1, &depResArray[0]); |
|
2818 |
|
2819 //Check for resource dependency information of Resource F |
|
2820 depResArray[0].iResourceId = iStaticDependencyResources[0]; |
|
2821 depResArray[0].iDependencyPriority = 1; |
|
2822 RmTest.CheckForDependencyInformation(Clients[0].iClientId, iStaticDependencyResources[2], 1, &depResArray[0]); |
|
2823 |
|
2824 //Check for resource dependency information of Resource A |
|
2825 RmTest.CheckForDependencyInformation(Clients[0].iClientId, iStaticDependencyResources[1], 1, &depResArray[0]); |
|
2826 |
|
2827 RmTest.GetNumResourcesInUseByClient(iCurrentClientId); |
|
2828 RmTest.GetInfoOnResourcesInUseByClient(iCurrentClientId, iMaxStaticResources + iMaxStaticDependentResources); |
|
2829 iCurrentClientId = 0; |
|
2830 //Get resource state of all dependent resource and verify |
|
2831 GetExtendedResStateAndVerify(iStaticDependencyResources[0], -50, -1); |
|
2832 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -11, iStaticDependencyResources[0]); |
|
2833 GetExtendedResStateAndVerify(iStaticDependencyResources[2], 1, iStaticDependencyResources[0]); |
|
2834 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[3], 13, iStaticDependencyResources[0]); |
|
2835 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); |
|
2836 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 73, iStaticDependencyResources[3]); |
|
2837 |
|
2838 r = lddChan.GetNumClientsUsingResource(Clients[0].iClientId, iStaticDependencyResources[3], numClients); |
|
2839 test(r == KErrNone); |
|
2840 test(numClients == 0); |
|
2841 //Request notification |
|
2842 for(count = 0; count < iMaxStaticDependentResources; count++) |
|
2843 { |
|
2844 r = lddChan.RequestNotification(Clients[0].iClientId, iStaticDependencyResources[count]); |
|
2845 test(r == KErrNone); |
|
2846 } |
|
2847 //Change state of resource A to -11 and verify |
|
2848 r = lddChan.ChangeResourceStateSync(Clients[0].iClientId, iStaticDependencyResources[1], -11); |
|
2849 test(r == KErrNone); |
|
2850 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -11, Clients[0].iClientId); |
|
2851 //Change state of resource A to -12 and verify |
|
2852 state = -12; |
|
2853 lddChan.ChangeResourceStateAsync(Clients[0].iClientId, iStaticDependencyResources[1], state, reqSet); |
|
2854 User::WaitForRequest(reqSet); |
|
2855 test(reqSet.Int() == KErrNone); |
|
2856 r = lddChan.CheckNotifications(iStaticDependencyResources[1], 1, 0); |
|
2857 test(r == KErrNone); |
|
2858 //Register client2 |
|
2859 RmTest.RegisterClient(); |
|
2860 //Change state of resource D to -49 and verify |
|
2861 state = -49; |
|
2862 lddChan.ChangeResourceStateAsync(Clients[1].iClientId, iStaticDependencyResources[0], state, reqSet); |
|
2863 User::WaitForRequest(reqSet); |
|
2864 test(reqSet.Int() == KErrNone); |
|
2865 //Check for notifications |
|
2866 r = lddChan.CheckNotifications(iStaticDependencyResources[0], 1, 0); |
|
2867 test(r == KErrNone); |
|
2868 r = lddChan.CheckNotifications(iStaticDependencyResources[1], 1, 0); |
|
2869 test(r == KErrNone); |
|
2870 r = lddChan.CheckNotifications(iStaticDependencyResources[3], 1, 0); |
|
2871 test(r == KErrNone); |
|
2872 r = lddChan.CheckNotifications(iStaticDependencyResources[5], 1, 0); |
|
2873 test(r == KErrNone); |
|
2874 //Get the state and verify for correctness |
|
2875 GetExtendedResStateAndVerify(iStaticDependencyResources[0], -49, Clients[1].iClientId); |
|
2876 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -13, iStaticDependencyResources[0]); |
|
2877 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, iStaticDependencyResources[0]); |
|
2878 GetExtendedResStateAndVerify(iStaticDependencyResources[3], 16, iStaticDependencyResources[0]); |
|
2879 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); |
|
2880 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 71, iStaticDependencyResources[3]); |
|
2881 //Change state of resource F to 1 and verify |
|
2882 r = lddChan.ChangeResourceStateSync(Clients[1].iClientId, iStaticDependencyResources[2], 1); |
|
2883 test(r == KErrNone); |
|
2884 r = lddChan.CheckNotifications(iStaticDependencyResources[2], 0, 0); |
|
2885 test(r == KErrNone); |
|
2886 GetExtendedResStateAndVerify(iStaticDependencyResources[2], 1, Clients[1].iClientId); |
|
2887 //Register client 3 |
|
2888 RmTest.RegisterClient(); |
|
2889 //Change state of resource E to 19 and verify |
|
2890 r = lddChan.ChangeResourceStateSync(Clients[2].iClientId, iStaticDependencyResources[3], 19); |
|
2891 test(r == KErrNone); |
|
2892 r = lddChan.CheckNotifications(iStaticDependencyResources[3], 1, 0); |
|
2893 test(r == KErrNone); |
|
2894 r = lddChan.CheckNotifications(iStaticDependencyResources[5], 1, 0); |
|
2895 test(r == KErrNone); |
|
2896 GetExtendedResStateAndVerify(iStaticDependencyResources[0], -49, Clients[1].iClientId); |
|
2897 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -13, iStaticDependencyResources[0]); |
|
2898 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, Clients[1].iClientId); |
|
2899 GetExtendedResStateAndVerify(iStaticDependencyResources[3], 19, Clients[2].iClientId); |
|
2900 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); |
|
2901 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 69, iStaticDependencyResources[3]); |
|
2902 //Register client 4 |
|
2903 RmTest.RegisterClient(); |
|
2904 //Change state of resource C to 0 and verify |
|
2905 r = lddChan.ChangeResourceStateSync(Clients[3].iClientId, iStaticDependencyResources[4], 0); |
|
2906 test(r == KErrNone); |
|
2907 r = lddChan.CheckNotifications(iStaticDependencyResources[4], 0, 0); |
|
2908 test(r == KErrNone); |
|
2909 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); |
|
2910 //Change state of resource C to 1 and verify |
|
2911 r = lddChan.ChangeResourceStateSync(Clients[2].iClientId, iStaticDependencyResources[4], 1); |
|
2912 test(r == KErrNone); |
|
2913 r = lddChan.CheckNotifications(iStaticDependencyResources[4], 0, 0); |
|
2914 test(r == KErrNone); |
|
2915 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); |
|
2916 //Change state of resource G to 67 and verify |
|
2917 r = lddChan.ChangeResourceStateSync(Clients[2].iClientId, iStaticDependencyResources[5], 67); |
|
2918 test(r == KErrNone); |
|
2919 r = lddChan.CheckNotifications(iStaticDependencyResources[5], 1, 0); |
|
2920 test(r == KErrNone); |
|
2921 GetExtendedResStateAndVerify(iStaticDependencyResources[0], -49, Clients[1].iClientId); |
|
2922 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -13, iStaticDependencyResources[0]); |
|
2923 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, Clients[1].iClientId); |
|
2924 GetExtendedResStateAndVerify(iStaticDependencyResources[3], 19, Clients[2].iClientId); |
|
2925 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); |
|
2926 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 67, Clients[2].iClientId); |
|
2927 //Change state of resource G to 67 and verify |
|
2928 r = lddChan.ChangeResourceStateSync(Clients[3].iClientId, iStaticDependencyResources[5], 67); |
|
2929 test(r == KErrNone); |
|
2930 r = lddChan.CheckNotifications(iStaticDependencyResources[5], 0, 0); |
|
2931 test(r == KErrNone); |
|
2932 GetExtendedResStateAndVerify(iStaticDependencyResources[0], -49, Clients[1].iClientId); |
|
2933 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -13, iStaticDependencyResources[0]); |
|
2934 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, Clients[1].iClientId); |
|
2935 GetExtendedResStateAndVerify(iStaticDependencyResources[3], 19, Clients[2].iClientId); |
|
2936 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); |
|
2937 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 67, Clients[2].iClientId); |
|
2938 |
|
2939 //Change the state of the resource E to 24 |
|
2940 state = 24; |
|
2941 //Register client 5 |
|
2942 RmTest.RegisterClient(); |
|
2943 lddChan.ChangeResourceStateAsync(Clients[4].iClientId, iStaticDependencyResources[3], state, reqSet); |
|
2944 User::WaitForRequest(reqSet); |
|
2945 test(reqSet.Int() == KErrNone); |
|
2946 r = lddChan.CheckNotifications(iStaticDependencyResources[3], 1, 0); |
|
2947 test(r == KErrNone); |
|
2948 r = lddChan.CheckNotifications(iStaticDependencyResources[5], 1, 0); |
|
2949 test(r == KErrNone); |
|
2950 GetExtendedResStateAndVerify(iStaticDependencyResources[0], -49, Clients[1].iClientId); |
|
2951 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -13, iStaticDependencyResources[0]); |
|
2952 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, Clients[1].iClientId); |
|
2953 GetExtendedResStateAndVerify(iStaticDependencyResources[3], 24, Clients[4].iClientId); |
|
2954 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); |
|
2955 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 65, iStaticDependencyResources[3]); |
|
2956 |
|
2957 //Change resource state of Resource D to -51 |
|
2958 r = lddChan.ChangeResourceStateSync(Clients[2].iClientId, iStaticDependencyResources[0], -51); |
|
2959 test(r == KErrAccessDenied); |
|
2960 GetExtendedResStateAndVerify(iStaticDependencyResources[0], -49, Clients[1].iClientId); |
|
2961 |
|
2962 //DeregisterClient 5 |
|
2963 r = lddChan.DeRegisterClient(Clients[4].iClientId); |
|
2964 test(r == KErrNone); |
|
2965 |
|
2966 r = lddChan.CheckNotifications(iStaticDependencyResources[3], 1, 0); |
|
2967 test(r == KErrNone); |
|
2968 r = lddChan.CheckNotifications(iStaticDependencyResources[5], 1, 0); |
|
2969 test(r == KErrNone); |
|
2970 |
|
2971 GetExtendedResStateAndVerify(iStaticDependencyResources[3], 19, Clients[2].iClientId); |
|
2972 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 63, iStaticDependencyResources[3]); |
|
2973 |
|
2974 //Change resource state of resource D to 50 |
|
2975 state = 50; |
|
2976 lddChan.ChangeResourceStateAsync(Clients[1].iClientId, iStaticDependencyResources[0], state, reqSet); |
|
2977 User::WaitForRequest(reqSet); |
|
2978 test(reqSet.Int() == KErrNone); |
|
2979 r = lddChan.CheckNotifications(iStaticDependencyResources[0], 1, 0); |
|
2980 test(r == KErrNone); |
|
2981 r = lddChan.CheckNotifications(iStaticDependencyResources[1], 1, 0); |
|
2982 test(r == KErrNone); |
|
2983 r = lddChan.CheckNotifications(iStaticDependencyResources[3], 1, 0); |
|
2984 test(r == KErrNone); |
|
2985 r = lddChan.CheckNotifications(iStaticDependencyResources[5], 1, 0); |
|
2986 test(r == KErrNone); |
|
2987 |
|
2988 GetExtendedResStateAndVerify(iStaticDependencyResources[0], 50, Clients[1].iClientId); |
|
2989 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -14, iStaticDependencyResources[0]); |
|
2990 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, Clients[1].iClientId); |
|
2991 GetExtendedResStateAndVerify(iStaticDependencyResources[3], 22, iStaticDependencyResources[0]); |
|
2992 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); |
|
2993 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 61, iStaticDependencyResources[3]); |
|
2994 |
|
2995 //Change resource state of resource G to 61 |
|
2996 r = lddChan.ChangeResourceStateSync(Clients[3].iClientId, iStaticDependencyResources[5], 61); |
|
2997 test(r == KErrNone); |
|
2998 |
|
2999 r = lddChan.CheckNotifications(iStaticDependencyResources[5], 0, 0); |
|
3000 test(r == KErrNone); |
|
3001 |
|
3002 GetExtendedResStateAndVerify(iStaticDependencyResources[0], 50, Clients[1].iClientId); |
|
3003 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -14, iStaticDependencyResources[0]); |
|
3004 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, Clients[1].iClientId); |
|
3005 GetExtendedResStateAndVerify(iStaticDependencyResources[3], 22, iStaticDependencyResources[0]); |
|
3006 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); |
|
3007 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 61, iStaticDependencyResources[3]); |
|
3008 |
|
3009 //Deregister client 4; |
|
3010 r = lddChan.DeRegisterClient(Clients[3].iClientId); |
|
3011 test(r == KErrNone); |
|
3012 |
|
3013 r = lddChan.CheckNotifications(iStaticDependencyResources[5], 0, 0); |
|
3014 test(r == KErrNone); |
|
3015 |
|
3016 GetExtendedResStateAndVerify(iStaticDependencyResources[0], 50, Clients[1].iClientId); |
|
3017 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -14, iStaticDependencyResources[0]); |
|
3018 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, Clients[1].iClientId); |
|
3019 GetExtendedResStateAndVerify(iStaticDependencyResources[3], 22, iStaticDependencyResources[0]); |
|
3020 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); |
|
3021 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 61, iStaticDependencyResources[3]); |
|
3022 |
|
3023 //Deregister client 3. |
|
3024 r = lddChan.DeRegisterClient(Clients[2].iClientId); |
|
3025 test(r == KErrNone); |
|
3026 |
|
3027 GetExtendedResStateAndVerify(iStaticDependencyResources[0], 50, Clients[1].iClientId); |
|
3028 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -14, iStaticDependencyResources[0]); |
|
3029 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, Clients[1].iClientId); |
|
3030 GetExtendedResStateAndVerify(iStaticDependencyResources[3], 22, iStaticDependencyResources[0]); |
|
3031 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); |
|
3032 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 61, iStaticDependencyResources[3]); |
|
3033 |
|
3034 //Deregister client 0 from Resource A |
|
3035 r = lddChan.DeRegisterClientLevelFromResource(Clients[0].iClientId, iStaticDependencyResources[1]); |
|
3036 test(r == KErrNone); |
|
3037 |
|
3038 r = lddChan.CheckNotifications(iStaticDependencyResources[1], 0, 0); |
|
3039 test(r == KErrNone); |
|
3040 |
|
3041 GetExtendedResStateAndVerify(iStaticDependencyResources[0], 50, Clients[1].iClientId); |
|
3042 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -14, iStaticDependencyResources[0]); |
|
3043 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, Clients[1].iClientId); |
|
3044 GetExtendedResStateAndVerify(iStaticDependencyResources[3], 22, iStaticDependencyResources[0]); |
|
3045 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); |
|
3046 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 61, iStaticDependencyResources[3]); |
|
3047 |
|
3048 //Move Resource D to default |
|
3049 r = lddChan.ChangeResourceStateSync(Clients[1].iClientId, iStaticDependencyResources[0], -100); |
|
3050 test(r == KErrPermissionDenied); |
|
3051 |
|
3052 //Deregister client 1 from Resource F |
|
3053 r = lddChan.DeRegisterClientLevelFromResource(Clients[1].iClientId, iStaticDependencyResources[2]); |
|
3054 test(r == KErrNone); |
|
3055 |
|
3056 r = lddChan.CheckNotifications(iStaticDependencyResources[1], 0, 0); |
|
3057 test(r == KErrNone); |
|
3058 |
|
3059 GetExtendedResStateAndVerify(iStaticDependencyResources[0], 50, Clients[1].iClientId); |
|
3060 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -14, iStaticDependencyResources[0]); |
|
3061 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, iStaticDependencyResources[0]); |
|
3062 GetExtendedResStateAndVerify(iStaticDependencyResources[3], 22, iStaticDependencyResources[0]); |
|
3063 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); |
|
3064 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 61, iStaticDependencyResources[3]); |
|
3065 |
|
3066 //Deregister client 2 |
|
3067 r = lddChan.DeRegisterClient(Clients[1].iClientId); |
|
3068 test(r == KErrNone); |
|
3069 |
|
3070 GetExtendedResStateAndVerify(iStaticDependencyResources[0], -100, -1); |
|
3071 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -10, iStaticDependencyResources[0]); |
|
3072 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 0, iStaticDependencyResources[0]); |
|
3073 GetExtendedResStateAndVerify(iStaticDependencyResources[3], 10, iStaticDependencyResources[0]); |
|
3074 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 1, iStaticDependencyResources[3]); |
|
3075 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 75, iStaticDependencyResources[3]); |
|
3076 //Deregister client 1 |
|
3077 r = lddChan.DeRegisterClient(Clients[0].iClientId); |
|
3078 test(r == KErrNone); |
|
3079 Clients.Close(); //Close the array and release memory |
|
3080 |
|
3081 //Test parallel execution of RC and Dependency resource DFC's |
|
3082 //Register client 1 |
|
3083 RmTest.RegisterClient(); |
|
3084 //Register client 2 |
|
3085 RmTest.RegisterClient(); |
|
3086 |
|
3087 state = 50; |
|
3088 /* CheckParallelExecutionForResChageStateWithDependency */ |
|
3089 lddChan.CheckParallelExecutionForChangeResState(Clients[1].iClientId, |
|
3090 iStaticDependencyResources[0],state,5,0,reqSet); |
|
3091 |
|
3092 User::WaitForRequest(reqSet); |
|
3093 test(reqSet.Int() == KErrNone); |
|
3094 |
|
3095 GetExtendedResStateAndVerify(iStaticDependencyResources[0], 50, Clients[1].iClientId); |
|
3096 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -11, iStaticDependencyResources[0]); |
|
3097 GetExtendedResStateAndVerify(iStaticDependencyResources[2], 1, iStaticDependencyResources[0]); |
|
3098 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[3], 13, iStaticDependencyResources[0]); |
|
3099 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); |
|
3100 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 73, iStaticDependencyResources[3]); |
|
3101 |
|
3102 TInt owner; |
|
3103 TBool cached = ETrue; |
|
3104 r = lddChan.GetResourceStateSync(Clients[1].iClientId, 4, cached, state, owner); |
|
3105 test(r == KErrNone); |
|
3106 test(state == 75); |
|
3107 test(owner == -1); |
|
3108 |
|
3109 r = lddChan.DeRegisterClient(Clients[1].iClientId); |
|
3110 test(r == KErrNone); |
|
3111 |
|
3112 GetExtendedResStateAndVerify(iStaticDependencyResources[0], -100, -1); |
|
3113 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -10, iStaticDependencyResources[0]); |
|
3114 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 0, iStaticDependencyResources[0]); |
|
3115 GetExtendedResStateAndVerify(iStaticDependencyResources[3], 10, iStaticDependencyResources[0]); |
|
3116 GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 1, iStaticDependencyResources[3]); |
|
3117 GetExtendedResStateAndVerify(iStaticDependencyResources[5], 75, iStaticDependencyResources[3]); |
|
3118 |
|
3119 r = lddChan.GetResourceStateSync(Clients[0].iClientId, 4, cached, state, owner); |
|
3120 test(r == KErrNone); |
|
3121 test(state == 75); |
|
3122 test(owner == -1); |
|
3123 |
|
3124 r = lddChan.DeRegisterClient(Clients[0].iClientId); |
|
3125 test(r == KErrNone); |
|
3126 |
|
3127 Clients.Close(); //Close the array and release memory |
|
3128 depResArray.Close(); //Close the array and release memory |
|
3129 } |
|
3130 #endif |
|
3131 |
|
3132 //This function validates each of the resource manager API's |
|
3133 void TestRM::APIValidationTest() |
|
3134 { |
|
3135 test.Next(_L("\nStarting API validation Test....")); |
|
3136 RmTest.RegisterClient(); |
|
3137 r = lddChan.GetResourceControllerVersion(Clients[0].iClientId, iTestingExtendedVersion); |
|
3138 test(r == KErrNone); |
|
3139 if(!iTestingExtendedVersion) |
|
3140 test.Printf(_L("Testing Basic Version only....")); |
|
3141 else |
|
3142 test.Printf(_L("Testing basic & extended version....")); |
|
3143 RmTest.ValidateClient(5, EOwnerProcess); |
|
3144 iCurrentClientId = -1; |
|
3145 RmTest.GetNumResourcesInUseByClient(iCurrentClientId); |
|
3146 RmTest.GetInfoOnResourcesInUseByClient(iCurrentClientId, iMaxStaticResources); |
|
3147 iCurrentClientId = 0; |
|
3148 NegativeTesting = ETrue; |
|
3149 if(Resources[0].iName.Compare(*(const TDesC8*)&SpecialResName)) |
|
3150 { |
|
3151 test.Printf(_L("Test runs only on simulated PSL\n")); |
|
3152 RmTest.DeRegisterClient(Clients[0].iClientId); |
|
3153 return; |
|
3154 } |
|
3155 TBuf8<32> PowerController = _L8("PowerController"); |
|
3156 r = lddChan.GetClientId(Clients[0].iClientId, (TDesC8&)PowerController, iPowerControllerId); |
|
3157 test(r == KErrNone); |
|
3158 r = lddChan.RegisterForIdleResourcesInfo(iPowerControllerId, 15); |
|
3159 test(r == KErrNone); |
|
3160 RmTest.GetClientName(iCurrentClientId); |
|
3161 RmTest.GetClientId(iCurrentClientId); |
|
3162 RmTest.GetResourceId(2); |
|
3163 RmTest.GetResourceInfo(19); |
|
3164 RmTest.GetNumResourcesInUseByClient(iCurrentClientId); |
|
3165 RmTest.GetInfoOnResourcesInUseByClient(iCurrentClientId, 3); |
|
3166 RmTest.GetNumClientsUsingResource(iCurrentClientId, (TUint)-1); |
|
3167 RmTest.GetNumClientsUsingResource(iCurrentClientId, 10); |
|
3168 RmTest.GetInfoOnClientsUsingResource((TUint)-1, 4); |
|
3169 RmTest.GetInfoOnClientsUsingResource(5, 3); |
|
3170 |
|
3171 TUint c; |
|
3172 for(c = 0; c < iMaxStaticResources; c++) |
|
3173 { |
|
3174 if(Resources[c].iSense == ECustom) |
|
3175 continue; |
|
3176 RmTest.GetResourceStateAsync(c, ETrue); |
|
3177 } |
|
3178 User::After(2000000); //Add delay to make sure that the asynchronous request is processed in controller thread |
|
3179 |
|
3180 for(c = 0; c < iMaxStaticResources; c++) |
|
3181 { |
|
3182 if(Resources[c].iSense == ECustom) |
|
3183 continue; |
|
3184 iCurrentClientId = c; |
|
3185 RmTest.RegisterClient(); |
|
3186 RmTest.AllocReserve(c); |
|
3187 RmTest.GetResourceStateAsync(c); |
|
3188 RmTest.RequestNotification(c); |
|
3189 RmTest.RequestNotificationCon(c); |
|
3190 } |
|
3191 |
|
3192 for(c=0; c< iMaxStaticResources; c++) |
|
3193 { |
|
3194 if(Resources[c].iSense == ECustom) |
|
3195 continue; |
|
3196 iCurrentClientId = c; |
|
3197 RmTest.ChangeResourceStateAsync(c); |
|
3198 RmTest.GetResourceStateAsync(c); |
|
3199 RmTest.GetResourceStateSync(c); |
|
3200 RmTest.ChangeResourceStateSync(c); |
|
3201 } |
|
3202 for(c = 0; c < iMaxStaticResources; c++) |
|
3203 { |
|
3204 if(Resources[c].iSense == ECustom) |
|
3205 continue; |
|
3206 iCurrentClientId = c; |
|
3207 RmTest.GetClientName(c); |
|
3208 RmTest.GetClientId(c); |
|
3209 RmTest.GetResourceId(c); |
|
3210 RmTest.GetResourceInfo(c); |
|
3211 RmTest.GetNumResourcesInUseByClient(c); |
|
3212 RmTest.GetInfoOnResourcesInUseByClient(c, Clients[c].iNumResources); |
|
3213 RmTest.GetNumClientsUsingResource(c, c); |
|
3214 RmTest.GetInfoOnClientsUsingResource(c, Resources[c].iNumClients); |
|
3215 RmTest.CancelNotification(c, ETrue); |
|
3216 RmTest.CancelNotification(c, EFalse); |
|
3217 } |
|
3218 |
|
3219 TInt clientCount = Clients.Count(); |
|
3220 for(c = clientCount-1; ((TInt)c) >=0; c--) |
|
3221 { |
|
3222 test.Printf(_L("DeRegister ClientId %d\n"), Clients[c].iClientId); |
|
3223 RmTest.DeRegisterClient(c); |
|
3224 } |
|
3225 Clients.Close(); |
|
3226 //Find any shared binary resource |
|
3227 for(c = 0; c < iMaxStaticResources; c++) |
|
3228 { |
|
3229 if(Resources[c].iSense == ECustom) |
|
3230 continue; |
|
3231 if((Resources[c].iUsage == EShared) && (Resources[c].iSense == ENegative)) |
|
3232 { |
|
3233 if(Resources[c].iType == 0x0) //Binary Resource |
|
3234 RmTest.SharedBinaryNegativeResourceTesting(c); |
|
3235 else |
|
3236 RmTest.SharedMultilevelNegativeResourceTesting(c); |
|
3237 } |
|
3238 else if((Resources[c].iUsage == EShared) && (Resources[c].iSense == EPositive)) |
|
3239 { |
|
3240 if(Resources[c].iType == 0x0) //Binary Resource |
|
3241 RmTest.SharedBinaryPositiveResourceTesting(c); |
|
3242 else |
|
3243 RmTest.SharedMultilevelPositiveResourceTesting(c); |
|
3244 } |
|
3245 } |
|
3246 |
|
3247 RmTest.CustomResourceTesting(CUSTOM_RESOURCE_NUMBER); |
|
3248 |
|
3249 //Testing of Deregistration of client level for binary resource |
|
3250 RmTest.RegisterClient(); |
|
3251 for(c = 0; c < iMaxStaticResources; c++) |
|
3252 { |
|
3253 if(Resources[c].iSense == ECustom) |
|
3254 continue; |
|
3255 RmTest.DeRegisterClientLevelFromResource(-1, c); |
|
3256 } |
|
3257 for(c = 0; c < iMaxStaticResources; c++) |
|
3258 { |
|
3259 iCurrentClientId = 0; |
|
3260 RmTest.ChangeResourceStateSync(c); |
|
3261 RmTest.DeRegisterClientLevelFromResource(0, c); |
|
3262 } |
|
3263 RmTest.RegisterClient(); |
|
3264 for(c = 0; c < iMaxStaticResources; c++) //Test valid only for shared resources. |
|
3265 { |
|
3266 if((Resources[c].iSense == ECustom) || (Resources[c].iUsage == ESingle)) |
|
3267 continue; |
|
3268 iCurrentClientId = 0; |
|
3269 RmTest.ChangeResourceStateSync(c); |
|
3270 iCurrentClientId = 1; |
|
3271 RmTest.ChangeResourceStateSync(c); |
|
3272 if(Resources[c].iCurrentClient == 0) |
|
3273 { |
|
3274 RmTest.DeRegisterClientLevelFromResource(0, c); |
|
3275 RmTest.DeRegisterClientLevelFromResource(1, c); |
|
3276 } |
|
3277 else |
|
3278 { |
|
3279 RmTest.DeRegisterClientLevelFromResource(1, c); |
|
3280 RmTest.DeRegisterClientLevelFromResource(0, c); |
|
3281 } |
|
3282 } |
|
3283 //Testing of Deregistration of client level for shared resource |
|
3284 for(c = 0; c < iMaxStaticResources; c++) |
|
3285 { |
|
3286 if((Resources[c].iSense == ECustom) || (!Resources[c].iUsage)) |
|
3287 continue; |
|
3288 RmTest.DeRegisterClientLevelFromResource(-1, c); |
|
3289 } |
|
3290 |
|
3291 RmTest.DeRegisterClient(1); |
|
3292 RmTest.DeRegisterClient(0); |
|
3293 RBuf8 info; |
|
3294 info.Create(15 * sizeof(SIdleResourceInfo)); |
|
3295 r = lddChan.GetIdleResourcesInfo(15, (TAny*)(TDes8*)&info); |
|
3296 test(r == KErrNone); |
|
3297 SIdleResourceInfo* pI = (SIdleResourceInfo*)info.Ptr(); |
|
3298 for(c = 0; c< 15; c++) |
|
3299 { |
|
3300 test(Resources[c].iCurrentClient == pI->iLevelOwnerId); |
|
3301 test(Resources[c].iCurrentLevel == pI->iCurrentLevel); |
|
3302 test(Resources[c].iResourceId == pI->iResourceId); |
|
3303 pI++; |
|
3304 } |
|
3305 info.Close(); |
|
3306 Clients.Close(); |
|
3307 #ifdef PRM_ENABLE_EXTENDED_VERSION |
|
3308 if(iTestingExtendedVersion) |
|
3309 { |
|
3310 TestStaticResourceWithDependency(); |
|
3311 TestDynamicResource(); |
|
3312 TestDynamicResourceDependency(); |
|
3313 } |
|
3314 #endif |
|
3315 Clients.Close(); |
|
3316 return; |
|
3317 } |
|
3318 |
|
3319 //---------------------------------------------------------------------------------------------- |
|
3320 //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0592 |
|
3321 //! @SYMTestType UT |
|
3322 //! @SYMPREQ PREQ1398 |
|
3323 //! @SYMTestCaseDesc This test case tests deregistration of client level functionality. |
|
3324 //! @SYMTestActions 0 Register client |
|
3325 //! 1 Change Resource State |
|
3326 //! 2 Deregister client level |
|
3327 //! 3 Deregister client |
|
3328 //! |
|
3329 //! @SYMTestExpectedResults 0 API should return with KErrNone, panics otherwise. |
|
3330 //! 1 API should return with KErrNone, panics otherwise. |
|
3331 //! 2 API should return with KErrNone, panics otherwise. |
|
3332 //! 3 API should return with KErrNone, panics otherwise. |
|
3333 //! @SYMTestPriority High |
|
3334 //! @SYMTestStatus Implemented |
|
3335 //---------------------------------------------------------------------------------------------- |
|
3336 void TestRM::DeRegisterClientLevelFromResource(TInt aClientId, TUint aResId) |
|
3337 { |
|
3338 TInt state; |
|
3339 TInt newState; |
|
3340 TInt levelOwnerId; |
|
3341 r = lddChan.GetResourceStateSync(Clients[0].iClientId, Resources[aResId].iResourceId, ETrue, newState, levelOwnerId); |
|
3342 test(r == KErrNone); |
|
3343 if((levelOwnerId != -1) && (levelOwnerId != (TInt)Clients[aClientId].iClientId)) |
|
3344 { |
|
3345 test.Printf(_L("Client Id does not match so not testing Deregistration of client level\n")); |
|
3346 return; |
|
3347 } |
|
3348 if(Resources[aResId].iUsage == ESingle) //Single user resource |
|
3349 { |
|
3350 if(levelOwnerId == -1) |
|
3351 { |
|
3352 TUint ClientId; |
|
3353 ClientName[6] = (TUint8)('0' + iMaxClientId+1); |
|
3354 r = lddChan.RegisterClient(ClientId, (const TDesC*)&ClientName); |
|
3355 test(r == KErrNone); |
|
3356 newState = Resources[aResId].iMaxLevel; |
|
3357 r = lddChan.ChangeResourceStateSync(ClientId, Resources[aResId].iResourceId, newState); |
|
3358 test(r == KErrNone); |
|
3359 r = lddChan.GetResourceStateSync(ClientId, Resources[aResId].iResourceId, ETrue, state, levelOwnerId); |
|
3360 test(r == KErrNone); |
|
3361 test(state == newState); |
|
3362 test(levelOwnerId == (TInt)ClientId); |
|
3363 r = lddChan.DeRegisterClientLevelFromResource(ClientId, Resources[aResId].iResourceId); |
|
3364 test(r == KErrNone); |
|
3365 r = lddChan.GetResourceStateSync(ClientId, Resources[aResId].iResourceId, ETrue, state, levelOwnerId); |
|
3366 test(r == KErrNone); |
|
3367 test(levelOwnerId == -1); |
|
3368 r = lddChan.DeRegisterClient(ClientId); |
|
3369 test(r == KErrNone); |
|
3370 return; |
|
3371 } |
|
3372 r = lddChan.DeRegisterClientLevelFromResource(Clients[aClientId].iClientId, Resources[aResId].iResourceId); |
|
3373 test(r == KErrNone); |
|
3374 r = lddChan.GetResourceStateSync(Clients[aClientId].iClientId, Resources[aResId].iResourceId, ETrue, state, levelOwnerId); |
|
3375 test(r == KErrNone); |
|
3376 test(levelOwnerId == -1); |
|
3377 //Update the local |
|
3378 Resources[aResId].iCurrentClient = -1; |
|
3379 Resources[aResId].iCurrentLevel = state; |
|
3380 Resources[aResId].iNumClients = 0; |
|
3381 delete Resources[aResId].iLevel; |
|
3382 Resources[aResId].iLevel = NULL; |
|
3383 return; |
|
3384 } |
|
3385 //Handle for Shared resources |
|
3386 if(levelOwnerId == -1) |
|
3387 { |
|
3388 TUint ClientId[2]; |
|
3389 ClientName[6] = (TUint8)('0' + iMaxClientId+1); |
|
3390 r = lddChan.RegisterClient(ClientId[0], (const TDesC*)&ClientName); |
|
3391 test(r == KErrNone); |
|
3392 ClientName[6] = (TUint8)('0' + iMaxClientId+2); |
|
3393 r = lddChan.RegisterClient(ClientId[1], (const TDesC*)&ClientName); |
|
3394 test(r == KErrNone); |
|
3395 newState = Resources[aResId].iMinLevel; |
|
3396 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3397 test(r == KErrNone); |
|
3398 r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, ETrue, state, levelOwnerId); |
|
3399 test(r == KErrNone); |
|
3400 test(levelOwnerId == (TInt)ClientId[0]); |
|
3401 r = lddChan.ChangeResourceStateSync(ClientId[1], Resources[aResId].iResourceId, newState); |
|
3402 test(r == KErrNone); |
|
3403 r = lddChan.DeRegisterClientLevelFromResource(ClientId[0], Resources[aResId].iResourceId); |
|
3404 test(r == KErrNone); |
|
3405 r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, ETrue, state, levelOwnerId); |
|
3406 test(r == KErrNone); |
|
3407 test(levelOwnerId == (TInt)ClientId[1]); |
|
3408 r = lddChan.DeRegisterClientLevelFromResource(ClientId[1], Resources[aResId].iResourceId); |
|
3409 test(r == KErrNone); |
|
3410 r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, ETrue, state, levelOwnerId); |
|
3411 test(r == KErrNone); |
|
3412 test(levelOwnerId == -1); |
|
3413 r = lddChan.DeRegisterClient(ClientId[0]); |
|
3414 test(r == KErrNone); |
|
3415 r = lddChan.DeRegisterClient(ClientId[1]); |
|
3416 test(r == KErrNone); |
|
3417 return; |
|
3418 } |
|
3419 r = lddChan.DeRegisterClientLevelFromResource(Clients[aClientId].iClientId, Resources[aResId].iResourceId); |
|
3420 test(r == KErrNone); |
|
3421 r = lddChan.GetResourceStateSync(Clients[aClientId].iClientId, Resources[aResId].iResourceId, ETrue, state, levelOwnerId); |
|
3422 test(r == KErrNone); |
|
3423 test(levelOwnerId != (TInt)Clients[aClientId].iClientId); |
|
3424 if(Resources[aResId].iNumClients == 1) |
|
3425 { |
|
3426 Resources[aResId].iNumClients--; |
|
3427 Resources[aResId].iCurrentClient = -1; |
|
3428 r = lddChan.GetResourceStateSync(Clients[aClientId].iClientId, Resources[aResId].iResourceId, ETrue, state, levelOwnerId); |
|
3429 test(r == KErrNone); |
|
3430 Resources[aResId].iCurrentLevel = state; |
|
3431 delete Resources[aResId].iLevel; |
|
3432 Resources[aResId].iLevel = NULL; |
|
3433 } |
|
3434 else |
|
3435 { |
|
3436 Resources[aResId].iNumClients--; |
|
3437 SPowerResourceClientLevel *pCL = NULL; |
|
3438 TInt level = KMinTInt; |
|
3439 TInt clientId = 0; |
|
3440 for(SPowerResourceClientLevel* pL = Resources[aResId].iLevel; pL != NULL; pL = pL->iNextInList) |
|
3441 { |
|
3442 if(pL->iClientId == Clients[aClientId].iClientId) |
|
3443 { |
|
3444 pCL = pL; |
|
3445 continue; |
|
3446 } |
|
3447 if(level == KMinTInt) |
|
3448 { |
|
3449 level = pL->iLevel; |
|
3450 clientId = pL->iClientId; |
|
3451 continue; |
|
3452 } |
|
3453 if(((Resources[aResId].iSense == EPositive) && (pL->iLevel > level)) || ((Resources[aResId].iSense == ENegative) && (pL->iLevel < level))) |
|
3454 { |
|
3455 level = pL->iLevel; |
|
3456 clientId = pL->iClientId; |
|
3457 } |
|
3458 } |
|
3459 delete pCL; |
|
3460 Resources[aResId].iCurrentClient = clientId; |
|
3461 Resources[aResId].iCurrentLevel = level; |
|
3462 } |
|
3463 return; |
|
3464 } |
|
3465 |
|
3466 //---------------------------------------------------------------------------------------------- |
|
3467 //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0593 |
|
3468 //! @SYMTestType UT |
|
3469 //! @SYMPREQ PREQ1398 |
|
3470 //! @SYMTestCaseDesc This test case tests changing resource state of shared positive resource. |
|
3471 //! @SYMTestActions 0 Register client1 |
|
3472 //! 1 Register client2 |
|
3473 //! 2 Register client3 |
|
3474 //! 3 Register client4 |
|
3475 //! 4 Client1 change resource state. |
|
3476 //! 5 Client2 change resource state. |
|
3477 //! 6 Client3 change resource state. |
|
3478 //! 7 Client4 change resource state. |
|
3479 //! 8 Client1 change resource state. |
|
3480 //! 9 Client2 change resource state. |
|
3481 //! 10 Deregister client2 |
|
3482 //! 11 Client3 change resource state. |
|
3483 //! 12 Deregister client1 |
|
3484 //! 13 Deregister client3 |
|
3485 //! 14 Deregister client4 |
|
3486 //! |
|
3487 //! @SYMTestExpectedResults 0 Client registered |
|
3488 //! 1 Client registered |
|
3489 //! 2 Client registered |
|
3490 //! 3 Client registered |
|
3491 //! 4 Resource state changed |
|
3492 //! 5 Resource state changed |
|
3493 //! 6 Resource state changed |
|
3494 //! 7 Resource state changed |
|
3495 //! 8 Resource state changed |
|
3496 //! 9 Resource state changed |
|
3497 //! 10 Client2 deregistered |
|
3498 //! 11 Resource state changed |
|
3499 //! 12 Client1 deregistered |
|
3500 //! 13 Client3 deregistered |
|
3501 //! 14 Client4 deregistered |
|
3502 //! @SYMTestPriority High |
|
3503 //! @SYMTestStatus Implemented |
|
3504 //---------------------------------------------------------------------------------------------- |
|
3505 void TestRM::SharedBinaryPositiveResourceTesting(TUint aResId) |
|
3506 { |
|
3507 TInt newState, levelOwnerId; |
|
3508 TRequestStatus req; |
|
3509 TUint ClientId[5]; |
|
3510 |
|
3511 ClientName[6] = (TUint8)('0' + iMaxClientId+1); |
|
3512 r = lddChan.RegisterClient(ClientId[0], (const TDesC*)&ClientName); |
|
3513 test(r == KErrNone); |
|
3514 |
|
3515 r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, ETrue, newState, levelOwnerId); |
|
3516 test(r == KErrNone); |
|
3517 if(levelOwnerId != -1) |
|
3518 { |
|
3519 test.Printf(_L("Not testing the shared resource as some other client is currently holding the resource\n")); |
|
3520 r = lddChan.DeRegisterClient(ClientId[0]); |
|
3521 test(r == KErrNone); |
|
3522 return; |
|
3523 } |
|
3524 |
|
3525 ClientName[6] = (TUint8)('0' + iMaxClientId +2); |
|
3526 r = lddChan.RegisterClient(ClientId[1], (const TDesC*)&ClientName); |
|
3527 test(r == KErrNone); |
|
3528 ClientName[6] = (TUint8)('0' + iMaxClientId +3); |
|
3529 r = lddChan.RegisterClient(ClientId[2], (const TDesC*)&ClientName); |
|
3530 test(r == KErrNone); |
|
3531 ClientName[6] = (TUint8)('0' + iMaxClientId +4); |
|
3532 r = lddChan.RegisterClient(ClientId[3], (const TDesC*)&ClientName); |
|
3533 test(r == KErrNone); |
|
3534 ClientName[6] = (TUint8)('0' + iMaxClientId +5); |
|
3535 r = lddChan.RegisterClient(ClientId[4], (const TDesC*)&ClientName); |
|
3536 test(r == KErrNone); |
|
3537 |
|
3538 newState = 1; |
|
3539 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3540 test(r == KErrNone); |
|
3541 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); |
|
3542 test(r == KErrNone); |
|
3543 r = lddChan.RequestNotification(ClientId[1], Resources[aResId].iResourceId); |
|
3544 test(r == KErrNone); |
|
3545 r = lddChan.RequestNotification(ClientId[2], Resources[aResId].iResourceId); |
|
3546 test(r == KErrNone); |
|
3547 r = lddChan.RequestNotification(ClientId[3], Resources[aResId].iResourceId, 1, ETrue); |
|
3548 test(r == KErrNone); |
|
3549 r = lddChan.RequestNotification(ClientId[2], Resources[aResId].iResourceId, 0, EFalse); |
|
3550 test(r == KErrNone); |
|
3551 newState = !newState; //State 0 |
|
3552 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3553 test(r == KErrNone); |
|
3554 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 2, 1); |
|
3555 test(r == KErrNone); |
|
3556 newState = !newState; //State 1 |
|
3557 r = lddChan.ChangeResourceStateSync(ClientId[1], Resources[aResId].iResourceId, newState); |
|
3558 test(r == KErrNone); |
|
3559 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 2, 1); |
|
3560 test(r == KErrNone); |
|
3561 lddChan.ChangeResourceStateAsync(ClientId[2], Resources[aResId].iResourceId, newState, req); |
|
3562 User::WaitForRequest(req); //State 1 |
|
3563 test(req.Int() == KErrNone); |
|
3564 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); |
|
3565 test(r == KErrNone); |
|
3566 newState = !newState; //State 0 |
|
3567 r = lddChan.ChangeResourceStateSync(ClientId[3], Resources[aResId].iResourceId, newState); |
|
3568 test(r == KErrNone); |
|
3569 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); |
|
3570 test(r == KErrNone); |
|
3571 newState = !newState; //state 1 |
|
3572 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3573 test(r == KErrNone); |
|
3574 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); |
|
3575 newState = !newState; //state 0 |
|
3576 r = lddChan.ChangeResourceStateSync(ClientId[1], Resources[aResId].iResourceId, newState); |
|
3577 test(r == KErrNone); |
|
3578 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0,0); |
|
3579 test(r == KErrNone); |
|
3580 r = lddChan.DeRegisterClient(ClientId[1]); |
|
3581 test(r == KErrNone); |
|
3582 newState = 0; |
|
3583 r = lddChan.ChangeResourceStateSync(ClientId[2], Resources[aResId].iResourceId, newState); |
|
3584 test(r == KErrNone); |
|
3585 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0,0); |
|
3586 test(r == KErrNone); |
|
3587 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3588 test(r == KErrNone); |
|
3589 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 1,1); |
|
3590 test(r == KErrNone); |
|
3591 r = lddChan.CancelNotification(ClientId[2], Resources[aResId].iResourceId, EFalse); |
|
3592 test(r == KErrCancel); |
|
3593 r = lddChan.CancelNotification(ClientId[3], Resources[aResId].iResourceId, ETrue); |
|
3594 test(r == KErrCancel); |
|
3595 newState = 1; |
|
3596 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3597 test(r == KErrNone); |
|
3598 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); |
|
3599 test(r == KErrNone); |
|
3600 r = lddChan.CancelNotification(ClientId[2], Resources[aResId].iResourceId, ETrue); |
|
3601 test(r == KErrCancel); |
|
3602 newState = 1; |
|
3603 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3604 test(r == KErrNone); |
|
3605 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); |
|
3606 test(r == KErrNone); |
|
3607 r = lddChan.DeRegisterClient(ClientId[0]); |
|
3608 test(r == KErrNone); |
|
3609 r = lddChan.DeRegisterClient(ClientId[2]); |
|
3610 test(r == KErrNone); |
|
3611 r = lddChan.DeRegisterClient(ClientId[3]); |
|
3612 test(r == KErrNone); |
|
3613 r = lddChan.GetResourceStateSync(ClientId[4], Resources[aResId].iResourceId, ETrue, newState, levelOwnerId); |
|
3614 test(r == KErrNone); |
|
3615 test(levelOwnerId == -1); |
|
3616 r = lddChan.DeRegisterClient(ClientId[4]); |
|
3617 test(r == KErrNone); |
|
3618 return; |
|
3619 } |
|
3620 |
|
3621 //---------------------------------------------------------------------------------------------- |
|
3622 //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0594 |
|
3623 //! @SYMTestType UT |
|
3624 //! @SYMPREQ PREQ1398 |
|
3625 //! @SYMTestCaseDesc This test case tests changing resource state of shared negative resource. |
|
3626 //! @SYMTestActions 0 Register client1 |
|
3627 //! 1 Register client2 |
|
3628 //! 2 Register client3 |
|
3629 //! 3 Register client4 |
|
3630 //! 4 Client1 change resource state. |
|
3631 //! 5 Client2 change resource state. |
|
3632 //! 6 Client3 change resource state. |
|
3633 //! 7 Client4 change resource state. |
|
3634 //! 8 Client1 change resource state. |
|
3635 //! 9 Client2 change resource state. |
|
3636 //! 10 Deregister client2 |
|
3637 //! 11 Client3 change resource state. |
|
3638 //! 12 Deregister client1 |
|
3639 //! 13 Deregister client3 |
|
3640 //! 14 Deregister client4 |
|
3641 //! |
|
3642 //! @SYMTestExpectedResults 0 Client registered |
|
3643 //! 1 Client registered |
|
3644 //! 2 Client registered |
|
3645 //! 3 Client registered |
|
3646 //! 4 Resource state changed |
|
3647 //! 5 Resource state changed |
|
3648 //! 6 Resource state changed |
|
3649 //! 7 Resource state changed |
|
3650 //! 8 Resource state changed |
|
3651 //! 9 Resource state changed |
|
3652 //! 10 Client2 deregistered |
|
3653 //! 11 Resource state changed |
|
3654 //! 12 Client1 deregistered |
|
3655 //! 13 Client3 deregistered |
|
3656 //! 14 Client4 deregistered |
|
3657 //! @SYMTestPriority High |
|
3658 //! @SYMTestStatus Implemented |
|
3659 //---------------------------------------------------------------------------------------------- |
|
3660 void TestRM::SharedBinaryNegativeResourceTesting(TUint aResId) |
|
3661 { |
|
3662 TInt newState; |
|
3663 TInt levelOwnerId; |
|
3664 TRequestStatus req; |
|
3665 TUint ClientId[5]; |
|
3666 |
|
3667 ClientName[6] = (TUint8)('0' + iMaxClientId+1); |
|
3668 r = lddChan.RegisterClient(ClientId[0], (const TDesC*)&ClientName); |
|
3669 test(r == KErrNone); |
|
3670 |
|
3671 r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, ETrue, newState, levelOwnerId); |
|
3672 test(r == KErrNone); |
|
3673 if(levelOwnerId != -1) |
|
3674 { |
|
3675 test.Printf(_L("Not testing the shared resource as some other client is currently holding the resource\n")); |
|
3676 r = lddChan.DeRegisterClient(ClientId[0]); |
|
3677 test(r == KErrNone); |
|
3678 return; |
|
3679 } |
|
3680 |
|
3681 ClientName[6] = (TUint8)('0' + iMaxClientId +2); |
|
3682 r = lddChan.RegisterClient(ClientId[1], (const TDesC*)&ClientName); |
|
3683 test(r == KErrNone); |
|
3684 ClientName[6] = (TUint8)('0' + iMaxClientId +3); |
|
3685 r = lddChan.RegisterClient(ClientId[2], (const TDesC*)&ClientName); |
|
3686 test(r == KErrNone); |
|
3687 ClientName[6] = (TUint8)('0' + iMaxClientId +4); |
|
3688 r = lddChan.RegisterClient(ClientId[3], (const TDesC*)&ClientName); |
|
3689 test(r == KErrNone); |
|
3690 ClientName[6] = (TUint8)('0' + iMaxClientId +5); |
|
3691 r = lddChan.RegisterClient(ClientId[4], (const TDesC*)&ClientName); |
|
3692 test(r == KErrNone); |
|
3693 |
|
3694 newState = 0; |
|
3695 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3696 test(r == KErrNone); |
|
3697 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); |
|
3698 test(r == KErrNone); |
|
3699 r = lddChan.RequestNotification(ClientId[1], Resources[aResId].iResourceId); |
|
3700 test(r == KErrNone); |
|
3701 r = lddChan.RequestNotification(ClientId[2], Resources[aResId].iResourceId); |
|
3702 test(r == KErrNone); |
|
3703 r = lddChan.RequestNotification(ClientId[3], Resources[aResId].iResourceId, 1, ETrue); |
|
3704 test(r == KErrNone); |
|
3705 r = lddChan.RequestNotification(ClientId[2], Resources[aResId].iResourceId, 0, EFalse); |
|
3706 test(r == KErrNone); |
|
3707 newState = !newState; //State 1 |
|
3708 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3709 test(r == KErrNone); |
|
3710 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 2, 1); |
|
3711 test(r == KErrNone); |
|
3712 newState = !newState; //State 0 |
|
3713 r = lddChan.ChangeResourceStateSync(ClientId[1], Resources[aResId].iResourceId, newState); |
|
3714 test(r == KErrNone); |
|
3715 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 2, 1); |
|
3716 test(r == KErrNone); |
|
3717 lddChan.ChangeResourceStateAsync(ClientId[2], Resources[aResId].iResourceId, newState, req); |
|
3718 User::WaitForRequest(req); //State 0 |
|
3719 test(req.Int() == KErrNone); |
|
3720 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); |
|
3721 test(r == KErrNone); |
|
3722 newState = !newState; //State 1 |
|
3723 r = lddChan.ChangeResourceStateSync(ClientId[3], Resources[aResId].iResourceId, newState); |
|
3724 test(r == KErrNone); |
|
3725 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); |
|
3726 test(r == KErrNone); |
|
3727 newState = !newState; //state 0 |
|
3728 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3729 test(r == KErrNone); |
|
3730 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); |
|
3731 newState = !newState; //state 1 |
|
3732 r = lddChan.ChangeResourceStateSync(ClientId[1], Resources[aResId].iResourceId, newState); |
|
3733 test(r == KErrNone); |
|
3734 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0,0); |
|
3735 test(r == KErrNone); |
|
3736 r = lddChan.DeRegisterClient(ClientId[1]); |
|
3737 test(r == KErrNone); |
|
3738 newState = 1; |
|
3739 r = lddChan.ChangeResourceStateSync(ClientId[2], Resources[aResId].iResourceId, newState); |
|
3740 test(r == KErrNone); |
|
3741 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0,0); |
|
3742 test(r == KErrNone); |
|
3743 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3744 test(r == KErrNone); |
|
3745 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 1,1); |
|
3746 test(r == KErrNone); |
|
3747 r = lddChan.CancelNotification(ClientId[2], Resources[aResId].iResourceId, EFalse); |
|
3748 test(r == KErrCancel); |
|
3749 r = lddChan.CancelNotification(ClientId[3], Resources[aResId].iResourceId, ETrue); |
|
3750 test(r == KErrCancel); |
|
3751 newState = 1; |
|
3752 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3753 test(r == KErrNone); |
|
3754 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); |
|
3755 test(r == KErrNone); |
|
3756 r = lddChan.CancelNotification(ClientId[2], Resources[aResId].iResourceId, ETrue); |
|
3757 test(r == KErrCancel); |
|
3758 newState = 1; |
|
3759 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3760 test(r == KErrNone); |
|
3761 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); |
|
3762 test(r == KErrNone); |
|
3763 r = lddChan.DeRegisterClient(ClientId[0]); |
|
3764 test(r == KErrNone); |
|
3765 r = lddChan.DeRegisterClient(ClientId[2]); |
|
3766 test(r == KErrNone); |
|
3767 r = lddChan.DeRegisterClient(ClientId[3]); |
|
3768 test(r == KErrNone); |
|
3769 r = lddChan.GetResourceStateSync(ClientId[4], Resources[aResId].iResourceId, ETrue, newState, levelOwnerId); |
|
3770 test(r == KErrNone); |
|
3771 test(levelOwnerId == -1); |
|
3772 r = lddChan.DeRegisterClient(ClientId[4]); |
|
3773 test(r == KErrNone); |
|
3774 return; |
|
3775 } |
|
3776 |
|
3777 //Test cases to test the shared multilevel negative resources |
|
3778 void TestRM::SharedMultilevelNegativeResourceTesting(TUint aResId) |
|
3779 { |
|
3780 TInt newState; |
|
3781 TInt levelOwnerId; |
|
3782 TRequestStatus req; |
|
3783 TUint ClientId[2]; |
|
3784 |
|
3785 //Register 1st client |
|
3786 ClientName[6] = (TUint8)('0' + iMaxClientId+1); |
|
3787 r = lddChan.RegisterClient(ClientId[0], (const TDesC*)&ClientName); |
|
3788 test(r == KErrNone); |
|
3789 |
|
3790 r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, ETrue, newState, levelOwnerId); |
|
3791 test(r == KErrNone); |
|
3792 if(levelOwnerId != -1) |
|
3793 { |
|
3794 test.Printf(_L("Not testing the shared resource as some other client is currently holding the resource\n")); |
|
3795 r = lddChan.DeRegisterClient(ClientId[0]); |
|
3796 test(r == KErrNone); |
|
3797 return; |
|
3798 } |
|
3799 |
|
3800 test.Printf(_L("Testing %d Shared Multilevel Negative Resource\n"), Resources[aResId].iResourceId); |
|
3801 |
|
3802 //Register 2nd client |
|
3803 ClientName[6] = (TUint8)('0' + iMaxClientId+2); |
|
3804 r = lddChan.RegisterClient(ClientId[1], (const TDesC*)&ClientName); |
|
3805 test(r == KErrNone); |
|
3806 |
|
3807 //Change the resource and ClientId[0] becomes the owner of the resource |
|
3808 newState = Resources[aResId].iMaxLevel + 10; |
|
3809 |
|
3810 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3811 test(r == KErrNone); |
|
3812 |
|
3813 TInt state; |
|
3814 r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, ETrue, state, levelOwnerId); |
|
3815 test(r == KErrNone); |
|
3816 test(state == newState); |
|
3817 test(levelOwnerId = (TInt)ClientId[0]); |
|
3818 |
|
3819 //Second client(clientId[1]) trying to change the resource, but still |
|
3820 newState = state +5; |
|
3821 lddChan.ChangeResourceStateAsync(ClientId[1], Resources[aResId].iResourceId, newState, req); |
|
3822 User::WaitForRequest(req); |
|
3823 test(req.Int() == KErrNone); |
|
3824 |
|
3825 lddChan.GetResourceStateAsync(ClientId[0], Resources[aResId].iResourceId, EFalse, req, newState, levelOwnerId); |
|
3826 User::WaitForRequest(req); |
|
3827 test(req.Int() == KErrNone); |
|
3828 test(state = newState); |
|
3829 test(levelOwnerId == (TInt)ClientId[0]); |
|
3830 |
|
3831 newState = state + 10; |
|
3832 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3833 test(r == KErrNone); |
|
3834 |
|
3835 r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, EFalse, state, levelOwnerId); |
|
3836 test(r == KErrNone); |
|
3837 newState = Resources[aResId].iMaxLevel + 15; |
|
3838 test(state == newState); |
|
3839 test(levelOwnerId == (TInt)ClientId[1]); |
|
3840 |
|
3841 r = lddChan.DeRegisterClientLevelFromResource(ClientId[1], Resources[aResId].iResourceId); |
|
3842 test(r == KErrNone); |
|
3843 |
|
3844 state = Resources[aResId].iMaxLevel + 20; |
|
3845 lddChan.GetResourceStateAsync(ClientId[1], Resources[aResId].iResourceId, ETrue, req, newState, levelOwnerId); |
|
3846 User::WaitForRequest(req); |
|
3847 test(req.Int() == KErrNone); |
|
3848 test(state == newState); |
|
3849 test(levelOwnerId == (TInt)ClientId[0]); |
|
3850 |
|
3851 newState = Resources[aResId].iMaxLevel + 10; |
|
3852 lddChan.ChangeResourceStateAsync(ClientId[1], Resources[aResId].iResourceId, newState, req); |
|
3853 User::WaitForRequest(req); |
|
3854 test(req.Int() == KErrNone); |
|
3855 |
|
3856 |
|
3857 lddChan.GetResourceStateAsync(ClientId[0], Resources[aResId].iResourceId, EFalse, req, state, levelOwnerId); |
|
3858 User::WaitForRequest(req); |
|
3859 test(req.Int() == KErrNone); |
|
3860 test(state == newState); |
|
3861 test(levelOwnerId == (TInt)ClientId[1]); |
|
3862 |
|
3863 r = lddChan.DeRegisterClient(ClientId[1]); |
|
3864 test(r == KErrNone); |
|
3865 |
|
3866 r = lddChan.DeRegisterClientLevelFromResource(ClientId[0], Resources[aResId].iResourceId); |
|
3867 test(r == KErrNone); |
|
3868 |
|
3869 r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, EFalse, state, levelOwnerId); |
|
3870 test(r == KErrNone); |
|
3871 test(state == Resources[aResId].iDefaultLevel); |
|
3872 test(levelOwnerId == -1); |
|
3873 |
|
3874 r = lddChan.DeRegisterClient(ClientId[0]); |
|
3875 test(r == KErrNone); |
|
3876 |
|
3877 return; |
|
3878 } |
|
3879 |
|
3880 //Test cases to test the shared multilevel positive resources |
|
3881 void TestRM::SharedMultilevelPositiveResourceTesting(TUint aResId) |
|
3882 { |
|
3883 TInt newState; |
|
3884 TInt levelOwnerId; |
|
3885 TRequestStatus req; |
|
3886 TUint ClientId[2]; |
|
3887 |
|
3888 //Register 1st client |
|
3889 ClientName[6] = (TUint8)('0' + iMaxClientId+1); |
|
3890 r = lddChan.RegisterClient(ClientId[0], (const TDesC*)&ClientName); |
|
3891 test(r == KErrNone); |
|
3892 |
|
3893 r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, ETrue, newState, levelOwnerId); |
|
3894 test(r == KErrNone); |
|
3895 if(levelOwnerId != -1) |
|
3896 { |
|
3897 test.Printf(_L("Not testing the shared resource as some other client is currently holding the resource\n")); |
|
3898 r = lddChan.DeRegisterClient(ClientId[0]); |
|
3899 test(r == KErrNone); |
|
3900 return; |
|
3901 } |
|
3902 |
|
3903 test.Printf(_L("Testing %d Shared Multilevel positive Resource\n"), Resources[aResId].iResourceId); |
|
3904 |
|
3905 //Register 2nd client |
|
3906 ClientName[6] = (TUint8)('0' + iMaxClientId+2); |
|
3907 r = lddChan.RegisterClient(ClientId[1], (const TDesC*)&ClientName); |
|
3908 test(r == KErrNone); |
|
3909 |
|
3910 //Change the resource and ClientId[0] becomes the owner of the resource |
|
3911 newState = Resources[aResId].iMinLevel + 20; |
|
3912 |
|
3913 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3914 test(r == KErrNone); |
|
3915 |
|
3916 TInt state; |
|
3917 r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, ETrue, state, levelOwnerId); |
|
3918 test(r == KErrNone); |
|
3919 test(state == newState); |
|
3920 test(levelOwnerId = (TInt)ClientId[0]); |
|
3921 |
|
3922 //Second client(clientId[1]) trying to change the resource, but still |
|
3923 newState = Resources[aResId].iMinLevel +10; |
|
3924 lddChan.ChangeResourceStateAsync(ClientId[1], Resources[aResId].iResourceId, newState, req); |
|
3925 User::WaitForRequest(req); |
|
3926 test(req.Int() == KErrNone); |
|
3927 |
|
3928 lddChan.GetResourceStateAsync(ClientId[0], Resources[aResId].iResourceId, EFalse, req, newState, levelOwnerId); |
|
3929 User::WaitForRequest(req); |
|
3930 test(req.Int() == KErrNone); |
|
3931 test(state = newState); |
|
3932 test(levelOwnerId == (TInt)ClientId[0]); |
|
3933 |
|
3934 newState = Resources[aResId].iMinLevel + 5; |
|
3935 r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); |
|
3936 test(r == KErrNone); |
|
3937 |
|
3938 r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, EFalse, state, levelOwnerId); |
|
3939 test(r == KErrNone); |
|
3940 test(state == Resources[aResId].iMinLevel+10); |
|
3941 test(levelOwnerId == (TInt)ClientId[1]); |
|
3942 |
|
3943 r = lddChan.DeRegisterClientLevelFromResource(ClientId[1], Resources[aResId].iResourceId); |
|
3944 test(r == KErrNone); |
|
3945 |
|
3946 newState = Resources[aResId].iMinLevel + 5; |
|
3947 lddChan.GetResourceStateAsync(ClientId[1], Resources[aResId].iResourceId, ETrue, req, state, levelOwnerId); |
|
3948 User::WaitForRequest(req); |
|
3949 test(req.Int() == KErrNone); |
|
3950 test(state == newState); |
|
3951 test(levelOwnerId == (TInt)ClientId[0]); |
|
3952 |
|
3953 newState = Resources[aResId].iMinLevel + 10; |
|
3954 lddChan.ChangeResourceStateAsync(ClientId[1], Resources[aResId].iResourceId, newState, req); |
|
3955 User::WaitForRequest(req); |
|
3956 test(req.Int() == KErrNone); |
|
3957 |
|
3958 |
|
3959 lddChan.GetResourceStateAsync(ClientId[0], Resources[aResId].iResourceId, EFalse, req, state, levelOwnerId); |
|
3960 User::WaitForRequest(req); |
|
3961 test(req.Int() == KErrNone); |
|
3962 test(state == newState); |
|
3963 test(levelOwnerId == (TInt)ClientId[1]); |
|
3964 |
|
3965 r = lddChan.DeRegisterClient(ClientId[1]); |
|
3966 test(r == KErrNone); |
|
3967 |
|
3968 r = lddChan.DeRegisterClientLevelFromResource(ClientId[0], Resources[aResId].iResourceId); |
|
3969 test(r == KErrNone); |
|
3970 |
|
3971 r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, EFalse, state, levelOwnerId); |
|
3972 test(r == KErrNone); |
|
3973 test(state == Resources[aResId].iDefaultLevel); |
|
3974 test(levelOwnerId == -1); |
|
3975 |
|
3976 r = lddChan.DeRegisterClient(ClientId[0]); |
|
3977 test(r == KErrNone); |
|
3978 |
|
3979 return; |
|
3980 } |
|
3981 |
|
3982 //Custom resource testing. This testing is done only with simulated resources. |
|
3983 //Testing of shared binary positive resource. |
|
3984 //---------------------------------------------------------------------------------------------- |
|
3985 //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0593 |
|
3986 //! @SYMTestType UT |
|
3987 //! @SYMPREQ PREQ1398 |
|
3988 //! @SYMTestCaseDesc This test case tests changing resource state of shared positive resource. |
|
3989 //! @SYMTestActions 0 Register client1 |
|
3990 //! 1 Register client2 |
|
3991 //! 2 Register client3 |
|
3992 //! 3 Register client4 |
|
3993 //! 4 Client1 change resource state. |
|
3994 //! 5 Client2 change resource state. |
|
3995 //! 6 Client3 get resource state. |
|
3996 //! 7 Client4 get resource state. |
|
3997 //! 8 Client1 change resource state. |
|
3998 //! 9 Client2 get resource state. |
|
3999 //! 10 Deregister client2 |
|
4000 //! 11 Deregister client1 |
|
4001 //! 12 Deregister client3 |
|
4002 //! 13 Deregister client4 |
|
4003 //! |
|
4004 //! @SYMTestExpectedResults 0 Client registered |
|
4005 //! 1 Client registered |
|
4006 //! 2 Client registered |
|
4007 //! 3 Client registered |
|
4008 //! 4 Resource state changed |
|
4009 //! 5 Resource state changed |
|
4010 //! 6 Resource state read and compared for correctness |
|
4011 //! 7 Resource state read and compared for correctness |
|
4012 //! 8 Resource state changed |
|
4013 //! 9 Resource state read and compared for correctness |
|
4014 //! 10 Client2 deregistered |
|
4015 //! 11 Client1 deregistered |
|
4016 //! 12 Client3 deregistered |
|
4017 //! 13 Client4 deregistered |
|
4018 //! @SYMTestPriority High |
|
4019 //! @SYMTestStatus Implemented |
|
4020 //---------------------------------------------------------------------------------------------- |
|
4021 void TestRM::CustomResourceTesting(TUint aResId) |
|
4022 { |
|
4023 test.Printf(_L("Testing custom function\n")); |
|
4024 TInt r = KErrNone; |
|
4025 TRequestStatus req; |
|
4026 TInt state; |
|
4027 TInt newState; |
|
4028 TInt levelOwnerId; |
|
4029 TUint ClientId[4]; |
|
4030 ClientName[6] = (TUint8)('0' + iMaxClientId +1); |
|
4031 r = lddChan.RegisterClient(ClientId[0], (const TDesC*)&ClientName); |
|
4032 test(r == KErrNone); |
|
4033 ClientName[6] = (TUint8)('0' + iMaxClientId +2); |
|
4034 r = lddChan.RegisterClient(ClientId[1], (const TDesC*)&ClientName); |
|
4035 test(r == KErrNone); |
|
4036 ClientName[6] = (TUint8)('0' + iMaxClientId +3); |
|
4037 r = lddChan.RegisterClient(ClientId[2], (const TDesC*)&ClientName); |
|
4038 test(r == KErrNone); |
|
4039 ClientName[6] = (TUint8)('0' + iMaxClientId +4); |
|
4040 r = lddChan.RegisterClient(ClientId[3], (const TDesC*)&ClientName); |
|
4041 test(r == KErrNone); |
|
4042 r = lddChan.RequestNotification(ClientId[0], Resources[aResId].iResourceId); |
|
4043 test(r == KErrNone); |
|
4044 r = lddChan.RequestNotification(ClientId[1], Resources[aResId].iResourceId); |
|
4045 test(r == KErrNone); |
|
4046 newState = 1; |
|
4047 state = 1; |
|
4048 lddChan.ChangeResourceStateAsync(ClientId[2], Resources[aResId].iResourceId, state, req); |
|
4049 User::WaitForRequest(req); //State 1 |
|
4050 test(req.Int() == KErrNone); |
|
4051 test(state == newState); |
|
4052 test(r == KErrNone); |
|
4053 r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 2, 0); |
|
4054 test(r == KErrNone); |
|
4055 state = 0; |
|
4056 lddChan.ChangeResourceStateAsync(ClientId[1], Resources[aResId].iResourceId, state, req); |
|
4057 User::WaitForRequest(req); |
|
4058 test(req.Int() == KErrNone); |
|
4059 test(state == newState); |
|
4060 r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, EFalse, state, levelOwnerId); |
|
4061 test(r == KErrNone); |
|
4062 test(state == 1); |
|
4063 lddChan.ChangeResourceStateAsync(ClientId[0], Resources[aResId].iResourceId, state, req); |
|
4064 User::WaitForRequest(req); |
|
4065 test(req.Int() == KErrNone); |
|
4066 test(state == newState); |
|
4067 r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, ETrue, state, levelOwnerId); |
|
4068 test(r == KErrNone); |
|
4069 test((TUint)levelOwnerId == ClientId[2]); |
|
4070 r = lddChan.ChangeResourceStateSync(ClientId[2], Resources[aResId].iResourceId, 0); |
|
4071 test(r == KErrNone); |
|
4072 r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, EFalse, state, levelOwnerId); |
|
4073 test(r == KErrNone); |
|
4074 test(state == 1); |
|
4075 test((TUint)levelOwnerId == ClientId[0]); |
|
4076 r = lddChan.DeRegisterClient(ClientId[0]); |
|
4077 test(r == KErrNone); |
|
4078 r = lddChan.DeRegisterClientLevelFromResource(ClientId[1], Resources[aResId].iResourceId); |
|
4079 test(r == KErrNone); |
|
4080 r= lddChan.DeRegisterClient(ClientId[2]); |
|
4081 test(r == KErrNone); |
|
4082 r = lddChan.GetResourceStateSync(ClientId[3], Resources[aResId].iResourceId, ETrue, state, levelOwnerId); |
|
4083 test(r == KErrNone); |
|
4084 test(levelOwnerId == -1); |
|
4085 r = lddChan.DeRegisterClient(ClientId[3]); |
|
4086 test(r == KErrNone); |
|
4087 r = lddChan.DeRegisterClient(ClientId[1]); |
|
4088 test(r == KErrNone); |
|
4089 return; |
|
4090 } |
|
4091 |
|
4092 //Resource manager operations are chosen randomly and tested for correctness. This is done only in |
|
4093 //simulated resources. Currently this runs for 500 iteration. |
|
4094 //NOTE: Increasing the iteration to more than 500 may fail due to insufficient internal buffers. |
|
4095 void TestRM::RegressionTest() |
|
4096 { |
|
4097 TUint operation = 0; |
|
4098 TUint resourceId; |
|
4099 TUint count; |
|
4100 NegativeTesting = 0; |
|
4101 iMaxClientId = 0; |
|
4102 iMaxStaticResources = 0; |
|
4103 iMaxStaticDependentResources = 0; |
|
4104 iMaxClients = 0; |
|
4105 RmTest.RegisterClient(); |
|
4106 iCurrentClientId = -1; |
|
4107 r = lddChan.GetResourceControllerVersion(Clients[0].iClientId, iTestingExtendedVersion); |
|
4108 if(r != KErrNone) |
|
4109 test.Printf(_L("Return value of GetResourceControllerVersion %d\n"), r); |
|
4110 test(r == KErrNone); |
|
4111 if(!iTestingExtendedVersion) |
|
4112 test.Printf(_L("Testing Basic Version only....")); |
|
4113 else |
|
4114 test.Printf(_L("Testing basic & extended version....")); |
|
4115 RmTest.GetNumResourcesInUseByClient(iCurrentClientId); |
|
4116 RmTest.GetInfoOnResourcesInUseByClient(iCurrentClientId, iMaxStaticResources); |
|
4117 if(!(Resources[0].iName.Compare(*(const TDesC8*)&SpecialResName))) |
|
4118 { |
|
4119 TBuf8<32> PowerController = _L8("PowerController"); |
|
4120 r = lddChan.GetClientId(Clients[0].iClientId, (TDesC8&)PowerController, iPowerControllerId); |
|
4121 test(r == KErrNone); |
|
4122 } |
|
4123 else |
|
4124 { |
|
4125 test.Printf(_L("Regression testing is run only on simulator")); |
|
4126 return; |
|
4127 } |
|
4128 |
|
4129 for(count = 0; count < 500; count++) |
|
4130 { |
|
4131 operation = Math::Random() % EOperationEnd; |
|
4132 iCurrentClientId = Math::Random() % iMaxClients; |
|
4133 resourceId = Math::Random() % iMaxStaticResources; |
|
4134 if(operation != ERegisterClient) |
|
4135 { |
|
4136 if(Clients[iCurrentClientId].iClientId == 0) //Not a valid client |
|
4137 continue; |
|
4138 } |
|
4139 if(Resources[resourceId].iSense == ECustom) |
|
4140 continue; |
|
4141 test.Printf(_L("\nOperation = %d, ClientId = %d, ResourceId = %d\n"), operation, iCurrentClientId, resourceId); |
|
4142 switch (operation) |
|
4143 { |
|
4144 case ERegisterClient: |
|
4145 RmTest.RegisterClient(); |
|
4146 break; |
|
4147 case EGetClientName: |
|
4148 RmTest.GetClientName(iCurrentClientId); |
|
4149 break; |
|
4150 case EGetAllClientName: |
|
4151 RmTest.GetClientName(0); |
|
4152 break; |
|
4153 case EGetClientId: |
|
4154 RmTest.GetClientId(iCurrentClientId); |
|
4155 break; |
|
4156 case EGetResourceId: |
|
4157 RmTest.GetResourceId(resourceId); |
|
4158 break; |
|
4159 case EGetResourceInfo: |
|
4160 RmTest.GetResourceInfo(resourceId); |
|
4161 break; |
|
4162 case EGetNumReosourceInUseByClient: |
|
4163 RmTest.GetNumResourcesInUseByClient(iCurrentClientId); |
|
4164 break; |
|
4165 case EGetInfoOnResourceInUseByClient: |
|
4166 test.Printf(_L("NumResources = %d\n"), Clients[iCurrentClientId].iNumResources); |
|
4167 RmTest.GetInfoOnResourcesInUseByClient(iCurrentClientId, Clients[iCurrentClientId].iNumResources); |
|
4168 break; |
|
4169 case EGetNumClientsUsingResource: |
|
4170 if(resourceId == 0) |
|
4171 { |
|
4172 RmTest.GetNumClientsUsingResource(iCurrentClientId, (TUint)-1); |
|
4173 } |
|
4174 else |
|
4175 { |
|
4176 RmTest.GetNumClientsUsingResource(iCurrentClientId, resourceId); |
|
4177 } |
|
4178 break; |
|
4179 case EGetInfoOnClientsUsingResource: |
|
4180 if(resourceId == 0) |
|
4181 RmTest.GetInfoOnClientsUsingResource((TUint)-1, iMaxClients+1); |
|
4182 else |
|
4183 { |
|
4184 test.Printf(_L("NumResources = %d\n"), Resources[resourceId].iNumClients); |
|
4185 RmTest.GetInfoOnClientsUsingResource(resourceId, Resources[resourceId].iNumClients); |
|
4186 } |
|
4187 break; |
|
4188 case EChangeResourceStateSync: |
|
4189 RmTest.ChangeResourceStateSync(resourceId); |
|
4190 break; |
|
4191 case EChangeResourceStateAsync: |
|
4192 RmTest.ChangeResourceStateAsync(resourceId); |
|
4193 break; |
|
4194 case EGetResourceStateSync: |
|
4195 RmTest.GetResourceStateSync(resourceId); |
|
4196 break; |
|
4197 case EGetResourceStateAsync: |
|
4198 RmTest.GetResourceStateAsync(resourceId); |
|
4199 break; |
|
4200 case ERequestNotificationCond: |
|
4201 RmTest.RequestNotificationCon(resourceId); |
|
4202 break; |
|
4203 case ERequestNotificationUnCond: |
|
4204 RmTest.RequestNotification(resourceId); |
|
4205 break; |
|
4206 case ECancelNotificationCond: |
|
4207 RmTest.CancelNotification(resourceId, ETrue); |
|
4208 break; |
|
4209 case ECancelNotificationUnCond: |
|
4210 RmTest.CancelNotification(resourceId, EFalse); |
|
4211 break; |
|
4212 } |
|
4213 } |
|
4214 //CleanUp |
|
4215 test.Printf(_L("Cleanup of all Clients\n")); |
|
4216 TInt clientCount = Clients.Count(); |
|
4217 for(count = clientCount-1; ((TInt)count) >=0; count--) |
|
4218 { |
|
4219 if(Clients[count].iClientId == 0) |
|
4220 continue; |
|
4221 test.Printf(_L("ClientId deregistration of %d\n"), Clients[count].iClientId); |
|
4222 RmTest.DeRegisterClient(count); |
|
4223 } |
|
4224 Clients.Close(); |
|
4225 } |
|
4226 |
|
4227 GLDEF_C TInt E32Main() |
|
4228 { |
|
4229 test.Title(); |
|
4230 test.Start(_L("Testing Resource Manager...\n")); |
|
4231 test.Next(_L("Load Physical device")); |
|
4232 #ifndef PRM_ENABLE_EXTENDED_VERSION |
|
4233 r = User::LoadPhysicalDevice(KPddFileName); |
|
4234 test(r==KErrNone || r==KErrAlreadyExists); |
|
4235 test.Next(_L("Load Logical Device")); |
|
4236 r=User::LoadLogicalDevice(KLddFileName); |
|
4237 test(r==KErrNone || r==KErrAlreadyExists); |
|
4238 __KHEAP_MARK; //Heap testing is done only for basic version |
|
4239 #else |
|
4240 r = User::LoadPhysicalDevice(KExtPddFileName); |
|
4241 test(r==KErrNone || r==KErrAlreadyExists); |
|
4242 test.Next(_L("Load Logical Device")); |
|
4243 r=User::LoadLogicalDevice(KExtLddFileName); |
|
4244 test(r==KErrNone || r==KErrAlreadyExists); |
|
4245 #endif |
|
4246 r = lddChan.Open(); |
|
4247 test(r==KErrNone || r==KErrAlreadyExists); |
|
4248 //Check whether the notifications recieved as a result of postboot level setting is as expected. |
|
4249 r = lddChan.CheckPostBootLevelNotifications(); |
|
4250 test(r == KErrNone); |
|
4251 TBool regressionTesting = EFalse; |
|
4252 //Parse the command line arguments. |
|
4253 TBuf<0x50> cmd; |
|
4254 User::CommandLine(cmd); |
|
4255 TLex lex(cmd); |
|
4256 lex.SkipSpace(); |
|
4257 if(lex.Get() == '-') |
|
4258 { |
|
4259 TChar letter = lex.Get(); |
|
4260 if((letter == 'R') || (letter == 'r')) |
|
4261 regressionTesting = ETrue; |
|
4262 } |
|
4263 if(regressionTesting) |
|
4264 RmTest.RegressionTest(); |
|
4265 else |
|
4266 RmTest.APIValidationTest(); |
|
4267 test.Printf(_L("Closing the channel\n")); |
|
4268 lddChan.Close(); |
|
4269 test.Printf(_L("Freeing logical device\n")); |
|
4270 #ifndef PRM_ENABLE_EXTENDED_VERSION |
|
4271 __KHEAP_MARKEND; |
|
4272 r = User::FreeLogicalDevice(KLddFileName); |
|
4273 test(r==KErrNone); |
|
4274 r = User::FreePhysicalDevice(KPddFileName); |
|
4275 test(r==KErrNone); |
|
4276 #else |
|
4277 r = User::FreeLogicalDevice(KExtLddFileName); |
|
4278 test(r==KErrNone); |
|
4279 r = User::FreePhysicalDevice(KExtPddFileName); |
|
4280 test(r==KErrNone); |
|
4281 #endif |
|
4282 User::After(100000); |
|
4283 test.End(); |
|
4284 test.Close(); |
|
4285 return KErrNone; |
|
4286 } |
|
4287 |