Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
21 SetTestStepName(KTDirectGdiBitBltStep);
29 Override of base class pure virtual
30 Lists the tests to be run
32 void CTBitBlt::RunTestsL()
34 if(iUseDirectGdi && !iUseSwDirectGdi)
36 // In the event that a test leaves after a BitBlt() or DrawBitmap() has occurred
37 // the vgimage cache will need to be reset.
38 // This needs to be the first item on the cleanupstack,
39 // as some tests perform pushes and pops of bitmaps.
40 CleanupStack::PushL(TCleanupItem(ResetCache, iVgImageCache));
45 iTestParams.iDoCompressed = ETrue;
46 SetTestStepID(_L("GRAPHICS-DIRECTGDI-BITBLT-0001"));
49 iTestParams.iDoCompressed = EFalse;
50 SetTestStepID(_L("GRAPHICS-DIRECTGDI-BITBLT-0003"));
51 TestInvalidParametersL();
53 SetTestStepID(_L("GRAPHICS-DIRECTGDI-BITBLT-0004"));
54 TestSourceBitmapCloningL();
56 SetTestStepID(_L("GRAPHICS-DIRECTGDI-BITBLT-0005"));
59 SetTestStepID(_L("GRAPHICS-DIRECTGDI-BITBLT-0006"));
65 SetTestStepID(_L("GRAPHICS-DIRECTGDI-BITBLT-0002"));
70 if(iUseDirectGdi && !iUseSwDirectGdi)
72 CleanupStack::PopAndDestroy(iVgImageCache);
78 GRAPHICS-DIRECTGDI-BITBLT-0001
95 Bit blitting basic functionality.
104 Test bit blitting with basic and valid parameters. The test sets an origin that is not 0,0
105 and does a single BitBlt() to a position offscreen that will be moved back onscreen due to the previously
106 set origin. The image should appear at 20,20.
108 @SYMTestExpectedResults
109 Source bitmap should be copied into target area. Valid bitmap should be created.
110 This bitmap should be the same as a reference bitmap.
112 void CTBitBlt::TestBasicL()
114 _LIT(KTestName, "BitBlt-Basic");
116 // Only do the compressed version of this test for one pixel format
117 // to cut down on the number of images produced.
118 TBool writeOutCompressed = (iTestParams.iDoCompressed && (iTestParams.iTargetPixelFormat == EUidPixelFormatRGB_565));
120 if(!iRunningOomTests)
122 INFO_PRINTF1(KTestName);
128 if(iTestParams.iDoCompressed)
130 bitmap = iCompressedBitmap;
134 bitmap = iCheckedBoardBitmap2;
137 iGc->BitBlt(TPoint(20, 20), *bitmap);
138 TESTNOERRORL(iGc->GetError());
140 if (!iTestParams.iDoCompressed || writeOutCompressed)
141 WriteTargetOutput(KTestName());
146 GRAPHICS-DIRECTGDI-BITBLT-0002
164 Various combinations of destination positions, source position and size
165 of a bitmap are tested. This test also covers boundary position and size.
174 Bitmap positioning in a target area, for boundary position, and for clipping
177 @SYMTestExpectedResults
178 Various parts of source bitmap should be copied into target area at
179 various positions. Parts of source bitmap that go beyond a target area
180 should be clipped. Valid bitmap should be created. This bitmap should
181 be the same as a reference bitmap.
183 void CTBitBlt::TestPositioningL()
185 _LIT(KTestName, "BitBlt-Positioning");
186 if(!iRunningOomTests)
188 INFO_PRINTF1(KTestName);
190 iTestParams.iDoCompressed = ETrue;
191 TestPositioningBaseL(KTestName(), EBitBlt);
192 iTestParams.iDoCompressed = EFalse;
193 TestPositioningBaseL(KTestName(), EBitBlt);
198 GRAPHICS-DIRECTGDI-BITBLT-0003
214 Calling BitBlt() method with invalid parameters
223 Set valid parameters (see BitBlt-Basic). Invoke the BitBlt() method replacing valid parameters with invalid equivalent. Create separate tests for horizontal and vertical coordinates.
225 Invalid source rectangles:
226 - TRect(-30, -30, -10, -10);
227 - TRect(bmpWidth+10, bmpHeight+10, bmpWidth+20, bmpHeight+20));
228 - TRect(bmpWidth, bmpHeight, 0, 0));
229 - TRect(-10, -10, -30, -30);
230 - TRect(0, 0, 0, 0));
231 Invalid source bitmaps:
233 - not initialized bitmap
236 @SYMTestExpectedResults
237 Function should detect invalid parameters and return.
238 Nothing should be drawn in a target area.
240 void CTBitBlt::TestInvalidParametersL()
242 _LIT(KTestName, "BitBlt-InvalidParameters");
243 if(!iRunningOomTests)
245 INFO_PRINTF1(KTestName);
247 TestInvalidParametersBaseL(KTestName(), EBitBlt);
252 GRAPHICS-DIRECTGDI-BITBLT-0004
269 Tests that the source bitmap is drawn correctly if it is deleted in the
270 test code right after BitBlt() is called, but before Finish() is called and
271 the image is actually drawn by the engine.
280 1. Invoke the BitBlt() method with valid parameters (see BitBlt-Basic).
281 2. Right after returning from BitBlt() call, destroy the source Bitmap (aBitmap).
282 3. Call the BitBlt() method again with the same bitmap parameter.
283 Repeat p. 1-3 a few times.#
285 @SYMTestExpectedResults
286 Source bitmap should be copied into target area. Memory leaks should not be
287 created. Valid bitmap should be created. This bitmap should be the same as
290 void CTBitBlt::TestSourceBitmapCloningL()
292 _LIT(KTestName, "BitBlt-SourceBitmapCloning");
293 if(!iRunningOomTests)
295 INFO_PRINTF1(KTestName);
297 iTestParams.iDoCompressed = ETrue;
298 TestSourceBitmapCloningBaseL(KTestName(), EBitBlt);
299 iTestParams.iDoCompressed = EFalse;
300 TestSourceBitmapCloningBaseL(KTestName(), EBitBlt);
305 GRAPHICS-DIRECTGDI-BITBLT-0005
322 Test correctness of bit blitting in all possible draw modes.
331 Set valid parameters (see BitBlt-Basic).
332 Use the semi-transparent source bitmap (aBitmap).
333 Set drawmode to EDrawModeWriteAlpha and call the methods.
334 Set drawmode to EDrawModePEN and call the methods.
335 Set drawmode to EDrawModeWriteAlpha and call the methods.
337 @SYMTestExpectedResults
338 Semi-transparent (for EDrawModePEN) and opaque (for EDrawModeWriteAlpha)
339 should be copied into rendering target, that is, the left and the right
340 bitmaps in the test should be drawn opaque, and the center bitmap in the
341 test should be draw blended. Valid bitmap should be created.
342 This bitmap should be the same as a reference bitmap.
344 void CTBitBlt::TestDrawModeL()
346 _LIT(KTestName, "BitBlt-DrawMode");
347 if(!iRunningOomTests)
349 INFO_PRINTF1(KTestName);
353 TSize bmpSize(iCheckedBoardWithAlphaBitmap->SizeInPixels());
355 TInt halfHeight = (bmpSize.iHeight >> 1);
356 TInt quaterWidth = (bmpSize.iWidth >> 2);
357 TInt y1 = halfHeight - (bmpSize.iHeight >> 2);
358 TSize vertRectSize (quaterWidth, bmpSize.iHeight);
359 TSize horizRectSize (bmpSize.iWidth, halfHeight);
361 // Render column to left
362 iGc->SetDrawMode(DirectGdi::EDrawModeWriteAlpha);
365 *iCheckedBoardWithAlphaBitmap,
366 TRect(TPoint(0, 0), vertRectSize));
368 // Render row in center
369 iGc->SetDrawMode(DirectGdi::EDrawModePEN);
372 *iCheckedBoardWithAlphaBitmap,
373 TRect(TPoint(0, 0), horizRectSize));
375 // Render column to right
376 iGc->SetDrawMode(DirectGdi::EDrawModeWriteAlpha);
378 TPoint(bmpSize.iWidth - quaterWidth, 0),
379 *iCheckedBoardWithAlphaBitmap,
380 TRect(TPoint(0, 0), vertRectSize));
382 TESTNOERRORL(iGc->GetError());
384 WriteTargetOutput(KTestName());
389 GRAPHICS-DIRECTGDI-BITBLT-0006
406 Test that a bitmap is drawn at the correct position when SetOrigin() is called before
407 the bitmap is blitted.
419 @SYMTestExpectedResults
420 Source bitmap should be drawn at the correct position (TPoint(20,20)). Valid bitmap
421 should be created. This bitmap shall be compared to a reference bitmap.
423 void CTBitBlt::TestSetOriginL()
425 _LIT(KTestName, "BitBlt-SetOrigin");
427 // Only do test for one pixel format to cut down on the number of images produced
428 // as this is just a positional test and we don't need to test for all pixel formats.
429 if (!((iTestParams.iTargetPixelFormat == EUidPixelFormatRGB_565) && (iTestParams.iSourcePixelFormat == EUidPixelFormatRGB_565)))
434 if(!iRunningOomTests)
436 INFO_PRINTF1(KTestName);
441 CFbsBitmap* bitmap = iCheckedBoardBitmap2;
443 iGc->SetOrigin(TPoint(-35, 80));
444 iGc->BitBlt(TPoint(55, -60), *bitmap);
445 TESTNOERRORL(iGc->GetError());
447 WriteTargetOutput(KTestName());