|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "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 /** |
|
17 @file |
|
18 @test |
|
19 @internalComponent - Internal Symbian test code |
|
20 */ |
|
21 |
|
22 #include "tgraphicsresourceteststepbase.h" |
|
23 #include <e32math.h> |
|
24 |
|
25 CTSgTestStepBase::CTSgTestStepBase() |
|
26 { |
|
27 } |
|
28 |
|
29 CTSgTestStepBase::~CTSgTestStepBase() |
|
30 { |
|
31 iSecondThread.Close(); |
|
32 } |
|
33 |
|
34 /** |
|
35 Overrides of base class virtual |
|
36 @leave Gets system wide error code |
|
37 @return - TVerdict code |
|
38 */ |
|
39 TVerdict CTSgTestStepBase::doTestStepPreambleL() |
|
40 { |
|
41 SetTestStepResult(EPass); |
|
42 return TestStepResult(); |
|
43 } |
|
44 |
|
45 /** |
|
46 Override of base class virtual |
|
47 @leave Gets system wide error code |
|
48 @return - TVerdict code |
|
49 */ |
|
50 TVerdict CTSgTestStepBase::doTestStepPostambleL() |
|
51 { |
|
52 return TestStepResult(); |
|
53 } |
|
54 |
|
55 /** |
|
56 Override of function from CTestStep so that each test failure is reported in output. |
|
57 */ |
|
58 EXPORT_C void CTSgTestStepBase::testBooleanTrue(TBool aCondition, const TText8* aFile, TInt aLine) |
|
59 { |
|
60 TRAP_IGNORE(testBooleanTrueL(aCondition, aFile, aLine, ETrue)); |
|
61 } |
|
62 |
|
63 /** |
|
64 Creates an image with some predefined parametres. |
|
65 @param aImage output image handle |
|
66 @leave Gets system wide error code |
|
67 */ |
|
68 void CTSgTestStepBase::CreateImageL(RSgImage& aImage) |
|
69 { |
|
70 TSgImageInfo info; |
|
71 info.iSizeInPixels = TSize(8, 8); |
|
72 info.iUsage = ESgUsageDirectGdiSource; |
|
73 info.iPixelFormat = EUidPixelFormatRGB_565; |
|
74 info.iCpuAccess = ESgCpuAccessReadWrite; |
|
75 info.iShareable = ETrue; |
|
76 |
|
77 CheckErrorL(KErrNone, aImage.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__); |
|
78 } |
|
79 |
|
80 /** |
|
81 Creates an image collection with some predefined parametres. |
|
82 @param aCollection output image collection handle |
|
83 @leave Gets system wide error code |
|
84 */ |
|
85 void CTSgTestStepBase::CreateImageCollectionL(RSgImageCollection& aCollection) |
|
86 { |
|
87 TSgImageInfo info; |
|
88 info.iSizeInPixels = TSize(8, 8); |
|
89 info.iUsage = ESgUsageDirectGdiSource; |
|
90 info.iPixelFormat = EUidPixelFormatRGB_565; |
|
91 info.iCpuAccess = ESgCpuAccessReadWrite; |
|
92 CheckErrorL(KErrNone, aCollection.Create(info, KNumImagesInCollection), (TText8*)__FILE__, __LINE__); |
|
93 TEST(!aCollection.IsNull()); |
|
94 } |
|
95 |
|
96 /** |
|
97 Creates a second process and do some tests in it. |
|
98 @param aProcessName The name of the new process |
|
99 @param aTestInfo The information for the tests |
|
100 @leave Gets system wide error code |
|
101 */ |
|
102 TInt CTSgTestStepBase::CreateSecondProcessAndDoTestL(const TDesC &aProcessName, TSgresTestInfo& aTestInfo) |
|
103 { |
|
104 // Create a second process |
|
105 RProcess process; |
|
106 User::LeaveIfError(process.Create(aProcessName, KNullDesC)); |
|
107 CleanupClosePushL(process); |
|
108 |
|
109 // Specify the test for the second process |
|
110 TESTL(KErrNone == process.SetParameter(KSecondProcessFunctionSlot, ((TSgresTestInfo)aTestInfo).iTestCase)); |
|
111 // Specify the id passed to the second process |
|
112 TPckg<TSgresTestInfo> ptr(aTestInfo); |
|
113 |
|
114 TESTL(KErrNone == process.SetParameter(KSecondProcessParametersSlot, ptr)); |
|
115 // Kick off the second process and wait for it to complete |
|
116 // The actual testing is done in the second process |
|
117 TRequestStatus status = KRequestPending; |
|
118 process.Logon(status); |
|
119 process.Resume(); |
|
120 User::WaitForRequest(status); |
|
121 |
|
122 TInt exitreason = process.ExitReason(); |
|
123 |
|
124 CleanupStack::PopAndDestroy(); |
|
125 |
|
126 //return test result |
|
127 return exitreason; |
|
128 } |
|
129 |
|
130 /** |
|
131 Creates a second thread and do some tests in it. |
|
132 @param aTestInfo The information for the tests |
|
133 @leave Gets system wide error code |
|
134 */ |
|
135 TInt CTSgTestStepBase::CreateSecondThreadAndDoTestL(TSgresTestInfo aTestInfo) |
|
136 { |
|
137 //create a semaphore |
|
138 RSemaphore sem; |
|
139 User::LeaveIfError(sem.CreateGlobal(KSecondThreadSemaphore, 0, EOwnerThread)); |
|
140 CleanupClosePushL(sem); |
|
141 |
|
142 User::LeaveIfError(iSecondThread.Create(KSecondThread, SecondThreadStart, KDefaultStackSize, &User::Heap(), &aTestInfo)); |
|
143 // Launch second thread |
|
144 TRequestStatus statusSecondThread; |
|
145 iSecondThread.Logon(statusSecondThread); |
|
146 iSecondThread.SetPriority(EPriorityLess); |
|
147 iSecondThread.Resume(); |
|
148 |
|
149 User::WaitForRequest(statusSecondThread); |
|
150 |
|
151 TInt result = iSecondThread.ExitReason(); |
|
152 |
|
153 //Close the handle |
|
154 CleanupStack::PopAndDestroy(1, &sem); |
|
155 iSecondThread.Close(); |
|
156 |
|
157 return result; |
|
158 } |
|
159 |
|
160 /** |
|
161 Creates a second thread and do some panic tests in it. |
|
162 @param aTestInfo The information for the tests |
|
163 @param aPanicCode The expected panic code |
|
164 @param aExitCategory The expected panic category |
|
165 @param aThreadName The name of the new thread |
|
166 @leave Gets system wide error code |
|
167 */ |
|
168 void CTSgTestStepBase::CreateSecondThreadAndCheckPanicL(TSgresTestInfo aTestInfo, TInt aPanicCode, TExitCategoryName aExitCategory, const TDesC &aThreadName) |
|
169 { |
|
170 User::LeaveIfError(iSecondThread.Create(aThreadName, SecondThreadStart, KDefaultStackSize, 0x100, 0x100, &aTestInfo)); |
|
171 // Launch second thread |
|
172 TRequestStatus statusSecondThread; |
|
173 iSecondThread.Logon(statusSecondThread); |
|
174 iSecondThread.SetPriority(EPriorityLess); |
|
175 iSecondThread.Resume(); |
|
176 |
|
177 User::WaitForRequest(statusSecondThread); |
|
178 |
|
179 if(EExitPanic != iSecondThread.ExitType()) |
|
180 { |
|
181 ERR_PRINTF3(_L("Expected exit type: %d, Actual exit type: %d"), EExitPanic, iSecondThread.ExitType()); |
|
182 TEST(EFalse); |
|
183 } |
|
184 |
|
185 if(aPanicCode != iSecondThread.ExitReason()) |
|
186 { |
|
187 ERR_PRINTF3(_L("Expected panic code: %d, Actual panic code: %d"), aPanicCode, iSecondThread.ExitReason()); |
|
188 TEST(EFalse); |
|
189 } |
|
190 |
|
191 TExitCategoryName secondThreadExitCategory = iSecondThread.ExitCategory(); |
|
192 if(aExitCategory != secondThreadExitCategory) |
|
193 { |
|
194 ERR_PRINTF3(_L("Expected panic category: %S, Actual panic category: %S"), &aExitCategory, &secondThreadExitCategory); |
|
195 TEST(EFalse); |
|
196 } |
|
197 |
|
198 //close the driver if the second thread exited with type EExitKill |
|
199 //assumming the second thread only calls SgDriver::Open() once |
|
200 if(iSecondThread.ExitType() != EExitKill) |
|
201 { |
|
202 SgDriver::Close(); |
|
203 } |
|
204 |
|
205 //Close the handle |
|
206 iSecondThread.Close(); |
|
207 } |
|
208 |
|
209 /** |
|
210 Creates a second process and do some panic tests in it. |
|
211 @param aTestInfo The information for the tests |
|
212 @param aPanicCode The expected panic code |
|
213 @param aExitCategory The expected panic category |
|
214 @param aProcessName The name of the new process |
|
215 @leave Gets system wide error code |
|
216 */ |
|
217 void CTSgTestStepBase::CreateSecondProcessAndCheckPanicL(TSgresTestInfo aTestInfo, TInt aPanicCode, TExitCategoryName aExitCategory, const TDesC &aProcessName) |
|
218 { |
|
219 // Create a second process |
|
220 RProcess process; |
|
221 User::LeaveIfError(process.Create(KSecondProcess, aProcessName)); |
|
222 CleanupClosePushL(process); |
|
223 |
|
224 // Specify the test for the second process |
|
225 TESTL(KErrNone == process.SetParameter(KSecondProcessFunctionSlot, ((TSgresTestInfo)aTestInfo).iTestCase)); |
|
226 // Specify the id passed to the second process |
|
227 TPckg<TSgresTestInfo> ptr(aTestInfo); |
|
228 |
|
229 TESTL(KErrNone == process.SetParameter(KSecondProcessParametersSlot, ptr)); |
|
230 // Kick off the second process and wait for it to complete |
|
231 // The actual testing is done in the second process |
|
232 TRequestStatus status; |
|
233 process.Logon(status); |
|
234 process.Resume(); |
|
235 User::WaitForRequest(status); |
|
236 |
|
237 if(EExitPanic != process.ExitType()) |
|
238 { |
|
239 ERR_PRINTF3(_L("Expected exit type: %d, Actual exit type: %d"), EExitPanic, process.ExitType()); |
|
240 TEST(EFalse); |
|
241 } |
|
242 if(aPanicCode != process.ExitReason()) |
|
243 { |
|
244 ERR_PRINTF3(_L("Expected panic code: %d, Actual panic code: %d"), aPanicCode, process.ExitReason()); |
|
245 TEST(EFalse); |
|
246 } |
|
247 |
|
248 _LIT(KMemoryLeakCategory, "SGALLOC"); |
|
249 TExitCategoryName processExitCategory = process.ExitCategory(); |
|
250 TBool matchCategory; |
|
251 if (aExitCategory != KMemoryLeakCategory) |
|
252 { |
|
253 matchCategory = aExitCategory == processExitCategory; |
|
254 } |
|
255 else |
|
256 { |
|
257 matchCategory = processExitCategory.Left(KMemoryLeakCategory().Length()) == KMemoryLeakCategory; |
|
258 } |
|
259 if (!matchCategory) |
|
260 { |
|
261 ERR_PRINTF3(_L("Expected panic category: %S, Actual panic category: %S"), &aExitCategory, &processExitCategory); |
|
262 TEST(EFalse); |
|
263 } |
|
264 |
|
265 CleanupStack::PopAndDestroy(); |
|
266 } |
|
267 |
|
268 /** |
|
269 Gets the supporting pixel formats according to the specified cpu access, usage, shareability and screen id flags. |
|
270 @leave Gets system wide error code |
|
271 */ |
|
272 void CTSgTestStepBase::CallGetPixelFormatsL(TSgCpuAccess aCpuAccess, TUint32 aUsage, TBool aShareable, TInt aScreenId) |
|
273 { |
|
274 TSgImageInfo info; |
|
275 info.iCpuAccess = aCpuAccess; |
|
276 info.iUsage = aUsage; |
|
277 info.iShareable = aShareable; |
|
278 info.iScreenId = aScreenId; |
|
279 info.iSizeInPixels = TSize(10, 10); |
|
280 iPixelFormatCount = KMaxPixelFormats; |
|
281 Mem::FillZ(iPixelFormatArray, KMaxPixelFormats * sizeof(TUidPixelFormat)); |
|
282 CheckErrorL(KErrNone, RSgImage::GetPixelFormats(info, iPixelFormatArray, iPixelFormatCount), (TText8*)__FILE__, __LINE__); |
|
283 } |
|
284 |
|
285 /** |
|
286 Checks the pixel formats returned against the compatibility guarantee table. |
|
287 @leave Gets system wide error code |
|
288 */ |
|
289 void CTSgTestStepBase::TestGetPixelFormatCompatibilityGuaranteesL() |
|
290 { |
|
291 CallGetPixelFormatsL(ESgCpuAccessNone, ESgUsageDirectGdiSource, ETrue, KSgScreenIdAny); |
|
292 CheckPixelFormatPresent(EUidPixelFormatARGB_8888_PRE); |
|
293 CheckPixelFormatPresent(EUidPixelFormatXRGB_8888); |
|
294 CheckPixelFormatPresent(EUidPixelFormatRGB_565); |
|
295 |
|
296 CallGetPixelFormatsL(ESgCpuAccessReadWrite, ESgUsageDirectGdiSource, ETrue, KSgScreenIdMain); |
|
297 CheckPixelFormatPresent(EUidPixelFormatARGB_8888_PRE); |
|
298 CheckPixelFormatPresent(EUidPixelFormatXRGB_8888); |
|
299 CheckPixelFormatPresent(EUidPixelFormatRGB_565); |
|
300 |
|
301 CallGetPixelFormatsL(ESgCpuAccessNone, ESgUsageDirectGdiSource|ESgUsageDirectGdiTarget, ETrue, KSgScreenIdMain); |
|
302 CheckPixelFormatPresent(EUidPixelFormatARGB_8888_PRE); |
|
303 CheckPixelFormatPresent(EUidPixelFormatXRGB_8888); |
|
304 |
|
305 CallGetPixelFormatsL(ESgCpuAccessNone, ESgUsageDirectGdiSource|ESgUsageOpenGlesTarget, ETrue, KSgScreenIdMain); |
|
306 CheckPixelFormatPresent(EUidPixelFormatARGB_8888_PRE); |
|
307 CheckPixelFormatPresent(EUidPixelFormatXRGB_8888); |
|
308 |
|
309 CallGetPixelFormatsL(ESgCpuAccessNone, ESgUsageDirectGdiSource|ESgUsageOpenVgTarget, ETrue, KSgScreenIdMain); |
|
310 CheckPixelFormatPresent(EUidPixelFormatARGB_8888_PRE); |
|
311 CheckPixelFormatPresent(EUidPixelFormatXRGB_8888); |
|
312 |
|
313 CallGetPixelFormatsL(ESgCpuAccessNone, ESgUsageDirectGdiSource|ESgUsageOpenGles2Target, ETrue, KSgScreenIdMain); |
|
314 CheckPixelFormatPresent(EUidPixelFormatARGB_8888_PRE); |
|
315 CheckPixelFormatPresent(EUidPixelFormatXRGB_8888); |
|
316 } |
|
317 |
|
318 /** |
|
319 Helper function to check if a certain pixel format is present |
|
320 in the returned pixel formats array. |
|
321 @param aPixelFormat The pixelformat to check |
|
322 */ |
|
323 void CTSgTestStepBase::CheckPixelFormatPresent(TUidPixelFormat aPixelFormat) |
|
324 { |
|
325 for(TInt i=0; i<iPixelFormatCount; ++i) |
|
326 { |
|
327 if(aPixelFormat == iPixelFormatArray[i]) |
|
328 { |
|
329 return; |
|
330 } |
|
331 } |
|
332 TEST(EFalse); |
|
333 } |
|
334 |
|
335 /** |
|
336 Helper function to test the equivalence of two TSgImageInfo structures. |
|
337 |
|
338 @see CTDirectGdiContextTarget::CompareInfos |
|
339 @param aInfo1 A TSgImageInfo structure to compare. |
|
340 @param aInfo2 A TSgImageInfo structure to compare. |
|
341 |
|
342 @return ETrue if the two are identical, EFalse otherwise. |
|
343 */ |
|
344 TBool CTSgTestStepBase::CompareInfos(TSgImageInfo& aInfo1, TSgImageInfo& aInfo2) |
|
345 { |
|
346 TBool result = EFalse; |
|
347 if(aInfo1.iCpuAccess == aInfo2.iCpuAccess |
|
348 && aInfo1.iPixelFormat == aInfo2.iPixelFormat |
|
349 && aInfo1.iScreenId == aInfo2.iScreenId |
|
350 && aInfo1.iShareable == aInfo2.iShareable |
|
351 && aInfo1.iSizeInPixels == aInfo2.iSizeInPixels |
|
352 && aInfo1.iUsage | aInfo2.iUsage |
|
353 && aInfo1.iUserAttributeCount == aInfo2.iUserAttributeCount) |
|
354 { |
|
355 for(TInt i=0; i<aInfo1.iUserAttributeCount; ++i) |
|
356 { |
|
357 if(aInfo1.iUserAttributes[i].iUid != aInfo2.iUserAttributes[i].iUid) |
|
358 { |
|
359 break; |
|
360 } |
|
361 } |
|
362 result = ETrue; |
|
363 } |
|
364 return result; |
|
365 } |
|
366 |
|
367 /** |
|
368 Wrapper function to open the graphics resource driver and puts an cleanup item |
|
369 on the cleanup stack. |
|
370 @leave Gets system wide error code |
|
371 */ |
|
372 void CTSgTestStepBase::TestOpenDriverL() |
|
373 { |
|
374 CheckErrorL(KErrNone, SgDriver::Open(), (TText8*)__FILE__, __LINE__); |
|
375 CleanupStack::PushL(TCleanupItem((TCleanupOperation)CloseDriverWhenLeave, NULL)); |
|
376 } |
|
377 |
|
378 /** |
|
379 Wrapper function to close the graphics resource driver. |
|
380 */ |
|
381 void CTSgTestStepBase::TestCloseDriver() |
|
382 { |
|
383 CleanupStack::PopAndDestroy(); |
|
384 } |
|
385 |
|
386 /** |
|
387 Creates an image with specified parametres. |
|
388 @param aImage output image handle |
|
389 @return KErrNone if the image was created successfully, otherwise one of the system-wide error codes |
|
390 */ |
|
391 TInt CreateImageWithParameters(TInt aWidth, TInt aHeight, TUidPixelFormat aPixelFormat, TUint32 aUsage, TBool aShareable, TSgCpuAccess aCpuAccess, RSgImage& aImage) |
|
392 { |
|
393 TSgImageInfo info; |
|
394 info.iSizeInPixels = TSize(aWidth, aHeight); |
|
395 info.iPixelFormat = aPixelFormat; |
|
396 info.iUsage = aUsage; |
|
397 info.iCpuAccess = aCpuAccess; |
|
398 info.iShareable = aShareable; |
|
399 return aImage.Create(info, NULL, 0); |
|
400 } |
|
401 |
|
402 /** |
|
403 Creates an image collection with some predefined parametres. |
|
404 @param aCollection output image collection handle |
|
405 @return KErrNone if the image was created successfully, otherwise one of the system-wide error codes |
|
406 */ |
|
407 TInt CreateImageCollectionWithParameters(TInt aWidth, TInt aHeight, TUidPixelFormat aPixelFormat, TUint32 aUsage, TBool aShareable, TSgCpuAccess aCpuAccess, RSgImageCollection& aCollection) |
|
408 { |
|
409 TSgImageInfo info; |
|
410 info.iSizeInPixels = TSize(aWidth, aHeight); |
|
411 info.iPixelFormat = aPixelFormat; |
|
412 info.iUsage = aUsage; |
|
413 info.iCpuAccess = aCpuAccess; |
|
414 info.iShareable = aShareable; |
|
415 return aCollection.Create(info, KNumImagesInCollection); |
|
416 } |
|
417 |
|
418 |
|
419 /** |
|
420 Second thread entry function. |
|
421 */ |
|
422 TInt CTSgTestStepBase::SecondThreadStart(TAny* aInfo) |
|
423 { |
|
424 TInt procHandles1 =0; |
|
425 TInt threadHandles1=0; |
|
426 RThread().HandleCount(procHandles1, threadHandles1); |
|
427 __UHEAP_MARK; |
|
428 |
|
429 RSemaphore sem; |
|
430 TInt result = 0; |
|
431 |
|
432 TInt openSem = sem.OpenGlobal(KSecondThreadSemaphore, EOwnerThread); |
|
433 |
|
434 TSgresTestCase testcase = ((TSgresTestInfo*)aInfo)->iTestCase; |
|
435 |
|
436 RSgImage image; |
|
437 RSgDrawable drawable; |
|
438 TSgImageInfo info1; |
|
439 TSgImageInfo info2; |
|
440 TSgDrawableId id; |
|
441 const TAny* dataAddressRead; |
|
442 TAny* dataAddressWrite; |
|
443 TInt dataStride; |
|
444 TSgDrawableId fakeid = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF}; |
|
445 |
|
446 //test cases without the need of an initialised driver |
|
447 switch (testcase) |
|
448 { |
|
449 case ESgresSecondThreadPanicResourceCountNoDriver: |
|
450 { |
|
451 SgDriver::ResourceCount(); // should panic with SGRES 5 |
|
452 } |
|
453 break; |
|
454 case ESgresSecondThreadPanicAllocMarkStartNoDriver: |
|
455 { |
|
456 SgDriver::AllocMarkStart(); // should panic with SGRES 5 |
|
457 } |
|
458 break; |
|
459 case ESgresSecondThreadPanicAllocMarkEndNoDriver: |
|
460 { |
|
461 SgDriver::AllocMarkEnd(0); // should panic with SGRES 5 |
|
462 } |
|
463 break; |
|
464 case ESgresSecondThreadPanicSetAllocFailNoDriver: |
|
465 { |
|
466 SgDriver::SetAllocFail(RAllocator::EFailNext, 1); // should panic with SGRES 5 |
|
467 } |
|
468 break; |
|
469 case ESgresSecondThreadPanicDrawableOpenNoDriver: |
|
470 { |
|
471 drawable.Open(KSgNullDrawableId); // should panic with SGRES 5 |
|
472 } |
|
473 break; |
|
474 case ESgresSecondThreadPanicImageOpenNoDriver1: |
|
475 { |
|
476 image.Open(KSgNullDrawableId); // should panic with SGRES 5 |
|
477 } |
|
478 break; |
|
479 case ESgresSecondThreadPanicImageOpenNoDriver2: |
|
480 { |
|
481 image.Open(KSgNullDrawableId, ESgDoNotRestrictUsage); // should panic with SGRES 5 |
|
482 } |
|
483 break; |
|
484 case ESgresSecondThreadPanicImageCreateNoDriver1: |
|
485 { |
|
486 image.Create(info1, NULL, 0); // should panic with SGRES 5 |
|
487 } |
|
488 break; |
|
489 case ESgresSecondThreadPanicImageCreateNoDriver2: |
|
490 { |
|
491 RSgImage tempImage; |
|
492 image.Create(info1, tempImage); // should panic with SGRES 5 |
|
493 } |
|
494 break; |
|
495 case ESgresSecondThreadPanicImageGetPixelFormatsNoDriver: |
|
496 { |
|
497 TInt count = 0; |
|
498 RSgImage::GetPixelFormats(info1, NULL, count); // should panic with SGRES 5 |
|
499 } |
|
500 break; |
|
501 case ESgresSecondThreadPanicImageCollectionCreateNoDriver1: |
|
502 { |
|
503 RSgImageCollection c; |
|
504 c.Create(info1, 0); // should panic with SGRES 5 |
|
505 } |
|
506 break; |
|
507 case ESgresSecondThreadPanicImageCollectionCreateNoDriver2: |
|
508 { |
|
509 RSgImageCollection c; |
|
510 c.Create(NULL, 0, NULL, 0); // should panic with SGRES 5 |
|
511 } |
|
512 break; |
|
513 } |
|
514 |
|
515 |
|
516 //open driver |
|
517 TInt ret = SgDriver::Open(); |
|
518 if(KErrNoMemory == ret) |
|
519 { |
|
520 sem.Close(); |
|
521 return KErrNoMemory; |
|
522 } |
|
523 if(KErrNone == ret) |
|
524 { |
|
525 switch (testcase) |
|
526 { |
|
527 case ESgresSecondThreadOpenImage: |
|
528 { |
|
529 TInt err = image.Open(((TSgresTestInfo*)aInfo)->iDrawableId); |
|
530 if(KErrNoMemory == err) |
|
531 { |
|
532 result = KErrNoMemory; |
|
533 break; |
|
534 } |
|
535 if(KErrNone == err) |
|
536 { |
|
537 result |= EFirstTestPassed; |
|
538 } |
|
539 if(KErrNone == image.GetInfo(info2)) |
|
540 { |
|
541 result |= ESecondTestPassed; |
|
542 } |
|
543 info1 = ((TSgresTestInfo*)aInfo)->iImageInfo; |
|
544 if(CompareInfos(info1, info2)) |
|
545 { |
|
546 result |= EThirdTestPassed; |
|
547 } |
|
548 id = image.Id(); |
|
549 if(id != KSgNullDrawableId) |
|
550 { |
|
551 result |= EFourthTestPassed; |
|
552 } |
|
553 if(id == ((TSgresTestInfo*)aInfo)->iDrawableId) |
|
554 { |
|
555 result |= EFifthTestPassed; |
|
556 } |
|
557 } |
|
558 break; |
|
559 case ESgresSecondThreadOpenDrawable: |
|
560 { |
|
561 TInt err = drawable.Open(((TSgresTestInfo*)aInfo)->iDrawableId); |
|
562 if(KErrNoMemory == err) |
|
563 { |
|
564 result = KErrNoMemory; |
|
565 break; |
|
566 } |
|
567 if(KErrNone == err) |
|
568 { |
|
569 result |= EFirstTestPassed; |
|
570 } |
|
571 id = drawable.Id(); |
|
572 if(id != KSgNullDrawableId) |
|
573 { |
|
574 result |= ESecondTestPassed; |
|
575 } |
|
576 if(id == ((TSgresTestInfo*)aInfo)->iDrawableId) |
|
577 { |
|
578 result |= EThirdTestPassed; |
|
579 } |
|
580 } |
|
581 break; |
|
582 case ESgresSecondThreadOpenImageInvalid: |
|
583 { |
|
584 TSgImageInfo info; |
|
585 info.iSizeInPixels = TSize(8, 8); |
|
586 info.iUsage = ESgUsageDirectGdiSource; |
|
587 info.iPixelFormat = EUidPixelFormatRGB_565; |
|
588 info.iCpuAccess = ESgCpuAccessReadWrite; |
|
589 |
|
590 TInt err = image.Create(info, KImageData, 16); |
|
591 if(KErrNoMemory == err) |
|
592 { |
|
593 result = KErrNoMemory; |
|
594 break; |
|
595 } |
|
596 if(KErrNone == err) |
|
597 { |
|
598 result |= EFirstTestPassed; |
|
599 } |
|
600 |
|
601 // non-empty handle |
|
602 id = ((TSgresTestInfo*)aInfo)->iDrawableId; |
|
603 err = image.Open(id); |
|
604 if(KErrNoMemory == err) |
|
605 { |
|
606 result = KErrNoMemory; |
|
607 break; |
|
608 } |
|
609 if(KErrInUse == err) |
|
610 { |
|
611 result |= ESecondTestPassed; |
|
612 } |
|
613 image.Close(); |
|
614 |
|
615 // null drawable id |
|
616 err = image.Open(KSgNullDrawableId); |
|
617 if(KErrNoMemory == err) |
|
618 { |
|
619 result = KErrNoMemory; |
|
620 break; |
|
621 } |
|
622 if(KErrArgument == err) |
|
623 { |
|
624 result |= EThirdTestPassed; |
|
625 } |
|
626 image.Close(); |
|
627 |
|
628 // non-existing drawable id |
|
629 err = image.Open(fakeid); |
|
630 if(KErrNoMemory == err) |
|
631 { |
|
632 result = KErrNoMemory; |
|
633 break; |
|
634 } |
|
635 if(KErrNotFound == err) |
|
636 { |
|
637 result |= EFourthTestPassed; |
|
638 } |
|
639 image.Close(); |
|
640 |
|
641 // open a non-sharable image |
|
642 err = image.Open(id); |
|
643 if(KErrNoMemory == err) |
|
644 { |
|
645 result = KErrNoMemory; |
|
646 break; |
|
647 } |
|
648 if(KErrNone == err) |
|
649 { |
|
650 result |= EFifthTestPassed; |
|
651 } |
|
652 image.Close(); |
|
653 } |
|
654 break; |
|
655 case ESgresSecondThreadOpenDrawableInvalid: |
|
656 // null drawable id |
|
657 { |
|
658 TInt err = drawable.Open(KSgNullDrawableId); |
|
659 if(KErrNoMemory == err) |
|
660 { |
|
661 result = KErrNoMemory; |
|
662 break; |
|
663 } |
|
664 if(KErrArgument == err) |
|
665 { |
|
666 result |= EFirstTestPassed; |
|
667 } |
|
668 drawable.Close(); |
|
669 |
|
670 // non-existing drawable id |
|
671 err = drawable.Open(fakeid); |
|
672 if(KErrNoMemory == err) |
|
673 { |
|
674 result = KErrNoMemory; |
|
675 break; |
|
676 } |
|
677 |
|
678 if(KErrNotFound == err) |
|
679 { |
|
680 result |= ESecondTestPassed; |
|
681 } |
|
682 drawable.Close(); |
|
683 |
|
684 // open a non-sharable image - should succeed |
|
685 id = ((TSgresTestInfo*)aInfo)->iDrawableId; |
|
686 err = drawable.Open(id); |
|
687 if(KErrNoMemory == err) |
|
688 { |
|
689 result = KErrNoMemory; |
|
690 break; |
|
691 } |
|
692 if(KErrNone == err) |
|
693 { |
|
694 result |= EThirdTestPassed; |
|
695 } |
|
696 |
|
697 // non-empty handle |
|
698 if(KErrInUse == drawable.Open(id)) |
|
699 { |
|
700 result |= EFourthTestPassed; |
|
701 } |
|
702 drawable.Close(); |
|
703 } |
|
704 break; |
|
705 case ESgresSecondThreadMapImage: |
|
706 { |
|
707 id = ((TSgresTestInfo*)aInfo)->iDrawableId; |
|
708 TInt err = image.Open(id); |
|
709 if(KErrNoMemory == err) |
|
710 { |
|
711 result = KErrNoMemory; |
|
712 break; |
|
713 } |
|
714 if(KErrNone == err) |
|
715 { |
|
716 result |= EFirstTestPassed; |
|
717 } |
|
718 if(KErrNone == image.MapReadOnly(dataAddressRead, dataStride)) |
|
719 { |
|
720 result |= ESecondTestPassed; |
|
721 } |
|
722 if(KErrNone == image.Unmap()) |
|
723 { |
|
724 result |= EThirdTestPassed; |
|
725 } |
|
726 if(KErrNone == image.MapWriteOnly(dataAddressWrite, dataStride)) |
|
727 { |
|
728 result |= EFourthTestPassed; |
|
729 } |
|
730 if(KErrNone == image.Unmap()) |
|
731 { |
|
732 result |= EFifthTestPassed; |
|
733 } |
|
734 if(KErrNone == image.MapReadWrite(dataAddressWrite, dataStride)) |
|
735 { |
|
736 result |= ESixthTestPassed; |
|
737 } |
|
738 if(KErrNone == image.Unmap()) |
|
739 { |
|
740 result |= ESeventhTestPassed; |
|
741 } |
|
742 } |
|
743 break; |
|
744 case ESgresSecondThreadUnmapImage: |
|
745 { |
|
746 id = ((TSgresTestInfo*)aInfo)->iDrawableId; |
|
747 TInt err = image.Open(id); |
|
748 if(KErrNoMemory == err) |
|
749 { |
|
750 result = KErrNoMemory; |
|
751 break; |
|
752 } |
|
753 if(KErrNone == err) |
|
754 { |
|
755 result |= EFirstTestPassed; |
|
756 } |
|
757 if(KErrNone == image.Unmap()) |
|
758 { |
|
759 result |= ESecondTestPassed; |
|
760 } |
|
761 } |
|
762 break; |
|
763 case ESgresSecondThreadPanicImageGetInterfaceInvalidHandle: |
|
764 { |
|
765 RSgImage image; |
|
766 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); |
|
767 if(KErrNone != ret) |
|
768 { |
|
769 result = ret; |
|
770 break; |
|
771 } |
|
772 RSgImage anotherImage; |
|
773 anotherImage = image; |
|
774 image.Close(); |
|
775 |
|
776 MSgImage_Sw* swInterface = NULL; |
|
777 ret = anotherImage.GetInterface(swInterface); //should panic with SGRES 2 |
|
778 SgDriver::Close(); |
|
779 } |
|
780 break; |
|
781 case ESgresSecondThreadPanicImageGetInterfaceNoDriver: |
|
782 { |
|
783 RSgImage image; |
|
784 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); |
|
785 if(KErrNone != ret) |
|
786 { |
|
787 result = ret; |
|
788 break; |
|
789 } |
|
790 RSgImage anotherImage; |
|
791 anotherImage = image; |
|
792 image.Close(); |
|
793 |
|
794 SgDriver::Close(); |
|
795 MSgImage_Sw* swInterface = NULL; |
|
796 anotherImage.GetInterface(swInterface); // should panic with SGRES 5 |
|
797 } |
|
798 break; |
|
799 case ESgresSecondThreadPanicImageCloseInvalidHandle: |
|
800 { |
|
801 RSgImage image; |
|
802 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); |
|
803 if(KErrNone != ret) |
|
804 { |
|
805 result = ret; |
|
806 break; |
|
807 } |
|
808 RSgImage anotherImage; |
|
809 anotherImage = image; |
|
810 image.Close(); |
|
811 |
|
812 anotherImage.Close(); //should panic with SGRES 2 |
|
813 SgDriver::Close(); |
|
814 } |
|
815 break; |
|
816 case ESgresSecondThreadPanicImageCloseNoDriver: |
|
817 { |
|
818 RSgImage image; |
|
819 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); |
|
820 if(KErrNone != ret) |
|
821 { |
|
822 result = ret; |
|
823 break; |
|
824 } |
|
825 RSgImage anotherImage; |
|
826 anotherImage = image; |
|
827 image.Close(); |
|
828 SgDriver::Close(); |
|
829 anotherImage.Close(); // should panic with SGRES 5 |
|
830 } |
|
831 break; |
|
832 case ESgresSecondThreadPanicImageIdInvalidHandle: |
|
833 { |
|
834 RSgImage image; |
|
835 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); |
|
836 if(KErrNone != ret) |
|
837 { |
|
838 result = ret; |
|
839 break; |
|
840 } |
|
841 RSgImage anotherImage; |
|
842 anotherImage = image; |
|
843 image.Close(); |
|
844 |
|
845 anotherImage.Id(); //should panic with SGRES 2 |
|
846 SgDriver::Close(); |
|
847 } |
|
848 break; |
|
849 case ESgresSecondThreadPanicImageIdNoDriver: |
|
850 { |
|
851 RSgImage image; |
|
852 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); |
|
853 if(KErrNone != ret) |
|
854 { |
|
855 result = ret; |
|
856 break; |
|
857 } |
|
858 RSgImage anotherImage; |
|
859 anotherImage = image; |
|
860 image.Close(); |
|
861 SgDriver::Close(); |
|
862 anotherImage.Id(); // should panic with SGRES 5 |
|
863 } |
|
864 break; |
|
865 case ESgresSecondThreadPanicImageDrawableTypeInvalidHandle: |
|
866 { |
|
867 RSgImage image; |
|
868 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); |
|
869 if(KErrNone != ret) |
|
870 { |
|
871 result = ret; |
|
872 break; |
|
873 } |
|
874 RSgImage anotherImage; |
|
875 anotherImage = image; |
|
876 image.Close(); |
|
877 |
|
878 anotherImage.DrawableType(); //should panic with SGRES 2 |
|
879 SgDriver::Close(); |
|
880 } |
|
881 break; |
|
882 case ESgresSecondThreadPanicImageDrawableTypeNoDriver: |
|
883 { |
|
884 RSgImage image; |
|
885 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); |
|
886 if(KErrNone != ret) |
|
887 { |
|
888 result = ret; |
|
889 break; |
|
890 } |
|
891 RSgImage anotherImage; |
|
892 anotherImage = image; |
|
893 image.Close(); |
|
894 SgDriver::Close(); |
|
895 anotherImage.DrawableType(); // should panic with SGRES 5 |
|
896 } |
|
897 break; |
|
898 case ESgresSecondThreadPanicImageCreateInvalidHandle: |
|
899 { |
|
900 RSgImage image; |
|
901 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); |
|
902 if(KErrNone != ret) |
|
903 { |
|
904 result = ret; |
|
905 break; |
|
906 } |
|
907 RSgImage anotherImage; |
|
908 anotherImage = image; |
|
909 image.Close(); |
|
910 |
|
911 RSgImage newImage; |
|
912 TSgImageInfo info; |
|
913 image.GetInfo(info); |
|
914 newImage.Create(info, anotherImage); //should panic with SGRES 3 |
|
915 SgDriver::Close(); |
|
916 } |
|
917 break; |
|
918 case ESgresSecondThreadPanicImageGetInfoInvalidHandle: |
|
919 { |
|
920 RSgImage image; |
|
921 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); |
|
922 if(KErrNone != ret) |
|
923 { |
|
924 result = ret; |
|
925 break; |
|
926 } |
|
927 RSgImage anotherImage; |
|
928 anotherImage = image; |
|
929 image.Close(); |
|
930 |
|
931 TSgImageInfo anotherInfo; |
|
932 anotherImage.GetInfo(anotherInfo); //should panic with SGRES 3 |
|
933 SgDriver::Close(); |
|
934 } |
|
935 break; |
|
936 case ESgresSecondThreadPanicImageGetInfoNoDriver: |
|
937 { |
|
938 RSgImage image; |
|
939 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); |
|
940 if(KErrNone != ret) |
|
941 { |
|
942 result = ret; |
|
943 break; |
|
944 } |
|
945 RSgImage anotherImage; |
|
946 anotherImage = image; |
|
947 image.Close(); |
|
948 SgDriver::Close(); |
|
949 TSgImageInfo anotherInfo; |
|
950 anotherImage.GetInfo(anotherInfo); // should panic with SGRES 5 |
|
951 } |
|
952 break; |
|
953 case ESgresSecondThreadPanicImageMapReadOnlyInvalidHandle: |
|
954 { |
|
955 RSgImage image; |
|
956 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); |
|
957 if(KErrNone != ret) |
|
958 { |
|
959 result = ret; |
|
960 break; |
|
961 } |
|
962 RSgImage anotherImage; |
|
963 anotherImage = image; |
|
964 image.Close(); |
|
965 |
|
966 anotherImage.MapReadOnly(dataAddressRead, dataStride); //should panic with SGRES 3 |
|
967 SgDriver::Close(); |
|
968 } |
|
969 break; |
|
970 case ESgresSecondThreadPanicImageMapReadOnlyNoDriver: |
|
971 { |
|
972 RSgImage image; |
|
973 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); |
|
974 if(KErrNone != ret) |
|
975 { |
|
976 result = ret; |
|
977 break; |
|
978 } |
|
979 RSgImage anotherImage; |
|
980 anotherImage = image; |
|
981 image.Close(); |
|
982 SgDriver::Close(); |
|
983 anotherImage.MapReadOnly(dataAddressRead, dataStride); // should panic with SGRES 5 |
|
984 } |
|
985 break; |
|
986 case ESgresSecondThreadPanicImageMapWriteOnlyInvalidHandle: |
|
987 { |
|
988 RSgImage image; |
|
989 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); |
|
990 if(KErrNone != ret) |
|
991 { |
|
992 result = ret; |
|
993 break; |
|
994 } |
|
995 RSgImage anotherImage; |
|
996 anotherImage = image; |
|
997 image.Close(); |
|
998 |
|
999 anotherImage.MapWriteOnly(dataAddressWrite, dataStride); //should panic with SGRES 3 |
|
1000 SgDriver::Close(); |
|
1001 } |
|
1002 break; |
|
1003 case ESgresSecondThreadPanicImageMapWriteOnlyNoDriver: |
|
1004 { |
|
1005 RSgImage image; |
|
1006 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); |
|
1007 if(KErrNone != ret) |
|
1008 { |
|
1009 result = ret; |
|
1010 break; |
|
1011 } |
|
1012 RSgImage anotherImage; |
|
1013 anotherImage = image; |
|
1014 image.Close(); |
|
1015 SgDriver::Close(); |
|
1016 anotherImage.MapWriteOnly(dataAddressWrite, dataStride); // should panic with SGRES 5 |
|
1017 } |
|
1018 break; |
|
1019 case ESgresSecondThreadPanicImageMapReadWriteInvalidHandle: |
|
1020 { |
|
1021 RSgImage image; |
|
1022 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); |
|
1023 if(KErrNone != ret) |
|
1024 { |
|
1025 result = ret; |
|
1026 break; |
|
1027 } |
|
1028 RSgImage anotherImage; |
|
1029 anotherImage = image; |
|
1030 image.Close(); |
|
1031 |
|
1032 anotherImage.MapReadWrite(dataAddressWrite, dataStride); //should panic with SGRES 3 |
|
1033 SgDriver::Close(); |
|
1034 } |
|
1035 break; |
|
1036 case ESgresSecondThreadPanicImageMapReadWriteNoDriver: |
|
1037 { |
|
1038 RSgImage image; |
|
1039 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); |
|
1040 if(KErrNone != ret) |
|
1041 { |
|
1042 result = ret; |
|
1043 break; |
|
1044 } |
|
1045 RSgImage anotherImage; |
|
1046 anotherImage = image; |
|
1047 image.Close(); |
|
1048 SgDriver::Close(); |
|
1049 anotherImage.MapReadWrite(dataAddressWrite, dataStride); // should panic with SGRES 5 |
|
1050 } |
|
1051 break; |
|
1052 case ESgresSecondThreadPanicImageUnmapInvalidHandle: |
|
1053 { |
|
1054 RSgImage image; |
|
1055 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); |
|
1056 if(KErrNone != ret) |
|
1057 { |
|
1058 result = ret; |
|
1059 break; |
|
1060 } |
|
1061 RSgImage anotherImage; |
|
1062 anotherImage = image; |
|
1063 image.Close(); |
|
1064 |
|
1065 anotherImage.Unmap(); //should panic with SGRES 3 |
|
1066 SgDriver::Close(); |
|
1067 } |
|
1068 break; |
|
1069 case ESgresSecondThreadPanicImageUnmapNoDriver: |
|
1070 { |
|
1071 RSgImage image; |
|
1072 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); |
|
1073 if(KErrNone != ret) |
|
1074 { |
|
1075 result = ret; |
|
1076 break; |
|
1077 } |
|
1078 RSgImage anotherImage; |
|
1079 anotherImage = image; |
|
1080 image.Close(); |
|
1081 SgDriver::Close(); |
|
1082 anotherImage.Unmap(); // should panic with SGRES 5 |
|
1083 } |
|
1084 break; |
|
1085 case ESgresSecondThreadPanicImageCollectionCloseInvalidHandle: |
|
1086 { |
|
1087 RSgImageCollection collection; |
|
1088 TInt ret = CreateImageCollectionWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, EFalse, ESgCpuAccessReadWrite, collection); |
|
1089 if(KErrNone != ret) |
|
1090 { |
|
1091 result = ret; |
|
1092 break; |
|
1093 } |
|
1094 |
|
1095 RSgImageCollection anotherCollection; |
|
1096 anotherCollection = collection; |
|
1097 collection.Close(); |
|
1098 anotherCollection.Close(); //should panic with SGRES 4 |
|
1099 SgDriver::Close(); |
|
1100 } |
|
1101 break; |
|
1102 case ESgresSecondThreadPanicImageCollectionCloseNoDriver: |
|
1103 { |
|
1104 RSgImageCollection collection; |
|
1105 TInt ret = CreateImageCollectionWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, EFalse, ESgCpuAccessReadWrite, collection); |
|
1106 if(KErrNone != ret) |
|
1107 { |
|
1108 result = ret; |
|
1109 break; |
|
1110 } |
|
1111 |
|
1112 RSgImageCollection anotherCollection; |
|
1113 anotherCollection = collection; |
|
1114 collection.Close(); |
|
1115 SgDriver::Close(); |
|
1116 anotherCollection.Close(); // should panic with SGRES 5 |
|
1117 } |
|
1118 break; |
|
1119 case ESgresSecondThreadPanicImageCollectionSurfaceIdInvalidHandle: |
|
1120 { |
|
1121 RSgImageCollection collection; |
|
1122 TInt ret = CreateImageCollectionWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, EFalse, ESgCpuAccessReadWrite, collection); |
|
1123 if(KErrNone != ret) |
|
1124 { |
|
1125 result = ret; |
|
1126 break; |
|
1127 } |
|
1128 |
|
1129 RSgImageCollection anotherCollection; |
|
1130 anotherCollection = collection; |
|
1131 collection.Close(); |
|
1132 anotherCollection.SurfaceId(); //should panic with SGRES 4 |
|
1133 SgDriver::Close(); |
|
1134 } |
|
1135 break; |
|
1136 case ESgresSecondThreadPanicImageCollectionSurfaceIdNoDriver: |
|
1137 { |
|
1138 RSgImageCollection collection; |
|
1139 TInt ret = CreateImageCollectionWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, EFalse, ESgCpuAccessReadWrite, collection); |
|
1140 if(KErrNone != ret) |
|
1141 { |
|
1142 result = ret; |
|
1143 break; |
|
1144 } |
|
1145 |
|
1146 RSgImageCollection anotherCollection; |
|
1147 anotherCollection = collection; |
|
1148 collection.Close(); |
|
1149 SgDriver::Close(); |
|
1150 anotherCollection.SurfaceId(); // should panic with SGRES 5 |
|
1151 } |
|
1152 break; |
|
1153 case ESgresSecondThreadPanicImageCollectionGetInfoInvalidHandle: |
|
1154 { |
|
1155 RSgImageCollection collection; |
|
1156 TInt ret = CreateImageCollectionWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, EFalse, ESgCpuAccessReadWrite, collection); |
|
1157 if(KErrNone != ret) |
|
1158 { |
|
1159 result = ret; |
|
1160 break; |
|
1161 } |
|
1162 |
|
1163 RSgImageCollection anotherCollection; |
|
1164 anotherCollection = collection; |
|
1165 collection.Close(); |
|
1166 TSgImageInfo anotherInfo; |
|
1167 anotherCollection.GetInfo(anotherInfo); //should panic with SGRES 4 |
|
1168 SgDriver::Close(); |
|
1169 } |
|
1170 break; |
|
1171 case ESgresSecondThreadPanicImageCollectionGetInfoNoDriver: |
|
1172 { |
|
1173 RSgImageCollection collection; |
|
1174 TInt ret = CreateImageCollectionWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, EFalse, ESgCpuAccessReadWrite, collection); |
|
1175 if(KErrNone != ret) |
|
1176 { |
|
1177 result = ret; |
|
1178 break; |
|
1179 } |
|
1180 |
|
1181 RSgImageCollection anotherCollection; |
|
1182 anotherCollection = collection; |
|
1183 collection.Close(); |
|
1184 TSgImageInfo anotherInfo; |
|
1185 SgDriver::Close(); |
|
1186 anotherCollection.GetInfo(anotherInfo); // should panic with SGRES 5 |
|
1187 } |
|
1188 break; |
|
1189 case ESgresSecondThreadPanicImageCollectionCountInvalidHandle: |
|
1190 { |
|
1191 RSgImageCollection collection; |
|
1192 TInt ret = CreateImageCollectionWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, EFalse, ESgCpuAccessReadWrite, collection); |
|
1193 if(KErrNone != ret) |
|
1194 { |
|
1195 result = ret; |
|
1196 break; |
|
1197 } |
|
1198 |
|
1199 RSgImageCollection anotherCollection; |
|
1200 anotherCollection = collection; |
|
1201 collection.Close(); |
|
1202 anotherCollection.Count(); //should panic with SGRES 4 |
|
1203 SgDriver::Close(); |
|
1204 } |
|
1205 break; |
|
1206 case ESgresSecondThreadPanicImageCollectionCountNoDriver: |
|
1207 { |
|
1208 RSgImageCollection collection; |
|
1209 TInt ret = CreateImageCollectionWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, EFalse, ESgCpuAccessReadWrite, collection); |
|
1210 if(KErrNone != ret) |
|
1211 { |
|
1212 result = ret; |
|
1213 break; |
|
1214 } |
|
1215 |
|
1216 RSgImageCollection anotherCollection; |
|
1217 anotherCollection = collection; |
|
1218 collection.Close(); |
|
1219 SgDriver::Close(); |
|
1220 anotherCollection.Count(); // should panic with SGRES 5 |
|
1221 } |
|
1222 break; |
|
1223 case ESgresSecondThreadPanicImageCollectionOpenImageInvalidHandle: |
|
1224 { |
|
1225 RSgImageCollection collection; |
|
1226 TInt ret = CreateImageCollectionWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, EFalse, ESgCpuAccessReadWrite, collection); |
|
1227 if(KErrNone != ret) |
|
1228 { |
|
1229 result = ret; |
|
1230 break; |
|
1231 } |
|
1232 |
|
1233 RSgImageCollection anotherCollection; |
|
1234 anotherCollection = collection; |
|
1235 collection.Close(); |
|
1236 RSgImage image; |
|
1237 anotherCollection.OpenImage(0, image); //should panic with SGRES 4 |
|
1238 SgDriver::Close(); |
|
1239 } |
|
1240 break; |
|
1241 case ESgresSecondThreadPanicImageCollectionOpenImageNoDriver: |
|
1242 { |
|
1243 RSgImageCollection collection; |
|
1244 TInt ret = CreateImageCollectionWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, EFalse, ESgCpuAccessReadWrite, collection); |
|
1245 if(KErrNone != ret) |
|
1246 { |
|
1247 result = ret; |
|
1248 break; |
|
1249 } |
|
1250 |
|
1251 RSgImageCollection anotherCollection; |
|
1252 anotherCollection = collection; |
|
1253 collection.Close(); |
|
1254 RSgImage image; |
|
1255 SgDriver::Close(); |
|
1256 anotherCollection.OpenImage(0, image); // should panic with SGRES 5 |
|
1257 } |
|
1258 break; |
|
1259 case ESgresMultipleThreadStressTest: |
|
1260 { |
|
1261 for (TInt i = 0; i < 1000 && result == KErrNone; ++i) |
|
1262 { |
|
1263 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); |
|
1264 if (KErrNone != ret) |
|
1265 { |
|
1266 result = ret; |
|
1267 break; |
|
1268 } |
|
1269 const TInt KMaxOpenCount = 100; |
|
1270 RSgImage images[KMaxOpenCount]; |
|
1271 TInt count = Math::Random() % KMaxOpenCount; |
|
1272 for (TInt k = 0; k < count; ++k) |
|
1273 { |
|
1274 ret = images[k].Open(((TSgresTestInfo*)aInfo)->iDrawableId); |
|
1275 if (KErrNone != ret) |
|
1276 { |
|
1277 result = ret; |
|
1278 break; |
|
1279 } |
|
1280 } |
|
1281 image.Close(); |
|
1282 for (TInt k = 0; k < count; ++k) |
|
1283 { |
|
1284 images[k].Close(); |
|
1285 } |
|
1286 } |
|
1287 } |
|
1288 break; |
|
1289 }; |
|
1290 } |
|
1291 image.Close(); |
|
1292 drawable.Close(); |
|
1293 SgDriver::Close(); |
|
1294 if (KErrNone == openSem) |
|
1295 { |
|
1296 sem.Signal(); |
|
1297 } |
|
1298 __UHEAP_MARKEND; |
|
1299 sem.Close(); |
|
1300 TInt procHandles2 =0; |
|
1301 TInt threadHandles2=0; |
|
1302 RThread().HandleCount(procHandles2,threadHandles2); |
|
1303 if (threadHandles1 != threadHandles2) |
|
1304 { |
|
1305 result = KErrGeneral; // Thread-owned handles not closed |
|
1306 } |
|
1307 |
|
1308 return result; |
|
1309 } |
|
1310 |
|
1311 /** |
|
1312 Static function used by the cleanup item to close the driver. |
|
1313 */ |
|
1314 void CTSgTestStepBase::CloseDriverWhenLeave(TAny* /*aInfo*/) |
|
1315 { |
|
1316 SgDriver::Close(); |
|
1317 } |
|
1318 |
|
1319 /** |
|
1320 Checks the function for the passed error codes and logs an error if the codes do not match. |
|
1321 If the test is running out of memory tests, KErrNoMemory is also an expected error code and |
|
1322 the function would just leave with KErrNoMemory in that case. |
|
1323 |
|
1324 @param aExpectedErrorCode The expected error code to check against |
|
1325 @param aActualErrorCode The actual error code |
|
1326 @param aFile The filename to use when reporting the error |
|
1327 @param aLine The line number to use when reporting the error |
|
1328 */ |
|
1329 void CTSgTestStepBase::CheckErrorL(TInt aExpectedErrorCode, TInt aActualErrorCode, const TText8* aFile, TInt aLine) |
|
1330 { |
|
1331 if(iRunningOomTests && KErrNoMemory == aActualErrorCode) |
|
1332 { |
|
1333 User::Leave(KErrNoMemory); |
|
1334 } |
|
1335 TESTWITHFILENAMEANDLINENUMBERL(aExpectedErrorCode == aActualErrorCode, aFile, aLine); |
|
1336 } |
|
1337 |
|
1338 /** |
|
1339 Out of memory tests. |
|
1340 */ |
|
1341 void CTSgTestStepBase::TestOOM() |
|
1342 { |
|
1343 SgDriver::Open(); |
|
1344 TInt err = KErrNone; |
|
1345 TInt tryCount = 0; |
|
1346 iRunningOomTests = ETrue; |
|
1347 do |
|
1348 { |
|
1349 SgDriver::SetAllocFail(RAllocator::EFailNext, ++tryCount); |
|
1350 TRAP(err, DoMemoryTestsL()); |
|
1351 } |
|
1352 while(err == KErrNoMemory); |
|
1353 |
|
1354 SgDriver::SetAllocFail(RAllocator::ENone, 0); |
|
1355 iRunningOomTests = EFalse; |
|
1356 SgDriver::Close(); |
|
1357 INFO_PRINTF2(_L("- server succeeded at private heap failure rate of %i\n"), tryCount); |
|
1358 } |
|
1359 |
|
1360 /** |
|
1361 Specifies which functions to run in out of memory conditions. |
|
1362 To be overridden by the derived test classes. |
|
1363 */ |
|
1364 void CTSgTestStepBase::DoMemoryTestsL() |
|
1365 { |
|
1366 } |