|
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 #include "tdrawbitmap.h" |
|
17 |
|
18 CTDrawBitmap::CTDrawBitmap() |
|
19 { |
|
20 SetTestStepName(KTDirectGdiDrawBitmapStep); |
|
21 } |
|
22 |
|
23 CTDrawBitmap::~CTDrawBitmap() |
|
24 { |
|
25 } |
|
26 |
|
27 /** |
|
28 Override of base class pure virtual |
|
29 Lists the tests to be run |
|
30 */ |
|
31 void CTDrawBitmap::RunTestsL() |
|
32 { |
|
33 if (iUseDirectGdi && !iUseSwDirectGdi) |
|
34 { |
|
35 // In the event that a test leaves after a BitBlt() or DrawBitmap() has occurred |
|
36 // the vgimage cache will need to be reset. |
|
37 // This needs to be the first item on the cleanupstack, |
|
38 // as some tests perform pushes and pops of bitmaps. |
|
39 CleanupStack::PushL(TCleanupItem(ResetCache, iVgImageCache)); |
|
40 } |
|
41 if(!iLargeTarget) |
|
42 { |
|
43 iTestParams.iDoCompressed = ETrue; |
|
44 SetTestStepID(_L("GRAPHICS-DIRECTGDI-DRAWBITMAP-0001")); |
|
45 TestBasicL(); |
|
46 RecordTestResultL(); |
|
47 iTestParams.iDoCompressed = EFalse; |
|
48 SetTestStepID(_L("GRAPHICS-DIRECTGDI-DRAWBITMAP-0003")); |
|
49 TestInvalidParametersL(); |
|
50 RecordTestResultL(); |
|
51 SetTestStepID(_L("GRAPHICS-DIRECTGDI-DRAWBITMAP-0005")); |
|
52 TestSourceBitmapCloningL(); |
|
53 RecordTestResultL(); |
|
54 SetTestStepID(_L("GRAPHICS-DIRECTGDI-DRAWBITMAP-0006")); |
|
55 TestDrawModeL(); |
|
56 RecordTestResultL(); |
|
57 SetTestStepID(_L("GRAPHICS-DIRECTGDI-DRAWBITMAP-0007")); |
|
58 TestSetOriginL(); |
|
59 RecordTestResultL(); |
|
60 } |
|
61 else |
|
62 { |
|
63 SetTestStepID(_L("GRAPHICS-DIRECTGDI-DRAWBITMAP-0002")); |
|
64 TestPositioningL(); |
|
65 RecordTestResultL(); |
|
66 SetTestStepID(_L("GRAPHICS-DIRECTGDI-DRAWBITMAP-0004")); |
|
67 TestScalingL(); |
|
68 RecordTestResultL(); |
|
69 } |
|
70 if (iUseDirectGdi && !iUseSwDirectGdi) |
|
71 { |
|
72 CleanupStack::PopAndDestroy(iVgImageCache); |
|
73 } |
|
74 } |
|
75 |
|
76 /** |
|
77 @SYMTestCaseID |
|
78 GRAPHICS-DIRECTGDI-DRAWBITMAP-0001 |
|
79 |
|
80 @SYMPREQ |
|
81 PREQ39 |
|
82 |
|
83 @SYMREQ |
|
84 REQ9199 |
|
85 REQ9204 |
|
86 REQ9195 |
|
87 REQ9201 |
|
88 REQ9202 |
|
89 REQ9222 |
|
90 REQ9223 |
|
91 REQ9236 |
|
92 REQ9237 |
|
93 |
|
94 @SYMTestCaseDesc |
|
95 Bitmap drawing basic functionality test. |
|
96 |
|
97 @SYMTestPriority |
|
98 Critical |
|
99 |
|
100 @SYMTestStatus |
|
101 Implemented |
|
102 |
|
103 @SYMTestActions |
|
104 Test bitmap drawing for simple and valid parameters: |
|
105 - Set the origin at TPoint(-35,80) |
|
106 - Draw a stretched bitmap at TPoint(55,-60) |
|
107 |
|
108 @SYMTestExpectedResults |
|
109 Source bitmap should be copied into drawing target. |
|
110 Valid bitmap should be created. This bitmap shall be compared |
|
111 to a reference bitmap. |
|
112 */ |
|
113 void CTDrawBitmap::TestBasicL() |
|
114 { |
|
115 _LIT(KTestName, "DrawBitmap-Basic"); |
|
116 if(!iRunningOomTests) |
|
117 { |
|
118 INFO_PRINTF1(KTestName); |
|
119 } |
|
120 |
|
121 ResetGc(); |
|
122 |
|
123 CFbsBitmap* bitmap; |
|
124 if(iTestParams.iDoCompressed) |
|
125 { |
|
126 bitmap = iCompressedBitmap; |
|
127 } |
|
128 else |
|
129 { |
|
130 bitmap = iCheckedBoardBitmap2; |
|
131 } |
|
132 |
|
133 iGc->DrawBitmap(TRect(TPoint(20, 20), bitmap->SizeInPixels()), *bitmap, TRect(10, 10, 130, 130)); |
|
134 TESTNOERRORL(iGc->GetError()); |
|
135 |
|
136 if(!iTestParams.iDoCompressed) |
|
137 WriteTargetOutput(KTestName()); |
|
138 } |
|
139 |
|
140 /** |
|
141 @SYMTestCaseID |
|
142 GRAPHICS-DIRECTGDI-DRAWBITMAP-0002 |
|
143 |
|
144 @SYMPREQ |
|
145 PREQ39 |
|
146 |
|
147 @SYMREQ |
|
148 REQ9199 |
|
149 REQ9204 |
|
150 REQ9195 |
|
151 REQ9201 |
|
152 REQ9202 |
|
153 REQ9222 |
|
154 REQ9223 |
|
155 REQ9236 |
|
156 REQ9237 |
|
157 |
|
158 @SYMTestCaseDesc |
|
159 Test regularity of bitmap positioning. |
|
160 |
|
161 @SYMTestPriority |
|
162 Critical |
|
163 |
|
164 @SYMTestStatus |
|
165 Implemented |
|
166 |
|
167 @SYMTestActions |
|
168 Test positioning functionality of DrawBitmap() methods. Test boundary |
|
169 conditions and clipping to surface area. |
|
170 Covers the whole target bitmap starting from TPoint(-30,-30) with staggered blits of a small 8x8 bitmap. |
|
171 |
|
172 @SYMTestExpectedResults |
|
173 Source bitmap should be drawn tiled in a staggered fashion across the whole target. Clipping should be applied. |
|
174 Valid bitmap should be created. This bitmap shall be compared to a reference bitmap. |
|
175 */ |
|
176 void CTDrawBitmap::TestPositioningL() |
|
177 { |
|
178 _LIT(KTestName, "DrawBitmap-Positioning"); |
|
179 if(!iRunningOomTests) |
|
180 { |
|
181 INFO_PRINTF1(KTestName); |
|
182 } |
|
183 iTestParams.iDoCompressed = ETrue; |
|
184 TestPositioningBaseL(KTestName(), EDrawBitmap); |
|
185 iTestParams.iDoCompressed = EFalse; |
|
186 TestPositioningBaseL(KTestName(), EDrawBitmap); |
|
187 } |
|
188 |
|
189 /** |
|
190 @SYMTestCaseID |
|
191 GRAPHICS-DIRECTGDI-DRAWBITMAP-0003 |
|
192 |
|
193 @SYMPREQ |
|
194 PREQ39 |
|
195 |
|
196 @SYMREQ |
|
197 REQ9199 |
|
198 REQ9204 |
|
199 REQ9195 |
|
200 REQ9222 |
|
201 REQ9223 |
|
202 REQ9236 |
|
203 REQ9237 |
|
204 |
|
205 @SYMTestCaseDesc |
|
206 Test functions behaviour after calling with invalid parameters. |
|
207 |
|
208 @SYMTestPriority |
|
209 Critical |
|
210 |
|
211 @SYMTestStatus |
|
212 Implemented |
|
213 |
|
214 @SYMTestActions |
|
215 Set valid parameters (see DrawBitmap-BasicL). Replace individual parameters |
|
216 with Invalid ones: |
|
217 Invalid source rectangles |
|
218 aSourceRect : negative source rectangle starting point or size |
|
219 TRect( TPoint( -30, -30), TSize(-10, -10) ) |
|
220 aSourceRect : source rectangle not compatible with bitmap |
|
221 TRect( TSize(aBitmap->SizeInPixel(). iWidth + 10, aBitmap->SizeInPixel(). IHeight + 10)) |
|
222 aSourceRect : swapped points in source rectangle |
|
223 TRect( TPoint( 100, 100 ) , TPoint( 0, 0 ) ) |
|
224 Invalid destination rectangle (aDestRect): |
|
225 negative size |
|
226 Invalid source bitmap |
|
227 zero size bitmap |
|
228 not initialized bitmap |
|
229 |
|
230 @SYMTestExpectedResults |
|
231 Function should detect invalid parameters and return. |
|
232 Nothing will be drawn on the target surface. |
|
233 */ |
|
234 void CTDrawBitmap::TestInvalidParametersL() |
|
235 { |
|
236 _LIT(KTestName, "DrawBitmap-InvalidParameters"); |
|
237 if(!iRunningOomTests) |
|
238 { |
|
239 INFO_PRINTF1(KTestName); |
|
240 } |
|
241 |
|
242 TestInvalidParametersBaseL(KTestName(), EDrawBitmap); |
|
243 } |
|
244 |
|
245 /** |
|
246 @SYMTestCaseID |
|
247 GRAPHICS-DIRECTGDI-DRAWBITMAP-0004 |
|
248 |
|
249 @SYMPREQ |
|
250 PREQ39 |
|
251 |
|
252 @SYMREQ |
|
253 REQ9199 |
|
254 REQ9204 |
|
255 REQ9195 |
|
256 REQ9201 |
|
257 REQ9202 |
|
258 REQ9222 |
|
259 REQ9223 |
|
260 REQ9236 |
|
261 REQ9237 |
|
262 |
|
263 @SYMTestCaseDesc |
|
264 Test regularity of bitmap scaling. |
|
265 |
|
266 @SYMTestPriority |
|
267 Critical |
|
268 |
|
269 @SYMTestStatus |
|
270 Implemented |
|
271 |
|
272 @SYMTestActions |
|
273 Test scaling implementation of DrawBitmap() methods : scaling down of a normal |
|
274 bitmap and scaling up of a bitmap fragment. |
|
275 |
|
276 @SYMTestExpectedResults |
|
277 Scaled bitmap should be drawn in a target area. Valid bitmap should be created. |
|
278 The bitmap should be properly scaled. This bitmap shall be compared to a reference |
|
279 bitmap. |
|
280 */ |
|
281 void CTDrawBitmap::TestScalingL() |
|
282 { |
|
283 _LIT(KTestName, "DrawBitmap-Scaling"); |
|
284 if(!iRunningOomTests) |
|
285 { |
|
286 INFO_PRINTF1(KTestName); |
|
287 } |
|
288 |
|
289 TInt width = iGdiTarget->SizeInPixels().iWidth; |
|
290 TInt height = iGdiTarget->SizeInPixels().iHeight; |
|
291 |
|
292 CFbsBitmap* bitmap1 = iCheckedBoardBitmap1; |
|
293 TInt bmp1Width = bitmap1->SizeInPixels().iWidth; |
|
294 TInt bmp1Height = bitmap1->SizeInPixels().iHeight; |
|
295 CFbsBitmap* bitmap2 = iCheckedBoardBitmap2; |
|
296 TInt bmp2Width = bitmap2->SizeInPixels().iWidth; |
|
297 TInt bmp2Height = bitmap2->SizeInPixels().iHeight; |
|
298 |
|
299 ResetGc(); |
|
300 |
|
301 // small bitmap - extrem magnification |
|
302 TReal32 scale = 1.0f; |
|
303 TReal32 scaleFactor = 1.55f; |
|
304 TInt posX = 1; |
|
305 for(TInt j=0; j<6; j++) |
|
306 { |
|
307 TSize size(static_cast<TInt>(bmp1Width*scale), static_cast<TInt>(bmp1Height*scale)); |
|
308 TPoint pos(posX, height/4-size.iHeight/2); |
|
309 |
|
310 iGc->DrawBitmap(TRect(pos, size), *bitmap1); |
|
311 |
|
312 posX += size.iWidth+2; |
|
313 scale *= scaleFactor; |
|
314 } |
|
315 |
|
316 // large bitmap - extreme minification |
|
317 |
|
318 scale /= scaleFactor; |
|
319 posX = 1; |
|
320 for(TInt j=5; j>=0; j--) |
|
321 { |
|
322 TSize size(static_cast<TInt>(bmp1Width*scale), static_cast<TInt>(bmp1Height*scale)); |
|
323 TPoint pos(posX, 3*height/4-size.iHeight/2); |
|
324 |
|
325 iGc->DrawBitmap(TRect(pos, size), *bitmap2); |
|
326 |
|
327 posX += size.iWidth+2; |
|
328 scale /= scaleFactor; |
|
329 } |
|
330 |
|
331 TESTNOERRORL(iGc->GetError()); |
|
332 |
|
333 TBuf<30> testName; |
|
334 testName.Append(KTestName); |
|
335 WriteTargetOutput(testName); |
|
336 } |
|
337 |
|
338 /** |
|
339 @SYMTestCaseID |
|
340 GRAPHICS-DIRECTGDI-DRAWBITMAP-0005 |
|
341 |
|
342 @SYMPREQ |
|
343 PREQ39 |
|
344 |
|
345 @SYMREQ |
|
346 REQ9199 |
|
347 REQ9204 |
|
348 REQ9195 |
|
349 REQ9201 |
|
350 REQ9202 |
|
351 REQ9222 |
|
352 REQ9223 |
|
353 REQ9236 |
|
354 REQ9237 |
|
355 |
|
356 @SYMTestCaseDesc |
|
357 Tests that a bitmap is still drawn successfully if it is deleted |
|
358 right after the call to DrawBitmap() but before Finish() is called. |
|
359 |
|
360 @SYMTestPriority |
|
361 Critical |
|
362 |
|
363 @SYMTestStatus |
|
364 Implemented |
|
365 |
|
366 @SYMTestActions |
|
367 For each method: |
|
368 1. Call method with valid parameters (see DrawBitmap-Basic). |
|
369 2. Right after returning from method call, destroy the source bitmap. |
|
370 3. Call the method again with the same bitmap parameter. |
|
371 Repeat p. 1-3 a few times. |
|
372 |
|
373 @SYMTestExpectedResults |
|
374 Source bitmap should be copied into target area. Memory leaks should not be |
|
375 created. Valid bitmap should be created. This bitmap should be the same as |
|
376 a reference bitmap. |
|
377 */ |
|
378 void CTDrawBitmap::TestSourceBitmapCloningL() |
|
379 { |
|
380 _LIT(KTestName, "DrawBitmap-SourceBitmapCloning"); |
|
381 if(!iRunningOomTests) |
|
382 { |
|
383 INFO_PRINTF1(KTestName); |
|
384 } |
|
385 |
|
386 iTestParams.iDoCompressed = ETrue; |
|
387 TestSourceBitmapCloningBaseL(KTestName(), EDrawBitmap); |
|
388 iTestParams.iDoCompressed = EFalse; |
|
389 TestSourceBitmapCloningBaseL(KTestName(), EDrawBitmap); |
|
390 } |
|
391 |
|
392 /** |
|
393 @SYMTestCaseID |
|
394 GRAPHICS-DIRECTGDI-DRAWBITMAP-0006 |
|
395 |
|
396 @SYMPREQ |
|
397 PREQ39 |
|
398 |
|
399 @SYMREQ |
|
400 REQ9199 |
|
401 REQ9204 |
|
402 REQ9195 |
|
403 REQ9201 |
|
404 REQ9202 |
|
405 REQ9222 |
|
406 REQ9223 |
|
407 REQ9236 |
|
408 REQ9237 |
|
409 |
|
410 @SYMTestCaseDesc |
|
411 Test correctness of drawing bitmaps in all possible draw modes. |
|
412 |
|
413 @SYMTestPriority |
|
414 Critical |
|
415 |
|
416 @SYMTestStatus |
|
417 Implemented |
|
418 |
|
419 @SYMTestActions |
|
420 Set valid parameters (see DrawBitmap-Basic). |
|
421 Use the semi-transparent source bitmap (aBitmap). |
|
422 Set drawmode to EDrawModeWriteAlpha and call the methods. |
|
423 Set drawmode to EDrawModePEN and call the methods. |
|
424 Set drawmode to EDrawModeWriteAlpha and call the methods. |
|
425 |
|
426 @SYMTestExpectedResults |
|
427 The image drawn in the center of the test should be drawn blended (EDrawModePEN) |
|
428 and the images drawn at the left and right sides should be drawn opaque (EDrawModeWriteAlpha). |
|
429 should be copied into rendering target. Valid bitmap should be created. |
|
430 This bitmap should be the same as a reference bitmap. |
|
431 */ |
|
432 void CTDrawBitmap::TestDrawModeL() |
|
433 { |
|
434 _LIT(KTestName, "DrawBitmap-DrawMode"); |
|
435 if(!iRunningOomTests) |
|
436 { |
|
437 INFO_PRINTF1(KTestName); |
|
438 } |
|
439 |
|
440 ResetGc(); |
|
441 |
|
442 TSize bmpSize(iCheckedBoardWithAlphaBitmap->SizeInPixels()); |
|
443 |
|
444 TInt halfHeight = (bmpSize.iHeight >> 1); |
|
445 TInt quaterWidth = (bmpSize.iWidth >> 2); |
|
446 TInt y1 = halfHeight - (bmpSize.iHeight >> 2); |
|
447 |
|
448 TSize vertRectSize (quaterWidth, bmpSize.iHeight); |
|
449 TSize horizRectSize (bmpSize.iWidth, halfHeight); |
|
450 |
|
451 // Render column to left |
|
452 iGc->SetDrawMode(DirectGdi::EDrawModeWriteAlpha); |
|
453 iGc->DrawBitmap( |
|
454 TRect (TPoint(0, 0), vertRectSize), |
|
455 *iCheckedBoardWithAlphaBitmap); |
|
456 |
|
457 // Render row in center |
|
458 iGc->SetDrawMode(DirectGdi::EDrawModePEN); |
|
459 iGc->DrawBitmap( |
|
460 TRect(TPoint(0, y1), horizRectSize), |
|
461 *iCheckedBoardWithAlphaBitmap); |
|
462 |
|
463 // Render column to right |
|
464 iGc->SetDrawMode(DirectGdi::EDrawModeWriteAlpha); |
|
465 iGc->DrawBitmap( |
|
466 TRect (TPoint(bmpSize.iWidth - quaterWidth, 0), vertRectSize), |
|
467 *iCheckedBoardWithAlphaBitmap); |
|
468 |
|
469 TESTNOERRORL(iGc->GetError()); |
|
470 |
|
471 WriteTargetOutput(KTestName()); |
|
472 } |
|
473 |
|
474 /** |
|
475 @SYMTestCaseID |
|
476 GRAPHICS-DIRECTGDI-DRAWBITMAP-0007 |
|
477 |
|
478 @SYMPREQ |
|
479 PREQ39 |
|
480 |
|
481 @SYMREQ |
|
482 REQ9199 |
|
483 REQ9204 |
|
484 REQ9195 |
|
485 REQ9201 |
|
486 REQ9202 |
|
487 REQ9222 |
|
488 REQ9223 |
|
489 REQ9236 |
|
490 REQ9237 |
|
491 |
|
492 @SYMTestCaseDesc |
|
493 Test that a bitmap is drawn at the correct position when SetOrigin() is called before |
|
494 the bitmap is drawn. |
|
495 |
|
496 @SYMTestPriority |
|
497 Critical |
|
498 |
|
499 @SYMTestStatus |
|
500 Implemented |
|
501 |
|
502 @SYMTestActions |
|
503 Call SetOrigin(). |
|
504 Call DrawBitmap(). |
|
505 |
|
506 @SYMTestExpectedResults |
|
507 Source bitmap should be drawn at the correct position (TPoint(20,20)). Valid bitmap |
|
508 should be created. This bitmap shall be compared to a reference bitmap. |
|
509 */ |
|
510 void CTDrawBitmap::TestSetOriginL() |
|
511 { |
|
512 _LIT(KTestName, "DrawBitmap-SetOrigin"); |
|
513 |
|
514 // Only do test for one pixel format to cut down on the number of images produced |
|
515 // as this is just a positional test and we don't need to test for all pixel formats. |
|
516 if (!((iTestParams.iTargetPixelFormat == EUidPixelFormatRGB_565) && (iTestParams.iSourcePixelFormat == EUidPixelFormatRGB_565))) |
|
517 { |
|
518 return; |
|
519 } |
|
520 |
|
521 if(!iRunningOomTests) |
|
522 { |
|
523 INFO_PRINTF1(KTestName); |
|
524 } |
|
525 |
|
526 ResetGc(); |
|
527 |
|
528 CFbsBitmap* bitmap = iCheckedBoardBitmap2; |
|
529 iGc->SetOrigin(TPoint(-35, 80)); |
|
530 iGc->DrawBitmap(TRect(TPoint(55, -60), bitmap->SizeInPixels()), *bitmap, TRect(10, 10, 130, 130)); |
|
531 TESTNOERRORL(iGc->GetError()); |
|
532 |
|
533 WriteTargetOutput(KTestName()); |
|
534 } |