|
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 #include <bitdev.h> |
|
17 #include <hal.h> |
|
18 #include "TBMP.H" |
|
19 #include "tparam.h" |
|
20 #include <graphics/fbsdefs.h> |
|
21 |
|
22 |
|
23 CTParam::CTParam(CTestStep* aStep): |
|
24 CTGraphicsBase(aStep), |
|
25 iDevice(NULL), |
|
26 iContext(NULL) |
|
27 { |
|
28 INFO_PRINTF1(_L("Large parameter testing")); |
|
29 } |
|
30 |
|
31 void CTParam::RunTestCaseL(TInt aCurTestCase) |
|
32 { |
|
33 ((CTParamStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); |
|
34 switch(aCurTestCase) |
|
35 { |
|
36 case 1: |
|
37 { |
|
38 ((CTParamStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0084")); |
|
39 INFO_PRINTF1(_L("Test display mode EGray256")); |
|
40 DoTestL(EGray256); |
|
41 break; |
|
42 } |
|
43 case 2: |
|
44 { |
|
45 ((CTParamStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0084")); |
|
46 INFO_PRINTF1(_L("Test display mode EColor256")); |
|
47 DoTestL(EColor256); |
|
48 break; |
|
49 } |
|
50 case 3: |
|
51 { |
|
52 ((CTParamStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0084")); |
|
53 INFO_PRINTF1(_L("Test display mode EColor4K")); |
|
54 DoTestL(EColor4K); |
|
55 break; |
|
56 } |
|
57 case 4: |
|
58 { |
|
59 ((CTParamStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0084")); |
|
60 INFO_PRINTF1(_L("Test display mode EColor64K")); |
|
61 DoTestL(EColor64K); |
|
62 break; |
|
63 } |
|
64 case 5: |
|
65 { |
|
66 ((CTParamStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0084")); |
|
67 INFO_PRINTF1(_L("Test display mode EColor16M")); |
|
68 DoTestL(EColor16M); |
|
69 break; |
|
70 } |
|
71 case 6: |
|
72 { |
|
73 ((CTParamStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0084")); |
|
74 INFO_PRINTF1(_L("Test display mode EColor16MU")); |
|
75 DoTestL(EColor16MU); |
|
76 break; |
|
77 } |
|
78 case 7: |
|
79 { |
|
80 ((CTParamStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0084")); |
|
81 INFO_PRINTF1(_L("Test display mode EColor16MA")); |
|
82 DoTestL(EColor16MA); |
|
83 break; |
|
84 } |
|
85 case 8: |
|
86 { |
|
87 ((CTParamStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0084")); |
|
88 INFO_PRINTF1(_L("Test display mode EColor16MAP")); |
|
89 DoTestL(EColor16MAP); |
|
90 break; |
|
91 } |
|
92 case 9: |
|
93 { |
|
94 ((CTParamStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); |
|
95 ((CTParamStep*)iStep)->CloseTMSGraphicsStep(); |
|
96 TestComplete(); |
|
97 break; |
|
98 } |
|
99 } |
|
100 ((CTParamStep*)iStep)->RecordTestResultL(); |
|
101 } |
|
102 |
|
103 /** |
|
104 @SYMTestCaseID GRAPHICS-BITGDI-0084 |
|
105 |
|
106 @SYMDEF |
|
107 |
|
108 @SYMTestCaseDesc tests the display modes |
|
109 |
|
110 @SYMTestPriority High |
|
111 |
|
112 @SYMTestStatus Implemented |
|
113 |
|
114 @SYMTestActions tests various graphic drawing and text drawing functions to all current screen modes |
|
115 |
|
116 @SYMTestExpectedResults Test should perform graphics operations succesfully. |
|
117 */ |
|
118 void CTParam::DoTestL(TDisplayMode aDispMode) |
|
119 { |
|
120 TRAPD(err,iDevice = CFbsScreenDevice::NewL(_L("scdv"),aDispMode)); |
|
121 if (err == KErrNotSupported) |
|
122 return; |
|
123 iDevice->ChangeScreenDevice(NULL); |
|
124 iDevice->SetAutoUpdate(ETrue); |
|
125 User::LeaveIfError(iDevice->CreateContext(iContext)); |
|
126 |
|
127 iDevice->SetScalingFactor(TPoint(15, 7), 3, 2, 1, 1); |
|
128 iContext->Activate(iDevice); |
|
129 |
|
130 CFbsFont* font = NULL; |
|
131 User::LeaveIfError(iDevice->GetNearestFontToDesignHeightInTwips(font,TFontSpec())); |
|
132 iContext->UseFont(font); |
|
133 iDevice->ReleaseFont(font); |
|
134 |
|
135 TInt ret = iBitmap.Load(_L("z:\\system\\data\\tbmp.mbm"),EMbmTbmpTbmp,EFalse); |
|
136 User::LeaveIfError(ret); |
|
137 |
|
138 DoAnotherTestL(); |
|
139 |
|
140 iBitmap.Reset(); |
|
141 delete iContext; |
|
142 delete iDevice; |
|
143 } |
|
144 |
|
145 void CTParam::DoAnotherTestL() |
|
146 { |
|
147 INFO_PRINTF1(_L("Parameters : check large parameters do not take too long")); |
|
148 TRect vlarge(-1000000000,-1000000000,1000000000,1000000000); |
|
149 TRect screen; |
|
150 iDevice->GetDrawRect(screen); |
|
151 |
|
152 INFO_PRINTF1(_L("Origin")); |
|
153 iContext->SetOrigin(vlarge.iTl); |
|
154 iContext->DrawRect(screen); |
|
155 iContext->SetOrigin(); |
|
156 iContext->Clear(screen); |
|
157 iContext->SetOrigin(vlarge.iBr); |
|
158 iContext->DrawRect(screen); |
|
159 iContext->SetOrigin(); |
|
160 iContext->Clear(screen); |
|
161 |
|
162 iContext->SetBrushStyle(CGraphicsContext::EDiamondCrossHatchBrush); |
|
163 iContext->SetBrushColor(KRgbBlack); |
|
164 INFO_PRINTF1(_L("BrushOrigin")); |
|
165 iContext->SetBrushOrigin(vlarge.iTl); |
|
166 iContext->DrawRect(screen); |
|
167 iContext->SetBrushOrigin(TPoint(0,0)); |
|
168 iContext->SetBrushColor(KRgbWhite); |
|
169 iContext->Clear(screen); |
|
170 iContext->SetBrushOrigin(vlarge.iBr); |
|
171 iContext->SetBrushColor(KRgbBlack); |
|
172 iContext->DrawRect(screen); |
|
173 iContext->SetBrushOrigin(TPoint(0,0)); |
|
174 iContext->SetBrushColor(KRgbWhite); |
|
175 iContext->Clear(screen); |
|
176 |
|
177 iContext->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
178 INFO_PRINTF1(_L("Plot")); |
|
179 iContext->Plot(vlarge.iBr); |
|
180 iContext->Clear(screen); |
|
181 |
|
182 INFO_PRINTF1(_L("DrawLine - Solid pen")); |
|
183 TInt count=1; |
|
184 for(;count<10000;count*=10) |
|
185 { |
|
186 iContext->SetPenSize(TSize(count,count)); |
|
187 INFO_PRINTF1(_L("Very large line 1")); |
|
188 iContext->DrawLine(vlarge.iBr,vlarge.iTl); |
|
189 INFO_PRINTF1(_L("Very large line 2")); |
|
190 iContext->DrawLine(TPoint(-1000000000,screen.iTl.iY),TPoint(1000000000,1000000000)); |
|
191 INFO_PRINTF1(_L("Very large line 3")); |
|
192 iContext->DrawLine(TPoint(screen.iTl.iX,-1000000000),TPoint(1000000000,1000000000)); |
|
193 INFO_PRINTF1(_L("Very large line 4")); |
|
194 iContext->DrawLine(TPoint(-1000000000,-1000000000),screen.iTl); |
|
195 INFO_PRINTF1(_L("Very large line 5")); |
|
196 iContext->DrawLine(screen.iBr,TPoint(1000000000,1000000000)); |
|
197 iContext->Clear(screen); |
|
198 } |
|
199 |
|
200 iContext->SetPenStyle(CGraphicsContext::EDottedPen); |
|
201 INFO_PRINTF1(_L("Line - Dotted pen")); |
|
202 for(count=1;count<10000;count*=10) |
|
203 { |
|
204 iContext->SetPenSize(TSize(count,count)); |
|
205 INFO_PRINTF1(_L("Very large line 1")); |
|
206 iContext->DrawLine(vlarge.iBr,vlarge.iTl); |
|
207 INFO_PRINTF1(_L("Very large line 2")); |
|
208 iContext->DrawLine(TPoint(-1000000000,screen.iTl.iY),TPoint(1000000000,1000000000)); |
|
209 INFO_PRINTF1(_L("Very large line 3")); |
|
210 iContext->DrawLine(TPoint(screen.iTl.iX,-1000000000),TPoint(1000000000,1000000000)); |
|
211 INFO_PRINTF1(_L("Very large line 4")); |
|
212 iContext->DrawLine(TPoint(-1000000000,-1000000000),screen.iTl); |
|
213 INFO_PRINTF1(_L("Very large line 5")); |
|
214 iContext->DrawLine(screen.iBr,TPoint(1000000000,1000000000)); |
|
215 iContext->Clear(screen); |
|
216 } |
|
217 |
|
218 iContext->SetPenStyle(CGraphicsContext::ESolidPen); |
|
219 iContext->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
220 iContext->SetBrushColor(KRgbBlack); |
|
221 iContext->SetPenSize(TSize(1,1)); |
|
222 INFO_PRINTF1(_L("Arc")); |
|
223 iContext->DrawArc(vlarge,vlarge.iBr,vlarge.iBr); |
|
224 iContext->Clear(screen); |
|
225 |
|
226 INFO_PRINTF1(_L("Ellipse")); |
|
227 iContext->DrawEllipse(vlarge); |
|
228 iContext->Clear(screen); |
|
229 |
|
230 INFO_PRINTF1(_L("Pie")); |
|
231 iContext->DrawPie(vlarge,vlarge.iBr,vlarge.iBr); |
|
232 iContext->Clear(screen); |
|
233 |
|
234 INFO_PRINTF1(_L("RoundRect")); |
|
235 iContext->DrawRoundRect(vlarge,TSize(100000000,100000000)); |
|
236 iContext->Clear(screen); |
|
237 |
|
238 INFO_PRINTF1(_L("Rect")); |
|
239 iContext->DrawRect(vlarge); |
|
240 iContext->Clear(screen); |
|
241 |
|
242 INFO_PRINTF1(_L("CopyRect")); |
|
243 iContext->CopyRect(TPoint(100000000,100000000),vlarge); |
|
244 iContext->Clear(screen); |
|
245 |
|
246 INFO_PRINTF1(_L("BitBlt")); |
|
247 iContext->BitBlt(TPoint(0,0),*iContext,vlarge); |
|
248 iContext->Clear(screen); |
|
249 iContext->BitBlt(TPoint(0,0),&iBitmap,vlarge); |
|
250 iContext->Clear(screen); |
|
251 |
|
252 INFO_PRINTF1(_L("BitBltMasked")); |
|
253 iContext->BitBltMasked(TPoint(0,0),&iBitmap,vlarge,&iBitmap,EFalse); |
|
254 iContext->Clear(screen); |
|
255 |
|
256 iContext->SetBrushColor(KRgbBlack); |
|
257 iContext->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
258 INFO_PRINTF1(_L("Polygon")); |
|
259 CArrayFixFlat<TPoint>* poly=new CArrayFixFlat<TPoint>(4); |
|
260 poly->AppendL(vlarge.iTl); |
|
261 TPoint temp(vlarge.iBr.iX,vlarge.iTl.iY); |
|
262 poly->AppendL(temp); |
|
263 poly->AppendL(vlarge.iBr); |
|
264 temp.SetXY(vlarge.iTl.iX,vlarge.iBr.iY); |
|
265 poly->AppendL(temp); |
|
266 iContext->DrawPolygon(poly); |
|
267 iContext->Clear(screen); |
|
268 delete poly; |
|
269 |
|
270 INFO_PRINTF1(_L("DrawBitmap")); |
|
271 iContext->DrawBitmap(vlarge,&iBitmap); |
|
272 iContext->Clear(screen); |
|
273 |
|
274 INFO_PRINTF1(_L("Text")); |
|
275 TBuf<16> text(_L("Test text.")); |
|
276 iContext->DrawText(text,vlarge.iTl); |
|
277 iContext->DrawText(_L("Test text."),vlarge.iBr); |
|
278 iContext->SetCharJustification(100000000,1); |
|
279 iContext->SetWordJustification(100000000,1); |
|
280 iContext->DrawText(_L("Test text."),TPoint(0,0)); |
|
281 iContext->Clear(screen); |
|
282 } |
|
283 |
|
284 //-------------- |
|
285 __CONSTRUCT_STEP__(Param) |
|
286 |
|
287 void CTParamStep::TestSetupL() |
|
288 { |
|
289 FbsStartup(); |
|
290 User::LeaveIfError(RFbsSession::Connect()); |
|
291 } |
|
292 |
|
293 void CTParamStep::TestClose() |
|
294 { |
|
295 RFbsSession::Disconnect(); |
|
296 } |