Update contrib.
1 // Copyright (c) 2008-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef TEXTENDEDBITMAPCOMMON_H
17 #define TEXTENDEDBITMAPCOMMON_H
19 #include "test/TGraphicsHarness.h"
21 // Uid for use when testing an extended bitmap that does not need to be
22 // drawn using the example rasterizer.
23 const TUid KUidTestExtendedBitmap = TUid::Uid(0xFFFFFFFF);
25 // Macros to automatically test error condition and report when test fails.
26 #define TESTCREATEEXTENDEDBITMAPL(sizeInPixels, displayMode, typeUid, data, dataSize, aExpectedError) \
28 CFbsBitmap* bmp = new(ELeave)CFbsBitmap;\
29 TInt res = bmp->CreateExtendedBitmap(sizeInPixels, displayMode, typeUid, data, dataSize);\
31 TESTEXPECTEDERRORL(res, aExpectedError);\
34 #define TESTCREATEEXTENDEDBITMAPINITIALIZERL(sizeInPixels, displayMode, typeUid, data, dataSize, aExpectedError) \
36 CFbsBitmap* bmp2 = new(ELeave)CFbsBitmap;\
37 CleanupStack::PushL(bmp2);\
38 CTestExtendedBitmapInitializer* initializer = new(ELeave) CTestExtendedBitmapInitializer(data, dataSize);\
39 TInt res2 = bmp2->CreateExtendedBitmap(sizeInPixels, displayMode, typeUid, dataSize, *initializer);\
41 CleanupStack::PopAndDestroy(bmp2);\
42 TESTEXPECTEDERRORL(res2, aExpectedError);\
46 class CTestExtendedBitmapInitializer : public CBase, public MFbsExtendedBitmapInitializer
49 CTestExtendedBitmapInitializer(const TUint8* aTestData, const TInt aTestDataSize);
51 // From MFbsExtendedBitmapInitializer
52 TInt InitExtendedBitmap(TAny* aData, TInt aDataSize);
54 const TInt iTestDataSize;
55 const TUint8* iTestData;
58 inline CTestExtendedBitmapInitializer::CTestExtendedBitmapInitializer(const TUint8* aTestData, const TInt aTestDataSize)
59 : iTestDataSize(aTestDataSize), iTestData(aTestData)
63 inline TInt CTestExtendedBitmapInitializer::InitExtendedBitmap(TAny* aData, TInt aDataSize)
65 if (!iTestData || iTestDataSize < aDataSize)
67 // Used to test handling of initializer error by CreateExtendedBitmap() and for
68 // GRAPHICS-FBSERV-EXTENDEDBITMAP-0014 - CTExtendedBitmapNegative::CreateNullDataL()
69 // to be returned the correct error on providing NULL data
72 Mem::Copy(aData, iTestData, aDataSize);
77 #endif // TEXTENDEDBITMAPCOMMON_H