279
|
1 |
// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
|
0
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
//
|
|
15 |
|
|
16 |
#include <e32test.h>
|
|
17 |
#include <e32def.h>
|
|
18 |
#include <e32def_private.h>
|
|
19 |
|
|
20 |
#include <d32resmanus.h>
|
|
21 |
|
|
22 |
#ifdef PRM_ENABLE_EXTENDED_VERSION
|
|
23 |
#define LDD_NAME _L("resourcecontrollerextended.ldd")
|
|
24 |
#else
|
|
25 |
#define LDD_NAME _L("resourcecontrol.ldd")
|
|
26 |
#endif
|
|
27 |
|
|
28 |
#ifdef PRM_ENABLE_EXTENDED_VERSION
|
|
29 |
#define PDD_NAME _L("resourcecontrollerextended.pdd")
|
|
30 |
#else
|
|
31 |
#define PDD_NAME _L("resourcecontroller.pdd")
|
|
32 |
#endif
|
|
33 |
|
|
34 |
//#define PIRATE_THREAD_TESTS
|
|
35 |
|
|
36 |
_LIT(testableResourceName,"SymbianSimulResource");
|
|
37 |
|
|
38 |
#ifdef RESMANUS_KERN
|
|
39 |
_LIT(testName,"t_resmanuskern");
|
|
40 |
#else
|
|
41 |
_LIT(testName,"t_resmanus");
|
|
42 |
#endif
|
|
43 |
|
|
44 |
TBuf<16> gTestName(testName);
|
|
45 |
|
|
46 |
GLDEF_D RBusDevResManUs gChannel;
|
|
47 |
|
|
48 |
TUint8 KNoOfGetStateRequests = 5;
|
|
49 |
TUint8 KNoOfSetStateRequests = 4;
|
|
50 |
TUint8 KNoOfNotifyRequests = 7;
|
|
51 |
#define MAX_NUM_REQUESTS 8 // Must be (at least) one greater than the largest of
|
|
52 |
// KNoOfGetStateRequests, KNoOfSetStateRequests, KNoOfNotifyRequests
|
|
53 |
#ifdef _DEBUG
|
|
54 |
TUint gLongLatencyResource;
|
|
55 |
TBool gHaveAsyncRes = EFalse;
|
|
56 |
TInt gAsyncResStateDelta = 0;
|
|
57 |
|
|
58 |
TUint gSharedResource;
|
|
59 |
TBool gHaveSharedRes = EFalse;
|
|
60 |
TInt gSharedResStateDelta = 0;
|
|
61 |
#else
|
|
62 |
// The UREL version of the driver will not implement the arrays and functionality required
|
|
63 |
// to determine the async and shared resources to use at runtime. The values provided here
|
|
64 |
// have been pre-determined to operate successfully with the simulated PSL.
|
|
65 |
//
|
|
66 |
TUint gLongLatencyResource = 6;
|
|
67 |
TBool gHaveAsyncRes = ETrue;
|
|
68 |
TInt gAsyncResStateDelta = -1;
|
|
69 |
|
|
70 |
TUint gSharedResource = 12;
|
|
71 |
TBool gHaveSharedRes = ETrue;
|
|
72 |
TInt gSharedResStateDelta = -1;
|
|
73 |
#endif
|
|
74 |
|
|
75 |
TBool gUseCached = EFalse;
|
|
76 |
|
244
|
77 |
class RTestSafe: public RTest
|
|
78 |
{
|
|
79 |
public:
|
|
80 |
RTestSafe(const TDesC &aTitle) :
|
|
81 |
RTest(aTitle), iCleanUpLevelMask (0), iFailHdnFunc(NULL)
|
|
82 |
{
|
|
83 |
}
|
|
84 |
RTestSafe(const TDesC &aTitle, void(*func)(RTestSafe &aTest)) :
|
|
85 |
RTest(aTitle), iFailHdnFunc(func)
|
|
86 |
{
|
|
87 |
}
|
|
88 |
|
|
89 |
// new version of operator(int), which calls our cleanup handler if check has failed
|
|
90 |
void operator()(TInt aResult)
|
|
91 |
{
|
|
92 |
if(!aResult && iFailHdnFunc)
|
|
93 |
iFailHdnFunc(*this);
|
|
94 |
RTest::operator ()(aResult);
|
|
95 |
}
|
|
96 |
|
|
97 |
void operator()(TInt aResult, TInt aLineNum)
|
|
98 |
{
|
|
99 |
if(!aResult && iFailHdnFunc)
|
|
100 |
iFailHdnFunc(*this);
|
|
101 |
RTest::operator ()(aResult, aLineNum);
|
|
102 |
}
|
|
103 |
|
|
104 |
void operator()(TInt aResult, TInt aLineNum, const TText* aFileName)
|
|
105 |
{
|
|
106 |
if(!aResult && iFailHdnFunc)
|
|
107 |
iFailHdnFunc(*this);
|
|
108 |
RTest::operator ()(aResult, aLineNum, aFileName);
|
|
109 |
}
|
|
110 |
|
|
111 |
// new version of End, which calls handler before exit..
|
|
112 |
void End()
|
|
113 |
{
|
|
114 |
if(iFailHdnFunc)
|
|
115 |
iFailHdnFunc(*this);
|
|
116 |
RTest::End();
|
|
117 |
}
|
|
118 |
|
|
119 |
void SetCleanupFlag(TUint aFlag)
|
|
120 |
{
|
|
121 |
iCleanUpLevelMask |= 1 << aFlag;
|
|
122 |
}
|
|
123 |
|
|
124 |
TBool CleanupNeeded(TUint aFlag)
|
|
125 |
{
|
|
126 |
return (iCleanUpLevelMask & (1 << aFlag)) >> aFlag;
|
|
127 |
}
|
|
128 |
|
|
129 |
TUint iCleanUpLevelMask;
|
|
130 |
void (*iFailHdnFunc)(RTestSafe &aTest);
|
|
131 |
};
|
|
132 |
|
|
133 |
// cleanup handler
|
|
134 |
enum TCleanupLevels
|
|
135 |
{
|
|
136 |
EPddLoaded = 0,
|
|
137 |
ELddLoaded,
|
|
138 |
EChannelOpened
|
|
139 |
};
|
|
140 |
|
|
141 |
|
|
142 |
void TestCleanup(RTestSafe &aTest)
|
|
143 |
{
|
|
144 |
// cleanup for all 3 levels..
|
|
145 |
if(aTest.CleanupNeeded(EChannelOpened))
|
|
146 |
{
|
|
147 |
gChannel.Close();
|
|
148 |
}
|
|
149 |
|
|
150 |
if(aTest.CleanupNeeded(ELddLoaded))
|
|
151 |
{
|
|
152 |
User::FreeLogicalDevice(KLddRootName);
|
|
153 |
}
|
|
154 |
|
|
155 |
if(aTest.CleanupNeeded(EPddLoaded))
|
|
156 |
{
|
|
157 |
User::FreePhysicalDevice(PDD_NAME);
|
|
158 |
}
|
|
159 |
}
|
|
160 |
|
|
161 |
// global gTest object..
|
|
162 |
RTestSafe gTest(testName, &TestCleanup);
|
|
163 |
|
|
164 |
LOCAL_C TInt CheckCaps()
|
|
165 |
{
|
|
166 |
TInt r = KErrNone;
|
|
167 |
RDevice d;
|
|
168 |
TPckgBuf<TCapsDevResManUs> caps;
|
|
169 |
r = d.Open(KLddRootName);
|
|
170 |
if(r == KErrNone)
|
|
171 |
{
|
|
172 |
d.GetCaps(caps);
|
|
173 |
d.Close();
|
|
174 |
|
|
175 |
TVersion ver = caps().version;
|
|
176 |
if(ver.iMajor != 1 || ver.iMinor != 0 || ver.iBuild != KE32BuildVersionNumber)
|
|
177 |
{
|
|
178 |
gTest.Printf(_L("Capabilities returned wrong version"));
|
|
179 |
gTest.Printf(_L("Expected(1, 0, %d), got (%d , %d, %d)"),
|
|
180 |
KE32BuildVersionNumber, ver.iMajor, ver.iMinor, ver.iBuild);
|
|
181 |
r = KErrGeneral;
|
|
182 |
}
|
|
183 |
}
|
|
184 |
return r;
|
|
185 |
}
|
|
186 |
|
0
|
187 |
LOCAL_C TInt OpenChannel(TDesC16& aName, RBusDevResManUs& aChannel)
|
|
188 |
{
|
|
189 |
TInt r = KErrNone;
|
|
190 |
// API accepts 8-bit descriptors, only - so convert name accordingly
|
|
191 |
TBuf8<MAX_RESOURCE_NAME_LENGTH+1>EightBitName;
|
|
192 |
EightBitName.Copy(aName);
|
|
193 |
r=(aChannel.Open(EightBitName));
|
|
194 |
if (r!=KErrNone)
|
|
195 |
gTest.Printf(_L("OpenChannel: Handle for channel %S error code =0x%x\n"),&aName,r);
|
|
196 |
else
|
|
197 |
gTest.Printf(_L("OpenChannel: Handle for channel %S =0x%x\n"),&aName,aChannel.Handle());
|
|
198 |
return r;
|
|
199 |
}
|
|
200 |
|
|
201 |
LOCAL_C TInt HelperResources()
|
|
202 |
//
|
|
203 |
// Helper method to support OpenAndRegisterChannel
|
|
204 |
// Invokes GetNoOfResources, GetAllResourcesInfo and GetResourceIdByName
|
|
205 |
//
|
|
206 |
{
|
|
207 |
TInt r = KErrNone;
|
|
208 |
|
|
209 |
__KHEAP_MARK;
|
|
210 |
|
|
211 |
// Check what resources are available
|
|
212 |
gTest.Printf(_L("**Test GetNoOfResources\n"));
|
|
213 |
TUint numResources=0;
|
|
214 |
if((r=gChannel.GetNoOfResources(numResources))!=KErrNone)
|
|
215 |
{
|
|
216 |
gTest.Printf(_L("GetNoOfResources for test channel returned %d\n"),r);
|
|
217 |
return r;
|
|
218 |
}
|
|
219 |
gTest.Printf(_L("Number of resources = %d (=0x%x)\n"),numResources,numResources);
|
|
220 |
|
|
221 |
// Read the resource information
|
|
222 |
gTest.Printf(_L("**Test GetAllResourcesInfo\n"));
|
|
223 |
|
|
224 |
// To support the GetAllResourcesInfo testing, instantiate TResourceInfoBuf objects
|
|
225 |
// and reference via an RSimplePointerArray
|
|
226 |
TUint bufSize = numResources;
|
|
227 |
RSimplePointerArray<TResourceInfoBuf> infoPtrs(bufSize);
|
|
228 |
for(TUint i=0;i<bufSize;i++)
|
|
229 |
{
|
|
230 |
TResourceInfoBuf *info = new TResourceInfoBuf();
|
|
231 |
if((r=infoPtrs.Insert(info, i))!=KErrNone)
|
|
232 |
{
|
|
233 |
gTest.Printf(_L("GetAllResourcesInfo infoPtrs.Insert at index %d returned %d\n"),i,r);
|
|
234 |
}
|
|
235 |
}
|
|
236 |
TUint updateNumResources=numResources;
|
|
237 |
if((r=gChannel.GetAllResourcesInfo(&infoPtrs,updateNumResources))!=KErrNone)
|
|
238 |
{
|
|
239 |
gTest.Printf(_L("GetAllResourcesInfo for channel returned %d\n"),r);
|
|
240 |
return r;
|
|
241 |
}
|
|
242 |
gTest.Printf(_L("Updated number of resources = %d\n"),updateNumResources);
|
|
243 |
|
|
244 |
#ifdef _DEBUG
|
|
245 |
// Print resource names
|
|
246 |
{
|
|
247 |
TBuf16<MAX_RESOURCE_NAME_LENGTH+1>name;
|
|
248 |
for(TUint i=0; i<updateNumResources; i++)
|
|
249 |
{
|
|
250 |
TResourceInfoBuf* currRes = infoPtrs[i];
|
|
251 |
name.Copy((*currRes)().iName);
|
|
252 |
name.PtrZ();
|
|
253 |
gTest.Printf(_L("Resource %d name = %S \n"),i,&name);
|
|
254 |
};
|
|
255 |
}
|
|
256 |
#endif
|
|
257 |
|
|
258 |
// Select a resource to use, then pass its name to GetResourceIdByName
|
|
259 |
// to check that the corresponding resource ID is acquired.
|
|
260 |
TResourceInfo currRes = (*infoPtrs[0])();
|
|
261 |
if(updateNumResources>1)
|
|
262 |
currRes=(*infoPtrs[1])();// First resource may be a dummy
|
|
263 |
TUint resourceId;
|
|
264 |
gTest.Printf(_L("Invoking GetResourceIdByName for last resource name extracted \n"));
|
|
265 |
if((r=gChannel.GetResourceIdByName(currRes.iName, resourceId))!=KErrNone)
|
|
266 |
{
|
|
267 |
gTest.Printf(_L("GetResourceIdByName for channel returned %d \n"),r);
|
|
268 |
return r;
|
|
269 |
}
|
|
270 |
gTest.Printf(_L("GetResourceIdByName gave ID = %d\n"),resourceId);
|
|
271 |
|
|
272 |
infoPtrs.Close();
|
|
273 |
|
|
274 |
__KHEAP_MARKEND;
|
|
275 |
|
|
276 |
return r;
|
|
277 |
}
|
|
278 |
|
|
279 |
LOCAL_C TInt CheckForSimulatedResources()
|
|
280 |
//
|
|
281 |
// Get the name of the first resource - if it does not match the expected name
|
|
282 |
// then the testing must not proceed, so return the relevant error code
|
|
283 |
//
|
|
284 |
{
|
|
285 |
TInt r = KErrNone;
|
|
286 |
TResourceInfoBuf buffer;
|
|
287 |
if((r=gChannel.GetResourceInfo(1, &buffer))!=KErrNone) // first resource ID = 1
|
|
288 |
{
|
|
289 |
gTest.Printf(_L("CheckForSimulatedResources, candidate get resource info returned %d\n"),r);
|
|
290 |
return r;
|
|
291 |
}
|
|
292 |
// Check the name of the resource
|
|
293 |
TBuf16<MAX_RESOURCE_NAME_LENGTH+1>name;
|
|
294 |
name.Copy(buffer().iName);
|
|
295 |
name.PtrZ();
|
|
296 |
if((r=name.Compare(testableResourceName))!=KErrNone)
|
|
297 |
{
|
|
298 |
gTest.Printf(_L("Resource name = %S, require %S \n"),&name,&testableResourceName);
|
|
299 |
r=KErrNotSupported;
|
|
300 |
}
|
|
301 |
return r;
|
|
302 |
}
|
|
303 |
|
|
304 |
//----------------------------------------------------------------------------------------------
|
|
305 |
//! @SYMTestCaseID KBASE-T_RESMANUS-0607
|
|
306 |
//! @SYMTestType UT
|
|
307 |
//! @SYMPREQ PREQ1398
|
|
308 |
//! @SYMTestCaseDesc This test case tests channel opening and initialisation APIs.
|
|
309 |
//! @SYMTestActions 0) Call Open API with a valid name.
|
|
310 |
//!
|
|
311 |
//! 1) Call Open API for two more channels
|
|
312 |
//! (to demonstrate multiple clients (channels) can be supported concurrently).
|
|
313 |
//!
|
|
314 |
//! 2) Call Open with an oversized name.
|
|
315 |
//!
|
|
316 |
//! 3) Call GetNoOfResources API
|
|
317 |
//!
|
|
318 |
//! 4) Call GetAllResourcesInfo API
|
|
319 |
//!
|
|
320 |
//! 5) Call GetResourceIdByName API for last of resource names gathered
|
|
321 |
//! in previous step
|
|
322 |
//!
|
|
323 |
//! 6) Call Initialise API on the channel originally created, with non-zero arguments.
|
|
324 |
//!
|
|
325 |
//! @SYMTestExpectedResults 0) API should return with KErrNone, exits otherwise.
|
|
326 |
//! 1) API should return with KErrNone, exits otherwise.
|
|
327 |
//! 2) API should return with KErrBadName, exits otherwise.
|
|
328 |
//! 3) API should return with KErrNone, exits otherwise.
|
|
329 |
//! 4) API should return with KErrNone, exits otherwise.
|
|
330 |
//! 5) API should return with KErrNone, exits otherwise.
|
|
331 |
//! 6) API should return with KErrNone, exits otherwise.
|
|
332 |
//!
|
|
333 |
//! @SYMTestPriority High
|
|
334 |
//! @SYMTestStatus Implemented
|
|
335 |
//----------------------------------------------------------------------------------------------
|
|
336 |
LOCAL_C TInt OpenAndRegisterChannel()
|
|
337 |
//
|
|
338 |
// Test Open and Initialise functionality
|
|
339 |
// Also invokes Resource inspection methods via HelperResource
|
|
340 |
//
|
|
341 |
{
|
|
342 |
TInt r;
|
|
343 |
|
|
344 |
if((r=OpenChannel(gTestName, gChannel))!=KErrNone)
|
|
345 |
return r;
|
|
346 |
|
|
347 |
// Check that the simulated resources required to support this testing are present
|
|
348 |
// If not, close the channel and return the propagated error code.
|
|
349 |
if((r=CheckForSimulatedResources())!=KErrNone)
|
|
350 |
{
|
|
351 |
gChannel.Close();
|
|
352 |
return r;
|
|
353 |
}
|
|
354 |
|
|
355 |
__KHEAP_MARK; // gTestName will remain open (allocated) when heap is checked
|
|
356 |
|
|
357 |
// Open a couple of additional channels to prove that more than one
|
|
358 |
// can exist
|
|
359 |
_LIT(tempStr1,"temp1");
|
|
360 |
TBufC<16> tempName1(tempStr1);
|
|
361 |
_LIT(tempStr2,"temp2");
|
|
362 |
TBufC<16> tempName2(tempStr2);
|
|
363 |
|
|
364 |
RBusDevResManUs channelTwo;
|
|
365 |
RBusDevResManUs channelThree;
|
|
366 |
|
|
367 |
if((r=OpenChannel(tempName1, channelTwo))!=KErrNone)
|
|
368 |
return r;
|
|
369 |
if((r=OpenChannel(tempName2, channelThree))!=KErrNone)
|
|
370 |
return r;
|
|
371 |
|
|
372 |
// The following test requires manual enabling in resource controller of macro
|
|
373 |
// DEBUG_VERSION - this is not done by default, so test is deactivated here.
|
|
374 |
//
|
|
375 |
#if 0
|
|
376 |
// Test rejection if try a name already in use
|
|
377 |
//
|
|
378 |
// (For UREL builds, duplicate names are allowed; but
|
|
379 |
// for UDEB builds, they are monitored and rejected)
|
|
380 |
//
|
|
381 |
RBusDevResManUs channelSameName;
|
|
382 |
r=OpenChannel(tempName1, channelSameName);
|
|
383 |
channelSameName.Close(); // Channel not used after here
|
|
384 |
if (r==KErrNone)
|
|
385 |
{
|
|
386 |
gTest.Printf(_L("Error: Handle for re-used name channel =0x%x\n"),channelSameName.Handle());
|
|
387 |
return KErrGeneral;
|
|
388 |
}
|
|
389 |
else if(r!=KErrCouldNotConnect)
|
|
390 |
{
|
|
391 |
gTest.Printf(_L("Error: re-used name gave unexpected error code =0x%x\n"),r);
|
|
392 |
return r;
|
|
393 |
}
|
|
394 |
else // if(r==KErrCouldNotConnect)
|
|
395 |
{
|
|
396 |
gTest.Printf(_L("Re-used channel name rejected with correct error code\n"));
|
|
397 |
}
|
|
398 |
#endif // if 0
|
|
399 |
|
|
400 |
// Test oversized name rejection
|
|
401 |
_LIT(longStr,"1abcdefghijklmnopqrstuvwxyz2abcdefghijklmnopqrstuvwxyz3abcdefghijklmnopqrstuvwxyz4abcdefghijklmnopqrstuvwxyz5abcdefghijklmnopqrstuvwxyz6abcdefghijklmnopqrstuvwxyz7abcdefghijklmnopqrstuvwxyz8abcdefghijklmnopqrstuvwxyz9abcdefghijklmnopqrstuvwxyz10abcdefghijklmnopqrstuvwxyz");
|
|
402 |
TBufC<271> longName(longStr);
|
|
403 |
|
|
404 |
// API accepts 8-bit descriptors for names, only
|
|
405 |
TBuf8<271>longName_8Bit;
|
|
406 |
longName_8Bit.Copy(longName);
|
|
407 |
|
|
408 |
RBusDevResManUs channelLong;
|
|
409 |
r=(channelLong.Open(longName_8Bit));
|
|
410 |
channelLong.Close(); // Channel not used after here
|
|
411 |
if (r==KErrNone)
|
|
412 |
{
|
|
413 |
gTest.Printf(_L("Error: Handle for oversize name channel =0x%x\n"),channelLong.Handle());
|
|
414 |
return KErrGeneral;
|
|
415 |
}
|
|
416 |
else if(r!=KErrBadName)
|
|
417 |
{
|
|
418 |
gTest.Printf(_L("Error: oversized name gave unexpected error code =0x%x\n"),r);
|
|
419 |
return r;
|
|
420 |
}
|
|
421 |
else // if(r==KErrBadName)
|
|
422 |
{
|
|
423 |
gTest.Printf(_L("Oversized name for channel rejected with correct error code\n"));
|
|
424 |
}
|
|
425 |
|
|
426 |
// Invokes GetNoOfResources, GetAllResourcesInfo and GetResourceIdByName
|
|
427 |
if((r=HelperResources())!=KErrNone)
|
|
428 |
return r;
|
|
429 |
|
|
430 |
// Close the temporary channels
|
|
431 |
// Do this before channel registration to enable valid check of kernel heap
|
|
432 |
channelTwo.Close();
|
|
433 |
channelThree.Close();
|
|
434 |
|
|
435 |
__KHEAP_MARKEND;
|
|
436 |
|
|
437 |
// Channel registration
|
|
438 |
gTest.Printf(_L("Invoking Initialise with values 0x%x, 0x%x, 0x%x\n"),KNoOfGetStateRequests,KNoOfSetStateRequests,KNoOfNotifyRequests);
|
|
439 |
if ((r=gChannel.Initialise(KNoOfGetStateRequests,KNoOfSetStateRequests,KNoOfNotifyRequests))!=KErrNone)
|
|
440 |
{
|
|
441 |
gTest.Printf(_L("Initialise for channel returned %d\n"),r);
|
|
442 |
return r;
|
|
443 |
}
|
|
444 |
|
|
445 |
return KErrNone;
|
|
446 |
}
|
|
447 |
|
|
448 |
|
|
449 |
LOCAL_C TInt HelperClients()
|
|
450 |
//
|
|
451 |
// Helper method to support TestGetClientGetResourceInfo
|
|
452 |
// Invokes GetNoOfClients and GetNamesAllClients
|
|
453 |
//
|
|
454 |
{
|
|
455 |
__KHEAP_MARK;
|
|
456 |
|
|
457 |
TInt r = KErrNone;
|
|
458 |
TUint numClients = 0;
|
|
459 |
TUint numAllClients = 0;
|
|
460 |
//
|
|
461 |
// GetNoOfClients - with aIncludeKern=EFalse
|
|
462 |
//
|
|
463 |
if((r=gChannel.GetNoOfClients(numClients, EFalse)) != KErrNone)
|
|
464 |
{
|
|
465 |
gTest.Printf(_L("GetNoOfClients (aIncludeKern==EFalse) returned %d\n"),r);
|
|
466 |
return r;
|
|
467 |
}
|
|
468 |
gTest.Printf(_L("GetNoOfClients (aIncludeKern==EFalse) gave 0x%x clients\n"),numClients);
|
|
469 |
|
|
470 |
//
|
|
471 |
// GetNoOfClients - with aIncludeKern=ETrue
|
|
472 |
//
|
|
473 |
r=gChannel.GetNoOfClients(numAllClients, ETrue);
|
|
474 |
#ifdef RESMANUS_KERN
|
|
475 |
if(r==KErrNone)
|
|
476 |
gTest.Printf(_L("GetNoOfClients (aIncludeKern==ETrue) returned KErrNone\n"));
|
|
477 |
#else
|
|
478 |
if(r==KErrPermissionDenied)
|
|
479 |
gTest.Printf(_L("GetNoOfClients (aIncludeKern==ETrue) returned KErrPermissionDenied\n"));
|
|
480 |
#endif
|
|
481 |
else
|
|
482 |
{
|
|
483 |
gTest.Printf(_L("GetNoOfClients (aIncludeKern==ETrue) returned %d"),r);
|
|
484 |
return KErrGeneral;
|
|
485 |
}
|
|
486 |
|
|
487 |
// To support the GetNamesAllClients testing, instantiate TClientName objects
|
|
488 |
// and reference via an RSimplePointerArray
|
|
489 |
TUint bufSize = (numAllClients>numClients)?numAllClients:numClients;
|
|
490 |
RSimplePointerArray<TClientName> infoPtrs(bufSize);
|
|
491 |
for(TUint i=0;i<bufSize;i++)
|
|
492 |
{
|
|
493 |
TClientName *info = new TClientName();
|
|
494 |
if((r=infoPtrs.Insert(info, i))!=KErrNone)
|
|
495 |
{
|
|
496 |
gTest.Printf(_L("GetNamesAllClients infoPtrs.Insert at index %d returned %d\n"),i,r);
|
|
497 |
}
|
|
498 |
}
|
|
499 |
|
|
500 |
//
|
|
501 |
// GetNamesAllClients - with aIncludeKern=EFalse
|
|
502 |
//
|
|
503 |
if((r=gChannel.GetNamesAllClients(&infoPtrs, numClients, EFalse)) != KErrNone)
|
|
504 |
{
|
|
505 |
gTest.Printf(_L("GetNamesAllClients (aIncludeKern==EFalse) returned %d\n"),r);
|
|
506 |
return r;
|
|
507 |
}
|
|
508 |
#ifdef _DEBUG
|
|
509 |
else
|
|
510 |
{
|
|
511 |
gTest.Printf(_L("GetNamesAllClients (aIncludeKern==EFalse) returned KErrNone, names follow\n"));
|
|
512 |
for(TUint i=0;i<numClients;i++)
|
|
513 |
{
|
|
514 |
TClientName *currName = infoPtrs[i];
|
|
515 |
TBuf16<sizeof(TClientName)> name;
|
|
516 |
name.Copy(*currName);
|
|
517 |
gTest.Printf(_L("Client name %d = %S\n"),i,&name);
|
|
518 |
}
|
|
519 |
}
|
|
520 |
#endif
|
|
521 |
|
|
522 |
//
|
|
523 |
// GetNamesAllClients - with aIncludeKern=ETrue
|
|
524 |
//
|
|
525 |
#ifdef RESMANUS_KERN
|
|
526 |
if((r=gChannel.GetNamesAllClients(&infoPtrs, numAllClients, ETrue)) != KErrNone)
|
|
527 |
{
|
|
528 |
gTest.Printf(_L("GetNamesAllClients (aIncludeKern==ETrue) returned %d\n"),r);
|
|
529 |
return r;
|
|
530 |
}
|
|
531 |
#ifdef _DEBUG
|
|
532 |
else
|
|
533 |
{
|
|
534 |
gTest.Printf(_L("GetNamesAllClients (aIncludeKern==ETrue) returned KErrNone, names follow\n"));
|
|
535 |
for(TUint i=0;i<numAllClients;i++)
|
|
536 |
{
|
|
537 |
TClientName *currName = infoPtrs[i];
|
|
538 |
TBuf16<sizeof(TClientName)> name;
|
|
539 |
name.Copy(*currName);
|
|
540 |
gTest.Printf(_L("Client name %d = %S\n"),i,&name);
|
|
541 |
}
|
|
542 |
}
|
|
543 |
#endif
|
|
544 |
#else
|
|
545 |
if((r=gChannel.GetNamesAllClients(&infoPtrs, numClients, ETrue)) == KErrPermissionDenied)
|
|
546 |
{
|
|
547 |
gTest.Printf(_L("GetNamesAllClients (aIncludeKern==ETrue) returned KErrPermissionDenied\n"));
|
|
548 |
r=KErrNone; // Ensure misleading status is not returned
|
|
549 |
}
|
|
550 |
else
|
|
551 |
{
|
|
552 |
gTest.Printf(_L("GetNamesAllClients (aIncludeKern==ETrue) returned %d"),r);
|
|
553 |
return r;
|
|
554 |
}
|
|
555 |
#endif
|
|
556 |
|
|
557 |
infoPtrs.Close();
|
|
558 |
__KHEAP_MARKEND;
|
|
559 |
|
|
560 |
return r;
|
|
561 |
}
|
|
562 |
|
|
563 |
LOCAL_C TInt HelperClientsUsingResource(TUint aResourceId)
|
|
564 |
//
|
|
565 |
// Helper method to support TestGetClientGetResourceInfo
|
|
566 |
// Invokes GetNumClientsUsingResource and GetInfoOnClientsUsingResource
|
|
567 |
//
|
|
568 |
{
|
|
569 |
__KHEAP_MARK;
|
|
570 |
|
|
571 |
TInt r = KErrNone;
|
|
572 |
//
|
|
573 |
// GetNumClientsUsingResource - with aIncludeKern=ETrue
|
|
574 |
//
|
|
575 |
TUint resourceAllClients = 0;
|
|
576 |
if((r=gChannel.GetNumClientsUsingResource(aResourceId, resourceAllClients, ETrue)) == KErrPermissionDenied)
|
|
577 |
{
|
|
578 |
gTest.Printf(_L("GetNumClientsUsingResource (aIncludeKern==ETrue) returned KErrPermissionDenied\n"));
|
|
579 |
#ifdef RESMANUS_KERN
|
|
580 |
return r;
|
|
581 |
}
|
|
582 |
else
|
|
583 |
{
|
|
584 |
if(r!=KErrNone)
|
|
585 |
{
|
|
586 |
gTest.Printf(_L("GetNumClientsUsingResource (aIncludeKern==ETrue) returned %d\n"),r);
|
|
587 |
return r;
|
|
588 |
}
|
|
589 |
else
|
|
590 |
gTest.Printf(_L("GetNumClientsUsingResource (aIncludeKern==ETrue) reported 0x%x clients\n"),resourceAllClients);
|
|
591 |
}
|
|
592 |
#else
|
|
593 |
}
|
|
594 |
else
|
|
595 |
{
|
|
596 |
gTest.Printf(_L("GetNumClientsUsingResource (aIncludeKern==ETrue) returned %d\n"),r);
|
|
597 |
return r;
|
|
598 |
}
|
|
599 |
#endif
|
|
600 |
//
|
|
601 |
// GetNumClientsUsingResource - with aIncludeKern=EFalse
|
|
602 |
//
|
|
603 |
TUint resourceClients = 0;
|
|
604 |
if((r=gChannel.GetNumClientsUsingResource(aResourceId, resourceClients, EFalse)) != KErrNone)
|
|
605 |
{
|
|
606 |
// If there are no clients that have requested a level then the Resource Controller will
|
|
607 |
// the client ID as a bad argument
|
|
608 |
if(!((resourceClients==0)&&(r==KErrArgument)))
|
|
609 |
{
|
|
610 |
gTest.Printf(_L("GetNumClientsUsingResource (aIncludeKern==EFalse) returned %d\n"),r);
|
|
611 |
return r;
|
|
612 |
}
|
|
613 |
else
|
|
614 |
r=KErrNone; // Ensure expected error is not misinterpeted
|
|
615 |
}
|
|
616 |
else
|
|
617 |
gTest.Printf(_L("GetNumClientsUsingResource (aIncludeKern==EFalse) reported 0x%x clients\n"),resourceClients);
|
|
618 |
|
|
619 |
// To support the GetInfoOnClientsUsingResource testing, instantiate TClientInfoBuf objects
|
|
620 |
// and reference via an RSimplePointerArray
|
|
621 |
TUint bufSize = (resourceAllClients>resourceClients)?resourceAllClients:resourceClients;
|
|
622 |
if(bufSize>0)
|
|
623 |
{
|
|
624 |
RSimplePointerArray<TClientInfoBuf> infoPtrs(bufSize);
|
|
625 |
for(TUint i=0;i<bufSize;i++)
|
|
626 |
{
|
|
627 |
TClientInfoBuf *info = new TClientInfoBuf();
|
|
628 |
if((r=infoPtrs.Insert(info, i))!=KErrNone)
|
|
629 |
{
|
|
630 |
gTest.Printf(_L("GetInfoOnClientsUsingResource infoPtrs.Insert at index %d returned %d\n"),i,r);
|
|
631 |
}
|
|
632 |
}
|
|
633 |
|
|
634 |
//
|
|
635 |
// GetInfoOnClientsUsingResource - with aIncludeKern=EFalse
|
|
636 |
//
|
|
637 |
if((r=gChannel.GetInfoOnClientsUsingResource(aResourceId, resourceClients, &infoPtrs, EFalse)) != KErrNone)
|
|
638 |
{
|
|
639 |
// If there are no clients that have requested a level then the resource will not
|
|
640 |
// have been found
|
|
641 |
if(!((resourceClients==0)&&(r==KErrNotFound)))
|
|
642 |
{
|
|
643 |
gTest.Printf(_L("GetInfoOnClientsUsingResource (aIncludeKern==EFalse) returned %d\n"),r);
|
|
644 |
return r;
|
|
645 |
}
|
|
646 |
}
|
|
647 |
#ifdef _DEBUG
|
|
648 |
else
|
|
649 |
{
|
|
650 |
gTest.Printf(_L("GetInfoOnClientsUsingResource (aIncludeKern==EFalse) returned KErrNone, info follows\n"));
|
|
651 |
for(TUint i=0;i<resourceClients;i++)
|
|
652 |
{
|
|
653 |
TClientInfoBuf* currInfoBuf = infoPtrs[i];
|
|
654 |
TClientInfo currInfo=(*currInfoBuf)();
|
|
655 |
TBuf16<sizeof(TClientName)> name;
|
|
656 |
name.Copy(currInfo.iName);
|
|
657 |
gTest.Printf(_L("Client name %d = %S, ID=0x%x\n"),i,&name,currInfo.iId);
|
|
658 |
}
|
|
659 |
}
|
|
660 |
#endif
|
|
661 |
//
|
|
662 |
// GetInfoOnClientsUsingResource - with aIncludeKern=ETrue
|
|
663 |
//
|
|
664 |
r=gChannel.GetInfoOnClientsUsingResource(aResourceId, resourceAllClients, &infoPtrs, ETrue);
|
|
665 |
{
|
|
666 |
#ifdef RESMANUS_KERN
|
|
667 |
if(r != KErrNone)
|
|
668 |
{
|
|
669 |
// If there are no clients that have requested a level then the Resource Controller
|
|
670 |
// will report a request for information on 0 clients as a bad argument
|
|
671 |
if(!((resourceClients==0)&&(r==KErrArgument)))
|
|
672 |
{
|
|
673 |
gTest.Printf(_L("GetInfoOnClientsUsingResource (aIncludeKern==ETrue) returned %d\n"),r);
|
|
674 |
return r;
|
|
675 |
}
|
|
676 |
else
|
|
677 |
r=KErrNone; // Ensure misleading result is not returned
|
|
678 |
}
|
|
679 |
#ifdef _DEBUG
|
|
680 |
else
|
|
681 |
{
|
|
682 |
gTest.Printf(_L("GetInfoOnClientsUsingResource (aIncludeKern==ETrue) returned KErrNone, info follows\n"));
|
|
683 |
for(TUint i=0;i<resourceClients;i++)
|
|
684 |
{
|
|
685 |
TClientInfoBuf* currInfoBuf = infoPtrs[i];
|
|
686 |
TClientInfo currInfo=(*currInfoBuf)();
|
|
687 |
TBuf16<sizeof(TClientName)> name;
|
|
688 |
name.Copy(currInfo.iName);
|
|
689 |
gTest.Printf(_L("Client name %d = %S, ID=0x%x\n"),i,&name,currInfo.iId);
|
|
690 |
}
|
|
691 |
}
|
|
692 |
#endif
|
|
693 |
#else
|
|
694 |
if(r == KErrNone)
|
|
695 |
{
|
|
696 |
gTest.Printf(_L("GetInfoOnClientsUsingResource (aIncludeKern==ETrue) returned KErrNone"));
|
|
697 |
return KErrGeneral;
|
|
698 |
}
|
|
699 |
else if(r==KErrPermissionDenied)
|
|
700 |
{
|
|
701 |
gTest.Printf(_L("GetInfoOnClientsUsingResource (aIncludeKern==ETrue) returned KErrPermissionDenied\n"));
|
|
702 |
r=KErrNone; // Ensure that misleading result is not propagated
|
|
703 |
}
|
|
704 |
else
|
|
705 |
{
|
|
706 |
gTest.Printf(_L("GetInfoOnClientsUsingResource (aIncludeKern==ETrue) returned %d\n"),r);
|
|
707 |
// If there are no clients that have requested a level then the Resource Controller
|
|
708 |
// will report a request for information on 0 clients as a bad argument
|
|
709 |
if(!((resourceClients==0)&&(r==KErrArgument)))
|
|
710 |
return r;
|
|
711 |
}
|
|
712 |
#endif
|
|
713 |
}
|
|
714 |
}
|
|
715 |
|
|
716 |
__KHEAP_MARKEND;
|
|
717 |
|
|
718 |
return r;
|
|
719 |
}
|
|
720 |
|
|
721 |
|
|
722 |
|
|
723 |
LOCAL_C TInt HelperResourcesInUseByClient()
|
|
724 |
//
|
|
725 |
// Helper method to supportTestGetClientGetResourceInfo
|
|
726 |
// Invokes GetNumResourcesInUseByClient and GetInfoOnResourcesInUseByClient
|
|
727 |
//
|
|
728 |
{
|
|
729 |
__KHEAP_MARK;
|
|
730 |
|
|
731 |
TInt r = KErrNone;
|
|
732 |
//
|
|
733 |
// GetNumResourcesInUseByClient
|
|
734 |
//
|
|
735 |
// API accepts 8-bit descriptors, only - so convert name accordingly
|
|
736 |
TBuf8<MAX_RESOURCE_NAME_LENGTH+1>name8Bit;
|
|
737 |
name8Bit.Copy(gTestName);
|
|
738 |
TClientName* clientName = (TClientName*)&name8Bit;
|
|
739 |
#if _DEBUG
|
|
740 |
TBuf <MAX_CLIENT_NAME_LENGTH> clientName16Bit;
|
|
741 |
clientName16Bit.Copy(*clientName);
|
|
742 |
clientName16Bit.SetLength(clientName->Length());
|
|
743 |
gTest.Printf(_L("Invoking GetNumResourcesInUseByClient with %S (expect KErrPermissionDenied if no levels requested yet)\n"),&clientName16Bit);
|
|
744 |
#endif
|
|
745 |
TUint numResourcesForClient;
|
|
746 |
if((r=gChannel.GetNumResourcesInUseByClient(*clientName, numResourcesForClient)) != KErrNone)
|
|
747 |
{
|
|
748 |
gTest.Printf(_L("GetNumResourcesInUseByClient returned %d\n"),r);
|
|
749 |
return r;
|
|
750 |
}
|
|
751 |
gTest.Printf(_L("GetNumResourcesInUseByClient gave number of resources = %d\n"),numResourcesForClient);
|
|
752 |
//
|
|
753 |
// In addition, check response when the name of an unknown client is passed
|
|
754 |
//
|
|
755 |
// Negative test - ensure that an unknown client name fails
|
|
756 |
_LIT(dumName,"DoesNotExist");
|
|
757 |
TBuf<16> dumNameBuf(dumName);
|
|
758 |
TBuf8<MAX_RESOURCE_NAME_LENGTH+1>dumName8Bit;
|
|
759 |
dumName8Bit.Copy(dumNameBuf);
|
|
760 |
TClientName* dumClientName = (TClientName*)&dumName8Bit;
|
|
761 |
#if _DEBUG
|
|
762 |
gTest.Printf(_L("Invoking GetNumResourcesInUseByClient with %S\n"),&dumNameBuf);
|
|
763 |
#endif
|
|
764 |
TUint numResForDumClient;
|
|
765 |
if((r=gChannel.GetNumResourcesInUseByClient(*dumClientName, numResForDumClient)) != KErrNotFound)
|
|
766 |
{
|
|
767 |
gTest.Printf(_L("GetNumResourcesInUseByClient returned %d\n"),r);
|
|
768 |
if(r==KErrNone)
|
|
769 |
r=KErrGeneral;
|
|
770 |
return r;
|
|
771 |
}
|
|
772 |
gTest.Printf(_L("GetNumResourcesInUseByClient returned %d\n"),r);
|
|
773 |
r=KErrNone; // Ensure misleading error code is not propagated
|
|
774 |
|
|
775 |
//
|
|
776 |
// GetInfoOnResourcesInUseByClient
|
|
777 |
//
|
|
778 |
// If the (TUint) number of resources in use by the client is zero skip the attempt to read the resource information
|
|
779 |
TUint updatedNumResourcesForClient = numResourcesForClient;
|
|
780 |
if(numResourcesForClient!=0)
|
|
781 |
{
|
|
782 |
TUint bufSize = numResourcesForClient;
|
|
783 |
RSimplePointerArray<TResourceInfoBuf> infoPtrs(bufSize);
|
|
784 |
for(TUint i=0;i<bufSize;i++)
|
|
785 |
{
|
|
786 |
TResourceInfoBuf *info = new TResourceInfoBuf();
|
|
787 |
if((r=infoPtrs.Insert(info, i))!=KErrNone)
|
|
788 |
{
|
|
789 |
gTest.Printf(_L("GetInfoOnResourcesInUseByClient infoPtrs.Insert at index %d returned %d\n"),i,r);
|
|
790 |
}
|
|
791 |
}
|
|
792 |
|
|
793 |
if((r=gChannel.GetInfoOnResourcesInUseByClient(*clientName, updatedNumResourcesForClient, &infoPtrs)) != KErrNone)
|
|
794 |
{
|
|
795 |
gTest.Printf(_L("GetInfoOnResourcesInUseByClient returned %d\n"),r);
|
|
796 |
// If there are no clients that have requested a level then the Resource Controller
|
|
797 |
// will report a request for information on 0 clients as a bad argument
|
|
798 |
if(!((updatedNumResourcesForClient==0)&&(r==KErrArgument)))
|
|
799 |
return r;
|
|
800 |
else
|
|
801 |
r=KErrNone; // Ensure misleading value is not returned by this function
|
|
802 |
}
|
|
803 |
else
|
|
804 |
{
|
|
805 |
gTest.Printf(_L("GetInfoOnResourcesInUseByClient gave updated number of resources %d\n"),updatedNumResourcesForClient);
|
|
806 |
#ifdef _DEBUG
|
|
807 |
// Print resource names
|
|
808 |
TBuf16<MAX_RESOURCE_NAME_LENGTH+1>name;
|
|
809 |
for(TUint i=0; i<updatedNumResourcesForClient; i++)
|
|
810 |
{
|
|
811 |
TResourceInfoBuf* currRes = infoPtrs[i];
|
|
812 |
name.Copy((*currRes)().iName);
|
|
813 |
name.PtrZ();
|
|
814 |
gTest.Printf(_L("Resource %d name = %S \n"),i,&name);
|
|
815 |
};
|
|
816 |
#endif
|
|
817 |
}
|
|
818 |
//
|
|
819 |
// In addition, check response when the name of an unknown client is passed
|
|
820 |
//
|
|
821 |
// Negative test - ensure that an unknown client name fails
|
|
822 |
r=gChannel.GetInfoOnResourcesInUseByClient(*dumClientName, updatedNumResourcesForClient, &infoPtrs);
|
|
823 |
gTest.Printf(_L("GetInfoOnResourcesInUseByClient for dummy client returned %d\n"),r);
|
|
824 |
if(r==KErrNone)
|
|
825 |
return KErrGeneral;
|
|
826 |
else if(r!=KErrNotFound)
|
|
827 |
return r;
|
|
828 |
// Ensure that misleading information is not returned to the calling function
|
|
829 |
r=KErrNone;
|
|
830 |
|
|
831 |
infoPtrs.Close();
|
|
832 |
}
|
|
833 |
|
|
834 |
__KHEAP_MARKEND;
|
|
835 |
|
|
836 |
return r;
|
|
837 |
}
|
|
838 |
|
|
839 |
|
|
840 |
LOCAL_C TInt HelperGetClientResourceInfo()
|
|
841 |
//
|
|
842 |
// Test methods to access information about clients and resources
|
|
843 |
//
|
|
844 |
{
|
|
845 |
__KHEAP_MARK;
|
|
846 |
|
|
847 |
TInt r = KErrNone;
|
|
848 |
// Invokes GetNoOfClients and GetNamesAllClients
|
|
849 |
if((r=HelperClients())!=KErrNone)
|
|
850 |
return r;
|
|
851 |
|
|
852 |
// Invokes GetNumClientsUsingResource and GetInfoOnClientsUsingResource
|
|
853 |
//
|
|
854 |
// First invoke on the Async resource
|
|
855 |
TUint resourceId = 1; // Arbitrary
|
|
856 |
if(gHaveAsyncRes)
|
|
857 |
{
|
|
858 |
resourceId = gLongLatencyResource;
|
|
859 |
gTest.Printf(_L("Invoking HelperClientsUsinResource for Async resource ID %d\n"),resourceId);
|
|
860 |
}
|
|
861 |
else
|
|
862 |
{
|
|
863 |
gTest.Printf(_L("Invoking HelperClientsUsinResource for default resource ID %d (Async resource not yet accessed)\n"),resourceId);
|
|
864 |
}
|
|
865 |
if((r=HelperClientsUsingResource(resourceId))!=KErrNone)
|
|
866 |
return r;
|
|
867 |
//
|
|
868 |
// Second invoke on the Shared resource - skip if not available
|
|
869 |
if(gHaveSharedRes)
|
|
870 |
{
|
|
871 |
resourceId = gSharedResource;
|
|
872 |
gTest.Printf(_L("Invoking HelperClientsUsinResource for Shared resource ID %d\n"),resourceId);
|
|
873 |
if((r=HelperClientsUsingResource(resourceId))!=KErrNone)
|
|
874 |
return r;
|
|
875 |
}
|
|
876 |
|
|
877 |
// Invokes GetNumResourcesInUseByClient and GetInfoOnResourcesInUseByClient
|
|
878 |
if((r=HelperResourcesInUseByClient())!=KErrNone)
|
|
879 |
return r;
|
|
880 |
|
|
881 |
__KHEAP_MARKEND;
|
|
882 |
|
|
883 |
return r;
|
|
884 |
}
|
|
885 |
|
|
886 |
#ifdef _DEBUG
|
|
887 |
LOCAL_C TInt SetAsyncResource()
|
|
888 |
//
|
|
889 |
// Support function for tests of asynchronous API methods
|
|
890 |
//
|
|
891 |
{
|
|
892 |
if(!gHaveAsyncRes)
|
|
893 |
{
|
|
894 |
gTest.Printf(_L("SetAsyncResource, Find Async resource to use\n"));
|
|
895 |
TRequestStatus status;
|
|
896 |
TBool cached = gUseCached;
|
|
897 |
TInt readValue = 0;
|
|
898 |
TInt levelOwnerId = 0;
|
|
899 |
TUint numPotentialResources;
|
|
900 |
TUint index=0;
|
|
901 |
TInt r=gChannel.GetNumCandidateAsyncResources(numPotentialResources);
|
|
902 |
if(r!=KErrNone)
|
|
903 |
{
|
|
904 |
gTest.Printf(_L("SetAsyncResource, GetNumCandidateAsyncResources returned %d\n"),r);
|
|
905 |
return r;
|
|
906 |
}
|
|
907 |
gTest.Printf(_L("SetAsyncResource, GetNumCandidateAsyncResources found %d resources\n"),numPotentialResources);
|
|
908 |
while((numPotentialResources>0) && !gHaveAsyncRes)
|
|
909 |
{
|
|
910 |
TUint tryResourceId=0;
|
|
911 |
r=gChannel.GetCandidateAsyncResourceId(index,tryResourceId);
|
|
912 |
if(r!=KErrNone)
|
|
913 |
{
|
|
914 |
gTest.Printf(_L("SetAsyncResource, GetCandidateAsyncResourceId returned %d\n"),r);
|
|
915 |
break;
|
|
916 |
}
|
|
917 |
gTest.Printf(_L("SetAsyncResource, GetNumCandidateAsyncResources index %d, resource ID %d\n"),index,tryResourceId);
|
|
918 |
// For the candidate resource to be usable, we need its current state
|
|
919 |
// to be sufficiently less the maximum for positive sense (or sufficiently
|
|
920 |
// more than the greater than the minimum for negative sense - but the current
|
|
921 |
// version of the code only considers positive sense).
|
|
922 |
gChannel.GetResourceState(status,tryResourceId,cached,&readValue,&levelOwnerId);
|
|
923 |
User::WaitForRequest(status);
|
|
924 |
if(status.Int() != KErrNone)
|
|
925 |
{
|
|
926 |
gTest.Printf(_L("SetAsyncResource, candidate get state returned %d\n"),r);
|
|
927 |
return r;
|
|
928 |
}
|
|
929 |
gTest.Printf(_L("SetAsyncResource, candidate get state gave %d, levelOwnerId = %d\n"),readValue,levelOwnerId);
|
|
930 |
TResourceInfoBuf buffer;
|
|
931 |
if((r=gChannel.GetResourceInfo(tryResourceId, &buffer))!=KErrNone)
|
|
932 |
{
|
|
933 |
gTest.Printf(_L("SetAsyncResource, candidate get resource info returned %d\n"),r);
|
|
934 |
return r;
|
|
935 |
}
|
|
936 |
// Print resource info
|
|
937 |
TBuf16<MAX_RESOURCE_NAME_LENGTH+1>name;
|
|
938 |
TResourceInfo* infoPtr = &(buffer());
|
|
939 |
name.Copy(infoPtr->iName);
|
|
940 |
gTest.Printf(_L("SetAsyncResource: Resource name = %S \n"),&name);
|
|
941 |
gTest.Printf(_L("SetAsyncResource: Resource Class =%d\n"),infoPtr->iClass);
|
|
942 |
gTest.Printf(_L("SetAsyncResource: Resource Type =%d\n"), infoPtr->iType);
|
|
943 |
gTest.Printf(_L("SetAsyncResource: Resource Usage =%d\n"), infoPtr->iUsage);
|
|
944 |
gTest.Printf(_L("SetAsyncResource: Resource Sense =%d\n"), infoPtr->iSense);
|
|
945 |
gTest.Printf(_L("SetAsyncResource: Resource MinLevel =%d\n"),infoPtr->iMinLevel);
|
|
946 |
gTest.Printf(_L("SetAsyncResource: Resource MaxLevel =%d\n"),infoPtr->iMaxLevel);
|
|
947 |
|
|
948 |
if((infoPtr->iMaxLevel - readValue) > LEVEL_GAP_REQUIRED_FOR_ASYNC_TESTING)
|
|
949 |
{
|
|
950 |
gLongLatencyResource = tryResourceId;
|
|
951 |
gAsyncResStateDelta = 1; // Will change resource level in positive direction
|
|
952 |
gHaveAsyncRes = ETrue;
|
|
953 |
}
|
|
954 |
else if((readValue - infoPtr->iMinLevel) > LEVEL_GAP_REQUIRED_FOR_ASYNC_TESTING)
|
|
955 |
{
|
|
956 |
gLongLatencyResource = tryResourceId;
|
|
957 |
gAsyncResStateDelta = -1; // Will change resource level in negative direction
|
|
958 |
gHaveAsyncRes = ETrue;
|
|
959 |
}
|
|
960 |
else
|
|
961 |
{
|
|
962 |
++index;
|
|
963 |
--numPotentialResources;
|
|
964 |
}
|
|
965 |
};
|
|
966 |
}
|
|
967 |
if(!gHaveAsyncRes)
|
|
968 |
{
|
|
969 |
gTest.Printf(_L("**Test SetAsyncResource - don't have suitable resource ... exiting\n"));
|
|
970 |
return KErrNotReady;
|
|
971 |
}
|
|
972 |
|
|
973 |
return KErrNone;
|
|
974 |
}
|
|
975 |
|
|
976 |
LOCAL_C TInt SetSharedResource()
|
|
977 |
//
|
|
978 |
// Support function for tests of shareable resources
|
|
979 |
//
|
|
980 |
{
|
|
981 |
__KHEAP_MARK;
|
|
982 |
|
|
983 |
if(!gHaveSharedRes)
|
|
984 |
{
|
|
985 |
TRequestStatus status;
|
|
986 |
TBool cached = gUseCached;
|
|
987 |
TInt readValue = 0;
|
|
988 |
TUint numPotentialResources;
|
|
989 |
TUint index=0;
|
|
990 |
TInt r=gChannel.GetNumCandidateSharedResources(numPotentialResources);
|
|
991 |
if(r!=KErrNone)
|
|
992 |
{
|
|
993 |
gTest.Printf(_L("SetSharedResource, GetNumCandidateSharedResources returned %d\n"),r);
|
|
994 |
return r;
|
|
995 |
}
|
|
996 |
gTest.Printf(_L("SetSharedResource, GetNumCandidateSharedResources found %d resources\n"),numPotentialResources);
|
|
997 |
while((numPotentialResources>0) && !gHaveSharedRes)
|
|
998 |
{
|
|
999 |
TUint tryResourceId=0;
|
|
1000 |
r=gChannel.GetCandidateSharedResourceId(index,tryResourceId);
|
|
1001 |
if(r!=KErrNone)
|
|
1002 |
{
|
|
1003 |
gTest.Printf(_L("SetSharedResource, GetCandidateSharedResourceId returned %d\n"),r);
|
|
1004 |
break;
|
|
1005 |
}
|
|
1006 |
gTest.Printf(_L("SetSharedResource, GetNumCandidateSharedResources index %d, resource ID %d\n"),index,tryResourceId);
|
|
1007 |
// To support the tests, the selected shareable resource must not be the same
|
|
1008 |
// resource as that selected for asynchronous testing
|
|
1009 |
if(gHaveAsyncRes)
|
|
1010 |
if(tryResourceId==gLongLatencyResource)
|
|
1011 |
{
|
|
1012 |
gTest.Printf(_L("SetSharedResource - skipping candidate resource %d - already used for async testing\n"),tryResourceId);
|
|
1013 |
continue;
|
|
1014 |
}
|
|
1015 |
// For the candidate resource to be usable, we need its current state
|
|
1016 |
// to be sufficiently less the maximum for positive sense (or sufficiently
|
|
1017 |
// more than the greater than the minimum for negative sense - but the current
|
|
1018 |
// version of the code only considers positive sense).
|
|
1019 |
TInt levelOwnerId = 0;
|
|
1020 |
gChannel.GetResourceState(status,tryResourceId,cached,&readValue,&levelOwnerId);
|
|
1021 |
User::WaitForRequest(status);
|
|
1022 |
if(status.Int() != KErrNone)
|
|
1023 |
{
|
|
1024 |
gTest.Printf(_L("SetSharedResource, candidate get state returned %d\n"),r);
|
|
1025 |
return r;
|
|
1026 |
}
|
|
1027 |
gTest.Printf(_L("SetSharedResource, candidate get state gave %d, levelOwnerId = %d\n"),readValue,levelOwnerId);
|
|
1028 |
TResourceInfoBuf buffer;
|
|
1029 |
if((r=gChannel.GetResourceInfo(tryResourceId, &buffer))!=KErrNone)
|
|
1030 |
{
|
|
1031 |
gTest.Printf(_L("SetSharedResource, candidate get resource info returned %d\n"),r);
|
|
1032 |
return r;
|
|
1033 |
}
|
|
1034 |
// Print resource info
|
|
1035 |
TBuf16<MAX_RESOURCE_NAME_LENGTH+1>name;
|
|
1036 |
TResourceInfo* infoPtr = &buffer();
|
|
1037 |
name.Copy(infoPtr->iName);
|
|
1038 |
gTest.Printf(_L("SetSharedResource: Resource name = %S \n"),&name);
|
|
1039 |
gTest.Printf(_L("SetSharedResource: Resource Class =%d\n"),infoPtr->iClass);
|
|
1040 |
gTest.Printf(_L("SetSharedResource: Resource Type =%d\n"), infoPtr->iType);
|
|
1041 |
gTest.Printf(_L("SetSharedResource: Resource Usage =%d\n"), infoPtr->iUsage);
|
|
1042 |
gTest.Printf(_L("SetSharedResource: Resource Sense =%d\n"), infoPtr->iSense);
|
|
1043 |
gTest.Printf(_L("SetSharedResource: Resource MinLevel =%d\n"),infoPtr->iMinLevel);
|
|
1044 |
gTest.Printf(_L("SetSharedResource: Resource MaxLevel =%d\n"),infoPtr->iMaxLevel);
|
|
1045 |
|
|
1046 |
if((infoPtr->iMaxLevel - readValue) > LEVEL_GAP_REQUIRED_FOR_ASYNC_TESTING)
|
|
1047 |
{
|
|
1048 |
gSharedResource = tryResourceId;
|
|
1049 |
gSharedResStateDelta = 1; // Will change resource level in positive direction
|
|
1050 |
gHaveSharedRes = ETrue;
|
|
1051 |
}
|
|
1052 |
else if((readValue - infoPtr->iMinLevel) > LEVEL_GAP_REQUIRED_FOR_ASYNC_TESTING)
|
|
1053 |
{
|
|
1054 |
gSharedResource = tryResourceId;
|
|
1055 |
gSharedResStateDelta = -1; // Will change resource level in negative direction
|
|
1056 |
gHaveSharedRes = ETrue;
|
|
1057 |
}
|
|
1058 |
else
|
|
1059 |
{
|
|
1060 |
++index;
|
|
1061 |
--numPotentialResources;
|
|
1062 |
}
|
|
1063 |
};
|
|
1064 |
}
|
|
1065 |
if(!gHaveSharedRes)
|
|
1066 |
{
|
|
1067 |
gTest.Printf(_L("**Test SetSharedResource - don't have suitable resource ... exiting\n"));
|
|
1068 |
return KErrNotReady;
|
|
1069 |
}
|
|
1070 |
|
|
1071 |
__KHEAP_MARKEND;
|
|
1072 |
return KErrNone;
|
|
1073 |
}
|
|
1074 |
|
|
1075 |
#endif
|
|
1076 |
|
|
1077 |
|
|
1078 |
//----------------------------------------------------------------------------------------------
|
|
1079 |
//! @SYMTestCaseID KBASE-T_RESMANUS-0609
|
|
1080 |
//! @SYMTestType UT
|
|
1081 |
//! @SYMPREQ PREQ1398
|
|
1082 |
//! @SYMTestCaseDesc This test case tests APIs for retrieving information about
|
|
1083 |
//! (1) clients of the channel and
|
|
1084 |
//! (2) power resources.
|
|
1085 |
//! Since the client lacks the ReadDeviceData PlatSec capability it will not
|
|
1086 |
//! be permitted to access information about kernel-side clients
|
|
1087 |
//!
|
|
1088 |
//! The tests are invoked a number of times:
|
|
1089 |
//! - first, to examine the starting state
|
|
1090 |
//! - then, to examine the effect of adding a new client (channel)
|
|
1091 |
//! - then, the examine the effect of adding a new client that requests a
|
|
1092 |
//| level on a resource
|
|
1093 |
//! - then, to test the effect of the original client requesting a level
|
|
1094 |
//! on a resource
|
|
1095 |
//!
|
|
1096 |
//! @SYMTestActions 0) Call GetNoOfClients API with default aIncludeKern=EFalse.
|
|
1097 |
//!
|
|
1098 |
//! 1) Call GetNoOfClients API with aIncludeKern=ETrue.
|
|
1099 |
//!
|
|
1100 |
//! 2) Call GetNamesAllClients API with default aIncludeKern=EFalse.
|
|
1101 |
//!
|
|
1102 |
//! 3) Call GetNamesAllClients API with aIncludeKern=ETrue.
|
|
1103 |
//!
|
|
1104 |
//! 4) Call GetNumClientsUsingResource API with aIncludeKern=ETrue.
|
|
1105 |
//!
|
|
1106 |
//! 5) Call GetNumClientsUsingResource API with default aIncludeKern=EFalse.
|
|
1107 |
//!
|
|
1108 |
//! 6) Call GetInfoOnClientsUsingResource API with default aIncludeKern=EFalse.
|
|
1109 |
//!
|
|
1110 |
//! 7) Call GetInfoOnClientsUsingResource API with aIncludeKern=ETrue.
|
|
1111 |
//!
|
|
1112 |
//! 8) GetNumResourcesInUseByClient for the original client
|
|
1113 |
//!
|
|
1114 |
//! 9) GetNumResourcesInUseByClient for a non-existent client
|
|
1115 |
//!
|
|
1116 |
//! 10) GetInfoOnResourcesInUseByClient for the original client
|
|
1117 |
//!
|
|
1118 |
//! 11) GetInfoOnResourcesInUseByClient for a non-existent client
|
|
1119 |
//!
|
|
1120 |
//! @SYMTestExpectedResults 0) API should return with KErrNone, exits otherwise.
|
|
1121 |
//!
|
|
1122 |
//! 1) If client exhibits PlatSec capability ReadDeviceData, API should return with KErrNone, exits otherwise.
|
|
1123 |
//! If client lacks PlatSec capability ReadDeviceData, API should return with KErrPermissionDenied, exits otherwise.
|
|
1124 |
//!
|
|
1125 |
//! 2) API should return with KErrNone, exits otherwise.
|
|
1126 |
//!
|
|
1127 |
//! 3) If client exhibits PlatSec capability ReadDeviceData, API should return with KErrNone, exits otherwise
|
|
1128 |
//! If client lacks PlatSec capability ReadDeviceData, API should return with KErrPermissionDenied, exits otherwise
|
|
1129 |
//!
|
|
1130 |
//! 4) If client exhibits PlatSec capability ReadDeviceData, API should return with KErrNone, exits otherwise.
|
|
1131 |
//! If client lacks PlatSec capability ReadDeviceData, API should return with KErrPermissionDenied, exits otherwise.
|
|
1132 |
//!
|
|
1133 |
//! 5) API should return with KErrNone, exits otherwise
|
|
1134 |
//!
|
|
1135 |
//! 6) API should return with KErrNone, exits otherwise.
|
|
1136 |
//!
|
|
1137 |
//! 7) If client exhibits PlatSec capability ReadDeviceData, API should return with KErrNone, exits otherwise
|
|
1138 |
//! If client lacks PlatSec capability ReadDeviceData, API should return with KErrPermissionDenied, exits otherwise
|
|
1139 |
//!
|
|
1140 |
//! 8) API should return with KErrNone, exits otherwise.
|
|
1141 |
//!
|
|
1142 |
//! 9) API should return with KErrNotFound, exits otherwise.
|
|
1143 |
//!
|
|
1144 |
//! 10) API should return with KErrNone, exits otherwise.
|
|
1145 |
//!
|
|
1146 |
//! 11) API should return with KErrNotFound, exits otherwise.
|
|
1147 |
//!
|
|
1148 |
//! @SYMTestPriority High
|
|
1149 |
//! @SYMTestStatus Implemented
|
|
1150 |
//----------------------------------------------------------------------------------------------
|
|
1151 |
LOCAL_C TInt TestGetClientGetResourceInfo()
|
|
1152 |
//
|
|
1153 |
// Test methods to access information about clients and resources
|
|
1154 |
//
|
|
1155 |
{
|
|
1156 |
TInt r = KErrNone;
|
|
1157 |
|
|
1158 |
// Open a couple of additional channels
|
|
1159 |
_LIT(tempStr1,"ExtraChan1");
|
|
1160 |
TBufC<16> tempName1(tempStr1);
|
|
1161 |
_LIT(tempStr2,"ExtraChan2");
|
|
1162 |
TBufC<16> tempName2(tempStr2);
|
|
1163 |
|
|
1164 |
RBusDevResManUs channelTwo;
|
|
1165 |
RBusDevResManUs channelThree;
|
|
1166 |
|
|
1167 |
if((r=OpenChannel(tempName1, channelTwo))!=KErrNone)
|
|
1168 |
return r;
|
|
1169 |
if((r=OpenChannel(tempName2, channelThree))!=KErrNone)
|
|
1170 |
return r;
|
|
1171 |
|
|
1172 |
// Test the tracking of the client and resource info
|
|
1173 |
//
|
|
1174 |
|
|
1175 |
// First invocation to establish starting state
|
|
1176 |
#ifdef _DEBUG
|
|
1177 |
gTest.Printf(_L("TestGetClientGetResourceInfo: First HelperGetClientResourceInfo call (starting state):\n"));
|
|
1178 |
#endif
|
|
1179 |
if((r=HelperGetClientResourceInfo())!=KErrNone)
|
|
1180 |
return r;
|
|
1181 |
|
|
1182 |
// Second invocation - examine effect of adding a client
|
|
1183 |
_LIT(tempStr3,"ExtraChan3");
|
|
1184 |
TBufC<16> tempName3(tempStr3);
|
|
1185 |
RBusDevResManUs channelFour;
|
|
1186 |
if((r=OpenChannel(tempName3, channelFour))!=KErrNone)
|
|
1187 |
return r;
|
|
1188 |
#ifdef _DEBUG
|
|
1189 |
gTest.Printf(_L("TestGetClientGetResourceInfo: Second HelperGetClientResourceInfo call (added client ExtraChan3):\n"));
|
|
1190 |
#endif
|
|
1191 |
|
|
1192 |
if((r=HelperGetClientResourceInfo())!=KErrNone)
|
|
1193 |
return r;
|
|
1194 |
|
|
1195 |
// Third invocation - examine effect of new client requesting a level for a resource
|
|
1196 |
// (This relies on getting and setting the state of gSharedResource - so skip the
|
|
1197 |
// test if this has not yet been identified
|
|
1198 |
//
|
|
1199 |
TUint startingLevel = 0;
|
|
1200 |
#ifdef _DEBUG
|
|
1201 |
if((r=SetSharedResource())!=KErrNone)
|
|
1202 |
return r;
|
|
1203 |
#endif
|
|
1204 |
if(!gHaveSharedRes)
|
|
1205 |
{
|
|
1206 |
gTest.Printf(_L("TestGetClientGetResourceInfo: no suitable shareable resource, so skipping third call:\n"));
|
|
1207 |
}
|
|
1208 |
else
|
|
1209 |
{
|
|
1210 |
// Channel registration
|
|
1211 |
gTest.Printf(_L("Initialise for temporary channel with arguments 1,1,0\n"));
|
|
1212 |
if ((r=channelFour.Initialise(1,1,0))!=KErrNone) // Just need 1 get and 1 set state
|
|
1213 |
{
|
|
1214 |
gTest.Printf(_L("Initialise for channel returned %d\n"),r);
|
|
1215 |
return r;
|
|
1216 |
}
|
|
1217 |
// Get initial state
|
|
1218 |
TRequestStatus status;
|
|
1219 |
TBool cached = gUseCached;
|
|
1220 |
TInt readValue;
|
|
1221 |
TInt levelOwnerId = 0;
|
|
1222 |
channelFour.GetResourceState(status,gSharedResource,cached,&readValue,&levelOwnerId);
|
|
1223 |
User::WaitForRequest(status);
|
|
1224 |
r=status.Int();
|
|
1225 |
if(r != KErrNone)
|
|
1226 |
{
|
|
1227 |
gTest.Printf(_L("TestGetClientGetResourceInfo, first get state for shareable returned %d\n"),r);
|
|
1228 |
return r;
|
|
1229 |
}
|
|
1230 |
startingLevel = (TUint)readValue;
|
|
1231 |
// Write updated state
|
|
1232 |
TUint newLevel = (TUint)(readValue + gSharedResStateDelta);
|
|
1233 |
gTest.Printf(_L("TestGetClientGetResourceInfo: levelOwnerId = %d\n"), levelOwnerId);
|
|
1234 |
gTest.Printf(_L("TestGetClientGetResourceInfo: shareable resource startingLevel=0x%x, writing 0x%x\n"), startingLevel, newLevel);
|
|
1235 |
channelFour.ChangeResourceState(status,gSharedResource,newLevel);
|
|
1236 |
User::WaitForRequest(status);
|
|
1237 |
r=status.Int();
|
|
1238 |
if(r != KErrNone)
|
|
1239 |
{
|
|
1240 |
gTest.Printf(_L("TestGetClientGetResourceInfo, first change state for shareable resource returned %d\n"),r);
|
|
1241 |
return r;
|
|
1242 |
}
|
|
1243 |
#ifdef _DEBUG
|
|
1244 |
gTest.Printf(_L("TestGetClientGetResourceInfo: third HelperGetClientResourceInfo call (new client set level on shared resource):\n"));
|
|
1245 |
#endif
|
|
1246 |
if((r=HelperGetClientResourceInfo())!=KErrNone)
|
|
1247 |
return r;
|
|
1248 |
}
|
|
1249 |
|
|
1250 |
|
244
|
1251 |
// Fourth invocation - examine effect of oryginal client requesting a level for
|
0
|
1252 |
// the Shared resource
|
|
1253 |
if(gHaveSharedRes)
|
|
1254 |
{
|
|
1255 |
TRequestStatus status;
|
|
1256 |
TBool cached = gUseCached;
|
|
1257 |
TInt readValue;
|
|
1258 |
TInt levelOwnerId;
|
|
1259 |
gChannel.GetResourceState(status,gSharedResource,cached,&readValue,&levelOwnerId);
|
|
1260 |
User::WaitForRequest(status);
|
|
1261 |
r=status.Int();
|
|
1262 |
if(r != KErrNone)
|
|
1263 |
{
|
|
1264 |
gTest.Printf(_L("TestGetClientGetResourceInfo, gChannel get state on Shareable resource returned %d\n"),r);
|
|
1265 |
return r;
|
|
1266 |
}
|
|
1267 |
gTest.Printf(_L("TestGetClientGetResourceInfo, GetResourceState levelOwnerId = %d\n"),levelOwnerId); // Request a level on the resource
|
|
1268 |
gChannel.ChangeResourceState(status,gSharedResource,(readValue+gSharedResStateDelta));
|
|
1269 |
User::WaitForRequest(status);
|
|
1270 |
if(status.Int() != KErrNone)
|
|
1271 |
{
|
|
1272 |
gTest.Printf(_L("TestGetClientGetResourceInfo, gChannel change state on Shareable returned %d\n"),r);
|
|
1273 |
return r;
|
|
1274 |
}
|
|
1275 |
#ifdef _DEBUG
|
|
1276 |
gTest.Printf(_L("TestGetClientGetResourceInfo: fourth HelperGetClientResourceInfo call (gChannel set level on Shareable resource):\n"));
|
|
1277 |
#endif
|
|
1278 |
if((r=HelperGetClientResourceInfo())!=KErrNone)
|
|
1279 |
return r;
|
|
1280 |
}
|
|
1281 |
|
|
1282 |
// Return the resource to the state it was on function entry
|
|
1283 |
if(gHaveSharedRes)
|
|
1284 |
{
|
|
1285 |
TRequestStatus status;
|
|
1286 |
gTest.Printf(_L("TestGetClientGetResourceInfo: returning sharable resource to startingLevel=0x%x\n"), startingLevel);
|
|
1287 |
gChannel.ChangeResourceState(status,gSharedResource,startingLevel);
|
|
1288 |
User::WaitForRequest(status);
|
|
1289 |
r=status.Int();
|
|
1290 |
if(r != KErrNone)
|
|
1291 |
{
|
|
1292 |
gTest.Printf(_L("TestGetClientGetResourceInfo, attempt to reset shareable resource state returned %d\n"),r);
|
|
1293 |
return r;
|
|
1294 |
}
|
|
1295 |
}
|
|
1296 |
|
|
1297 |
// Close the temporary channels
|
|
1298 |
channelTwo.Close();
|
|
1299 |
channelThree.Close();
|
|
1300 |
channelFour.Close();
|
|
1301 |
|
|
1302 |
return r;
|
|
1303 |
}
|
|
1304 |
|
|
1305 |
|
|
1306 |
|
|
1307 |
//----------------------------------------------------------------------------------------------
|
|
1308 |
//! @SYMTestCaseID KBASE-T_RESMANUS-0610
|
|
1309 |
//! @SYMTestType UT
|
|
1310 |
//! @SYMPREQ PREQ1398
|
|
1311 |
//! @SYMTestCaseDesc This test case tests APIs for getting and setting the state of resources;
|
|
1312 |
//! it also tests APIs to cancel such requests.
|
|
1313 |
//!
|
|
1314 |
//! @SYMTestActions 0) Call API to get the initial state of a selected resource.
|
|
1315 |
//!
|
|
1316 |
//! 1) Call API to modify the state of the resource.
|
|
1317 |
//!
|
|
1318 |
//! 2) Call API to get the new state of the resource and check it exhibits
|
|
1319 |
//! the expected value.
|
279
|
1320 |
//!
|
|
1321 |
//! 3) Call API to modify the state of the resource by setting its level to zero.
|
|
1322 |
//!
|
|
1323 |
//! 4) Call API to get the state of the resource and check it exhibits the expected zero value.
|
0
|
1324 |
//!
|
279
|
1325 |
//! 5) Call API to return the resource state to its original value.
|
0
|
1326 |
//!
|
279
|
1327 |
//! 6) Call API to get the state of a long latency resource then call API
|
0
|
1328 |
//! with operation-type qualifier cancel the request.
|
|
1329 |
//!
|
279
|
1330 |
//! 7) Call API to modify the state of the long latency resource then call API
|
0
|
1331 |
//! with operation-type qualifier to cancel the request.
|
|
1332 |
//!
|
279
|
1333 |
//! 8) Call API to get the state of a long latency resource and wait for it
|
0
|
1334 |
//! to complete. Then call API with operation-type qualifier to cancel the request.
|
|
1335 |
//!
|
279
|
1336 |
//! 9) Call API to modify the state of the long latency resource and wait for
|
0
|
1337 |
//! it to complete. Then call API with operation-type qualifier to cancel the request.
|
|
1338 |
//!
|
279
|
1339 |
//! 10) Call API to get the state of a long latency resource then call API
|
0
|
1340 |
//! without operation-type qualifier to cancel the request.
|
|
1341 |
//!
|
279
|
1342 |
//! 11) Call API to modify the state of the long latency resource then call API
|
0
|
1343 |
//! without operation-type qualifier to cancel the request.
|
|
1344 |
//!
|
279
|
1345 |
//! 12) Call API to get the state of a long latency resource and wait for it
|
0
|
1346 |
//! to complete. Then call API without operation-type qualifier to cancel the request.
|
|
1347 |
//!
|
279
|
1348 |
//! 13) Call API to modify the state of the long latency resource and wait for
|
0
|
1349 |
//! it to complete. Then call API without operation-type qualifier to cancel the request.
|
|
1350 |
//!
|
279
|
1351 |
//! 14) Call API to get the state of a long latency resource 'n' times. Then call API with
|
0
|
1352 |
//! resource qualifier to cancel the requests.
|
|
1353 |
//!
|
279
|
1354 |
//! 15) Call API to modify the state of a long latency resource 'm' times. Then call API with
|
0
|
1355 |
//! resource qualifier to cancel the requests.
|
|
1356 |
//!
|
279
|
1357 |
//! 16) Call API to get the state of a long latency resource 'n' times and wait for them to complete.
|
0
|
1358 |
//! Then call API with resource qualifier to cancel the requests.
|
|
1359 |
//!
|
279
|
1360 |
//! 17) Call API to modify the state of a long latency resource 'm' times and wait for them to complete.
|
0
|
1361 |
//! Then call API with resource qualifier to cancel the requests.
|
|
1362 |
//!
|
279
|
1363 |
//! 18) Call API to get the state of a long latency resource 'n' times, call API to modify the state of
|
0
|
1364 |
//! a long latency resource 'm' times. Call the API to cancel the get operations with resource qualifier.
|
|
1365 |
//! Wait for the operations to complete. Check the state of the associated TRequestStatus objects.
|
|
1366 |
//!
|
279
|
1367 |
//! 19) Call API to get the state of a long latency resource 'n' times, call API to modify the state of
|
0
|
1368 |
//! a long latency resource 'm' times. Call the API to cancel the modify operations with resource qualifier.
|
|
1369 |
//! Wait for the get operations to complete. Check the state of the associated TRequestStatus objects.
|
|
1370 |
//!
|
279
|
1371 |
//! 20) Call API to get the state of a long latency resource 'n' times, call API to modify the state of
|
0
|
1372 |
//! a long latency resource 'm' times. Wait for the get operations to complete. Call the API to cancel the get
|
|
1373 |
//! operations with resource qualifier. Check the state of the associated TRequestStatus objects.
|
|
1374 |
//!
|
279
|
1375 |
//! 21) Call API to get the state of a long latency resource 'n' times, call API to modify the state of
|
0
|
1376 |
//! a long latency resource 'm' times. Wait for the modify operations to complete. Call the API to cancel the modify
|
|
1377 |
//! operations with resource qualifier. Check the state of the associated TRequestStatus objects.
|
|
1378 |
//!
|
279
|
1379 |
//! 22) Call API to get the state of a long latency resource 'n' times, call API to modify the state of
|
0
|
1380 |
//! a long latency resource 'm' times.
|
|
1381 |
//! Then call API with operation-type qualifier to cancel the even-numbered get request(s).
|
|
1382 |
//! Then call API without operation-type qualifier to cancel the even-numbered modify request(s).
|
|
1383 |
//! Check the state of the associated TRequestStatus objects.
|
|
1384 |
//!
|
|
1385 |
//! @SYMTestExpectedResults 0) The associated TRequestStatus object should indicate KErrNone, exits otherwise.
|
|
1386 |
//!
|
|
1387 |
//! 1) The associated TRequestStatus object should indicate KErrNone, exits otherwise.
|
|
1388 |
//!
|
|
1389 |
//! 2) The associated TRequestStatus object should indicate KErrNone, exits otherwise.
|
|
1390 |
//! Exit if the value read back is not as expected.
|
|
1391 |
//!
|
|
1392 |
//! 3) The associated TRequestStatus object should indicate KErrNone, exits otherwise.
|
|
1393 |
//!
|
279
|
1394 |
//! 4) The associated TRequestStatus object should indicate KErrNone, exits otherwise.
|
|
1395 |
//! Exit if the value read back is not as expected.
|
|
1396 |
//!
|
|
1397 |
//! 5) The associated TRequestStatus object should indicate KErrNone, exits otherwise.
|
|
1398 |
//!
|
|
1399 |
//! 6) The associated TRequestStatus object should indicate KErrCancel if the cancel
|
0
|
1400 |
//! request was accepted, exits otherwise.
|
|
1401 |
//! The associated TRequestStatus object should indicate KErrNone if the cancel request
|
|
1402 |
//! was not accepted, exits otherwise.
|
|
1403 |
//!
|
279
|
1404 |
//! 7) The associated TRequestStatus object should indicate KErrCancel if the cancel
|
0
|
1405 |
//! request was accepted, exits otherwise.
|
|
1406 |
//! The associated TRequestStatus object should indicate KErrNone if the cancel request
|
|
1407 |
//! was not accepted, exits otherwise.
|
|
1408 |
//!
|
279
|
1409 |
//! 8) The TRequestStatus object associated with the get operation should indicate
|
0
|
1410 |
//! KErrNone - exits otherwise. The TRequestStatus object associated with the cancel
|
|
1411 |
//! operation should indicate KErrNone - exits otherwise.
|
|
1412 |
//!
|
279
|
1413 |
//! 9) The TRequestStatus object associated with the get operation should indicate
|
0
|
1414 |
//! KErrNone - exits otherwise. The TRequestStatus object associated with the cancel
|
|
1415 |
//! operation should indicate KErrNone - exits otherwise.
|
|
1416 |
//!
|
279
|
1417 |
//! 10) The associated TRequestStatus object should indicate KErrCancel, exits otherwise.
|
0
|
1418 |
//!
|
279
|
1419 |
//! 11) The associated TRequestStatus object should indicate KErrCancel, exits otherwise.
|
0
|
1420 |
//!
|
279
|
1421 |
//! 12) The TRequestStatus object associated with the get operation should indicate
|
0
|
1422 |
//! KErrNone - exits otherwise. The TRequestStatus object associated with the cancel
|
|
1423 |
//! operation should indicate KErrNone - exits otherwise.
|
|
1424 |
//!
|
279
|
1425 |
//! 13) The TRequestStatus object associated with the get operation should indicate
|
0
|
1426 |
//! KErrNone - exits otherwise. The TRequestStatus object associated with the cancel
|
|
1427 |
//! operation should indicate KErrNone - exits otherwise.
|
|
1428 |
//!
|
279
|
1429 |
//! 14) The TRequestStatus objects should all exibit KErrCancel - exits otherwise.
|
0
|
1430 |
//!
|
279
|
1431 |
//! 15) The TRequestStatus objects should all exibit KErrCancel - exits otherwise.
|
0
|
1432 |
//!
|
279
|
1433 |
//! 16) The TRequestStatus objects associated with the get operations should all exibit KErrNone - exits otherwise.
|
0
|
1434 |
//! The TRequestStatus objects associated with the cancel operations should all exibit KErrNone - exits otherwise
|
|
1435 |
//!
|
279
|
1436 |
//! 17) The TRequestStatus objects associated with the modify operations should all exibit KErrNone - exits otherwise.
|
0
|
1437 |
//! The TRequestStatus objects associated with the cancel operations should all exibit KErrNone - exits otherwise
|
|
1438 |
//!
|
279
|
1439 |
//! 18) The TRequestStatus objects associated with the get operations should all exibit KErrCancel - exits otherwise.
|
0
|
1440 |
//! The TRequestStatus objects associated with the modify operations should all exibit KErrNone - exits otherwise
|
|
1441 |
//!
|
279
|
1442 |
//! 19) The TRequestStatus objects associated with the get operations should all exibit KErrNone - exits otherwise.
|
0
|
1443 |
//! The TRequestStatus objects associated with the modify operations should all exibit KErrCancel - exits otherwise
|
|
1444 |
//!
|
279
|
1445 |
//! 20) The TRequestStatus objects associated with the get and modify operations should all exibit KErrNone - exits otherwise.
|
0
|
1446 |
//!
|
279
|
1447 |
//! 21) The TRequestStatus objects associated with the get and modify operations should all exibit KErrNone - exits otherwise.
|
0
|
1448 |
//!
|
279
|
1449 |
//! 22) The TRequestStatus objects associated with the even-numbered request should exhibit KErrCancel.
|
0
|
1450 |
//! The TRequestStatus objects associated with the odd-numbered request should exhibit KErrNone.
|
|
1451 |
//!
|
|
1452 |
//! @SYMTestPriority High
|
|
1453 |
//! @SYMTestStatus Implemented
|
|
1454 |
//----------------------------------------------------------------------------------------------
|
|
1455 |
LOCAL_C TInt TestGetSetResourceStateOps()
|
|
1456 |
//
|
|
1457 |
// Test resource state access methods
|
|
1458 |
//
|
|
1459 |
{
|
|
1460 |
TInt r = KErrNone;
|
|
1461 |
|
|
1462 |
TRequestStatus status;
|
244
|
1463 |
TRequestStatus status2;
|
0
|
1464 |
TBool cached = gUseCached;
|
|
1465 |
TInt readValue = 0;
|
244
|
1466 |
TInt readValue2 = 0;
|
0
|
1467 |
TInt levelOwnerId = 0;
|
|
1468 |
TInt testNo = 0;
|
|
1469 |
|
|
1470 |
#ifdef _DEBUG
|
|
1471 |
// Ensure we have a resource we can use
|
|
1472 |
if((r=SetAsyncResource())!=KErrNone)
|
|
1473 |
return r;
|
|
1474 |
#endif
|
|
1475 |
|
|
1476 |
// 0) Call API to get the initial state of a selected resource.
|
|
1477 |
gTest.Printf(_L("TestGetSetResourceStateOps, starting test %d\n"),testNo++);
|
|
1478 |
gChannel.GetResourceState(status,gLongLatencyResource,cached,&readValue,&levelOwnerId);
|
|
1479 |
User::WaitForRequest(status);
|
|
1480 |
if(status.Int() != KErrNone)
|
|
1481 |
{
|
|
1482 |
gTest.Printf(_L("TestGetSetResourceStateOps, get state status = %d\n"),r);
|
|
1483 |
return r;
|
|
1484 |
}
|
|
1485 |
TUint startingLevel = (TUint)readValue;
|
|
1486 |
gTest.Printf(_L("TestGetSetResourceStateOps: initial level read =0x%x, levelOwnerId = %d\n"),readValue,levelOwnerId);
|
|
1487 |
|
|
1488 |
// 1) Call API to modify the state of the resource.
|
|
1489 |
gTest.Printf(_L("TestGetSetResourceStateOps, starting test %d\n"),testNo++);
|
|
1490 |
TUint newLevel = (TUint)(readValue + gAsyncResStateDelta);
|
|
1491 |
gTest.Printf(_L("TestGetSetResourceStateOps: writing 0x%x\n"), newLevel);
|
|
1492 |
gChannel.ChangeResourceState(status,gLongLatencyResource,newLevel);
|
|
1493 |
User::WaitForRequest(status);
|
|
1494 |
if(status.Int() != KErrNone)
|
|
1495 |
{
|
|
1496 |
gTest.Printf(_L("TestGetSetResourceStateOps, first change state returned %d\n"),r);
|
|
1497 |
return r;
|
|
1498 |
}
|
|
1499 |
|
|
1500 |
// 2) Call API to get the new state of the resource and check it exhibits the expected value.
|
|
1501 |
gTest.Printf(_L("TestGetSetResourceStateOps, starting test %d\n"),testNo++);
|
|
1502 |
gChannel.GetResourceState(status,gLongLatencyResource,cached,&readValue,&levelOwnerId);
|
|
1503 |
User::WaitForRequest(status);
|
|
1504 |
if(status.Int() != KErrNone)
|
|
1505 |
{
|
|
1506 |
gTest.Printf(_L("TestGetSetResourceStateOps, get state status = %d\n"),r);
|
|
1507 |
return r;
|
|
1508 |
}
|
|
1509 |
gTest.Printf(_L("TestGetSetResourceStateOps: level read back =0x%x, levelOwnerId=%d\n"),readValue,levelOwnerId);
|
|
1510 |
gTest(newLevel==(TUint)readValue);
|
|
1511 |
|
279
|
1512 |
// 3) Call API to modify the state of the resource by setting its level to zero
|
|
1513 |
gTest.Printf(_L("TestGetSetResourceStateOps, starting test %d\n"),testNo++);
|
|
1514 |
gChannel.ChangeResourceState(status,gLongLatencyResource,0);
|
|
1515 |
User::WaitForRequest(status);
|
|
1516 |
if(status != KErrNone)
|
|
1517 |
{
|
|
1518 |
gTest.Printf(_L("ChangeResourceState to level 0 returned %d\n"),r);
|
|
1519 |
return r;
|
|
1520 |
}
|
|
1521 |
|
|
1522 |
// 4) Call API to get the state of the resource and check it exhibits the expected zero value.
|
|
1523 |
gTest.Printf(_L("TestGetSetResourceStateOps, starting test %d\n"),testNo++);
|
|
1524 |
gChannel.GetResourceState(status,gLongLatencyResource,cached,&readValue,&levelOwnerId);
|
|
1525 |
User::WaitForRequest(status);
|
|
1526 |
if(status != KErrNone)
|
|
1527 |
{
|
|
1528 |
gTest.Printf(_L("TestGetSetResourceStateOps, get state status = %d\n"),r);
|
|
1529 |
return r;
|
|
1530 |
}
|
|
1531 |
gTest.Printf(_L("TestGetSetResourceStateOps: level read back =0x%x, levelOwnerId=%d\n"),readValue,levelOwnerId);
|
|
1532 |
gTest(readValue==0);
|
|
1533 |
|
|
1534 |
// 5) Call API to return the resource state to its original value.
|
0
|
1535 |
gTest.Printf(_L("TestGetSetResourceStateOps, starting test %d\n"),testNo++);
|
|
1536 |
gTest.Printf(_L("TestGetSetResourceStateOps: write original level 0x%x\n"), startingLevel);
|
|
1537 |
gChannel.ChangeResourceState(status,gLongLatencyResource,startingLevel);
|
|
1538 |
User::WaitForRequest(status);
|
|
1539 |
if(status.Int() != KErrNone)
|
|
1540 |
{
|
|
1541 |
gTest.Printf(_L("TestGetSetResourceStateOps, change state status = %d\n"),r);
|
|
1542 |
return r;
|
|
1543 |
}
|
|
1544 |
gChannel.GetResourceState(status,gLongLatencyResource,cached,&readValue,&levelOwnerId);
|
|
1545 |
User::WaitForRequest(status);
|
|
1546 |
if(status.Int() != KErrNone)
|
|
1547 |
{
|
|
1548 |
gTest.Printf(_L("TestGetSetResourceStateOps, get state status = %d\n"),r);
|
|
1549 |
return r;
|
|
1550 |
}
|
|
1551 |
gTest.Printf(_L("TestGetSetResourceStateOps: check original level read back =0x%x, levelOwnerId=%d\n"),readValue,levelOwnerId);
|
|
1552 |
|
279
|
1553 |
// 6) Call API to get the state of a long latency resource then call API with operation-type qualifier cancel the request.
|
0
|
1554 |
gTest.Printf(_L("TestGetSetResourceStateOps, starting test %d\n"),testNo++);
|
|
1555 |
gChannel.GetResourceState(status,gLongLatencyResource,cached,&readValue,&levelOwnerId);
|
|
1556 |
r=gChannel.CancelGetResourceState(status);
|
|
1557 |
if(r!=KErrInUse)
|
|
1558 |
{
|
|
1559 |
gTest.Printf(_L("TestGetSetResourceStateOps, CancelGetResourceState returned %d\n"),r);
|
|
1560 |
}
|
|
1561 |
if(r!=KErrCompletion) // If request had not completed before cancellation request
|
|
1562 |
{
|
|
1563 |
User::WaitForRequest(status);
|
|
1564 |
if(r==KErrNone) // Cancel expected to proceed as requested
|
|
1565 |
{
|
|
1566 |
if(status.Int() != KErrCancel)
|
|
1567 |
{
|
|
1568 |
gTest.Printf(_L("TestGetSetResourceStateOps, expected KErrCancel but cancelled get state status = %d\n"),r);
|
|
1569 |
return r;
|
|
1570 |
}
|
|
1571 |
}
|
|
1572 |
else if(r==KErrInUse) // Cancel failed since request was being processed - so expect successful completion
|
|
1573 |
{
|
|
1574 |
if(status.Int() != KErrNone)
|
|
1575 |
{
|
|
1576 |
gTest.Printf(_L("TestGetSetResourceStateOps, expected KErrNone but cancelled get state status = %d\n"),r);
|
|
1577 |
return r;
|
|
1578 |
}
|
|
1579 |
}
|
|
1580 |
else if(status.Int() != KErrCancel) // Just report the error code and return
|
|
1581 |
{
|
|
1582 |
gTest.Printf(_L("TestGetSetResourceStateOps, cancelled get state status = %d\n"),r);
|
|
1583 |
return r;
|
|
1584 |
}
|
|
1585 |
|
|
1586 |
}
|
|
1587 |
|
279
|
1588 |
// 7) Call API to modify the state of the long latency resource then call API with operation-type qualifier to cancel the request.
|
0
|
1589 |
gTest.Printf(_L("TestGetSetResourceStateOps, starting test %d\n"),testNo++);
|
|
1590 |
newLevel = (TUint)(readValue + gAsyncResStateDelta);
|
|
1591 |
gChannel.ChangeResourceState(status,gLongLatencyResource,newLevel);
|
|
1592 |
r=gChannel.CancelChangeResourceState(status);
|
|
1593 |
if(r!=KErrInUse)
|
|
1594 |
{
|
|
1595 |
gTest.Printf(_L("TestGetSetResourceStateOps, CancelChangeResourceState returned %d\n"),r);
|
|
1596 |
}
|
|
1597 |
if(r!=KErrCompletion) // If request had not completed before cancellation request
|
|
1598 |
{
|
|
1599 |
User::WaitForRequest(status);
|
|
1600 |
if(r==KErrNone) // Cancel expected to proceed as requested
|
|
1601 |
{
|
|
1602 |
if(status.Int() != KErrCancel)
|
|
1603 |
{
|
|
1604 |
gTest.Printf(_L("TestGetSetResourceStateOps, expected KErrCancel but cancelled get state status = %d\n"),r);
|
|
1605 |
return r;
|
|
1606 |
}
|
|
1607 |
}
|
|
1608 |
else if(r==KErrInUse) // Cancel failed since request was being processed - so expect successful completion
|
|
1609 |
{
|
|
1610 |
if(status.Int() != KErrNone)
|
|
1611 |
{
|
|
1612 |
gTest.Printf(_L("TestGetSetResourceStateOps, expected KErrNone but cancelled get state status = %d\n"),r);
|
|
1613 |
return r;
|
|
1614 |
}
|
|
1615 |
}
|
|
1616 |
else if(status.Int() != KErrCancel) // Just report the error code and return
|
|
1617 |
{
|
|
1618 |
gTest.Printf(_L("TestGetSetResourceStateOps, cancelled get state status = %d\n"),r);
|
|
1619 |
return r;
|
|
1620 |
}
|
|
1621 |
}
|
|
1622 |
|
|
1623 |
|
279
|
1624 |
// 8) Call API to get the state of a long latency resource and wait for it to complete.
|
0
|
1625 |
// Then call API with operation-type qualifier to cancel the request.
|
|
1626 |
gTest.Printf(_L("TestGetSetResourceStateOps, starting test %d\n"),testNo++);
|
|
1627 |
gChannel.GetResourceState(status,gLongLatencyResource,cached,&readValue,&levelOwnerId);
|
|
1628 |
User::WaitForRequest(status);
|
|
1629 |
if(status.Int() != KErrNone)
|
|
1630 |
{
|
|
1631 |
gTest.Printf(_L("TestGetSetResourceStateOps, get state status = %d\n"),r);
|
|
1632 |
return r;
|
|
1633 |
}
|
|
1634 |
r=gChannel.CancelGetResourceState(status);
|
|
1635 |
if(r!=KErrNone)
|
|
1636 |
{
|
|
1637 |
gTest.Printf(_L("TestGetSetResourceStateOps, CancelGetResourceState returned %d\n"),r);
|
|
1638 |
}
|
|
1639 |
if(status.Int() != KErrNone) // TRequestStatus should be unchanged
|
|
1640 |
{
|
|
1641 |
gTest.Printf(_L("TestGetSetResourceStateOps, completed-then-cancelled get state status = %d\n"),r);
|
|
1642 |
return r;
|
|
1643 |
}
|
|
1644 |
|
279
|
1645 |
// 9) Call API to modify the state of the long latency resource and wait for it to complete.
|
0
|
1646 |
// Then call API with operation-type qualifier to cancel the request.
|
|
1647 |
gTest.Printf(_L("TestGetSetResourceStateOps, starting test %d\n"),testNo++);
|
|
1648 |
gChannel.ChangeResourceState(status,gLongLatencyResource,(readValue + gAsyncResStateDelta));
|
|
1649 |
User::WaitForRequest(status);
|
|
1650 |
if(status.Int() != KErrNone)
|
|
1651 |
{
|
|
1652 |
gTest.Printf(_L("TestGetSetResourceStateOps, change state status = %d\n"),r);
|
|
1653 |
return r;
|
|
1654 |
}
|
|
1655 |
r=gChannel.CancelChangeResourceState(status);
|
|
1656 |
if(r!=KErrNone)
|
|
1657 |
{
|
|
1658 |
gTest.Printf(_L("TestGetSetResourceStateOps, CancelChangeResourceState returned %d\n"),r);
|
|
1659 |
}
|
|
1660 |
if(status.Int() != KErrNone) // TRequestStatus should be unchanged
|
|
1661 |
{
|
|
1662 |
gTest.Printf(_L("TestGetSetResourceStateOps, completed-then-cancelled change state status = %d\n"),r);
|
|
1663 |
return r;
|
|
1664 |
}
|
|
1665 |
|
279
|
1666 |
// 10) Call API to get the state of a long latency resource then call API without operation-type qualifier to cancel the request.
|
0
|
1667 |
gTest.Printf(_L("TestGetSetResourceStateOps, starting test %d\n"),testNo++);
|
244
|
1668 |
|
|
1669 |
// NOTE: Cancel operation can only remove request which is still inside the resource controller
|
|
1670 |
// message queue. If the queue is empty, the resource controller may process the request very quickly
|
|
1671 |
// after it is sent. It may cause the test fail. To solve this, two get long latency resource state
|
|
1672 |
// requests are submitted. So that the second one must be inside the resource controller.
|
|
1673 |
// And we will always test the second request
|
|
1674 |
|
0
|
1675 |
gChannel.GetResourceState(status,gLongLatencyResource,cached,&readValue,&levelOwnerId);
|
244
|
1676 |
gChannel.GetResourceState(status2,gLongLatencyResource,cached,&readValue2,&levelOwnerId);
|
0
|
1677 |
gChannel.CancelAsyncOperation(&status);
|
244
|
1678 |
gChannel.CancelAsyncOperation(&status2);
|
0
|
1679 |
User::WaitForRequest(status);
|
244
|
1680 |
User::WaitForRequest(status2);
|
|
1681 |
if(status2.Int() != KErrCancel)
|
0
|
1682 |
{
|
|
1683 |
gTest.Printf(_L("TestGetSetResourceStateOps, cancelled get state status = %d\n"),r);
|
|
1684 |
return r;
|
|
1685 |
}
|
|
1686 |
|
279
|
1687 |
// 11) Call API to modify the state of the long latency resource then call API without operation-type qualifier to cancel the request.
|
0
|
1688 |
gTest.Printf(_L("TestGetSetResourceStateOps, starting test %d\n"),testNo++);
|
244
|
1689 |
|
|
1690 |
// NOTE: Cancel operation can only remove request which is still inside the resource controller
|
|
1691 |
// message queue. If the queue is empty, the resource controller may process the request very quickly
|
|
1692 |
// after it is sent. It may cause the test fail. To solve this, two get long latency resource state
|
|
1693 |
// requests are submitted. So that the second one must be inside the resource controller.
|
|
1694 |
// And we will always test the second request
|
|
1695 |
|
0
|
1696 |
newLevel = (TUint)(readValue + gAsyncResStateDelta);
|
|
1697 |
gChannel.ChangeResourceState(status,gLongLatencyResource,newLevel);
|
244
|
1698 |
gChannel.ChangeResourceState(status2,gLongLatencyResource,newLevel);
|
0
|
1699 |
gChannel.CancelAsyncOperation(&status);
|
244
|
1700 |
gChannel.CancelAsyncOperation(&status2);
|
0
|
1701 |
User::WaitForRequest(status);
|
244
|
1702 |
User::WaitForRequest(status2);
|
|
1703 |
if(status2.Int() != KErrCancel)
|
0
|
1704 |
{
|
|
1705 |
gTest.Printf(_L("TestGetSetResourceStateOps, cancelled change state status = %d\n"),r);
|
|
1706 |
return r;
|
|
1707 |
}
|
|
1708 |
|
279
|
1709 |
// 12) Call API to get the state of a long latency resource and wait for it to complete.
|
0
|
1710 |
// Then call API without operation-type qualifier to cancel the request.
|
|
1711 |
gTest.Printf(_L("TestGetSetResourceStateOps, starting test %d\n"),testNo++);
|
|
1712 |
gChannel.GetResourceState(status,gLongLatencyResource,cached,&readValue,&levelOwnerId);
|
|
1713 |
User::WaitForRequest(status);
|
|
1714 |
if(status.Int() != KErrNone)
|
|
1715 |
{
|
|
1716 |
gTest.Printf(_L("TestGetSetResourceStateOps, get state status = %d\n"),r);
|
|
1717 |
return r;
|
|
1718 |
}
|
|
1719 |
gChannel.CancelAsyncOperation(&status);
|
|
1720 |
if(status.Int() != KErrNone) // TRequestStatus should be unchanged
|
|
1721 |
{
|
|
1722 |
gTest.Printf(_L("TestGetSetResourceStateOps, completed-then-cancelled get state status = %d\n"),r);
|
|
1723 |
return r;
|
|
1724 |
}
|
|
1725 |
|
279
|
1726 |
// 13) Call API to modify the state of the long latency resource and wait for it to complete.
|
0
|
1727 |
// Then call API without operation-type qualifier to cancel the request.
|
|
1728 |
gTest.Printf(_L("TestGetSetResourceStateOps, starting test %d\n"),testNo++);
|
|
1729 |
gChannel.ChangeResourceState(status,gLongLatencyResource,(readValue + gAsyncResStateDelta));
|
|
1730 |
User::WaitForRequest(status);
|
|
1731 |
if(status.Int() != KErrNone)
|
|
1732 |
{
|
|
1733 |
gTest.Printf(_L("TestGetSetResourceStateOps, change state status = %d\n"),r);
|
|
1734 |
return r;
|
|
1735 |
}
|
|
1736 |
gChannel.CancelAsyncOperation(&status);
|
|
1737 |
if(status.Int() != KErrNone) // TRequestStatus should be unchanged
|
|
1738 |
{
|
|
1739 |
gTest.Printf(_L("TestGetSetResourceStateOps, completed-then-cancelled change state status = %d\n"),r);
|
|
1740 |
return r;
|
|
1741 |
}
|
|
1742 |
|
|
1743 |
// 'n' and 'm' values and support for cancellation of multiple requests
|
|
1744 |
const TInt KLoopVarN = 2;
|
|
1745 |
const TInt KLoopVarM = 3;
|
|
1746 |
TRequestStatus getReqStatus[KLoopVarN];
|
|
1747 |
TRequestStatus setReqStatus[KLoopVarM];
|
|
1748 |
TInt i=0;
|
|
1749 |
|
279
|
1750 |
// 14) Call API to get the state of a long latency resource 'n' times.
|
0
|
1751 |
// Then call API with resource qualifier to cancel the requests.
|
|
1752 |
gTest.Printf(_L("TestGetSetResourceStateOps, starting test %d\n"),testNo++);
|
|
1753 |
for(i=0;i<KLoopVarN;i++)
|
|
1754 |
{
|
|
1755 |
gChannel.GetResourceState(getReqStatus[i],gLongLatencyResource,cached,&readValue,&levelOwnerId);
|
|
1756 |
}
|
|
1757 |
gChannel.CancelGetResourceStateRequests(gLongLatencyResource);
|
|
1758 |
for(i=0;i<KLoopVarN;i++)
|
|
1759 |
{
|
|
1760 |
User::WaitForRequest(getReqStatus[i]);
|
244
|
1761 |
|
|
1762 |
// NOTE: Cancel operation can only remove request which is still inside the resource controller
|
|
1763 |
// message queue. If the queue is empty, the resource controller may process the request very quickly
|
|
1764 |
// after it is sent. It may cause the test fail. To solve this, we skip the test for request 0.
|
|
1765 |
|
|
1766 |
if(i>0 && ((r=getReqStatus[i].Int()) != KErrCancel))
|
0
|
1767 |
{
|
|
1768 |
gTest.Printf(_L("TestGetSetResourceStateOps, cancelled get state status[%d] = %d\n"),i,r);
|
|
1769 |
return r;
|
|
1770 |
}
|
|
1771 |
}
|
|
1772 |
|
279
|
1773 |
// 15) Call API to modify the state of a long latency resource 'm' times.
|
0
|
1774 |
// Then call API with resource qualifier to cancel the requests.
|
|
1775 |
gTest.Printf(_L("TestGetSetResourceStateOps, starting test %d\n"),testNo++);
|
|
1776 |
for(i=0;i<KLoopVarM;i++)
|
|
1777 |
{
|
|
1778 |
gChannel.ChangeResourceState(setReqStatus[i],gLongLatencyResource,(readValue + gAsyncResStateDelta));
|
|
1779 |
}
|
|
1780 |
gChannel.CancelChangeResourceStateRequests(gLongLatencyResource);
|
|
1781 |
for(i=0;i<KLoopVarM;i++)
|
|
1782 |
{
|
|
1783 |
User::WaitForRequest(setReqStatus[i]);
|
244
|
1784 |
|
|
1785 |
// NOTE: Cancel operation can only remove request which is still inside the resource controller
|
|
1786 |
// message queue. If the queue is empty, the resource controller may process the request very quickly
|
|
1787 |
// after it is sent. It may cause the test fail. To solve this, we skip the test for request 0.
|
|
1788 |
|
|
1789 |
if(i>0 && ((r=setReqStatus[i].Int()) != KErrCancel))
|
0
|
1790 |
{
|
|
1791 |
gTest.Printf(_L("TestGetSetResourceStateOps, cancelled change state status[%d] = %d\n"),i,r);
|
|
1792 |
return r;
|
|
1793 |
}
|
|
1794 |
}
|
|
1795 |
|
279
|
1796 |
// 16) Call API to get the state of a long latency resource 'n' times and wait for them to complete.
|
0
|
1797 |
// Then call API with resource qualifier to cancel the requests.
|
|
1798 |
gTest.Printf(_L("TestGetSetResourceStateOps, starting test %d\n"),testNo++);
|
|
1799 |
for(i=0;i<KLoopVarN;i++)
|
|
1800 |
{
|
|
1801 |
gChannel.GetResourceState(getReqStatus[i],gLongLatencyResource,cached,&readValue,&levelOwnerId);
|
|
1802 |
}
|
|
1803 |
for(i=0;i<KLoopVarN;i++)
|
|
1804 |
{
|
|
1805 |
User::WaitForRequest(getReqStatus[i]);
|
|
1806 |
if((r=getReqStatus[i].Int()) != KErrNone)
|
|
1807 |
{
|
|
1808 |
gTest.Printf(_L("TestGetSetResourceStateOps, before cancel get state status[%d] = %d\n"),i,r);
|
|
1809 |
return r;
|
|
1810 |
}
|
|
1811 |
}
|
|
1812 |
gChannel.CancelGetResourceStateRequests(gLongLatencyResource);
|
|
1813 |
for(i=0;i<KLoopVarN;i++)
|
|
1814 |
{
|
|
1815 |
if((r=getReqStatus[i].Int()) != KErrNone)
|
|
1816 |
{
|
|
1817 |
gTest.Printf(_L("TestGetSetResourceStateOps, after cancel get state status[%d] = %d\n"),i,r);
|
|
1818 |
return r;
|
|
1819 |
}
|
|
1820 |
}
|
|
1821 |
|
279
|
1822 |
// 17) Call API to modify the state of a long latency resource 'm' times and wait for them to complete.
|
0
|
1823 |
// Then call API with resource qualifier to cancel the requests.
|
|
1824 |
gTest.Printf(_L("TestGetSetResourceStateOps, starting test %d\n"),testNo++);
|
|
1825 |
for(i=0;i<KLoopVarM;i++)
|
|
1826 |
{
|
|
1827 |
gChannel.ChangeResourceState(setReqStatus[i],gLongLatencyResource,(readValue + gAsyncResStateDelta));
|
|
1828 |
}
|
|
1829 |
for(i=0;i<KLoopVarM;i++)
|
|
1830 |
{
|
|
1831 |
User::WaitForRequest(setReqStatus[i]);
|
|
1832 |
if((r=setReqStatus[i].Int()) != KErrNone)
|
|
1833 |
{
|
|
1834 |
gTest.Printf(_L("TestGetSetResourceStateOps, before cancel change state status[%d] = %d\n"),i,r);
|
|
1835 |
return r;
|
|
1836 |
}
|
|
1837 |
}
|
|
1838 |
gChannel.CancelChangeResourceStateRequests(gLongLatencyResource);
|
|
1839 |
for(i=0;i<KLoopVarM;i++)
|
|
1840 |
{
|
|
1841 |
if((r=setReqStatus[i].Int()) != KErrNone)
|
|
1842 |
{
|
|
1843 |
gTest.Printf(_L("TestGetSetResourceStateOps, after cancel change state status[%d] = %d\n"),i,r);
|
|
1844 |
return r;
|
|
1845 |
}
|
|
1846 |
}
|
|
1847 |
|
279
|
1848 |
// 18) Call API to get the state of a long latency resource 'n' times, call API to modify the state of
|
0
|
1849 |
// a long latency resource 'm' times.
|
|
1850 |
// Call the API to cancel the get operations with resource qualifier.
|
|
1851 |
// Wait for the operations to complete. Check the state of the associated TRequestStatus objects.
|
|
1852 |
gTest.Printf(_L("TestGetSetResourceStateOps, starting test %d\n"),testNo++);
|
|
1853 |
for(i=0;i<KLoopVarN;i++)
|
|
1854 |
{
|
|
1855 |
gChannel.GetResourceState(getReqStatus[i],gLongLatencyResource,cached,&readValue,&levelOwnerId);
|
|
1856 |
}
|
|
1857 |
for(i=0;i<KLoopVarM;i++)
|
|
1858 |
{
|
|
1859 |
gChannel.ChangeResourceState(setReqStatus[i],gLongLatencyResource,(readValue + gAsyncResStateDelta));
|
|
1860 |
}
|
|
1861 |
gChannel.CancelGetResourceStateRequests(gLongLatencyResource);
|
|
1862 |
for(i=0;i<KLoopVarN;i++)
|
|
1863 |
{
|
|
1864 |
User::WaitForRequest(getReqStatus[i]);
|
244
|
1865 |
|
|
1866 |
// NOTE: Cancel operation can only remove request which is still inside the resource controller
|
|
1867 |
// message queue. If the queue is empty, the resource controller may process the request very quickly
|
|
1868 |
// after it is sent. It may cause the test fail. To solve this, we skip the test for request 0.
|
|
1869 |
|
|
1870 |
if(i>0 && ((r=getReqStatus[i].Int()) != KErrCancel))
|
0
|
1871 |
{
|
|
1872 |
gTest.Printf(_L("TestGetSetResourceStateOps, cancelled get state status[%d] = %d\n"),i,r);
|
|
1873 |
return r;
|
|
1874 |
}
|
|
1875 |
}
|
|
1876 |
for(i=0;i<KLoopVarM;i++)
|
|
1877 |
{
|
|
1878 |
User::WaitForRequest(setReqStatus[i]);
|
|
1879 |
if((r=setReqStatus[i].Int()) != KErrNone)
|
|
1880 |
{
|
|
1881 |
gTest.Printf(_L("TestGetSetResourceStateOps, completed change state status[%d] = %d\n"),i,r);
|
|
1882 |
return r;
|
|
1883 |
}
|
|
1884 |
}
|
|
1885 |
|
279
|
1886 |
// 19) Call API to get the state of a long latency resource 'n' times, call API to modify the state of
|
0
|
1887 |
// a long latency resource 'm' times.
|
|
1888 |
// Call the API to cancel the modify operations with resource qualifier.
|
|
1889 |
// Wait for the get operations to complete. Check the state of the associated TRequestStatus objects.
|
|
1890 |
gTest.Printf(_L("TestGetSetResourceStateOps, starting test %d\n"),testNo++);
|
|
1891 |
for(i=0;i<KLoopVarN;i++)
|
|
1892 |
{
|
|
1893 |
gChannel.GetResourceState(getReqStatus[i],gLongLatencyResource,cached,&readValue,&levelOwnerId);
|
|
1894 |
}
|
|
1895 |
for(i=0;i<KLoopVarM;i++)
|
|
1896 |
{
|
|
1897 |
gChannel.ChangeResourceState(setReqStatus[i],gLongLatencyResource,(readValue + gAsyncResStateDelta));
|
|
1898 |
}
|
|
1899 |
gChannel.CancelChangeResourceStateRequests(gLongLatencyResource);
|
|
1900 |
for(i=0;i<KLoopVarN;i++)
|
|
1901 |
{
|
|
1902 |
User::WaitForRequest(getReqStatus[i]);
|
|
1903 |
if((r=getReqStatus[i].Int()) != KErrNone)
|
|
1904 |
{
|
|
1905 |
gTest.Printf(_L("TestGetSetResourceStateOps, completed get state status[%d] = %d\n"),i,r);
|
|
1906 |
return r;
|
|
1907 |
}
|
|
1908 |
}
|
|
1909 |
for(i=0;i<KLoopVarM;i++)
|
|
1910 |
{
|
|
1911 |
User::WaitForRequest(setReqStatus[i]);
|
|
1912 |
if((r=setReqStatus[i].Int()) != KErrCancel)
|
|
1913 |
{
|
|
1914 |
gTest.Printf(_L("TestGetSetResourceStateOps, cancelled change state status[%d] = %d\n"),i,r);
|
|
1915 |
return r;
|
|
1916 |
}
|
|
1917 |
}
|
|
1918 |
|
279
|
1919 |
// 20) Call API to get the state of a long latency resource 'n' times, call API to modify the state of
|
0
|
1920 |
// a long latency resource 'm' times. Wait for the get operations to complete.
|
|
1921 |
// Call the API to cancel the get operations with resource qualifier. Check the state of the associated TRequestStatus objects.
|
|
1922 |
gTest.Printf(_L("TestGetSetResourceStateOps, starting test %d\n"),testNo++);
|
|
1923 |
for(i=0;i<KLoopVarN;i++)
|
|
1924 |
{
|
|
1925 |
gChannel.GetResourceState(getReqStatus[i],gLongLatencyResource,cached,&readValue,&levelOwnerId);
|
|
1926 |
}
|
|
1927 |
TInt flipper = -1;
|
|
1928 |
for(i=0;i<KLoopVarM;i++)
|
|
1929 |
{
|
|
1930 |
gChannel.ChangeResourceState(setReqStatus[i],gLongLatencyResource,(readValue + (flipper*gAsyncResStateDelta)));
|
|
1931 |
flipper*=-1;
|
|
1932 |
}
|
|
1933 |
for(i=0;i<KLoopVarN;i++)
|
|
1934 |
{
|
|
1935 |
User::WaitForRequest(getReqStatus[i]);
|
|
1936 |
if((r=getReqStatus[i].Int()) != KErrNone)
|
|
1937 |
{
|
|
1938 |
gTest.Printf(_L("TestGetSetResourceStateOps, completed get state status[%d] = %d\n"),i,r);
|
|
1939 |
return r;
|
|
1940 |
}
|
|
1941 |
}
|
|
1942 |
gChannel.CancelGetResourceStateRequests(gLongLatencyResource);
|
|
1943 |
for(i=0;i<KLoopVarM;i++)
|
|
1944 |
{
|
|
1945 |
User::WaitForRequest(setReqStatus[i]);
|
|
1946 |
if((r=setReqStatus[i].Int()) != KErrNone)
|
|
1947 |
{
|
|
1948 |
gTest.Printf(_L("TestGetSetResourceStateOps, completed change state status[%d]= %d\n"),i,r);
|
|
1949 |
return r;
|
|
1950 |
}
|
|
1951 |
}
|
|
1952 |
for(i=0;i<KLoopVarN;i++)
|
|
1953 |
{
|
|
1954 |
if((r=getReqStatus[i].Int()) != KErrNone)
|
|
1955 |
{
|
|
1956 |
gTest.Printf(_L("TestGetSetResourceStateOps, completed-then-cancelled get state status[%d]= %d\n"),i,r);
|
|
1957 |
return r;
|
|
1958 |
}
|
|
1959 |
}
|
|
1960 |
|
279
|
1961 |
// 21) Call API to get the state of a long latency resource 'n' times, call API to modify the state of
|
0
|
1962 |
// a long latency resource 'm' times. Wait for the modify operations to complete. Call the API to cancel the modify
|
|
1963 |
// operations with resource qualifier. Check the state of the associated TRequestStatus objects.
|
|
1964 |
gTest.Printf(_L("TestGetSetResourceStateOps, starting test %d\n"),testNo++);
|
|
1965 |
for(i=0;i<KLoopVarN;i++)
|
|
1966 |
{
|
|
1967 |
gChannel.GetResourceState(getReqStatus[i],gLongLatencyResource,cached,&readValue,&levelOwnerId);
|
|
1968 |
}
|
|
1969 |
for(i=0;i<KLoopVarM;i++)
|
|
1970 |
{
|
|
1971 |
gChannel.ChangeResourceState(setReqStatus[i],gLongLatencyResource,(readValue + gAsyncResStateDelta));
|
|
1972 |
}
|
|
1973 |
for(i=0;i<KLoopVarM;i++)
|
|
1974 |
{
|
|
1975 |
User::WaitForRequest(setReqStatus[i]);
|
|
1976 |
if((r=setReqStatus[i].Int()) != KErrNone)
|
|
1977 |
{
|
|
1978 |
gTest.Printf(_L("TestGetSetResourceStateOps, completed change state status[%d] = %d\n"),i,r);
|
|
1979 |
return r;
|
|
1980 |
}
|
|
1981 |
}
|
|
1982 |
gChannel.CancelChangeResourceStateRequests(gLongLatencyResource);
|
|
1983 |
for(i=0;i<KLoopVarN;i++)
|
|
1984 |
{
|
|
1985 |
User::WaitForRequest(getReqStatus[i]);
|
|
1986 |
if((r=getReqStatus[i].Int()) != KErrNone)
|
|
1987 |
{
|
|
1988 |
gTest.Printf(_L("TestGetSetResourceStateOps, completed get state status[%d] = %d\n"),i,r);
|
|
1989 |
return r;
|
|
1990 |
}
|
|
1991 |
}
|
|
1992 |
for(i=0;i<KLoopVarM;i++)
|
|
1993 |
{
|
|
1994 |
if((r=setReqStatus[i].Int()) != KErrNone)
|
|
1995 |
{
|
|
1996 |
gTest.Printf(_L("TestGetSetResourceStateOps, cancelled change state status[%d] = %d\n"),i,r);
|
|
1997 |
return r;
|
|
1998 |
}
|
|
1999 |
}
|
|
2000 |
|
279
|
2001 |
// 22) Call API to get the state of a long latency resource 'n' times, call API to modify the state of a long latency resource 'm' times.
|
0
|
2002 |
// Then call API without operation-type qualifier to cancel the even-numbered modify request(s).
|
|
2003 |
// Then call API with operation-type qualifier to cancel the even-numbered get request(s).
|
|
2004 |
// Check the state of the associated TRequestStatus objects.
|
|
2005 |
gTest.Printf(_L("TestGetSetResourceStateOps, starting test %d\n"),testNo++);
|
|
2006 |
for(i=0;i<KLoopVarN;i++)
|
|
2007 |
{
|
|
2008 |
gChannel.GetResourceState(getReqStatus[i],gLongLatencyResource,cached,&readValue,&levelOwnerId);
|
|
2009 |
}
|
|
2010 |
for(i=0;i<KLoopVarM;i++)
|
|
2011 |
{
|
|
2012 |
gChannel.ChangeResourceState(setReqStatus[i],gLongLatencyResource,(readValue + gAsyncResStateDelta));
|
|
2013 |
}
|
|
2014 |
for(i=0;i<KLoopVarM;i+=2)
|
|
2015 |
{
|
|
2016 |
gChannel.CancelAsyncOperation(&(setReqStatus[i]));
|
|
2017 |
}
|
|
2018 |
for(i=0;i<KLoopVarN;i+=2)
|
|
2019 |
{
|
|
2020 |
r=gChannel.CancelGetResourceState(getReqStatus[i]);
|
|
2021 |
if(r!=KErrNone)
|
|
2022 |
{
|
244
|
2023 |
|
|
2024 |
// NOTE: Cancel operation can only remove request which is still inside the resource controller
|
|
2025 |
// message queue. If the queue is empty, the resource controller may process the request very quickly
|
|
2026 |
// after it is sent. It may cause the test fail. To solve this, we skip the test for request 0.
|
|
2027 |
|
|
2028 |
if(i!=0)
|
|
2029 |
{
|
|
2030 |
gTest.Printf(_L("TestGetSetResourceStateOps, CancelGetResourceState for index %d returned %d\n"),i,r);
|
|
2031 |
return r;
|
|
2032 |
}
|
0
|
2033 |
}
|
|
2034 |
}
|
|
2035 |
for(i=0;i<KLoopVarM;i++)
|
|
2036 |
{
|
|
2037 |
User::WaitForRequest(setReqStatus[i]);
|
|
2038 |
if((r=setReqStatus[i].Int()) != KErrCancel)
|
|
2039 |
{
|
|
2040 |
gTest.Printf(_L("TestGetSetResourceStateOps, cancelled change state status[%d] = %d\n"),i,r);
|
|
2041 |
return r;
|
|
2042 |
}
|
|
2043 |
if(++i >= KLoopVarM)
|
|
2044 |
break;
|
|
2045 |
User::WaitForRequest(setReqStatus[i]);
|
|
2046 |
if((r=setReqStatus[i].Int()) != KErrNone)
|
|
2047 |
{
|
|
2048 |
gTest.Printf(_L("TestGetSetResourceStateOps, completed change state status[%d] = %d\n"),i,r);
|
|
2049 |
return r;
|
|
2050 |
}
|
|
2051 |
}
|
|
2052 |
for(i=0;i<KLoopVarN;i++)
|
|
2053 |
{
|
|
2054 |
User::WaitForRequest(getReqStatus[i]);
|
244
|
2055 |
|
|
2056 |
// NOTE: Cancel operation can only remove request which is still inside the resource controller
|
|
2057 |
// message queue. If the queue is empty, the resource controller may process the request very quickly
|
|
2058 |
// after it is sent. It may cause the test fail. To solve this, we skip the test for request 0.
|
|
2059 |
|
|
2060 |
if(i>0 && ((r=getReqStatus[i].Int()) != KErrCancel))
|
0
|
2061 |
{
|
|
2062 |
gTest.Printf(_L("TestGetSetResourceStateOps, cancelled get state status[%d] = %d\n"),i,r);
|
|
2063 |
return r;
|
|
2064 |
}
|
|
2065 |
if(++i >= KLoopVarN)
|
|
2066 |
break;
|
|
2067 |
User::WaitForRequest(getReqStatus[i]);
|
|
2068 |
if((r=getReqStatus[i].Int()) != KErrNone)
|
|
2069 |
{
|
|
2070 |
gTest.Printf(_L("TestGetSetResourceStateOps, completed get state status[%d] = %d\n"),i,r);
|
|
2071 |
return r;
|
|
2072 |
}
|
|
2073 |
}
|
|
2074 |
return KErrNone;
|
|
2075 |
}
|
|
2076 |
|
|
2077 |
|
|
2078 |
//----------------------------------------------------------------------------------------------
|
|
2079 |
//! @SYMTestCaseID KBASE-T_RESMANUS-0611
|
|
2080 |
//! @SYMTestType UT
|
|
2081 |
//! @SYMPREQ PREQ1398
|
|
2082 |
//! @SYMTestCaseDesc This test case tests APIs for regulating getting and setting the state of resources
|
|
2083 |
//!
|
|
2084 |
//! @SYMTestActions 0) Issue the maximum number (requested in the call to the Initialise API)
|
|
2085 |
//! of requests to get the current state of a resource. Then issue one further request.
|
|
2086 |
//!
|
|
2087 |
//! 1) Issue the maximum number (requested in the call to the Initialise API) of
|
|
2088 |
//! requests to set the current state of a resource. Then issue one further request.
|
|
2089 |
//!
|
|
2090 |
//! @SYMTestExpectedResults 0) Test that the TRequestStatus object associated with the last request
|
|
2091 |
//! exhibits status code KErrUnderflow - exit otherwise. Test that the
|
|
2092 |
//! TRequestStatus objects associated with the preceding requests exhibit
|
|
2093 |
//! status code KErrNone - exit otherwise.
|
|
2094 |
//!
|
|
2095 |
//! 1) Test that the TRequestStatus object associated with the last request
|
|
2096 |
//! exhibits status code KErrUnderflow - exit otherwise. Test that the
|
|
2097 |
//! TRequestStatus objects associated with the preceding requests exhibit
|
|
2098 |
//! status code KErrNone - exit otherwise.
|
|
2099 |
//!
|
|
2100 |
//! @SYMTestPriority High
|
|
2101 |
//! @SYMTestStatus Implemented
|
|
2102 |
//----------------------------------------------------------------------------------------------
|
|
2103 |
LOCAL_C TInt TestGetSetResourceStateQuota()
|
|
2104 |
//
|
|
2105 |
// Test resource state access quota management
|
|
2106 |
//
|
|
2107 |
{
|
|
2108 |
TUint resourceId;
|
|
2109 |
|
|
2110 |
// To perform the quota test we need a long latency resource
|
|
2111 |
// If one has not been defined alert the user and return
|
|
2112 |
if(!gHaveAsyncRes)
|
|
2113 |
{
|
|
2114 |
gTest.Printf(_L("TestGetSetResourceStateQuota: don't have suitable asynchronous resource ... exiting\n"));
|
|
2115 |
return KErrNone;
|
|
2116 |
}
|
|
2117 |
else
|
|
2118 |
resourceId = gLongLatencyResource;
|
|
2119 |
|
|
2120 |
TInt r = KErrNone;
|
|
2121 |
TBool lastErr = KErrNone;
|
|
2122 |
|
|
2123 |
TInt i = 0;
|
|
2124 |
TRequestStatus status[MAX_NUM_REQUESTS];
|
|
2125 |
TInt state[MAX_NUM_REQUESTS];
|
|
2126 |
TBool cached = gUseCached;
|
|
2127 |
TInt levelOwnerId = 0;
|
|
2128 |
|
|
2129 |
//
|
|
2130 |
// Test GetResourceState - check client can not exceed quota of requests
|
|
2131 |
//
|
|
2132 |
gTest.Printf(_L("**Test GetResourceState (quota management)\n"));
|
|
2133 |
|
|
2134 |
// KNoOfGetStateRequests Get state requests (of the same resource, ID=1) to consume the client quota
|
|
2135 |
for(i=0; i<KNoOfGetStateRequests; i++)
|
|
2136 |
gChannel.GetResourceState(status[i],resourceId,cached,&(state[i]),&levelOwnerId);
|
|
2137 |
|
|
2138 |
// Addition Get state request to exceed the quota - the provided TRequestStatus
|
|
2139 |
// object should indicate KErrUnderflow
|
|
2140 |
gChannel.GetResourceState(status[KNoOfGetStateRequests],resourceId,cached,&(state[KNoOfGetStateRequests]),&levelOwnerId);
|
|
2141 |
User::WaitForRequest(status[KNoOfGetStateRequests]);
|
|
2142 |
if(status[KNoOfGetStateRequests].Int() != KErrUnderflow)
|
|
2143 |
{
|
|
2144 |
gTest.Printf(_L("TestGetSetResourceStateQuota, extra get state returned %d\n"),r);
|
|
2145 |
return r;
|
|
2146 |
}
|
|
2147 |
|
|
2148 |
// Need to check the TRequestStatus objects
|
|
2149 |
for(i=0; i<KNoOfGetStateRequests; i++)
|
|
2150 |
{
|
|
2151 |
User::WaitForRequest(status[i]);
|
|
2152 |
if((r=status[i].Int()) != KErrNone)
|
|
2153 |
{
|
|
2154 |
gTest.Printf(_L("TestGetSetResourceStateQuota, get state %d returned %d\n"),i, r);
|
|
2155 |
lastErr = r;
|
|
2156 |
}
|
|
2157 |
}
|
|
2158 |
if(lastErr != KErrNone)
|
|
2159 |
return lastErr;
|
|
2160 |
|
|
2161 |
//
|
|
2162 |
// Test ChangeResourceState - check client can not exceed quota of requests
|
|
2163 |
//
|
|
2164 |
gTest.Printf(_L("**Test ChangeResourceState (quota management)\n"));
|
|
2165 |
|
|
2166 |
// KNoOfSetStateRequests Set state requests (of the same resource, ID=1) to consume the client quota
|
|
2167 |
TInt newState = (state[1])+1;
|
|
2168 |
for(i=0; i<KNoOfSetStateRequests; i++)
|
|
2169 |
{
|
|
2170 |
gChannel.ChangeResourceState(status[i],resourceId,newState);
|
|
2171 |
}
|
|
2172 |
|
|
2173 |
// Addition Set state request to exceed the quota - the provided TRequestStatus
|
|
2174 |
// object should indicate KErrUnderflow
|
|
2175 |
gChannel.ChangeResourceState(status[KNoOfSetStateRequests],resourceId,newState);
|
|
2176 |
User::WaitForRequest(status[KNoOfSetStateRequests]);
|
|
2177 |
if(status[KNoOfSetStateRequests].Int() != KErrUnderflow)
|
|
2178 |
{
|
|
2179 |
gTest.Printf(_L("TestGetSetResourceStateQuota, extra set state returned %d\n"),r);
|
|
2180 |
return r;
|
|
2181 |
}
|
|
2182 |
|
|
2183 |
// Need to check the TRequestStatus objects
|
|
2184 |
for(i=0; i<KNoOfSetStateRequests; i++)
|
|
2185 |
{
|
|
2186 |
User::WaitForRequest(status[i]);
|
|
2187 |
if((r=status[i].Int()) != KErrNone)
|
|
2188 |
{
|
|
2189 |
gTest.Printf(_L("TestGetSetResourceStateQuota, set state %d returned %d\n"),i, r);
|
|
2190 |
lastErr = r;
|
|
2191 |
}
|
|
2192 |
}
|
|
2193 |
if(lastErr != KErrNone)
|
|
2194 |
return lastErr;
|
|
2195 |
|
|
2196 |
return r;
|
|
2197 |
}
|
|
2198 |
|
|
2199 |
|
|
2200 |
LOCAL_C TInt TriggerNotification(TRequestStatus& aStatus, TUint aResourceId, TBool aCached, TInt aDelta)
|
|
2201 |
//
|
|
2202 |
// Support the notification tests - cause a notification for the specified resource
|
|
2203 |
//
|
|
2204 |
{
|
|
2205 |
TInt r = KErrNone;
|
|
2206 |
TInt readValue = 0;
|
|
2207 |
TInt levelOwnerId = 0;
|
|
2208 |
// Get initial state
|
|
2209 |
gChannel.GetResourceState(aStatus,aResourceId,aCached,&readValue,&levelOwnerId);
|
|
2210 |
User::WaitForRequest(aStatus);
|
|
2211 |
if(aStatus.Int() != KErrNone)
|
|
2212 |
{
|
|
2213 |
r=aStatus.Int();
|
|
2214 |
gTest.Printf(_L("TriggerNotification, get state returned %d\n"),r);
|
|
2215 |
return r;
|
|
2216 |
}
|
|
2217 |
TUint startingLevel = (TUint)readValue;
|
|
2218 |
|
|
2219 |
// Write updated state
|
|
2220 |
TUint newLevel = (TUint)(readValue + aDelta);
|
|
2221 |
gTest.Printf(_L("TriggerNotification: startingLevel=0x%x, writing 0x%x\n"), startingLevel, newLevel);
|
|
2222 |
gChannel.ChangeResourceState(aStatus,aResourceId,newLevel);
|
|
2223 |
User::WaitForRequest(aStatus);
|
|
2224 |
if(aStatus.Int() != KErrNone)
|
|
2225 |
{
|
|
2226 |
r=aStatus.Int();
|
|
2227 |
gTest.Printf(_L("TriggerNotification, change state returned %d\n"),r);
|
|
2228 |
return r;
|
|
2229 |
}
|
|
2230 |
|
|
2231 |
return r;
|
|
2232 |
}
|
|
2233 |
|
|
2234 |
|
|
2235 |
LOCAL_C TInt CalcNotifyDirAndThr(TRequestStatus& aStatus, TUint aResourceId, TBool aCached, TInt& aThreshold, TBool& aDirection)
|
|
2236 |
//
|
|
2237 |
// Support the notification tests - determine an appropriate threshold and direction to request
|
|
2238 |
//
|
|
2239 |
{
|
|
2240 |
__KHEAP_MARK;
|
|
2241 |
|
|
2242 |
// Need to know current state
|
|
2243 |
TInt r = KErrNone;
|
|
2244 |
TInt readValue = 0;
|
|
2245 |
TInt levelOwnerId = 0;
|
|
2246 |
{
|
|
2247 |
gChannel.GetResourceState(aStatus,aResourceId,aCached,&readValue,&levelOwnerId);
|
|
2248 |
User::WaitForRequest(aStatus);
|
|
2249 |
if(aStatus.Int() != KErrNone)
|
|
2250 |
{
|
|
2251 |
r=aStatus.Int();
|
|
2252 |
gTest.Printf(_L("TestNotificationOps, pre-qualified notify get state returned %d\n"),r);
|
|
2253 |
return r;
|
|
2254 |
}
|
|
2255 |
}
|
|
2256 |
aThreshold = readValue + gAsyncResStateDelta;
|
|
2257 |
aDirection=(gAsyncResStateDelta>0)?ETrue:EFalse;
|
|
2258 |
|
|
2259 |
__KHEAP_MARKEND;
|
|
2260 |
|
|
2261 |
return r;
|
|
2262 |
}
|
|
2263 |
|
|
2264 |
|
|
2265 |
//----------------------------------------------------------------------------------------------
|
|
2266 |
//! @SYMTestCaseID KBASE-T_RESMANUS-0612
|
|
2267 |
//! @SYMTestType UT
|
|
2268 |
//! @SYMPREQ PREQ1398
|
|
2269 |
//! @SYMTestCaseDesc This test case tests APIs for requesting both qualified and unqualified
|
|
2270 |
//! notifications; it also tests APIs to cancel such requests.
|
|
2271 |
//!
|
|
2272 |
//! @SYMTestActions 0) Call API to request notification of an unqualified change in resource
|
|
2273 |
//! state for a selected resource. Trigger a state change.
|
|
2274 |
//!
|
|
2275 |
//! 1) Call API to request notification of a qualified change in resource
|
|
2276 |
//! state for a selected resource. Trigger a state change.
|
|
2277 |
//!
|
|
2278 |
//! 2) Call API to request notification of an unqualified change in resource
|
|
2279 |
//! state for a selected resource. Then call API to cancel all notifications for the resource.
|
|
2280 |
//!
|
|
2281 |
//! 3) Call API to request notification of a qualified change in resource
|
|
2282 |
//! state for a selected resource. Then call API to cancel all notifications for the resource.
|
|
2283 |
//!
|
|
2284 |
//! 4) Call API to request notification of an unqualified change in resource
|
|
2285 |
//! state for a selected resource. Trigger a state change. Then call API to cancel all
|
|
2286 |
//! notifications for the resource.
|
|
2287 |
//!
|
|
2288 |
//! 5) Call API to request notification of a qualified change in resource
|
|
2289 |
//! state for a selected resource. Trigger a state change. Then call API to cancel all
|
|
2290 |
//! notifications for the resource.
|
|
2291 |
//!
|
|
2292 |
//! 6) Call API to request notification of an unqualified change in resource
|
|
2293 |
//! state for a selected resource. Then call API to cancel the notification request
|
|
2294 |
//!
|
|
2295 |
//! 7) Call API to request notification of a qualified change in resource
|
|
2296 |
//! state for a selected resource. Then call API to cancel the notification request
|
|
2297 |
//!
|
|
2298 |
//! 8) Call API to request notification of an unqualified change in resource
|
|
2299 |
//! state for a selected resource. Trigger a state change. Then call API to cancel the
|
|
2300 |
//! notification request
|
|
2301 |
//!
|
|
2302 |
//! 9) Call API to request notification of a qualified change in resource
|
|
2303 |
//! state for a selected resource. Trigger a state change. Then call API to cancel the
|
|
2304 |
//! notification request
|
|
2305 |
//!
|
|
2306 |
//! 10) Call API to request notification of an unqualified change in resource
|
|
2307 |
//! state for a selected resource. Then call API to cancel generic async request
|
|
2308 |
//!
|
|
2309 |
//! 11) Call API to request notification of a qualified change in resource
|
|
2310 |
//! state for a selected resource. Then call API to cancel generic async request
|
|
2311 |
//!
|
|
2312 |
//! 12) Call API to request notification of an unqualified change in resource
|
|
2313 |
//! state for a selected resource. Trigger a state change. Then call API to cancel
|
|
2314 |
//! generic async request
|
|
2315 |
//!
|
|
2316 |
//! 13) Call API to request notification of a qualified change in resource
|
|
2317 |
//! state for a selected resource. Trigger a state change. Then call API to cancel
|
|
2318 |
//! generic async request
|
|
2319 |
//!
|
|
2320 |
//! @SYMTestExpectedResults 0) The associated TRequestStatus object should indicate KErrNone
|
|
2321 |
//! - exits otherwise.
|
|
2322 |
//!
|
|
2323 |
//! 1) The associated TRequestStatus object should indicate KErrNone
|
|
2324 |
//! - exits otherwise.
|
|
2325 |
//!
|
|
2326 |
//! 2) The associated TRequestStatus object should indicate KErrCancel
|
|
2327 |
//! - exits otherwise.
|
|
2328 |
//!
|
|
2329 |
//! 3) The associated TRequestStatus object should indicate KErrCancel
|
|
2330 |
//! - exits otherwise.
|
|
2331 |
//!
|
|
2332 |
//! 4) The TRequestStatus object should indicate state KRequestPending until
|
|
2333 |
//! the state change is triggered, upon which it should exhibit state
|
|
2334 |
//! KErrNone. After the cancellation it should still exhibit state KErrNone.
|
|
2335 |
//! Exit for any deviation from this behaviour.
|
|
2336 |
//!
|
|
2337 |
//! 5) The TRequestStatus object should indicate state KRequestPending until
|
|
2338 |
//! the state change is triggered, upon which it should exhibit state
|
|
2339 |
//! KErrNone. After the cancellation it should still exhibit state KErrNone.
|
|
2340 |
//! Exit for any deviation from this behaviour.
|
|
2341 |
//!
|
|
2342 |
//! 6) The associated TRequestStatus object should indicate KErrCancel
|
|
2343 |
//! - exits otherwise.
|
|
2344 |
//!
|
|
2345 |
//! 7) The associated TRequestStatus object should indicate KErrCancel
|
|
2346 |
//! - exits otherwise.
|
|
2347 |
//!
|
|
2348 |
//! 8) The TRequestStatus object should indicate state KRequestPending until
|
|
2349 |
//! the state change is triggered, upon which it should exhibit state
|
|
2350 |
//! KErrNone. After the cancellation it should still exhibit state KErrNone.
|
|
2351 |
//! Exit for any deviation from this behaviour.
|
|
2352 |
//!
|
|
2353 |
//! 9) The TRequestStatus object should indicate state KRequestPending until
|
|
2354 |
//! the state change is triggered, upon which it should exhibit state
|
|
2355 |
//! KErrNone. After the cancellation it should still exhibit state KErrNone.
|
|
2356 |
//! Exit for any deviation from this behaviour.
|
|
2357 |
//!
|
|
2358 |
//! 10) The associated TRequestStatus object should indicate KErrCancel
|
|
2359 |
//! - exits otherwise.
|
|
2360 |
//!
|
|
2361 |
//! 11) The associated TRequestStatus object should indicate KErrCancel
|
|
2362 |
//! - exits otherwise.
|
|
2363 |
//!
|
|
2364 |
//! 12) The TRequestStatus object should indicate state KRequestPending until
|
|
2365 |
//! the state change is triggered, upon which it should exhibit state
|
|
2366 |
//! KErrNone. After the cancellation it should still exhibit state KErrNone.
|
|
2367 |
//! Exit for any deviation from this behaviour.
|
|
2368 |
//!
|
|
2369 |
//! 13) The TRequestStatus object should indicate state KRequestPending until
|
|
2370 |
//! the state change is triggered, upon which it should exhibit state
|
|
2371 |
//! KErrNone. After the cancellation it should still exhibit state KErrNone.
|
|
2372 |
//! Exit for any deviation from this behaviour.
|
|
2373 |
//!
|
|
2374 |
//! @SYMTestPriority High
|
|
2375 |
//! @SYMTestStatus Implemented
|
|
2376 |
//----------------------------------------------------------------------------------------------
|
|
2377 |
LOCAL_C TInt TestNotificationOps()
|
|
2378 |
//
|
|
2379 |
// Test notification methods
|
|
2380 |
//
|
|
2381 |
{
|
|
2382 |
__KHEAP_MARK;
|
|
2383 |
|
|
2384 |
TInt r = KErrNone;
|
|
2385 |
TRequestStatus status;
|
|
2386 |
TUint resourceId;
|
|
2387 |
TInt stateDelta;
|
|
2388 |
if(!gHaveAsyncRes)
|
|
2389 |
{
|
|
2390 |
resourceId = 2; // Arbitrary
|
|
2391 |
stateDelta = 1; // Arbitrary
|
|
2392 |
}
|
|
2393 |
else
|
|
2394 |
{
|
|
2395 |
resourceId = gLongLatencyResource;
|
|
2396 |
stateDelta = gAsyncResStateDelta;
|
|
2397 |
}
|
|
2398 |
TInt testIndex = 0;
|
|
2399 |
|
|
2400 |
// 0) Call API to request notification of an unqualified change in resource
|
|
2401 |
// state for a selected resource. Trigger a state change.
|
|
2402 |
gTest.Printf(_L("TestNotificationOps: starting test %d\n"),testIndex++);
|
|
2403 |
gChannel.RequestNotification(status, resourceId);
|
|
2404 |
if(status.Int() != KRequestPending)
|
|
2405 |
{
|
|
2406 |
gTest.Printf(_L("TestNotificationOps: status=%d\n"),status.Int());
|
|
2407 |
return KErrGeneral;
|
|
2408 |
}
|
|
2409 |
TBool cached = gUseCached;
|
|
2410 |
TRequestStatus triggerStatus;
|
|
2411 |
if((r=TriggerNotification(triggerStatus, resourceId, cached, stateDelta))!=KErrNone)
|
|
2412 |
return r;
|
|
2413 |
User::WaitForRequest(status);
|
|
2414 |
if(status.Int()!=KErrNone)
|
|
2415 |
{
|
|
2416 |
gTest.Printf(_L("TestNotificationOps: after TriggerNotification status = %d\n"),status.Int());
|
|
2417 |
return r;
|
|
2418 |
}
|
|
2419 |
|
|
2420 |
// 1) Call API to request notification of a qualified change in resource
|
|
2421 |
// state for a selected resource. Trigger a state change.
|
|
2422 |
gTest.Printf(_L("TestNotificationOps: starting test %d\n"),testIndex++);
|
|
2423 |
TInt dumThreshold=0;
|
|
2424 |
TBool dumDirection=EFalse;
|
|
2425 |
if((r=CalcNotifyDirAndThr(status, resourceId, cached, dumThreshold, dumDirection))!=KErrNone)
|
|
2426 |
return r;
|
|
2427 |
gChannel.RequestNotification(status, resourceId, dumThreshold, dumDirection);
|
|
2428 |
if(status.Int() != KRequestPending)
|
|
2429 |
{
|
|
2430 |
gTest.Printf(_L("TestNotificationOps: status=%d\n"),status.Int());
|
|
2431 |
return KErrGeneral;
|
|
2432 |
}
|
|
2433 |
// Pass gAsyncResStateDelta as this represents the delta value
|
|
2434 |
if((r=TriggerNotification(triggerStatus, resourceId, cached, gAsyncResStateDelta))!=KErrNone)
|
|
2435 |
return r;
|
|
2436 |
User::WaitForRequest(status);
|
|
2437 |
if(status.Int()!=KErrNone)
|
|
2438 |
{
|
|
2439 |
gTest.Printf(_L("TestNotificationOps: after TriggerNotification status = %d\n"),status.Int());
|
|
2440 |
return r;
|
|
2441 |
}
|
|
2442 |
|
|
2443 |
// 2) Call API to request notification of an unqualified change in resource
|
|
2444 |
// state for a selected resource. Then call API to cancel all notifications for the resource.
|
|
2445 |
gTest.Printf(_L("TestNotificationOps: starting test %d\n"),testIndex++);
|
|
2446 |
gChannel.RequestNotification(status, resourceId);
|
|
2447 |
if(status.Int() != KRequestPending)
|
|
2448 |
{
|
|
2449 |
gTest.Printf(_L("TestNotificationOps: status=%d\n"),status.Int());
|
|
2450 |
return KErrGeneral;
|
|
2451 |
}
|
|
2452 |
r=gChannel.CancelNotificationRequests(resourceId);
|
|
2453 |
if(r!=KErrNone)
|
|
2454 |
{
|
|
2455 |
gTest.Printf(_L("TestNotificationOps, CancelNotificationRequests returned %d\n"),r);
|
|
2456 |
return r;
|
|
2457 |
}
|
|
2458 |
User::WaitForRequest(status);
|
|
2459 |
if(status.Int()!=KErrCancel)
|
|
2460 |
{
|
|
2461 |
gTest.Printf(_L("TestNotificationOps: after cancel basic request status = %d\n"),status.Int());
|
|
2462 |
return r;
|
|
2463 |
}
|
|
2464 |
|
|
2465 |
// 3) Call API to request notification of a qualified change in resource
|
|
2466 |
// state for a selected resource. Then call API to cancel all notifications for the resource.
|
|
2467 |
gTest.Printf(_L("TestNotificationOps: starting test %d\n"),testIndex++);
|
|
2468 |
dumThreshold = 0; // Arbitrary
|
|
2469 |
dumDirection = ETrue; // Arbitrary
|
|
2470 |
if((r=CalcNotifyDirAndThr(status, resourceId, cached, dumThreshold, dumDirection))!=KErrNone)
|
|
2471 |
return r;
|
|
2472 |
gChannel.RequestNotification(status, resourceId, dumThreshold, dumDirection);
|
|
2473 |
if(status.Int() != KRequestPending)
|
|
2474 |
{
|
|
2475 |
gTest.Printf(_L("TestNotificationOps: status=%d\n"),status.Int());
|
|
2476 |
return KErrGeneral;
|
|
2477 |
}
|
|
2478 |
r=gChannel.CancelNotificationRequests(resourceId);
|
|
2479 |
if(r!=KErrNone)
|
|
2480 |
{
|
|
2481 |
gTest.Printf(_L("TestNotificationOps, CancelNotificationRequests (qualified) returned %d\n"),r);
|
|
2482 |
return r;
|
|
2483 |
}
|
|
2484 |
User::WaitForRequest(status);
|
|
2485 |
if(status.Int()!=KErrCancel)
|
|
2486 |
{
|
|
2487 |
gTest.Printf(_L("TestNotificationOps: after qualified request cancel status = %d\n"),status.Int());
|
|
2488 |
return r;
|
|
2489 |
}
|
|
2490 |
|
|
2491 |
// 4) Call API to request notification of an unqualified change in resource
|
|
2492 |
// state for a selected resource. Trigger a state change. Then call API to cancel all
|
|
2493 |
// notifications for the resource.
|
|
2494 |
gTest.Printf(_L("TestNotificationOps: starting test %d\n"),testIndex++);
|
|
2495 |
gChannel.RequestNotification(status, resourceId);
|
|
2496 |
if(status.Int() != KRequestPending)
|
|
2497 |
{
|
|
2498 |
gTest.Printf(_L("TestNotificationOps: status=%d\n"),status.Int());
|
|
2499 |
return KErrGeneral;
|
|
2500 |
}
|
|
2501 |
// Pass gAsyncResStateDelta as this represents the delta value
|
|
2502 |
if((r=TriggerNotification(triggerStatus, resourceId, cached, gAsyncResStateDelta))!=KErrNone)
|
|
2503 |
return r;
|
|
2504 |
User::WaitForRequest(status);
|
|
2505 |
if(status.Int()!=KErrNone)
|
|
2506 |
{
|
|
2507 |
gTest.Printf(_L("TestNotificationOps: trigger basic request before cancel, status = %d\n"),status.Int());
|
|
2508 |
return r;
|
|
2509 |
}
|
|
2510 |
r=gChannel.CancelNotificationRequests(resourceId);
|
|
2511 |
if(r!=KErrNone)
|
|
2512 |
{
|
|
2513 |
gTest.Printf(_L("TestNotificationOps, CancelNotificationRequests returned %d\n"),r);
|
|
2514 |
return r;
|
|
2515 |
}
|
|
2516 |
if(status.Int()!=KErrNone)
|
|
2517 |
{
|
|
2518 |
gTest.Printf(_L("TestNotificationOps: after cancel (completed) basic request status = %d\n"),status.Int());
|
|
2519 |
return r;
|
|
2520 |
}
|
|
2521 |
|
|
2522 |
// 5) Call API to request notification of a qualified change in resource
|
|
2523 |
// state for a selected resource. Trigger a state change. Then call API to cancel all
|
|
2524 |
// notifications for the resource.
|
|
2525 |
gTest.Printf(_L("TestNotificationOps: starting test %d\n"),testIndex++);
|
|
2526 |
if((r=CalcNotifyDirAndThr(status, resourceId, cached, dumThreshold, dumDirection))!=KErrNone)
|
|
2527 |
return r;
|
|
2528 |
gChannel.RequestNotification(status, resourceId, dumThreshold, dumDirection);
|
|
2529 |
if(status.Int() != KRequestPending)
|
|
2530 |
{
|
|
2531 |
gTest.Printf(_L("TestNotificationOps: status=%d\n"),status.Int());
|
|
2532 |
return KErrGeneral;
|
|
2533 |
}
|
|
2534 |
// Pass gAsyncResStateDelta as this represents the delta value
|
|
2535 |
if((r=TriggerNotification(triggerStatus, resourceId, cached, gAsyncResStateDelta))!=KErrNone)
|
|
2536 |
return r;
|
|
2537 |
User::WaitForRequest(status);
|
|
2538 |
if(status.Int()!=KErrNone)
|
|
2539 |
{
|
|
2540 |
gTest.Printf(_L("TestNotificationOps: trigger qualified request before cancel, status = %d\n"),status.Int());
|
|
2541 |
return r;
|
|
2542 |
}
|
|
2543 |
r=gChannel.CancelNotificationRequests(resourceId);
|
|
2544 |
if(r!=KErrNone)
|
|
2545 |
{
|
|
2546 |
gTest.Printf(_L("TestNotificationOps, CancelNotificationRequests (qualified) returned %d\n"),r);
|
|
2547 |
return r;
|
|
2548 |
}
|
|
2549 |
if(status.Int()!=KErrNone)
|
|
2550 |
{
|
|
2551 |
gTest.Printf(_L("TestNotificationOps: after cancel (completed) qualified request status = %d\n"),status.Int());
|
|
2552 |
return r;
|
|
2553 |
}
|
|
2554 |
|
|
2555 |
// 6) Call API to request notification of an unqualified change in resource
|
|
2556 |
// state for a selected resource. Then call API to cancel the notification request
|
|
2557 |
gTest.Printf(_L("TestNotificationOps: starting test %d\n"),testIndex++);
|
|
2558 |
gChannel.RequestNotification(status, resourceId);
|
|
2559 |
if(status.Int() != KRequestPending)
|
|
2560 |
{
|
|
2561 |
gTest.Printf(_L("TestNotificationOps: status=%d\n"),status.Int());
|
|
2562 |
return KErrGeneral;
|
|
2563 |
}
|
|
2564 |
r=gChannel.CancelRequestNotification(status);
|
|
2565 |
if(r!=KErrNone)
|
|
2566 |
{
|
|
2567 |
gTest.Printf(_L("TestNotificationOps, CancelNotificationRequests returned %d\n"),r);
|
|
2568 |
return r;
|
|
2569 |
}
|
|
2570 |
User::WaitForRequest(status);
|
|
2571 |
if(status.Int()!=KErrCancel)
|
|
2572 |
{
|
|
2573 |
gTest.Printf(_L("TestNotificationOps: after cancel basic request status = %d\n"),status.Int());
|
|
2574 |
return r;
|
|
2575 |
}
|
|
2576 |
|
|
2577 |
// 7) Call API to request notification of a qualified change in resource
|
|
2578 |
// state for a selected resource. Then call API to cancel the notification request
|
|
2579 |
gTest.Printf(_L("TestNotificationOps: starting test %d\n"),testIndex++);
|
|
2580 |
dumThreshold = 0; // Arbitrary
|
|
2581 |
dumDirection = ETrue; // Arbitrary
|
|
2582 |
if((r=CalcNotifyDirAndThr(status, resourceId, cached, dumThreshold, dumDirection))!=KErrNone)
|
|
2583 |
return r;
|
|
2584 |
gChannel.RequestNotification(status, resourceId, dumThreshold, dumDirection);
|
|
2585 |
if(status.Int() != KRequestPending)
|
|
2586 |
{
|
|
2587 |
gTest.Printf(_L("TestNotificationOps: status=%d\n"),status.Int());
|
|
2588 |
return KErrGeneral;
|
|
2589 |
}
|
|
2590 |
r=gChannel.CancelRequestNotification(status);
|
|
2591 |
if(r!=KErrNone)
|
|
2592 |
{
|
|
2593 |
gTest.Printf(_L("TestNotificationOps, CancelNotificationRequests (qualified) returned %d\n"),r);
|
|
2594 |
return r;
|
|
2595 |
}
|
|
2596 |
User::WaitForRequest(status);
|
|
2597 |
if(status.Int()!=KErrCancel)
|
|
2598 |
{
|
|
2599 |
gTest.Printf(_L("TestNotificationOps: after qualified request cancel status = %d\n"),status.Int());
|
|
2600 |
return r;
|
|
2601 |
}
|
|
2602 |
|
|
2603 |
// 8) Call API to request notification of an unqualified change in resource
|
|
2604 |
// state for a selected resource. Trigger a state change. Then call API to cancel the
|
|
2605 |
// notification request
|
|
2606 |
gTest.Printf(_L("TestNotificationOps: starting test %d\n"),testIndex++);
|
|
2607 |
gChannel.RequestNotification(status, resourceId);
|
|
2608 |
if(status.Int() != KRequestPending)
|
|
2609 |
{
|
|
2610 |
gTest.Printf(_L("TestNotificationOps: status=%d\n"),status.Int());
|
|
2611 |
return KErrGeneral;
|
|
2612 |
}
|
|
2613 |
// Pass gAsyncResStateDelta as this represents the delta value
|
|
2614 |
if((r=TriggerNotification(triggerStatus, resourceId, cached, gAsyncResStateDelta))!=KErrNone)
|
|
2615 |
return r;
|
|
2616 |
User::WaitForRequest(status);
|
|
2617 |
if(status.Int()!=KErrNone)
|
|
2618 |
{
|
|
2619 |
gTest.Printf(_L("TestNotificationOps: trigger basic request before cancel, status = %d\n"),status.Int());
|
|
2620 |
return r;
|
|
2621 |
}
|
|
2622 |
r=gChannel.CancelRequestNotification(status);
|
|
2623 |
if(r!=KErrNone)
|
|
2624 |
{
|
|
2625 |
gTest.Printf(_L("TestNotificationOps, CancelNotificationRequests returned %d\n"),r);
|
|
2626 |
return r;
|
|
2627 |
}
|
|
2628 |
if(status.Int()!=KErrNone)
|
|
2629 |
{
|
|
2630 |
gTest.Printf(_L("TestNotificationOps: after cancel (completed) basic request status = %d\n"),status.Int());
|
|
2631 |
return r;
|
|
2632 |
}
|
|
2633 |
|
|
2634 |
// 9) Call API to request notification of a qualified change in resource
|
|
2635 |
// state for a selected resource. Trigger a state change. Then call API to cancel the
|
|
2636 |
// notification request
|
|
2637 |
gTest.Printf(_L("TestNotificationOps: starting test %d\n"),testIndex++);
|
|
2638 |
if((r=CalcNotifyDirAndThr(status, resourceId, cached, dumThreshold, dumDirection))!=KErrNone)
|
|
2639 |
return r;
|
|
2640 |
gChannel.RequestNotification(status, resourceId, dumThreshold, dumDirection);
|
|
2641 |
if(status.Int() != KRequestPending)
|
|
2642 |
{
|
|
2643 |
gTest.Printf(_L("TestNotificationOps: status=%d\n"),status.Int());
|
|
2644 |
return KErrGeneral;
|
|
2645 |
}
|
|
2646 |
// Pass gAsyncResStateDelta as this represents the delta value
|
|
2647 |
if((r=TriggerNotification(triggerStatus, resourceId, cached, gAsyncResStateDelta))!=KErrNone)
|
|
2648 |
return r;
|
|
2649 |
User::WaitForRequest(status);
|
|
2650 |
if(status.Int()!=KErrNone)
|
|
2651 |
{
|
|
2652 |
gTest.Printf(_L("TestNotificationOps: trigger qualified request before cancel, status = %d\n"),status.Int());
|
|
2653 |
return r;
|
|
2654 |
}
|
|
2655 |
r=gChannel.CancelRequestNotification(status);
|
|
2656 |
if(r!=KErrNone)
|
|
2657 |
{
|
|
2658 |
gTest.Printf(_L("TestNotificationOps, CancelNotificationRequests (qualified) returned %d\n"),r);
|
|
2659 |
return r;
|
|
2660 |
}
|
|
2661 |
if(status.Int()!=KErrNone)
|
|
2662 |
{
|
|
2663 |
gTest.Printf(_L("TestNotificationOps: after cancel (completed) qualified request status = %d\n"),status.Int());
|
|
2664 |
return r;
|
|
2665 |
}
|
|
2666 |
|
|
2667 |
|
|
2668 |
// 10) Call API to request notification of an unqualified change in resource
|
|
2669 |
// state for a selected resource. Then call API to cancel generic async request
|
|
2670 |
gTest.Printf(_L("TestNotificationOps: starting test %d\n"),testIndex++);
|
|
2671 |
gChannel.RequestNotification(status, resourceId);
|
|
2672 |
if(status.Int() != KRequestPending)
|
|
2673 |
{
|
|
2674 |
gTest.Printf(_L("TestNotificationOps: status=%d\n"),status.Int());
|
|
2675 |
return KErrGeneral;
|
|
2676 |
}
|
|
2677 |
gChannel.CancelAsyncOperation(&status);
|
|
2678 |
User::WaitForRequest(status);
|
|
2679 |
if(status.Int()!=KErrCancel)
|
|
2680 |
{
|
|
2681 |
gTest.Printf(_L("TestNotificationOps: after cancel basic request status = %d\n"),status.Int());
|
|
2682 |
return r;
|
|
2683 |
}
|
|
2684 |
|
|
2685 |
// 11) Call API to request notification of a qualified change in resource
|
|
2686 |
// state for a selected resource. Then call API to cancel generic async request
|
|
2687 |
gTest.Printf(_L("TestNotificationOps: starting test %d\n"),testIndex++);
|
|
2688 |
dumThreshold = 0; // Arbitrary
|
|
2689 |
dumDirection = ETrue; // Arbitrary
|
|
2690 |
if((r=CalcNotifyDirAndThr(status, resourceId, cached, dumThreshold, dumDirection))!=KErrNone)
|
|
2691 |
return r;
|
|
2692 |
gChannel.RequestNotification(status, resourceId, dumThreshold, dumDirection);
|
|
2693 |
if(status.Int() != KRequestPending)
|
|
2694 |
{
|
|
2695 |
gTest.Printf(_L("TestNotificationOps: status=%d\n"),status.Int());
|
|
2696 |
return KErrGeneral;
|
|
2697 |
}
|
|
2698 |
gChannel.CancelAsyncOperation(&status);
|
|
2699 |
User::WaitForRequest(status);
|
|
2700 |
if(status.Int()!=KErrCancel)
|
|
2701 |
{
|
|
2702 |
gTest.Printf(_L("TestNotificationOps: after qualified request cancel status = %d\n"),status.Int());
|
|
2703 |
return r;
|
|
2704 |
}
|
|
2705 |
|
|
2706 |
// 12) Call API to request notification of an unqualified change in resource
|
|
2707 |
// state for a selected resource. Trigger a state change. Then call API to cancel
|
|
2708 |
// generic async request
|
|
2709 |
gTest.Printf(_L("TestNotificationOps: starting test %d\n"),testIndex++);
|
|
2710 |
gChannel.RequestNotification(status, resourceId);
|
|
2711 |
if(status.Int() != KRequestPending)
|
|
2712 |
{
|
|
2713 |
gTest.Printf(_L("TestNotificationOps: status=%d\n"),status.Int());
|
|
2714 |
return KErrGeneral;
|
|
2715 |
}
|
|
2716 |
// Pass gAsyncResStateDelta as this represents the delta value
|
|
2717 |
if((r=TriggerNotification(triggerStatus, resourceId, cached, gAsyncResStateDelta))!=KErrNone)
|
|
2718 |
return r;
|
|
2719 |
User::WaitForRequest(status);
|
|
2720 |
if(status.Int()!=KErrNone)
|
|
2721 |
{
|
|
2722 |
gTest.Printf(_L("TestNotificationOps: trigger basic request before cancel, status = %d\n"),status.Int());
|
|
2723 |
return r;
|
|
2724 |
}
|
|
2725 |
gChannel.CancelAsyncOperation(&status);
|
|
2726 |
if(status.Int()!=KErrNone)
|
|
2727 |
{
|
|
2728 |
gTest.Printf(_L("TestNotificationOps: after cancel (completed) basic request status = %d\n"),status.Int());
|
|
2729 |
return r;
|
|
2730 |
}
|
|
2731 |
|
|
2732 |
// 13) Call API to request notification of a qualified change in resource
|
|
2733 |
// state for a selected resource. Trigger a state change. Then call API to cancel
|
|
2734 |
// generic async request
|
|
2735 |
gTest.Printf(_L("TestNotificationOps: starting test %d\n"),testIndex++);
|
|
2736 |
if((r=CalcNotifyDirAndThr(status, resourceId, cached, dumThreshold, dumDirection))!=KErrNone)
|
|
2737 |
return r;
|
|
2738 |
gChannel.RequestNotification(status, resourceId, dumThreshold, dumDirection);
|
|
2739 |
if(status.Int() != KRequestPending)
|
|
2740 |
{
|
|
2741 |
gTest.Printf(_L("TestNotificationOps: status=%d\n"),status.Int());
|
|
2742 |
return KErrGeneral;
|
|
2743 |
}
|
|
2744 |
// Pass gAsyncResStateDelta as this represents the delta value
|
|
2745 |
if((r=TriggerNotification(triggerStatus, resourceId, cached, gAsyncResStateDelta))!=KErrNone)
|
|
2746 |
return r;
|
|
2747 |
User::WaitForRequest(status);
|
|
2748 |
if(status.Int()!=KErrNone)
|
|
2749 |
{
|
|
2750 |
gTest.Printf(_L("TestNotificationOps: trigger qualified request before cancel, status = %d\n"),status.Int());
|
|
2751 |
return r;
|
|
2752 |
}
|
|
2753 |
gChannel.CancelAsyncOperation(&status);
|
|
2754 |
if(status.Int()!=KErrNone)
|
|
2755 |
{
|
|
2756 |
gTest.Printf(_L("TestNotificationOps: after cancel (completed) qualified request status = %d\n"),status.Int());
|
|
2757 |
return r;
|
|
2758 |
}
|
|
2759 |
|
|
2760 |
__KHEAP_MARKEND;
|
|
2761 |
|
|
2762 |
return r;
|
|
2763 |
}
|
|
2764 |
|
|
2765 |
//----------------------------------------------------------------------------------------------
|
|
2766 |
//! @SYMTestCaseID KBASE-T_RESMANUS-0613
|
|
2767 |
//! @SYMTestType UT
|
|
2768 |
//! @SYMPREQ PREQ1398
|
|
2769 |
//! @SYMTestCaseDesc This test case tests quota management for notification operations.
|
|
2770 |
//!
|
|
2771 |
//! @SYMTestActions 0) Issue the maximum number (requested in the call to the Initialise API)
|
|
2772 |
//! of requests for notification of unqualified changes to the state of a
|
|
2773 |
//! resource. Then issue one further request.
|
|
2774 |
//!
|
|
2775 |
//! 1) Issue the maximum number (requested in the call to the Initialise API)
|
|
2776 |
//! of requests for notification of qualified changes to the state of a
|
|
2777 |
//! resource. Then issue one further request.
|
|
2778 |
//!
|
|
2779 |
//! 2) Issue the maximum number (requested in the call to the Initialise API)
|
|
2780 |
//! of requests for notification changes to the state of a resource, where
|
|
2781 |
//! every odd request is for an unqualified change and every even request is
|
|
2782 |
//! for a qualified change. Then issue one further request.
|
|
2783 |
//!
|
|
2784 |
//! @SYMTestExpectedResults 0) Test that the TRequestStatus object associated with the last
|
|
2785 |
//! request exhibits status code KErrUnderflow - exit otherwise. Test
|
|
2786 |
//! that the TRequestStatus objects associated with the preceding requests
|
|
2787 |
//! exhibit status code KErrNone - exit otherwise.
|
|
2788 |
//!
|
|
2789 |
//! 1) Test that the TRequestStatus object associated with the last request
|
|
2790 |
//! exhibits status code KErrUnderflow - exit otherwise. Test that the
|
|
2791 |
//! TRequestStatus objects associated with the preceding requests exhibit
|
|
2792 |
//! status code KErrNone - exit otherwise.
|
|
2793 |
//!
|
|
2794 |
//! 2) Test that the TRequestStatus object associated with the last request
|
|
2795 |
//! exhibits status code KErrUnderflow - exit otherwise. Test that the
|
|
2796 |
//! TRequestStatus objects associated with the preceding requests exhibit
|
|
2797 |
//! status code KErrNone - exit otherwise.
|
|
2798 |
//!
|
|
2799 |
//! @SYMTestPriority High
|
|
2800 |
//! @SYMTestStatus Implemented
|
|
2801 |
//----------------------------------------------------------------------------------------------
|
|
2802 |
LOCAL_C TInt TestNotificationQuota()
|
|
2803 |
//
|
|
2804 |
// Test notification request quota management
|
|
2805 |
//
|
|
2806 |
{
|
|
2807 |
__KHEAP_MARK;
|
|
2808 |
|
|
2809 |
TInt r = KErrNone;
|
|
2810 |
TRequestStatus status[MAX_NUM_REQUESTS];
|
|
2811 |
TInt loopVar=0;
|
|
2812 |
TBool cached = gUseCached;
|
|
2813 |
TRequestStatus triggerStatus;
|
|
2814 |
TUint resourceId = gLongLatencyResource;
|
|
2815 |
|
|
2816 |
// Test quota for basic operation
|
|
2817 |
//
|
|
2818 |
// Loop to perform maximum number of requests, check TRequestStatus objects are pending
|
|
2819 |
for(loopVar=0; loopVar<KNoOfNotifyRequests; loopVar++)
|
|
2820 |
{
|
|
2821 |
gChannel.RequestNotification(status[loopVar], resourceId);
|
|
2822 |
if(status[loopVar].Int() != KRequestPending)
|
|
2823 |
{
|
|
2824 |
gTest.Printf(_L("TestNotificationQuota: status not KRequestPending, =%d\n"),
|
|
2825 |
status[loopVar].Int());
|
|
2826 |
return KErrGeneral;
|
|
2827 |
}
|
|
2828 |
}
|
|
2829 |
// Issue one more request, check that TRequestStatus object exhibits state KErrUnderflow
|
|
2830 |
gChannel.RequestNotification(status[KNoOfNotifyRequests], resourceId);
|
|
2831 |
if(status[KNoOfNotifyRequests].Int() != KErrUnderflow)
|
|
2832 |
{
|
|
2833 |
gTest.Printf(_L("TestNotificationQuota: status[%d] not KErrUnderflow, =%d\n"),
|
|
2834 |
KNoOfNotifyRequests,status[loopVar].Int());
|
|
2835 |
return KErrGeneral;
|
|
2836 |
}
|
|
2837 |
// Loop to trigger previously-issued notifications, check TRequestStatus objects
|
|
2838 |
for(loopVar=0; loopVar<KNoOfNotifyRequests; loopVar++)
|
|
2839 |
{
|
|
2840 |
// Pass gAsyncResStateDelta as this represents the delta value
|
|
2841 |
if((r=TriggerNotification(triggerStatus, resourceId, cached, gAsyncResStateDelta))!=KErrNone)
|
|
2842 |
return r;
|
|
2843 |
User::WaitForRequest(status[loopVar]);
|
|
2844 |
if(status[loopVar].Int()!=KErrNone)
|
|
2845 |
{
|
|
2846 |
gTest.Printf(_L("TestNotificationQuota: trigger basic request status[%d] = %d\n"),
|
|
2847 |
loopVar,status[loopVar].Int());
|
|
2848 |
return r;
|
|
2849 |
}
|
|
2850 |
}
|
|
2851 |
|
|
2852 |
|
|
2853 |
// Test quota for qualified operation
|
|
2854 |
//
|
|
2855 |
TInt dumThreshold = -25; // Arbitrary
|
|
2856 |
TBool dumDirection = ETrue; // Arbitrary
|
|
2857 |
//
|
|
2858 |
// Loop to perform maximum number of requests, check TRequestStatus objects are pending
|
|
2859 |
for(loopVar=0; loopVar<KNoOfNotifyRequests; loopVar++)
|
|
2860 |
{
|
|
2861 |
if((r=CalcNotifyDirAndThr(status[loopVar], resourceId, cached, dumThreshold, dumDirection))!=KErrNone)
|
|
2862 |
return r;
|
|
2863 |
gChannel.RequestNotification(status[loopVar], resourceId, dumThreshold, dumDirection);
|
|
2864 |
if(status[loopVar].Int() != KRequestPending)
|
|
2865 |
{
|
|
2866 |
gTest.Printf(_L("TestNotificationQuota: status[%d] not KRequestPending, =%d\n"),
|
|
2867 |
loopVar,status[loopVar].Int());
|
|
2868 |
return KErrGeneral;
|
|
2869 |
}
|
|
2870 |
}
|
|
2871 |
// Issue one more request, check that TRequestStatus object exhibits state KErrUnderflow
|
|
2872 |
if((r=CalcNotifyDirAndThr(status[KNoOfNotifyRequests], resourceId, cached, dumThreshold, dumDirection))!=KErrNone)
|
|
2873 |
return r;
|
|
2874 |
gChannel.RequestNotification(status[KNoOfNotifyRequests], resourceId, dumThreshold, dumDirection);
|
|
2875 |
if(status[KNoOfNotifyRequests].Int() != KErrUnderflow)
|
|
2876 |
{
|
|
2877 |
gTest.Printf(_L("TestNotificationQuota: status[%d] not KErrUnderflow, =%d\n"),
|
|
2878 |
KNoOfNotifyRequests,status[loopVar].Int());
|
|
2879 |
return KErrGeneral;
|
|
2880 |
}
|
|
2881 |
// Loop to trigger previously-issued notifications, check TRequestStatus objects
|
|
2882 |
for(loopVar=0; loopVar<KNoOfNotifyRequests; loopVar++)
|
|
2883 |
{
|
|
2884 |
// Pass gAsyncResStateDelta as this represents the delta value
|
|
2885 |
if((r=TriggerNotification(triggerStatus, resourceId, cached, gAsyncResStateDelta))!=KErrNone)
|
|
2886 |
return r;
|
|
2887 |
User::WaitForRequest(status[loopVar]);
|
|
2888 |
if(status[loopVar].Int()!=KErrNone)
|
|
2889 |
{
|
|
2890 |
gTest.Printf(_L("TestNotificationQuota: trigger qualified request status[%d] = %d\n"),
|
|
2891 |
loopVar,status[loopVar].Int());
|
|
2892 |
return r;
|
|
2893 |
}
|
|
2894 |
}
|
|
2895 |
|
|
2896 |
// Text quota with mixture of basic and qualified requests
|
|
2897 |
//
|
|
2898 |
TBool qualified = ETrue;
|
|
2899 |
// Issue requests and check TRequestStatus objects are pending
|
|
2900 |
for(loopVar=0; loopVar<KNoOfNotifyRequests; loopVar++)
|
|
2901 |
{
|
|
2902 |
if(qualified)
|
|
2903 |
{
|
|
2904 |
if((r=CalcNotifyDirAndThr(status[loopVar], resourceId, cached, dumThreshold, dumDirection))!=KErrNone)
|
|
2905 |
return r;
|
|
2906 |
gChannel.RequestNotification(status[loopVar], resourceId, dumThreshold, dumDirection);
|
|
2907 |
}
|
|
2908 |
else
|
|
2909 |
{
|
|
2910 |
gChannel.RequestNotification(status[loopVar], resourceId);
|
|
2911 |
}
|
|
2912 |
qualified=!qualified;
|
|
2913 |
if(status[loopVar].Int() != KRequestPending)
|
|
2914 |
{
|
|
2915 |
gTest.Printf(_L("TestNotificationQuota: mixed loop status[%d] not KRequestPending, =%d\n"),
|
|
2916 |
loopVar,status[loopVar].Int());
|
|
2917 |
return KErrGeneral;
|
|
2918 |
}
|
|
2919 |
}
|
|
2920 |
// Issue one more request, check that TRequestStatus object exhibits state KErrUnderflow
|
|
2921 |
if(qualified)
|
|
2922 |
{
|
|
2923 |
if((r=CalcNotifyDirAndThr(status[KNoOfNotifyRequests], resourceId, cached, dumThreshold, dumDirection))!=KErrNone)
|
|
2924 |
return r;
|
|
2925 |
gChannel.RequestNotification(status[KNoOfNotifyRequests], resourceId, dumThreshold, dumDirection);
|
|
2926 |
}
|
|
2927 |
else
|
|
2928 |
{
|
|
2929 |
gChannel.RequestNotification(status[KNoOfNotifyRequests], resourceId);
|
|
2930 |
}
|
|
2931 |
if(status[KNoOfNotifyRequests].Int() != KErrUnderflow)
|
|
2932 |
{
|
|
2933 |
gTest.Printf(_L("TestNotificationQuota: mixed loop status[%d] not KErrUnderflow, =%d\n"),
|
|
2934 |
KNoOfNotifyRequests,status[loopVar].Int());
|
|
2935 |
return KErrGeneral;
|
|
2936 |
}
|
|
2937 |
// Loop to trigger previously-issued notifications, check TRequestStatus objects
|
|
2938 |
for(loopVar=0; loopVar<KNoOfNotifyRequests; loopVar++)
|
|
2939 |
{
|
|
2940 |
// Pass gAsyncResStateDelta as this represents the delta value
|
|
2941 |
if((r=TriggerNotification(triggerStatus, resourceId, cached, gAsyncResStateDelta))!=KErrNone)
|
|
2942 |
return r;
|
|
2943 |
User::WaitForRequest(status[loopVar]);
|
|
2944 |
if(status[loopVar].Int()!=KErrNone)
|
|
2945 |
{
|
|
2946 |
gTest.Printf(_L("TestNotificationQuota: trigger mixed request status[%d] = %d\n"),
|
|
2947 |
loopVar,status[loopVar].Int());
|
|
2948 |
return r;
|
|
2949 |
}
|
|
2950 |
}
|
|
2951 |
|
|
2952 |
__KHEAP_MARKEND;
|
|
2953 |
|
|
2954 |
return r;
|
|
2955 |
}
|
|
2956 |
|
|
2957 |
#ifdef PIRATE_THREAD_TESTS
|
|
2958 |
|
|
2959 |
RThread PirateThread;
|
|
2960 |
TRequestStatus PirateStatus;
|
|
2961 |
const TInt KHeapSize=0x4000;
|
|
2962 |
const TInt KStackSize=0x4000;
|
|
2963 |
|
|
2964 |
_LIT(KPirateThreadName,"Pirate");
|
|
2965 |
|
|
2966 |
TInt PirateThreadFn(TAny* /*aSrcThread*/)
|
|
2967 |
{
|
|
2968 |
#if 0
|
|
2969 |
TInt r=KErrNone;
|
|
2970 |
RBusDevResManUs pirateChannel = gChannel;
|
|
2971 |
RThread& thread = *((RThread*)aSrcThread);
|
|
2972 |
|
|
2973 |
/* 1 - pirate with current thread - Panics kernel with KErrBadHandle */
|
|
2974 |
if((r=pirateChannel.Duplicate(RThread(),EOwnerProcess))!=KErrAccessDenied)
|
|
2975 |
{
|
|
2976 |
gTest.Printf(_L("TestThreadExclusiveAccess: pirateChannel.Duplicate(RThread(),EOwnerProcess) returned %d\n"),r);
|
|
2977 |
return KErrGeneral;
|
|
2978 |
}
|
|
2979 |
|
|
2980 |
/* 2 - pirate with parent thread - Panics kernel with KErrBadHandle */
|
|
2981 |
pirateChannel = gChannel;
|
|
2982 |
if((r=pirateChannel.Duplicate(thread,EOwnerThread))!=KErrAccessDenied)
|
|
2983 |
{
|
|
2984 |
gTest.Printf(_L("TestThreadExclusiveAccess: pirateChannel.Duplicate(thread,EOwnerThread) returned %d\n"),r);
|
|
2985 |
return KErrGeneral;
|
|
2986 |
}
|
|
2987 |
|
|
2988 |
/* 3 - gChannel with current thread - Panics kernel with KErrBadHandle */
|
|
2989 |
if((r=gChannel.Duplicate(RThread(),EOwnerThread))!=KErrAccessDenied)
|
|
2990 |
{
|
|
2991 |
gTest.Printf(_L("TestThreadExclusiveAccess: gChannel.Duplicate(RThread(),EOwnerThread) returned %d\n"),r);
|
|
2992 |
return KErrGeneral;
|
|
2993 |
}
|
|
2994 |
|
|
2995 |
/* 4 - gChannel with parent thread - Panics kernel with KErrBadHandle */
|
|
2996 |
if((r=gChannel.Duplicate(thread,EOwnerThread))!=KErrAccessDenied)
|
|
2997 |
{
|
|
2998 |
gTest.Printf(_L("TestThreadExclusiveAccess: gChannel.Duplicate(thread,EOwnerThread)returned %d\n"),r);
|
|
2999 |
return KErrGeneral;
|
|
3000 |
}
|
|
3001 |
#endif
|
|
3002 |
|
|
3003 |
// pirateChannel.Close();
|
|
3004 |
return KErrNone;
|
|
3005 |
}
|
|
3006 |
|
|
3007 |
TInt StartPirate(RThread& aSrcThread)
|
|
3008 |
{
|
|
3009 |
TAny* srcThread =(TAny*)(&aSrcThread);
|
|
3010 |
TInt r=PirateThread.Create(KPirateThreadName,PirateThreadFn,KStackSize,KHeapSize,KHeapSize,srcThread,EOwnerThread);
|
|
3011 |
if (r!=KErrNone)
|
|
3012 |
return r;
|
|
3013 |
PirateThread.Logon(PirateStatus);
|
|
3014 |
PirateThread.Resume();
|
|
3015 |
return KErrNone;
|
|
3016 |
}
|
|
3017 |
|
|
3018 |
TInt WaitForPirateThread()
|
|
3019 |
{
|
|
3020 |
User::WaitForRequest(PirateStatus);
|
|
3021 |
TInt exitType=PirateThread.ExitType();
|
|
3022 |
TInt exitReason=PirateThread.ExitReason();
|
|
3023 |
TBuf<16> exitCat=PirateThread.ExitCategory();
|
|
3024 |
if((exitType!= EExitKill)||(exitReason!=KErrNone))
|
|
3025 |
{
|
|
3026 |
gTest.Printf(_L("Pirate thread error: %d\n"),PirateStatus.Int());
|
|
3027 |
gTest.Printf(_L("Thread exit reason: %d,%d,%S\n"),exitType,exitReason,&exitCat);
|
|
3028 |
gTest(0);
|
|
3029 |
}
|
|
3030 |
PirateThread.Close();
|
|
3031 |
return KErrNone;
|
|
3032 |
}
|
|
3033 |
|
|
3034 |
#endif
|
|
3035 |
|
|
3036 |
//----------------------------------------------------------------------------------------------
|
|
3037 |
//! @SYMTestCaseID KBASE-T_RESMANUS-0608
|
|
3038 |
//! @SYMTestType UT
|
|
3039 |
//! @SYMPREQ PREQ1398
|
|
3040 |
//! @SYMTestCaseDesc This test case tests that channels can not be shared between threads.
|
|
3041 |
//! @SYMTestActions 0) Attempt to Duplicate the channel handle with EOwnerProcess as the owner type.
|
|
3042 |
//!
|
|
3043 |
//! 1) Attempt to Duplicate the channel handle with EOwnerThread
|
|
3044 |
//!
|
|
3045 |
//! @SYMTestExpectedResults 0) API should return with KErrAccessDenied, exits otherwise.
|
|
3046 |
//! 1) API should return with KErrNone, exits otherwise.
|
|
3047 |
//!
|
|
3048 |
//! @SYMTestPriority High
|
|
3049 |
//! @SYMTestStatus Implemented
|
|
3050 |
//----------------------------------------------------------------------------------------------
|
|
3051 |
LOCAL_C TInt TestThreadExclusiveAccess()
|
|
3052 |
//
|
|
3053 |
// Test mechanism to prevent other threads accessing a channel
|
|
3054 |
//
|
|
3055 |
{
|
|
3056 |
__KHEAP_MARK;
|
|
3057 |
|
|
3058 |
TInt r;
|
|
3059 |
RBusDevResManUs pirateChannel = gChannel;
|
|
3060 |
if((r=pirateChannel.Duplicate(RThread(),EOwnerProcess))!=KErrAccessDenied)
|
|
3061 |
{
|
|
3062 |
gTest.Printf(_L("TestThreadExclusiveAccess: Duplicate with EOwnerProcess returned %d\n"),r);
|
|
3063 |
if(r==KErrNone)
|
|
3064 |
r=KErrGeneral;
|
244
|
3065 |
return r; // return error which is neither KErrNone nor KErrAccessDenied
|
0
|
3066 |
}
|
|
3067 |
pirateChannel = gChannel;
|
|
3068 |
if((r=pirateChannel.Duplicate(RThread(),EOwnerThread))!=KErrNone)
|
|
3069 |
{
|
|
3070 |
gTest.Printf(_L("TestThreadExclusiveAccess: Duplicate with EOwnerThread returned %d\n"),r);
|
|
3071 |
return r;
|
|
3072 |
}
|
|
3073 |
#ifdef PIRATE_THREAD_TESTS
|
|
3074 |
RThread& threadRef = RThread();
|
|
3075 |
if((r=StartPirate(threadRef))!=KErrNone)
|
|
3076 |
{
|
|
3077 |
gTest.Printf(_L("TestThreadExclusiveAccess: StartPirate returned %d\n"),r);
|
|
3078 |
return KErrGeneral;
|
|
3079 |
}
|
|
3080 |
if((r=WaitForPirateThread())!=KErrNone)
|
|
3081 |
{
|
|
3082 |
gTest.Printf(_L("TestThreadExclusiveAccess: WaitForPirateThread returned %d\n"),r);
|
|
3083 |
return KErrGeneral;
|
|
3084 |
}
|
|
3085 |
#endif
|
|
3086 |
pirateChannel.Close();
|
|
3087 |
|
|
3088 |
__KHEAP_MARKEND;
|
|
3089 |
|
|
3090 |
return KErrNone;
|
|
3091 |
}
|
|
3092 |
|
|
3093 |
RThread Thrd2;
|
|
3094 |
TRequestStatus Thrd2Status;
|
|
3095 |
const TInt KHeapSize=0x4000;
|
|
3096 |
const TInt KStackSize=0x4000;
|
|
3097 |
|
|
3098 |
_LIT(KThrd2Name,"Thread2");
|
|
3099 |
|
|
3100 |
|
|
3101 |
TInt Thread2Fn(TAny* /* */)
|
|
3102 |
//
|
|
3103 |
// Test that more than one thread can be supported
|
|
3104 |
//
|
|
3105 |
{
|
|
3106 |
TInt r;
|
|
3107 |
|
|
3108 |
// Open a channel
|
|
3109 |
//
|
|
3110 |
_LIT(secThrdStr,"Thrd2Channel");
|
|
3111 |
TBufC<16> secThrdName(secThrdStr);
|
|
3112 |
// API accepts 8-bit descriptors, only - so convert name accordingly
|
|
3113 |
TBuf8<MAX_RESOURCE_NAME_LENGTH+1>EightBitName;
|
|
3114 |
EightBitName.Copy(secThrdName);
|
|
3115 |
RBusDevResManUs secThrdChannel;
|
|
3116 |
if((r=secThrdChannel.Open(EightBitName))!=KErrNone)
|
|
3117 |
return r;
|
|
3118 |
|
|
3119 |
// Read the resource information
|
|
3120 |
//
|
|
3121 |
TUint numResources=0;
|
|
3122 |
if((r=secThrdChannel.GetNoOfResources(numResources))!=KErrNone)
|
|
3123 |
return r;
|
|
3124 |
|
|
3125 |
// To support the GetAllResourcesInfo testing, instantiate TResourceInfoBuf objects
|
|
3126 |
// and reference via an RSimplePointerArray
|
|
3127 |
TUint bufSize = numResources;
|
|
3128 |
RSimplePointerArray<TResourceInfoBuf> resPtrs(bufSize);
|
|
3129 |
for(TUint i=0;i<bufSize;i++)
|
|
3130 |
{
|
|
3131 |
TResourceInfoBuf *info = new TResourceInfoBuf();
|
|
3132 |
if((r=resPtrs.Insert(info, i))!=KErrNone)
|
|
3133 |
return r;
|
|
3134 |
}
|
|
3135 |
|
|
3136 |
TUint updateNumResources=numResources;
|
|
3137 |
if((r=secThrdChannel.GetAllResourcesInfo(&resPtrs,updateNumResources))!=KErrNone)
|
|
3138 |
return r;
|
|
3139 |
resPtrs.Close();
|
|
3140 |
|
|
3141 |
|
|
3142 |
// Read current client information
|
|
3143 |
//
|
|
3144 |
TUint numClients=0;
|
|
3145 |
TUint numAllClients=0;
|
|
3146 |
//
|
|
3147 |
// GetNoOfClients - with default aIncludeKern=EFalse
|
|
3148 |
//
|
|
3149 |
if((r=secThrdChannel.GetNoOfClients(numClients,EFalse)) != KErrNone)
|
|
3150 |
return r;
|
|
3151 |
//
|
|
3152 |
// GetNoOfClients - with aIncludeKern=ETrue
|
|
3153 |
//
|
|
3154 |
r=secThrdChannel.GetNoOfClients(numAllClients, ETrue);
|
|
3155 |
#ifdef RESMANUS_KERN
|
|
3156 |
if(r!=KErrNone)
|
|
3157 |
#else
|
|
3158 |
if(r!=KErrPermissionDenied)
|
|
3159 |
#endif
|
|
3160 |
return KErrGeneral;
|
|
3161 |
//
|
|
3162 |
// Need a buffer big enough to contain numClients instances of TClientName
|
|
3163 |
// To support the GetNamesAllClients testing, instantiate TClientName objects
|
|
3164 |
// and reference via an RSimplePointerArray
|
|
3165 |
TUint resBufSize = (numAllClients>numClients)?numAllClients:numClients;
|
|
3166 |
RSimplePointerArray<TClientName> infoPtrs(resBufSize);
|
|
3167 |
for(TUint j=0;j<resBufSize;j++)
|
|
3168 |
{
|
|
3169 |
TClientName *info = new TClientName();
|
|
3170 |
if((r=infoPtrs.Insert(info, j))!=KErrNone)
|
|
3171 |
return r;
|
|
3172 |
}
|
|
3173 |
//
|
|
3174 |
// GetNamesAllClients - with aIncludeKern=EFalse
|
|
3175 |
//
|
|
3176 |
if((r=secThrdChannel.GetNamesAllClients(&infoPtrs, numClients, EFalse)) != KErrNone)
|
|
3177 |
return r;
|
|
3178 |
//
|
|
3179 |
// GetNamesAllClients - with aIncludeKern=ETrue
|
|
3180 |
//
|
|
3181 |
#ifdef RESMANUS_KERN
|
|
3182 |
if((r=secThrdChannel.GetNamesAllClients(&infoPtrs, numAllClients, ETrue)) != KErrNone)
|
|
3183 |
return r;
|
|
3184 |
#else
|
|
3185 |
if((r=secThrdChannel.GetNamesAllClients(&infoPtrs, numClients, ETrue)) != KErrPermissionDenied)
|
|
3186 |
{
|
|
3187 |
if(r==KErrNone)
|
|
3188 |
r=KErrGeneral;
|
244
|
3189 |
return r; // return error which is neither KErrPermissionDenied nor KErrGeneral
|
0
|
3190 |
}
|
|
3191 |
else
|
|
3192 |
r=KErrNone; // Ensure misleading result is not propagated
|
|
3193 |
#endif
|
|
3194 |
infoPtrs.Close();
|
|
3195 |
|
|
3196 |
// If we don't have a shared resource identified, skip the remaining tests
|
|
3197 |
if(gHaveSharedRes)
|
|
3198 |
{
|
|
3199 |
// Register with the Resource Controller
|
|
3200 |
//
|
|
3201 |
if ((r=secThrdChannel.Initialise(1,1,0))!=KErrNone) // Just need 1 get and 1 set state
|
|
3202 |
return r;
|
|
3203 |
// Set a level on the shared resource
|
|
3204 |
//
|
|
3205 |
// Get initial state
|
|
3206 |
TRequestStatus status;
|
|
3207 |
TBool cached = gUseCached;
|
|
3208 |
TInt readValue;
|
|
3209 |
TInt levelOwnerId;
|
|
3210 |
secThrdChannel.GetResourceState(status,gSharedResource,cached,&readValue,&levelOwnerId);
|
|
3211 |
User::WaitForRequest(status);
|
|
3212 |
r=status.Int();
|
|
3213 |
if(r != KErrNone)
|
|
3214 |
return r;
|
|
3215 |
// Write updated state
|
|
3216 |
TUint newLevel = (TUint)(readValue + gSharedResStateDelta);
|
|
3217 |
secThrdChannel.ChangeResourceState(status,gSharedResource,newLevel);
|
|
3218 |
User::WaitForRequest(status);
|
|
3219 |
r=status.Int();
|
|
3220 |
if(r != KErrNone)
|
|
3221 |
return r;
|
|
3222 |
|
|
3223 |
// Read current client information
|
|
3224 |
//
|
|
3225 |
numClients=0;
|
|
3226 |
numAllClients=0;
|
|
3227 |
//
|
|
3228 |
// GetNoOfClients - with default aIncludeKern=EFalse
|
|
3229 |
//
|
|
3230 |
if((r=secThrdChannel.GetNoOfClients(numClients,EFalse)) != KErrNone)
|
|
3231 |
return r;
|
|
3232 |
//
|
|
3233 |
// GetNoOfClients - with aIncludeKern=ETrue
|
|
3234 |
//
|
|
3235 |
#ifdef RESMANUS_KERN
|
|
3236 |
if((r=secThrdChannel.GetNoOfClients(numAllClients, ETrue))!=KErrNone)
|
|
3237 |
#else
|
|
3238 |
if((r=secThrdChannel.GetNoOfClients(numAllClients, ETrue))!=KErrPermissionDenied)
|
|
3239 |
#endif
|
|
3240 |
return KErrGeneral;
|
|
3241 |
//
|
|
3242 |
// Need a buffer big enough to contain numClients instances of TClientName
|
|
3243 |
// To support the GetNamesAllClients testing, instantiate TClientName objects
|
|
3244 |
// and reference via an RSimplePointerArray
|
|
3245 |
TUint bufSize = (numAllClients>numClients)?numAllClients:numClients;
|
|
3246 |
RSimplePointerArray<TClientName> infoPtrs(bufSize);
|
|
3247 |
for(TUint i=0;i<bufSize;i++)
|
|
3248 |
{
|
|
3249 |
TClientName *info = new TClientName();
|
|
3250 |
if((r=infoPtrs.Insert(info, i))!=KErrNone)
|
|
3251 |
return r;
|
|
3252 |
}
|
|
3253 |
//
|
|
3254 |
// GetNamesAllClients - with aIncludeKern=EFalse
|
|
3255 |
//
|
|
3256 |
if((r=secThrdChannel.GetNamesAllClients(&infoPtrs, numClients, EFalse)) != KErrNone)
|
|
3257 |
return r;
|
|
3258 |
//
|
|
3259 |
// GetNamesAllClients - with aIncludeKern=ETrue
|
|
3260 |
//
|
|
3261 |
#ifdef RESMANUS_KERN
|
|
3262 |
if((r=secThrdChannel.GetNamesAllClients(&infoPtrs, numAllClients, ETrue)) != KErrNone)
|
|
3263 |
return r;
|
|
3264 |
#else
|
|
3265 |
if((r=secThrdChannel.GetNamesAllClients(&infoPtrs, numClients, ETrue)) != KErrPermissionDenied)
|
|
3266 |
{
|
|
3267 |
if(r==KErrNone)
|
|
3268 |
r=KErrGeneral;
|
244
|
3269 |
return r; // return error which is neither KErrPermissionDenied nor KErrGeneral
|
0
|
3270 |
}
|
|
3271 |
else
|
|
3272 |
r=KErrNone; // Ensure misleading result is not propagated
|
|
3273 |
#endif
|
|
3274 |
infoPtrs.Close();
|
|
3275 |
|
|
3276 |
// Read the resource information
|
|
3277 |
//
|
|
3278 |
numResources=0;
|
|
3279 |
if((r=secThrdChannel.GetNoOfResources(numResources))!=KErrNone)
|
|
3280 |
return r;
|
|
3281 |
|
|
3282 |
//
|
|
3283 |
// Need a buffer big enough to contain numResources instances of TResourceInfoBuf
|
|
3284 |
// To support the GetAllResourcesInfo testing, instantiate TResourceInfoBuf objects
|
|
3285 |
// and reference via an RSimplePointerArray
|
|
3286 |
RSimplePointerArray<TResourceInfoBuf> resPtrs(numResources);
|
|
3287 |
for(TUint j=0;j<numResources;j++)
|
|
3288 |
{
|
|
3289 |
TResourceInfoBuf *info = new TResourceInfoBuf();
|
|
3290 |
if((r=resPtrs.Insert(info, j))!=KErrNone)
|
|
3291 |
return r;
|
|
3292 |
}
|
|
3293 |
|
|
3294 |
if((r=secThrdChannel.GetAllResourcesInfo(&resPtrs,numResources))!=KErrNone)
|
|
3295 |
return r;
|
|
3296 |
resPtrs.Close();
|
|
3297 |
}
|
|
3298 |
|
|
3299 |
// Close the channel
|
|
3300 |
secThrdChannel.Close();
|
|
3301 |
return r;
|
|
3302 |
}
|
|
3303 |
|
|
3304 |
TInt StartThread2()
|
|
3305 |
{
|
|
3306 |
TInt r=Thrd2.Create(KThrd2Name,Thread2Fn,KStackSize,KHeapSize,KHeapSize,NULL,EOwnerThread);
|
|
3307 |
if (r!=KErrNone)
|
|
3308 |
return r;
|
|
3309 |
Thrd2.Logon(Thrd2Status);
|
|
3310 |
Thrd2.Resume();
|
|
3311 |
return KErrNone;
|
|
3312 |
}
|
|
3313 |
|
|
3314 |
TInt WaitForThread2()
|
|
3315 |
{
|
|
3316 |
User::WaitForRequest(Thrd2Status);
|
|
3317 |
TInt exitType=Thrd2.ExitType();
|
|
3318 |
TInt exitReason=Thrd2.ExitReason();
|
|
3319 |
TBuf<16> exitCat=Thrd2.ExitCategory();
|
|
3320 |
if((exitType!= EExitKill)||(exitReason!=KErrNone))
|
|
3321 |
{
|
|
3322 |
gTest.Printf(_L("Thread2 error: %d\n"),Thrd2Status.Int());
|
|
3323 |
gTest.Printf(_L("Thread exit reason: %d,%d,%S\n"),exitType,exitReason,&exitCat);
|
|
3324 |
gTest(0);
|
|
3325 |
}
|
|
3326 |
Thrd2.Close();
|
|
3327 |
return KErrNone;
|
|
3328 |
}
|
|
3329 |
|
|
3330 |
|
|
3331 |
//----------------------------------------------------------------------------------------------
|
|
3332 |
//! @SYMTestCaseID KBASE-T_RESMANUS-0614
|
|
3333 |
//! @SYMTestType UT
|
|
3334 |
//! @SYMPREQ PREQ1398
|
|
3335 |
//! @SYMTestCaseDesc This test case tests that an additional thread can open a channel and
|
|
3336 |
//! exercise selected APIs.
|
|
3337 |
//!
|
|
3338 |
//! @SYMTestActions 0) Call API to open a channel.
|
|
3339 |
//!
|
|
3340 |
//! 1) Call GetNoOfResources API.
|
|
3341 |
//!
|
|
3342 |
//! 2) Call GetAllResourcesInfo API.
|
|
3343 |
//!
|
|
3344 |
//! 3) Call GetNoOfClients API with default aIncludeKern=EFalse.
|
|
3345 |
//!
|
|
3346 |
//! 4) Call GetNoOfClients API with aIncludeKern=ETrue
|
|
3347 |
//!
|
|
3348 |
//! 5) Call GetNamesAllClientsAPI with default aIncludeKern=EFalse.
|
|
3349 |
//!
|
|
3350 |
//! 6) Call GetNamesAllClientsAPI with aIncludeKern=ETrue
|
|
3351 |
//!
|
|
3352 |
//! 7) Call Initialise API.
|
|
3353 |
//!
|
|
3354 |
//! 8) Call GetResourceState API for selected resource.
|
|
3355 |
//!
|
|
3356 |
//! 9) Call GetResourceState API for selected resource.
|
|
3357 |
//!
|
|
3358 |
//! 10) Call GetNoOfClients API with default aIncludeKern=EFalse.
|
|
3359 |
//!
|
|
3360 |
//! 11) Call GetNoOfClients API with aIncludeKern=ETrue
|
|
3361 |
//!
|
|
3362 |
//! 12) Call GetNamesAllClientsAPI with default aIncludeKern=EFalse.
|
|
3363 |
//!
|
|
3364 |
//! 13) Call GetNamesAllClientsAPI with aIncludeKern=ETrue
|
|
3365 |
//!
|
|
3366 |
//! 14) Call GetNoOfResources API.
|
|
3367 |
//!
|
|
3368 |
//! 15) Call GetAllResourcesInfo API.
|
|
3369 |
//!
|
|
3370 |
//! @SYMTestExpectedResults 0) Test that the channel was opened - exit otherwise.
|
|
3371 |
//!
|
|
3372 |
//! 1) Test that the API call returned KErrNone - exit otherwise.
|
|
3373 |
//!
|
|
3374 |
//! 2) Test that the API call returned KErrNone - exit otherwise.
|
|
3375 |
//!
|
|
3376 |
//! 3) Test that the API call returned KErrNone - exit otherwise.
|
|
3377 |
//!
|
|
3378 |
//! 4) If client exhibits PlatSec capability ReadDeviceData, Test that the API call returned KErrNone - exit otherwise
|
|
3379 |
//! If client lacks PlatSec capability ReadDeviceData, Test that the API call returned KErrPermissionDenied - exit otherwise
|
|
3380 |
//!
|
|
3381 |
//! 5) Test that the API call returned KErrNone - exit otherwise.
|
|
3382 |
//!
|
|
3383 |
//! 6) If client exhibits PlatSec capability ReadDeviceData, Test that the API call returned KErrNone - exit otherwise
|
|
3384 |
//! If client lacks PlatSec capability ReadDeviceData, Test that the API call returned KErrPermissionDenied - exit otherwise
|
|
3385 |
//!
|
|
3386 |
//! 7) Test that the API call returned KErrNone - exit otherwise
|
|
3387 |
//!
|
|
3388 |
//! 8) Test that the associated TRequestStatus object exhibited state KErrNone - exit otherwise
|
|
3389 |
//!
|
|
3390 |
//! 9) Test that the associated TRequestStatus object exhibited state KErrNone - exit otherwise
|
|
3391 |
//!
|
|
3392 |
//! 10) Test that the API call returned KErrNone - exit otherwise.
|
|
3393 |
//!
|
|
3394 |
//! 11) If client exhibits PlatSec capability ReadDeviceData, Test that the API call returned KErrNone - exit otherwise
|
|
3395 |
//! If client lacks PlatSec capability ReadDeviceData, Test that the API call returned KErrPermissionDenied - exit otherwise
|
|
3396 |
//!
|
|
3397 |
//! 12) Test that the API call returned KErrNone - exit otherwise.
|
|
3398 |
//!
|
|
3399 |
//! 13) If client exhibits PlatSec capability ReadDeviceData, Test that the API call returned KErrNone - exit otherwise
|
|
3400 |
//! If client lacks PlatSec capability ReadDeviceData, Test that the API call returned KErrPermissionDenied - exit otherwise
|
|
3401 |
//!
|
|
3402 |
//! 14) Test that the API call returned KErrNone - exit otherwise.
|
|
3403 |
//!
|
|
3404 |
//! 15) Test that the API call returned KErrNone - exit otherwise.
|
|
3405 |
//!
|
|
3406 |
//! @SYMTestPriority High
|
|
3407 |
//! @SYMTestStatus Implemented
|
|
3408 |
//----------------------------------------------------------------------------------------------
|
|
3409 |
LOCAL_C TInt TestAdditionalThread()
|
|
3410 |
//
|
|
3411 |
// Test that more than one thread can be supported
|
|
3412 |
//
|
|
3413 |
{
|
|
3414 |
TInt r;
|
|
3415 |
if((r=StartThread2())!=KErrNone)
|
|
3416 |
{
|
|
3417 |
gTest.Printf(_L("TestAdditionalThread: StartThread2 returned %d\n"),r);
|
|
3418 |
return KErrGeneral;
|
|
3419 |
}
|
|
3420 |
if((r=WaitForThread2())!=KErrNone)
|
|
3421 |
{
|
|
3422 |
gTest.Printf(_L("TestAdditionalThread: WaitForThread2 returned %d\n"),r);
|
|
3423 |
return KErrGeneral;
|
|
3424 |
}
|
|
3425 |
|
|
3426 |
return r;
|
|
3427 |
}
|
|
3428 |
|
|
3429 |
|
|
3430 |
LOCAL_C TInt LocateResourceWithDependencies(TUint &aNumResources, TUint &aResId, TUint &aNumDependents)
|
|
3431 |
//
|
|
3432 |
// Support function for tests of dependencies
|
|
3433 |
//
|
|
3434 |
{
|
|
3435 |
__KHEAP_MARK;
|
|
3436 |
|
|
3437 |
TInt r = KErrNone;
|
|
3438 |
if((r=gChannel.GetNoOfResources(aNumResources))!=KErrNone)
|
|
3439 |
{
|
|
3440 |
gTest.Printf(_L("GetNoOfResources for test channel returned %d\n"),r);
|
|
3441 |
return r;
|
|
3442 |
}
|
|
3443 |
TUint bufSize = aNumResources;
|
|
3444 |
RSimplePointerArray<TResourceInfoBuf> infoPtrs(bufSize);
|
|
3445 |
for(TUint i=0;i<bufSize;i++)
|
|
3446 |
{
|
|
3447 |
TResourceInfoBuf *info = new TResourceInfoBuf();
|
|
3448 |
if((r=infoPtrs.Insert(info, i))!=KErrNone)
|
|
3449 |
{
|
|
3450 |
gTest.Printf(_L("GetAllResourcesInfo infoPtrs.Insert at index %d returned %d\n"),i,r);
|
|
3451 |
}
|
|
3452 |
}
|
|
3453 |
TUint updateNumResources=aNumResources;
|
|
3454 |
if((r=gChannel.GetAllResourcesInfo(&infoPtrs,updateNumResources))!=KErrNone)
|
|
3455 |
{
|
|
3456 |
gTest.Printf(_L("GetAllResourcesInfo for channel returned %d\n"),r);
|
|
3457 |
return r;
|
|
3458 |
}
|
|
3459 |
for(TUint resNo=0;resNo<aNumResources;resNo++)
|
|
3460 |
{
|
|
3461 |
TResourceInfoBuf *info = infoPtrs[resNo];
|
|
3462 |
TUint resId = ((*info)()).iId;
|
|
3463 |
TUint numDependents = 0;
|
|
3464 |
r=gChannel.GetNumDependentsForResource(resId,&numDependents, EFalse); // EFalse - don't load the dependency info
|
|
3465 |
if((r!=KErrNone)&&(r!=KErrNotFound)&&(r!=KErrNotSupported))
|
|
3466 |
{
|
|
3467 |
gTest.Printf(_L("TestTransientHandling: GetNumDependentsForResource returned %d\n"),r);
|
|
3468 |
return r;
|
|
3469 |
}
|
|
3470 |
if(numDependents>0)
|
|
3471 |
{
|
|
3472 |
aResId = resId;
|
|
3473 |
aNumDependents = numDependents;
|
|
3474 |
break;
|
|
3475 |
}
|
|
3476 |
}
|
|
3477 |
|
|
3478 |
infoPtrs.Close();
|
|
3479 |
|
|
3480 |
__KHEAP_MARKEND;
|
|
3481 |
|
|
3482 |
return r;
|
|
3483 |
}
|
|
3484 |
|
|
3485 |
|
|
3486 |
|
|
3487 |
//----------------------------------------------------------------------------------------------
|
|
3488 |
//! @SYMTestCaseID KBASE-T_RESMANUS-0615
|
|
3489 |
//! @SYMTestType UT
|
|
3490 |
//! @SYMPREQ PREQ1398
|
|
3491 |
//! @SYMTestCaseDesc This test case tests the different options available for handling transient data.
|
|
3492 |
//! @SYMTestActions 0) Locate a resource that has at least one dependency.
|
|
3493 |
//!
|
|
3494 |
//! 1) Read the number of dependencies without reading the dependency information.
|
|
3495 |
//! Call to read the dependency information (without re-loading).
|
|
3496 |
//!
|
|
3497 |
//! 2) Read the number of dependencies (with default option of reading the dependency information).
|
|
3498 |
//! Then read the dependency information (without re-loading).
|
|
3499 |
//!
|
|
3500 |
//! 3) Repeat the read the number of dependencies without reading the dependency information
|
|
3501 |
//! Then read the dependency information (without re-loading).
|
|
3502 |
//! Then read the dependency information (with re-loading).
|
|
3503 |
//!
|
|
3504 |
//! 4) Attempt to read the dependency information (without re-loading) with a buffer of insufficient size
|
|
3505 |
//!
|
|
3506 |
//! 5) Read the number of (all) resources without reading the resource information.
|
|
3507 |
//! Call to read (all) the resource information (without re-loading).
|
|
3508 |
//!
|
|
3509 |
//! 6) Read the number of (all) resources (with default option of reading the resource information).
|
|
3510 |
//! Then read (all) the resource information (without re-loading).
|
|
3511 |
//!
|
|
3512 |
//! 7) Repeat the read the number of (all) resources without reading the resources information
|
|
3513 |
//! Then read (all) the resources information (without re-loading).
|
|
3514 |
//! Then read (all) the resources information (with re-loading).
|
|
3515 |
//!
|
|
3516 |
//! 8) Attempt to read (all) the resource information (without re-loading) with a buffer of insufficient size
|
|
3517 |
//!
|
|
3518 |
//! 9) Read the number of user-side clients using a resource without reading the resource information.
|
|
3519 |
//! Call to read the information for user-side clients using a resource (without re-loading).
|
|
3520 |
//!
|
|
3521 |
//! 10) Read the number of user-side clients (with loading of the client information)
|
|
3522 |
//! Call to read the client information (without re-loading) should return be successful
|
|
3523 |
//! Call to read the information for a resourceID with zero clients (without re-loading)
|
|
3524 |
//! Call to read the information for the first resourceID
|
|
3525 |
//!
|
|
3526 |
//! 11) Repeat the read of the number of user-side clients (without re-loading)
|
|
3527 |
//! Call to read the client information (without re-loading)
|
|
3528 |
//! Call to read the client information (with re-loading)
|
|
3529 |
//!
|
|
3530 |
//! 12) Open a second channel on the User-Side API, and call initialise support for resource state access
|
|
3531 |
//! Get the current state of a specific resource, then change the state
|
|
3532 |
//! Call to read the number of user-side clients for the resource (with loading of the client information)
|
|
3533 |
//! but with a buffer of insufficient size.
|
|
3534 |
//!
|
|
3535 |
//! 13) Read the number of resources in use by a specified client (without loading)
|
|
3536 |
//! Call to read the information on the resources in use by the client (without loading)
|
|
3537 |
//!
|
|
3538 |
//! 14) Open a third channel on the User-Side API, do not call initialise.
|
|
3539 |
//! Read the number of resources in use by a specified client (with loading)
|
|
3540 |
//! Call to read the information for resources in use by the third channel (without re-loading)
|
|
3541 |
//! Call to read the information for resources in use by the second channel (without re-loading)
|
|
3542 |
//!
|
|
3543 |
//! 15) Read the number of resources in use by a specified client (without loading)
|
|
3544 |
//! Call to read the information on the resources in use by the client (without loading)
|
|
3545 |
//! Call to read the information on the resources in use by the client (with loading)
|
|
3546 |
//!
|
|
3547 |
//! 16) Read the number of resources in use by a specified client (with loading)
|
|
3548 |
//! Call to read the information on the resources in use by the client (without loading)
|
|
3549 |
//! with a buffer of insufficient size.
|
|
3550 |
//!
|
|
3551 |
//! @SYMTestExpectedResults 0) If a suitable resource is found, the number of dependencies is reported - exit otherwise.
|
|
3552 |
//!
|
|
3553 |
//! 1) Test that the read of the number of dependencies returns KErrNone - exit otherwise.
|
|
3554 |
//! Test that the read of the dependency information returned KErrNotReady - exit otherwise.
|
|
3555 |
//!
|
|
3556 |
//! 2) Test that the read of the number of dependencies returns KErrNone - exit otherwise.
|
|
3557 |
//! Test that the read of the dependency information returned KErrNone - exit otherwise.
|
|
3558 |
//!
|
|
3559 |
//! 3) Test that the read of the number of dependencies returns KErrNone - exit otherwise.
|
|
3560 |
//! Test that the read of the dependency information (without re-loading) returned KErrNotReady - exit otherwise.
|
|
3561 |
//! Test that the read of the dependency information (with re-loading) returned KErrNone - exit otherwise.
|
|
3562 |
//!
|
|
3563 |
//! 4) Test that the read of the dependency information returns KErrArgument - exit otherwise
|
|
3564 |
//!
|
|
3565 |
//! 5) Test that the read of the number of resources returns KErrNone - exit otherwise.
|
|
3566 |
//! Test that the read of the resource information returned KErrNotReady - exit otherwise.
|
|
3567 |
//!
|
|
3568 |
//! 6) Test that the read of the number of resources returns KErrNone - exit otherwise.
|
|
3569 |
//! Test that the read of the resource information returned KErrNone - exit otherwise.
|
|
3570 |
//!
|
|
3571 |
//! 7) Test that the read of the number of resources returns KErrNone - exit otherwise.
|
|
3572 |
//! Test that the read of the resource information (without re-loading) returned KErrNotReady - exit otherwise.
|
|
3573 |
//! Test that the read of the resources information (with re-loading) returned KErrNone - exit otherwise.
|
|
3574 |
//!
|
|
3575 |
//! 8) Test that the read of the resource information returns KErrArgument - exit otherwise
|
|
3576 |
//!
|
|
3577 |
//! 9) Test that the read of the number of clients returns KErrNone - exit otherwise.
|
|
3578 |
//! Test that the read of the client information returned KErrNotReady - exit otherwise.
|
|
3579 |
//!
|
|
3580 |
//! 10) Test that the read of the number of clients returns KErrNone - exit otherwise.
|
|
3581 |
//! Test that the read of the client information returned KErrNone - exit otherwise.
|
|
3582 |
//! Test that the read of the client information returned KErrNone and numClients==0 - exit otherwise.
|
|
3583 |
//! Test that the read of the client information returned KErrNotReady - exit otherwise.
|
|
3584 |
//!
|
|
3585 |
//! 11) Test that the read of the number of clients returns KErrNone - exit otherwise.
|
|
3586 |
//! Test that the read of the client information returned KErrNotReady - exit otherwise.
|
|
3587 |
//! Test that the read of the client information returned KErrNone - exit otherwise.
|
|
3588 |
//!
|
|
3589 |
//! 12) Test that the opening and initialisation of the channel was successful - exit otherwise.
|
|
3590 |
//! Test that the get and change of the resource state completed successfully - exit otherwise
|
|
3591 |
//! Test that the read of the client information returned KErrArgument - exit otherwise.
|
|
3592 |
//!
|
|
3593 |
//! 13) Test that the read of the number of resources returns KErrNone - exit otherwise.
|
|
3594 |
//! Test that the read of the resource information returned KErrNotReady - exit otherwise.
|
|
3595 |
//!
|
|
3596 |
//! 14) Test that the opening of the channel was successful - exit otherwise.
|
|
3597 |
//! Test that the read of the resource information returned KErrNone - exit otherwise.
|
|
3598 |
//! Test that the read of the client information returned KErrNone, and numResources = 0 - exit otherwise.
|
|
3599 |
//! Test that the read of the client information returned KErrNotReady - exit otherwise.
|
|
3600 |
//!
|
|
3601 |
//! 15) Test that the read of the number of resources returns KErrNone - exit otherwise.
|
|
3602 |
//! Test that the read of the resource information returned KErrNotReady - exit otherwise.
|
|
3603 |
//! Test that the read of the resource information returned KErrNone - exit otherwise.
|
|
3604 |
//!
|
|
3605 |
//! 16) Test that the read of the number of resources returns KErrNone - exit otherwise.
|
|
3606 |
//! Test that the read of the resource information returned KErrArgument - exit otherwise..
|
|
3607 |
//!
|
|
3608 |
//! @SYMTestPriority High
|
|
3609 |
//! @SYMTestStatus Implemented
|
|
3610 |
//----------------------------------------------------------------------------------------------
|
|
3611 |
LOCAL_C TInt TestTransientHandling()
|
|
3612 |
//
|
|
3613 |
// Test APIs with options for handling transient data (dependencies, resources and clients)
|
|
3614 |
//
|
|
3615 |
{
|
|
3616 |
TInt r = KErrNone;
|
|
3617 |
TUint testNo = 1;
|
|
3618 |
|
|
3619 |
TUint numDependents = 0;
|
|
3620 |
TUint resNo = 0;
|
|
3621 |
|
|
3622 |
//
|
|
3623 |
// Dependency data tests
|
|
3624 |
//
|
|
3625 |
|
|
3626 |
gTest.Printf(_L("TestTransientHandling: dependency data tests ...\n"));
|
|
3627 |
|
|
3628 |
// 0) Find a resource that has dependents - if none is located skip the remaining dependancy tests
|
|
3629 |
// (this reads the number of dependencies, without loading the dependency data)
|
|
3630 |
//
|
|
3631 |
TUint numResources=0;
|
|
3632 |
if((r=LocateResourceWithDependencies(numResources, resNo, numDependents))!=KErrNone)
|
|
3633 |
{
|
|
3634 |
gTest.Printf(_L("TestTransientHandling: no resource with dependencies found ... skipping tests\n"));
|
|
3635 |
return KErrNone;
|
|
3636 |
}
|
|
3637 |
if(numDependents==0)
|
|
3638 |
{
|
|
3639 |
gTest.Printf(_L("TestTransientHandling: no resource with dependencies found ... skipping tests\n"));
|
|
3640 |
}
|
|
3641 |
else
|
|
3642 |
{
|
|
3643 |
// 1) Read the number of dependencies without reading the dependency information
|
|
3644 |
// Subsequent call to read the dependency information (without re-loading) should return error KErrNotReady
|
|
3645 |
gTest.Printf(_L("TestTransientHandling: test %d\n"),testNo++);
|
|
3646 |
if((r=gChannel.GetNumDependentsForResource(resNo,&numDependents, EFalse))!=KErrNone)
|
|
3647 |
{
|
|
3648 |
gTest.Printf(_L("TestTransientHandling: GetNumDependentsForResource returned %d\n"),r);
|
|
3649 |
return r;
|
|
3650 |
}
|
|
3651 |
gTest.Printf(_L("TestTransientHandling: GetNumDependentsForResource reported %d dependents for resource %d\n"),numDependents,resNo);
|
|
3652 |
if(numDependents > 0)
|
|
3653 |
{
|
|
3654 |
RBuf8 buffer;
|
|
3655 |
if((buffer.Create(numDependents*sizeof(SResourceDependencyInfo)))!=KErrNone)
|
|
3656 |
return KErrGeneral;
|
|
3657 |
buffer.SetLength(0);
|
|
3658 |
if((r=gChannel.GetDependentsIdForResource(resNo, buffer, &numDependents))!=KErrNotReady)
|
|
3659 |
{
|
|
3660 |
gTest.Printf(_L("TestTransientHandling: GetDependentsIdForResource returned %d\n"),r);
|
|
3661 |
return KErrGeneral;
|
|
3662 |
}
|
|
3663 |
buffer.Close();
|
|
3664 |
}
|
|
3665 |
|
|
3666 |
// 2) Read the number of dependencies (and, by default, read the dependency information)
|
|
3667 |
// Subsequent call to read the dependency information (without re-loading) should return be successful
|
|
3668 |
gTest.Printf(_L("TestTransientHandling: test %d\n"),testNo++);
|
|
3669 |
if((r=gChannel.GetNumDependentsForResource(resNo,&numDependents))!=KErrNone)
|
|
3670 |
{
|
|
3671 |
gTest.Printf(_L("TestTransientHandling: GetNumDependentsForResource returned %d\n"),r);
|
|
3672 |
return r;
|
|
3673 |
}
|
|
3674 |
gTest.Printf(_L("TestTransientHandling: GetNumDependentsForResource reported %d dependents for resource %d\n"),numDependents,resNo);
|
|
3675 |
if(numDependents > 0)
|
|
3676 |
{
|
|
3677 |
RBuf8 buffer;
|
|
3678 |
if((buffer.Create(numDependents*sizeof(SResourceDependencyInfo)))!=KErrNone)
|
|
3679 |
return KErrGeneral;
|
|
3680 |
buffer.SetLength(0);
|
|
3681 |
if((r=gChannel.GetDependentsIdForResource(resNo, buffer, &numDependents))!=KErrNone)
|
|
3682 |
{
|
|
3683 |
gTest.Printf(_L("TestTransientHandling: GetDependentsIdForResource returned %d\n"),r);
|
|
3684 |
return r;
|
|
3685 |
}
|
|
3686 |
SResourceDependencyInfo* tempPtr = (SResourceDependencyInfo*)(buffer.Ptr());
|
|
3687 |
gTest.Printf(_L("TestTransientHandling: numDependents = %d\n"),numDependents);
|
|
3688 |
for(TUint i=0; i<numDependents; i++,tempPtr++)
|
|
3689 |
{
|
|
3690 |
gTest.Printf(_L("TestTransientHandling: info.iResourceId = %d\n"),tempPtr->iResourceId);
|
|
3691 |
gTest.Printf(_L("TestTransientHandling: info.iDependencyPriority= %d\n"),tempPtr->iDependencyPriority);
|
|
3692 |
}
|
|
3693 |
buffer.Close();
|
|
3694 |
}
|
|
3695 |
|
|
3696 |
// 3) Repeat the read the number of dependencies without reading the dependency information
|
|
3697 |
// Subsequent call to read the dependency information (without re-loading) should return error KErrNotReady
|
|
3698 |
// Then call to read the dependency information (with re-loading) should be successful
|
|
3699 |
gTest.Printf(_L("TestTransientHandling: test %d\n"),testNo++);
|
|
3700 |
if((r=gChannel.GetNumDependentsForResource(resNo,&numDependents, EFalse))!=KErrNone)
|
|
3701 |
{
|
|
3702 |
gTest.Printf(_L("TestTransientHandling: GetNumDependentsForResource returned %d\n"),r);
|
|
3703 |
return r;
|
|
3704 |
}
|
|
3705 |
gTest.Printf(_L("TestTransientHandling: GetNumDependentsForResource reported %d dependents for resource %d\n"),numDependents,resNo);
|
|
3706 |
if(numDependents > 0)
|
|
3707 |
{
|
|
3708 |
RBuf8 buffer;
|
|
3709 |
if((buffer.Create(numDependents*sizeof(SResourceDependencyInfo)))!=KErrNone)
|
|
3710 |
return KErrGeneral;
|
|
3711 |
buffer.SetLength(0);
|
|
3712 |
|
|
3713 |
if((r=gChannel.GetDependentsIdForResource(resNo, buffer, &numDependents))!=KErrNotReady)
|
|
3714 |
{
|
|
3715 |
gTest.Printf(_L("TestTransientHandling: GetDependentsIdForResource returned %d\n"),r);
|
|
3716 |
return KErrGeneral;
|
|
3717 |
}
|
|
3718 |
if((r=gChannel.GetDependentsIdForResource(resNo, buffer, &numDependents, ETrue))!=KErrNone)
|
|
3719 |
{
|
|
3720 |
gTest.Printf(_L("TestTransientHandling: GetDependentsIdForResource returned %d\n"),r);
|
|
3721 |
return KErrGeneral;
|
|
3722 |
}
|
|
3723 |
SResourceDependencyInfo* tempPtr = (SResourceDependencyInfo*)(buffer.Ptr());
|
|
3724 |
for(TUint i=0; i<numDependents; i++,tempPtr++)
|
|
3725 |
{
|
|
3726 |
gTest.Printf(_L("TestTransientHandling: info.iResourceId = %d"),tempPtr->iResourceId);
|
|
3727 |
gTest.Printf(_L("TestTransientHandling: info.iDependencyPriority= %d"),tempPtr->iDependencyPriority);
|
|
3728 |
}
|
|
3729 |
buffer.Close();
|
|
3730 |
}
|
|
3731 |
|
|
3732 |
// 4) Attempt to read the dependency information (without re-loading) with a buffer of insufficient size should
|
|
3733 |
// return error KErrArgument
|
|
3734 |
gTest.Printf(_L("TestTransientHandling: test %d\n"),testNo++);
|
|
3735 |
if(numDependents > 0)
|
|
3736 |
{
|
|
3737 |
RBuf8 buffer;
|
|
3738 |
if((buffer.Create((numDependents-1)*sizeof(SResourceDependencyInfo)))!=KErrNone)
|
|
3739 |
return KErrGeneral;
|
|
3740 |
buffer.SetLength(0);
|
|
3741 |
if((r=gChannel.GetDependentsIdForResource(resNo, buffer, &numDependents))!=KErrArgument)
|
|
3742 |
{
|
|
3743 |
gTest.Printf(_L("TestTransientHandling: GetDependentsIdForResource returned %d\n"),r);
|
|
3744 |
return KErrGeneral;
|
|
3745 |
}
|
|
3746 |
// Ensure misleading result is not returned
|
|
3747 |
r=KErrNone;
|
|
3748 |
buffer.Close();
|
|
3749 |
}
|
|
3750 |
}
|
|
3751 |
|
|
3752 |
|
|
3753 |
//
|
|
3754 |
// All resource data tests
|
|
3755 |
//
|
|
3756 |
|
|
3757 |
gTest.Printf(_L("TestTransientHandling: All resource data tests ...\n"));
|
|
3758 |
testNo=1;
|
|
3759 |
|
|
3760 |
// 5) Attempt to read the resource information without having previously loaded it.
|
|
3761 |
gTest.Printf(_L("TestTransientHandling: test %d\n"),testNo++);
|
|
3762 |
{
|
|
3763 |
TUint numResources = 0;
|
|
3764 |
r = gChannel.GetNoOfResources(numResources, EFalse); // EFalse - don't load the resource info
|
|
3765 |
if(r!=KErrNone)
|
|
3766 |
{
|
|
3767 |
gTest.Printf(_L("GetNoOfResources returned %d\n"),r);
|
|
3768 |
return r;
|
|
3769 |
}
|
|
3770 |
// To support the GetAllResourcesInfo testing, instantiate TResourceInfoBuf objects
|
|
3771 |
// and reference via an RSimplePointerArray
|
|
3772 |
RSimplePointerArray<TResourceInfoBuf> infoPtrs(numResources);
|
|
3773 |
for(TUint i=0;i<numResources;i++)
|
|
3774 |
{
|
|
3775 |
TResourceInfoBuf *info = new TResourceInfoBuf();
|
|
3776 |
if((r=infoPtrs.Insert(info, i))!=KErrNone)
|
|
3777 |
{
|
|
3778 |
gTest.Printf(_L("TestTransientHandling test, GetAllResourcesInfo infoPtrs.Insert at index %d returned %d\n"),testNo,i,r);
|
|
3779 |
}
|
|
3780 |
}
|
|
3781 |
if((r=gChannel.GetAllResourcesInfo(&infoPtrs, numResources))!=KErrNotReady)
|
|
3782 |
{
|
|
3783 |
gTest.Printf(_L("TestTransientHandling: GetAllResourcesInfo returned %d\n"),r);
|
|
3784 |
return KErrGeneral;
|
|
3785 |
}
|
|
3786 |
else
|
|
3787 |
r=KErrNone; // Ensure misleading result is not propagated
|
|
3788 |
infoPtrs.Close();
|
|
3789 |
}
|
|
3790 |
|
|
3791 |
// 6) Read the number of resources (and, by default, read the resource information)
|
|
3792 |
// Subsequent call to read the resource information (without re-loading) should return be successful
|
|
3793 |
gTest.Printf(_L("TestTransientHandling: test %d\n"),testNo++);
|
|
3794 |
{
|
|
3795 |
TUint numResources = 0;
|
|
3796 |
if((r=gChannel.GetNoOfResources(numResources))!=KErrNone)
|
|
3797 |
{
|
|
3798 |
gTest.Printf(_L("GetNoOfResources returned %d\n"),r);
|
|
3799 |
return r;
|
|
3800 |
}
|
|
3801 |
// To support the GetAllResourcesInfo testing, instantiate TResourceInfoBuf objects
|
|
3802 |
// and reference via an RSimplePointerArray
|
|
3803 |
RSimplePointerArray<TResourceInfoBuf> infoPtrs(numResources);
|
|
3804 |
for(TUint i=0;i<numResources;i++)
|
|
3805 |
{
|
|
3806 |
TResourceInfoBuf *info = new TResourceInfoBuf();
|
|
3807 |
if((r=infoPtrs.Insert(info, i))!=KErrNone)
|
|
3808 |
{
|
|
3809 |
gTest.Printf(_L("TestTransientHandling test, GetAllResourcesInfo infoPtrs.Insert at index %d returned %d\n"),testNo,i,r);
|
|
3810 |
}
|
|
3811 |
}
|
|
3812 |
if((r=gChannel.GetAllResourcesInfo(&infoPtrs, numResources))!=KErrNone)
|
|
3813 |
{
|
|
3814 |
gTest.Printf(_L("TestTransientHandling: GetAllResourcesInfo returned %d\n"),r);
|
|
3815 |
return r;
|
|
3816 |
}
|
|
3817 |
infoPtrs.Close();
|
|
3818 |
}
|
|
3819 |
|
|
3820 |
// 7) Repeat the read the number of resources without reading the resource information
|
|
3821 |
// Subsequent call to read the resource information (without re-loading) should return error KErrNotReady
|
|
3822 |
// Then call to read the resource information (with re-loading) should be successful
|
|
3823 |
gTest.Printf(_L("TestTransientHandling: test %d\n"),testNo++);
|
|
3824 |
{
|
|
3825 |
TUint numResources = 0;
|
|
3826 |
if((r=gChannel.GetNoOfResources(numResources, EFalse))!=KErrNone) // EFalse - don't load the resource info
|
|
3827 |
{
|
|
3828 |
gTest.Printf(_L("GetNoOfResources returned %d\n"),r);
|
|
3829 |
return r;
|
|
3830 |
}
|
|
3831 |
// To support the GetAllResourcesInfo testing, instantiate TResourceInfoBuf objects
|
|
3832 |
// and reference via an RSimplePointerArray
|
|
3833 |
RSimplePointerArray<TResourceInfoBuf> infoPtrs(numResources);
|
|
3834 |
for(TUint i=0;i<numResources;i++)
|
|
3835 |
{
|
|
3836 |
TResourceInfoBuf *info = new TResourceInfoBuf();
|
|
3837 |
if((r=infoPtrs.Insert(info, i))!=KErrNone)
|
|
3838 |
{
|
|
3839 |
gTest.Printf(_L("TestTransientHandling test, GetAllResourcesInfo infoPtrs.Insert at index %d returned %d\n"),testNo,i,r);
|
|
3840 |
}
|
|
3841 |
}
|
|
3842 |
if((r=gChannel.GetAllResourcesInfo(&infoPtrs, numResources))!=KErrNotReady)
|
|
3843 |
{
|
|
3844 |
gTest.Printf(_L("TestTransientHandling: GetAllResourcesInfo returned %d\n"),r);
|
|
3845 |
return KErrGeneral;
|
|
3846 |
}
|
|
3847 |
if((r=gChannel.GetAllResourcesInfo(&infoPtrs, numResources,ETrue))!=KErrNone)
|
|
3848 |
{
|
|
3849 |
gTest.Printf(_L("TestTransientHandling: GetAllResourcesInfo returned %d\n"),r);
|
|
3850 |
return r;
|
|
3851 |
}
|
|
3852 |
else
|
|
3853 |
infoPtrs.Close();
|
|
3854 |
}
|
|
3855 |
|
|
3856 |
|
|
3857 |
// 8) Attempt to read the resource information (without re-loading) with a buffer of insufficient size should
|
|
3858 |
// return error KErrArgument
|
|
3859 |
gTest.Printf(_L("TestTransientHandling: test %d\n"),testNo++);
|
|
3860 |
{
|
|
3861 |
TUint numResources = 0;
|
|
3862 |
if((r=gChannel.GetNoOfResources(numResources, EFalse))!=KErrNone) // EFalse - don't load the resource info
|
|
3863 |
{
|
|
3864 |
gTest.Printf(_L("GetNoOfResources returned %d\n"),r);
|
|
3865 |
return r;
|
|
3866 |
}
|
|
3867 |
// To support the GetAllResourcesInfo testing, instantiate TResourceInfoBuf objects
|
|
3868 |
// and reference via an RSimplePointerArray
|
|
3869 |
RSimplePointerArray<TResourceInfoBuf> infoPtrs(numResources - 1);
|
|
3870 |
for(TUint i=0;i<(numResources-1);i++)
|
|
3871 |
{
|
|
3872 |
TResourceInfoBuf *info = new TResourceInfoBuf();
|
|
3873 |
if((r=infoPtrs.Insert(info, i))!=KErrNone)
|
|
3874 |
{
|
|
3875 |
gTest.Printf(_L("TestTransientHandling test, GetAllResourcesInfo infoPtrs.Insert at index %d returned %d\n"),testNo,i,r);
|
|
3876 |
}
|
|
3877 |
}
|
|
3878 |
if((r=gChannel.GetAllResourcesInfo(&infoPtrs, numResources))!=KErrArgument)
|
|
3879 |
{
|
|
3880 |
gTest.Printf(_L("TestTransientHandling: GetAllResourcesInfo returned %d\n"),r);
|
|
3881 |
return KErrGeneral;
|
|
3882 |
}
|
|
3883 |
// Ensure misleading result is not returned
|
|
3884 |
r=KErrNone;
|
|
3885 |
infoPtrs.Close();
|
|
3886 |
}
|
|
3887 |
|
|
3888 |
//
|
|
3889 |
// Specific resource data tests
|
|
3890 |
//
|
|
3891 |
|
|
3892 |
gTest.Printf(_L("TestTransientHandling: Resource-specific data tests ...\n"));
|
|
3893 |
testNo=1;
|
|
3894 |
|
|
3895 |
// 9) Attempt to read the resource information without having previously loaded it.
|
|
3896 |
gTest.Printf(_L("TestTransientHandling: test %d\n"),testNo++);
|
|
3897 |
{
|
|
3898 |
TUint numClients = 0;
|
|
3899 |
if((r=gChannel.GetNumClientsUsingResource(gLongLatencyResource, numClients, EFalse, EFalse))!=KErrNone) // user-side clients, don't load the info
|
|
3900 |
{
|
|
3901 |
gTest.Printf(_L("GetNumClientsUsingResource returned %d\n"),r);
|
|
3902 |
return r;
|
|
3903 |
}
|
|
3904 |
// To support the GetInfoOnClientsUsingResource testing, instantiate TClientInfoBuf objects
|
|
3905 |
// and reference via an RSimplePointerArray
|
|
3906 |
RSimplePointerArray<TClientInfoBuf> infoPtrs(numClients);
|
|
3907 |
for(TUint i=0;i<numClients;i++)
|
|
3908 |
{
|
|
3909 |
TClientInfoBuf *info = new TClientInfoBuf();
|
|
3910 |
if((r=infoPtrs.Insert(info, i))!=KErrNone)
|
|
3911 |
{
|
|
3912 |
gTest.Printf(_L("TestTransientHandling test, GetInfoOnClientsUsingResource infoPtrs.Insert at index %d returned %d\n"),testNo,i,r);
|
|
3913 |
}
|
|
3914 |
}
|
|
3915 |
if((r=gChannel.GetInfoOnClientsUsingResource(gLongLatencyResource, numClients, &infoPtrs, EFalse))!=KErrNotReady)
|
|
3916 |
{
|
|
3917 |
gTest.Printf(_L("TestTransientHandling: GetInfoOnClientsUsingResource returned %d\n"),r);
|
|
3918 |
return KErrGeneral;
|
|
3919 |
}
|
|
3920 |
else
|
|
3921 |
r=KErrNone; // Ensure misleading result is not propagated
|
|
3922 |
infoPtrs.Close();
|
|
3923 |
}
|
|
3924 |
|
|
3925 |
// 10) Read the number of clients (and, by default, read the client information)
|
|
3926 |
// Subsequent call to read the client information (without re-loading) should return be successful
|
|
3927 |
// Call to read the information for a resourceID with zero clients (without re-loading) should return KErrNone, numClients==0
|
|
3928 |
// Call to read the information for a resourceID with one or more clients (without re-loading) should return KErrNotReady
|
|
3929 |
gTest.Printf(_L("TestTransientHandling: test %d\n"),testNo++);
|
|
3930 |
{
|
|
3931 |
TUint numClients = 0;
|
|
3932 |
if((r=gChannel.GetNumClientsUsingResource(gLongLatencyResource, numClients, EFalse))!=KErrNone) // user-side clients, load the info
|
|
3933 |
{
|
|
3934 |
gTest.Printf(_L("GetNumClientsUsingResource returned %d\n"),r);
|
|
3935 |
return r;
|
|
3936 |
}
|
|
3937 |
// To support the GetInfoOnClientsUsingResource testing, instantiate TClientInfoBuf objects
|
|
3938 |
// and reference via an RSimplePointerArray
|
|
3939 |
RSimplePointerArray<TClientInfoBuf> infoPtrs(numClients);
|
|
3940 |
for(TUint i=0;i<numClients;i++)
|
|
3941 |
{
|
|
3942 |
TClientInfoBuf *info = new TClientInfoBuf();
|
|
3943 |
if((r=infoPtrs.Insert(info, i))!=KErrNone)
|
|
3944 |
{
|
|
3945 |
gTest.Printf(_L("TestTransientHandling test, GetInfoOnClientsUsingResource infoPtrs.Insert at index %d returned %d\n"),testNo,i,r);
|
|
3946 |
}
|
|
3947 |
}
|
|
3948 |
if((r=gChannel.GetInfoOnClientsUsingResource(gLongLatencyResource, numClients, &infoPtrs, EFalse))!=KErrNone)
|
|
3949 |
{
|
|
3950 |
gTest.Printf(_L("TestTransientHandling: GetInfoOnClientsUsingResource for gLongLatencyResource returned %d\n"),r);
|
|
3951 |
return r;
|
|
3952 |
}
|
|
3953 |
if(((r=gChannel.GetInfoOnClientsUsingResource((gLongLatencyResource+1), numClients, &infoPtrs, EFalse))!=KErrNone) || (numClients!=0))
|
|
3954 |
{
|
|
3955 |
gTest.Printf(_L("TestTransientHandling: GetInfoOnClientsUsingResource for (gLongLatencyResource+1) returned %d\n"),r);
|
|
3956 |
if(numClients!=0)
|
|
3957 |
gTest.Printf(_L("TestTransientHandling: GetInfoOnClientsUsingResource for (gLongLatencyResource+1), %d clients\n"),numClients);
|
|
3958 |
return KErrGeneral;
|
|
3959 |
}
|
|
3960 |
if((r=gChannel.GetInfoOnClientsUsingResource(gSharedResource, numClients, &infoPtrs, EFalse))!=KErrNotReady)
|
|
3961 |
{
|
|
3962 |
gTest.Printf(_L("TestTransientHandling: GetInfoOnClientsUsingResource (for gSharedResource) returned %d\n"),r);
|
244
|
3963 |
return KErrGeneral;
|
0
|
3964 |
}
|
|
3965 |
infoPtrs.Close();
|
|
3966 |
}
|
|
3967 |
|
|
3968 |
|
|
3969 |
// 11) Repeat the read the number of clients without reading the client information
|
|
3970 |
// Subsequent call to read the client information (without re-loading) should return error KErrNotReady
|
|
3971 |
// Then call to read the client information (with re-loading) should be successful
|
|
3972 |
gTest.Printf(_L("TestTransientHandling: test %d\n"),testNo++);
|
|
3973 |
{
|
|
3974 |
TUint numClients = 0;
|
|
3975 |
if((r=gChannel.GetNumClientsUsingResource(gLongLatencyResource, numClients, EFalse, EFalse))!=KErrNone) // user-side clients, don't load the info
|
|
3976 |
{
|
|
3977 |
gTest.Printf(_L("GetNumClientsUsingResource returned %d\n"),r);
|
|
3978 |
return r;
|
|
3979 |
}
|
|
3980 |
// To support the GetInfoOnClientsUsingResource testing, instantiate TClientInfoBuf objects
|
|
3981 |
// and reference via an RSimplePointerArray
|
|
3982 |
RSimplePointerArray<TClientInfoBuf> infoPtrs(numClients);
|
|
3983 |
for(TUint i=0;i<numClients;i++)
|
|
3984 |
{
|
|
3985 |
TClientInfoBuf *info = new TClientInfoBuf();
|
|
3986 |
if((r=infoPtrs.Insert(info, i))!=KErrNone)
|
|
3987 |
{
|
|
3988 |
gTest.Printf(_L("TestTransientHandling test, GetInfoOnClientsUsingResource infoPtrs.Insert at index %d returned %d\n"),testNo,i,r);
|
|
3989 |
}
|
|
3990 |
}
|
|
3991 |
if((r=gChannel.GetInfoOnClientsUsingResource(gLongLatencyResource, numClients, &infoPtrs, EFalse))!=KErrNotReady)
|
|
3992 |
{
|
|
3993 |
gTest.Printf(_L("TestTransientHandling: GetInfoOnClientsUsingResource for gLongLatencyResource returned %d\n"),r);
|
|
3994 |
return KErrGeneral;
|
|
3995 |
}
|
|
3996 |
if((r=gChannel.GetInfoOnClientsUsingResource(gLongLatencyResource, numClients, &infoPtrs, EFalse, ETrue))!=KErrNone)
|
|
3997 |
{
|
|
3998 |
gTest.Printf(_L("TestTransientHandling: GetInfoOnClientsUsingResource for gLongLatencyResource returned %d\n"),r);
|
|
3999 |
return r;
|
|
4000 |
}
|
|
4001 |
|
|
4002 |
infoPtrs.Close();
|
|
4003 |
}
|
|
4004 |
|
|
4005 |
// 12) To support the following test (and specific resource data tests, below) need a second channel to be using the resource
|
|
4006 |
_LIT(tempStr1,"ExtraChan1");
|
|
4007 |
TBufC<16> tempName1(tempStr1);
|
|
4008 |
RBusDevResManUs channelTwo;
|
|
4009 |
if((r=OpenChannel(tempName1, channelTwo))!=KErrNone)
|
|
4010 |
{
|
|
4011 |
gTest.Printf(_L("Failed to open channelTwo, %d\n"),r);
|
|
4012 |
channelTwo.Close();
|
|
4013 |
return r;
|
|
4014 |
}
|
|
4015 |
if ((r=channelTwo.Initialise(1,1,1))!=KErrNone)
|
|
4016 |
{
|
|
4017 |
gTest.Printf(_L("Failed to Initialise channelTwo, %d\n"),r);
|
|
4018 |
channelTwo.Close();
|
|
4019 |
return r;
|
|
4020 |
}
|
|
4021 |
// Attempt to change the resource level
|
|
4022 |
// Get initial state
|
|
4023 |
TRequestStatus status;
|
|
4024 |
TBool cached = gUseCached;
|
|
4025 |
TInt readValue;
|
|
4026 |
TInt levelOwnerId = 0;
|
|
4027 |
channelTwo.GetResourceState(status,gSharedResource,cached,&readValue,&levelOwnerId);
|
|
4028 |
User::WaitForRequest(status);
|
|
4029 |
r=status.Int();
|
|
4030 |
if(r != KErrNone)
|
|
4031 |
{
|
|
4032 |
gTest.Printf(_L("GetResourceState for gSharedResource completed with = 0x%x\n"),r);
|
|
4033 |
return r;
|
|
4034 |
}
|
|
4035 |
// Write updated state
|
|
4036 |
TUint newLevel = (TUint)(readValue + gSharedResStateDelta);
|
|
4037 |
channelTwo.ChangeResourceState(status,gSharedResource,newLevel);
|
|
4038 |
User::WaitForRequest(status);
|
|
4039 |
r=status.Int();
|
|
4040 |
if(r != KErrNone)
|
|
4041 |
{
|
|
4042 |
gTest.Printf(_L("ChangeResourceState forgSharedResource completed with %d\n"),r);
|
|
4043 |
return r;
|
|
4044 |
}
|
|
4045 |
|
|
4046 |
// Attempt to read the client information (without re-loading) with a buffer of insufficient size should
|
|
4047 |
// return error KErrArgument
|
|
4048 |
gTest.Printf(_L("TestTransientHandling: test %d\n"),testNo++);
|
|
4049 |
{
|
|
4050 |
TUint numClients = 0;
|
|
4051 |
if((r=gChannel.GetNumClientsUsingResource(gSharedResource, numClients, EFalse))!=KErrNone) // user-side clients, load the info
|
|
4052 |
{
|
|
4053 |
gTest.Printf(_L("GetNumClientsUsingResource returned %d\n"),r);
|
|
4054 |
channelTwo.Close();
|
|
4055 |
return r;
|
|
4056 |
}
|
|
4057 |
// To support the GetInfoOnClientsUsingResource testing, instantiate TClientInfoBuf objects
|
|
4058 |
// and reference via an RSimplePointerArray
|
|
4059 |
RSimplePointerArray<TClientInfoBuf> infoPtrs(numClients-1);
|
|
4060 |
for(TUint i=0;i<(numClients-1);i++)
|
|
4061 |
{
|
|
4062 |
TClientInfoBuf *info = new TClientInfoBuf();
|
|
4063 |
if((r=infoPtrs.Insert(info, i))!=KErrNone)
|
|
4064 |
{
|
|
4065 |
gTest.Printf(_L("TestTransientHandling test, GetInfoOnClientsUsingResource infoPtrs.Insert at index %d returned %d\n"),testNo,i,r);
|
|
4066 |
channelTwo.Close();
|
|
4067 |
}
|
|
4068 |
}
|
|
4069 |
if((r=gChannel.GetInfoOnClientsUsingResource(gSharedResource, numClients, &infoPtrs, EFalse))!=KErrArgument)
|
|
4070 |
{
|
|
4071 |
gTest.Printf(_L("TestTransientHandling: GetInfoOnClientsUsingResource for gLongLatencyResource returned %d\n"),r);
|
|
4072 |
channelTwo.Close();
|
|
4073 |
return KErrGeneral;
|
|
4074 |
}
|
|
4075 |
// Ensure misleading result is not returned
|
|
4076 |
r=KErrNone;
|
|
4077 |
infoPtrs.Close();
|
|
4078 |
}
|
|
4079 |
|
|
4080 |
|
|
4081 |
//
|
|
4082 |
// Specific resource data tests
|
|
4083 |
//
|
|
4084 |
|
|
4085 |
gTest.Printf(_L("TestTransientHandling: Client-specific data tests ...\n"));
|
|
4086 |
testNo=1;
|
|
4087 |
|
|
4088 |
// These tests require a client name
|
|
4089 |
TBuf8<MAX_RESOURCE_NAME_LENGTH+1>name8Bit;
|
|
4090 |
name8Bit.Copy(gTestName);
|
|
4091 |
TClientName* clientName = (TClientName*)&name8Bit;
|
|
4092 |
#if _DEBUG
|
|
4093 |
TBuf <MAX_CLIENT_NAME_LENGTH> clientName16Bit;
|
|
4094 |
clientName16Bit.Copy(*clientName);
|
|
4095 |
clientName16Bit.SetLength(clientName->Length());
|
|
4096 |
gTest.Printf(_L("Invoking TestTransientHandling client-specific data tests with %S \n"),&clientName16Bit);
|
|
4097 |
#endif
|
|
4098 |
// 13) Attempt to read the resource information without having previously loaded it.
|
|
4099 |
gTest.Printf(_L("TestTransientHandling: test %d\n"),testNo++);
|
|
4100 |
{
|
|
4101 |
TUint numResources = 0;
|
|
4102 |
if((r=gChannel.GetNumResourcesInUseByClient(*clientName, numResources, EFalse))!=KErrNone) // EFalse - don't load data
|
|
4103 |
{
|
|
4104 |
gTest.Printf(_L("GetNumResourcesInUseByClient returned %d\n"),r);
|
|
4105 |
return r;
|
|
4106 |
}
|
|
4107 |
// To support the GetInfoOnResourcesInUseByClient testing, instantiate TResourceInfoBuf objects
|
|
4108 |
// and reference via an RSimplePointerArray
|
|
4109 |
RSimplePointerArray<TResourceInfoBuf> infoPtrs(numResources);
|
|
4110 |
for(TUint i=0;i<numResources;i++)
|
|
4111 |
{
|
|
4112 |
TResourceInfoBuf *info = new TResourceInfoBuf();
|
|
4113 |
if((r=infoPtrs.Insert(info, i))!=KErrNone)
|
|
4114 |
{
|
|
4115 |
gTest.Printf(_L("TestTransientHandling test, GetAllResourcesInfo infoPtrs.Insert at index %d returned %d\n"),testNo,i,r);
|
|
4116 |
}
|
|
4117 |
}
|
|
4118 |
if((r=gChannel.GetInfoOnResourcesInUseByClient(*clientName, numResources, &infoPtrs))!=KErrNotReady)
|
|
4119 |
{
|
|
4120 |
gTest.Printf(_L("TestTransientHandling: GetInfoOnClientsUsingResource returned %d\n"),r);
|
|
4121 |
return KErrGeneral;
|
|
4122 |
}
|
|
4123 |
else
|
|
4124 |
r=KErrNone; // Ensure misleading result is not propagated
|
|
4125 |
infoPtrs.Close();
|
|
4126 |
}
|
|
4127 |
|
|
4128 |
// 14) To support the following test need a third channel
|
|
4129 |
_LIT(tempStr2,"ExtraChan2");
|
|
4130 |
TBufC<16> tempName2(tempStr2);
|
|
4131 |
RBusDevResManUs channelThree;
|
|
4132 |
if((r=OpenChannel(tempName2, channelThree))!=KErrNone)
|
|
4133 |
{
|
|
4134 |
gTest.Printf(_L("Failed to open channelThree, %d\n"),r);
|
|
4135 |
channelTwo.Close();
|
|
4136 |
return r;
|
|
4137 |
}
|
|
4138 |
// Read the number of resources (and, by default, read the resource information)
|
|
4139 |
// Subsequent call to read the resource information (without re-loading) should return be successful
|
|
4140 |
// Call to read the information for a client name with zero resource requirements (without re-loading) should return KErrNone, numResources==0
|
|
4141 |
// Call to read the information for a client name with one or more resource requirements (without re-loading) should return KErrNotReady
|
|
4142 |
gTest.Printf(_L("TestTransientHandling: test %d\n"),testNo++);
|
|
4143 |
{
|
|
4144 |
TUint numResources = 0;
|
|
4145 |
if((r=gChannel.GetNumResourcesInUseByClient(*clientName, numResources))!=KErrNone) // load data
|
|
4146 |
{
|
|
4147 |
gTest.Printf(_L("GetNumResourcesInUseByClient returned %d\n"),r);
|
|
4148 |
return r;
|
|
4149 |
}
|
|
4150 |
// To support the GetInfoOnResourcesInUseByClient testing, instantiate TResourceInfoBuf objects
|
|
4151 |
// and reference via an RSimplePointerArray
|
|
4152 |
RSimplePointerArray<TResourceInfoBuf> infoPtrs(numResources);
|
|
4153 |
for(TUint i=0;i<numResources;i++)
|
|
4154 |
{
|
|
4155 |
TResourceInfoBuf *info = new TResourceInfoBuf();
|
|
4156 |
if((r=infoPtrs.Insert(info, i))!=KErrNone)
|
|
4157 |
{
|
|
4158 |
gTest.Printf(_L("TestTransientHandling test, GetAllResourcesInfo infoPtrs.Insert at index %d returned %d\n"),testNo,i,r);
|
|
4159 |
}
|
|
4160 |
}
|
|
4161 |
if((r=gChannel.GetInfoOnResourcesInUseByClient(*clientName, numResources, &infoPtrs))!=KErrNone)
|
|
4162 |
{
|
|
4163 |
gTest.Printf(_L("TestTransientHandling: gChannel GetInfoOnClientsUsingResource returned %d\n"),r);
|
|
4164 |
return KErrGeneral;
|
|
4165 |
}
|
|
4166 |
TUint dumResources=0;
|
|
4167 |
TBuf8<MAX_RESOURCE_NAME_LENGTH+1>name8Bit2;
|
|
4168 |
name8Bit2.Copy(tempName2);
|
|
4169 |
TClientName* clientName2 = (TClientName*)&name8Bit2;
|
|
4170 |
if((r=gChannel.GetInfoOnResourcesInUseByClient(*clientName2, dumResources, &infoPtrs))!=KErrNone)
|
|
4171 |
{
|
|
4172 |
gTest.Printf(_L("TestTransientHandling: tempName2 GetInfoOnClientsUsingResource returned %d\n"),r);
|
|
4173 |
return KErrGeneral;
|
|
4174 |
}
|
|
4175 |
if(dumResources!=0)
|
|
4176 |
{
|
|
4177 |
gTest.Printf(_L("TestTransientHandling: tempName2 GetInfoOnClientsUsingResource dumResources=%d\n"),dumResources);
|
|
4178 |
return KErrGeneral;
|
|
4179 |
}
|
|
4180 |
TBuf8<MAX_RESOURCE_NAME_LENGTH+1>name8Bit1;
|
|
4181 |
name8Bit1.Copy(tempName1);
|
|
4182 |
TClientName* clientName1 = (TClientName*)&name8Bit1;
|
|
4183 |
if((r=gChannel.GetInfoOnResourcesInUseByClient(*clientName1, numResources, &infoPtrs))!=KErrNotReady)
|
|
4184 |
{
|
|
4185 |
gTest.Printf(_L("TestTransientHandling: tempName1 GetInfoOnClientsUsingResource returned %d\n"),r);
|
|
4186 |
return KErrGeneral;
|
|
4187 |
}
|
|
4188 |
|
|
4189 |
infoPtrs.Close();
|
|
4190 |
}
|
|
4191 |
|
|
4192 |
|
|
4193 |
// 15) Repeat the read the number of resources without reading the resource information
|
|
4194 |
// Subsequent call to read the resources information (without re-loading) should return error KErrNotReady
|
|
4195 |
// Then call to read the resources information (with re-loading) should be successful
|
|
4196 |
gTest.Printf(_L("TestTransientHandling: test %d\n"),testNo++);
|
|
4197 |
{
|
|
4198 |
TUint numResources = 0;
|
|
4199 |
if((r=gChannel.GetNumResourcesInUseByClient(*clientName, numResources, EFalse))!=KErrNone) // don't load data
|
|
4200 |
{
|
|
4201 |
gTest.Printf(_L("GetNumResourcesInUseByClient returned %d\n"),r);
|
|
4202 |
return r;
|
|
4203 |
}
|
|
4204 |
// To support the GetInfoOnResourcesInUseByClient testing, instantiate TResourceInfoBuf objects
|
|
4205 |
// and reference via an RSimplePointerArray
|
|
4206 |
RSimplePointerArray<TResourceInfoBuf> infoPtrs(numResources);
|
|
4207 |
for(TUint i=0;i<numResources;i++)
|
|
4208 |
{
|
|
4209 |
TResourceInfoBuf *info = new TResourceInfoBuf();
|
|
4210 |
if((r=infoPtrs.Insert(info, i))!=KErrNone)
|
|
4211 |
{
|
|
4212 |
gTest.Printf(_L("TestTransientHandling test, GetAllResourcesInfo infoPtrs.Insert at index %d returned %d\n"),testNo,i,r);
|
|
4213 |
}
|
|
4214 |
}
|
|
4215 |
if((r=gChannel.GetInfoOnResourcesInUseByClient(*clientName, numResources, &infoPtrs))!=KErrNotReady)
|
|
4216 |
{
|
|
4217 |
gTest.Printf(_L("TestTransientHandling: GetInfoOnResourcesInUseByClient returned %d\n"),r);
|
|
4218 |
return KErrGeneral;
|
|
4219 |
}
|
|
4220 |
if((r=gChannel.GetInfoOnResourcesInUseByClient(*clientName, numResources, &infoPtrs, ETrue))!=KErrNone)
|
|
4221 |
{
|
|
4222 |
gTest.Printf(_L("TestTransientHandling: GetInfoOnResourcesInUseByClient returned %d\n"),r);
|
|
4223 |
return r;
|
|
4224 |
}
|
|
4225 |
infoPtrs.Close();
|
|
4226 |
}
|
|
4227 |
|
|
4228 |
|
|
4229 |
// 16) Attempt to read the resource information (without re-loading) with a buffer of insufficient size should
|
|
4230 |
// return error KErrArgument
|
|
4231 |
gTest.Printf(_L("TestTransientHandling: test %d\n"),testNo++);
|
|
4232 |
{
|
|
4233 |
TUint numResources = 0;
|
|
4234 |
if((r=gChannel.GetNumResourcesInUseByClient(*clientName, numResources))!=KErrNone) // load data
|
|
4235 |
{
|
|
4236 |
gTest.Printf(_L("GetNumResourcesInUseByClient returned %d\n"),r);
|
|
4237 |
return r;
|
|
4238 |
}
|
|
4239 |
// To support the GetInfoOnResourcesInUseByClient testing, instantiate TResourceInfoBuf objects
|
|
4240 |
// and reference via an RSimplePointerArray
|
|
4241 |
RSimplePointerArray<TResourceInfoBuf> infoPtrs(numResources-1);
|
|
4242 |
for(TUint i=0;i<(numResources-1);i++)
|
|
4243 |
{
|
|
4244 |
TResourceInfoBuf *info = new TResourceInfoBuf();
|
|
4245 |
if((r=infoPtrs.Insert(info, i))!=KErrNone)
|
|
4246 |
{
|
|
4247 |
gTest.Printf(_L("TestTransientHandling test, GetAllResourcesInfo infoPtrs.Insert at index %d returned %d\n"),testNo,i,r);
|
|
4248 |
}
|
|
4249 |
}
|
|
4250 |
if((r=gChannel.GetInfoOnResourcesInUseByClient(*clientName, numResources, &infoPtrs))!=KErrArgument)
|
|
4251 |
{
|
|
4252 |
gTest.Printf(_L("TestTransientHandling: GetInfoOnResourcesInUseByClient returned %d\n"),r);
|
|
4253 |
return KErrGeneral;
|
|
4254 |
}
|
|
4255 |
|
|
4256 |
// Ensure misleading result is not returned
|
|
4257 |
r=KErrNone;
|
|
4258 |
infoPtrs.Close();
|
|
4259 |
}
|
|
4260 |
|
|
4261 |
channelTwo.Close();
|
|
4262 |
channelThree.Close();
|
|
4263 |
|
|
4264 |
return r;
|
|
4265 |
}
|
|
4266 |
|
|
4267 |
|
|
4268 |
EXPORT_C TInt E32Main()
|
|
4269 |
//
|
|
4270 |
// Main
|
|
4271 |
//
|
244
|
4272 |
{
|
|
4273 |
gTest.Title();
|
0
|
4274 |
gTest.Start(_L("Test Power Resource Manager user side API\n"));
|
|
4275 |
|
|
4276 |
// Test attempted load of PDD
|
244
|
4277 |
gTest.Next(_L("**Load PDD\n"));
|
|
4278 |
TInt r = User::LoadPhysicalDevice(PDD_NAME);
|
|
4279 |
gTest((r == KErrNone) || (r == KErrAlreadyExists));
|
|
4280 |
gTest.SetCleanupFlag(EPddLoaded);
|
|
4281 |
|
|
4282 |
// Test attempted load of LDD
|
|
4283 |
gTest.Next(_L("**Load LDD\n"));
|
|
4284 |
r = User::LoadLogicalDevice(LDD_NAME);
|
|
4285 |
gTest((r == KErrNone) || (r == KErrAlreadyExists));
|
|
4286 |
r = KErrNone; // Re-initialise in case set to KErrAlreadyExists
|
|
4287 |
gTest.SetCleanupFlag(ELddLoaded);
|
|
4288 |
|
|
4289 |
// test caps
|
|
4290 |
gTest(CheckCaps() == KErrNone);
|
|
4291 |
|
|
4292 |
// Need a channel open for the following tests
|
|
4293 |
gTest.Next(_L("**OpenAndRegisterChannel\n"));
|
|
4294 |
r = OpenAndRegisterChannel();
|
|
4295 |
gTest(r == KErrNone);
|
|
4296 |
gTest.SetCleanupFlag(EChannelOpened);
|
|
4297 |
|
|
4298 |
// Get the version of the ResourceController
|
|
4299 |
TUint version;
|
|
4300 |
r = gChannel.GetResourceControllerVersion(version);
|
|
4301 |
gTest.Printf(_L("TestTransientHandling: ResourceController version =0x%x\n"), version);
|
|
4302 |
gTest(r == KErrNone);
|
|
4303 |
|
|
4304 |
gTest.Next(_L("**TestThreadExclusiveAccess\n"));
|
|
4305 |
r = TestThreadExclusiveAccess();
|
|
4306 |
gTest(r == KErrNone);
|
|
4307 |
|
|
4308 |
gTest.Next(_L("**TestGetClientGetResourceInfo - initial state\n"));
|
|
4309 |
r = TestGetClientGetResourceInfo();
|
|
4310 |
gTest(r == KErrNone);
|
|
4311 |
|
|
4312 |
gTest.Next(_L("**TestGetSetResourceStateOps\n"));
|
|
4313 |
r = TestGetSetResourceStateOps();
|
|
4314 |
gTest(r == KErrNone);
|
|
4315 |
|
|
4316 |
gTest.Next(_L("**TestGetClientGetResourceInfo - after changing stateof Async resource\n"));
|
|
4317 |
r = TestGetClientGetResourceInfo();
|
|
4318 |
gTest(r == KErrNone);
|
|
4319 |
|
|
4320 |
gTest.Next(_L("**TestGetSetResourceStateQuota\n"));
|
|
4321 |
r = TestGetSetResourceStateQuota();
|
|
4322 |
gTest(r == KErrNone);
|
|
4323 |
|
|
4324 |
gTest.Next(_L("**TestNotificationOps\n"));
|
|
4325 |
r = TestNotificationOps();
|
|
4326 |
gTest(r == KErrNone);
|
|
4327 |
|
|
4328 |
gTest.Next(_L("**TestNotificationQuota\n"));
|
|
4329 |
r = TestNotificationQuota();
|
|
4330 |
gTest(r == KErrNone);
|
|
4331 |
|
|
4332 |
// Should be no change since last invocation (assuming that
|
|
4333 |
// no clients other than those in this test)
|
|
4334 |
gTest.Next(_L("**TestGetClientGetResourceInfo - last invocation\n"));
|
|
4335 |
r = TestGetClientGetResourceInfo();
|
|
4336 |
gTest(r == KErrNone);
|
|
4337 |
|
|
4338 |
gTest.Next(_L("**TestAdditionalThread\n"));
|
|
4339 |
r = TestAdditionalThread();
|
|
4340 |
gTest(r == KErrNone);
|
|
4341 |
|
|
4342 |
gTest.Next(_L("**TestTransientHandling\n"));
|
|
4343 |
r = TestTransientHandling();
|
|
4344 |
gTest(r == KErrNone);
|
0
|
4345 |
|
|
4346 |
gTest.End();
|
244
|
4347 |
return KErrNone;
|
|
4348 |
}
|
|
4349 |
|
|
4350 |
|