sl@0: // Copyright (c) 2008-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 "textendedbitmapcommon.h" sl@0: #include "textendedbitmaplegacy.h" sl@0: #include "tfbs.h" sl@0: #include sl@0: #include sl@0: sl@0: const TUint8 KTestData[] = "Extended bitmap test data 123456"; sl@0: const TInt KTestDataSize = sizeof(KTestData); sl@0: const TInt KTestWidth = 50; sl@0: const TInt KTestHeight = 50; sl@0: const TSize KSizeInPixels = TSize(KTestWidth,KTestHeight); sl@0: const TDisplayMode KDisplayMode = EColor64K; sl@0: const TInt KBpp = 2; // 2 bpp for EColor64K sl@0: sl@0: // Test mbm files used by CTExtendedBitmapLegacy::TestApisThatCallResetL(). sl@0: // These are used to check the operation of CFbsBitmap::Load() when used with sl@0: // extended bitmaps. sl@0: _LIT(KRomBmpFilename, "z:\\system\\data\\rf1.mbm"); sl@0: _LIT(KRamBitmapFilenameOnZ, "z:\\system\\data\\16RAM2.mbm"); sl@0: _LIT(KRamBitmapFilename, "c:\\textendedbitmaplegacy_16RAM2.mbm"); sl@0: sl@0: LOCAL_D RFs TheFs; sl@0: sl@0: CTExtendedBitmapLegacy::CTExtendedBitmapLegacy(CTestStep* aStep): sl@0: CTFbsBase(aStep, ETrue) sl@0: { sl@0: } sl@0: sl@0: CTExtendedBitmapLegacy::~CTExtendedBitmapLegacy() sl@0: { sl@0: ((CTExtendedBitmapLegacyStep*)iStep)->CloseTMSGraphicsStep(); sl@0: } sl@0: sl@0: void CTExtendedBitmapLegacy::RunFbsTestL(TInt aCurTestCase) sl@0: { sl@0: ((CTExtendedBitmapLegacyStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); sl@0: switch(aCurTestCase) sl@0: { sl@0: case 1: sl@0: ((CTExtendedBitmapLegacyStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-EXTENDEDBITMAP-0030")); sl@0: TestDuplicateL(); sl@0: break; sl@0: case 2: sl@0: ((CTExtendedBitmapLegacyStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-EXTENDEDBITMAP-0031")); sl@0: TestAccessDeniedL(); sl@0: break; sl@0: case 3: sl@0: ((CTExtendedBitmapLegacyStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-EXTENDEDBITMAP-0032")); sl@0: TestNotSupportedL(); sl@0: break; sl@0: case 4: sl@0: ((CTExtendedBitmapLegacyStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-EXTENDEDBITMAP-0033")); sl@0: TestTwipsL(); sl@0: break; sl@0: case 5: sl@0: ((CTExtendedBitmapLegacyStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-EXTENDEDBITMAP-0034")); sl@0: TestGettersL(); sl@0: break; sl@0: case 6: sl@0: ((CTExtendedBitmapLegacyStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-EXTENDEDBITMAP-0035")); sl@0: TestGetScanLineL(); sl@0: break; sl@0: case 7: sl@0: ((CTExtendedBitmapLegacyStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-EXTENDEDBITMAP-0036")); sl@0: TestApisThatCallResetL(); sl@0: break; sl@0: case 8: sl@0: ((CTExtendedBitmapLegacyStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-EXTENDEDBITMAP-0037")); sl@0: TestApisThatLeaveL(); sl@0: break; sl@0: case 9: sl@0: ((CTExtendedBitmapLegacyStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-EXTENDEDBITMAP-0038")); sl@0: TestNotSupportedNoReturnL(); sl@0: break; sl@0: case 10: sl@0: ((CTExtendedBitmapLegacyStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-EXTENDEDBITMAP-0039")); sl@0: TestGetPixelL(); sl@0: // Fall through as last test case sl@0: default: sl@0: SetLastTestCase(); sl@0: break; sl@0: } sl@0: ((CTExtendedBitmapLegacyStep*)iStep)->RecordTestResultL(); sl@0: } sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-FBSERV-EXTENDEDBITMAP-0030 sl@0: sl@0: @SYMTestCaseDesc sl@0: Create an extended bitmap then duplicate it by calling CFbsBitmap::Duplicate() sl@0: sl@0: @SYMPREQ sl@0: PREQ2096 sl@0: sl@0: @SYMREQ sl@0: REQ10847 sl@0: sl@0: @SYMTestPriority sl@0: High sl@0: sl@0: @SYMTestStatus sl@0: Implemented sl@0: sl@0: @SYMTestActions sl@0: Create an extended bitmap using test data and test Uid. sl@0: Call Duplicate() on the extended bitmap. sl@0: Retrieves and validates the bitmap size, display mode, Uid, data and data size. sl@0: sl@0: @SYMTestExpectedResults sl@0: Extended bitmap created and duplicated and information should match exactly. sl@0: */ sl@0: void CTExtendedBitmapLegacy::TestDuplicateL() sl@0: { sl@0: INFO_PRINTF1(_L("Duplicate - create a duplicate of an extended bitmap")); sl@0: sl@0: CFbsBitmap* bmp = new(ELeave) CFbsBitmap; sl@0: CleanupStack::PushL(bmp); sl@0: TInt err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize); sl@0: TESTNOERRORL(err); sl@0: sl@0: CFbsBitmap* duplicateBmp = new(ELeave) CFbsBitmap; sl@0: CleanupStack::PushL(duplicateBmp); sl@0: err = duplicateBmp->Duplicate(bmp->Handle()); sl@0: TESTNOERRORL(err); sl@0: sl@0: // check that the size, display mode etc are all correct sl@0: TESTSIZEEQUALL(duplicateBmp->SizeInPixels(), KSizeInPixels); sl@0: TESTEQUALL(duplicateBmp->DisplayMode(), KDisplayMode); sl@0: TESTEQUALL(duplicateBmp->DisplayMode(), KDisplayMode); sl@0: TESTEQUALL(duplicateBmp->ExtendedBitmapType(), KUidTestExtendedBitmap); sl@0: sl@0: duplicateBmp->BeginDataAccess(); sl@0: sl@0: const TUint8* returnedDataAddress = reinterpret_cast(duplicateBmp->DataAddress()); sl@0: TESTNOTEQUALL(returnedDataAddress, NULL); sl@0: sl@0: // compare the size of the data in the duplicate bitmap with the size of the original data, they should be the same sl@0: TInt returnedDataSize = duplicateBmp->DataSize(); sl@0: TESTEQUALL(returnedDataSize, KTestDataSize); sl@0: sl@0: // compare the data returned from the duplicate bitmap with the original data, they should be the same sl@0: TInt res = Mem::Compare(returnedDataAddress, returnedDataSize, KTestData, KTestDataSize); sl@0: TESTEQUALL(res, 0); sl@0: sl@0: duplicateBmp->EndDataAccess(ETrue); sl@0: sl@0: CleanupStack::PopAndDestroy(2, bmp); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-FBSERV-EXTENDEDBITMAP-0031 sl@0: sl@0: @SYMTestCaseDesc sl@0: Test that all the legacy CFbsBitmap APIs (i.e. APIs that existed before PREQ2096) sl@0: that should return KErrAccessDenied for an extended bitmap do so correctly. sl@0: sl@0: @SYMPREQ sl@0: PREQ2096 sl@0: sl@0: @SYMREQ sl@0: REQ10847 sl@0: REQ10856 sl@0: REQ10857 sl@0: sl@0: @SYMTestPriority sl@0: High sl@0: sl@0: @SYMTestStatus sl@0: Implemented sl@0: sl@0: @SYMTestActions sl@0: Create an extended bitmap using test data and test Uid. sl@0: Call all the legacy APIs that should return KErrAccessDenied: sl@0: - Resize() sl@0: - Compress() sl@0: - CompressInBackground() sl@0: - SwapWidthAndHeight() sl@0: sl@0: @SYMTestExpectedResults sl@0: The legacy APIs tested should all return KErrAccessDenied. sl@0: */ sl@0: void CTExtendedBitmapLegacy::TestAccessDeniedL() sl@0: { sl@0: INFO_PRINTF1(_L("AccessDenied - test legacy CFbsBitmap APIs that should return KErrAccessDenied when used with an extended bitmap")); sl@0: sl@0: CFbsBitmap* bmp = new(ELeave) CFbsBitmap; sl@0: CleanupStack::PushL(bmp); sl@0: TInt err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize); sl@0: TESTNOERRORL(err); sl@0: sl@0: INFO_PRINTF1(_L("Resize()")); sl@0: err = bmp->Resize(TSize(100,100)); sl@0: TESTEXPECTEDERRORL(err, KErrAccessDenied); sl@0: sl@0: // This covers both versions of Compress() as one calls the other sl@0: INFO_PRINTF1(_L("Compress()")); sl@0: err = bmp->Compress(); sl@0: TESTEXPECTEDERRORL(err, KErrAccessDenied); sl@0: sl@0: // This covers both synchronous versions of CompressInBackground() as one calls the other sl@0: INFO_PRINTF1(_L("CompressInBackground()")); sl@0: err = bmp->CompressInBackground(); sl@0: TESTEXPECTEDERRORL(err, KErrAccessDenied); sl@0: sl@0: // This covers both asynchronous versions of CompressInBackground() as one calls the other sl@0: INFO_PRINTF1(_L("CompressInBackground() (asynchronous)")); sl@0: TRequestStatus requestStatus; sl@0: bmp->CompressInBackground(requestStatus); sl@0: User::WaitForRequest(requestStatus); sl@0: TESTEXPECTEDERRORL(requestStatus.Int(), KErrAccessDenied); sl@0: sl@0: INFO_PRINTF1(_L("SwapWidthAndHeight()")); sl@0: err = bmp->SwapWidthAndHeight(); sl@0: TESTEXPECTEDERRORL(err, KErrAccessDenied); sl@0: sl@0: CleanupStack::PopAndDestroy(bmp); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-FBSERV-EXTENDEDBITMAP-0032 sl@0: sl@0: @SYMTestCaseDesc sl@0: Test that all the legacy CFbsBitmap APIs (i.e. APIs that existted before PREQ2096) sl@0: that should return KErrNotSupported for an extended bitmap do so correctly, or sl@0: if they have no return value and are not supported that they return cleanly. sl@0: sl@0: @SYMPREQ sl@0: PREQ2096 sl@0: sl@0: @SYMREQ sl@0: REQ10847 sl@0: REQ10856 sl@0: REQ10857 sl@0: sl@0: @SYMTestPriority sl@0: High sl@0: sl@0: @SYMTestStatus sl@0: Implemented sl@0: sl@0: @SYMTestActions sl@0: Create an extended bitmap using test data and test Uid. sl@0: Call all the legacy APIs that should return KErrNotSupported: sl@0: - Save() sl@0: - GetPalette() sl@0: - SetDisplayMode() sl@0: sl@0: @SYMTestExpectedResults sl@0: The legacy APIs tested should all return KErrNotSupported where they have return sl@0: values, they should not cause errors where they are not supported but don't return sl@0: an error value. sl@0: */ sl@0: void CTExtendedBitmapLegacy::TestNotSupportedL() sl@0: { sl@0: INFO_PRINTF1(_L("NotSupported - test legacy CFbsBitmap APIs that are not supported when used with an extended bitmap")); sl@0: sl@0: CFbsBitmap* bmp = new(ELeave) CFbsBitmap; sl@0: CleanupStack::PushL(bmp); sl@0: TInt err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize); sl@0: TESTNOERRORL(err); sl@0: sl@0: // Methods that should return KErrNotSupported sl@0: INFO_PRINTF1(_L("Save() - filename")); sl@0: _LIT(KFilename, "C:\\temp.mbm"); sl@0: TESTEXPECTEDERRORL(bmp->Save(KFilename), KErrNotSupported); sl@0: sl@0: INFO_PRINTF1(_L("Save() - RFile")); sl@0: RFile file; sl@0: err = file.Open(TheFs, KFilename, EFileWrite); sl@0: TESTNOERRORL(err); sl@0: CleanupClosePushL(file); sl@0: TESTEXPECTEDERRORL(bmp->Save(file), KErrNotSupported); sl@0: CleanupStack::PopAndDestroy(&file); sl@0: sl@0: INFO_PRINTF1(_L("GetPalette()")); sl@0: CPalette* palette; sl@0: TESTEXPECTEDERRORL(bmp->GetPalette(palette), KErrNotSupported); sl@0: sl@0: INFO_PRINTF1(_L("SetDisplayMode()")); sl@0: err = bmp->SetDisplayMode(EColor16MU); sl@0: TESTEXPECTEDERRORL(err, KErrNotSupported); sl@0: sl@0: sl@0: CleanupStack::PopAndDestroy(bmp); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-FBSERV-EXTENDEDBITMAP-0033 sl@0: sl@0: @SYMTestCaseDesc sl@0: Test that all CFbsBitmap methods that mention Twips work correctly with extended bitmaps. sl@0: sl@0: @SYMPREQ sl@0: PREQ2096 sl@0: sl@0: @SYMREQ sl@0: REQ10847 sl@0: REQ10857 sl@0: REQ10858 sl@0: sl@0: @SYMTestPriority sl@0: High sl@0: sl@0: @SYMTestStatus sl@0: Implemented sl@0: sl@0: @SYMTestActions sl@0: Create an extended bitmap using test data and test Uid. sl@0: Call all the legacy APIs that mention Twips: sl@0: - SetSizeInTwips() sl@0: - SizeInTwips() sl@0: - HorizontalPixelsToTwips() sl@0: - HorizontalTwipsToPixels() sl@0: - VerticalPixelsToTwips() sl@0: - VerticalTwipsToPixels() sl@0: sl@0: @SYMTestExpectedResults sl@0: All methods should work correctly with extended bitmaps. sl@0: */ sl@0: void CTExtendedBitmapLegacy::TestTwipsL() sl@0: { sl@0: INFO_PRINTF1(_L("Twips - test legacy CFbsBitmap Twips APIs work correctly when used with an extended bitmap")); sl@0: const TSize KSizeInTwips(20,30); sl@0: sl@0: CFbsBitmap* bmp = new(ELeave) CFbsBitmap; sl@0: CleanupStack::PushL(bmp); sl@0: TInt err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize); sl@0: TESTNOERRORL(err); sl@0: sl@0: INFO_PRINTF1(_L("SetSizeInTwips()")); sl@0: bmp->SetSizeInTwips(KSizeInTwips); sl@0: sl@0: INFO_PRINTF1(_L("SizeInTwips()")); sl@0: TESTSIZEEQUALL(bmp->SizeInTwips(), KSizeInTwips); sl@0: sl@0: INFO_PRINTF1(_L("HorizontalPixelsToTwips()")); sl@0: TESTEQUALL(bmp->HorizontalPixelsToTwips(KSizeInPixels.iWidth), KSizeInTwips.iWidth); sl@0: sl@0: INFO_PRINTF1(_L("HorizontalTwipsToPixels()")); sl@0: TESTEQUALL(bmp->HorizontalTwipsToPixels(KSizeInTwips.iWidth), KSizeInPixels.iWidth); sl@0: sl@0: INFO_PRINTF1(_L("VerticalPixelsToTwips()")); sl@0: TESTEQUALL(bmp->VerticalPixelsToTwips(KSizeInPixels.iHeight), KSizeInTwips.iHeight); sl@0: sl@0: INFO_PRINTF1(_L("VerticalTwipsToPixels()")); sl@0: TESTEQUALL(bmp->VerticalTwipsToPixels(KSizeInTwips.iHeight), KSizeInPixels.iHeight); sl@0: sl@0: const TDisplayMode displayMode[] = {EColor256, EColor4K, EColor16M, EColor16MU, EColor64K, sl@0: EGray256, EGray16, EGray4, EGray2, EColor16, EColor16MA, EColor16MAP}; sl@0: TInt ii = 0; sl@0: err = KErrNotSupported; sl@0: CFbsScreenDevice* scd = NULL; sl@0: for(;(iiSetSizeInTwips(scd); sl@0: sl@0: delete scd; sl@0: CleanupStack::PopAndDestroy(1, bmp); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-FBSERV-EXTENDEDBITMAP-0034 sl@0: sl@0: @SYMTestCaseDesc sl@0: Test the simple getter CFbsBitmap APIs such as Handle(). sl@0: sl@0: @SYMPREQ sl@0: PREQ2096 sl@0: sl@0: @SYMREQ sl@0: REQ10847 sl@0: REQ10857 sl@0: REQ10858 sl@0: sl@0: @SYMTestPriority sl@0: High sl@0: sl@0: @SYMTestStatus sl@0: Implemented sl@0: sl@0: @SYMTestActions sl@0: Create an extended bitmap using test data and test Uid. sl@0: Call the following simple getter APIs: sl@0: - InitialDisplayMode() sl@0: - IsRomBitmap() sl@0: - Handle() sl@0: - Header() sl@0: - IsLargeBitmap() sl@0: - DataStride() sl@0: - HardwareBitmapHandle() sl@0: - SerialNumber() sl@0: - IsCompressedInRAM() sl@0: - GetAllBitmapHandles() sl@0: sl@0: @SYMTestExpectedResults sl@0: No errors should occur. sl@0: */ sl@0: void CTExtendedBitmapLegacy::TestGettersL() sl@0: { sl@0: INFO_PRINTF1(_L("Test simple getter APIs")); sl@0: sl@0: CFbsBitmap* bmp = new(ELeave) CFbsBitmap; sl@0: CleanupStack::PushL(bmp); sl@0: TInt err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize); sl@0: TESTNOERRORL(err); sl@0: sl@0: INFO_PRINTF1(_L("InitialDisplayMode()")); sl@0: TESTEQUALL(bmp->InitialDisplayMode(), KDisplayMode); sl@0: sl@0: INFO_PRINTF1(_L("IsRomBitmap()")); sl@0: TESTTRUEL(bmp->IsRomBitmap()); sl@0: sl@0: INFO_PRINTF1(_L("Handle()")); sl@0: TESTNOTEQUALL(bmp->Handle(), 0); sl@0: sl@0: INFO_PRINTF1(_L("Header()")); sl@0: SEpocBitmapHeader header = bmp->Header(); sl@0: TESTSIZEEQUALL(header.iSizeInPixels, KSizeInPixels); sl@0: TESTSIZEEQUALL(header.iSizeInTwips, TSize(0,0)); sl@0: TESTEQUALL(header.iBitsPerPixel, 16); sl@0: TESTEQUALL(header.iColor, 1); sl@0: TESTEQUALL(header.iPaletteEntries, 0); sl@0: TESTEQUALL(header.iCompression, EProprietaryCompression); sl@0: sl@0: INFO_PRINTF1(_L("IsLargeBitmap()")); sl@0: TESTTRUEL(bmp->IsLargeBitmap()); sl@0: sl@0: INFO_PRINTF1(_L("DataStride()")); sl@0: TESTEQUALL(bmp->DataStride(), KSizeInPixels.iWidth*KBpp); sl@0: sl@0: INFO_PRINTF1(_L("HardwareBitmapHandle()")); sl@0: TESTEQUALL(bmp->HardwareBitmapHandle(), 0); sl@0: sl@0: INFO_PRINTF1(_L("SerialNumber()")); sl@0: TESTNOTEQUALL(bmp->SerialNumber(), 0); sl@0: sl@0: INFO_PRINTF1(_L("IsCompressedInRAM()")); sl@0: TESTEQUALL(bmp->IsCompressedInRAM(), EFalse); sl@0: sl@0: // The touch count changes for a bitmap (not a ROM bitmap) when it is resized etc, it should not change sl@0: // when Resize() is called on an extended bitmap sl@0: INFO_PRINTF1(_L("TouchCount()")); sl@0: TESTEQUALL(bmp->TouchCount(), 0); sl@0: bmp->Resize(TSize(100,100)); sl@0: TESTEQUALL(bmp->TouchCount(), 0); sl@0: sl@0: // Bitmaps (not ROM bitmaps) become volatile if DataAddress() is called outside BeginDataAccess() and EndDataAccess(), sl@0: // should never be set for extended bitmaps sl@0: INFO_PRINTF1(_L("IsVolatile()")); sl@0: TESTEQUALL(bmp->IsVolatile(), EFalse); sl@0: bmp->DataAddress(); sl@0: TESTEQUALL(bmp->IsVolatile(), EFalse); sl@0: sl@0: RArray handles; sl@0: CleanupClosePushL(handles); sl@0: INFO_PRINTF1(_L("GetAllBitmapHandles()")); sl@0: TESTNOERRORL(bmp->GetAllBitmapHandles(handles)); sl@0: TESTTRUEL(handles.Count() > 0); sl@0: sl@0: CleanupStack::PopAndDestroy(2, bmp); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-FBSERV-EXTENDEDBITMAP-0035 sl@0: sl@0: @SYMTestCaseDesc sl@0: Test GetScanLine with extended bitmaps where no rasterizer is present. sl@0: sl@0: @SYMPREQ sl@0: PREQ2096 sl@0: sl@0: @SYMREQ sl@0: REQ10847 sl@0: REQ10857 sl@0: REQ10858 sl@0: sl@0: @SYMTestPriority sl@0: High sl@0: sl@0: @SYMTestStatus sl@0: Implemented sl@0: sl@0: @SYMTestActions sl@0: Create an extended bitmap using test data and test Uid that is not supported by a rasterizer. sl@0: Call GetScanLine(). sl@0: sl@0: @SYMTestExpectedResults sl@0: GetScanLine() should return a white scanline of the length requested, no errors should occur. sl@0: */ sl@0: void CTExtendedBitmapLegacy::TestGetScanLineL() sl@0: { sl@0: INFO_PRINTF1(_L("Test CFbsBitmap::GetScanLine() where there is no supported rasterizer for the passed extended bitmap Uid")); sl@0: sl@0: CFbsBitmap* bmp = new(ELeave) CFbsBitmap; sl@0: CleanupStack::PushL(bmp); sl@0: TInt err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize); sl@0: TESTNOERRORL(err); sl@0: sl@0: const TInt KScanlineLength = KTestWidth*KBpp; sl@0: TBuf8 buf; sl@0: bmp->GetScanLine(buf, TPoint(0,0), KTestWidth, KDisplayMode); sl@0: TESTEQUALL(buf.Size(), KScanlineLength); sl@0: sl@0: // Check that the scanline has been set to white sl@0: for (TInt i = 0; i < KScanlineLength; i++) sl@0: { sl@0: TESTEQUALL(buf[i], 255); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(bmp); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-FBSERV-EXTENDEDBITMAP-0036 sl@0: sl@0: @SYMTestCaseDesc sl@0: Test an extended bitmap with all of the CFbsBitmap APIs that call Reset(). sl@0: sl@0: @SYMPREQ sl@0: PREQ2096 sl@0: sl@0: @SYMREQ sl@0: REQ10847 sl@0: sl@0: @SYMTestPriority sl@0: High sl@0: sl@0: @SYMTestStatus sl@0: Implemented sl@0: sl@0: @SYMTestActions sl@0: For each API: sl@0: - Create an extended bitmap using test data and test Uid that is not supported by a rasterizer. sl@0: - Call the API. sl@0: The following APIs are tested: sl@0: - Load() sl@0: - LoadAndCompress() sl@0: - Internalize() sl@0: - SetRomBitmapL() sl@0: sl@0: @SYMTestExpectedResults sl@0: All APIs tested should complete with no errors, the resultant CFbsBitmap sl@0: should not be an extended bitmap as it will have been reset. sl@0: */ sl@0: void CTExtendedBitmapLegacy::TestApisThatCallResetL() sl@0: { sl@0: INFO_PRINTF1(_L("Test CFbsBitmap APIs that Call Reset()")); sl@0: sl@0: CFbsBitmap* bmp = new(ELeave) CFbsBitmap; sl@0: CleanupStack::PushL(bmp); sl@0: TInt err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize); sl@0: TESTNOERRORL(err); sl@0: TESTEQUALL(bmp->ExtendedBitmapType(), KUidTestExtendedBitmap); sl@0: sl@0: INFO_PRINTF1(_L("Load()")); sl@0: err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize); sl@0: TESTNOERRORL(err); sl@0: TESTEQUALL(bmp->ExtendedBitmapType(), KUidTestExtendedBitmap); // should be an extended bitmap again sl@0: TESTNOERRORL(bmp->Load(KRamBitmapFilename)); sl@0: TESTNOTEQUALL(bmp->ExtendedBitmapType(), KUidTestExtendedBitmap); // should no longer be an extended bitmap sl@0: sl@0: INFO_PRINTF1(_L("LoadAndCompress()")); sl@0: err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize); sl@0: TESTNOERRORL(err); sl@0: TESTEQUALL(bmp->ExtendedBitmapType(), KUidTestExtendedBitmap); // should be an extended bitmap again sl@0: TESTNOERRORL(bmp->LoadAndCompress(KRamBitmapFilename)); sl@0: TESTNOTEQUALL(bmp->ExtendedBitmapType(), KUidTestExtendedBitmap); // should no longer be an extended bitmap sl@0: sl@0: INFO_PRINTF1(_L("InternalizeL()")); sl@0: CBufFlat* buf = CBufFlat::NewL(512); sl@0: CleanupStack::PushL(buf); sl@0: RBufWriteStream writeStream(*buf,0); sl@0: bmp->ExternalizeL(writeStream); // externalize a normal bitmap sl@0: writeStream.Close(); sl@0: err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize); sl@0: TESTNOERRORL(err); sl@0: TESTEQUALL(bmp->ExtendedBitmapType(), KUidTestExtendedBitmap); // should be an extended bitmap again sl@0: RBufReadStream readStream(*buf,0); sl@0: bmp->InternalizeL(readStream); sl@0: readStream.Close(); sl@0: TESTNOTEQUALL(bmp->ExtendedBitmapType(), KUidTestExtendedBitmap); // should no longer be an extended bitmap sl@0: sl@0: TUint32* romAddress = NULL; sl@0: if(!CFbsBitmap::IsFileInRom(KRomBmpFilename, romAddress)) //check any rom bitmap sl@0: { sl@0: INFO_PRINTF2(_L("Skipping tests of ROM bitmaps since file \"%S\" is reported to not be a ROM bitmap."), &KRomBmpFilename); sl@0: INFO_PRINTF1(_L("This should only occur on non-XIP ROMs, e.g. NAND ROMs, where ROM bitmaps aren't supported.")); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("SetRomBitmapL()")); sl@0: CFbsBitmapEx* romBitmap = new(ELeave) CFbsBitmapEx; sl@0: CleanupStack::PushL(romBitmap); sl@0: INFO_PRINTF2(_L("... attempting to load %S"), &KRomBmpFilename); sl@0: err = romBitmap->Load(KRomBmpFilename); sl@0: TESTNOERRORL(err); sl@0: TInt size = 0; sl@0: INFO_PRINTF1(_L("... calling SetRomBitmapL()")); sl@0: bmp->SetRomBitmapL(romBitmap->BitmapAddress(), size); sl@0: TESTNOTEQUALL(bmp->ExtendedBitmapType(), KUidTestExtendedBitmap); // should no longer be an extended bitmap sl@0: TEST(bmp->SerialNumber() == -TInt64(static_cast(bmp->Handle()))); // A ROM bitmap's handle is its address pointer, its serial number is -ve the address pointer sl@0: sl@0: CleanupStack::PopAndDestroy(1, romBitmap); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(2, bmp); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-FBSERV-EXTENDEDBITMAP-0037 sl@0: sl@0: @SYMTestCaseDesc sl@0: Test the CFbsBitmap APIs that should leave when called by an extended bitmap. sl@0: sl@0: @SYMPREQ sl@0: PREQ2096 sl@0: sl@0: @SYMREQ sl@0: REQ10847 sl@0: REQ10856 sl@0: REQ10857 sl@0: sl@0: @SYMTestPriority sl@0: High sl@0: sl@0: @SYMTestStatus sl@0: Implemented sl@0: sl@0: @SYMTestActions sl@0: For each API: sl@0: - Create an extended bitmap using test data and test Uid that is not supported by a rasterizer. sl@0: - Call the API. sl@0: The following APIs are tested: sl@0: - ExternalizeL() sl@0: - ExternalizeRectangleL() sl@0: sl@0: @SYMTestExpectedResults sl@0: All APIs tested should leave with the error KErrNotSupported. sl@0: */ sl@0: void CTExtendedBitmapLegacy::TestApisThatLeaveL() sl@0: { sl@0: INFO_PRINTF1(_L("ApisThatLeave - test legacy CFbsBitmap APIs that leave when used with an extended bitmap")); sl@0: sl@0: CFbsBitmap* bmp = new(ELeave) CFbsBitmap; sl@0: CleanupStack::PushL(bmp); sl@0: TInt err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize); sl@0: TESTNOERRORL(err); sl@0: sl@0: INFO_PRINTF1(_L("ExternalizeL()")); sl@0: CBufFlat* buf = CBufFlat::NewL(512); sl@0: CleanupStack::PushL(buf); sl@0: RBufWriteStream writeStream(*buf,0); sl@0: CleanupClosePushL(writeStream); sl@0: TRAP(err, bmp->ExternalizeL(writeStream)); sl@0: TESTEXPECTEDERRORL(err, KErrNotSupported); sl@0: sl@0: INFO_PRINTF1(_L("ExternalizeRectangleL()")); sl@0: RBufWriteStream writeStream2(*buf,0); sl@0: CleanupClosePushL(writeStream2); sl@0: TRAP(err, bmp->ExternalizeRectangleL(writeStream2, TRect(10,10,100,100))); sl@0: TESTEXPECTEDERRORL(err, KErrNotSupported); sl@0: sl@0: CleanupStack::PopAndDestroy(4, bmp); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-FBSERV-EXTENDEDBITMAP-0038 sl@0: sl@0: @SYMTestCaseDesc sl@0: Test that APIs that do not return an error value or leave, yet are not supported sl@0: for extended bitmaps, do not cause an error. sl@0: sl@0: @SYMPREQ sl@0: PREQ2096 sl@0: sl@0: @SYMREQ sl@0: REQ10847 sl@0: REQ10856 sl@0: REQ10857 sl@0: sl@0: @SYMTestPriority sl@0: High sl@0: sl@0: @SYMTestStatus sl@0: Implemented sl@0: sl@0: @SYMTestActions sl@0: For each API: sl@0: - Create an extended bitmap using test data and test Uid that is not supported by a rasterizer. sl@0: - Call the API. sl@0: The following APIs are tested: sl@0: - PaletteAttributes() sl@0: - SetPalette() sl@0: sl@0: @SYMTestExpectedResults sl@0: All APIs tested should complete with no errors. sl@0: */ sl@0: void CTExtendedBitmapLegacy::TestNotSupportedNoReturnL() sl@0: { sl@0: INFO_PRINTF1(_L("NotSupportedNoReturn - test legacy CFbsBitmap APIs that are not supported when used with an extended bitmap but do not return errors")); sl@0: sl@0: CFbsBitmap* bmp = new(ELeave) CFbsBitmap; sl@0: CleanupStack::PushL(bmp); sl@0: TInt err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize); sl@0: TESTNOERRORL(err); sl@0: sl@0: // Methods that are not supported and do not return errors values sl@0: INFO_PRINTF1(_L("PaletteAttributes()")); sl@0: TBool modifiable; sl@0: TInt numEntries; sl@0: bmp->PaletteAttributes(modifiable, numEntries); sl@0: sl@0: INFO_PRINTF1(_L("SetPalette()")); sl@0: bmp->SetPalette(NULL); sl@0: sl@0: CleanupStack::PopAndDestroy(bmp); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-FBSERV-EXTENDEDBITMAP-0039 sl@0: sl@0: @SYMTestCaseDesc sl@0: Test GetPixel with extended bitmaps where no rasterizer is present sl@0: that supports the extended bitmap type. sl@0: sl@0: @SYMCR sl@0: CR1804 sl@0: sl@0: @SYMREQ sl@0: REQ10858 sl@0: sl@0: @SYMTestPriority sl@0: High sl@0: sl@0: @SYMTestStatus sl@0: Implemented sl@0: sl@0: @SYMTestActions sl@0: Create an extended bitmap using test data and test Uid that is not supported by a rasterizer. sl@0: Call GetPixel(). sl@0: sl@0: @SYMTestExpectedResults sl@0: GetPixel() should return white pixels at the points requested, no errors should occur. sl@0: */ sl@0: void CTExtendedBitmapLegacy::TestGetPixelL() sl@0: { sl@0: INFO_PRINTF1(_L("Test CFbsBitmap::GetPixel() where there is no supported rasterizer for the passed extended bitmap Uid")); sl@0: sl@0: CFbsBitmap* bmp = new(ELeave) CFbsBitmap; sl@0: CleanupStack::PushL(bmp); sl@0: TInt err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize); sl@0: TESTNOERRORL(err); sl@0: sl@0: // Check that the absence of a rasteriser causes legacy off-screen rendering to sl@0: // treat the extended bitmap as if all pixels were white. sl@0: TRgb color; sl@0: for (TInt y = 0; y < KTestHeight; ++y) sl@0: { sl@0: for (TInt x = 0; x < KTestWidth; ++x) sl@0: { sl@0: bmp->GetPixel(color, TPoint(x,y)); sl@0: TESTTRUEL(color == KRgbWhite); sl@0: } sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(bmp); sl@0: } sl@0: sl@0: __CONSTRUCT_STEP__(ExtendedBitmapLegacy) sl@0: sl@0: void CTExtendedBitmapLegacyStep::TestSetupL() sl@0: { sl@0: // Copy files needed by the tests to c: sl@0: TheFs.Connect(); sl@0: TInt err = BaflUtils::CopyFile(TheFs, KRamBitmapFilenameOnZ, KRamBitmapFilename); sl@0: if (err != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("Error copying test mbm file from rom to ram: %d"), err); sl@0: User::Leave(err); sl@0: } sl@0: } sl@0: sl@0: void CTExtendedBitmapLegacyStep::TestClose() sl@0: { sl@0: // Delete files used by the tests from c: sl@0: BaflUtils::DeleteFile(TheFs, KRamBitmapFilename); sl@0: TheFs.Close(); sl@0: }