|
1 // Copyright (c) 2007-2010 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(info1, getInfo1)); |
|
584 TEST(getInfo1.iPixelFormat == getInfo2.iPixelFormat |
|
585 && getInfo1.iSizeInPixels == getInfo2.iSizeInPixels |
|
586 && getInfo1.iUsage == getInfo2.iUsage); |
|
587 |
|
588 if (iEnableConformanceTests) |
|
589 { |
|
590 //opening image in a second thread in the current process |
|
591 TSgThreadTestInfo threadInfo(id1, info1, ESgresSecondThreadOpenImage); |
|
592 TInt testResult = 0; |
|
593 TRAPD(err, testResult = CreateSecondThreadAndDoTestL(threadInfo)); |
|
594 TEST(err == KErrNone); |
|
595 TEST(testResult >= 0); |
|
596 |
|
597 // Test the results from the second thread |
|
598 TEST(testResult & EFirstTestPassed); |
|
599 TEST(testResult & ESecondTestPassed); |
|
600 TEST(testResult & EThirdTestPassed); |
|
601 TEST(testResult & EFourthTestPassed); |
|
602 TEST(testResult & EFifthTestPassed); |
|
603 TEST(testResult & ESixthTestPassed); |
|
604 TEST(testResult & ESeventhTestPassed); |
|
605 TEST(testResult & EEighthTestPassed); |
|
606 |
|
607 //opening image in a second process |
|
608 TSgProcessTestInfo processInfo(id1, getInfo1, ESgresSecondProcessOpenImage); |
|
609 TRAP(err, testResult = CreateSecondProcessAndDoTestL(KSecondProcess, processInfo)); |
|
610 TEST(err == KErrNone); |
|
611 TEST(testResult >= 0); |
|
612 |
|
613 TEST(testResult & EFirstTestPassed); |
|
614 TEST(testResult & ESecondTestPassed); |
|
615 TEST(testResult & EThirdTestPassed); |
|
616 TEST(testResult & EFourthTestPassed); |
|
617 TEST(testResult & EFifthTestPassed); |
|
618 TEST(testResult & ESixthTestPassed); |
|
619 TEST(testResult & ESeventhTestPassed); |
|
620 } |
|
621 |
|
622 image1.Close(); |
|
623 image2.Close(); |
|
624 |
|
625 TestCloseDriver(); |
|
626 } |
|
627 |
|
628 /** |
|
629 Fake RSgImage extension interface used in negative RSgImage::GetInterface() Tests |
|
630 */ |
|
631 class MFake |
|
632 { |
|
633 public: |
|
634 enum { EInterfaceUid = 0x88888888 }; |
|
635 }; |
|
636 |
|
637 class MFakeNullUid |
|
638 { |
|
639 public: |
|
640 enum { EInterfaceUid = KNullUidValue}; |
|
641 }; |
|
642 |
|
643 /** |
|
644 @SYMTestCaseID GRAPHICS-RESOURCE-0044 |
|
645 @SYMTestCaseDesc Gets an invalid/unsupported image extension interface |
|
646 @SYMPREQ PREQ2637 |
|
647 @SYMFssID RSgImage::Create(const TSgImageInfo&, const TAny*, TInt) |
|
648 RSgImage::GetInterface() |
|
649 @SYMTestPriority Low |
|
650 @SYMTestType UT |
|
651 @SYMTestPurpose Negative test to ensure the correct error code is returned when attempting |
|
652 to retrieve an invalid RSgImage extension interface. |
|
653 @SYMTestActions Initialise the graphics resource component. Create an image. |
|
654 1. Declare an unsupported interface MFake and pass to GetInterface(). |
|
655 2. Declare an interface MFakeNullUid which has a null uid and pass to GetInterface(). |
|
656 @SYMTestExpectedResults 1. GetInterface() should return KErrExtensionNotSupported. |
|
657 2. GetInterface() should return KErrArgument since null uids are not acceptable. |
|
658 */ |
|
659 void CTSgImageGeneric::TestGetInterfaceL() |
|
660 { |
|
661 TestOpenDriverL(); |
|
662 |
|
663 TSgImageInfo info; |
|
664 info.iSizeInPixels = TSize(8, 8); |
|
665 info.iUsage = ESgUsageBitOpenVgImage; |
|
666 info.iPixelFormat = EUidPixelFormatRGB_565; |
|
667 |
|
668 RSgImage image; |
|
669 |
|
670 //fake interface |
|
671 MFake* smFake = reinterpret_cast<MFake*>(1); |
|
672 MFake* smFake2 = reinterpret_cast<MFake*>(1); |
|
673 |
|
674 //Check Calls to Get Interface on Null Image Handle |
|
675 TEST(KErrBadHandle == image.GetInterface(smFake)); |
|
676 TEST(KErrBadHandle == image.GetInterface(smFake2)); |
|
677 TEST(!smFake); |
|
678 TEST(!smFake2); |
|
679 |
|
680 CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__); |
|
681 |
|
682 // check TSgDrawableId is not NULL |
|
683 TSgDrawableId id = image.Id(); |
|
684 TEST(KSgNullDrawableId != id); |
|
685 |
|
686 smFake = reinterpret_cast<MFake*>(1); |
|
687 smFake2 = reinterpret_cast<MFake*>(1); |
|
688 |
|
689 TEST(KErrExtensionNotSupported == image.GetInterface(smFake)); |
|
690 TEST(!smFake); |
|
691 |
|
692 TEST(KErrExtensionNotSupported == image.GetInterface(smFake2)); |
|
693 TEST(!smFake2); |
|
694 |
|
695 // null interface uid |
|
696 MFakeNullUid* smFake3 = NULL; |
|
697 TEST(KErrArgument == image.GetInterface(smFake3)); |
|
698 TEST(!smFake3); |
|
699 |
|
700 image.Close(); |
|
701 |
|
702 TestCloseDriver(); |
|
703 } |
|
704 |
|
705 /** |
|
706 @SYMTestCaseID GRAPHICS-RESOURCE-0024 |
|
707 @SYMTestCaseDesc Gets supported pixel formats with invalid parameters. |
|
708 @SYMPREQ PREQ2637 |
|
709 @SYMFssID RSgImage::GetPixelFormats(TUint32, RArray<TInt>, |
|
710 const TSgAttributeArrayBase*) |
|
711 @SYMTestPriority Low |
|
712 @SYMTestType UT |
|
713 @SYMTestPurpose Negative test to ensure the correct error messages are returned when user tries to |
|
714 call GetPixelFormats() with invalid parameters. |
|
715 @SYMTestActions Initialise the graphics resource component. Call RSgImage::GetPixelFormats with: |
|
716 1. Usage of 0 |
|
717 2. Invalid attribute array |
|
718 3. Valid arguments |
|
719 4. Pixel formats array is not empty |
|
720 @SYMTestExpectedResults RSgImage::GetPixelFormats() should return: |
|
721 1. KErrArgument |
|
722 2. KErrNotSupported |
|
723 3. KErrNone |
|
724 4. KErrArgument |
|
725 */ |
|
726 void CTSgImageGeneric::TestGetPixelFormatsInvalidL() |
|
727 { |
|
728 RArray<TInt> pixelFormats; |
|
729 CleanupClosePushL(pixelFormats); |
|
730 TSgAttributeArray<1> attribArray; |
|
731 attribArray[0].iUid = KNullUid; |
|
732 attribArray[0].iValue = 0; |
|
733 TEST(attribArray.Count() == 1); |
|
734 |
|
735 TestOpenDriverL(); |
|
736 |
|
737 TEST(KErrArgument == RSgImage::GetPixelFormats(0, pixelFormats)); |
|
738 pixelFormats.Reset(); |
|
739 |
|
740 TEST(KErrNotSupported == RSgImage::GetPixelFormats(ESgUsageBitOpenVgImage, pixelFormats, &attribArray)); |
|
741 pixelFormats.Reset(); |
|
742 |
|
743 TEST(KErrNone == RSgImage::GetPixelFormats(ESgUsageBitOpenVgImage, pixelFormats)); |
|
744 TEST(pixelFormats.Count() > 0); |
|
745 //Don't reset pixel formats for next test |
|
746 |
|
747 TEST(KErrArgument == RSgImage::GetPixelFormats(ESgUsageBitOpenVgImage, pixelFormats)); |
|
748 pixelFormats.Reset(); |
|
749 |
|
750 TestCloseDriver(); |
|
751 CleanupStack::PopAndDestroy(&pixelFormats); |
|
752 } |
|
753 |
|
754 /** |
|
755 @SYMTestCaseID GRAPHICS-RESOURCE-0025 |
|
756 @SYMTestCaseDesc Opens an image with different invalid and valid parameters. |
|
757 @SYMPREQ PREQ2637 |
|
758 @SYMFssID RSgImage::Open(const TSgDrawableId&) |
|
759 @SYMTestPriority Medium |
|
760 @SYMTestType UT |
|
761 @SYMTestPurpose Negative test to check correct error messages are returned when opening |
|
762 image with different invalid parameters. |
|
763 @SYMTestActions Initialise the graphics resource component. Construct an RSgImage object. |
|
764 Call the Open() function in both the current process and another process with: |
|
765 1. a non-null RSgImage handle |
|
766 2. null drawable id |
|
767 3. fake drawable id |
|
768 4. a valid RSgImage handle |
|
769 Do the same tests in a second thread and a second process. |
|
770 @SYMTestExpectedResults The function should return: |
|
771 1. KErrInUse |
|
772 2. KErrArgument |
|
773 3. KErrNotFound |
|
774 4. KErrNone |
|
775 */ |
|
776 void CTSgImageGeneric::TestOpenImageInvalidL() |
|
777 { |
|
778 TestOpenDriverL(); |
|
779 //create a non-sharable image |
|
780 TSgImageInfo info; |
|
781 info.iSizeInPixels = TSize(8, 8); |
|
782 info.iUsage = ESgUsageBitOpenVgImage; |
|
783 info.iPixelFormat = EUidPixelFormatRGB_565; |
|
784 |
|
785 RSgImage image; |
|
786 CheckErrorL(KErrNone, image.Create(info, KCrossImageData, KCrossImageDataStride), (TText8*)__FILE__, __LINE__); |
|
787 CleanupClosePushL(image); |
|
788 const TSgDrawableId id = image.Id(); |
|
789 |
|
790 //Attempt to create the image again using the same object |
|
791 TEST(KErrInUse == image.Create(info, KCrossImageData, KCrossImageDataStride)); |
|
792 |
|
793 //same thread |
|
794 // non-empty handle |
|
795 RSgImage image1; |
|
796 CreateImageL(image1); |
|
797 CleanupClosePushL(image1); |
|
798 TEST(KErrInUse == image1.Open(id)); |
|
799 image1.Close(); |
|
800 |
|
801 // non-existing drawable id |
|
802 TSgDrawableId fakeid = {0xFFFFFFFFFFFFFFFFU}; |
|
803 CheckErrorL(KErrNotFound, image1.Open(fakeid), (TText8*)__FILE__, __LINE__); |
|
804 image1.Close(); |
|
805 |
|
806 if (iEnableConformanceTests) |
|
807 { |
|
808 //different thread in the same process |
|
809 TSgThreadTestInfo threadInfo(id, info, ESgresSecondThreadOpenImageInvalid); |
|
810 TInt testResult = 0; |
|
811 TRAPD(err, testResult = CreateSecondThreadAndDoTestL(threadInfo)); |
|
812 TEST(testResult >= 0); |
|
813 // Test the results from the second thread |
|
814 TEST(testResult & EFirstTestPassed); |
|
815 TEST(testResult & ESecondTestPassed); |
|
816 TEST(testResult & EThirdTestPassed); |
|
817 TEST(testResult & EFourthTestPassed); |
|
818 TEST(testResult & EFifthTestPassed); |
|
819 |
|
820 //different process |
|
821 TSgProcessTestInfo processInfo(id, info, ESgresSecondProcessOpenImageInvalid); |
|
822 TRAP(err, testResult = CreateSecondProcessAndDoTestL(KSecondProcess, processInfo)); |
|
823 TEST(testResult >= 0); |
|
824 TEST(testResult & EFirstTestPassed); |
|
825 TEST(testResult & ESecondTestPassed); |
|
826 TEST(testResult & EThirdTestPassed); |
|
827 TEST(testResult & EFourthTestPassed); |
|
828 TEST(testResult & EFifthTestPassed); |
|
829 } |
|
830 |
|
831 CleanupStack::PopAndDestroy(2); |
|
832 TestCloseDriver(); |
|
833 } |
|
834 |
|
835 /** |
|
836 @SYMTestCaseID GRAPHICS-RESOURCE-0026 |
|
837 @SYMTestCaseDesc Closes an image multiple times. |
|
838 @SYMPREQ PREQ2637 |
|
839 @SYMFssID RSgImage::Close() |
|
840 @SYMTestPriority High |
|
841 @SYMTestType UT |
|
842 @SYMTestPurpose To check calling Close() multiple times after Open() does not cause |
|
843 errors or panics. |
|
844 @SYMTestActions Initialise the graphics resource component. Create an image and then |
|
845 call Close() three times on it. |
|
846 @SYMTestExpectedResults The function should not cause any errors or panics. |
|
847 */ |
|
848 void CTSgImageGeneric::TestCloseImageManyTimesL() |
|
849 { |
|
850 TestOpenDriverL(); |
|
851 RSgImage image; |
|
852 CreateImageL(image); |
|
853 TEST(!image.IsNull()); |
|
854 |
|
855 image.Close(); |
|
856 TEST(image.IsNull()); |
|
857 image.Close(); |
|
858 TEST(image.IsNull()); |
|
859 image.Close(); |
|
860 TEST(image.IsNull()); |
|
861 |
|
862 TestCloseDriver(); |
|
863 } |
|
864 |
|
865 |
|
866 /** |
|
867 @SYMTestCaseID GRAPHICS-RESOURCE-0027 |
|
868 @SYMTestCaseDesc Closes an image object without opening it. |
|
869 @SYMPREQ PREQ2637 |
|
870 @SYMFssID RSgImage::Close() |
|
871 @SYMTestPriority Medium |
|
872 @SYMTestType UT |
|
873 @SYMTestPurpose To check Close() does nothing if the image is not already opened. |
|
874 @SYMTestActions Initialise the graphics resource component. Declare an RSgImage object and |
|
875 call Close() on it. |
|
876 @SYMTestExpectedResults The function should not cause any errors or panics. |
|
877 */ |
|
878 void CTSgImageGeneric::TestCloseImageWithoutOpenL() |
|
879 { |
|
880 TestOpenDriverL(); |
|
881 RSgImage image; |
|
882 TEST(image.IsNull()); |
|
883 image.Close(); |
|
884 TEST(image.IsNull()); |
|
885 TestCloseDriver(); |
|
886 } |
|
887 |
|
888 /** |
|
889 @SYMTestCaseID GRAPHICS-RESOURCE-0028 |
|
890 @SYMTestCaseDesc Creates an image with various invalid parameters. |
|
891 @SYMPREQ PREQ2637 |
|
892 @SYMFssID RSgImage::Create(const TSgImageInfo&, const TAny*, TInt, const TSgAttributeArrayBase* = NULL) |
|
893 RSgImage::Create(const TSgImageInfo&, const RSgImage&, const TSgAttributeArrayBase* = NULL) |
|
894 @SYMTestPriority Medium |
|
895 @SYMTestType UT |
|
896 @SYMTestPurpose Negative test to check the function returns the correct error messages when |
|
897 the parameters are invalid. |
|
898 @SYMTestActions Initialise the graphics resource component. Construct a TSgImageInfo object |
|
899 and initialise the all the member variables with random values. Call the appropriate |
|
900 Create() function with: |
|
901 1. invalid TSgImageInfo.iSizeInPixels |
|
902 2. unsupported TSgImageInfo Pixel Format |
|
903 3. the creating RSgImage handle is not null |
|
904 4. the aSgImage handle is null |
|
905 5. the size and pixel format in TSgImageInfo is not the same as that of aSgImage |
|
906 6. the pixel stride specified is 0 when bitmap data is given |
|
907 @SYMTestExpectedResults The function should return |
|
908 1. KErrArgument or KErrNotSupported for the overload taking an RSgImage |
|
909 2. KErrNotSupported |
|
910 3. KErrInUse |
|
911 4. KErrArgument |
|
912 5. KErrNotSupported |
|
913 6. KErrArgument |
|
914 */ |
|
915 void CTSgImageGeneric::TestCreateImageInvalidL() |
|
916 { |
|
917 TestOpenDriverL(); |
|
918 RSgImage image; |
|
919 |
|
920 RSgImage validImage; |
|
921 TSgImageInfo validInfo(TSize(8,8), EUidPixelFormatRGB_565, ESgUsageBitOpenVgImage); |
|
922 TEST(KErrNone == validImage.Create(validInfo, KCrossImageData, KCrossImageDataStride)); |
|
923 |
|
924 //invalid info 1 - invalid width |
|
925 TSgImageInfo info1(TSize(-100,100), EUidPixelFormatRGB_565, ESgUsageBitOpenVgImage); |
|
926 TEST(KErrArgument == image.Create(info1, NULL, 0)); |
|
927 image.Close(); |
|
928 TEST(KErrArgument == image.Create(info1, KCrossImageData, KCrossImageDataStride)); |
|
929 image.Close(); |
|
930 //invalid height |
|
931 info1.iSizeInPixels = TSize(100, -100); |
|
932 TEST(KErrArgument == image.Create(info1, NULL, 0)); |
|
933 image.Close(); |
|
934 //Sizes don't match |
|
935 TEST(KErrNotSupported == image.Create(info1, validImage)); |
|
936 image.Close(); |
|
937 |
|
938 info1.iSizeInPixels = TSize(0,0); |
|
939 TEST(KErrArgument == image.Create(info1, NULL, 0)); |
|
940 image.Close(); |
|
941 TEST(KErrArgument == image.Create(info1, KCrossImageData, KCrossImageDataStride)); |
|
942 image.Close(); |
|
943 //Sizes don't match |
|
944 TEST(KErrNotSupported == image.Create(info1, validImage)); |
|
945 image.Close(); |
|
946 |
|
947 //Invalid usage |
|
948 info1.iUsage = KMaxTUint32; |
|
949 info1.iSizeInPixels = TSize(8,8); |
|
950 TEST(KErrNotSupported == image.Create(info1, KCrossImageData, KCrossImageDataStride)); |
|
951 image.Close(); |
|
952 TEST(KErrNotSupported == image.Create(info1, validImage)); |
|
953 image.Close(); |
|
954 |
|
955 //unsupported info 1 - invalid pixel format |
|
956 TSgImageInfo info2; |
|
957 info2.iSizeInPixels = TSize(8, 8); |
|
958 info2.iUsage = ESgUsageBitOpenVgImage; |
|
959 info2.iPixelFormat = EUidPixelFormatUnknown; |
|
960 TEST(KErrArgument == image.Create(info2, NULL, 0)); |
|
961 image.Close(); |
|
962 TEST(KErrArgument == image.Create(info2, KCrossImageData, KCrossImageDataStride)); |
|
963 image.Close(); |
|
964 |
|
965 //unsupported info 2 - large image size |
|
966 info2.iPixelFormat = ESgPixelFormatRGB_565; |
|
967 info2.iSizeInPixels = TSize(40000, 100); |
|
968 TEST(KErrTooBig == image.Create(info2, NULL, 0)); |
|
969 info2.iSizeInPixels = TSize(100, 40000); |
|
970 TEST(KErrTooBig == image.Create(info2, NULL, 0)); |
|
971 image.Close(); |
|
972 |
|
973 //non-null handle |
|
974 CreateImageL(image); |
|
975 TSgImageInfo info3; |
|
976 info3.iSizeInPixels = TSize(8, 8); |
|
977 info3.iUsage = ESgUsageBitOpenVgImage; |
|
978 info3.iPixelFormat = ESgPixelFormatRGB_565; |
|
979 |
|
980 TInt ret = image.Create(info3, NULL, 16); |
|
981 TEST(KErrInUse == ret); |
|
982 |
|
983 //non-null handle: create from an existing image |
|
984 RSgImage image1; |
|
985 CreateImageL(image1); |
|
986 TEST(KErrInUse == image1.Create(info3, image)); |
|
987 image1.Close(); |
|
988 |
|
989 //null existing image handle |
|
990 RSgImage image2; |
|
991 TEST(image2.IsNull()); |
|
992 TEST(KErrArgument == image1.Create(info3, image2)); |
|
993 |
|
994 //the size and pixel format in TSgImageInfo is not the same as that of aSgImage |
|
995 TSgImageInfo info4(TSize(100,100), ESgPixelFormatARGB_8888, ESgUsageBitOpenVgImage); |
|
996 TEST(KErrNotSupported == image1.Create(info4, image)); |
|
997 |
|
998 image1.GetInfo(info3); |
|
999 info4.iSizeInPixels = info3.iSizeInPixels; |
|
1000 info4.iPixelFormat = ESgPixelFormatXRGB_8888; |
|
1001 TEST(KErrNotSupported == image1.Create(info4, image)); |
|
1002 |
|
1003 image.Close(); |
|
1004 image1.Close(); |
|
1005 |
|
1006 TSgImageInfo info5(TSize(8,8), ESgPixelFormatRGB_565, ESgUsageBitOpenVgImage); |
|
1007 |
|
1008 TSgAttributeArray<1> attribArray; |
|
1009 attribArray[0].iUid = KNullUid; |
|
1010 attribArray[0].iValue = 0; |
|
1011 |
|
1012 TEST(KErrNotSupported == image1.Create(info5, KCrossImageData, KCrossImageDataStride, &attribArray)); |
|
1013 image1.Close(); |
|
1014 |
|
1015 //Stride of 0 |
|
1016 TEST(KErrArgument == image1.Create(info5, KCrossImageData, 0)); |
|
1017 image1.Close(); |
|
1018 |
|
1019 validImage.Close(); |
|
1020 |
|
1021 TestCloseDriver(); |
|
1022 } |
|
1023 |
|
1024 /** |
|
1025 @SYMTestCaseID GRAPHICS-RESOURCE-0039 |
|
1026 @SYMTestCaseDesc Calls GetInfo() on an invalid image. |
|
1027 @SYMPREQ PREQ2637 |
|
1028 @SYMFssID RSgImage::GetInfo(TSgImageInfo&) |
|
1029 @SYMTestPriority Low |
|
1030 @SYMTestType UT |
|
1031 @SYMTestPurpose Negative test to check the correct error is returned when the client |
|
1032 tries to get information on an invalid image. |
|
1033 @SYMTestActions Initialise the graphics resource component. |
|
1034 Call GetInfo() on an image that is not initialised. |
|
1035 @SYMTestExpectedResults GetInfo() should return KErrBadHandle |
|
1036 */ |
|
1037 void CTSgImageGeneric::TestGetInfoImageInvalidL() |
|
1038 { |
|
1039 TestOpenDriverL(); |
|
1040 RSgImage image; |
|
1041 TSgImageInfo info(TSize(5,5), ESgPixelFormatARGB_8888, ESgUsageBitOpenVgImage); |
|
1042 |
|
1043 //uninitialised image |
|
1044 TEST(KErrBadHandle == image.GetInfo(info)); |
|
1045 |
|
1046 TestCloseDriver(); |
|
1047 } |
|
1048 |
|
1049 /** |
|
1050 @SYMTestCaseID GRAPHICS-RESOURCE-0092 |
|
1051 @SYMTestCaseDesc Calls GetAttribute() on an invalid image. |
|
1052 @SYMPREQ PREQ2637 |
|
1053 @SYMFssID RSgImage::GetAttribute(TUid, TInt&) |
|
1054 @SYMTestPriority Low |
|
1055 @SYMTestType UT |
|
1056 @SYMTestPurpose Negative test to check the correct error is returned when the client |
|
1057 tries to get attributes on an invalid image. |
|
1058 @SYMTestActions Initialise the graphics resource component. |
|
1059 Call GetInfo on an image that is not initialised. |
|
1060 @SYMTestExpectedResults GetAttribute() should return KErrBadHandle |
|
1061 */ |
|
1062 void CTSgImageGeneric::TestGetAttributesImageInvalidL() |
|
1063 { |
|
1064 TestOpenDriverL(); |
|
1065 RSgImage image; |
|
1066 TSgImageInfo info(TSize(5,5), ESgPixelFormatARGB_8888, ESgUsageBitOpenVgImage); |
|
1067 |
|
1068 TUid uid = {0x12345678}; |
|
1069 TInt val = 0; |
|
1070 TEST(KErrBadHandle == image.GetAttribute(uid, val)); |
|
1071 |
|
1072 image.Close(); |
|
1073 |
|
1074 TestCloseDriver(); |
|
1075 } |
|
1076 |
|
1077 /** |
|
1078 @SYMTestCaseID GRAPHICS-RESOURCE-0100 |
|
1079 @SYMTestCaseDesc Creates images using negative and invalid data strides. |
|
1080 @SYMPREQ PREQ2637 |
|
1081 @SYMFssID RSgImage::Create(TUid, TInt&) |
|
1082 @SYMTestPriority Medium |
|
1083 @SYMTestType UT |
|
1084 @SYMTestPurpose Positive test for using negative data strides. |
|
1085 Negative test for using invalid data strides. |
|
1086 @SYMTestActions Initialise the graphics resource component. |
|
1087 1. Create an image with a data stride that is smaller than the width |
|
1088 of the image. |
|
1089 2. Create an image with a pointer to bitmap data, but 0 data stride. |
|
1090 3. Create an image with a negative data stride equal to the width |
|
1091 of the image. |
|
1092 4. Create an image with a negative data stride less than the width |
|
1093 of the image. |
|
1094 @SYMTestExpectedResults 1. Create() should return KErrArgument. |
|
1095 2. Create() should return KErrArgument. |
|
1096 3. Create() should successfully create the image and return KErrNone. |
|
1097 4. Create() should return KErrArgument. |
|
1098 */ |
|
1099 void CTSgImageGeneric::TestCreateImageDataStrideL() |
|
1100 { |
|
1101 TestOpenDriverL(); |
|
1102 |
|
1103 RSgImage image; |
|
1104 TSgImageInfo info1(TSize(8,8), EUidPixelFormatRGB_565, ESgUsageBitOpenVgImage); |
|
1105 |
|
1106 TEST(KErrArgument == image.Create(info1, KCrossImageData, KCrossImageDataStride-1)); |
|
1107 image.Close(); |
|
1108 TEST(KErrArgument == image.Create(info1, KCrossImageData, 0)); |
|
1109 image.Close(); |
|
1110 |
|
1111 TEST(KErrNone == image.Create(info1, KCrossImageData, -KCrossImageDataStride)); |
|
1112 image.Close(); |
|
1113 |
|
1114 TEST(KErrArgument == image.Create(info1, KCrossImageData, -KCrossImageDataStride+1)); |
|
1115 image.Close(); |
|
1116 |
|
1117 TestCloseDriver(); |
|
1118 } |
|
1119 |
|
1120 /** |
|
1121 @SYMTestCaseID GRAPHICS-RESOURCE-0048 |
|
1122 @SYMTestCaseDesc RSgImage stress tests |
|
1123 @SYMPREQ PREQ2637 |
|
1124 @SYMFssID RSgImage::Create(const TSgImageInfo&, const TAny*, TInt) |
|
1125 RSgImage::Close() |
|
1126 @SYMTestPriority Medium |
|
1127 @SYMTestType CT |
|
1128 @SYMTestPurpose To ensure creating and destroying RSgImage multiple times work well. |
|
1129 @SYMTestActions Create images 1000 times but only store KMaxImagesInArray of them |
|
1130 at one time in an RArray. When a new image is to be added to the |
|
1131 array, a random image from the array is removed. |
|
1132 @SYMTestExpectedResults There should be no panics or leaves. |
|
1133 */ |
|
1134 void CTSgImageGeneric::TestStress1L() |
|
1135 { |
|
1136 TestOpenDriverL(); |
|
1137 TSgImageInfo info; |
|
1138 info.iPixelFormat = EUidPixelFormatRGB_565; |
|
1139 info.iSizeInPixels = TSize(100, 100); |
|
1140 info.iUsage = ESgUsageBitOpenVgImage; |
|
1141 |
|
1142 TInt KMaxImagesInArray =40; |
|
1143 TInt64 seed = 0; |
|
1144 for (TInt count = 1000; count > 0; --count) |
|
1145 { |
|
1146 RSgImage image; |
|
1147 CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__); |
|
1148 CleanupClosePushL(image); |
|
1149 iTestImages.AppendL(image); |
|
1150 CleanupStack::Pop(); |
|
1151 if (iTestImages.Count() >= KMaxImagesInArray) |
|
1152 { |
|
1153 TInt i = Math::Rand(seed) % KMaxImagesInArray; |
|
1154 iTestImages[i].Close(); |
|
1155 iTestImages.Remove(i); |
|
1156 } |
|
1157 } |
|
1158 TInt count = iTestImages.Count(); |
|
1159 for(TInt i=0; i<count; ++i) |
|
1160 { |
|
1161 iTestImages[i].Close(); |
|
1162 } |
|
1163 iTestImages.Reset(); |
|
1164 TestCloseDriver(); |
|
1165 } |
|
1166 |
|
1167 /** |
|
1168 @SYMTestCaseID GRAPHICS-RESOURCE-0049 |
|
1169 @SYMTestCaseDesc RSgImage multiple threads open and close stress tests |
|
1170 @SYMPREQ PREQ2637 |
|
1171 @SYMFssID RSgImage::Open(const TSgDrawableId&) |
|
1172 RSgImage::Close() |
|
1173 @SYMTestPriority Medium |
|
1174 @SYMTestType CT |
|
1175 @SYMTestPurpose To ensure opening and destroying RSgImage multiple times and randomly |
|
1176 in other threads work well. |
|
1177 @SYMTestActions Create an image in the main thread. In a loop of 1000 times, randomly select |
|
1178 one of the five threads and either open or close the image depending on the |
|
1179 state of the thread. |
|
1180 @SYMTestExpectedResults There should be no panics or leaves. |
|
1181 */ |
|
1182 void CTSgImageGeneric::TestStress2L() |
|
1183 { |
|
1184 TestOpenDriverL(); |
|
1185 RSgImage image; |
|
1186 CreateImageL(image); |
|
1187 CleanupClosePushL(image); |
|
1188 const TSgDrawableId id = image.Id(); |
|
1189 |
|
1190 TSgImageInfo info; |
|
1191 TEST(KErrNone == image.GetInfo(info)); |
|
1192 TSgThreadTestInfo threadInfo(id, info, ESgresMultipleThreadStressTest); |
|
1193 |
|
1194 //create a semaphore |
|
1195 RSemaphore sem; |
|
1196 User::LeaveIfError(sem.CreateGlobal(KSecondThreadSemaphore, 0, EOwnerThread)); |
|
1197 CleanupClosePushL(sem); |
|
1198 |
|
1199 //create threads |
|
1200 const TInt KNoOfThreads = 5; |
|
1201 RArray<RThread> threads; |
|
1202 _LIT(KMultipleThreadName, "Multiple Threads Stress Test Thread "); |
|
1203 for (TInt i = 0; i < KNoOfThreads; ++i) |
|
1204 { |
|
1205 TBuf<50> threadName(KMultipleThreadName); |
|
1206 threadName.AppendNum(i); |
|
1207 RThread thread; |
|
1208 User::LeaveIfError(thread.Create(threadName, SgTestSecondThread::ThreadStart, KDefaultStackSize, KSecondThreadMinHeapSize, KSecondThreadMaxHeapSize, &threadInfo)); |
|
1209 thread.SetPriority(EPriorityLess); |
|
1210 threads.AppendL(thread); |
|
1211 } |
|
1212 // run threads |
|
1213 for (TInt i = 0; i < KNoOfThreads; ++i) |
|
1214 { |
|
1215 threads[i].Resume(); |
|
1216 } |
|
1217 // wait for the threads to terminate processing |
|
1218 for (TInt i = 0; i < KNoOfThreads; ++i) |
|
1219 { |
|
1220 sem.Wait(); |
|
1221 } |
|
1222 for (TInt i = 0; i < KNoOfThreads; ++i) |
|
1223 { |
|
1224 threads[i].Close(); |
|
1225 } |
|
1226 CleanupStack::PopAndDestroy(2, &image); // image, sem |
|
1227 TestCloseDriver(); |
|
1228 } |
|
1229 |
|
1230 /** |
|
1231 @SYMTestCaseID GRAPHICS-RESOURCE-0051 |
|
1232 @SYMTestCaseDesc Calls RSgImage::GetInterface() with an invalid image handle |
|
1233 @SYMPREQ PREQ2637 |
|
1234 @SYMFssID RSgImage::GetInterface(TUid, TAny*&) |
|
1235 @SYMTestPriority Low |
|
1236 @SYMTestType UT |
|
1237 @SYMTestPurpose Negative test to ensure calling GetInterface() with an invalid image handle |
|
1238 will cause a panic. |
|
1239 @SYMTestActions Initialise the graphics resource component and create an image in a second thread. |
|
1240 Declare another image and assign it to the current image handle. Close the current |
|
1241 image so the second image handle becomes invalid. Call GetInterface() on the |
|
1242 second handle. |
|
1243 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3(ESgPanicBadDrawableHandle). |
|
1244 */ |
|
1245 void CTSgImageGeneric::TestPanicImageGetInterfaceInvalidHandleL() |
|
1246 { |
|
1247 TSgImageInfo info(TSize(),0,0); |
|
1248 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageGetInterfaceInvalidHandle); |
|
1249 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1250 _LIT(KTestName, "TestImageGetInterfaceInvalidHandleLThread"); |
|
1251 CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName); |
|
1252 } |
|
1253 |
|
1254 /** |
|
1255 @SYMTestCaseID GRAPHICS-RESOURCE-0052 |
|
1256 @SYMTestCaseDesc Calls RSgImage::GetInterface() with a non-null handle and an uninitialised driver |
|
1257 @SYMPREQ PREQ2637 |
|
1258 @SYMFssID RSgImage::GetInterface(TUid, TAny*&) |
|
1259 @SYMTestPriority Low |
|
1260 @SYMTestType UT |
|
1261 @SYMTestPurpose Negative test to ensure calling GetInterface() with a non-null handle and an |
|
1262 uninitialised driver will cause a panic. |
|
1263 @SYMTestActions Initialise the graphics resource component and create an image in a second thread. |
|
1264 Declare another image and assign it to the current image handle. Close the current |
|
1265 image so the second image handle becomes invalid. Close the graphics resource driver. |
|
1266 Call GetInterface() on the second handle. |
|
1267 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver). |
|
1268 */ |
|
1269 void CTSgImageGeneric::TestPanicImageGetInterfaceNoDriverL() |
|
1270 { |
|
1271 TSgImageInfo info(TSize(),0,0); |
|
1272 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageGetInterfaceNoDriver); |
|
1273 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1274 _LIT(KTestName, "TestImageGetInterfaceNoDriverL"); |
|
1275 CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName); |
|
1276 } |
|
1277 |
|
1278 /** |
|
1279 @SYMTestCaseID GRAPHICS-RESOURCE-0053 |
|
1280 @SYMTestCaseDesc Calls RSgImage::Close() with an invalid image handle |
|
1281 @SYMPREQ PREQ2637 |
|
1282 @SYMFssID RSgImage::Close() |
|
1283 @SYMTestPriority Low |
|
1284 @SYMTestType UT |
|
1285 @SYMTestPurpose Negative test to ensure calling Close() with an invalid image handle will |
|
1286 cause a panic. |
|
1287 @SYMTestActions Initialise the graphics resource component and create an image in a second thread. |
|
1288 Declare another image and assign it to the current image handle. Close the current |
|
1289 image so the second image handle becomes invalid. Call Close() on the second handle. |
|
1290 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3(ESgPanicBadDrawableHandle). |
|
1291 */ |
|
1292 void CTSgImageGeneric::TestPanicImageCloseInvalidHandleL() |
|
1293 { |
|
1294 TSgImageInfo info(TSize(),0,0); |
|
1295 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageCloseInvalidHandle); |
|
1296 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1297 _LIT(KTestName, "TestImageCloseInvalidHandleL"); |
|
1298 CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName); |
|
1299 } |
|
1300 |
|
1301 /** |
|
1302 @SYMTestCaseID GRAPHICS-RESOURCE-0054 |
|
1303 @SYMTestCaseDesc Calls RSgImage::Close() with a non-null handle and an uninitialised driver |
|
1304 @SYMPREQ PREQ2637 |
|
1305 @SYMFssID RSgImage::Close() |
|
1306 @SYMTestPriority Low |
|
1307 @SYMTestType UT |
|
1308 @SYMTestPurpose Negative test to ensure calling Close() with a non-null handle and an |
|
1309 uninitialised driver will cause a panic. |
|
1310 @SYMTestActions Initialise the graphics resource component and create an image in a second thread. |
|
1311 Declare another image and assign it to the current image handle. Close the current |
|
1312 image so the second image handle becomes invalid. Close the graphics resource driver. |
|
1313 Call Close() on the second handle. |
|
1314 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver). |
|
1315 */ |
|
1316 void CTSgImageGeneric::TestPanicImageCloseNoDriverL() |
|
1317 { |
|
1318 TSgImageInfo info(TSize(),0,0); |
|
1319 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageCloseNoDriver); |
|
1320 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1321 _LIT(KTestName, "TestImageCloseNoDriverL"); |
|
1322 CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName); |
|
1323 } |
|
1324 |
|
1325 /** |
|
1326 @SYMTestCaseID GRAPHICS-RESOURCE-0055 |
|
1327 @SYMTestCaseDesc Calls RSgImage::Id() with an invalid image handle |
|
1328 @SYMPREQ PREQ2637 |
|
1329 @SYMFssID RSgImage::Id() |
|
1330 @SYMTestPriority Low |
|
1331 @SYMTestType UT |
|
1332 @SYMTestPurpose Negative test to ensure calling Id() with an invalid image handle will |
|
1333 cause a panic. |
|
1334 @SYMTestActions Initialise the graphics resource component and create an image in a second thread. |
|
1335 Declare another image and assign it to the current image handle. Close the current |
|
1336 image so the second image handle becomes invalid. Call Id() on the second |
|
1337 handle. |
|
1338 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3(ESgPanicBadDrawableHandle). |
|
1339 */ |
|
1340 void CTSgImageGeneric::TestPanicImageIdInvalidHandleL() |
|
1341 { |
|
1342 TSgImageInfo info(TSize(),0,0); |
|
1343 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageIdInvalidHandle); |
|
1344 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1345 _LIT(KTestName, "TestImageIdInvalidHandleL"); |
|
1346 CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName); |
|
1347 } |
|
1348 |
|
1349 /** |
|
1350 @SYMTestCaseID GRAPHICS-RESOURCE-0056 |
|
1351 @SYMTestCaseDesc Calls RSgImage::Id() with a non-null handle and an uninitialised driver |
|
1352 @SYMPREQ PREQ2637 |
|
1353 @SYMFssID RSgImage::Id() |
|
1354 @SYMTestPriority Low |
|
1355 @SYMTestType UT |
|
1356 @SYMTestPurpose Negative test to ensure calling Id() with a non-null handle and an |
|
1357 uninitialised driver will cause a panic. |
|
1358 @SYMTestActions Initialise the graphics resource component and create an image in a second thread. |
|
1359 Declare another image and assign it to the current image handle. Close the current |
|
1360 image so the second image handle becomes invalid. Close the graphics resource driver. |
|
1361 Call Id() on the second handle. |
|
1362 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver). |
|
1363 */ |
|
1364 void CTSgImageGeneric::TestPanicImageIdNoDriverL() |
|
1365 { |
|
1366 TSgImageInfo info(TSize(),0,0); |
|
1367 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageIdNoDriver); |
|
1368 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1369 _LIT(KTestName, "TestImageIdNoDriverL"); |
|
1370 CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName); |
|
1371 } |
|
1372 |
|
1373 /** |
|
1374 @SYMTestCaseID GRAPHICS-RESOURCE-0057 |
|
1375 @SYMTestCaseDesc Calls RSgImage::Create() with an invalid image handle |
|
1376 @SYMPREQ PREQ2637 |
|
1377 @SYMFssID RSgImage::Create(const TSgImageInfo&, const RSgImage&) |
|
1378 @SYMTestPriority Low |
|
1379 @SYMTestType UT |
|
1380 @SYMTestPurpose Negative test to ensure calling Create() with an invalid image handle will |
|
1381 cause a panic. |
|
1382 @SYMTestActions Initialise the graphics resource component and create an image in a second thread. |
|
1383 Declare another image and assign it to the current image handle. Close the current |
|
1384 image so the second image handle becomes invalid. Call Create() on the second |
|
1385 handle. |
|
1386 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3(ESgPanicBadDrawableHandle). |
|
1387 */ |
|
1388 void CTSgImageGeneric::TestPanicImageCreateInvalidHandleL() |
|
1389 { |
|
1390 TSgImageInfo info(TSize(),0,0); |
|
1391 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageCreateInvalidHandle); |
|
1392 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1393 _LIT(KTestName, "TestImageCreateInvalidHandleL"); |
|
1394 CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName); |
|
1395 } |
|
1396 |
|
1397 /** |
|
1398 @SYMTestCaseID GRAPHICS-RESOURCE-0058 |
|
1399 @SYMTestCaseDesc Calls RSgImage::GetInfo() with an invalid image handle |
|
1400 @SYMPREQ PREQ2637 |
|
1401 @SYMFssID RSgImage::GetInfo(TSgImageInfo&) |
|
1402 @SYMTestPriority Low |
|
1403 @SYMTestType UT |
|
1404 @SYMTestPurpose Negative test to ensure calling GetInfo() with an invalid image handle will |
|
1405 cause a panic. |
|
1406 @SYMTestActions Initialise the graphics resource component and create an image in a second thread. |
|
1407 Declare another image and assign it to the current image handle. Close the current |
|
1408 image so the second image handle becomes invalid. Call GetInfo() on the second |
|
1409 handle. |
|
1410 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3(ESgPanicBadDrawableHandle). |
|
1411 */ |
|
1412 void CTSgImageGeneric::TestPanicImageGetInfoInvalidHandleL() |
|
1413 { |
|
1414 TSgImageInfo info(TSize(),0,0); |
|
1415 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageGetInfoInvalidHandle); |
|
1416 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1417 _LIT(KTestName, "TestImageGetInfoInvalidHandleL"); |
|
1418 CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName); |
|
1419 } |
|
1420 |
|
1421 /** |
|
1422 @SYMTestCaseID GRAPHICS-RESOURCE-0059 |
|
1423 @SYMTestCaseDesc Calls RSgImage::GetInfo() with a non-null handle and an uninitialised driver |
|
1424 @SYMPREQ PREQ2637 |
|
1425 @SYMFssID SgImage::GetInfo(TSgImageInfo&) |
|
1426 @SYMTestPriority Low |
|
1427 @SYMTestType UT |
|
1428 @SYMTestPurpose Negative test to ensure calling GetInfo() with a non-null handle and an |
|
1429 uninitialised driver will cause a panic. |
|
1430 @SYMTestActions Initialise the graphics resource component and create an image in a second thread. |
|
1431 Declare another image and assign it to the current image handle. Close the current |
|
1432 image so the second image handle becomes invalid. Close the graphics resource driver. |
|
1433 Call GetInfo() on the second handle. |
|
1434 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver). |
|
1435 */ |
|
1436 void CTSgImageGeneric::TestPanicImageGetInfoNoDriverL() |
|
1437 { |
|
1438 TSgImageInfo info(TSize(),0,0); |
|
1439 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageGetInfoNoDriver); |
|
1440 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1441 _LIT(KTestName, "TestImageGetInfoNoDriverL"); |
|
1442 CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName); |
|
1443 } |
|
1444 |
|
1445 /** |
|
1446 @SYMTestCaseID GRAPHICS-RESOURCE-0082 |
|
1447 @SYMTestCaseDesc Calls RSgImage::Open() when the driver was not initialised. |
|
1448 @SYMPREQ PREQ2637 |
|
1449 @SYMFssID RSgImage::Open(const TSgDrawableId&, TUint32) |
|
1450 @SYMTestPriority Low |
|
1451 @SYMTestType UT |
|
1452 @SYMTestPurpose Negative test to ensure calling RSgImage::Open() with an uninitialised driver |
|
1453 will cause a panic. |
|
1454 @SYMTestActions Do not initialise the graphics resource component and call RSgImage::Open() |
|
1455 in a second thread. |
|
1456 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver). |
|
1457 */ |
|
1458 void CTSgImageGeneric::TestPanicImageOpenNoDriverL() |
|
1459 { |
|
1460 TSgImageInfo info(TSize(),0,0); |
|
1461 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageOpenNoDriver); |
|
1462 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1463 _LIT(KTestName, "TestPanicImageOpenNoDriverL"); |
|
1464 CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName); |
|
1465 } |
|
1466 |
|
1467 /** |
|
1468 @SYMTestCaseID GRAPHICS-RESOURCE-0083 |
|
1469 @SYMTestCaseDesc Creates an image from memory when the driver was not initialised. |
|
1470 @SYMPREQ PREQ2637 |
|
1471 @SYMFssID RSgImage::Create(const TSgImageInfo&, const TAny*, TInt) |
|
1472 @SYMTestPriority Low |
|
1473 @SYMTestType UT |
|
1474 @SYMTestPurpose Negative test to ensure calling RSgImage::Create() with an uninitialised |
|
1475 driver will cause a panic. |
|
1476 @SYMTestActions Do not initialise the graphics resource component and call RSgImage::Open() |
|
1477 in a second thread. |
|
1478 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver). |
|
1479 */ |
|
1480 void CTSgImageGeneric::TestPanicImageCreateNoDriver1L() |
|
1481 { |
|
1482 TSgImageInfo info(TSize(),0,0); |
|
1483 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageCreateNoDriver1); |
|
1484 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1485 _LIT(KTestName, "TestPanicImageCreateNoDriver1L"); |
|
1486 CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName); |
|
1487 } |
|
1488 |
|
1489 /** |
|
1490 @SYMTestCaseID GRAPHICS-RESOURCE-0084 |
|
1491 @SYMTestCaseDesc Creates an image from an existing image when the driver was not initialised. |
|
1492 @SYMPREQ PREQ2637 |
|
1493 @SYMFssID RSgImage::Create(const TSgImageInfo&, const RSgImage&) |
|
1494 @SYMTestPriority Low |
|
1495 @SYMTestType UT |
|
1496 @SYMTestPurpose Negative test to ensure calling RSgImage::Create() with an uninitialised driver |
|
1497 will cause a panic. |
|
1498 @SYMTestActions Do not initialise the graphics resource component and call RSgImage::Open() in |
|
1499 a second thread. |
|
1500 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver). |
|
1501 */ |
|
1502 void CTSgImageGeneric::TestPanicImageCreateNoDriver2L() |
|
1503 { |
|
1504 TSgImageInfo info(TSize(),0,0); |
|
1505 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageCreateNoDriver2); |
|
1506 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1507 _LIT(KTestName, "TestPanicImageCreateNoDriver2L"); |
|
1508 CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName); |
|
1509 } |
|
1510 |
|
1511 /** |
|
1512 @SYMTestCaseID GRAPHICS-RESOURCE-0088 |
|
1513 @SYMTestCaseDesc Calls RSgImage::DrawableType() when the driver was not initialised. |
|
1514 @SYMPREQ PREQ2637 |
|
1515 @SYMFssID RSgImage::DrawableType() |
|
1516 @SYMTestPriority Low |
|
1517 @SYMTestType UT |
|
1518 @SYMTestPurpose Negative test to ensure calling RSgImage::DrawableType() with an uninitialised |
|
1519 driver will cause a panic. |
|
1520 @SYMTestActions Do not initialise the graphics resource component and call RSgImage::DrawableType() |
|
1521 in a second thread. |
|
1522 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver). |
|
1523 */ |
|
1524 void CTSgImageGeneric::TestPanicImageDrawableTypeNoDriverL() |
|
1525 { |
|
1526 TSgImageInfo info(TSize(),0,0); |
|
1527 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageDrawableTypeNoDriver); |
|
1528 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1529 _LIT(KTestName, "TestPanicImageOpenNoDriverL"); |
|
1530 CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName); |
|
1531 } |
|
1532 |
|
1533 /** |
|
1534 @SYMTestCaseID GRAPHICS-RESOURCE-0089 |
|
1535 @SYMTestCaseDesc Calls RSgImage::DrawableType() with an invalid image handle |
|
1536 @SYMPREQ PREQ2637 |
|
1537 @SYMFssID RSgImage::DrawableType() |
|
1538 @SYMTestPriority Low |
|
1539 @SYMTestType UT |
|
1540 @SYMTestPurpose Negative test to ensure calling RSgImage::DrawableType() with an uninitialised |
|
1541 driver will cause a panic. |
|
1542 @SYMTestActions Do not initialise the graphics resource component and call RSgImage::DrawableType() |
|
1543 in a second thread. |
|
1544 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3 (ESgPanicBadDrawableHandle). |
|
1545 */ |
|
1546 void CTSgImageGeneric::TestPanicImageDrawableTypeInvalidHandleL() |
|
1547 { |
|
1548 TSgImageInfo info(TSize(),0,0); |
|
1549 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageDrawableTypeInvalidHandle); |
|
1550 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1551 _LIT(KTestName, "TestPanicImageOpenNoDriverL"); |
|
1552 CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName); |
|
1553 } |
|
1554 |
|
1555 /** |
|
1556 @SYMTestCaseID GRAPHICS-RESOURCE-0090 |
|
1557 @SYMTestCaseDesc Calls RSgImage::DrawableType() with an invalid image handle |
|
1558 @SYMPREQ PREQ2637 |
|
1559 @SYMFssID RSgImage::GetAttribute() |
|
1560 @SYMTestPriority Low |
|
1561 @SYMTestType UT |
|
1562 @SYMTestPurpose Negative test to ensure calling RSgImage::GetAttribute() with an invalid handle |
|
1563 will cause a panic. |
|
1564 @SYMTestActions Initialise the graphics resource component and call RSgImage::GetAttribute() |
|
1565 in a second thread with an invalid handle. |
|
1566 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3 (ESgPanicBadDrawableHandle). |
|
1567 */ |
|
1568 void CTSgImageGeneric::TestPanicImageGetAttributeInvalidHandleL() |
|
1569 { |
|
1570 TSgImageInfo info(TSize(),0,0); |
|
1571 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageGetAttributeInvalidHandle); |
|
1572 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1573 _LIT(KTestName, "TestPanicImageGetAttributeInvalidHandleL"); |
|
1574 CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName); |
|
1575 } |
|
1576 |
|
1577 /** |
|
1578 @SYMTestCaseID GRAPHICS-RESOURCE-0091 |
|
1579 @SYMTestCaseDesc Calls RSgImage::GetAttribute() with no open driver |
|
1580 @SYMPREQ PREQ2637 |
|
1581 @SYMFssID RSgImage::GetAttribute() |
|
1582 @SYMTestPriority Low |
|
1583 @SYMTestType UT |
|
1584 @SYMTestPurpose Negative test to ensure calling RSgImage::GetAttribute() with an uninitialised |
|
1585 driver will cause a panic. |
|
1586 @SYMTestActions Do not initialise the graphics resource component and call RSgImage::GetAttribute() |
|
1587 in a second thread. |
|
1588 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver). |
|
1589 */ |
|
1590 void CTSgImageGeneric::TestPanicImageGetAttributeNoDriverL() |
|
1591 { |
|
1592 TSgImageInfo info(TSize(),0,0); |
|
1593 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageGetAttributeNoDriver); |
|
1594 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1595 _LIT(KTestName, "TestPanicImageGetAttributeNoDriverL"); |
|
1596 CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName); |
|
1597 } |
|
1598 |
|
1599 /** |
|
1600 @SYMTestCaseID GRAPHICS-RESOURCE-0097 |
|
1601 @SYMTestCaseDesc Access out of bound TSgAttibuteArray index |
|
1602 @SYMPREQ PREQ2637 |
|
1603 @SYMFssID TSgAttributeArray |
|
1604 @SYMTestPriority Low |
|
1605 @SYMTestType UT |
|
1606 @SYMTestPurpose Negative test to ensure calling an out of bound index on a TSgAttributeArray |
|
1607 will cause a panic. |
|
1608 @SYMTestActions Create a TSgAttributeArray of size 5 and attempt to access an element higher |
|
1609 than the size. |
|
1610 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 4 (ESgPanicBadAttributeArrayIndex). |
|
1611 */ |
|
1612 void CTSgImageGeneric::TestPanicImageAttributeArrayInvalidIndexL() |
|
1613 { |
|
1614 TSgImageInfo info(TSize(),0,0); |
|
1615 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicAttributeArrayInvalidIndex); |
|
1616 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1617 _LIT(KTestName, "AttributeArrayInvalidIndexL"); |
|
1618 CreateSecondThreadAndCheckPanicL(threadInfo, 4, exitCategoryName, KTestName); |
|
1619 } |
|
1620 |
|
1621 /** |
|
1622 @SYMTestCaseID GRAPHICS-RESOURCE-0098 |
|
1623 @SYMTestCaseDesc Access out of bound TSgAttibuteArray index |
|
1624 @SYMPREQ PREQ2637 |
|
1625 @SYMFssID TSgAttributeArray |
|
1626 @SYMTestPriority Low |
|
1627 @SYMTestType UT |
|
1628 @SYMTestPurpose Negative test to ensure calling an out of bound index on a TSgAttributeArray |
|
1629 will cause a panic. |
|
1630 @SYMTestActions Create a TSgAttributeArray of size 5 and attempt to access an element higher |
|
1631 than the size. |
|
1632 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 4 (ESgPanicBadAttributeArrayIndex). |
|
1633 */ |
|
1634 void CTSgImageGeneric::TestPanicImageAttributeArrayInvalidIndex2L() |
|
1635 { |
|
1636 TSgImageInfo info(TSize(),0,0); |
|
1637 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicAttributeArrayInvalidIndex2); |
|
1638 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1639 _LIT(KTestName, "AttributeArrayInvalidIndexL"); |
|
1640 CreateSecondThreadAndCheckPanicL(threadInfo, 4, exitCategoryName, KTestName); |
|
1641 } |
|
1642 |
|
1643 /** |
|
1644 @SYMTestCaseID GRAPHICS-RESOURCE-0101 |
|
1645 @SYMTestCaseDesc Close an RSgDriver with open resources |
|
1646 @SYMPREQ PREQ2637 |
|
1647 @SYMFssID RSgDriver |
|
1648 @SYMTestPriority Low |
|
1649 @SYMTestType UT |
|
1650 @SYMTestPurpose Negative test to ensure closing a driver with open resources will cause a panic. |
|
1651 @SYMTestActions Create an RSgImage on an open driver, then close the driver. |
|
1652 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 2 (ESgPanicUnclosedResources). |
|
1653 */ |
|
1654 void CTSgImageGeneric::TestPanicDriverCloseOpenResourcesL() |
|
1655 { |
|
1656 TSgImageInfo info(TSize(),0,0); |
|
1657 TSgProcessTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondProcessPanicDriverCloseOpenResources); |
|
1658 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
1659 CreateSecondProcessAndCheckPanicL(threadInfo, 2, exitCategoryName, KSecondProcess); |
|
1660 } |
|
1661 |
|
1662 /** |
|
1663 @SYMTestCaseID GRAPHICS-RESOURCE-0102 |
|
1664 @SYMTestCaseDesc Open/Close RSgDriver and Create/Close RSgImage in separate threads |
|
1665 @SYMPREQ PREQ2637 |
|
1666 @SYMFssID RSgDriver, RSgImage |
|
1667 @SYMTestPriority High |
|
1668 @SYMTestType UT |
|
1669 @SYMTestPurpose To ensure that it is possible to Open/Close the RSgDriver from |
|
1670 a separate thread, and to ensure that it is possible to Create/Open/Close |
|
1671 RSgImages from a seperate thread. |
|
1672 @SYMTestActions 1. Declare a RSgDriver, and pass to another thread to open. |
|
1673 2. Declare a RSgImage, and pass to another thread to create. |
|
1674 3. Pass created RSgImage to another thread to Open(). |
|
1675 4. Pass the image to another thread to Close(). |
|
1676 5. Pass the RSgDriver to another thread to Close() |
|
1677 @SYMTestExpectedResults All steps to succeed with no errors reported. |
|
1678 */ |
|
1679 void CTSgImageGeneric::TestCreateOpenCloseImageAndDriverInSecondThreadL() |
|
1680 { |
|
1681 TSgImageInfo info(TSize(),0,0); |
|
1682 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadOpenPassedDriver); |
|
1683 |
|
1684 RSgDriver driver; |
|
1685 threadInfo.iSgDriver = &driver; |
|
1686 |
|
1687 RSgImage image; |
|
1688 threadInfo.iSgImage = ℑ |
|
1689 |
|
1690 //Open the driver in another thread |
|
1691 TEST(CreateSecondThreadAndDoTestL(threadInfo)==0); |
|
1692 |
|
1693 //Create the image in a thread |
|
1694 threadInfo.iTestCase = ESgresSecondThreadCreatePassedImage; |
|
1695 TEST(CreateSecondThreadAndDoTestL(threadInfo)==0); |
|
1696 |
|
1697 //Now try opening the image in another thread |
|
1698 RSgImage image2; |
|
1699 threadInfo.iTestCase = ESgresSecondThreadOpenPassedImage; |
|
1700 threadInfo.iDrawableId = image.Id(); |
|
1701 threadInfo.iSgImage = &image2; |
|
1702 TEST(CreateSecondThreadAndDoTestL(threadInfo)==0); |
|
1703 |
|
1704 //Close the "Opened" image in another thread |
|
1705 threadInfo.iTestCase = ESgresSecondThreadClosePassedImage; |
|
1706 TEST(CreateSecondThreadAndDoTestL(threadInfo)==0); |
|
1707 |
|
1708 //Close the "Created" image in another thread |
|
1709 threadInfo.iTestCase = ESgresSecondThreadClosePassedImage; |
|
1710 threadInfo.iSgImage = ℑ |
|
1711 TEST(CreateSecondThreadAndDoTestL(threadInfo)==0); |
|
1712 |
|
1713 //Close the driver in another thread |
|
1714 threadInfo.iTestCase = ESgresSecondThreadClosePassedDriver; |
|
1715 TEST(CreateSecondThreadAndDoTestL(threadInfo)==0); |
|
1716 } |
|
1717 |
|
1718 /** |
|
1719 @SYMTestCaseID GRAPHICS-RESOURCE-0104 |
|
1720 @SYMTestCaseDesc Open a RSgImage using multiple threads. |
|
1721 @SYMDEF ou1cimx1#197357 |
|
1722 @SYMFssID RSgImage |
|
1723 @SYMTestPriority Low |
|
1724 @SYMTestType UT |
|
1725 @SYMTestPurpose To show that images can be opened safely when used with multiple threads in |
|
1726 separate processes. |
|
1727 @SYMTestActions 1. Process A, creates an RSgImage |
|
1728 2. Process B, creates a secondary thread, which creates a handle to the image |
|
1729 created in A. |
|
1730 3. Process B, primary thread opens a handle to the same image. |
|
1731 4. Process B, secondary thread closes the handle and terminates thread. |
|
1732 5. Process B, primary thread waits for thread cleanup, then attempts to |
|
1733 access the data of the image by creating a copy of it. |
|
1734 @SYMTestExpectedResults All steps to succeed with no errors reported. |
|
1735 */ |
|
1736 void CTSgImageGeneric::TestOpenImageMultithreadedL() |
|
1737 { |
|
1738 TestOpenDriverL(); |
|
1739 RSgImage image; |
|
1740 CreateImageL(image); |
|
1741 CleanupClosePushL(image); |
|
1742 |
|
1743 TSgImageInfo info; |
|
1744 TInt err = image.GetInfo(info); |
|
1745 TESTE(err == KErrNone, err); |
|
1746 |
|
1747 TSgProcessTestInfo processInfo(image.Id(), info, ESgresSecondProcessOpenImageMultithreaded); |
|
1748 TInt testResult = 0; |
|
1749 TRAP(err, testResult = CreateSecondProcessAndDoTestL(KSecondProcess, processInfo)); |
|
1750 TESTE(err == KErrNone, err); |
|
1751 TEST(testResult & EFirstTestPassed); |
|
1752 TEST(testResult & ESecondTestPassed); |
|
1753 TEST(testResult <= (EFirstTestPassed | ESecondTestPassed)); |
|
1754 |
|
1755 CleanupStack::PopAndDestroy(1); // image |
|
1756 TestCloseDriver(); |
|
1757 } |