os/graphics/fbs/fontandbitmapserver/tfbs/tfbsbase.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/fbs/fontandbitmapserver/tfbs/tfbsbase.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,178 @@
     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 TFBSBASE_H
    1.20 +#define TFBSBASE_H
    1.21 +
    1.22 +#include "test/TGraphicsHarness.h"
    1.23 +#include <f32file.h>
    1.24 +
    1.25 +#define INFO_PRINTF9(p1, p2, p3, p4, p5, p6, p7, p8, p9) \
    1.26 +	{\
    1.27 +	Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4), (p5), (p6), (p7), (p8), (p9));\
    1.28 +	}
    1.29 +
    1.30 +#define ERR_PRINTF9(p1, p2, p3, p4, p5, p6, p7, p8, p9) \
    1.31 +	{\
    1.32 +	Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3), (p4), (p5), (p6), (p7), (p8), (p9));\
    1.33 +	}
    1.34 +
    1.35 +#define TESTTRUEL(a) \
    1.36 +	{\
    1.37 +	TBool b = a;\
    1.38 +	if(!b){\
    1.39 +		if(iCurrentRunIsLowMemory)\
    1.40 +			{\
    1.41 +			INFO_PRINTF1(_L("TESTTRUEL failed."));\
    1.42 +			}\
    1.43 +		else\
    1.44 +			{\
    1.45 +			ERR_PRINTF1(_L("TESTTRUEL failed."));\
    1.46 +			}\
    1.47 +		User::Leave(KErrGeneral);\
    1.48 +		}\
    1.49 +	}
    1.50 +
    1.51 +#define TESTEQUALL(actual, expected) \
    1.52 +	{\
    1.53 +	TBool b = (actual == expected);\
    1.54 +	if(!b){\
    1.55 +		if(iCurrentRunIsLowMemory)\
    1.56 +			{\
    1.57 +			INFO_PRINTF3(_L("TESTEQUALL failed. Expected %i, got %i"), expected, actual);\
    1.58 +			}\
    1.59 +		else\
    1.60 +			{\
    1.61 +			ERR_PRINTF3(_L("TESTEQUALL failed. Expected %i, got %i"), expected, actual);\
    1.62 +			}\
    1.63 +		User::Leave(KErrGeneral);\
    1.64 +		}\
    1.65 +	}
    1.66 +
    1.67 +#define TESTSIZEEQUALL(actual, expected) \
    1.68 +	{\
    1.69 +	TSize a = actual;\
    1.70 +	TSize b = expected;\
    1.71 +	TBool c = (actual == expected);\
    1.72 +	if(!c){\
    1.73 +		if(iCurrentRunIsLowMemory)\
    1.74 +			{\
    1.75 +			INFO_PRINTF5(_L("TESTEQUALL failed. Expected (%i,%i), got (%i,%i)"), b.iHeight, b.iWidth, a.iHeight, a.iWidth);\
    1.76 +			}\
    1.77 +		else\
    1.78 +			{\
    1.79 +			ERR_PRINTF5(_L("TESTEQUALL failed. Expected (%i,%i), got (%i,%i)"), b.iHeight, b.iWidth, a.iHeight, a.iWidth);\
    1.80 +			}\
    1.81 +		User::Leave(KErrGeneral);\
    1.82 +		}\
    1.83 +	}
    1.84 +
    1.85 +#define TESTCOLOREQUALL(actual, expected) \
    1.86 +	{\
    1.87 +	TRgb a = actual;\
    1.88 +	TRgb b = expected;\
    1.89 +	TBool c = (actual == expected);\
    1.90 +	if(!c){\
    1.91 +		if(iCurrentRunIsLowMemory)\
    1.92 +			{\
    1.93 +			INFO_PRINTF9(_L("TESTEQUALL failed. Expected (RGBA) (%i,%i,%i,%i), got (%i,%i,%i,%i)"), b.Red(), b.Green(), b.Blue(), b.Alpha(), a.Red(), a.Green(), a.Blue(), a.Alpha());\
    1.94 +			}\
    1.95 +		else\
    1.96 +			{\
    1.97 +			ERR_PRINTF9(_L("TESTEQUALL failed. Expected (RGBA) (%i,%i,%i,%i), got (%i,%i,%i,%i)"), b.Red(), b.Green(), b.Blue(), b.Alpha(), a.Red(), a.Green(), a.Blue(), a.Alpha());\
    1.98 +			}\
    1.99 +		User::Leave(KErrGeneral);\
   1.100 +		}\
   1.101 +	}
   1.102 +
   1.103 +#define TESTNOTEQUALL(actual, notexpected) \
   1.104 +	{\
   1.105 +	TBool b = (actual == notexpected);\
   1.106 +	if(b){\
   1.107 +		if(iCurrentRunIsLowMemory)\
   1.108 +			{\
   1.109 +			INFO_PRINTF2(_L("TESTNOTEQUALL failed. Expected not to get %i but did"), notexpected);\
   1.110 +			}\
   1.111 +		else\
   1.112 +			{\
   1.113 +			ERR_PRINTF2(_L("TESTNOTEQUALL failed. Expected not to get %i but did"), notexpected);\
   1.114 +			}\
   1.115 +		User::Leave(KErrGeneral);\
   1.116 +		}\
   1.117 +	}
   1.118 +
   1.119 +#define TESTNOERRORL(a) \
   1.120 +	{\
   1.121 +	TInt b = a;\
   1.122 +	if(KErrNone != b){\
   1.123 +		if(iCurrentRunIsLowMemory)\
   1.124 +			{\
   1.125 +			INFO_PRINTF2(_L("Error code returned: %i"), b);\
   1.126 +			}\
   1.127 +		else\
   1.128 +			{\
   1.129 +			ERR_PRINTF2(_L("Unexpected error code returned: %i"), b);\
   1.130 +			}\
   1.131 +		User::Leave(b);\
   1.132 +		}\
   1.133 +	}
   1.134 +	
   1.135 +#define TESTEXPECTEDERRORL(a, aExpectedError) \
   1.136 +	{\
   1.137 +	TInt b = a;\
   1.138 +	if(b != aExpectedError){\
   1.139 +		if(iCurrentRunIsLowMemory)\
   1.140 +			{\
   1.141 +			INFO_PRINTF3(_L("Expected error %i, but instead returned: %i"), aExpectedError, b);\
   1.142 +			}\
   1.143 +		else\
   1.144 +			{\
   1.145 +			ERR_PRINTF3(_L("Expected error %i, but instead returned: %i"), aExpectedError, b);\
   1.146 +			}\
   1.147 +		User::Leave(b);\
   1.148 +		}\
   1.149 +	}
   1.150 +
   1.151 +/** Base class used by all fbs extended bitmap test classes. Allows out of memory testing to
   1.152 +be carried out easily for each test case. 
   1.153 + */
   1.154 +class CTFbsBase : public CTGraphicsBase
   1.155 +	{
   1.156 +public:
   1.157 +	CTFbsBase(CTestStep* aStep, TBool aRunWithLowMemory);
   1.158 +	~CTFbsBase();
   1.159 +	
   1.160 +	static TRgb ExtractRgb(TUint8* aBuffer, TInt aPixelOffset, TDisplayMode aDispMode);
   1.161 +
   1.162 +protected:
   1.163 +	// From CTGraphicsStep
   1.164 +	virtual void RunTestCaseL(TInt aCurTestCase);
   1.165 +	
   1.166 +	// Fbs test - to be implemented by test class
   1.167 +	virtual void RunFbsTestL(TInt aCurTestCase) = 0;
   1.168 +	
   1.169 +	void SetLastTestCase();
   1.170 +
   1.171 +private:
   1.172 +	CTestStep&	iTestStep;
   1.173 +	TBool		iLastTestCase;
   1.174 +
   1.175 +protected:
   1.176 +	TBool		iRunWithLowMemory;
   1.177 +	TBool		iCurrentRunIsLowMemory;
   1.178 +
   1.179 +	};
   1.180 +
   1.181 +#endif //TFBSBASE_H