sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include "tdrawbitmap.h" sl@0: sl@0: CTDrawBitmap::CTDrawBitmap() sl@0: { sl@0: SetTestStepName(KTDirectGdiDrawBitmapStep); sl@0: } sl@0: sl@0: CTDrawBitmap::~CTDrawBitmap() sl@0: { sl@0: } sl@0: sl@0: /** sl@0: Override of base class pure virtual sl@0: Lists the tests to be run sl@0: */ sl@0: void CTDrawBitmap::RunTestsL() sl@0: { sl@0: if (iUseDirectGdi && !iUseSwDirectGdi) sl@0: { sl@0: // In the event that a test leaves after a BitBlt() or DrawBitmap() has occurred sl@0: // the vgimage cache will need to be reset. sl@0: // This needs to be the first item on the cleanupstack, sl@0: // as some tests perform pushes and pops of bitmaps. sl@0: CleanupStack::PushL(TCleanupItem(ResetCache, iVgImageCache)); sl@0: } sl@0: if(!iLargeTarget) sl@0: { sl@0: iTestParams.iDoCompressed = ETrue; sl@0: SetTestStepID(_L("GRAPHICS-DIRECTGDI-DRAWBITMAP-0001")); sl@0: TestBasicL(); sl@0: RecordTestResultL(); sl@0: iTestParams.iDoCompressed = EFalse; sl@0: SetTestStepID(_L("GRAPHICS-DIRECTGDI-DRAWBITMAP-0003")); sl@0: TestInvalidParametersL(); sl@0: RecordTestResultL(); sl@0: SetTestStepID(_L("GRAPHICS-DIRECTGDI-DRAWBITMAP-0005")); sl@0: TestSourceBitmapCloningL(); sl@0: RecordTestResultL(); sl@0: SetTestStepID(_L("GRAPHICS-DIRECTGDI-DRAWBITMAP-0006")); sl@0: TestDrawModeL(); sl@0: RecordTestResultL(); sl@0: SetTestStepID(_L("GRAPHICS-DIRECTGDI-DRAWBITMAP-0007")); sl@0: TestSetOriginL(); sl@0: RecordTestResultL(); sl@0: } sl@0: else sl@0: { sl@0: SetTestStepID(_L("GRAPHICS-DIRECTGDI-DRAWBITMAP-0002")); sl@0: TestPositioningL(); sl@0: RecordTestResultL(); sl@0: SetTestStepID(_L("GRAPHICS-DIRECTGDI-DRAWBITMAP-0004")); sl@0: TestScalingL(); sl@0: RecordTestResultL(); sl@0: } sl@0: if (iUseDirectGdi && !iUseSwDirectGdi) sl@0: { sl@0: CleanupStack::PopAndDestroy(iVgImageCache); sl@0: } sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-DIRECTGDI-DRAWBITMAP-0001 sl@0: sl@0: @SYMPREQ sl@0: PREQ39 sl@0: sl@0: @SYMREQ sl@0: REQ9199 sl@0: REQ9204 sl@0: REQ9195 sl@0: REQ9201 sl@0: REQ9202 sl@0: REQ9222 sl@0: REQ9223 sl@0: REQ9236 sl@0: REQ9237 sl@0: sl@0: @SYMTestCaseDesc sl@0: Bitmap drawing basic functionality test. sl@0: sl@0: @SYMTestPriority sl@0: Critical sl@0: sl@0: @SYMTestStatus sl@0: Implemented sl@0: sl@0: @SYMTestActions sl@0: Test bitmap drawing for simple and valid parameters: sl@0: - Set the origin at TPoint(-35,80) sl@0: - Draw a stretched bitmap at TPoint(55,-60) sl@0: sl@0: @SYMTestExpectedResults sl@0: Source bitmap should be copied into drawing target. sl@0: Valid bitmap should be created. This bitmap shall be compared sl@0: to a reference bitmap. sl@0: */ sl@0: void CTDrawBitmap::TestBasicL() sl@0: { sl@0: _LIT(KTestName, "DrawBitmap-Basic"); sl@0: if(!iRunningOomTests) sl@0: { sl@0: INFO_PRINTF1(KTestName); sl@0: } sl@0: sl@0: ResetGc(); sl@0: sl@0: CFbsBitmap* bitmap; sl@0: if(iTestParams.iDoCompressed) sl@0: { sl@0: bitmap = iCompressedBitmap; sl@0: } sl@0: else sl@0: { sl@0: bitmap = iCheckedBoardBitmap2; sl@0: } sl@0: sl@0: iGc->DrawBitmap(TRect(TPoint(20, 20), bitmap->SizeInPixels()), *bitmap, TRect(10, 10, 130, 130)); sl@0: TESTNOERRORL(iGc->GetError()); sl@0: sl@0: if(!iTestParams.iDoCompressed) sl@0: WriteTargetOutput(KTestName()); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-DIRECTGDI-DRAWBITMAP-0002 sl@0: sl@0: @SYMPREQ sl@0: PREQ39 sl@0: sl@0: @SYMREQ sl@0: REQ9199 sl@0: REQ9204 sl@0: REQ9195 sl@0: REQ9201 sl@0: REQ9202 sl@0: REQ9222 sl@0: REQ9223 sl@0: REQ9236 sl@0: REQ9237 sl@0: sl@0: @SYMTestCaseDesc sl@0: Test regularity of bitmap positioning. sl@0: sl@0: @SYMTestPriority sl@0: Critical sl@0: sl@0: @SYMTestStatus sl@0: Implemented sl@0: sl@0: @SYMTestActions sl@0: Test positioning functionality of DrawBitmap() methods. Test boundary sl@0: conditions and clipping to surface area. sl@0: Covers the whole target bitmap starting from TPoint(-30,-30) with staggered blits of a small 8x8 bitmap. sl@0: sl@0: @SYMTestExpectedResults sl@0: Source bitmap should be drawn tiled in a staggered fashion across the whole target. Clipping should be applied. sl@0: Valid bitmap should be created. This bitmap shall be compared to a reference bitmap. sl@0: */ sl@0: void CTDrawBitmap::TestPositioningL() sl@0: { sl@0: _LIT(KTestName, "DrawBitmap-Positioning"); sl@0: if(!iRunningOomTests) sl@0: { sl@0: INFO_PRINTF1(KTestName); sl@0: } sl@0: iTestParams.iDoCompressed = ETrue; sl@0: TestPositioningBaseL(KTestName(), EDrawBitmap); sl@0: iTestParams.iDoCompressed = EFalse; sl@0: TestPositioningBaseL(KTestName(), EDrawBitmap); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-DIRECTGDI-DRAWBITMAP-0003 sl@0: sl@0: @SYMPREQ sl@0: PREQ39 sl@0: sl@0: @SYMREQ sl@0: REQ9199 sl@0: REQ9204 sl@0: REQ9195 sl@0: REQ9222 sl@0: REQ9223 sl@0: REQ9236 sl@0: REQ9237 sl@0: sl@0: @SYMTestCaseDesc sl@0: Test functions behaviour after calling with invalid parameters. sl@0: sl@0: @SYMTestPriority sl@0: Critical sl@0: sl@0: @SYMTestStatus sl@0: Implemented sl@0: sl@0: @SYMTestActions sl@0: Set valid parameters (see DrawBitmap-BasicL). Replace individual parameters sl@0: with Invalid ones: sl@0: Invalid source rectangles sl@0: aSourceRect : negative source rectangle starting point or size sl@0: TRect( TPoint( -30, -30), TSize(-10, -10) ) sl@0: aSourceRect : source rectangle not compatible with bitmap sl@0: TRect( TSize(aBitmap->SizeInPixel(). iWidth + 10, aBitmap->SizeInPixel(). IHeight + 10)) sl@0: aSourceRect : swapped points in source rectangle sl@0: TRect( TPoint( 100, 100 ) , TPoint( 0, 0 ) ) sl@0: Invalid destination rectangle (aDestRect): sl@0: negative size sl@0: Invalid source bitmap sl@0: zero size bitmap sl@0: not initialized bitmap sl@0: sl@0: @SYMTestExpectedResults sl@0: Function should detect invalid parameters and return. sl@0: Nothing will be drawn on the target surface. sl@0: */ sl@0: void CTDrawBitmap::TestInvalidParametersL() sl@0: { sl@0: _LIT(KTestName, "DrawBitmap-InvalidParameters"); sl@0: if(!iRunningOomTests) sl@0: { sl@0: INFO_PRINTF1(KTestName); sl@0: } sl@0: sl@0: TestInvalidParametersBaseL(KTestName(), EDrawBitmap); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-DIRECTGDI-DRAWBITMAP-0004 sl@0: sl@0: @SYMPREQ sl@0: PREQ39 sl@0: sl@0: @SYMREQ sl@0: REQ9199 sl@0: REQ9204 sl@0: REQ9195 sl@0: REQ9201 sl@0: REQ9202 sl@0: REQ9222 sl@0: REQ9223 sl@0: REQ9236 sl@0: REQ9237 sl@0: sl@0: @SYMTestCaseDesc sl@0: Test regularity of bitmap scaling. sl@0: sl@0: @SYMTestPriority sl@0: Critical sl@0: sl@0: @SYMTestStatus sl@0: Implemented sl@0: sl@0: @SYMTestActions sl@0: Test scaling implementation of DrawBitmap() methods : scaling down of a normal sl@0: bitmap and scaling up of a bitmap fragment. sl@0: sl@0: @SYMTestExpectedResults sl@0: Scaled bitmap should be drawn in a target area. Valid bitmap should be created. sl@0: The bitmap should be properly scaled. This bitmap shall be compared to a reference sl@0: bitmap. sl@0: */ sl@0: void CTDrawBitmap::TestScalingL() sl@0: { sl@0: _LIT(KTestName, "DrawBitmap-Scaling"); sl@0: if(!iRunningOomTests) sl@0: { sl@0: INFO_PRINTF1(KTestName); sl@0: } sl@0: sl@0: TInt width = iGdiTarget->SizeInPixels().iWidth; sl@0: TInt height = iGdiTarget->SizeInPixels().iHeight; sl@0: sl@0: CFbsBitmap* bitmap1 = iCheckedBoardBitmap1; sl@0: TInt bmp1Width = bitmap1->SizeInPixels().iWidth; sl@0: TInt bmp1Height = bitmap1->SizeInPixels().iHeight; sl@0: CFbsBitmap* bitmap2 = iCheckedBoardBitmap2; sl@0: TInt bmp2Width = bitmap2->SizeInPixels().iWidth; sl@0: TInt bmp2Height = bitmap2->SizeInPixels().iHeight; sl@0: sl@0: ResetGc(); sl@0: sl@0: // small bitmap - extrem magnification sl@0: TReal32 scale = 1.0f; sl@0: TReal32 scaleFactor = 1.55f; sl@0: TInt posX = 1; sl@0: for(TInt j=0; j<6; j++) sl@0: { sl@0: TSize size(static_cast(bmp1Width*scale), static_cast(bmp1Height*scale)); sl@0: TPoint pos(posX, height/4-size.iHeight/2); sl@0: sl@0: iGc->DrawBitmap(TRect(pos, size), *bitmap1); sl@0: sl@0: posX += size.iWidth+2; sl@0: scale *= scaleFactor; sl@0: } sl@0: sl@0: // large bitmap - extreme minification sl@0: sl@0: scale /= scaleFactor; sl@0: posX = 1; sl@0: for(TInt j=5; j>=0; j--) sl@0: { sl@0: TSize size(static_cast(bmp1Width*scale), static_cast(bmp1Height*scale)); sl@0: TPoint pos(posX, 3*height/4-size.iHeight/2); sl@0: sl@0: iGc->DrawBitmap(TRect(pos, size), *bitmap2); sl@0: sl@0: posX += size.iWidth+2; sl@0: scale /= scaleFactor; sl@0: } sl@0: sl@0: TESTNOERRORL(iGc->GetError()); sl@0: sl@0: TBuf<30> testName; sl@0: testName.Append(KTestName); sl@0: WriteTargetOutput(testName); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-DIRECTGDI-DRAWBITMAP-0005 sl@0: sl@0: @SYMPREQ sl@0: PREQ39 sl@0: sl@0: @SYMREQ sl@0: REQ9199 sl@0: REQ9204 sl@0: REQ9195 sl@0: REQ9201 sl@0: REQ9202 sl@0: REQ9222 sl@0: REQ9223 sl@0: REQ9236 sl@0: REQ9237 sl@0: sl@0: @SYMTestCaseDesc sl@0: Tests that a bitmap is still drawn successfully if it is deleted sl@0: right after the call to DrawBitmap() but before Finish() is called. sl@0: sl@0: @SYMTestPriority sl@0: Critical sl@0: sl@0: @SYMTestStatus sl@0: Implemented sl@0: sl@0: @SYMTestActions sl@0: For each method: sl@0: 1. Call method with valid parameters (see DrawBitmap-Basic). sl@0: 2. Right after returning from method call, destroy the source bitmap. sl@0: 3. Call the method again with the same bitmap parameter. sl@0: Repeat p. 1-3 a few times. sl@0: sl@0: @SYMTestExpectedResults sl@0: Source bitmap should be copied into target area. Memory leaks should not be sl@0: created. Valid bitmap should be created. This bitmap should be the same as sl@0: a reference bitmap. sl@0: */ sl@0: void CTDrawBitmap::TestSourceBitmapCloningL() sl@0: { sl@0: _LIT(KTestName, "DrawBitmap-SourceBitmapCloning"); sl@0: if(!iRunningOomTests) sl@0: { sl@0: INFO_PRINTF1(KTestName); sl@0: } sl@0: sl@0: iTestParams.iDoCompressed = ETrue; sl@0: TestSourceBitmapCloningBaseL(KTestName(), EDrawBitmap); sl@0: iTestParams.iDoCompressed = EFalse; sl@0: TestSourceBitmapCloningBaseL(KTestName(), EDrawBitmap); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-DIRECTGDI-DRAWBITMAP-0006 sl@0: sl@0: @SYMPREQ sl@0: PREQ39 sl@0: sl@0: @SYMREQ sl@0: REQ9199 sl@0: REQ9204 sl@0: REQ9195 sl@0: REQ9201 sl@0: REQ9202 sl@0: REQ9222 sl@0: REQ9223 sl@0: REQ9236 sl@0: REQ9237 sl@0: sl@0: @SYMTestCaseDesc sl@0: Test correctness of drawing bitmaps in all possible draw modes. sl@0: sl@0: @SYMTestPriority sl@0: Critical sl@0: sl@0: @SYMTestStatus sl@0: Implemented sl@0: sl@0: @SYMTestActions sl@0: Set valid parameters (see DrawBitmap-Basic). sl@0: Use the semi-transparent source bitmap (aBitmap). sl@0: Set drawmode to EDrawModeWriteAlpha and call the methods. sl@0: Set drawmode to EDrawModePEN and call the methods. sl@0: Set drawmode to EDrawModeWriteAlpha and call the methods. sl@0: sl@0: @SYMTestExpectedResults sl@0: The image drawn in the center of the test should be drawn blended (EDrawModePEN) sl@0: and the images drawn at the left and right sides should be drawn opaque (EDrawModeWriteAlpha). sl@0: should be copied into rendering target. Valid bitmap should be created. sl@0: This bitmap should be the same as a reference bitmap. sl@0: */ sl@0: void CTDrawBitmap::TestDrawModeL() sl@0: { sl@0: _LIT(KTestName, "DrawBitmap-DrawMode"); sl@0: if(!iRunningOomTests) sl@0: { sl@0: INFO_PRINTF1(KTestName); sl@0: } sl@0: sl@0: ResetGc(); sl@0: sl@0: TSize bmpSize(iCheckedBoardWithAlphaBitmap->SizeInPixels()); sl@0: sl@0: TInt halfHeight = (bmpSize.iHeight >> 1); sl@0: TInt quaterWidth = (bmpSize.iWidth >> 2); sl@0: TInt y1 = halfHeight - (bmpSize.iHeight >> 2); sl@0: sl@0: TSize vertRectSize (quaterWidth, bmpSize.iHeight); sl@0: TSize horizRectSize (bmpSize.iWidth, halfHeight); sl@0: sl@0: // Render column to left sl@0: iGc->SetDrawMode(DirectGdi::EDrawModeWriteAlpha); sl@0: iGc->DrawBitmap( sl@0: TRect (TPoint(0, 0), vertRectSize), sl@0: *iCheckedBoardWithAlphaBitmap); sl@0: sl@0: // Render row in center sl@0: iGc->SetDrawMode(DirectGdi::EDrawModePEN); sl@0: iGc->DrawBitmap( sl@0: TRect(TPoint(0, y1), horizRectSize), sl@0: *iCheckedBoardWithAlphaBitmap); sl@0: sl@0: // Render column to right sl@0: iGc->SetDrawMode(DirectGdi::EDrawModeWriteAlpha); sl@0: iGc->DrawBitmap( sl@0: TRect (TPoint(bmpSize.iWidth - quaterWidth, 0), vertRectSize), sl@0: *iCheckedBoardWithAlphaBitmap); sl@0: sl@0: TESTNOERRORL(iGc->GetError()); sl@0: sl@0: WriteTargetOutput(KTestName()); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-DIRECTGDI-DRAWBITMAP-0007 sl@0: sl@0: @SYMPREQ sl@0: PREQ39 sl@0: sl@0: @SYMREQ sl@0: REQ9199 sl@0: REQ9204 sl@0: REQ9195 sl@0: REQ9201 sl@0: REQ9202 sl@0: REQ9222 sl@0: REQ9223 sl@0: REQ9236 sl@0: REQ9237 sl@0: sl@0: @SYMTestCaseDesc sl@0: Test that a bitmap is drawn at the correct position when SetOrigin() is called before sl@0: the bitmap is drawn. sl@0: sl@0: @SYMTestPriority sl@0: Critical sl@0: sl@0: @SYMTestStatus sl@0: Implemented sl@0: sl@0: @SYMTestActions sl@0: Call SetOrigin(). sl@0: Call DrawBitmap(). sl@0: sl@0: @SYMTestExpectedResults sl@0: Source bitmap should be drawn at the correct position (TPoint(20,20)). Valid bitmap sl@0: should be created. This bitmap shall be compared to a reference bitmap. sl@0: */ sl@0: void CTDrawBitmap::TestSetOriginL() sl@0: { sl@0: _LIT(KTestName, "DrawBitmap-SetOrigin"); sl@0: sl@0: // Only do test for one pixel format to cut down on the number of images produced sl@0: // as this is just a positional test and we don't need to test for all pixel formats. sl@0: if (!((iTestParams.iTargetPixelFormat == EUidPixelFormatRGB_565) && (iTestParams.iSourcePixelFormat == EUidPixelFormatRGB_565))) sl@0: { sl@0: return; sl@0: } sl@0: sl@0: if(!iRunningOomTests) sl@0: { sl@0: INFO_PRINTF1(KTestName); sl@0: } sl@0: sl@0: ResetGc(); sl@0: sl@0: CFbsBitmap* bitmap = iCheckedBoardBitmap2; sl@0: iGc->SetOrigin(TPoint(-35, 80)); sl@0: iGc->DrawBitmap(TRect(TPoint(55, -60), bitmap->SizeInPixels()), *bitmap, TRect(10, 10, 130, 130)); sl@0: TESTNOERRORL(iGc->GetError()); sl@0: sl@0: WriteTargetOutput(KTestName()); sl@0: }