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