os/graphics/fbs/fontandbitmapserver/tfbs/textendedbitmapcommon.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/fbs/fontandbitmapserver/tfbs/textendedbitmapcommon.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,77 @@
     1.4 +// Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#ifndef TEXTENDEDBITMAPCOMMON_H
    1.20 +#define TEXTENDEDBITMAPCOMMON_H
    1.21 +
    1.22 +#include "test/TGraphicsHarness.h"
    1.23 +
    1.24 +// Uid for use when testing an extended bitmap that does not need to be
    1.25 +// drawn using the example rasterizer.
    1.26 +const TUid KUidTestExtendedBitmap	= TUid::Uid(0xFFFFFFFF);
    1.27 +
    1.28 +// Macros to automatically test error condition and report when test fails.
    1.29 +#define TESTCREATEEXTENDEDBITMAPL(sizeInPixels, displayMode, typeUid, data, dataSize, aExpectedError) \
    1.30 +	{\
    1.31 +	CFbsBitmap* bmp = new(ELeave)CFbsBitmap;\
    1.32 +	TInt res = bmp->CreateExtendedBitmap(sizeInPixels, displayMode, typeUid, data, dataSize);\
    1.33 +	delete bmp;\
    1.34 +	TESTEXPECTEDERRORL(res, aExpectedError);\
    1.35 +	}
    1.36 +
    1.37 +#define TESTCREATEEXTENDEDBITMAPINITIALIZERL(sizeInPixels, displayMode, typeUid, data, dataSize, aExpectedError) \
    1.38 +	{\
    1.39 +	CFbsBitmap* bmp2 = new(ELeave)CFbsBitmap;\
    1.40 +	CleanupStack::PushL(bmp2);\
    1.41 +	CTestExtendedBitmapInitializer* initializer = new(ELeave) CTestExtendedBitmapInitializer(data, dataSize);\
    1.42 +	TInt res2 = bmp2->CreateExtendedBitmap(sizeInPixels, displayMode, typeUid, dataSize, *initializer);\
    1.43 +	delete initializer;\
    1.44 +	CleanupStack::PopAndDestroy(bmp2);\
    1.45 +	TESTEXPECTEDERRORL(res2, aExpectedError);\
    1.46 +	}
    1.47 +
    1.48 +
    1.49 +class CTestExtendedBitmapInitializer : public CBase, public MFbsExtendedBitmapInitializer
    1.50 +	{
    1.51 +public:
    1.52 +	CTestExtendedBitmapInitializer(const TUint8* aTestData, const TInt aTestDataSize);
    1.53 +	
    1.54 +	// From MFbsExtendedBitmapInitializer
    1.55 +	TInt InitExtendedBitmap(TAny* aData, TInt aDataSize);
    1.56 +private:
    1.57 +	const TInt iTestDataSize;
    1.58 +	const TUint8* iTestData;
    1.59 +	};
    1.60 +
    1.61 +inline CTestExtendedBitmapInitializer::CTestExtendedBitmapInitializer(const TUint8* aTestData, const TInt aTestDataSize)
    1.62 +: iTestDataSize(aTestDataSize), iTestData(aTestData)
    1.63 +	{
    1.64 +	}
    1.65 +
    1.66 +inline TInt CTestExtendedBitmapInitializer::InitExtendedBitmap(TAny* aData, TInt aDataSize)
    1.67 +	{
    1.68 +	if (!iTestData || iTestDataSize < aDataSize)
    1.69 +		{
    1.70 +		// Used to test handling of initializer error by CreateExtendedBitmap() and for
    1.71 +		// GRAPHICS-FBSERV-EXTENDEDBITMAP-0014 - CTExtendedBitmapNegative::CreateNullDataL()
    1.72 +		// to be returned the correct error on providing NULL data
    1.73 +		return KErrUnderflow;
    1.74 +		}
    1.75 +	Mem::Copy(aData, iTestData, aDataSize);
    1.76 +	return KErrNone;
    1.77 +	}
    1.78 +
    1.79 +
    1.80 +#endif // TEXTENDEDBITMAPCOMMON_H