os/graphics/fbs/fontandbitmapserver/tfbs/tfbsbase.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#ifndef TFBSBASE_H
sl@0
    17
#define TFBSBASE_H
sl@0
    18
sl@0
    19
#include "test/TGraphicsHarness.h"
sl@0
    20
#include <f32file.h>
sl@0
    21
sl@0
    22
#define INFO_PRINTF9(p1, p2, p3, p4, p5, p6, p7, p8, p9) \
sl@0
    23
	{\
sl@0
    24
	Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4), (p5), (p6), (p7), (p8), (p9));\
sl@0
    25
	}
sl@0
    26
sl@0
    27
#define ERR_PRINTF9(p1, p2, p3, p4, p5, p6, p7, p8, p9) \
sl@0
    28
	{\
sl@0
    29
	Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3), (p4), (p5), (p6), (p7), (p8), (p9));\
sl@0
    30
	}
sl@0
    31
sl@0
    32
#define TESTTRUEL(a) \
sl@0
    33
	{\
sl@0
    34
	TBool b = a;\
sl@0
    35
	if(!b){\
sl@0
    36
		if(iCurrentRunIsLowMemory)\
sl@0
    37
			{\
sl@0
    38
			INFO_PRINTF1(_L("TESTTRUEL failed."));\
sl@0
    39
			}\
sl@0
    40
		else\
sl@0
    41
			{\
sl@0
    42
			ERR_PRINTF1(_L("TESTTRUEL failed."));\
sl@0
    43
			}\
sl@0
    44
		User::Leave(KErrGeneral);\
sl@0
    45
		}\
sl@0
    46
	}
sl@0
    47
sl@0
    48
#define TESTEQUALL(actual, expected) \
sl@0
    49
	{\
sl@0
    50
	TBool b = (actual == expected);\
sl@0
    51
	if(!b){\
sl@0
    52
		if(iCurrentRunIsLowMemory)\
sl@0
    53
			{\
sl@0
    54
			INFO_PRINTF3(_L("TESTEQUALL failed. Expected %i, got %i"), expected, actual);\
sl@0
    55
			}\
sl@0
    56
		else\
sl@0
    57
			{\
sl@0
    58
			ERR_PRINTF3(_L("TESTEQUALL failed. Expected %i, got %i"), expected, actual);\
sl@0
    59
			}\
sl@0
    60
		User::Leave(KErrGeneral);\
sl@0
    61
		}\
sl@0
    62
	}
sl@0
    63
sl@0
    64
#define TESTSIZEEQUALL(actual, expected) \
sl@0
    65
	{\
sl@0
    66
	TSize a = actual;\
sl@0
    67
	TSize b = expected;\
sl@0
    68
	TBool c = (actual == expected);\
sl@0
    69
	if(!c){\
sl@0
    70
		if(iCurrentRunIsLowMemory)\
sl@0
    71
			{\
sl@0
    72
			INFO_PRINTF5(_L("TESTEQUALL failed. Expected (%i,%i), got (%i,%i)"), b.iHeight, b.iWidth, a.iHeight, a.iWidth);\
sl@0
    73
			}\
sl@0
    74
		else\
sl@0
    75
			{\
sl@0
    76
			ERR_PRINTF5(_L("TESTEQUALL failed. Expected (%i,%i), got (%i,%i)"), b.iHeight, b.iWidth, a.iHeight, a.iWidth);\
sl@0
    77
			}\
sl@0
    78
		User::Leave(KErrGeneral);\
sl@0
    79
		}\
sl@0
    80
	}
sl@0
    81
sl@0
    82
#define TESTCOLOREQUALL(actual, expected) \
sl@0
    83
	{\
sl@0
    84
	TRgb a = actual;\
sl@0
    85
	TRgb b = expected;\
sl@0
    86
	TBool c = (actual == expected);\
sl@0
    87
	if(!c){\
sl@0
    88
		if(iCurrentRunIsLowMemory)\
sl@0
    89
			{\
sl@0
    90
			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());\
sl@0
    91
			}\
sl@0
    92
		else\
sl@0
    93
			{\
sl@0
    94
			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());\
sl@0
    95
			}\
sl@0
    96
		User::Leave(KErrGeneral);\
sl@0
    97
		}\
sl@0
    98
	}
sl@0
    99
sl@0
   100
#define TESTNOTEQUALL(actual, notexpected) \
sl@0
   101
	{\
sl@0
   102
	TBool b = (actual == notexpected);\
sl@0
   103
	if(b){\
sl@0
   104
		if(iCurrentRunIsLowMemory)\
sl@0
   105
			{\
sl@0
   106
			INFO_PRINTF2(_L("TESTNOTEQUALL failed. Expected not to get %i but did"), notexpected);\
sl@0
   107
			}\
sl@0
   108
		else\
sl@0
   109
			{\
sl@0
   110
			ERR_PRINTF2(_L("TESTNOTEQUALL failed. Expected not to get %i but did"), notexpected);\
sl@0
   111
			}\
sl@0
   112
		User::Leave(KErrGeneral);\
sl@0
   113
		}\
sl@0
   114
	}
sl@0
   115
sl@0
   116
#define TESTNOERRORL(a) \
sl@0
   117
	{\
sl@0
   118
	TInt b = a;\
sl@0
   119
	if(KErrNone != b){\
sl@0
   120
		if(iCurrentRunIsLowMemory)\
sl@0
   121
			{\
sl@0
   122
			INFO_PRINTF2(_L("Error code returned: %i"), b);\
sl@0
   123
			}\
sl@0
   124
		else\
sl@0
   125
			{\
sl@0
   126
			ERR_PRINTF2(_L("Unexpected error code returned: %i"), b);\
sl@0
   127
			}\
sl@0
   128
		User::Leave(b);\
sl@0
   129
		}\
sl@0
   130
	}
sl@0
   131
	
sl@0
   132
#define TESTEXPECTEDERRORL(a, aExpectedError) \
sl@0
   133
	{\
sl@0
   134
	TInt b = a;\
sl@0
   135
	if(b != aExpectedError){\
sl@0
   136
		if(iCurrentRunIsLowMemory)\
sl@0
   137
			{\
sl@0
   138
			INFO_PRINTF3(_L("Expected error %i, but instead returned: %i"), aExpectedError, b);\
sl@0
   139
			}\
sl@0
   140
		else\
sl@0
   141
			{\
sl@0
   142
			ERR_PRINTF3(_L("Expected error %i, but instead returned: %i"), aExpectedError, b);\
sl@0
   143
			}\
sl@0
   144
		User::Leave(b);\
sl@0
   145
		}\
sl@0
   146
	}
sl@0
   147
sl@0
   148
/** Base class used by all fbs extended bitmap test classes. Allows out of memory testing to
sl@0
   149
be carried out easily for each test case. 
sl@0
   150
 */
sl@0
   151
class CTFbsBase : public CTGraphicsBase
sl@0
   152
	{
sl@0
   153
public:
sl@0
   154
	CTFbsBase(CTestStep* aStep, TBool aRunWithLowMemory);
sl@0
   155
	~CTFbsBase();
sl@0
   156
	
sl@0
   157
	static TRgb ExtractRgb(TUint8* aBuffer, TInt aPixelOffset, TDisplayMode aDispMode);
sl@0
   158
sl@0
   159
protected:
sl@0
   160
	// From CTGraphicsStep
sl@0
   161
	virtual void RunTestCaseL(TInt aCurTestCase);
sl@0
   162
	
sl@0
   163
	// Fbs test - to be implemented by test class
sl@0
   164
	virtual void RunFbsTestL(TInt aCurTestCase) = 0;
sl@0
   165
	
sl@0
   166
	void SetLastTestCase();
sl@0
   167
sl@0
   168
private:
sl@0
   169
	CTestStep&	iTestStep;
sl@0
   170
	TBool		iLastTestCase;
sl@0
   171
sl@0
   172
protected:
sl@0
   173
	TBool		iRunWithLowMemory;
sl@0
   174
	TBool		iCurrentRunIsLowMemory;
sl@0
   175
sl@0
   176
	};
sl@0
   177
sl@0
   178
#endif //TFBSBASE_H