|
1 // Copyright (c) 2006-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 // TMULSCREENS.CPP |
|
15 // Tests the newly API function added to RWindow which enables/disables |
|
16 // the usage of Off-Screen Bitmap (OSB). |
|
17 // The test will draw squares with random colours on screen filling the |
|
18 // whole drawable area. The drawing will start first with flickering screen |
|
19 // and will switch to flicker free in 4 seconds. |
|
20 // |
|
21 // |
|
22 |
|
23 /** |
|
24 @file |
|
25 @test |
|
26 @internalComponent - Internal Symbian test code |
|
27 */ |
|
28 |
|
29 #include "TFLICKERFREE.H" |
|
30 |
|
31 //=================================================== |
|
32 // CBGWin Declaration |
|
33 //=================================================== |
|
34 |
|
35 CBGWin::CBGWin(): CTWin() |
|
36 { |
|
37 } |
|
38 |
|
39 CBGWin::~CBGWin() |
|
40 { |
|
41 } |
|
42 |
|
43 void CBGWin::ConstructWin(TPoint aPos, TSize aSize, TBool aVisible) |
|
44 { |
|
45 iSize = aSize; |
|
46 SetUpL(aPos,iSize,TheClient->iGroup,*TheClient->iGc, aVisible); |
|
47 BaseWin()->SetRequiredDisplayMode(EColor256); |
|
48 } |
|
49 |
|
50 void CBGWin::Draw() |
|
51 { |
|
52 iGc->Clear(); |
|
53 iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
54 |
|
55 TUint propW = iSize.iWidth/32; |
|
56 TUint propH = iSize.iHeight/12; |
|
57 |
|
58 for(TInt i = 0; i < iSize.iWidth ; i+=propW) |
|
59 { |
|
60 for(TInt j = 0; j < iSize.iHeight; j+=propH) |
|
61 { |
|
62 iGc->SetBrushColor(TRgb( (TInt)(Math::Random()%255), (TInt)(Math::Random()%255), (TInt)(Math::Random()%255) )); |
|
63 iGc->DrawRect(TRect(i, j, i+propW-1, j+propH-1)); |
|
64 } |
|
65 } |
|
66 } |
|
67 |
|
68 void CBGWin::EnableOSBd(TBool aState) |
|
69 { |
|
70 iWin.EnableOSB(aState); |
|
71 } |
|
72 |
|
73 //=================================================== |
|
74 // CFlickerTest Declaration |
|
75 //=================================================== |
|
76 |
|
77 /* This function will be called periodically to draw the rects |
|
78 on screen.*/ |
|
79 void CTFlickerFree::TestFlickering() |
|
80 { |
|
81 for( int i = 0; i < 40; ++i) |
|
82 { |
|
83 // for the first 3 seconds draw with flicker |
|
84 if(i < 20 ) |
|
85 iBgWin->EnableOSBd(EFalse); |
|
86 // for the next 3 seconds draw with flicker free |
|
87 else if(i >=20 ) |
|
88 iBgWin->EnableOSBd(ETrue); |
|
89 |
|
90 iBgWin->DrawNow(); |
|
91 |
|
92 // this draws 20 frames per second for 4 seconds |
|
93 User::After(50000); |
|
94 } |
|
95 } |
|
96 |
|
97 CTFlickerFree::CTFlickerFree(CTestStep* aStep): |
|
98 CTWsGraphicsBase(aStep) |
|
99 { |
|
100 } |
|
101 |
|
102 CTFlickerFree::~CTFlickerFree() |
|
103 { |
|
104 delete iBgWin; |
|
105 } |
|
106 |
|
107 void CTFlickerFree::ConstructL() |
|
108 { |
|
109 // get the size of the current client to assign it to the background window |
|
110 TSize scrSize = TSize(TheClient->iScreen->SizeInPixels()); |
|
111 |
|
112 // construct the window in the background |
|
113 iBgWin = new (ELeave) CBGWin(); |
|
114 iBgWin->ConstructWin(TPoint(0,0), scrSize, ETrue); |
|
115 } |
|
116 |
|
117 /* Sets the windowing environment, constructs the CPeriod object and |
|
118 starts the CPeriod object.*/ |
|
119 void CTFlickerFree::RunTestCaseL(TInt aCurTestCase) |
|
120 { |
|
121 ((CTFlickerFreeStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); |
|
122 switch(aCurTestCase) |
|
123 { |
|
124 case 1: |
|
125 /** |
|
126 @SYMTestCaseID GRAPHICS-WSERV-0567 |
|
127 */ |
|
128 ((CTFlickerFreeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0567")); |
|
129 TestFlickering(); |
|
130 break; |
|
131 default: |
|
132 ((CTFlickerFreeStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); |
|
133 ((CTFlickerFreeStep*)iStep)->CloseTMSGraphicsStep(); |
|
134 TestComplete(); |
|
135 } |
|
136 ((CTFlickerFreeStep*)iStep)->RecordTestResultL(); |
|
137 } |
|
138 |
|
139 __WS_CONSTRUCT_STEP__(FlickerFree) |