|
1 // Copyright (c) 2008-2009 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 TFBSBASE_H |
|
17 #define TFBSBASE_H |
|
18 |
|
19 #include "TGraphicsHarness.h" |
|
20 #include <f32file.h> |
|
21 |
|
22 #define INFO_PRINTF9(p1, p2, p3, p4, p5, p6, p7, p8, p9) \ |
|
23 {\ |
|
24 Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4), (p5), (p6), (p7), (p8), (p9));\ |
|
25 } |
|
26 |
|
27 #define ERR_PRINTF9(p1, p2, p3, p4, p5, p6, p7, p8, p9) \ |
|
28 {\ |
|
29 Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3), (p4), (p5), (p6), (p7), (p8), (p9));\ |
|
30 } |
|
31 |
|
32 #define TESTTRUEL(a) \ |
|
33 {\ |
|
34 TBool b = a;\ |
|
35 if(!b){\ |
|
36 if(iCurrentRunIsLowMemory)\ |
|
37 {\ |
|
38 INFO_PRINTF1(_L("TESTTRUEL failed."));\ |
|
39 }\ |
|
40 else\ |
|
41 {\ |
|
42 ERR_PRINTF1(_L("TESTTRUEL failed."));\ |
|
43 }\ |
|
44 User::Leave(KErrGeneral);\ |
|
45 }\ |
|
46 } |
|
47 |
|
48 #define TESTEQUALL(actual, expected) \ |
|
49 {\ |
|
50 TBool b = (actual == expected);\ |
|
51 if(!b){\ |
|
52 if(iCurrentRunIsLowMemory)\ |
|
53 {\ |
|
54 INFO_PRINTF3(_L("TESTEQUALL failed. Expected %i, got %i"), expected, actual);\ |
|
55 }\ |
|
56 else\ |
|
57 {\ |
|
58 ERR_PRINTF3(_L("TESTEQUALL failed. Expected %i, got %i"), expected, actual);\ |
|
59 }\ |
|
60 User::Leave(KErrGeneral);\ |
|
61 }\ |
|
62 } |
|
63 |
|
64 #define TESTSIZEEQUALL(actual, expected) \ |
|
65 {\ |
|
66 TSize a = actual;\ |
|
67 TSize b = expected;\ |
|
68 TBool c = (actual == expected);\ |
|
69 if(!c){\ |
|
70 if(iCurrentRunIsLowMemory)\ |
|
71 {\ |
|
72 INFO_PRINTF5(_L("TESTEQUALL failed. Expected (%i,%i), got (%i,%i)"), b.iHeight, b.iWidth, a.iHeight, a.iWidth);\ |
|
73 }\ |
|
74 else\ |
|
75 {\ |
|
76 ERR_PRINTF5(_L("TESTEQUALL failed. Expected (%i,%i), got (%i,%i)"), b.iHeight, b.iWidth, a.iHeight, a.iWidth);\ |
|
77 }\ |
|
78 User::Leave(KErrGeneral);\ |
|
79 }\ |
|
80 } |
|
81 |
|
82 #define TESTCOLOREQUALL(actual, expected) \ |
|
83 {\ |
|
84 TRgb a = actual;\ |
|
85 TRgb b = expected;\ |
|
86 TBool c = (actual == expected);\ |
|
87 if(!c){\ |
|
88 if(iCurrentRunIsLowMemory)\ |
|
89 {\ |
|
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());\ |
|
91 }\ |
|
92 else\ |
|
93 {\ |
|
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());\ |
|
95 }\ |
|
96 User::Leave(KErrGeneral);\ |
|
97 }\ |
|
98 } |
|
99 |
|
100 #define TESTNOTEQUALL(actual, notexpected) \ |
|
101 {\ |
|
102 TBool b = (actual == notexpected);\ |
|
103 if(b){\ |
|
104 if(iCurrentRunIsLowMemory)\ |
|
105 {\ |
|
106 INFO_PRINTF2(_L("TESTNOTEQUALL failed. Expected not to get %i but did"), notexpected);\ |
|
107 }\ |
|
108 else\ |
|
109 {\ |
|
110 ERR_PRINTF2(_L("TESTNOTEQUALL failed. Expected not to get %i but did"), notexpected);\ |
|
111 }\ |
|
112 User::Leave(KErrGeneral);\ |
|
113 }\ |
|
114 } |
|
115 |
|
116 #define TESTNOERRORL(a) \ |
|
117 {\ |
|
118 TInt b = a;\ |
|
119 if(KErrNone != b){\ |
|
120 if(iCurrentRunIsLowMemory)\ |
|
121 {\ |
|
122 INFO_PRINTF2(_L("Error code returned: %i"), b);\ |
|
123 }\ |
|
124 else\ |
|
125 {\ |
|
126 ERR_PRINTF2(_L("Unexpected error code returned: %i"), b);\ |
|
127 }\ |
|
128 User::Leave(b);\ |
|
129 }\ |
|
130 } |
|
131 |
|
132 #define TESTEXPECTEDERRORL(a, aExpectedError) \ |
|
133 {\ |
|
134 TInt b = a;\ |
|
135 if(b != aExpectedError){\ |
|
136 if(iCurrentRunIsLowMemory)\ |
|
137 {\ |
|
138 INFO_PRINTF3(_L("Expected error %i, but instead returned: %i"), aExpectedError, b);\ |
|
139 }\ |
|
140 else\ |
|
141 {\ |
|
142 ERR_PRINTF3(_L("Expected error %i, but instead returned: %i"), aExpectedError, b);\ |
|
143 }\ |
|
144 User::Leave(b);\ |
|
145 }\ |
|
146 } |
|
147 |
|
148 /** Base class used by all fbs extended bitmap test classes. Allows out of memory testing to |
|
149 be carried out easily for each test case. |
|
150 */ |
|
151 class CTFbsBase : public CTGraphicsBase |
|
152 { |
|
153 public: |
|
154 CTFbsBase(CTestStep* aStep, TBool aRunWithLowMemory); |
|
155 ~CTFbsBase(); |
|
156 |
|
157 static TRgb ExtractRgb(TUint8* aBuffer, TInt aPixelOffset, TDisplayMode aDispMode); |
|
158 |
|
159 protected: |
|
160 // From CTGraphicsStep |
|
161 virtual void RunTestCaseL(TInt aCurTestCase); |
|
162 |
|
163 // Fbs test - to be implemented by test class |
|
164 virtual void RunFbsTestL(TInt aCurTestCase) = 0; |
|
165 |
|
166 void SetLastTestCase(); |
|
167 |
|
168 private: |
|
169 CTestStep& iTestStep; |
|
170 TBool iLastTestCase; |
|
171 |
|
172 protected: |
|
173 TBool iRunWithLowMemory; |
|
174 TBool iCurrentRunIsLowMemory; |
|
175 |
|
176 }; |
|
177 |
|
178 #endif //TFBSBASE_H |