|
1 // Copyright (c) 1997-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 |
|
17 #include <e32hal.h> |
|
18 #include "TGDI.H" |
|
19 #include <bitdev.h> |
|
20 #include <hal.h> |
|
21 #include "TBMP.H" |
|
22 #include "tbase.h" |
|
23 #include <graphics/fbsdefs.h> |
|
24 |
|
25 |
|
26 CTGdi::CTGdi(CTestStep* aStep): |
|
27 CTGraphicsBase(aStep), |
|
28 iTestGdi() |
|
29 { |
|
30 } |
|
31 |
|
32 void CTGdi::RunTestCaseL(TInt aCurTestCase) |
|
33 { |
|
34 ((CTGdiStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); |
|
35 switch(aCurTestCase) |
|
36 { |
|
37 case 1: |
|
38 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0030")); |
|
39 TestScreenL(EGray2); |
|
40 break; |
|
41 case 2: |
|
42 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0030")); |
|
43 TestScreenL(EGray4); |
|
44 break; |
|
45 case 3: |
|
46 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0030")); |
|
47 TestScreenL(EGray16); |
|
48 break; |
|
49 case 4: |
|
50 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0030")); |
|
51 TestScreenL(EGray256); |
|
52 break; |
|
53 case 5: |
|
54 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0030")); |
|
55 TestScreenL(EColor16); |
|
56 break; |
|
57 case 6: |
|
58 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0030")); |
|
59 TestScreenL(EColor256); |
|
60 break; |
|
61 case 7: |
|
62 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0030")); |
|
63 TestScreenL(EColor4K); |
|
64 break; |
|
65 case 8: |
|
66 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0030")); |
|
67 TestScreenL(EColor64K); |
|
68 break; |
|
69 case 9: |
|
70 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0030")); |
|
71 TestScreenL(EColor16M); |
|
72 break; |
|
73 case 10: |
|
74 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0030")); |
|
75 TestScreenL(EColor16MU); |
|
76 break; |
|
77 case 11: |
|
78 ((CTGdiStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); |
|
79 // Test still failing, see DEF094106 |
|
80 // TestScreenL(EColor16MA); |
|
81 break; |
|
82 case 12: |
|
83 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0031")); |
|
84 TestBitmapL(EGray2); |
|
85 break; |
|
86 case 13: |
|
87 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0031")); |
|
88 TestBitmapL(EGray4); |
|
89 break; |
|
90 case 14: |
|
91 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0031")); |
|
92 TestBitmapL(EGray16); |
|
93 break; |
|
94 case 15: |
|
95 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0031")); |
|
96 TestBitmapL(EGray256); |
|
97 break; |
|
98 case 16: |
|
99 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0031")); |
|
100 TestBitmapL(EColor16); |
|
101 break; |
|
102 case 17: |
|
103 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0031")); |
|
104 TestBitmapL(EColor256); |
|
105 break; |
|
106 case 18: |
|
107 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0031")); |
|
108 TestBitmapL(EColor4K); |
|
109 break; |
|
110 case 19: |
|
111 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0031")); |
|
112 TestBitmapL(EColor64K); |
|
113 break; |
|
114 case 20: |
|
115 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0031")); |
|
116 TestBitmapL(EColor16M); |
|
117 break; |
|
118 case 21: |
|
119 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0031")); |
|
120 TestBitmapL(EColor16MU); |
|
121 break; |
|
122 case 22: |
|
123 ((CTGdiStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); |
|
124 // Test still failing, see DEF094106 |
|
125 // TestBitmapL(EColor16MA); |
|
126 break; |
|
127 case 23: |
|
128 ((CTGdiStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); |
|
129 ((CTGdiStep*)iStep)->CloseTMSGraphicsStep(); |
|
130 TestComplete(); |
|
131 break; |
|
132 } |
|
133 ((CTGdiStep*)iStep)->RecordTestResultL(); |
|
134 // |
|
135 } |
|
136 |
|
137 |
|
138 /** |
|
139 @SYMTestCaseID GRAPHICS-BITGDI-0030 |
|
140 |
|
141 @SYMDEF |
|
142 |
|
143 @SYMTestCaseDesc Tests screen creation in various colour modes |
|
144 |
|
145 @SYMTestPriority High |
|
146 |
|
147 @SYMTestStatus Implemented |
|
148 |
|
149 @SYMTestActions Creates a screen in a certain colour mode, draws a bitmap on it then destroys it |
|
150 |
|
151 @SYMTestExpectedResults Test should pass |
|
152 */ |
|
153 void CTGdi::TestScreenL(TDisplayMode aDispMode) |
|
154 { |
|
155 CFbsScreenDevice* device = NULL; |
|
156 TRAPD(err,device = CFbsScreenDevice::NewL(_L("scdv"),aDispMode)); |
|
157 if (err == KErrNotSupported) |
|
158 return; |
|
159 else |
|
160 User::LeaveIfError(err); |
|
161 CleanupStack::PushL(device); |
|
162 device->ChangeScreenDevice(NULL); |
|
163 device->SetAutoUpdate(ETrue); |
|
164 |
|
165 DoTestAndDeleteL(device,ETrue); |
|
166 CleanupStack::PopAndDestroy(1,device); |
|
167 } |
|
168 |
|
169 |
|
170 /** |
|
171 @SYMTestCaseID GRAPHICS-BITGDI-0031 |
|
172 |
|
173 @SYMDEF |
|
174 |
|
175 @SYMTestCaseDesc Tests bitmap creation in various colour modes |
|
176 |
|
177 @SYMTestPriority High |
|
178 |
|
179 @SYMTestStatus Implemented |
|
180 |
|
181 @SYMTestActions Creates a bitmap in a certain colour mode, draws a bitmap on it then destroys it |
|
182 |
|
183 @SYMTestExpectedResults Test should pass |
|
184 */ |
|
185 void CTGdi::TestBitmapL(TDisplayMode aDispMode) |
|
186 { |
|
187 CFbsBitmap* bitmap = new(ELeave) CFbsBitmap; |
|
188 CleanupStack::PushL(bitmap); |
|
189 //Creating a Reference Bitmap of screensize to compare the results |
|
190 CFbsScreenDevice* qdevice = NULL; |
|
191 TRAPD(error, qdevice = CFbsScreenDevice::NewL(_L("scdv"),aDispMode)); |
|
192 |
|
193 if (error == KErrNotSupported) |
|
194 { |
|
195 CleanupStack::PopAndDestroy(bitmap); |
|
196 return; |
|
197 } |
|
198 else |
|
199 { |
|
200 User::LeaveIfError(error); |
|
201 } |
|
202 |
|
203 CleanupStack::PushL(qdevice); |
|
204 qdevice->SetAutoUpdate(ETrue); |
|
205 TSize screensize=qdevice->SizeInPixels(); |
|
206 TInt ret = bitmap->Create(screensize,aDispMode); |
|
207 if (ret == KErrNotSupported) |
|
208 { |
|
209 CleanupStack::PopAndDestroy(2,bitmap); |
|
210 return; |
|
211 } |
|
212 else |
|
213 { |
|
214 User::LeaveIfError(ret); |
|
215 } |
|
216 |
|
217 CFbsBitmapDevice* device = CFbsBitmapDevice::NewL(bitmap); |
|
218 CleanupStack::PushL(device); |
|
219 DoTestAndDeleteL(device, EFalse); |
|
220 CleanupStack::PopAndDestroy(3,bitmap); |
|
221 } |
|
222 |
|
223 void CTGdi::DoTestAndDeleteL(CFbsDevice* aDevice,TBool aScreen) |
|
224 { |
|
225 CFbsBitGc* gc = NULL; |
|
226 User::LeaveIfError(aDevice->CreateContext(gc)); |
|
227 CleanupStack::PushL(gc); |
|
228 |
|
229 CFbsFont* font = NULL; |
|
230 User::LeaveIfError(aDevice->GetNearestFontToDesignHeightInTwips(font,TFontSpec())); |
|
231 gc->UseFont(font); |
|
232 aDevice->ReleaseFont(font); |
|
233 |
|
234 CFbsBitmap* bmp = new(ELeave) CFbsBitmap; |
|
235 CleanupStack::PushL(bmp); |
|
236 TInt ret = bmp->Load(_L("z:\\system\\data\\tbmp.mbm"),EMbmTbmpTblank); |
|
237 User::LeaveIfError(ret); |
|
238 gc->UseBrushPattern(bmp->Handle()); |
|
239 |
|
240 if (aScreen) |
|
241 INFO_PRINTF2(_L("Gdi screen device testing, mode %d\n"),aDevice->DisplayMode()); |
|
242 else |
|
243 INFO_PRINTF2(_L("Gdi bitmap device testing, mode %d\n"),aDevice->DisplayMode()); |
|
244 |
|
245 TBuf<KFailureSectionNameBufferLength> section; |
|
246 iTestGdi.Construct(aDevice,gc,section); |
|
247 |
|
248 TBool pass = iTestGdi.Test(); |
|
249 |
|
250 if (!pass) |
|
251 { |
|
252 INFO_PRINTF2(_L("Gdi device test failed section: %S"),§ion); |
|
253 //Getch(); |
|
254 } |
|
255 TEST(pass); |
|
256 |
|
257 CleanupStack::PopAndDestroy(2,gc); |
|
258 } |
|
259 |
|
260 //-------------- |
|
261 __CONSTRUCT_STEP__(Gdi) |
|
262 |
|
263 void CTGdiStep::TestSetupL() |
|
264 { |
|
265 FbsStartup(); |
|
266 User::LeaveIfError(RFbsSession::Connect()); |
|
267 } |
|
268 |
|
269 void CTGdiStep::TestClose() |
|
270 { |
|
271 RFbsSession::Disconnect(); |
|
272 } |