os/graphics/fbs/fontandbitmapserver/tfbs/textendedbitmapcommon.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #ifndef TEXTENDEDBITMAPCOMMON_H
    17 #define TEXTENDEDBITMAPCOMMON_H
    18 
    19 #include "test/TGraphicsHarness.h"
    20 
    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);
    24 
    25 // Macros to automatically test error condition and report when test fails.
    26 #define TESTCREATEEXTENDEDBITMAPL(sizeInPixels, displayMode, typeUid, data, dataSize, aExpectedError) \
    27 	{\
    28 	CFbsBitmap* bmp = new(ELeave)CFbsBitmap;\
    29 	TInt res = bmp->CreateExtendedBitmap(sizeInPixels, displayMode, typeUid, data, dataSize);\
    30 	delete bmp;\
    31 	TESTEXPECTEDERRORL(res, aExpectedError);\
    32 	}
    33 
    34 #define TESTCREATEEXTENDEDBITMAPINITIALIZERL(sizeInPixels, displayMode, typeUid, data, dataSize, aExpectedError) \
    35 	{\
    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);\
    40 	delete initializer;\
    41 	CleanupStack::PopAndDestroy(bmp2);\
    42 	TESTEXPECTEDERRORL(res2, aExpectedError);\
    43 	}
    44 
    45 
    46 class CTestExtendedBitmapInitializer : public CBase, public MFbsExtendedBitmapInitializer
    47 	{
    48 public:
    49 	CTestExtendedBitmapInitializer(const TUint8* aTestData, const TInt aTestDataSize);
    50 	
    51 	// From MFbsExtendedBitmapInitializer
    52 	TInt InitExtendedBitmap(TAny* aData, TInt aDataSize);
    53 private:
    54 	const TInt iTestDataSize;
    55 	const TUint8* iTestData;
    56 	};
    57 
    58 inline CTestExtendedBitmapInitializer::CTestExtendedBitmapInitializer(const TUint8* aTestData, const TInt aTestDataSize)
    59 : iTestDataSize(aTestDataSize), iTestData(aTestData)
    60 	{
    61 	}
    62 
    63 inline TInt CTestExtendedBitmapInitializer::InitExtendedBitmap(TAny* aData, TInt aDataSize)
    64 	{
    65 	if (!iTestData || iTestDataSize < aDataSize)
    66 		{
    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
    70 		return KErrUnderflow;
    71 		}
    72 	Mem::Copy(aData, iTestData, aDataSize);
    73 	return KErrNone;
    74 	}
    75 
    76 
    77 #endif // TEXTENDEDBITMAPCOMMON_H