|
1 // Copyright (c) 1996-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 // Screen device test code |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @test |
|
21 @internalComponent - Internal Symbian test code |
|
22 */ |
|
23 |
|
24 #include "TSCRDEVRESSWITCH.H" |
|
25 |
|
26 //Define this to get visible pauses (in test 6: DeviceResSwitchL) |
|
27 //#define VISIBLE_PAUSES |
|
28 |
|
29 //Define this to get extra logging which may be useful in tracking down a fail |
|
30 //#define EXTRA_LOGGING |
|
31 |
|
32 CTScreenDeviceResSwitch::CTScreenDeviceResSwitch(CTestStep* aStep) : CTWsGraphicsBase(aStep) |
|
33 {} |
|
34 |
|
35 CTScreenDeviceResSwitch::~CTScreenDeviceResSwitch() |
|
36 {} |
|
37 |
|
38 void CTScreenDeviceResSwitch::ConstructL() |
|
39 { |
|
40 //The following is just another test... it doesn't leave any resources for use by the test class AFAICT... |
|
41 RWsSession aSession; |
|
42 CWsScreenDevice *device1; |
|
43 CWsScreenDevice *device2; |
|
44 CWsScreenDevice *device3; |
|
45 |
|
46 aSession.Connect(); |
|
47 device1=new(ELeave) CWsScreenDevice(aSession); |
|
48 device1->Construct(iTest->iScreenNumber); |
|
49 delete device1; |
|
50 device1=new(ELeave) CWsScreenDevice(aSession); |
|
51 device1->Construct(iTest->iScreenNumber); |
|
52 device2=new(ELeave) CWsScreenDevice(aSession); |
|
53 device2->Construct(iTest->iScreenNumber); |
|
54 device3=new(ELeave) CWsScreenDevice(aSession); |
|
55 device3->Construct(iTest->iScreenNumber); |
|
56 delete device3; |
|
57 CFbsFont *font; |
|
58 User::LeaveIfError(device1->GetNearestFontToDesignHeightInTwips((CFont *&)font,TFontSpec())); |
|
59 RWindowGroup group(aSession); |
|
60 group.Construct(777); |
|
61 group.SetOwningWindowGroup(TheClient->iGroup->GroupWin()->Identifier()); |
|
62 RWindow win(aSession); |
|
63 win.Construct(group,77); |
|
64 CWindowGc *gc=new(ELeave) CWindowGc(device1); |
|
65 gc->Construct(); |
|
66 gc->Activate(win); |
|
67 gc->UseFont(font); |
|
68 device1->ReleaseFont(font); |
|
69 aSession.Flush(); |
|
70 delete gc; |
|
71 win.Close(); |
|
72 group.Close(); |
|
73 delete device1; |
|
74 delete device2; |
|
75 aSession.Close(); |
|
76 } |
|
77 |
|
78 |
|
79 class CPrimaryColoursWin : public CTWin |
|
80 { |
|
81 public: |
|
82 enum //various size factors |
|
83 { |
|
84 kShrinkFactor=5, |
|
85 kPlotSize=16, |
|
86 kPlotMargin=4, |
|
87 kPlotWithMargin=kPlotSize+kPlotMargin, |
|
88 kPlotsAccross=3, |
|
89 kPlotsDown=1, |
|
90 kMinWidth=kPlotWithMargin*kPlotsAccross+kPlotMargin, |
|
91 kMinHeight=kPlotWithMargin*kPlotsDown+kPlotMargin, |
|
92 KNumChannels=3, |
|
93 KNumColours=256 |
|
94 }; |
|
95 |
|
96 CPrimaryColoursWin(); |
|
97 ~CPrimaryColoursWin(); |
|
98 //Virtual Function from CTBaseWin |
|
99 void Draw(); |
|
100 TInt CountUniquePlottedColours(); |
|
101 TInt iDrawn; |
|
102 TInt iNumColours; |
|
103 TBool iBadPixels[KNumChannels][KNumColours]; |
|
104 TBuf<0x40> iDisplayText; |
|
105 }; |
|
106 |
|
107 CPrimaryColoursWin::CPrimaryColoursWin() |
|
108 { |
|
109 for (TInt channelnum=0;channelnum<KNumChannels;channelnum++) |
|
110 { |
|
111 for (TInt colour=0;colour<KNumColours;colour++) |
|
112 { |
|
113 iBadPixels[channelnum][colour]=EFalse; |
|
114 } |
|
115 } |
|
116 |
|
117 iDisplayText.Zero(); |
|
118 iDisplayText.Format(_L("Test text")); |
|
119 } |
|
120 |
|
121 CPrimaryColoursWin::~CPrimaryColoursWin() |
|
122 { |
|
123 |
|
124 } |
|
125 |
|
126 void CPrimaryColoursWin::Draw() |
|
127 { |
|
128 iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
129 iGc->SetPenStyle(CGraphicsContext::ESolidPen); |
|
130 iGc->SetPenColor(TRgb(255, 255, 255)); |
|
131 iGc->SetBrushColor(TRgb(0, 0, 0)); |
|
132 TSize winSize = Size(); |
|
133 iGc->DrawRect(TRect(winSize)); |
|
134 |
|
135 CFont* font; |
|
136 TFontSpec fontSpec(_L(""), 300); |
|
137 TheClient->iScreen->GetNearestFontInTwips(font, fontSpec); |
|
138 |
|
139 if (font) |
|
140 { |
|
141 iGc->UseFont(font); |
|
142 TRect r(TPoint(0, 0), Size()); |
|
143 r.Shrink(kMinHeight, kMinHeight); |
|
144 iGc->DrawText(iDisplayText, r, font->AscentInPixels(), iGc->ECenter, 0); |
|
145 iGc->DiscardFont(); |
|
146 TheClient->iScreen->ReleaseFont(font); |
|
147 } |
|
148 |
|
149 iNumColours = 0; |
|
150 TPoint lhsAbs = Win()->AbsPosition(); |
|
151 |
|
152 for(TInt channelnum = 0, channelmul = 1, xoordinate = kPlotMargin; channelnum < KNumChannels; channelnum++, channelmul <<= 8, xoordinate += kPlotWithMargin) |
|
153 { |
|
154 TRgb lastPixel(255, 255, 255, 255); |
|
155 |
|
156 for(TInt colour = 0; colour < KNumColours; colour++) |
|
157 { |
|
158 if(!iBadPixels[channelnum][colour]) |
|
159 { |
|
160 iGc->SetPenColor(TRgb(colour * channelmul)); |
|
161 } |
|
162 else |
|
163 { |
|
164 iGc->SetPenColor(TRgb(255, 255, 255)); |
|
165 } |
|
166 |
|
167 TPoint point = TPoint(xoordinate + (colour & 0x0f), kPlotMargin + (colour >> 4)); |
|
168 iGc->Plot(point); |
|
169 } |
|
170 } |
|
171 |
|
172 iDrawn=ETrue; |
|
173 } |
|
174 |
|
175 TInt CPrimaryColoursWin::CountUniquePlottedColours() |
|
176 { |
|
177 iNumColours = 0; |
|
178 TPoint lhsAbs = Win()->AbsPosition(); |
|
179 |
|
180 for(TInt channelnum = 0, channelmul = 1, xoordinate = kPlotMargin; channelnum < 3; channelnum++, channelmul <<=8 , xoordinate += kPlotWithMargin) |
|
181 { |
|
182 TRgb lastPixel(255, 255, 255, 255); |
|
183 |
|
184 for(TInt colour = 0; colour < 256; colour++) |
|
185 { |
|
186 TRgb readPixel; |
|
187 TPoint point = TPoint(xoordinate + (colour & 0x0f), kPlotMargin + (colour >> 4)); |
|
188 TheClient->iScreen->GetPixel(readPixel, lhsAbs + point); |
|
189 |
|
190 if(readPixel != lastPixel) |
|
191 { |
|
192 lastPixel = readPixel; |
|
193 iNumColours++; |
|
194 iBadPixels[channelnum][colour] = EFalse; |
|
195 } |
|
196 else |
|
197 { |
|
198 iBadPixels[channelnum][colour] = ETrue; |
|
199 } |
|
200 } // for loop |
|
201 } // for loop |
|
202 |
|
203 return iNumColours; |
|
204 } |
|
205 |
|
206 /** |
|
207 Intended primarily as a visual check that the mode is displayed correctly, |
|
208 for each rotated mode. |
|
209 **/ |
|
210 void CTScreenDeviceResSwitch::DeviceResSwitchWithRotationsL() |
|
211 { |
|
212 CWsScreenDevice *screen=TheClient->iScreen; |
|
213 TInt originalScreenMode = screen->CurrentScreenMode(); |
|
214 TPixelsTwipsAndRotation originalModeSettings; |
|
215 screen->GetScreenModeSizeAndRotation(originalScreenMode,originalModeSettings); |
|
216 CArrayFixFlat<TInt> *rotations=new(ELeave) CArrayFixFlat<TInt>(1); |
|
217 CleanupStack::PushL(rotations); |
|
218 INFO_PRINTF2(_L("ScreenMode and rotation with colour depth. ScreenModes=%i"),TheClient->iScreenModes.Count()); |
|
219 |
|
220 for (TInt rr=0,maxrr=3;rr<maxrr;++rr) |
|
221 for (TInt ii=0,maxii=TheClient->iScreenModes.Count();ii<maxii;++ii) |
|
222 { |
|
223 TInt newMode=TheClient->iScreenModes[ii]; |
|
224 if ( screen->GetScreenModeOrigin(ii)!=TPoint(0,0) || screen->GetScreenModeScale(ii)!=TSize(1,1) ) |
|
225 { |
|
226 INFO_PRINTF2(_L("ScreenMode %i skipped: has scalind and/ or rotation"),ii); |
|
227 INFO_PRINTF1(_L("This scaling code is known to be broken if all modes do not support scaling")); |
|
228 INFO_PRINTF1(_L("See defect DEF111847 and break request 2226")); |
|
229 INFO_PRINTF5(_L("Origin: %i %i Scale %i %i"), |
|
230 screen->GetScreenModeOrigin(ii).iX,screen->GetScreenModeOrigin(ii).iY, |
|
231 screen->GetScreenModeScale(ii).iWidth,screen->GetScreenModeScale(ii).iHeight |
|
232 ); |
|
233 continue; |
|
234 } |
|
235 |
|
236 screen->SetAppScreenMode(newMode); |
|
237 screen->SetScreenMode(newMode); |
|
238 TInt currentScreenMode = screen->CurrentScreenMode(); |
|
239 TEST(currentScreenMode == newMode); |
|
240 |
|
241 User::LeaveIfError(screen->GetRotationsList(newMode,rotations)); |
|
242 INFO_PRINTF4(_L("ScreenMode and rotation with colour depth. Mode#%i=%i. Rotations=%i"),ii,newMode,rotations->Count()); |
|
243 TPixelsTwipsAndRotation currentModeSettings; |
|
244 screen->GetDefaultScreenSizeAndRotation(currentModeSettings); |
|
245 screen->SetScreenSizeAndRotation(currentModeSettings); |
|
246 for (TInt jj=0,maxjj=rotations->Count();jj<maxjj;jj++) |
|
247 { |
|
248 CFbsBitGc::TGraphicsOrientation newOrientation=STATIC_CAST(CFbsBitGc::TGraphicsOrientation,rotations[0][jj]); |
|
249 INFO_PRINTF3(_L("ScreenMode and rotation with colour depth. Rotation#%i=%i(0..3)"),jj,newOrientation); |
|
250 screen->SetCurrentRotations(newMode,newOrientation); |
|
251 TheClient->iWs.Flush(); |
|
252 |
|
253 TPixelsAndRotation modeSettings; |
|
254 TheClient->iScreen->GetDefaultScreenSizeAndRotation(modeSettings); |
|
255 TRect screenRect(TPoint(0,0),modeSettings.iPixelSize); |
|
256 |
|
257 //move the debug windows to inside the area |
|
258 //actually don't bother yet! |
|
259 if (screenRect.Width()>screenRect.Height()) |
|
260 { |
|
261 } |
|
262 else |
|
263 { |
|
264 } |
|
265 DeviceResSwitchL(); |
|
266 } |
|
267 screen->SetCurrentRotations(newMode,currentModeSettings.iRotation); |
|
268 screen->SetScreenSizeAndRotation(currentModeSettings); |
|
269 } |
|
270 |
|
271 CleanupStack::PopAndDestroy(); |
|
272 screen->SetScreenMode(originalScreenMode); |
|
273 screen->SetCurrentRotations(originalScreenMode,originalModeSettings.iRotation); |
|
274 screen->SetScreenSizeAndRotation(originalModeSettings); |
|
275 } |
|
276 |
|
277 /** |
|
278 Intended primarily as a visual check that the mode is displayed correctly, |
|
279 this code also verifies that the number of physical colours matches the reported mode. |
|
280 Note that although written to test GCE, this test is general and applies to all display versions. |
|
281 **/ |
|
282 void CTScreenDeviceResSwitch::DeviceResSwitchL() |
|
283 { |
|
284 INFO_PRINTF1(_L("DeviceResSwitchL: Entering function")); |
|
285 TInt error = KErrNone; |
|
286 TInt isTransparencySupportedResult = KErrNone; |
|
287 |
|
288 TRAP(error, isTransparencySupportedResult = IsTransparencySupportedL()); |
|
289 |
|
290 if(error != KErrNone) |
|
291 { |
|
292 INFO_PRINTF1(_L("DeviceResSwitchL: Transparency is not supported. Exits.")); |
|
293 return; |
|
294 } |
|
295 |
|
296 TRAP(error, CalculateDisplayPropertiesL()); |
|
297 |
|
298 if(error != KErrNone) |
|
299 { |
|
300 INFO_PRINTF1(_L("DeviceResSwitchL: Could not calculate display properties. Test not supported. Exits.")); |
|
301 return; |
|
302 } |
|
303 |
|
304 TDisplayMode startDisplayMode = TheClient->iScreen->DisplayMode(); |
|
305 TInt startColoursPixel = TDisplayModeUtils::NumDisplayModeColors(startDisplayMode); |
|
306 |
|
307 TPixelsAndRotation modeSettings; |
|
308 TheClient->iScreen->GetDefaultScreenSizeAndRotation(modeSettings); |
|
309 TRect r(TPoint(0, 0), modeSettings.iPixelSize); |
|
310 |
|
311 // Starts off full-screen. Only shrink it if it will still be large enough to run the test |
|
312 // It should be... the test only needs 60x20 pixels |
|
313 |
|
314 if(r.Width() > r.Height()) |
|
315 { |
|
316 if(r.Width() > (CPrimaryColoursWin::kMinWidth) * (CPrimaryColoursWin::kShrinkFactor-2) * 3 / (CPrimaryColoursWin::kShrinkFactor * 2)) |
|
317 { |
|
318 r.iTl.iX = r.iBr.iX / 3; |
|
319 } |
|
320 } |
|
321 else |
|
322 { |
|
323 if (r.Height() > (CPrimaryColoursWin::kMinHeight) * (CPrimaryColoursWin::kShrinkFactor - 2) * 3/ (CPrimaryColoursWin::kShrinkFactor * 2)) |
|
324 { |
|
325 r.iTl.iY = r.iBr.iY / 3; |
|
326 } |
|
327 } |
|
328 if(r.Width() > (CPrimaryColoursWin::kMinWidth) * (CPrimaryColoursWin::kShrinkFactor - 2) / CPrimaryColoursWin::kShrinkFactor) |
|
329 { |
|
330 if(r.Height() > (CPrimaryColoursWin::kMinHeight) * (CPrimaryColoursWin::kShrinkFactor - 2) / CPrimaryColoursWin::kShrinkFactor) |
|
331 { |
|
332 r.Shrink(r.Width() / CPrimaryColoursWin::kShrinkFactor, r.Height() / CPrimaryColoursWin::kShrinkFactor); |
|
333 } |
|
334 } |
|
335 |
|
336 for(TInt i = 0; i < EColorLast; i++) |
|
337 { |
|
338 TDisplayMode tryMode = TDisplayMode(i); |
|
339 TInt tryColoursPixel = NumDisplayModeColors(tryMode); |
|
340 |
|
341 INFO_PRINTF3(_L("DeviceResSwitchL: tryColoursPixel = %d, tryMode = %d"), tryColoursPixel, tryMode); |
|
342 |
|
343 if(TDisplayModeUtils::IsDisplayModeColor(tryMode) && startColoursPixel <= tryColoursPixel) |
|
344 { |
|
345 //Create a test window at this mode, and see if it changes the screen mode |
|
346 { // The braces define the lifetime of testWin. It must be destroyed before we check if mode changed back successfully. |
|
347 |
|
348 CPrimaryColoursWin* testWin1 = new (ELeave) CPrimaryColoursWin; |
|
349 CleanupStack::PushL(testWin1); |
|
350 |
|
351 TInt expectedColoursPerChannel = 1; |
|
352 TInt tt; |
|
353 |
|
354 testWin1->SetUpL(r.iTl, r.Size(), TheClient->iGroup, *TheClient->iGc, &tryMode); |
|
355 TheClient->iWs.Flush(); |
|
356 TDisplayMode newDisplayMode = TheClient->iScreen->DisplayMode(); |
|
357 |
|
358 TEST(TDisplayModeUtils::NumDisplayModeColors(newDisplayMode) >= tryColoursPixel); |
|
359 |
|
360 if(!(TDisplayModeUtils::NumDisplayModeColors(newDisplayMode) >= tryColoursPixel)) |
|
361 { |
|
362 ERR_PRINTF3(_L("testWin1: newDisplayMode = %d, tryColoursPixel = %d"), newDisplayMode, tryColoursPixel); |
|
363 } |
|
364 |
|
365 // Estimate the minimum number of shades of primary colours given the bits per pixel. |
|
366 // The maximum is twice this. Very appoximate but seems to work OK for 256 colours. Probably not good for grey modes. |
|
367 for(tt = tryColoursPixel; tt >= 8; tt >>= 3) |
|
368 { |
|
369 expectedColoursPerChannel <<= 1; |
|
370 } |
|
371 |
|
372 // Draw some test data on the test window. |
|
373 testWin1->DrawNow(); |
|
374 TheClient->iWs.Flush(); |
|
375 |
|
376 #ifdef VISIBLE_PAUSES |
|
377 TheClient->StdLogWindow().LogMessage(EFalse, _L("Mode: "), tryMode); |
|
378 User::After(1000000); |
|
379 #endif |
|
380 TInt numUniqueColours = testWin1->CountUniquePlottedColours(); |
|
381 INFO_PRINTF2(_L("testWin1: numUniqueColours = %d"), numUniqueColours); |
|
382 testWin1->DrawNow(); |
|
383 TheClient->StdLogWindow().LogMessage(EFalse, _L("Channel Colours: "), numUniqueColours); |
|
384 TheClient->iWs.Flush(); |
|
385 |
|
386 #ifdef VISIBLE_PAUSES |
|
387 User::After(1000000); |
|
388 #endif |
|
389 // Read it back and see if it has the expected quality |
|
390 TEST(numUniqueColours >= (expectedColoursPerChannel * 3)); |
|
391 |
|
392 if(!(numUniqueColours >= (expectedColoursPerChannel * 3))) |
|
393 { |
|
394 ERR_PRINTF3(_L("testWin1: numUniqueColours = %d, (expectedColoursPerChannel * 3) = %d"), numUniqueColours, (expectedColoursPerChannel * 3)); |
|
395 } |
|
396 |
|
397 /* |
|
398 * Defect 107176 was rejected. This test for transparency is therefore removed. |
|
399 * |
|
400 */ |
|
401 if (false) //newDisplayMode != startDisplayMode) // Hide the window under a startmode window and see if we switch back? |
|
402 if (isTransparencySupportedResult==KErrNone && newDisplayMode != startDisplayMode) // Hide the window under a startmode window and see if we switch back? |
|
403 /* |
|
404 * Defect 107176 was rejected. This test for transparency is therefore removed. |
|
405 * The crash demonstrated by this code is related to the inconsistant support for origin and scale |
|
406 * See defect DEF111847 and break request 2226 |
|
407 */ |
|
408 if (false) //newDisplayMode != startDisplayMode) // Hide the window under a startmode window and see if we switch back? |
|
409 { |
|
410 // Demonstration of defect 107176 |
|
411 // Create a translucent window which obscures the high-colour window |
|
412 // The existing code reduces the display colour depth because it thinks the obscured window is not visible any more |
|
413 // However, the obscured window is actually visible trough the transparency |
|
414 CPrimaryColoursWin* testWin2 = new (ELeave) CPrimaryColoursWin; |
|
415 CleanupStack::PushL(testWin2); |
|
416 |
|
417 testWin2->SetUpL(r.iTl - TPoint(20,20), r.Size() + TSize(40,40), TheClient->iGroup, *TheClient->iGc, &startDisplayMode, ETrue, 0x80); |
|
418 TheClient->iWs.Flush(); |
|
419 testWin2->DrawNow(); |
|
420 TheClient->iWs.Flush(); |
|
421 |
|
422 TDisplayMode newnewDisplayMode = TheClient->iScreen->DisplayMode(); |
|
423 TInt newNumUniqueColours = testWin2->CountUniquePlottedColours(); |
|
424 INFO_PRINTF2(_L("testWin2: newNumUniqueColours = %d"), newNumUniqueColours); |
|
425 |
|
426 TEST(newnewDisplayMode == newDisplayMode); |
|
427 |
|
428 if(!(newnewDisplayMode == newDisplayMode)) |
|
429 { |
|
430 ERR_PRINTF3(_L("testWin2: newnewDisplayMode = %d, newDisplayMode = %d"), newnewDisplayMode, newDisplayMode); |
|
431 } |
|
432 |
|
433 testWin2->DrawNow(); |
|
434 TheClient->iWs.Flush(); |
|
435 |
|
436 #ifdef VISIBLE_PAUSES |
|
437 User::After(1000000); |
|
438 #endif |
|
439 TheClient->iWs.Flush(); |
|
440 |
|
441 CleanupStack::PopAndDestroy(testWin2); |
|
442 testWin2 = NULL; |
|
443 } |
|
444 |
|
445 CleanupStack::PopAndDestroy(testWin1); |
|
446 testWin1 = NULL; |
|
447 } |
|
448 |
|
449 TDisplayMode afterDisplayMode = TheClient->iScreen->DisplayMode(); |
|
450 TEST(afterDisplayMode == startDisplayMode); |
|
451 |
|
452 if(afterDisplayMode != startDisplayMode) |
|
453 { |
|
454 ERR_PRINTF3(_L("DeviceResSwitchL: Original colour depth not restored. Was %i, now %i (TDisplayMode)"), startDisplayMode, afterDisplayMode); |
|
455 } |
|
456 |
|
457 #ifdef VISIBLE_PAUSES |
|
458 User::After(1000000); |
|
459 #endif |
|
460 } // context |
|
461 } // for loop ends |
|
462 |
|
463 INFO_PRINTF1(_L("DeviceResSwitchL: Returning from function")); |
|
464 } |
|
465 |
|
466 void CTScreenDeviceResSwitch::CalculateDisplayPropertiesL() |
|
467 { |
|
468 INFO_PRINTF1(_L("CalculateDisplayPropertiesL: Entering function")); |
|
469 |
|
470 TDisplayMode tryMode = (TDisplayMode) (EColorLast - 1); |
|
471 TPixelsAndRotation modeSettings; |
|
472 TheClient->iScreen->GetDefaultScreenSizeAndRotation(modeSettings); |
|
473 TRect r(TPoint(0, 0), modeSettings.iPixelSize); |
|
474 |
|
475 CPrimaryColoursWin* tempWin = new (ELeave) CPrimaryColoursWin; |
|
476 CleanupStack::PushL(tempWin); |
|
477 |
|
478 tempWin->SetUpL(r.iTl, r.Size(), TheClient->iGroup, *TheClient->iGc, &tryMode); |
|
479 TheClient->iWs.Flush(); |
|
480 |
|
481 iMaxDisplayMode = TheClient->iScreen->DisplayMode(); |
|
482 INFO_PRINTF2(_L("CalculateDisplayPropertiesL: iMaxDisplayMode %d"), iMaxDisplayMode); |
|
483 iMaxDisplayModeColors = TDisplayModeUtils::NumDisplayModeColors(iMaxDisplayMode); |
|
484 INFO_PRINTF2(_L("CalculateDisplayPropertiesL: iMaxDisplayModeColors %d"), iMaxDisplayModeColors); |
|
485 |
|
486 CleanupStack::PopAndDestroy(tempWin); |
|
487 INFO_PRINTF1(_L("CalculateDisplayPropertiesL: Returning from function")); |
|
488 } |
|
489 |
|
490 TInt CTScreenDeviceResSwitch::NumDisplayModeColors(TDisplayMode aDispMode) |
|
491 { |
|
492 TInt dispModeColors = TDisplayModeUtils::NumDisplayModeColors(aDispMode); |
|
493 |
|
494 if(dispModeColors > iMaxDisplayModeColors) |
|
495 { |
|
496 return iMaxDisplayModeColors; |
|
497 } |
|
498 |
|
499 return dispModeColors; |
|
500 } |
|
501 |
|
502 TInt CTScreenDeviceResSwitch::IsTransparencySupportedL() |
|
503 { |
|
504 INFO_PRINTF1(_L("IsTransparencySupportedL: Entering function")); |
|
505 // Creates a window and sets the transparency, if this feature |
|
506 // is not enabled, KErrNotSupported will be returned |
|
507 const TRgb KTransparencyColor(85,85,85); |
|
508 RWindow win(TheClient->iWs); |
|
509 win.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle); |
|
510 win.SetExtent(TPoint(0,0), TSize(50,50)); |
|
511 win.SetRequiredDisplayMode(EColor256); |
|
512 TInt ret = win.SetTransparencyFactor(KTransparencyColor); |
|
513 win.Close(); |
|
514 |
|
515 if(!ret) |
|
516 { |
|
517 INFO_PRINTF1(_L("IsTransparencySupportedL: Transparency is supported")); |
|
518 } |
|
519 else |
|
520 { |
|
521 INFO_PRINTF1(_L("IsTransparencySupportedL: Transparency is not supported")); |
|
522 } |
|
523 |
|
524 INFO_PRINTF1(_L("IsTransparencySupportedL: Returning from function")); |
|
525 return ret; |
|
526 } |
|
527 |
|
528 void CTScreenDeviceResSwitch::RunTestCaseL(TInt /*aCurTestCase*/) |
|
529 { |
|
530 ((CTScreenDeviceResSwitchStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); |
|
531 switch(++iTest->iState) |
|
532 { |
|
533 /** |
|
534 @SYMTestCaseID GRAPHICS-WSERV-0440 |
|
535 |
|
536 @SYMDEF DEF107176 |
|
537 |
|
538 @SYMTestCaseDesc Intended primarily as a visual check that the mode is displayed correctly. Checks correct display mode is set. |
|
539 The test also verifies that the number of physical colours matches the reported mode. |
|
540 Note that although written to test GCE, this test is general and applies to all display versions. |
|
541 |
|
542 @SYMTestPriority High |
|
543 |
|
544 @SYMTestStatus Implemented |
|
545 |
|
546 @SYMTestActions Creates a windows with a higher display mode. Then creates a transparent |
|
547 window with lower display mode that completely covers the first window. |
|
548 Checks the display mode is not changed to the lower diplay mode when |
|
549 the higher display mode window is visible through transparency. |
|
550 |
|
551 @SYMTestExpectedResults The higher display mode should still be set after the second window is drawn. |
|
552 */ |
|
553 case 1: |
|
554 ((CTScreenDeviceResSwitchStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0440")); |
|
555 iTest->LogSubTest(_L("Device resolution switching")); |
|
556 DeviceResSwitchL(); |
|
557 break; |
|
558 /** |
|
559 @SYMTestCaseID GRAPHICS-WSERV-0520 |
|
560 |
|
561 @SYMTestCaseDesc Test for device switching when mode increased. |
|
562 |
|
563 @SYMTestActions Windows are created in increasing modes and pixel colours written and read back. |
|
564 This code verifies that the mode change actually takes place. |
|
565 I am using this visually to verify that the new GCE is actually changing the mode. |
|
566 |
|
567 **/ |
|
568 case 2: |
|
569 ((CTScreenDeviceResSwitchStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0520")); |
|
570 iTest->LogSubTest(_L("More device resolution switching")); |
|
571 DeviceResSwitchWithRotationsL(); |
|
572 break; |
|
573 default: |
|
574 ((CTScreenDeviceResSwitchStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); |
|
575 ((CTScreenDeviceResSwitchStep*)iStep)->CloseTMSGraphicsStep(); |
|
576 TestComplete(); |
|
577 } |
|
578 ((CTScreenDeviceResSwitchStep*)iStep)->RecordTestResultL(); |
|
579 } |
|
580 |
|
581 __WS_CONSTRUCT_STEP__(ScreenDeviceResSwitch) |