|
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 - Graphics Resource API Conformance Test Suite |
|
20 */ |
|
21 |
|
22 |
|
23 #include "tsgimagegeneric.h" |
|
24 |
|
25 #include <e32math.h> |
|
26 |
|
27 CTSgImageGeneric::CTSgImageGeneric(TBool aConformanceTests) : |
|
28 CTSgTestStepBase(aConformanceTests) |
|
29 { |
|
30 INFO_PRINTF1(_L("Graphics resource component test - RSgImage Generic Tests.\r\n")); |
|
31 } |
|
32 |
|
33 CTSgImageGeneric::~CTSgImageGeneric() |
|
34 { |
|
35 DestroyImages(); |
|
36 } |
|
37 |
|
38 void CTSgImageGeneric::DestroyImages() |
|
39 { |
|
40 TInt count = iTestImages.Count(); |
|
41 for(TInt i=0; i<count; ++i) |
|
42 { |
|
43 iTestImages[i].Close(); |
|
44 } |
|
45 iTestImages.Reset(); |
|
46 } |
|
47 |
|
48 /** |
|
49 Overrides of base class pure virtual |
|
50 Our implementation only gets called if the base class doTestStepPreambleL() did |
|
51 not leave. That being the case, the current test result value will be EPass. |
|
52 @leave Gets system wide error code |
|
53 @return TVerdict code |
|
54 */ |
|
55 TVerdict CTSgImageGeneric::doTestStepL() |
|
56 { |
|
57 SetTestStepID(_L("GRAPHICS-RESOURCE-0003")); |
|
58 INFO_PRINTF1(_L("Getting pixel formats supported on all platforms.\r\n")); |
|
59 TestGetPixelFormatsL(); |
|
60 RecordTestResultL(); |
|
61 |
|
62 SetTestStepID(_L("GRAPHICS-RESOURCE-0004")); |
|
63 INFO_PRINTF1(_L("Create an uninitialised image.\r\n")); |
|
64 TestCreateImageUninitializedL(); |
|
65 RecordTestResultL(); |
|
66 |
|
67 SetTestStepID(_L("GRAPHICS-RESOURCE-0005")); |
|
68 INFO_PRINTF1(_L("Create an image from a block of memory.\r\n")); |
|
69 TestCreateImageL(); |
|
70 RecordTestResultL(); |
|
71 |
|
72 SetTestStepID(_L("GRAPHICS-RESOURCE-0011")); |
|
73 INFO_PRINTF1(_L("Ensure all mandatory image pixel formats supported.\r\n")); |
|
74 TestCreateImageAllPixelFormatsL(); |
|
75 RecordTestResultL(); |
|
76 |
|
77 SetTestStepID(_L("GRAPHICS-RESOURCE-0006")); |
|
78 INFO_PRINTF1(_L("Create an image from an existing image.\r\n")); |
|
79 TestCreateImageFromExistingImageL(); |
|
80 RecordTestResultL(); |
|
81 |
|
82 SetTestStepID(_L("GRAPHICS-RESOURCE-0007")); |
|
83 INFO_PRINTF1(_L("Getting information about the image.\r\n")); |
|
84 TestGetImageInfoL(); |
|
85 RecordTestResultL(); |
|
86 |
|
87 SetTestStepID(_L("GRAPHICS-RESOURCE-0008")); |
|
88 INFO_PRINTF1(_L("Retrieving drawable id of an image.\r\n")); |
|
89 TestGetImageDrawableIdL(); |
|
90 RecordTestResultL(); |
|
91 |
|
92 SetTestStepID(_L("GRAPHICS-RESOURCE-0010")); |
|
93 INFO_PRINTF1(_L("Opening a handle to an image in both the current process and another process.\r\n")); |
|
94 TestOpenImageL(); |
|
95 RecordTestResultL(); |
|
96 |
|
97 SetTestStepID(_L("GRAPHICS-RESOURCE-0100")); |
|
98 INFO_PRINTF1(_L("Creating images with negative and invalid data strides.\r\n")); |
|
99 TestCreateImageDataStrideL(); |
|
100 RecordTestResultL(); |
|
101 |
|
102 SetTestStepID(_L("GRAPHICS-RESOURCE-0044")); |
|
103 INFO_PRINTF1(_L("Getting the available interfaces from an image.\r\n")); |
|
104 TestGetInterfaceL(); |
|
105 RecordTestResultL(); |
|
106 |
|
107 SetTestStepID(_L("GRAPHICS-RESOURCE-0024")); |
|
108 INFO_PRINTF1(_L("Getting supported pixel formats with invalid parameters.\r\n")); |
|
109 TestGetPixelFormatsInvalidL(); |
|
110 RecordTestResultL(); |
|
111 |
|
112 SetTestStepID(_L("GRAPHICS-RESOURCE-0025")); |
|
113 INFO_PRINTF1(_L("Opening an image with different invalid parameters.\r\n")); |
|
114 TestOpenImageInvalidL(); |
|
115 RecordTestResultL(); |
|
116 |
|
117 SetTestStepID(_L("GRAPHICS-RESOURCE-0026")); |
|
118 INFO_PRINTF1(_L("Closing the handle to an image object multiple times.\r\n")); |
|
119 TestCloseImageManyTimesL(); |
|
120 RecordTestResultL(); |
|
121 |
|
122 SetTestStepID(_L("GRAPHICS-RESOURCE-0027")); |
|
123 INFO_PRINTF1(_L("Closing the handle to an image object without opening it.\r\n")); |
|
124 TestCloseImageWithoutOpenL(); |
|
125 RecordTestResultL(); |
|
126 |
|
127 SetTestStepID(_L("GRAPHICS-RESOURCE-0028")); |
|
128 INFO_PRINTF1(_L("Creating an image with various invalid parameters.\r\n")); |
|
129 TestCreateImageInvalidL(); |
|
130 RecordTestResultL(); |
|
131 |
|
132 SetTestStepID(_L("GRAPHICS-RESOURCE-0039")); |
|
133 INFO_PRINTF1(_L("Getting information about an invalid image.\r\n")); |
|
134 TestGetInfoImageInvalidL(); |
|
135 RecordTestResultL(); |
|
136 |
|
137 SetTestStepID(_L("GRAPHICS-RESOURCE-0092")); |
|
138 INFO_PRINTF1(_L("Getting Attributes about an invalid image.\r\n")); |
|
139 TestGetAttributesImageInvalidL(); |
|
140 RecordTestResultL(); |
|
141 |
|
142 SetTestStepID(_L("GRAPHICS-RESOURCE-0048")); |
|
143 INFO_PRINTF1(_L("RSgImage generic stress test.\r\n")); |
|
144 TestStress1L(); |
|
145 RecordTestResultL(); |
|
146 |
|
147 SetTestStepID(_L("GRAPHICS-RESOURCE-0049")); |
|
148 INFO_PRINTF1(_L("RSgImage generic multi-thread stress test.\r\n")); |
|
149 TestStress2L(); |
|
150 RecordTestResultL(); |
|
151 |
|
152 SetTestStepID(_L("GRAPHICS-RESOURCE-0104")); |
|
153 INFO_PRINTF1(_L("Opening a RSgImage in a second process with multiple threads.\r\n")); |
|
154 TestOpenImageMultithreadedL(); |
|
155 RecordTestResultL(); |
|
156 |
|
157 #ifdef _DEBUG |
|
158 |
|
159 SetTestStepID(_L("GRAPHICS-RESOURCE-0052")); |
|
160 INFO_PRINTF1(_L("RSgImage generic panic test - GetInterface() with non null image handle and uninitialised driver\r\n")); |
|
161 TestPanicImageGetInterfaceNoDriverL(); |
|
162 RecordTestResultL(); |
|
163 |
|
164 SetTestStepID(_L("GRAPHICS-RESOURCE-0054")); |
|
165 INFO_PRINTF1(_L("RSgImage generic panic test - Close() with non null image handle and uninitialised driver\r\n")); |
|
166 TestPanicImageCloseNoDriverL(); |
|
167 RecordTestResultL(); |
|
168 |
|
169 SetTestStepID(_L("GRAPHICS-RESOURCE-0056")); |
|
170 INFO_PRINTF1(_L("RSgImage generic panic test - Id() with non null image handle and uninitialised driver\r\n")); |
|
171 TestPanicImageIdNoDriverL(); |
|
172 RecordTestResultL(); |
|
173 |
|
174 SetTestStepID(_L("GRAPHICS-RESOURCE-0059")); |
|
175 INFO_PRINTF1(_L("RSgImage generic panic test - GetInfo() with non null image handle and uninitialised driver\r\n")); |
|
176 TestPanicImageGetInfoNoDriverL(); |
|
177 RecordTestResultL(); |
|
178 |
|
179 SetTestStepID(_L("GRAPHICS-RESOURCE-0082")); |
|
180 INFO_PRINTF1(_L("RSgImage generic panic test - Open() with an uninitialised driver\r\n")); |
|
181 TestPanicImageOpenNoDriverL(); |
|
182 RecordTestResultL(); |
|
183 |
|
184 SetTestStepID(_L("GRAPHICS-RESOURCE-0083")); |
|
185 INFO_PRINTF1(_L("RSgImage generic panic test - Create() from memory with an uninitialised driver\r\n")); |
|
186 TestPanicImageCreateNoDriver1L(); |
|
187 RecordTestResultL(); |
|
188 |
|
189 SetTestStepID(_L("GRAPHICS-RESOURCE-0084")); |
|
190 INFO_PRINTF1(_L("RSgImage generic panic test - Create() from existing image with an uninitialised driver\r\n")); |
|
191 TestPanicImageCreateNoDriver2L(); |
|
192 RecordTestResultL(); |
|
193 |
|
194 SetTestStepID(_L("GRAPHICS-RESOURCE-0088")); |
|
195 INFO_PRINTF1(_L("RSgImage generic panic test - DrawableType() with an uninitialised driver\r\n")); |
|
196 TestPanicImageDrawableTypeNoDriverL(); |
|
197 RecordTestResultL(); |
|
198 |
|
199 INFO_PRINTF1(_L("RSgImage generic panic test - GetAttribute() with an uninitialised driver\r\n")); |
|
200 TestPanicImageGetAttributeNoDriverL(); |
|
201 RecordTestResultL(); |
|
202 |
|
203 SetTestStepID(_L("GRAPHICS-RESOURCE-0097")); |
|
204 INFO_PRINTF1(_L("RSgAttributeArray generic panic test - Out of bounds array index specified\r\n")); |
|
205 TestPanicImageAttributeArrayInvalidIndexL(); |
|
206 RecordTestResultL(); |
|
207 |
|
208 SetTestStepID(_L("GRAPHICS-RESOURCE-0098")); |
|
209 INFO_PRINTF1(_L("RSgAttributeArray generic panic test - Out of bounds array index specified\r\n")); |
|
210 TestPanicImageAttributeArrayInvalidIndex2L(); |
|
211 RecordTestResultL(); |
|
212 |
|
213 SetTestStepID(_L("GRAPHICS-RESOURCE-0102")); |
|
214 INFO_PRINTF1(_L("RSgDriver/RSgImage multi processs Create, Open and Close test\r\n")); |
|
215 TestCreateOpenCloseImageAndDriverInSecondThreadL(); |
|
216 RecordTestResultL(); |
|
217 |
|
218 SetTestStepID(_L("GRAPHICS-RESOURCE-0052")); |
|
219 INFO_PRINTF1(_L("RSgImage generic panic test - GetInterface() with invalid image handle\r\n")); |
|
220 TestPanicImageGetInterfaceInvalidHandleL(); |
|
221 RecordTestResultL(); |
|
222 |
|
223 SetTestStepID(_L("GRAPHICS-RESOURCE-0053")); |
|
224 INFO_PRINTF1(_L("RSgImage generic panic test - Close() with invalid image handle\r\n")); |
|
225 TestPanicImageCloseInvalidHandleL(); |
|
226 RecordTestResultL(); |
|
227 |
|
228 SetTestStepID(_L("GRAPHICS-RESOURCE-0055")); |
|
229 INFO_PRINTF1(_L("RSgImage generic panic test - Id() with invalid image handle\r\n")); |
|
230 TestPanicImageIdInvalidHandleL(); |
|
231 RecordTestResultL(); |
|
232 |
|
233 SetTestStepID(_L("GRAPHICS-RESOURCE-0057")); |
|
234 INFO_PRINTF1(_L("RSgImage generic panic test - Create() with invalid image handle\r\n")); |
|
235 TestPanicImageCreateInvalidHandleL(); |
|
236 RecordTestResultL(); |
|
237 |
|
238 SetTestStepID(_L("GRAPHICS-RESOURCE-0058")); |
|
239 INFO_PRINTF1(_L("RSgImage generic panic test - GetInfo() with invalid image handle\r\n")); |
|
240 TestPanicImageGetInfoInvalidHandleL(); |
|
241 RecordTestResultL(); |
|
242 |
|
243 SetTestStepID(_L("GRAPHICS-RESOURCE-0089")); |
|
244 INFO_PRINTF1(_L("RSgImage generic panic test - DrawableType() with invalid image handle\r\n")); |
|
245 TestPanicImageDrawableTypeInvalidHandleL(); |
|
246 RecordTestResultL(); |
|
247 |
|
248 INFO_PRINTF1(_L("RSgImage generic panic test - GetInfo() with invalid image handle\r\n")); |
|
249 TestPanicImageGetAttributeInvalidHandleL(); |
|
250 RecordTestResultL(); |
|
251 |
|
252 SetTestStepID(_L("GRAPHICS-RESOURCE-0101")); |
|
253 INFO_PRINTF1(_L("RSgDriver generic panic test - Closing a driver with open resources\r\n")); |
|
254 TestPanicDriverCloseOpenResourcesL(); |
|
255 RecordTestResultL(); |
|
256 #else |
|
257 INFO_PRINTF1(_L("Warning: Skipping the panic tests in release build. \r\n")); |
|
258 #endif |
|
259 return TestStepResult(); |
|
260 } |
|
261 |
|
262 |
|
263 /** |
|
264 @SYMTestCaseID GRAPHICS-RESOURCE-0003 |
|
265 @SYMTestCaseDesc Gets supported pixel formats on all platforms. |
|
266 @SYMPREQ PREQ2637 |
|
267 @SYMFssID RSgImage::GetPixelFormats(const TSgImageInfo&, TUidPixelFormat*, TInt&) |
|
268 @SYMTestPriority High |
|
269 @SYMTestType UT |
|
270 @SYMTestPurpose To ensure all the available pixel formats are returned |
|
271 in the array. |
|
272 @SYMTestActions Initialise the graphics resource component. |
|
273 Construct an RArray to recieve the pixel formats. |
|
274 1. Retrieve pixel formats with an RArray<TInt>. Check the array size. |
|
275 2. Retrieve pixel formats when using an invalid usage bit value. |
|
276 3. Retrieve pixel formats supporting OpenGL ES. |
|
277 4. Retrieve pixel formats supporting OpenGL ES 2. |
|
278 5. Ensure the mandated pixel formats are available |
|
279 @SYMTestExpectedResults The function must return: |
|
280 1. KErrNone |
|
281 2. KErrNone, but zero entries in the returned array. |
|
282 3. KErrNone, and a non-zero array size. |
|
283 4. KErrNone, and a non-zero array size. |
|
284 5. The returned pixel formats should cover the pixel formats |
|
285 in the image compatibility table that works on all platforms. |
|
286 */ |
|
287 void CTSgImageGeneric::TestGetPixelFormatsL() |
|
288 { |
|
289 TestOpenDriverL(); |
|
290 |
|
291 //Retrieve the pixel formats |
|
292 RArray<TInt> pixelFormatArray; |
|
293 CheckErrorL(KErrNone, RSgImage::GetPixelFormats(ESgUsageBitOpenVgImage, pixelFormatArray), (TText8*)__FILE__, __LINE__); |
|
294 TEST(pixelFormatArray.Count() > 0); |
|
295 pixelFormatArray.Reset(); |
|
296 |
|
297 // invalid usage bit |
|
298 const TInt KInvalidUsageBit = 0x1000; |
|
299 CheckErrorL(KErrNone, RSgImage::GetPixelFormats(KInvalidUsageBit, pixelFormatArray), (TText8*)__FILE__, __LINE__); |
|
300 TEST(pixelFormatArray.Count() == 0); |
|
301 pixelFormatArray.Reset(); |
|
302 |
|
303 //check all the pixel formats returned are in the common compatibility guarantees table |
|
304 TestGetPixelFormatCompatibilityGuaranteesL(); |
|
305 |
|
306 TestCloseDriver(); |
|
307 } |
|
308 |
|
309 /** |
|
310 @SYMTestCaseID GRAPHICS-RESOURCE-0004 |
|
311 @SYMTestCaseDesc Creates an uninitialised image. |
|
312 @SYMPREQ PREQ2637 |
|
313 @SYMFssID RSgImage::Create(const TSgImageInfo&, const TAny*, TInt) |
|
314 RSgImage::IsNull() |
|
315 @SYMTestPriority Critical |
|
316 @SYMTestType UT |
|
317 @SYMTestPurpose To ensure an uninitialised image can be created. |
|
318 @SYMTestActions Initialise the graphics resource component. |
|
319 Construct a well-defined TSgImageInfo object to work on all platforms. |
|
320 Create an image with a NULL base address for the TSgImageInfo object. |
|
321 @SYMTestExpectedResults Create() should return KErrNone in all cases. |
|
322 The image data in the created images is uninitialised. |
|
323 */ |
|
324 void CTSgImageGeneric::TestCreateImageUninitializedL() |
|
325 { |
|
326 TestOpenDriverL(); |
|
327 TSgImageInfo info; |
|
328 info.iSizeInPixels = TSize(100, 100); |
|
329 info.iUsage = ESgUsageBitOpenVgImage; |
|
330 info.iPixelFormat = EUidPixelFormatRGB_565; |
|
331 |
|
332 RSgImage image; |
|
333 CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__); |
|
334 TEST(!image.IsNull()); |
|
335 image.Close(); |
|
336 |
|
337 TestCloseDriver(); |
|
338 } |
|
339 |
|
340 |
|
341 /** |
|
342 @SYMTestCaseID GRAPHICS-RESOURCE-0005 |
|
343 @SYMTestCaseDesc Creates an image from a block of memory. |
|
344 @SYMPREQ PREQ2637 |
|
345 @SYMFssID RSgImage::Create(const TSgImageInfo&, const TAny*, TInt) |
|
346 RSgImage::IsNull() |
|
347 @SYMTestPriority Critical |
|
348 @SYMTestType UT |
|
349 @SYMTestPurpose To ensure images can be created from a block of memory. |
|
350 @SYMTestActions Initialise the graphics resource component. |
|
351 Construct well-defined TSgImageInfo objects that work on all platforms. |
|
352 Create a block of memory with or without initialised data. |
|
353 Then create an image with the starting address of that memory. |
|
354 @SYMTestExpectedResults The function should return KErrNone in all cases. |
|
355 The user data starting at address aDataAddress will be populated into the new image. |
|
356 */ |
|
357 void CTSgImageGeneric::TestCreateImageL() |
|
358 { |
|
359 TestOpenDriverL(); |
|
360 TSgImageInfo info; |
|
361 info.iSizeInPixels = TSize(8, 8); |
|
362 info.iPixelFormat = EUidPixelFormatRGB_565; |
|
363 info.iUsage = ESgUsageBitOpenVgImage; |
|
364 |
|
365 RSgImage image; |
|
366 CheckErrorL(KErrNone, image.Create(info, KCrossImageData, KCrossImageDataStride), (TText8*)__FILE__, __LINE__); |
|
367 TEST(!image.IsNull()); |
|
368 image.Close(); |
|
369 |
|
370 //Ensure that it is possible to create an image of at least 2048x2048 |
|
371 RSgImage image2; |
|
372 TSgImageInfo info2; |
|
373 info2.iSizeInPixels = TSize(2048, 2048); |
|
374 info2.iPixelFormat = EUidPixelFormatXRGB_8888; |
|
375 info2.iUsage = ESgUsageBitOpenVgImage; |
|
376 |
|
377 TEST(KErrNone == image2.Create(info2)); |
|
378 image2.Close(); |
|
379 |
|
380 info2.iSizeInPixels = TSize(KDiagonalImageSize, KDiagonalImageSize); |
|
381 // This should create an image with a green diagonal from top-left to bottom-right on white background |
|
382 TEST(KErrNone == image.Create(info2, iDiagonalImageData, KDiagonalImageDataStride)); |
|
383 image.Close(); |
|
384 // This should create an image with a green diagonal from top-right to bottom-left on white background |
|
385 TEST(KErrNone == image.Create(info2, iDiagonalImageData, -KDiagonalImageDataStride)); |
|
386 image.Close(); |
|
387 |
|
388 TestCloseDriver(); |
|
389 } |
|
390 |
|
391 /** |
|
392 @SYMTestCaseID GRAPHICS-RESOURCE-0011 |
|
393 @SYMTestCaseDesc Creates an uninitialised image in all mandatory pixel formats. |
|
394 @SYMPREQ PREQ2637 |
|
395 @SYMFssID RSgImage::Create(const TSgImageInfo&, const TAny*, TInt) |
|
396 @SYMTestPriority High |
|
397 @SYMTestType UT |
|
398 @SYMTestPurpose To ensure all mandatory image pixel formats are supported. |
|
399 @SYMTestActions Initialise the graphics resource component. |
|
400 Create an image with a NULL base address for each mandatory pixel |
|
401 format of Graphics Resource implementations. |
|
402 @SYMTestExpectedResults The function should return KErrNone in all cases. |
|
403 */ |
|
404 void CTSgImageGeneric::TestCreateImageAllPixelFormatsL() |
|
405 { |
|
406 TestOpenDriverL(); |
|
407 |
|
408 RSgImage image; |
|
409 const TSize KImageSize = TSize(8, 8); |
|
410 const TUint32 KImageUsage = ESgUsageBitOpenVgImage; |
|
411 TInt err = KErrNone; |
|
412 |
|
413 err = image.Create(TSgImageInfo(KImageSize, EUidPixelFormatA_8, KImageUsage), NULL, 0); |
|
414 TESTE(err == KErrNone, err); |
|
415 TEST(!image.IsNull()); |
|
416 image.Close(); |
|
417 |
|
418 err = image.Create(TSgImageInfo(KImageSize, EUidPixelFormatRGB_565, KImageUsage), NULL, 0); |
|
419 TESTE(err == KErrNone, err); |
|
420 TEST(!image.IsNull()); |
|
421 image.Close(); |
|
422 |
|
423 err = image.Create(TSgImageInfo(KImageSize, EUidPixelFormatXRGB_8888, KImageUsage), NULL, 0); |
|
424 TESTE(err == KErrNone, err); |
|
425 TEST(!image.IsNull()); |
|
426 image.Close(); |
|
427 |
|
428 err = image.Create(TSgImageInfo(KImageSize, EUidPixelFormatARGB_8888, KImageUsage), NULL, 0); |
|
429 TESTE(err == KErrNone, err); |
|
430 TEST(!image.IsNull()); |
|
431 image.Close(); |
|
432 |
|
433 err = image.Create(TSgImageInfo(KImageSize, EUidPixelFormatARGB_8888_PRE, KImageUsage), NULL, 0); |
|
434 TESTE(err == KErrNone, err); |
|
435 TEST(!image.IsNull()); |
|
436 image.Close(); |
|
437 |
|
438 TestCloseDriver(); |
|
439 } |
|
440 |
|
441 /** |
|
442 @SYMTestCaseID GRAPHICS-RESOURCE-0006 |
|
443 @SYMTestCaseDesc Creates an image from an existing image. |
|
444 @SYMPREQ PREQ2637 |
|
445 @SYMFssID RSgImage::Create(const TSgImageInfo&, const RSgImage&) |
|
446 @SYMTestPriority Critical |
|
447 @SYMTestType UT |
|
448 @SYMTestPurpose To ensure images can be created from existing images. |
|
449 @SYMTestActions Initialise the graphics resource component. |
|
450 Create an image. |
|
451 Create another image with the attributes of this image as the TSgImageInfo. |
|
452 @SYMTestExpectedResults The function should return KErrNone. |
|
453 The new image should be identical to the old one. |
|
454 */ |
|
455 void CTSgImageGeneric::TestCreateImageFromExistingImageL() |
|
456 { |
|
457 RSgImage image1; |
|
458 RSgImage image2; |
|
459 TSgImageInfo info; |
|
460 info.iUsage = ESgUsageBitOpenVgImage; |
|
461 |
|
462 TestOpenDriverL(); |
|
463 CreateImageL(image1); |
|
464 CleanupClosePushL(image1); |
|
465 TEST(KErrNone == image1.GetInfo(info)); |
|
466 |
|
467 info.iUsage = ESgUsageBitOpenVgImage; |
|
468 CheckErrorL(KErrNone, image2.Create(info, image1), (TText8*)__FILE__, __LINE__); |
|
469 CleanupClosePushL(image2); |
|
470 TSgImageInfo info2; |
|
471 TEST(KErrNone == image2.GetInfo(info2)); |
|
472 TEST(CompareInfos(info, info2)); |
|
473 CleanupStack::PopAndDestroy(2); |
|
474 TestCloseDriver(); |
|
475 } |
|
476 |
|
477 |
|
478 /** |
|
479 @SYMTestCaseID GRAPHICS-RESOURCE-0007 |
|
480 @SYMTestCaseDesc Calls GetInfo on an image. |
|
481 @SYMPREQ PREQ2637 |
|
482 @SYMFssID RSgImage::GetInfo(TSgImageInfo&) |
|
483 @SYMTestPriority Critical |
|
484 @SYMTestType UT |
|
485 @SYMTestPurpose To ensure the information about the image is correct. |
|
486 @SYMTestActions Initialise the graphics resource component. |
|
487 Construct a TSgImageInfo object and initialise all the member variables. |
|
488 Call GetInfo() and compare the resulting TSgImageInfo objects with previous ones. |
|
489 @SYMTestExpectedResults The function should return KErrNone. |
|
490 Information about the image object is stored in the aInfo parameter. |
|
491 The retrieved TSgImageInfo objects should be identical to the original ones. |
|
492 */ |
|
493 void CTSgImageGeneric::TestGetImageInfoL() |
|
494 { |
|
495 TestOpenDriverL(); |
|
496 TSgImageInfo info; |
|
497 info.iPixelFormat = EUidPixelFormatRGB_565; |
|
498 info.iSizeInPixels = TSize(100, 100); |
|
499 info.iUsage = ESgUsageBitOpenVgImage; |
|
500 |
|
501 RSgImage image; |
|
502 CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__); |
|
503 CleanupClosePushL(image); |
|
504 |
|
505 TSgImageInfo info2; |
|
506 TEST(KErrNone == image.GetInfo(info2)); |
|
507 TEST(CompareInfos(info, info2)); |
|
508 CleanupStack::PopAndDestroy(); |
|
509 |
|
510 TestCloseDriver(); |
|
511 } |
|
512 |
|
513 /** |
|
514 @SYMTestCaseID GRAPHICS-RESOURCE-0008 |
|
515 @SYMTestCaseDesc Retrieves drawable id and drawable type of an image. |
|
516 @SYMPREQ PREQ2637 |
|
517 @SYMFssID RSgImage::Id() |
|
518 RSgImage::DrawableType() |
|
519 @SYMTestPriority Critical |
|
520 @SYMTestType UT |
|
521 @SYMTestPurpose To ensure the globally unique drawable id of the image can be retrieved. |
|
522 @SYMTestActions Initialise the graphics resource component. Create an image. Call |
|
523 Id() to retrieve its drawable id. |
|
524 @SYMTestExpectedResults A valid drawable id should be successfully returned when the image has been opened. |
|
525 KSgNullDrawableId should be returned if it has not; the default drawable type should |
|
526 be KNullUid. |
|
527 */ |
|
528 void CTSgImageGeneric::TestGetImageDrawableIdL() |
|
529 { |
|
530 RSgImage image; |
|
531 TEST(KNullUid == image.DrawableType()); |
|
532 TSgDrawableId id = image.Id(); |
|
533 TEST(id == KSgNullDrawableId); |
|
534 TestOpenDriverL(); |
|
535 |
|
536 CreateImageL(image); |
|
537 id = image.Id(); |
|
538 TEST(id != KSgNullDrawableId); |
|
539 TEST(KSgImageTypeUid == image.DrawableType()); |
|
540 |
|
541 image.Close(); |
|
542 TestCloseDriver(); |
|
543 } |
|
544 |
|
545 /** |
|
546 @SYMTestCaseID GRAPHICS-RESOURCE-0010 |
|
547 @SYMTestCaseDesc Opens a handle to an image in both the current process and another process. |
|
548 @SYMPREQ PREQ2637 |
|
549 @SYMFssID RSgImage::Open(const TSgDrawableId&) |
|
550 @SYMTestPriority Critical |
|
551 @SYMTestType UT |
|
552 @SYMTestPurpose To ensure image can be opened in both a second thread in the current |
|
553 process and another process. |
|
554 @SYMTestActions Initialise the graphics resource component. Create an image and call |
|
555 Open() on the image in the second thread in the current process and in |
|
556 another process. To ensure they are correct compare their Id and attributes. |
|
557 @SYMTestExpectedResults The function must return KErrNone in all cases. |
|
558 */ |
|
559 void CTSgImageGeneric::TestOpenImageL() |
|
560 { |
|
561 TestOpenDriverL(); |
|
562 |
|
563 RSgImage image1; |
|
564 TSgImageInfo info1; |
|
565 info1.iSizeInPixels = TSize(8, 8); |
|
566 info1.iUsage = ESgUsageBitOpenVgImage; |
|
567 info1.iPixelFormat = EUidPixelFormatRGB_565; |
|
568 CheckErrorL(KErrNone, image1.Create(info1, KCrossImageData, KCrossImageDataStride), (TText8*)__FILE__, __LINE__); |
|
569 |
|
570 const TSgDrawableId id1 = image1.Id(); |
|
571 |
|
572 //opening image in the current thread |
|
573 RSgImage image2; |
|
574 TEST(KErrNone == image2.Open(id1)); |
|
575 TEST(image1.Id() == image2.Id()); |
|
576 |
|
577 TSgImageInfo getInfo1; |
|
578 TSgImageInfo getInfo2; |
|
579 |
|
580 image1.GetInfo(getInfo1); |
|
581 image2.GetInfo(getInfo2); |
|
582 |
|
583 TEST(CompareInfos(getInfo1, getInfo2)); |
|
584 |
|
585 if (iEnableConformanceTests) |
|
586 { |
|
587 //opening image in a second thread in the current process |
|
588 TSgThreadTestInfo threadInfo(id1, info1, ESgresSecondThreadOpenImage); |
|
589 TInt testResult = 0; |
|
590 TRAPD(err, testResult = CreateSecondThreadAndDoTestL(threadInfo)); |
|
591 TEST(err == KErrNone); |
|
592 TEST(testResult >= 0); |
|
593 |
|
594 // Test the results from the second thread |
|
595 TEST(testResult & EFirstTestPassed); |
|
596 TEST(testResult & ESecondTestPassed); |
|
597 TEST(testResult & EThirdTestPassed); |
|
598 TEST(testResult & EFourthTestPassed); |
|
599 TEST(testResult & EFifthTestPassed); |
|
600 TEST(testResult & ESixthTestPassed); |
|
601 TEST(testResult & ESeventhTestPassed); |
|
602 TEST(testResult & EEighthTestPassed); |
|
603 |
|
604 //opening image in a second process |
|
605 TSgProcessTestInfo processInfo(id1, info1, ESgresSecondProcessOpenImage); |
|
606 TRAP(err, testResult = CreateSecondProcessAndDoTestL(KSecondProcess, processInfo)); |
|
607 TEST(err == KErrNone); |
|
608 TEST(testResult >= 0); |
|
609 |
|
610 TEST(testResult & EFirstTestPassed); |
|
611 TEST(testResult & ESecondTestPassed); |
|
612 TEST(testResult & EThirdTestPassed); |
|
613 TEST(testResult & EFourthTestPassed); |
|
614 TEST(testResult & EFifthTestPassed); |
|
615 TEST(testResult & ESixthTestPassed); |
|
616 TEST(testResult & ESeventhTestPassed); |
|
617 TEST(testResult & EEighthTestPassed); |
|
618 } |
|
619 |
|
620 image1.Close(); |
|
621 image2.Close(); |
|
622 |
|
623 TestCloseDriver(); |
|
624 } |
|
625 |
|
626 /** |
|
627 Fake RSgImage extension interface used in negative RSgImage::GetInterface() Tests |
|
628 */ |
|
629 class MFake |
|
630 { |
|
631 public: |
|
632 enum { EInterfaceUid = 0x88888888 }; |
|
633 }; |
|
634 |
|
635 class MFakeNullUid |
|
636 { |
|
637 public: |
|
638 enum { EInterfaceUid = KNullUidValue}; |
|
639 }; |
|
640 |
|
641 /** |
|
642 @SYMTestCaseID GRAPHICS-RESOURCE-0044 |
|
643 @SYMTestCaseDesc Gets an invalid/unsupported image extension interface |
|
644 @SYMPREQ PREQ2637 |
|
645 @SYMFssID RSgImage::Create(const TSgImageInfo&, const TAny*, TInt) |
|
646 RSgImage::GetInterface() |
|
647 @SYMTestPriority Low |
|
648 @SYMTestType UT |
|
649 @SYMTestPurpose Negative test to ensure the correct error code is returned when attempting |
|
650 to retrieve an invalid RSgImage extension interface. |
|
651 @SYMTestActions Initialise the graphics resource component. Create an image. |
|
652 1. Declare an unsupported interface MFake and pass to GetInterface(). |
|
653 2. Declare an interface MFakeNullUid which has a null uid and pass to GetInterface(). |
|
654 @SYMTestExpectedResults 1. GetInterface() should return KErrExtensionNotSupported. |
|
655 2. GetInterface() should return KErrArgument since null uids are not acceptable. |
|
656 */ |
|
657 void CTSgImageGeneric::TestGetInterfaceL() |
|
658 { |
|
659 TestOpenDriverL(); |
|
660 |
|
661 TSgImageInfo info; |
|
662 info.iSizeInPixels = TSize(8, 8); |
|
663 info.iUsage = ESgUsageBitOpenVgImage; |
|
664 info.iPixelFormat = EUidPixelFormatRGB_565; |
|
665 |
|
666 RSgImage image; |
|
667 |
|
668 //fake interface |
|
669 MFake* smFake = reinterpret_cast<MFake*>(1); |
|
670 MFake* smFake2 = reinterpret_cast<MFake*>(1); |
|
671 |
|
672 //Check Calls to Get Interface on Null Image Handle |
|
673 TEST(KErrBadHandle == image.GetInterface(smFake)); |
|
674 TEST(KErrBadHandle == image.GetInterface(smFake2)); |
|
675 TEST(!smFake); |
|
676 TEST(!smFake2); |
|
677 |
|
678 CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__); |
|
679 |
|
680 // check TSgDrawableId is not NULL |
|
681 TSgDrawableId id = image.Id(); |
|
682 TEST(KSgNullDrawableId != id); |
|
683 |
|
684 smFake = reinterpret_cast<MFake*>(1); |
|
685 smFake2 = reinterpret_cast<MFake*>(1); |
|
686 |
|
687 TEST(KErrExtensionNotSupported == image.GetInterface(smFake)); |
|
688 TEST(!smFake); |
|
689 |
|
690 TEST(KErrExtensionNotSupported == image.GetInterface(smFake2)); |
|
691 TEST(!smFake2); |
|
692 |
|
693 // null interface uid |
|
694 MFakeNullUid* smFake3 = NULL; |
|
695 TEST(KErrArgument == image.GetInterface(smFake3)); |
|
696 TEST(!smFake3); |
|
697 |
|
698 image.Close(); |
|
699 |
|
700 TestCloseDriver(); |
|
701 } |
|
702 |
|
703 /** |
|
704 @SYMTestCaseID GRAPHICS-RESOURCE-0024 |
|
705 @SYMTestCaseDesc Gets supported pixel formats with invalid parameters. |
|
706 @SYMPREQ PREQ2637 |
|
707 @SYMFssID RSgImage::GetPixelFormats(TUint32, RArray<TInt>, |
|
708 const TSgAttributeArrayBase*) |
|
709 @SYMTestPriority Low |
|
710 @SYMTestType UT |
|
711 @SYMTestPurpose Negative test to ensure the correct error messages are returned when user tries to |
|
712 call GetPixelFormats() with invalid parameters. |
|
713 @SYMTestActions Initialise the graphics resource component. Call RSgImage::GetPixelFormats with: |
|
714 1. Usage of 0 |
|
715 2. Invalid attribute array |
|
716 3. Valid arguments |
|
717 4. Pixel formats array is not empty |
|
718 @SYMTestExpectedResults RSgImage::GetPixelFormats() should return: |
|
719 1. KErrArgument |
|
720 2. KErrNotSupported |
|
721 3. KErrNone |
|
722 4. KErrArgument |
|
723 */ |
|
724 void CTSgImageGeneric::TestGetPixelFormatsInvalidL() |
|
725 { |
|
726 RArray<TInt> pixelFormats; |
|
727 CleanupClosePushL(pixelFormats); |
|
728 TSgAttributeArray<1> attribArray; |
|
729 attribArray[0].iUid = KNullUid; |
|
730 attribArray[0].iValue = 0; |
|
731 TEST(attribArray.Count() == 1); |
|
732 |
|
733 TestOpenDriverL(); |
|
734 |
|
735 TEST(KErrArgument == RSgImage::GetPixelFormats(0, pixelFormats)); |
|
736 pixelFormats.Reset(); |
|
737 |
|
738 TEST(KErrNotSupported == RSgImage::GetPixelFormats(ESgUsageBitOpenVgImage, pixelFormats, &attribArray)); |
|
739 pixelFormats.Reset(); |
|
740 |
|
741 TEST(KErrNone == RSgImage::GetPixelFormats(ESgUsageBitOpenVgImage, pixelFormats)); |
|
742 TEST(pixelFormats.Count() > 0); |
|
743 //Don't reset pixel formats for next test |
|
744 |
|
745 TEST(KErrArgument == RSgImage::GetPixelFormats(ESgUsageBitOpenVgImage, pixelFormats)); |
|
746 pixelFormats.Reset(); |
|
747 |
|
748 TestCloseDriver(); |
|
749 CleanupStack::PopAndDestroy(&pixelFormats); |
|
750 } |
|
751 |
|
752 /** |
|
753 @SYMTestCaseID GRAPHICS-RESOURCE-0025 |
|
754 @SYMTestCaseDesc Opens an image with different invalid and valid parameters. |
|
755 @SYMPREQ PREQ2637 |
|
756 @SYMFssID RSgImage::Open(const TSgDrawableId&) |
|
757 @SYMTestPriority Medium |
|
758 @SYMTestType UT |
|
759 @SYMTestPurpose Negative test to check correct error messages are returned when opening |
|
760 image with different invalid parameters. |
|
761 @SYMTestActions Initialise the graphics resource component. Construct an RSgImage object. |
|
762 Call the Open() function in both the current process and another process with: |
|
763 1. a non-null RSgImage handle |
|
764 2. null drawable id |
|
765 3. fake drawable id |
|
766 4. a valid RSgImage handle |
|
767 Do the same tests in a second thread and a second process. |
|
768 @SYMTestExpectedResults The function should return: |
|
769 1. KErrInUse |
|
770 2. KErrArgument |
|
771 3. KErrNotFound |
|
772 4. KErrNone |
|
773 */ |
|
774 void CTSgImageGeneric::TestOpenImageInvalidL() |
|
775 { |
|
776 TestOpenDriverL(); |
|
777 //create a non-sharable image |
|
778 TSgImageInfo info; |
|
779 info.iSizeInPixels = TSize(8, 8); |
|
780 info.iUsage = ESgUsageBitOpenVgImage; |
|
781 info.iPixelFormat = EUidPixelFormatRGB_565; |
|
782 |
|
783 RSgImage image; |
|
784 CheckErrorL(KErrNone, image.Create(info, KCrossImageData, KCrossImageDataStride), (TText8*)__FILE__, __LINE__); |
|
785 CleanupClosePushL(image); |
|
786 const TSgDrawableId id = image.Id(); |
|
787 |
|
788 //Attempt to create the image again using the same object |
|
789 TEST(KErrInUse == image.Create(info, KCrossImageData, KCrossImageDataStride)); |
|
790 |
|
791 //same thread |
|
792 // non-empty handle |
|
793 RSgImage image1; |
|
794 CreateImageL(image1); |
|
795 CleanupClosePushL(image1); |
|
796 TEST(KErrInUse == image1.Open(id)); |
|
797 image1.Close(); |
|
798 |
|
799 // non-existing drawable id |
|
800 TSgDrawableId fakeid = {0xFFFFFFFFFFFFFFFFU}; |
|
801 CheckErrorL(KErrNotFound, image1.Open(fakeid), (TText8*)__FILE__, __LINE__); |
|
802 image1.Close(); |
|
803 |
|
804 if (iEnableConformanceTests) |
|
805 { |
|
806 //different thread in the same process |
|
807 TSgThreadTestInfo threadInfo(id, info, ESgresSecondThreadOpenImageInvalid); |
|
808 TInt testResult = 0; |
|
809 TRAPD(err, testResult = CreateSecondThreadAndDoTestL(threadInfo)); |
|
810 TEST(testResult >= 0); |
|
811 // Test the results from the second thread |
|
812 TEST(testResult & EFirstTestPassed); |
|
813 TEST(testResult & ESecondTestPassed); |
|
814 TEST(testResult & EThirdTestPassed); |
|
815 TEST(testResult & EFourthTestPassed); |
|
816 TEST(testResult & EFifthTestPassed); |
|
817 |
|
818 //different process |
|
819 TSgProcessTestInfo processInfo(id, info, ESgresSecondProcessOpenImageInvalid); |
|
820 TRAP(err, testResult = CreateSecondProcessAndDoTestL(KSecondProcess, processInfo)); |
|
821 TEST(testResult >= 0); |
|
822 TEST(testResult & EFirstTestPassed); |
|
823 TEST(testResult & ESecondTestPassed); |
|
824 TEST(testResult & EThirdTestPassed); |
|
825 TEST(testResult & EFourthTestPassed); |
|
826 TEST(testResult & EFifthTestPassed); |
|
827 } |
|
828 |
|
829 CleanupStack::PopAndDestroy(2); |
|
830 TestCloseDriver(); |
|
831 } |
|
832 |
|
833 /** |
|
834 @SYMTestCaseID GRAPHICS-RESOURCE-0026 |
|
835 @SYMTestCaseDesc Closes an image multiple times. |
|
836 @SYMPREQ PREQ2637 |
|
837 @SYMFssID RSgImage::Close() |
|
838 @SYMTestPriority High |
|
839 @SYMTestType UT |
|
840 @SYMTestPurpose To check calling Close() multiple times after Open() does not cause |
|
841 errors or panics. |
|
842 @SYMTestActions Initialise the graphics resource component. Create an image and then |
|
843 call Close() three times on it. |
|
844 @SYMTestExpectedResults The function should not cause any errors or panics. |
|
845 */ |
|
846 void CTSgImageGeneric::TestCloseImageManyTimesL() |
|
847 { |
|
848 TestOpenDriverL(); |
|
849 RSgImage image; |
|
850 CreateImageL(image); |
|
851 TEST(!image.IsNull()); |
|
852 |
|
853 image.Close(); |
|
854 TEST(image.IsNull()); |
|
855 image.Close(); |
|
856 TEST(image.IsNull()); |
|
857 image.Close(); |
|
858 TEST(image.IsNull()); |
|
859 |
|
860 TestCloseDriver(); |
|
861 } |
|
862 |
|
863 |
|
864 /** |
|
865 @SYMTestCaseID GRAPHICS-RESOURCE-0027 |
|
866 @SYMTestCaseDesc Closes an image object without opening it. |
|
867 @SYMPREQ PREQ2637 |
|
868 @SYMFssID RSgImage::Close() |
|
869 @SYMTestPriority Medium |
|
870 @SYMTestType UT |
|
871 @SYMTestPurpose To check Close() does nothing if the image is not already opened. |
|
872 @SYMTestActions Initialise the graphics resource component. Declare an RSgImage object and |
|
873 call Close() on it. |
|
874 @SYMTestExpectedResults The function should not cause any errors or panics. |
|
875 */ |
|
876 void CTSgImageGeneric::TestCloseImageWithoutOpenL() |
|
877 { |
|
878 TestOpenDriverL(); |
|
879 RSgImage image; |
|
880 TEST(image.IsNull()); |
|
881 image.Close(); |
|
882 TEST(image.IsNull()); |
|
883 TestCloseDriver(); |
|
884 } |
|
885 |
|
886 /** |
|
887 @SYMTestCaseID GRAPHICS-RESOURCE-0028 |
|
888 @SYMTestCaseDesc Creates an image with various invalid parameters. |
|
889 @SYMPREQ PREQ2637 |
|
890 @SYMFssID RSgImage::Create(const TSgImageInfo&, const TAny*, TInt, const TSgAttributeArrayBase* = NULL) |
|
891 RSgImage::Create(const TSgImageInfo&, const RSgImage&, const TSgAttributeArrayBase* = NULL) |
|
892 @SYMTestPriority Medium |
|
893 @SYMTestType UT |
|
894 @SYMTestPurpose Negative test to check the function returns the correct error messages when |
|
895 the parameters are invalid. |
|
896 @SYMTestActions Initialise the graphics resource component. Construct a TSgImageInfo object |
|
897 and initialise the all the member variables with random values. Call the appropriate |
|
898 Create() function with: |
|
899 1. invalid TSgImageInfo.iSizeInPixels |
|
900 2. unsupported TSgImageInfo Pixel Format |
|
901 3. the creating RSgImage handle is not null |
|
902 4. the aSgImage handle is null |
|
903 5. the size and pixel format in TSgImageInfo is not the same as that of aSgImage |
|
904 6. the pixel stride specified is 0 when bitmap data is given |
|
905 @SYMTestExpectedResults The function should return |
|
906 1. KErrArgument or KErrNotSupported for the overload taking an RSgImage |
|
907 2. KErrNotSupported |
|
908 3. KErrInUse |
|
909 4. KErrArgument |
|
910 5. KErrNotSupported |
|
911 6. KErrArgument |
|
912 */ |
|
913 void CTSgImageGeneric::TestCreateImageInvalidL() |
|
914 { |
|
915 TestOpenDriverL(); |
|
916 RSgImage image; |
|
917 |
|
918 RSgImage validImage; |
|
919 TSgImageInfo validInfo(TSize(8,8), EUidPixelFormatRGB_565, ESgUsageBitOpenVgImage); |
|
920 TEST(KErrNone == validImage.Create(validInfo, KCrossImageData, KCrossImageDataStride)); |
|
921 |
|
922 //invalid info 1 - invalid width |
|
923 TSgImageInfo info1(TSize(-100,100), EUidPixelFormatRGB_565, ESgUsageBitOpenVgImage); |
|
924 TEST(KErrArgument == image.Create(info1, NULL, 0)); |
|
925 image.Close(); |
|
926 TEST(KErrArgument == image.Create(info1, KCrossImageData, KCrossImageDataStride)); |
|
927 image.Close(); |
|
928 //invalid height |
|
929 info1.iSizeInPixels = TSize(100, -100); |
|
930 TEST(KErrArgument == image.Create(info1, NULL, 0)); |
|
931 image.Close(); |
|
932 //Sizes don't match |
|
933 TEST(KErrNotSupported == image.Create(info1, validImage)); |
|
934 image.Close(); |
|
935 |
|
936 info1.iSizeInPixels = TSize(0,0); |
|
937 TEST(KErrArgument == image.Create(info1, NULL, 0)); |
|
938 image.Close(); |
|
939 TEST(KErrArgument == image.Create(info1, KCrossImageData, KCrossImageDataStride)); |
|
940 image.Close(); |
|
941 //Sizes don't match |
|
942 TEST(KErrNotSupported == image.Create(info1, validImage)); |
|
943 image.Close(); |
|
944 |
|
945 //Invalid usage |
|
946 info1.iUsage = KMaxTUint32; |
|
947 info1.iSizeInPixels = TSize(8,8); |
|
948 TEST(KErrNotSupported == image.Create(info1, KCrossImageData, KCrossImageDataStride)); |
|
949 image.Close(); |
|
950 TEST(KErrNotSupported == image.Create(info1, validImage)); |
|
951 image.Close(); |
|
952 |
|
953 //unsupported info 1 - invalid pixel format |
|
954 TSgImageInfo info2; |
|
955 info2.iSizeInPixels = TSize(8, 8); |
|
956 info2.iUsage = ESgUsageBitOpenVgImage; |
|
957 info2.iPixelFormat = EUidPixelFormatUnknown; |
|
958 TEST(KErrArgument == image.Create(info2, NULL, 0)); |
|
959 image.Close(); |
|
960 TEST(KErrArgument == image.Create(info2, KCrossImageData, KCrossImageDataStride)); |
|
961 image.Close(); |
|
962 |
|
963 //unsupported info 2 - large image size |
|
964 info2.iPixelFormat = ESgPixelFormatRGB_565; |
|
965 info2.iSizeInPixels = TSize(40000, 100); |
|
966 TEST(KErrTooBig == image.Create(info2, NULL, 0)); |
|
967 info2.iSizeInPixels = TSize(100, 40000); |
|
968 TEST(KErrTooBig == image.Create(info2, NULL, 0)); |
|
969 image.Close(); |
|
970 |
|
971 //non-null handle |
|
972 CreateImageL(image); |
|
973 TSgImageInfo info3; |
|
974 info3.iSizeInPixels = TSize(8, 8); |
|
975 info3.iUsage = ESgUsageBitOpenVgImage; |
|
976 info3.iPixelFormat = ESgPixelFormatRGB_565; |
|
977 |
|
978 TInt ret = image.Create(info3, NULL, 16); |
|
979 TEST(KErrInUse == ret); |
|
980 |
|
981 //non-null handle: create from an existing image |
|
982 RSgImage image1; |
|
983 CreateImageL(image1); |
|
984 TEST(KErrInUse == image1.Create(info3, image)); |
|
985 image1.Close(); |
|
986 |
|
987 //null existing image handle |
|
988 RSgImage image2; |
|
989 TEST(image2.IsNull()); |
|
990 TEST(KErrArgument == image1.Create(info3, image2)); |
|
991 |
|
992 //the size and pixel format in TSgImageInfo is not the same as that of aSgImage |
|
993 TSgImageInfo info4(TSize(100,100), ESgPixelFormatARGB_8888, ESgUsageBitOpenVgImage); |
|
994 TEST(KErrNotSupported == image1.Create(info4, image)); |
|
995 |
|
996 image1.GetInfo(info3); |
|
997 info4.iSizeInPixels = info3.iSizeInPixels; |
|
998 info4.iPixelFormat = ESgPixelFormatXRGB_8888; |
|
999 TEST(KErrNotSupported == image1.Create(info4, image)); |
|
1000 |
|
1001 image.Close(); |
|
1002 image1.Close(); |
|
1003 |
|
1004 TSgImageInfo info5(TSize(8,8), ESgPixelFormatRGB_565, ESgUsageBitOpenVgImage); |
|
1005 |
|
1006 TSgAttributeArray<1> attribArray; |
|
1007 attribArray[0].iUid = KNullUid; |
|
1008 attribArray[0].iValue = 0; |
|
1009 |
|
1010 TEST(KErrNotSupported == image1.Create(info5, KCrossImageData, KCrossImageDataStride, &attribArray)); |
|
1011 image1.Close(); |
|
1012 |
|
1013 //Stride of 0 |
|
1014 TEST(KErrArgument == image1.Create(info5, KCrossImageData, 0)); |
|
1015 image1.Close(); |
|
1016 |
|
1017 validImage.Close(); |
|
1018 |
|
1019 TestCloseDriver(); |
|
1020 } |
|
1021 |
|
1022 /** |
|
1023 @SYMTestCaseID GRAPHICS-RESOURCE-0039 |
|
1024 @SYMTestCaseDesc Calls GetInfo() on an invalid image. |
|
1025 @SYMPREQ PREQ2637 |
|
1026 @SYMFssID RSgImage::GetInfo(TSgImageInfo&) |
|
1027 @SYMTestPriority Low |
|
1028 @SYMTestType UT |
|
1029 @SYMTestPurpose Negative test to check the correct error is returned when the client |
|
1030 tries to get information on an invalid image. |
|
1031 @SYMTestActions Initialise the graphics resource component. |
|
1032 Call GetInfo() on an image that is not initialised. |
|
1033 @SYMTestExpectedResults GetInfo() should return KErrBadHandle |
|
1034 */ |
|
1035 void CTSgImageGeneric::TestGetInfoImageInvalidL() |
|
1036 { |
|
1037 TestOpenDriverL(); |
|
1038 RSgImage image; |
|
1039 TSgImageInfo info(TSize(5,5), ESgPixelFormatARGB_8888, ESgUsageBitOpenVgImage); |
|
1040 |
|
1041 //uninitialised image |
|
1042 TEST(KErrBadHandle == image.GetInfo(info)); |
|
1043 |
|
1044 TestCloseDriver(); |
|
1045 } |
|
1046 |
|
1047 /** |
|
1048 @SYMTestCaseID GRAPHICS-RESOURCE-0092 |
|
1049 @SYMTestCaseDesc Calls GetAttribute() on an invalid image. |
|
1050 @SYMPREQ PREQ2637 |
|
1051 @SYMFssID RSgImage::GetAttribute(TUid, TInt&) |
|
1052 @SYMTestPriority Low |
|
1053 @SYMTestType UT |
|
1054 @SYMTestPurpose Negative test to check the correct error is returned when the client |
|
1055 tries to get attributes on an invalid image. |
|
1056 @SYMTestActions Initialise the graphics resource component. |
|
1057 Call GetInfo on an image that is not initialised. |
|
1058 @SYMTestExpectedResults GetAttribute() should return KErrBadHandle |
|
1059 */ |
|
1060 void CTSgImageGeneric::TestGetAttributesImageInvalidL() |
|
1061 { |
|
1062 TestOpenDriverL(); |
|
1063 RSgImage image; |
|
1064 TSgImageInfo info(TSize(5,5), ESgPixelFormatARGB_8888, ESgUsageBitOpenVgImage); |
|
1065 |
|
1066 TUid uid = {0x12345678}; |
|
1067 TInt val = 0; |
|
1068 TEST(KErrBadHandle == image.GetAttribute(uid, val)); |
|
1069 |
|
1070 image.Close(); |
|
1071 |
|
1072 TestCloseDriver(); |
|
1073 } |
|
1074 |
|
1075 /** |
|
1076 @SYMTestCaseID GRAPHICS-RESOURCE-0100 |
|
1077 @SYMTestCaseDesc Creates images using negative and invalid data strides. |
|
1078 @SYMPREQ PREQ2637 |
|
1079 @SYMFssID RSgImage::Create(TUid, TInt&) |
|
1080 @SYMTestPriority Medium |
|
1081 @SYMTestType UT |
|
1082 @SYMTestPurpose Positive test for using negative data strides. |
|
1083 Negative test for using invalid data strides. |
|
1084 @SYMTestActions Initialise the graphics resource component. |
|
1085 1. Create an image with a data stride that is smaller than the width |
|
1086 of the image. |
|
1087 2. Create an image with a pointer to bitmap data, but 0 data stride. |
|
1088 3. Create an image with a negative data stride equal to the width |
|
1089 of the image. |
|
1090 4. Create an image with a negative data stride less than the width |
|
1091 of the image. |
|
1092 @SYMTestExpectedResults 1. Create() should return KErrArgument. |
|
1093 2. Create() should return KErrArgument. |
|
1094 3. Create() should successfully create the image and return KErrNone. |
|
1095 4. Create() should return KErrArgument. |
|
1096 */ |
|
1097 void CTSgImageGeneric::TestCreateImageDataStrideL() |
|
1098 { |
|
1099 TestOpenDriverL(); |
|
1100 |
|
1101 RSgImage image; |
|
1102 TSgImageInfo info1(TSize(8,8), EUidPixelFormatRGB_565, ESgUsageBitOpenVgImage); |
|
1103 |
|
1104 TEST(KErrArgument == image.Create(info1, KCrossImageData, KCrossImageDataStride-1)); |
|
1105 image.Close(); |
|
1106 TEST(KErrArgument == image.Create(info1, KCrossImageData, 0)); |
|
1107 image.Close(); |
|
1108 |
|
1109 TEST(KErrNone == image.Create(info1, KCrossImageData, -KCrossImageDataStride)); |
|
1110 image.Close(); |
|
1111 |
|
1112 TEST(KErrArgument == image.Create(info1, KCrossImageData, -KCrossImageDataStride+1)); |
|
1113 image.Close(); |
|
1114 |
|
1115 TestCloseDriver(); |
|
1116 } |
|
1117 |
|
1118 /** |
|
1119 @SYMTestCaseID GRAPHICS-RESOURCE-0048 |
|
1120 @SYMTestCaseDesc RSgImage stress tests |
|
1121 @SYMPREQ PREQ2637 |
|
1122 @SYMFssID RSgImage::Create(const TSgImageInfo&, const TAny*, TInt) |
|
1123 RSgImage::Close() |
|
1124 @SYMTestPriority Medium |
|
1125 @SYMTestType CT |
|
1126 @SYMTestPurpose To ensure creating and destroying RSgImage multiple times work well. |
|
1127 @SYMTestActions Create images 1000 times but only store KMaxImagesInArray of them |
|
1128 at one time in an RArray. When a new image is to be added to the |
|
1129 array, a random image from the array is removed. |
|
1130 @SYMTestExpectedResults There should be no panics or leaves. |
|
1131 */ |
|
1132 void CTSgImageGeneric::TestStress1L() |
|
1133 { |
|
1134 TestOpenDriverL(); |
|
1135 TSgImageInfo info; |
|
1136 info.iPixelFormat = EUidPixelFormatRGB_565; |
|
1137 info.iSizeInPixels = TSize(100, 100); |
|
1138 info.iUsage = ESgUsageBitOpenVgImage; |
|
1139 |
|
1140 TInt KMaxImagesInArray =40; |
|
1141 TInt64 seed = 0; |
|
1142 for (TInt count = 1000; count > 0; --count) |
|
1143 { |
|
1144 RSgImage image; |
|
1145 CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__); |
|
1146 CleanupClosePushL(image); |
|
1147 iTestImages.AppendL(image); |
|
1148 CleanupStack::Pop(); |
|
1149 if (iTestImages.Count() >= KMaxImagesInArray) |
|
1150 { |
|
1151 TInt i = Math::Rand(seed) % KMaxImagesInArray; |
|
1152 iTestImages[i].Close(); |
|
1153 iTestImages.Remove(i); |
|
1154 } |
|
1155 } |
|
1156 TInt count = iTestImages.Count(); |
|
1157 for(TInt i=0; i<count; ++i) |
|
1158 { |
|
1159 iTestImages[i].Close(); |
|
1160 } |
|
1161 iTestImages.Reset(); |
|
1162 TestCloseDriver(); |
|
1163 } |
|
1164 |
|
1165 /** |
|
1166 @SYMTestCaseID GRAPHICS-RESOURCE-0049 |
|
1167 @SYMTestCaseDesc RSgImage multiple threads open and close stress tests |
|
1168 @SYMPREQ PREQ2637 |
|
1169 @SYMFssID RSgImage::Open(const TSgDrawableId&) |
|
1170 RSgImage::Close() |
|
1171 @SYMTestPriority Medium |
|
1172 @SYMTestType CT |
|
1173 @SYMTestPurpose To ensure opening and destroying RSgImage multiple times and randomly |
|
1174 in other threads work well. |
|
1175 @SYMTestActions Create an image in the main thread. In a loop of 1000 times, randomly select |
|
1176 one of the five threads and either open or close the image depending on the |
|
1177 state of the thread. |
|
1178 @SYMTestExpectedResults There should be no panics or leaves. |
|
1179 */ |
|
1180 void CTSgImageGeneric::TestStress2L() |
|
1181 { |
|
1182 TestOpenDriverL(); |
|
1183 RSgImage image; |
|
1184 CreateImageL(image); |
|
1185 CleanupClosePushL(image); |
|
1186 const TSgDrawableId id = image.Id(); |
|
1187 |
|
1188 TSgImageInfo info; |
|
1189 TEST(KErrNone == image.GetInfo(info)); |
|
1190 TSgThreadTestInfo threadInfo(id, info, ESgresMultipleThreadStressTest); |
|
1191 |
|
1192 //create a semaphore |
|
1193 RSemaphore sem; |
|
1194 User::LeaveIfError(sem.CreateGlobal(KSecondThreadSemaphore, 0, EOwnerThread)); |
|
1195 CleanupClosePushL(sem); |
|
1196 |
|
1197 //create threads |
|
1198 const TInt KNoOfThreads = 5; |
|
1199 RArray<RThread> threads; |
|
1200 _LIT(KMultipleThreadName, "Multiple Threads Stress Test Thread "); |
|
1201 for (TInt i = 0; i < KNoOfThreads; ++i) |
|
1202 { |
|
1203 TBuf<50> threadName(KMultipleThreadName); |
|
1204 threadName.AppendNum(i); |
|
1205 RThread thread; |
|
1206 User::LeaveIfError(thread.Create(threadName, SgTestSecondThread::ThreadStart, KDefaultStackSize, KSecondThreadMinHeapSize, KSecondThreadMaxHeapSize, &threadInfo)); |
|
1207 thread.SetPriority(EPriorityLess); |
|
1208 threads.AppendL(thread); |
|
1209 } |
|
1210 // run threads |
|
1211 for (TInt i = 0; i < KNoOfThreads; ++i) |
|
1212 { |
|
1213 threads[i].Resume(); |
|
1214 } |
|
1215 // wait for the threads to terminate processing |
|
1216 for (TInt i = 0; i < KNoOfThreads; ++i) |
|
1217 { |
|
1218 sem.Wait(); |
|
1219 } |
|
1220 for (TInt i = 0; i < KNoOfThreads; ++i) |
|
1221 { |
|
1222 threads[i].Close(); |
|
1223 } |
|
1224 CleanupStack::PopAndDestroy(2, &image); // image, sem |
|
1225 TestCloseDriver(); |
|
1226 } |
|
1227 |
|
1228 /** |
|
1229 @SYMTestCaseID GRAPHICS-RESOURCE-0051 |
|
1230 @SYMTestCaseDesc Calls RSgImage::GetInterface() with an invalid image handle |
|
1231 @SYMPREQ PREQ2637 |
|
1232 @SYMFssID RSgImage::GetInterface(TUid, TAny*&) |
|
1233 @SYMTestPriority Low |
|
1234 @SYMTestType UT |
|
1235 @SYMTestPurpose Negative test to ensure calling GetInterface() with an invalid image handle |
|
1236 will cause a panic. |
|
1237 @SYMTestActions Initialise the graphics resource component and create an image in a second thread. |
|
1238 Declare another image and assign it to the current image handle. Close the current |
|
1239 image so the second image handle becomes invalid. Call GetInterface() on the |
|
1240 second handle. |
|
1241 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3(ESgPanicBadDrawableHandle). |
|
1242 */ |
|
1243 void CTSgImageGeneric::TestPanicImageGetInterfaceInvalidHandleL() |
|
1244 { |
|
1245 TSgImageInfo info(TSize(),0,0); |
|
1246 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageGetInterfaceInvalidHandle); |
|
1247 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1248 _LIT(KTestName, "TestImageGetInterfaceInvalidHandleLThread"); |
|
1249 CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName); |
|
1250 } |
|
1251 |
|
1252 /** |
|
1253 @SYMTestCaseID GRAPHICS-RESOURCE-0052 |
|
1254 @SYMTestCaseDesc Calls RSgImage::GetInterface() with a non-null handle and an uninitialised driver |
|
1255 @SYMPREQ PREQ2637 |
|
1256 @SYMFssID RSgImage::GetInterface(TUid, TAny*&) |
|
1257 @SYMTestPriority Low |
|
1258 @SYMTestType UT |
|
1259 @SYMTestPurpose Negative test to ensure calling GetInterface() with a non-null handle and an |
|
1260 uninitialised driver will cause a panic. |
|
1261 @SYMTestActions Initialise the graphics resource component and create an image in a second thread. |
|
1262 Declare another image and assign it to the current image handle. Close the current |
|
1263 image so the second image handle becomes invalid. Close the graphics resource driver. |
|
1264 Call GetInterface() on the second handle. |
|
1265 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver). |
|
1266 */ |
|
1267 void CTSgImageGeneric::TestPanicImageGetInterfaceNoDriverL() |
|
1268 { |
|
1269 TSgImageInfo info(TSize(),0,0); |
|
1270 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageGetInterfaceNoDriver); |
|
1271 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1272 _LIT(KTestName, "TestImageGetInterfaceNoDriverL"); |
|
1273 CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName); |
|
1274 } |
|
1275 |
|
1276 /** |
|
1277 @SYMTestCaseID GRAPHICS-RESOURCE-0053 |
|
1278 @SYMTestCaseDesc Calls RSgImage::Close() with an invalid image handle |
|
1279 @SYMPREQ PREQ2637 |
|
1280 @SYMFssID RSgImage::Close() |
|
1281 @SYMTestPriority Low |
|
1282 @SYMTestType UT |
|
1283 @SYMTestPurpose Negative test to ensure calling Close() with an invalid image handle will |
|
1284 cause a panic. |
|
1285 @SYMTestActions Initialise the graphics resource component and create an image in a second thread. |
|
1286 Declare another image and assign it to the current image handle. Close the current |
|
1287 image so the second image handle becomes invalid. Call Close() on the second handle. |
|
1288 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3(ESgPanicBadDrawableHandle). |
|
1289 */ |
|
1290 void CTSgImageGeneric::TestPanicImageCloseInvalidHandleL() |
|
1291 { |
|
1292 TSgImageInfo info(TSize(),0,0); |
|
1293 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageCloseInvalidHandle); |
|
1294 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1295 _LIT(KTestName, "TestImageCloseInvalidHandleL"); |
|
1296 CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName); |
|
1297 } |
|
1298 |
|
1299 /** |
|
1300 @SYMTestCaseID GRAPHICS-RESOURCE-0054 |
|
1301 @SYMTestCaseDesc Calls RSgImage::Close() with a non-null handle and an uninitialised driver |
|
1302 @SYMPREQ PREQ2637 |
|
1303 @SYMFssID RSgImage::Close() |
|
1304 @SYMTestPriority Low |
|
1305 @SYMTestType UT |
|
1306 @SYMTestPurpose Negative test to ensure calling Close() with a non-null handle and an |
|
1307 uninitialised driver will cause a panic. |
|
1308 @SYMTestActions Initialise the graphics resource component and create an image in a second thread. |
|
1309 Declare another image and assign it to the current image handle. Close the current |
|
1310 image so the second image handle becomes invalid. Close the graphics resource driver. |
|
1311 Call Close() on the second handle. |
|
1312 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver). |
|
1313 */ |
|
1314 void CTSgImageGeneric::TestPanicImageCloseNoDriverL() |
|
1315 { |
|
1316 TSgImageInfo info(TSize(),0,0); |
|
1317 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageCloseNoDriver); |
|
1318 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1319 _LIT(KTestName, "TestImageCloseNoDriverL"); |
|
1320 CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName); |
|
1321 } |
|
1322 |
|
1323 /** |
|
1324 @SYMTestCaseID GRAPHICS-RESOURCE-0055 |
|
1325 @SYMTestCaseDesc Calls RSgImage::Id() with an invalid image handle |
|
1326 @SYMPREQ PREQ2637 |
|
1327 @SYMFssID RSgImage::Id() |
|
1328 @SYMTestPriority Low |
|
1329 @SYMTestType UT |
|
1330 @SYMTestPurpose Negative test to ensure calling Id() with an invalid image handle will |
|
1331 cause a panic. |
|
1332 @SYMTestActions Initialise the graphics resource component and create an image in a second thread. |
|
1333 Declare another image and assign it to the current image handle. Close the current |
|
1334 image so the second image handle becomes invalid. Call Id() on the second |
|
1335 handle. |
|
1336 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3(ESgPanicBadDrawableHandle). |
|
1337 */ |
|
1338 void CTSgImageGeneric::TestPanicImageIdInvalidHandleL() |
|
1339 { |
|
1340 TSgImageInfo info(TSize(),0,0); |
|
1341 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageIdInvalidHandle); |
|
1342 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1343 _LIT(KTestName, "TestImageIdInvalidHandleL"); |
|
1344 CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName); |
|
1345 } |
|
1346 |
|
1347 /** |
|
1348 @SYMTestCaseID GRAPHICS-RESOURCE-0056 |
|
1349 @SYMTestCaseDesc Calls RSgImage::Id() with a non-null handle and an uninitialised driver |
|
1350 @SYMPREQ PREQ2637 |
|
1351 @SYMFssID RSgImage::Id() |
|
1352 @SYMTestPriority Low |
|
1353 @SYMTestType UT |
|
1354 @SYMTestPurpose Negative test to ensure calling Id() with a non-null handle and an |
|
1355 uninitialised driver will cause a panic. |
|
1356 @SYMTestActions Initialise the graphics resource component and create an image in a second thread. |
|
1357 Declare another image and assign it to the current image handle. Close the current |
|
1358 image so the second image handle becomes invalid. Close the graphics resource driver. |
|
1359 Call Id() on the second handle. |
|
1360 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver). |
|
1361 */ |
|
1362 void CTSgImageGeneric::TestPanicImageIdNoDriverL() |
|
1363 { |
|
1364 TSgImageInfo info(TSize(),0,0); |
|
1365 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageIdNoDriver); |
|
1366 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1367 _LIT(KTestName, "TestImageIdNoDriverL"); |
|
1368 CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName); |
|
1369 } |
|
1370 |
|
1371 /** |
|
1372 @SYMTestCaseID GRAPHICS-RESOURCE-0057 |
|
1373 @SYMTestCaseDesc Calls RSgImage::Create() with an invalid image handle |
|
1374 @SYMPREQ PREQ2637 |
|
1375 @SYMFssID RSgImage::Create(const TSgImageInfo&, const RSgImage&) |
|
1376 @SYMTestPriority Low |
|
1377 @SYMTestType UT |
|
1378 @SYMTestPurpose Negative test to ensure calling Create() with an invalid image handle will |
|
1379 cause a panic. |
|
1380 @SYMTestActions Initialise the graphics resource component and create an image in a second thread. |
|
1381 Declare another image and assign it to the current image handle. Close the current |
|
1382 image so the second image handle becomes invalid. Call Create() on the second |
|
1383 handle. |
|
1384 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3(ESgPanicBadDrawableHandle). |
|
1385 */ |
|
1386 void CTSgImageGeneric::TestPanicImageCreateInvalidHandleL() |
|
1387 { |
|
1388 TSgImageInfo info(TSize(),0,0); |
|
1389 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageCreateInvalidHandle); |
|
1390 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1391 _LIT(KTestName, "TestImageCreateInvalidHandleL"); |
|
1392 CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName); |
|
1393 } |
|
1394 |
|
1395 /** |
|
1396 @SYMTestCaseID GRAPHICS-RESOURCE-0058 |
|
1397 @SYMTestCaseDesc Calls RSgImage::GetInfo() with an invalid image handle |
|
1398 @SYMPREQ PREQ2637 |
|
1399 @SYMFssID RSgImage::GetInfo(TSgImageInfo&) |
|
1400 @SYMTestPriority Low |
|
1401 @SYMTestType UT |
|
1402 @SYMTestPurpose Negative test to ensure calling GetInfo() with an invalid image handle will |
|
1403 cause a panic. |
|
1404 @SYMTestActions Initialise the graphics resource component and create an image in a second thread. |
|
1405 Declare another image and assign it to the current image handle. Close the current |
|
1406 image so the second image handle becomes invalid. Call GetInfo() on the second |
|
1407 handle. |
|
1408 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3(ESgPanicBadDrawableHandle). |
|
1409 */ |
|
1410 void CTSgImageGeneric::TestPanicImageGetInfoInvalidHandleL() |
|
1411 { |
|
1412 TSgImageInfo info(TSize(),0,0); |
|
1413 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageGetInfoInvalidHandle); |
|
1414 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1415 _LIT(KTestName, "TestImageGetInfoInvalidHandleL"); |
|
1416 CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName); |
|
1417 } |
|
1418 |
|
1419 /** |
|
1420 @SYMTestCaseID GRAPHICS-RESOURCE-0059 |
|
1421 @SYMTestCaseDesc Calls RSgImage::GetInfo() with a non-null handle and an uninitialised driver |
|
1422 @SYMPREQ PREQ2637 |
|
1423 @SYMFssID SgImage::GetInfo(TSgImageInfo&) |
|
1424 @SYMTestPriority Low |
|
1425 @SYMTestType UT |
|
1426 @SYMTestPurpose Negative test to ensure calling GetInfo() with a non-null handle and an |
|
1427 uninitialised driver will cause a panic. |
|
1428 @SYMTestActions Initialise the graphics resource component and create an image in a second thread. |
|
1429 Declare another image and assign it to the current image handle. Close the current |
|
1430 image so the second image handle becomes invalid. Close the graphics resource driver. |
|
1431 Call GetInfo() on the second handle. |
|
1432 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver). |
|
1433 */ |
|
1434 void CTSgImageGeneric::TestPanicImageGetInfoNoDriverL() |
|
1435 { |
|
1436 TSgImageInfo info(TSize(),0,0); |
|
1437 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageGetInfoNoDriver); |
|
1438 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1439 _LIT(KTestName, "TestImageGetInfoNoDriverL"); |
|
1440 CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName); |
|
1441 } |
|
1442 |
|
1443 /** |
|
1444 @SYMTestCaseID GRAPHICS-RESOURCE-0082 |
|
1445 @SYMTestCaseDesc Calls RSgImage::Open() when the driver was not initialised. |
|
1446 @SYMPREQ PREQ2637 |
|
1447 @SYMFssID RSgImage::Open(const TSgDrawableId&, TUint32) |
|
1448 @SYMTestPriority Low |
|
1449 @SYMTestType UT |
|
1450 @SYMTestPurpose Negative test to ensure calling RSgImage::Open() with an uninitialised driver |
|
1451 will cause a panic. |
|
1452 @SYMTestActions Do not initialise the graphics resource component and call RSgImage::Open() |
|
1453 in a second thread. |
|
1454 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver). |
|
1455 */ |
|
1456 void CTSgImageGeneric::TestPanicImageOpenNoDriverL() |
|
1457 { |
|
1458 TSgImageInfo info(TSize(),0,0); |
|
1459 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageOpenNoDriver); |
|
1460 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1461 _LIT(KTestName, "TestPanicImageOpenNoDriverL"); |
|
1462 CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName); |
|
1463 } |
|
1464 |
|
1465 /** |
|
1466 @SYMTestCaseID GRAPHICS-RESOURCE-0083 |
|
1467 @SYMTestCaseDesc Creates an image from memory when the driver was not initialised. |
|
1468 @SYMPREQ PREQ2637 |
|
1469 @SYMFssID RSgImage::Create(const TSgImageInfo&, const TAny*, TInt) |
|
1470 @SYMTestPriority Low |
|
1471 @SYMTestType UT |
|
1472 @SYMTestPurpose Negative test to ensure calling RSgImage::Create() with an uninitialised |
|
1473 driver will cause a panic. |
|
1474 @SYMTestActions Do not initialise the graphics resource component and call RSgImage::Open() |
|
1475 in a second thread. |
|
1476 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver). |
|
1477 */ |
|
1478 void CTSgImageGeneric::TestPanicImageCreateNoDriver1L() |
|
1479 { |
|
1480 TSgImageInfo info(TSize(),0,0); |
|
1481 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageCreateNoDriver1); |
|
1482 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1483 _LIT(KTestName, "TestPanicImageCreateNoDriver1L"); |
|
1484 CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName); |
|
1485 } |
|
1486 |
|
1487 /** |
|
1488 @SYMTestCaseID GRAPHICS-RESOURCE-0084 |
|
1489 @SYMTestCaseDesc Creates an image from an existing image when the driver was not initialised. |
|
1490 @SYMPREQ PREQ2637 |
|
1491 @SYMFssID RSgImage::Create(const TSgImageInfo&, const RSgImage&) |
|
1492 @SYMTestPriority Low |
|
1493 @SYMTestType UT |
|
1494 @SYMTestPurpose Negative test to ensure calling RSgImage::Create() with an uninitialised driver |
|
1495 will cause a panic. |
|
1496 @SYMTestActions Do not initialise the graphics resource component and call RSgImage::Open() in |
|
1497 a second thread. |
|
1498 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver). |
|
1499 */ |
|
1500 void CTSgImageGeneric::TestPanicImageCreateNoDriver2L() |
|
1501 { |
|
1502 TSgImageInfo info(TSize(),0,0); |
|
1503 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageCreateNoDriver2); |
|
1504 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1505 _LIT(KTestName, "TestPanicImageCreateNoDriver2L"); |
|
1506 CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName); |
|
1507 } |
|
1508 |
|
1509 /** |
|
1510 @SYMTestCaseID GRAPHICS-RESOURCE-0088 |
|
1511 @SYMTestCaseDesc Calls RSgImage::DrawableType() when the driver was not initialised. |
|
1512 @SYMPREQ PREQ2637 |
|
1513 @SYMFssID RSgImage::DrawableType() |
|
1514 @SYMTestPriority Low |
|
1515 @SYMTestType UT |
|
1516 @SYMTestPurpose Negative test to ensure calling RSgImage::DrawableType() with an uninitialised |
|
1517 driver will cause a panic. |
|
1518 @SYMTestActions Do not initialise the graphics resource component and call RSgImage::DrawableType() |
|
1519 in a second thread. |
|
1520 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver). |
|
1521 */ |
|
1522 void CTSgImageGeneric::TestPanicImageDrawableTypeNoDriverL() |
|
1523 { |
|
1524 TSgImageInfo info(TSize(),0,0); |
|
1525 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageDrawableTypeNoDriver); |
|
1526 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1527 _LIT(KTestName, "TestPanicImageOpenNoDriverL"); |
|
1528 CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName); |
|
1529 } |
|
1530 |
|
1531 /** |
|
1532 @SYMTestCaseID GRAPHICS-RESOURCE-0089 |
|
1533 @SYMTestCaseDesc Calls RSgImage::DrawableType() with an invalid image handle |
|
1534 @SYMPREQ PREQ2637 |
|
1535 @SYMFssID RSgImage::DrawableType() |
|
1536 @SYMTestPriority Low |
|
1537 @SYMTestType UT |
|
1538 @SYMTestPurpose Negative test to ensure calling RSgImage::DrawableType() with an uninitialised |
|
1539 driver will cause a panic. |
|
1540 @SYMTestActions Do not initialise the graphics resource component and call RSgImage::DrawableType() |
|
1541 in a second thread. |
|
1542 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3 (ESgPanicBadDrawableHandle). |
|
1543 */ |
|
1544 void CTSgImageGeneric::TestPanicImageDrawableTypeInvalidHandleL() |
|
1545 { |
|
1546 TSgImageInfo info(TSize(),0,0); |
|
1547 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageDrawableTypeInvalidHandle); |
|
1548 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1549 _LIT(KTestName, "TestPanicImageOpenNoDriverL"); |
|
1550 CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName); |
|
1551 } |
|
1552 |
|
1553 /** |
|
1554 @SYMTestCaseID GRAPHICS-RESOURCE-0090 |
|
1555 @SYMTestCaseDesc Calls RSgImage::DrawableType() with an invalid image handle |
|
1556 @SYMPREQ PREQ2637 |
|
1557 @SYMFssID RSgImage::GetAttribute() |
|
1558 @SYMTestPriority Low |
|
1559 @SYMTestType UT |
|
1560 @SYMTestPurpose Negative test to ensure calling RSgImage::GetAttribute() with an invalid handle |
|
1561 will cause a panic. |
|
1562 @SYMTestActions Initialise the graphics resource component and call RSgImage::GetAttribute() |
|
1563 in a second thread with an invalid handle. |
|
1564 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3 (ESgPanicBadDrawableHandle). |
|
1565 */ |
|
1566 void CTSgImageGeneric::TestPanicImageGetAttributeInvalidHandleL() |
|
1567 { |
|
1568 TSgImageInfo info(TSize(),0,0); |
|
1569 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageGetAttributeInvalidHandle); |
|
1570 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1571 _LIT(KTestName, "TestPanicImageGetAttributeInvalidHandleL"); |
|
1572 CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName); |
|
1573 } |
|
1574 |
|
1575 /** |
|
1576 @SYMTestCaseID GRAPHICS-RESOURCE-0091 |
|
1577 @SYMTestCaseDesc Calls RSgImage::GetAttribute() with no open driver |
|
1578 @SYMPREQ PREQ2637 |
|
1579 @SYMFssID RSgImage::GetAttribute() |
|
1580 @SYMTestPriority Low |
|
1581 @SYMTestType UT |
|
1582 @SYMTestPurpose Negative test to ensure calling RSgImage::GetAttribute() with an uninitialised |
|
1583 driver will cause a panic. |
|
1584 @SYMTestActions Do not initialise the graphics resource component and call RSgImage::GetAttribute() |
|
1585 in a second thread. |
|
1586 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver). |
|
1587 */ |
|
1588 void CTSgImageGeneric::TestPanicImageGetAttributeNoDriverL() |
|
1589 { |
|
1590 TSgImageInfo info(TSize(),0,0); |
|
1591 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageGetAttributeNoDriver); |
|
1592 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1593 _LIT(KTestName, "TestPanicImageGetAttributeNoDriverL"); |
|
1594 CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName); |
|
1595 } |
|
1596 |
|
1597 /** |
|
1598 @SYMTestCaseID GRAPHICS-RESOURCE-0097 |
|
1599 @SYMTestCaseDesc Access out of bound TSgAttibuteArray index |
|
1600 @SYMPREQ PREQ2637 |
|
1601 @SYMFssID TSgAttributeArray |
|
1602 @SYMTestPriority Low |
|
1603 @SYMTestType UT |
|
1604 @SYMTestPurpose Negative test to ensure calling an out of bound index on a TSgAttributeArray |
|
1605 will cause a panic. |
|
1606 @SYMTestActions Create a TSgAttributeArray of size 5 and attempt to access an element higher |
|
1607 than the size. |
|
1608 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 4 (ESgPanicBadAttributeArrayIndex). |
|
1609 */ |
|
1610 void CTSgImageGeneric::TestPanicImageAttributeArrayInvalidIndexL() |
|
1611 { |
|
1612 TSgImageInfo info(TSize(),0,0); |
|
1613 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicAttributeArrayInvalidIndex); |
|
1614 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1615 _LIT(KTestName, "AttributeArrayInvalidIndexL"); |
|
1616 CreateSecondThreadAndCheckPanicL(threadInfo, 4, exitCategoryName, KTestName); |
|
1617 } |
|
1618 |
|
1619 /** |
|
1620 @SYMTestCaseID GRAPHICS-RESOURCE-0098 |
|
1621 @SYMTestCaseDesc Access out of bound TSgAttibuteArray index |
|
1622 @SYMPREQ PREQ2637 |
|
1623 @SYMFssID TSgAttributeArray |
|
1624 @SYMTestPriority Low |
|
1625 @SYMTestType UT |
|
1626 @SYMTestPurpose Negative test to ensure calling an out of bound index on a TSgAttributeArray |
|
1627 will cause a panic. |
|
1628 @SYMTestActions Create a TSgAttributeArray of size 5 and attempt to access an element higher |
|
1629 than the size. |
|
1630 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 4 (ESgPanicBadAttributeArrayIndex). |
|
1631 */ |
|
1632 void CTSgImageGeneric::TestPanicImageAttributeArrayInvalidIndex2L() |
|
1633 { |
|
1634 TSgImageInfo info(TSize(),0,0); |
|
1635 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicAttributeArrayInvalidIndex2); |
|
1636 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1637 _LIT(KTestName, "AttributeArrayInvalidIndexL"); |
|
1638 CreateSecondThreadAndCheckPanicL(threadInfo, 4, exitCategoryName, KTestName); |
|
1639 } |
|
1640 |
|
1641 /** |
|
1642 @SYMTestCaseID GRAPHICS-RESOURCE-0101 |
|
1643 @SYMTestCaseDesc Close an RSgDriver with open resources |
|
1644 @SYMPREQ PREQ2637 |
|
1645 @SYMFssID RSgDriver |
|
1646 @SYMTestPriority Low |
|
1647 @SYMTestType UT |
|
1648 @SYMTestPurpose Negative test to ensure closing a driver with open resources will cause a panic. |
|
1649 @SYMTestActions Create an RSgImage on an open driver, then close the driver. |
|
1650 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 2 (ESgPanicUnclosedResources). |
|
1651 */ |
|
1652 void CTSgImageGeneric::TestPanicDriverCloseOpenResourcesL() |
|
1653 { |
|
1654 TSgImageInfo info(TSize(),0,0); |
|
1655 TSgProcessTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondProcessPanicDriverCloseOpenResources); |
|
1656 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1657 CreateSecondProcessAndCheckPanicL(threadInfo, 2, exitCategoryName, KSecondProcess); |
|
1658 } |
|
1659 |
|
1660 /** |
|
1661 @SYMTestCaseID GRAPHICS-RESOURCE-0102 |
|
1662 @SYMTestCaseDesc Open/Close RSgDriver and Create/Close RSgImage in separate threads |
|
1663 @SYMPREQ PREQ2637 |
|
1664 @SYMFssID RSgDriver, RSgImage |
|
1665 @SYMTestPriority High |
|
1666 @SYMTestType UT |
|
1667 @SYMTestPurpose To ensure that it is possible to Open/Close the RSgDriver from |
|
1668 a separate thread, and to ensure that it is possible to Create/Open/Close |
|
1669 RSgImages from a seperate thread. |
|
1670 @SYMTestActions 1. Declare a RSgDriver, and pass to another thread to open. |
|
1671 2. Declare a RSgImage, and pass to another thread to create. |
|
1672 3. Pass created RSgImage to another thread to Open(). |
|
1673 4. Pass the image to another thread to Close(). |
|
1674 5. Pass the RSgDriver to another thread to Close() |
|
1675 @SYMTestExpectedResults All steps to succeed with no errors reported. |
|
1676 */ |
|
1677 void CTSgImageGeneric::TestCreateOpenCloseImageAndDriverInSecondThreadL() |
|
1678 { |
|
1679 TSgImageInfo info(TSize(),0,0); |
|
1680 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadOpenPassedDriver); |
|
1681 |
|
1682 RSgDriver driver; |
|
1683 threadInfo.iSgDriver = &driver; |
|
1684 |
|
1685 RSgImage image; |
|
1686 threadInfo.iSgImage = ℑ |
|
1687 |
|
1688 //Open the driver in another thread |
|
1689 TEST(CreateSecondThreadAndDoTestL(threadInfo)==0); |
|
1690 |
|
1691 //Create the image in a thread |
|
1692 threadInfo.iTestCase = ESgresSecondThreadCreatePassedImage; |
|
1693 TEST(CreateSecondThreadAndDoTestL(threadInfo)==0); |
|
1694 |
|
1695 //Now try opening the image in another thread |
|
1696 RSgImage image2; |
|
1697 threadInfo.iTestCase = ESgresSecondThreadOpenPassedImage; |
|
1698 threadInfo.iDrawableId = image.Id(); |
|
1699 threadInfo.iSgImage = &image2; |
|
1700 TEST(CreateSecondThreadAndDoTestL(threadInfo)==0); |
|
1701 |
|
1702 //Close the "Opened" image in another thread |
|
1703 threadInfo.iTestCase = ESgresSecondThreadClosePassedImage; |
|
1704 TEST(CreateSecondThreadAndDoTestL(threadInfo)==0); |
|
1705 |
|
1706 //Close the "Created" image in another thread |
|
1707 threadInfo.iTestCase = ESgresSecondThreadClosePassedImage; |
|
1708 threadInfo.iSgImage = ℑ |
|
1709 TEST(CreateSecondThreadAndDoTestL(threadInfo)==0); |
|
1710 |
|
1711 //Close the driver in another thread |
|
1712 threadInfo.iTestCase = ESgresSecondThreadClosePassedDriver; |
|
1713 TEST(CreateSecondThreadAndDoTestL(threadInfo)==0); |
|
1714 } |
|
1715 |
|
1716 /** |
|
1717 @SYMTestCaseID GRAPHICS-RESOURCE-0104 |
|
1718 @SYMTestCaseDesc Open a RSgImage using multiple threads. |
|
1719 @SYMDEF ou1cimx1#197357 |
|
1720 @SYMFssID RSgImage |
|
1721 @SYMTestPriority Low |
|
1722 @SYMTestType UT |
|
1723 @SYMTestPurpose To show that images can be opened safely when used with multiple threads in |
|
1724 separate processes. |
|
1725 @SYMTestActions 1. Process A, creates an RSgImage |
|
1726 2. Process B, creates a secondary thread, which creates a handle to the image |
|
1727 created in A. |
|
1728 3. Process B, primary thread opens a handle to the same image. |
|
1729 4. Process B, secondary thread closes the handle and terminates thread. |
|
1730 5. Process B, primary thread waits for thread cleanup, then attempts to |
|
1731 access the data of the image by creating a copy of it. |
|
1732 @SYMTestExpectedResults All steps to succeed with no errors reported. |
|
1733 */ |
|
1734 void CTSgImageGeneric::TestOpenImageMultithreadedL() |
|
1735 { |
|
1736 TestOpenDriverL(); |
|
1737 RSgImage image; |
|
1738 CreateImageL(image); |
|
1739 CleanupClosePushL(image); |
|
1740 |
|
1741 TSgImageInfo info; |
|
1742 TInt err = image.GetInfo(info); |
|
1743 TESTE(err == KErrNone, err); |
|
1744 |
|
1745 TSgProcessTestInfo processInfo(image.Id(), info, ESgresSecondProcessOpenImageMultithreaded); |
|
1746 TInt testResult = 0; |
|
1747 TRAP(err, testResult = CreateSecondProcessAndDoTestL(KSecondProcess, processInfo)); |
|
1748 TESTE(err == KErrNone, err); |
|
1749 TEST(testResult & EFirstTestPassed); |
|
1750 TEST(testResult & ESecondTestPassed); |
|
1751 TEST(testResult <= (EFirstTestPassed | ESecondTestPassed)); |
|
1752 |
|
1753 CleanupStack::PopAndDestroy(1); // image |
|
1754 TestCloseDriver(); |
|
1755 } |