103
|
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 |
// Test code for screen mode scaling CR
|
|
15 |
// Test code for the Scaling part of Change Request PHAR-5SJGAM
|
|
16 |
// ("Enable screen mode positioning and scaling").
|
|
17 |
// Tests screen scale being configurable for a screen mode -
|
|
18 |
// eg it is now possible to set in wsini.ini amount by which a screen
|
|
19 |
// mode's screen will be scaled when drawn on the physical screen.
|
|
20 |
//
|
|
21 |
//
|
|
22 |
|
|
23 |
/**
|
|
24 |
@file
|
|
25 |
@test
|
|
26 |
@internalComponent - Internal Symbian test code
|
|
27 |
*/
|
|
28 |
|
|
29 |
#include "TScreenModeScaling.h"
|
|
30 |
|
|
31 |
#define MY_TEST_BITMAP _L("Z:\\WSTEST\\MYTEST.MBM")
|
|
32 |
|
|
33 |
LOCAL_D TSize FullScreenModeSize;
|
|
34 |
LOCAL_D TInt Copy2ndHalfOfScreen;
|
|
35 |
|
|
36 |
void ClearBitmap(CFbsBitmap* aBitMap)
|
|
37 |
{
|
|
38 |
// clear the content of bitmap before it is used for copying
|
|
39 |
CFbsBitmapDevice *device=CFbsBitmapDevice::NewL(aBitMap);
|
|
40 |
CleanupStack::PushL(device);
|
|
41 |
CFbsBitGc *gc=NULL;
|
|
42 |
User::LeaveIfError(device->CreateContext(gc));
|
|
43 |
CleanupStack::PushL(gc);
|
|
44 |
gc->Clear();
|
|
45 |
CleanupStack::PopAndDestroy(2,device);
|
|
46 |
}
|
|
47 |
|
|
48 |
/*CBitMapWin*/
|
|
49 |
|
|
50 |
void CBitMapWin::Draw()
|
|
51 |
{
|
|
52 |
iGc->BitBlt(TPoint(),&iBackup->Bitmap());
|
|
53 |
}
|
|
54 |
|
|
55 |
/*CTestSpriteWin*/
|
|
56 |
|
|
57 |
CTestSpriteWin::~CTestSpriteWin()
|
|
58 |
{
|
|
59 |
}
|
|
60 |
|
|
61 |
void CTestSpriteWin::UpdateWin(TPoint aOrigin)
|
|
62 |
{
|
|
63 |
SetOrigin(aOrigin);
|
|
64 |
DrawNow();
|
|
65 |
}
|
|
66 |
|
|
67 |
void CTestSpriteWin::Draw()
|
|
68 |
{
|
|
69 |
iGc->BitBlt(iOrigin,&iSpriteBitmap);
|
|
70 |
}
|
|
71 |
|
|
72 |
/*CTScreenModeScaling*/
|
|
73 |
|
|
74 |
CTScreenModeScaling::CTScreenModeScaling(CTestStep* aStep) : CTWsGraphicsBase(aStep)
|
|
75 |
{
|
|
76 |
}
|
|
77 |
|
|
78 |
CTScreenModeScaling::~CTScreenModeScaling()
|
|
79 |
{
|
|
80 |
delete iTestWin;
|
|
81 |
delete iBlankWin;
|
|
82 |
delete iBackedUpWin;
|
|
83 |
delete iTestChildWin;
|
|
84 |
delete iScreenBitmap;
|
|
85 |
delete iBitmapWin;
|
|
86 |
delete iCheckWin;
|
|
87 |
delete iTransWin;
|
|
88 |
delete iBackgroundWin;
|
|
89 |
delete iCheckBitmap;
|
|
90 |
delete iTransparencyBitmap;
|
|
91 |
delete iBackgroundBitmap;
|
|
92 |
delete iForegroundBitmap;
|
|
93 |
}
|
|
94 |
|
|
95 |
void CTScreenModeScaling::ConstructL()
|
|
96 |
{
|
|
97 |
iDisplayMode=TheClient->iScreen->DisplayMode();
|
|
98 |
if (iDisplayMode<EColor256)
|
|
99 |
iDisplayMode=EColor256;
|
|
100 |
User::LeaveIfError(iSpriteBitmap.Load(MY_TEST_BITMAP,0));
|
|
101 |
|
|
102 |
TheClient->iScreen->SetAppScreenMode(TheClient->iScreenModes[0]);
|
|
103 |
FullScreenModeSize=TheClient->iScreen->SizeInPixels();
|
|
104 |
iBlankWin=new(ELeave) CTBlankWindow();
|
|
105 |
iBlankWin->ConstructL(*TheClient->iGroup);
|
|
106 |
User::LeaveIfError(iBlankWin->BaseWin()->SetRequiredDisplayMode(EColor256));
|
|
107 |
iBlankWin->SetExt(TPoint(),FullScreenModeSize);
|
|
108 |
iBlankWin->Activate();
|
|
109 |
|
|
110 |
iTestWin=new(ELeave) CBasicWin;
|
|
111 |
iTestWin->ConstructExtLD(*TheClient->iGroup,TPoint(),FullScreenModeSize);
|
|
112 |
User::LeaveIfError(iTestWin->BaseWin()->SetRequiredDisplayMode(EColor256));
|
|
113 |
iTestWin->AssignGC(*TheClient->iGc);
|
|
114 |
iTestWin->SetVisible(EFalse);
|
|
115 |
iTestWin->Activate();
|
|
116 |
iTestWin->BaseWin()->SetShadowDisabled(ETrue);
|
|
117 |
iTestWin->BaseWin()->SetShadowHeight(0);
|
|
118 |
|
|
119 |
iBackedUpWin=new(ELeave) CTBackedUpWin(iDisplayMode);
|
|
120 |
iBackedUpWin->ConstructExtLD(*iTestWin,TPoint(),FullScreenModeSize);
|
|
121 |
iBackedUpWin->SetVisible(EFalse);
|
|
122 |
iBackedUpWin->Activate();
|
|
123 |
|
|
124 |
iTestChildWin=new(ELeave) CTBlankWindow();
|
|
125 |
iTestChildWin->ConstructL(*iTestWin);
|
|
126 |
User::LeaveIfError(iTestChildWin->BaseWin()->SetRequiredDisplayMode(EColor256));
|
|
127 |
iTestChildWin->BaseWin()->SetShadowDisabled(ETrue);
|
|
128 |
iTestChildWin->SetColor(KRgbGreen);
|
|
129 |
iTestChildWin->BaseWin()->SetVisible(EFalse);
|
|
130 |
iTestChildWin->Activate();
|
|
131 |
|
|
132 |
iScreenBitmap=new(ELeave) CFbsBitmap();
|
|
133 |
User::LeaveIfError(iScreenBitmap->Create(TSize(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight),iDisplayMode));
|
|
134 |
|
|
135 |
iBitmapWin=new(ELeave) CBmpWin(*iScreenBitmap);
|
|
136 |
iBitmapWin->ConstructExtLD(*TheClient->iGroup,TPoint(),iScreenBitmap->SizeInPixels());
|
|
137 |
User::LeaveIfError(iBitmapWin->BaseWin()->SetRequiredDisplayMode(EColor256));
|
|
138 |
iBitmapWin->AssignGC(*TheClient->iGc);
|
|
139 |
iBitmapWin->Activate();
|
|
140 |
iBitmapWin->SetVisible(EFalse);
|
|
141 |
iBitmapWin->BaseWin()->SetShadowDisabled(ETrue);
|
|
142 |
iBitmapWin->BaseWin()->SetShadowHeight(0);
|
|
143 |
|
|
144 |
//.. Create all the bitmaps and transparent windows
|
|
145 |
iWinSize.SetSize(20,20);
|
|
146 |
iTransparencyBitmap=CBitmap::NewL(iWinSize,EGray256);
|
|
147 |
iBackgroundBitmap=CBitmap::NewL(iWinSize,iDisplayMode);
|
|
148 |
iForegroundBitmap=CBitmap::NewL(iWinSize,iDisplayMode);
|
|
149 |
|
|
150 |
CBitMapWin* backgroundWin=new(ELeave) CBitMapWin(iBackgroundBitmap);
|
|
151 |
backgroundWin->ConstructExtLD(*TheClient->iGroup,TPoint(),iWinSize);
|
|
152 |
iBackgroundWin=backgroundWin;
|
|
153 |
User::LeaveIfError(iBackgroundWin->BaseWin()->SetRequiredDisplayMode(EColor256));
|
|
154 |
iBackgroundWin->SetVisible(EFalse);
|
|
155 |
iBackgroundWin->BaseWin()->SetShadowDisabled(ETrue);
|
|
156 |
iBackgroundWin->BaseWin()->SetShadowHeight(0);
|
|
157 |
iBackgroundWin->AssignGC(*TheClient->iGc);
|
|
158 |
iBackgroundWin->Activate();
|
|
159 |
|
|
160 |
CBitMapWin* transWin=new(ELeave) CBitMapWin(iForegroundBitmap);
|
|
161 |
transWin->ConstructExtLD(*TheClient->iGroup,TPoint(),iWinSize);
|
|
162 |
iTransWin=transWin;
|
|
163 |
RWindowBase& transWinB=*iTransWin->BaseWin();
|
|
164 |
User::LeaveIfError(transWinB.SetRequiredDisplayMode(EColor256));
|
|
165 |
transWinB.SetShadowDisabled(ETrue);
|
|
166 |
transWinB.SetShadowHeight(0);
|
|
167 |
iTransWin->SetVisible(EFalse);
|
|
168 |
iTransWin->AssignGC(*TheClient->iGc);
|
|
169 |
iTransWin->Win()->SetTransparencyBitmap(iTransparencyBitmap->Bitmap());
|
|
170 |
iTransWin->Activate();
|
|
171 |
|
|
172 |
CTBackedUpWin* checkWin=new(ELeave) CTBackedUpWin(iDisplayMode);
|
|
173 |
checkWin->ConstructExtLD(*TheClient->iGroup,TPoint(iWinSize.iWidth+1,0),iWinSize);
|
|
174 |
iCheckWin=checkWin;
|
|
175 |
RBackedUpWindow& win=*iCheckWin->BackedUpWin();
|
|
176 |
win.SetShadowHeight(0);
|
|
177 |
iCheckWin->Activate();
|
|
178 |
win.MaintainBackup();
|
|
179 |
iCheckBitmap=CBitmap::NewL(win.BitmapHandle());
|
|
180 |
iCheckWin->BaseWin()->SetShadowDisabled(ETrue);
|
|
181 |
iCheckWin->BaseWin()->SetShadowHeight(0);
|
|
182 |
iCheckWin->BaseWin()->SetVisible(EFalse);
|
|
183 |
TheClient->Flush();
|
|
184 |
TheClient->WaitForRedrawsToFinish();
|
|
185 |
}
|
|
186 |
|
|
187 |
void CTScreenModeScaling::TestTopClientWindowPositionAPIs(TPoint aPos,RWindowBase* aWin)
|
|
188 |
{
|
|
189 |
TEST(aWin->AbsPosition()==aPos);
|
|
190 |
TEST(aWin->Position()==aPos);
|
|
191 |
TEST(aWin->InquireOffset(*TheClient->iGroup->GroupWin())==aPos);
|
|
192 |
}
|
|
193 |
|
|
194 |
void CTScreenModeScaling::TestChildWindowPositionAPIs(TPoint aPos,TPoint aParentPos,RWindowBase* aWin,RWindowBase* aParentWin)
|
|
195 |
{
|
|
196 |
TEST(aWin->AbsPosition()==aParentPos+aPos);
|
|
197 |
TEST(aWin->Position()==aPos);
|
|
198 |
TEST(aWin->InquireOffset(*TheClient->iGroup->GroupWin())==aParentPos+aPos);
|
|
199 |
TEST(aWin->InquireOffset(*aParentWin)==aPos);
|
|
200 |
}
|
|
201 |
|
|
202 |
void CTScreenModeScaling::TestRect()
|
|
203 |
{
|
|
204 |
// Here if the width or height of the screen cannot be divided by 2
|
|
205 |
// then make both the rect size same by reducing the first or second which ever is smaller
|
|
206 |
// and make sure that top left corner is not disturbed.
|
|
207 |
TRect rect1=TRect(PhysicalToLogical(TPoint()-iCurrentScreenModeOrigin,iCurrentScreenModeScale),
|
|
208 |
PhysicalToLogical(TPoint(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight)-iCurrentScreenModeOrigin,
|
|
209 |
iCurrentScreenModeScale)
|
|
210 |
);
|
|
211 |
TRect rect2=TRect(PhysicalToLogical(TPoint(FullScreenModeSize.iWidth/2,0)-iCurrentScreenModeOrigin,
|
|
212 |
iCurrentScreenModeScale),
|
|
213 |
PhysicalToLogical(FullScreenModeSize.AsPoint()-iCurrentScreenModeOrigin,
|
|
214 |
iCurrentScreenModeScale)
|
|
215 |
);
|
|
216 |
if ((Abs(rect1.iBr.iX-rect1.iTl.iX)>Abs(rect2.iBr.iX-rect2.iTl.iX)) || (Abs(rect1.iBr.iY-rect1.iTl.iY)>Abs(rect2.iBr.iY-rect2.iTl.iY)))
|
|
217 |
{
|
|
218 |
rect1.SetRect(rect1.iTl,rect2.Size());
|
|
219 |
}
|
|
220 |
if ((Abs(rect1.iBr.iX-rect1.iTl.iX)<Abs(rect2.iBr.iX-rect2.iTl.iX)) || (Abs(rect1.iBr.iY-rect1.iTl.iY)<Abs(rect2.iBr.iY-rect2.iTl.iY)))
|
|
221 |
{
|
|
222 |
rect2.SetRect(rect2.iTl,rect1.Size());
|
|
223 |
}
|
|
224 |
TBool retVal = TheClient->iScreen->RectCompare(rect1,rect2);
|
|
225 |
TEST(retVal);
|
|
226 |
if (!retVal)
|
|
227 |
INFO_PRINTF3(_L("TheClient->iScreen->RectCompare(rect1,rect2) return value - Expected: %d, Actual: %d"), ETrue, retVal);
|
|
228 |
}
|
|
229 |
|
|
230 |
void CTScreenModeScaling::CompareRegionsL(const TRegion &aRegion1,const TRegion &aRegion2)
|
|
231 |
{
|
|
232 |
RRegion tmp;
|
|
233 |
tmp.Copy(aRegion1);
|
|
234 |
tmp.SubRegion(aRegion2);
|
|
235 |
if (tmp.CheckError())
|
|
236 |
User::Leave(KErrNoMemory);
|
|
237 |
TBool retVal = tmp.IsEmpty();
|
|
238 |
TEST(retVal);
|
|
239 |
if (!retVal)
|
|
240 |
INFO_PRINTF3(_L("RRegion1.IsEmpty() return value - Expected: %d, Actual: %d"), ETrue, retVal);
|
|
241 |
tmp.Copy(aRegion2);
|
|
242 |
tmp.SubRegion(aRegion1);
|
|
243 |
if (tmp.CheckError())
|
|
244 |
User::Leave(KErrNoMemory);
|
|
245 |
retVal = tmp.IsEmpty();
|
|
246 |
TEST(retVal);
|
|
247 |
if (!retVal)
|
|
248 |
INFO_PRINTF3(_L("RRegion2.IsEmpty() return value - Expected: %d, Actual: %d"), ETrue, retVal);
|
|
249 |
|
|
250 |
tmp.Close();
|
|
251 |
}
|
|
252 |
|
|
253 |
void CTScreenModeScaling::SetUpSpriteLC(RWsSprite &aSprite, RWsSession &aSession, RWindowTreeNode &aWindow,TInt aFlags)
|
|
254 |
{
|
|
255 |
aSprite=RWsSprite(aSession);
|
|
256 |
User::LeaveIfError(aSprite.Construct(aWindow,TPoint(),aFlags));
|
|
257 |
CleanupClosePushL(aSprite);
|
|
258 |
TSpriteMember member;
|
|
259 |
iTest->SetUpMember(member);
|
|
260 |
member.iBitmap=&iSpriteBitmap;
|
|
261 |
User::LeaveIfError(aSprite.AppendMember(member));
|
|
262 |
User::LeaveIfError(aSprite.Activate());
|
|
263 |
}
|
|
264 |
|
|
265 |
void CTScreenModeScaling::TestGetInvalidRegionL(TRect& aRect)
|
|
266 |
{
|
|
267 |
RRegion testRegion;
|
|
268 |
RRegion invalid;
|
|
269 |
iTestWin->Invalidate(aRect);
|
|
270 |
testRegion.AddRect(aRect);
|
|
271 |
iTestWin->Win()->GetInvalidRegion(invalid);
|
|
272 |
CleanupClosePushL(testRegion);
|
|
273 |
CleanupClosePushL(invalid);
|
|
274 |
CompareRegionsL(testRegion, invalid);
|
|
275 |
CleanupStack::PopAndDestroy(2, &testRegion);
|
|
276 |
TheClient->WaitForRedrawsToFinish();
|
|
277 |
}
|
|
278 |
|
|
279 |
void CTScreenModeScaling::CopyAndCompareL()
|
|
280 |
{
|
|
281 |
TInt oldOrdinalPriority = TheClient->iGroup->GroupWin()->OrdinalPriority();
|
|
282 |
TInt oldOrdinalPosition = TheClient->iGroup->GroupWin()->OrdinalPosition();
|
|
283 |
// the following line makes sure that a console object hidden outside of
|
|
284 |
// screens range doesn't affect test results ocerlapping the bitmap window
|
|
285 |
TheClient->iGroup->GroupWin()->SetOrdinalPosition(0, 65535);
|
|
286 |
|
|
287 |
// clear the content of bitmap before it is used for copying
|
|
288 |
ClearBitmap(iScreenBitmap);
|
|
289 |
|
|
290 |
// Copy first half or second half of the screen to a bitmap then paste it to second or first half of the screen
|
|
291 |
TRect testWinRect(PhysicalToLogical(TPoint((Copy2ndHalfOfScreen ? FullScreenModeSize.iWidth/2 : 0),0)-iCurrentScreenModeOrigin,iCurrentScreenModeScale),
|
|
292 |
PhysicalToLogical(TPoint((Copy2ndHalfOfScreen ? FullScreenModeSize.iWidth : FullScreenModeSize.iWidth/2),FullScreenModeSize.iHeight)-iCurrentScreenModeOrigin,iCurrentScreenModeScale)
|
|
293 |
);
|
|
294 |
TheClient->iScreen->CopyScreenToBitmap(iScreenBitmap,testWinRect);
|
|
295 |
iBitmapWin->SetExt(PhysicalToLogical(TPoint((Copy2ndHalfOfScreen ? 0 : FullScreenModeSize.iWidth/2),0)-iCurrentScreenModeOrigin,iCurrentScreenModeScale),testWinRect.Size());
|
|
296 |
iBitmapWin->SetVisible(ETrue);
|
|
297 |
iBitmapWin->DrawNow();
|
|
298 |
TheClient->Flush();
|
|
299 |
TestRect();
|
|
300 |
iBitmapWin->SetVisible(EFalse);
|
|
301 |
iTestWin->SetVisible(EFalse);
|
|
302 |
TheClient->Flush();
|
|
303 |
|
|
304 |
TheClient->iGroup->GroupWin()->SetOrdinalPosition(oldOrdinalPosition, oldOrdinalPriority);
|
|
305 |
}
|
|
306 |
|
|
307 |
/**
|
|
308 |
@SYMTestCaseID GRAPHICS-WSERV-0093
|
|
309 |
|
|
310 |
@SYMDEF DEF081259, DEF111847
|
|
311 |
|
|
312 |
@SYMTestCaseDesc Window tests
|
|
313 |
REQUIREMENT: PREQ673 (Screen Scaling)
|
|
314 |
API: RWindowBase::InquireOffset(), RWindowBase::AbsPosition(),RWindowBase::Position()
|
|
315 |
|
|
316 |
@SYMTestPriority High
|
|
317 |
|
|
318 |
@SYMTestStatus Implemented
|
|
319 |
|
|
320 |
@SYMTestActions Loops through all the screen modes present in the wsini file, and then moves to the test screen
|
|
321 |
mode where it goes on changing the screen scale and origin. In each of the wsini screen modes and test
|
|
322 |
screen modes, it checks the test window's API's RWindowBase::InquireOffset(), RWindowBase::AbsPosition()
|
|
323 |
RWindowBase::Position(). Then it copies the content from either first or second half to second or first
|
|
324 |
half and compares both the regions so that its content are same.
|
|
325 |
Additionally, as part of defect fix DEF111847, this also loops through all the display modes, and if possible
|
|
326 |
tests each with the above described method. Previously, it use to only test Color256.
|
|
327 |
|
|
328 |
@SYMTestExpectedResults The content of both halves of the screen should match.
|
|
329 |
*/
|
|
330 |
void CTScreenModeScaling::WindowTestsL()
|
|
331 |
{
|
|
332 |
INFO_PRINTF1(_L("AUTO WindowTests : "));
|
|
333 |
|
|
334 |
TDisplayMode curDispMode; // Holds the current display mode being tested
|
|
335 |
|
|
336 |
for(curDispMode = EGray2; curDispMode < EColorLast; curDispMode = TDisplayMode(curDispMode+1))
|
|
337 |
{
|
|
338 |
if (curDispMode == ERgb)
|
|
339 |
{
|
|
340 |
continue;
|
|
341 |
}
|
|
342 |
CTClient* client=new(ELeave) CTClient();
|
|
343 |
CleanupStack::PushL(client);
|
|
344 |
client->SetScreenNumber(iTest->iScreenNumber);
|
|
345 |
client->ConstructL();
|
|
346 |
client->iGroup=new(ELeave) TestWindowGroup(client);
|
|
347 |
client->iGroup->ConstructL();
|
|
348 |
client->iGroup->WinTreeNode()->SetOrdinalPosition(1);
|
|
349 |
RBlankWindow testWindow(client->iWs);
|
|
350 |
User::LeaveIfError(testWindow.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle));
|
|
351 |
CleanupClosePushL(testWindow);
|
|
352 |
|
|
353 |
TInt setDispMode; // Holds the actual display mode that was set
|
|
354 |
setDispMode = testWindow.SetRequiredDisplayMode(curDispMode);
|
|
355 |
|
|
356 |
//Only do the tests if the requested mode was actually set
|
|
357 |
if(curDispMode == setDispMode)
|
|
358 |
{
|
|
359 |
//Create and show DisplayMode details message
|
|
360 |
_LIT(KModeDetails, "Display Mode: ");
|
|
361 |
TBuf<30> modeDetailsMessage(KModeDetails);
|
|
362 |
modeDetailsMessage.Append(DisplayModeAsString(curDispMode));
|
|
363 |
LOG_MESSAGE(modeDetailsMessage);
|
|
364 |
|
|
365 |
testWindow.Activate();
|
|
366 |
TheClient->iGroup->GroupWin()->EnableScreenChangeEvents();
|
|
367 |
TInt numOfModes=TheClient->iScreenModes.Count();
|
|
368 |
TInt ii;
|
|
369 |
for (ii=0; ii<numOfModes; ++ii)
|
|
370 |
{
|
|
371 |
INFO_PRINTF1(_L(" Start of Loop"));
|
|
372 |
iCurrentMode=TheClient->iScreenModes[ii];
|
|
373 |
TPixelsAndRotation pixelsAndRotation;
|
|
374 |
iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(iCurrentMode);
|
|
375 |
iCurrentScreenModeScale=TheClient->iScreen->GetScreenModeScale(iCurrentMode);
|
|
376 |
TheClient->iScreen->GetScreenModeSizeAndRotation(iCurrentMode,pixelsAndRotation);
|
|
377 |
if (pixelsAndRotation.iRotation==CFbsBitGc::EGraphicsOrientationNormal)
|
|
378 |
{
|
|
379 |
INFO_PRINTF1(_L(" Do Tests"));
|
|
380 |
TRAPD(ret,DoWindowTestsL());
|
|
381 |
TEST(ret==KErrNone);
|
|
382 |
if (ret!=KErrNone)
|
|
383 |
{
|
|
384 |
INFO_PRINTF3(_L("DoWindowTestsL() return value - Expected: %d, Actual: %d"), KErrNone, ret);
|
|
385 |
}
|
|
386 |
|
|
387 |
INFO_PRINTF1(_L(" Window Trees"));
|
|
388 |
client->iScreen->SetAppScreenMode(iCurrentMode);
|
|
389 |
client->Flush();
|
|
390 |
}
|
|
391 |
}
|
|
392 |
TestDifferentScales(numOfModes-1);
|
|
393 |
}
|
|
394 |
CleanupStack::PopAndDestroy(2,client);
|
|
395 |
}
|
|
396 |
}
|
|
397 |
|
|
398 |
void CTScreenModeScaling::TestDifferentScales(TInt aLastModeIdx)
|
|
399 |
{
|
|
400 |
if (aLastModeIdx<0) return;
|
|
401 |
TPixelsAndRotation pixelsAndRotation;
|
|
402 |
for (TInt modeCount=aLastModeIdx;modeCount>=0;--modeCount)
|
|
403 |
{
|
|
404 |
TheClient->iScreen->GetScreenModeSizeAndRotation(TheClient->iScreenModes[modeCount],pixelsAndRotation);
|
|
405 |
if (pixelsAndRotation.iRotation==CFbsBitGc::EGraphicsOrientationNormal)
|
|
406 |
break;
|
|
407 |
}
|
|
408 |
iCurrentMode=TheClient->iScreenModes[aLastModeIdx];
|
|
409 |
TheClient->iScreen->SetAppScreenMode(iCurrentMode);
|
|
410 |
TheClient->iScreen->SetScreenMode(iCurrentMode);
|
|
411 |
TSizeMode storeModeData=TheClient->iScreen->GetCurrentScreenModeAttributes();
|
|
412 |
TSizeMode testMode=storeModeData;
|
|
413 |
for (TInt xScale=1;xScale<4;++xScale)
|
|
414 |
{
|
|
415 |
for (TInt yScale=1;yScale<4;++yScale)
|
|
416 |
{
|
|
417 |
testMode.iScreenScale=TSize(xScale,yScale);
|
|
418 |
TestDifferentOrigin(testMode,TPoint(20,20));
|
|
419 |
TestDifferentOrigin(testMode,TPoint(20,30));
|
|
420 |
TestDifferentOrigin(testMode,TPoint(30,20));
|
|
421 |
TestDifferentOrigin(testMode,TPoint(FullScreenModeSize.iWidth/2+640/FullScreenModeSize.iWidth*10,60));
|
|
422 |
}
|
|
423 |
}
|
|
424 |
TheClient->iScreen->SetScreenMode(iCurrentMode);
|
|
425 |
TheClient->iScreen->SetCurrentScreenModeAttributes(storeModeData);
|
|
426 |
TInt defaultMode=TheClient->iScreenModes[0];
|
|
427 |
TheClient->iScreen->SetAppScreenMode(defaultMode);
|
|
428 |
TheClient->iScreen->SetScreenMode(defaultMode);
|
|
429 |
}
|
|
430 |
|
|
431 |
void CTScreenModeScaling::TestDifferentOrigin(TSizeMode &aMode,TPoint aOrigin)
|
|
432 |
{
|
|
433 |
TheClient->iScreen->SetScreenMode(iCurrentMode);//.. this is required because at the end of next screenmode test it will be set to zero screen mode
|
|
434 |
aMode.iOrigin=aOrigin;
|
|
435 |
TheClient->iScreen->SetCurrentScreenModeAttributes(aMode);
|
|
436 |
TheClient->iScreen->SetAppScreenMode(iCurrentMode);
|
|
437 |
TheClient->iScreen->SetScreenMode(iCurrentMode);
|
|
438 |
iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(iCurrentMode);
|
|
439 |
iCurrentScreenModeScale=TheClient->iScreen->GetScreenModeScale(iCurrentMode);
|
|
440 |
TRAPD(ret,DoWindowTestsL());
|
|
441 |
TEST(ret==KErrNone);
|
|
442 |
if (ret!=KErrNone)
|
|
443 |
INFO_PRINTF3(_L("DoWindowTestsL() return value - Expected: %d, Actual: %d"), KErrNone, ret);
|
|
444 |
}
|
|
445 |
|
|
446 |
void CTScreenModeScaling::DoWindowTestsL()
|
|
447 |
{
|
|
448 |
TheClient->iScreen->SetAppScreenMode(iCurrentMode);
|
|
449 |
TheClient->iScreen->SetScreenMode(iCurrentMode);
|
|
450 |
Copy2ndHalfOfScreen=(iCurrentScreenModeOrigin.iX>FullScreenModeSize.iWidth/2? 1 : 0);
|
|
451 |
TRect testWinRect(PhysicalToLogical(TPoint(),iCurrentScreenModeScale),
|
|
452 |
PhysicalToLogical(TPoint((Copy2ndHalfOfScreen ? FullScreenModeSize.iWidth
|
|
453 |
: FullScreenModeSize.iWidth/2),
|
|
454 |
FullScreenModeSize.iHeight)-iCurrentScreenModeOrigin,iCurrentScreenModeScale)
|
|
455 |
);
|
|
456 |
testWinRect.Shrink(10,10);
|
|
457 |
iTestWinSize=testWinRect.Size();
|
|
458 |
PositionTestL(testWinRect.iTl);
|
|
459 |
testWinRect.Shrink(10,10);
|
|
460 |
iTestWinSize=testWinRect.Size();
|
|
461 |
PositionTestL(testWinRect.iTl);
|
|
462 |
BackedUpChildWindowTestL(testWinRect.iTl);
|
|
463 |
GetInvalidRegionTestL(testWinRect.iTl);
|
|
464 |
//NextScreenModeTestL(testWinRect.iTl); //This test needs a lot more work ###
|
|
465 |
}
|
|
466 |
|
|
467 |
void CTScreenModeScaling::PositionTestL(TPoint aPostion)
|
|
468 |
{
|
|
469 |
iTestWin->SetExt(aPostion,iTestWinSize);
|
|
470 |
iTestWin->SetVisible(ETrue);
|
|
471 |
iTestWin->Invalidate();
|
|
472 |
TheClient->Flush();
|
|
473 |
TheClient->WaitForRedrawsToFinish();
|
|
474 |
TestTopClientWindowPositionAPIs(aPostion,iTestWin->BaseWin());
|
|
475 |
CopyAndCompareL();
|
|
476 |
}
|
|
477 |
|
|
478 |
void CTScreenModeScaling::BackedUpChildWindowTestL(TPoint aPostion)
|
|
479 |
{
|
|
480 |
iTestWin->SetVisible(ETrue);
|
|
481 |
TPoint backedUpWinPt=TPoint(iTestWinSize.iWidth/3,iTestWinSize.iHeight/4);
|
|
482 |
iBackedUpWin->SetExtL(backedUpWinPt,TSize(iTestWinSize.iWidth/6,iTestWinSize.iHeight/6));
|
|
483 |
iBackedUpWin->SetVisible(ETrue);
|
|
484 |
TestChildWindowPositionAPIs(backedUpWinPt,aPostion,iBackedUpWin->BaseWin(),iTestWin->BaseWin());
|
|
485 |
aPostion+=TPoint(10,10);
|
|
486 |
iTestWin->SetPos(aPostion);
|
|
487 |
TestTopClientWindowPositionAPIs(aPostion,iTestWin->BaseWin());
|
|
488 |
TestChildWindowPositionAPIs(backedUpWinPt,aPostion,iBackedUpWin->BaseWin(),iTestWin->BaseWin());
|
|
489 |
iTestWin->Invalidate();
|
|
490 |
TheClient->Flush();
|
|
491 |
TheClient->WaitForRedrawsToFinish();
|
|
492 |
TestTopClientWindowPositionAPIs(aPostion,iTestWin->BaseWin());
|
|
493 |
TestChildWindowPositionAPIs(backedUpWinPt,aPostion,iBackedUpWin->BaseWin(),iTestWin->BaseWin());
|
|
494 |
CopyAndCompareL();
|
|
495 |
iBackedUpWin->SetVisible(EFalse);
|
|
496 |
}
|
|
497 |
|
|
498 |
void CTScreenModeScaling::NextScreenModeTestL(TPoint aPos)
|
|
499 |
{
|
|
500 |
TInt numOfModes=TheClient->iScreenModes.Count();
|
|
501 |
TInt defaultMode=TheClient->iScreenModes[0];
|
|
502 |
TInt lastMode=TheClient->iScreenModes[numOfModes-1];
|
|
503 |
TInt mode=(iCurrentMode<lastMode? iCurrentMode:defaultMode);
|
|
504 |
// find current mode index
|
|
505 |
TInt ii;
|
|
506 |
TInt modeIdx=0;
|
|
507 |
for (ii=0; ii<numOfModes; ++ii)
|
|
508 |
{
|
|
509 |
if (mode==TheClient->iScreenModes[ii])
|
|
510 |
{
|
|
511 |
modeIdx=ii;
|
|
512 |
break;
|
|
513 |
}
|
|
514 |
}
|
|
515 |
TPoint screenModeOrigin(0,0);
|
|
516 |
TPixelsAndRotation pixelsAndRotation;
|
|
517 |
while (screenModeOrigin==TPoint()||(pixelsAndRotation.iRotation!=CFbsBitGc::EGraphicsOrientationNormal))
|
|
518 |
{
|
|
519 |
mode=(mode==lastMode? defaultMode : TheClient->iScreenModes[++modeIdx]);
|
|
520 |
if (mode==iCurrentMode)
|
|
521 |
{
|
|
522 |
return;
|
|
523 |
}
|
|
524 |
screenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(mode);
|
|
525 |
TheClient->iScreen->GetScreenModeSizeAndRotation(mode,pixelsAndRotation);
|
|
526 |
}
|
|
527 |
iTestWin->SetExt(aPos,iTestWinSize);
|
|
528 |
iTestWin->SetVisible(ETrue);
|
|
529 |
TheClient->Flush();
|
|
530 |
CBasicWin* basicWin=new(ELeave) CBasicWin;
|
|
531 |
CleanupStack::PushL(basicWin);
|
|
532 |
basicWin->ConstructExtLD(*iTestWin,TPoint(),TSize(iTestWinSize.iWidth/5,iTestWinSize.iHeight/5));
|
|
533 |
User::LeaveIfError(basicWin->BaseWin()->SetRequiredDisplayMode(EColor256));
|
|
534 |
basicWin->AssignGC(*TheClient->iGc);
|
|
535 |
basicWin->BaseWin()->SetShadowDisabled(ETrue);
|
|
536 |
basicWin->BaseWin()->SetShadowHeight(0);
|
|
537 |
basicWin->Activate();
|
|
538 |
TPoint pos(iTestWinSize.iWidth/3,iTestWinSize.iWidth/4);
|
|
539 |
basicWin->SetPos(pos);
|
|
540 |
TheClient->Flush();
|
|
541 |
TheClient->WaitForRedrawsToFinish();
|
|
542 |
TestChildWindowPositionAPIs(pos,aPos,basicWin->BaseWin(),iTestWin->BaseWin());
|
|
543 |
iCurrentScreenModeScale=TheClient->iScreen->GetScreenModeScale(mode);
|
|
544 |
iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(mode);
|
|
545 |
Copy2ndHalfOfScreen=(iCurrentScreenModeOrigin.iX>FullScreenModeSize.iWidth/2? 1 : 0);
|
|
546 |
TheClient->iScreen->SetAppScreenMode(mode);
|
|
547 |
TheClient->iScreen->SetScreenMode(mode);
|
|
548 |
iTestWin->SetVisible(ETrue);
|
|
549 |
CopyAndCompareL();
|
|
550 |
TheClient->iScreen->SetAppScreenMode(defaultMode);
|
|
551 |
TheClient->iScreen->SetScreenMode(defaultMode);
|
|
552 |
CleanupStack::PopAndDestroy(basicWin);
|
|
553 |
}
|
|
554 |
|
|
555 |
void CTScreenModeScaling::GetInvalidRegionTestL(TPoint aPos)
|
|
556 |
{
|
|
557 |
iTestWin->SetExt(aPos,iTestWinSize);
|
|
558 |
iTestWin->SetVisible(ETrue);
|
|
559 |
iTestChildWin->SetExt(TPoint(iTestWinSize.iWidth>>2,iTestWinSize.iHeight>>2),TSize(iTestWinSize.iWidth>>1,iTestWinSize.iHeight>>1));
|
|
560 |
iTestChildWin->SetVisible(ETrue);
|
|
561 |
TheClient->Flush(); // ensure testchildwin is on-screen
|
|
562 |
|
|
563 |
CArrayFixFlat<TRect> *rectList=new(ELeave) CArrayFixFlat<TRect>(3);
|
|
564 |
CleanupStack::PushL(rectList);
|
|
565 |
rectList->AppendL(TRect(1,1,5,2));
|
|
566 |
rectList->AppendL(TRect(iTest->StdTestWindowSize().iWidth>>1,iTest->StdTestWindowSize().iHeight>>1,iTest->StdTestWindowSize().iWidth,iTest->StdTestWindowSize().iHeight));
|
|
567 |
rectList->AppendL(TRect(2,0,4,5));
|
|
568 |
|
|
569 |
// set iTestWin to a 'clean state' before invalidating rects in the window
|
|
570 |
iTestWin->DrawNow();
|
|
571 |
TheClient->Flush();
|
|
572 |
|
|
573 |
// invalidate the various rectangles in iTestWin & then initiate a redraw of the window
|
|
574 |
RRegion invalidRegion;
|
|
575 |
RRegion region;
|
|
576 |
for (TInt index=0;index<rectList->Count();index++)
|
|
577 |
{
|
|
578 |
const TRect& myRect = (*rectList)[index];
|
|
579 |
iTestWin->Invalidate(myRect);
|
|
580 |
region.AddRect(myRect);
|
|
581 |
}
|
|
582 |
CleanupStack::PopAndDestroy(rectList);
|
|
583 |
CleanupClosePushL(invalidRegion);
|
|
584 |
CleanupClosePushL(region);
|
|
585 |
iTestWin->Win()->GetInvalidRegion(invalidRegion);
|
|
586 |
CompareRegionsL(region, invalidRegion);
|
|
587 |
CleanupStack::PopAndDestroy(2,&invalidRegion);
|
|
588 |
iTestChildWin->SetVisible(EFalse);
|
|
589 |
|
|
590 |
// ensure the test child win is removed
|
|
591 |
TheClient->Flush();
|
|
592 |
TheClient->WaitForRedrawsToFinish();
|
|
593 |
|
|
594 |
TRect rect1(iTestWinSize);
|
|
595 |
TestGetInvalidRegionL(rect1);
|
|
596 |
TInt width=iTestWinSize.iWidth;
|
|
597 |
TInt height=iTestWinSize.iHeight;
|
|
598 |
TRect rect2(TPoint(width/6,height/6),TSize(width/3,height/3));
|
|
599 |
TestGetInvalidRegionL(rect2);
|
|
600 |
|
|
601 |
// invalidate the entire test window
|
|
602 |
iTestWin->Invalidate();
|
|
603 |
TheClient->Flush();
|
|
604 |
|
|
605 |
iTestWin->SetPos(TPoint(15,15));
|
|
606 |
iTestWin->SetPos(TPoint());
|
|
607 |
iTestWin->SetPos(TPoint(-15,-15));
|
|
608 |
iTestWin->SetPos(aPos);
|
|
609 |
RRegion invalid;
|
|
610 |
RRegion testRegion(rect1);
|
|
611 |
CleanupClosePushL(invalid);
|
|
612 |
CleanupClosePushL(testRegion);
|
|
613 |
iTestWin->Win()->GetInvalidRegion(invalid);
|
|
614 |
TBool retVal = !invalid.CheckError();
|
|
615 |
TEST(retVal);
|
|
616 |
if (!retVal)
|
|
617 |
INFO_PRINTF3(_L("RRegion.CheckError() return value - Expected: %d, Actual: %d"), ETrue, retVal);
|
|
618 |
TEST(invalid.BoundingRect().iBr.iX<=iTestWinSize.iWidth);
|
|
619 |
if (invalid.BoundingRect().iBr.iX>iTestWinSize.iWidth)
|
|
620 |
INFO_PRINTF3(_L("invalid.BoundingRect().iBr.iX<=iTestWinSize.iWidth - Expected: %d, Actual: %d"), invalid.BoundingRect().iBr.iX, iTestWinSize.iWidth);
|
|
621 |
CompareRegionsL(testRegion,invalid);
|
|
622 |
CleanupStack::PopAndDestroy(2,&invalid);
|
|
623 |
|
|
624 |
// redraw the test window & confirm
|
|
625 |
iTestWin->DrawNow();
|
|
626 |
TheClient->Flush();
|
|
627 |
CopyAndCompareL();
|
|
628 |
}
|
|
629 |
|
|
630 |
/**
|
|
631 |
@SYMTestCaseID GRAPHICS-WSERV-0094
|
|
632 |
|
|
633 |
@SYMDEF DEF081259
|
|
634 |
|
|
635 |
@SYMTestCaseDesc SpriteTestL
|
|
636 |
REQUIREMENT: PREQ673 (Screen Scaling)
|
|
637 |
API: RWsSprite::SetPosition()
|
|
638 |
|
|
639 |
@SYMTestPriority High
|
|
640 |
|
|
641 |
@SYMTestStatus Implemented
|
|
642 |
|
|
643 |
@SYMTestActions In the same way as in window tests it shifts the screen modes.
|
|
644 |
In each screen modes it creates a sprite window and then it moves slightly
|
|
645 |
either side or bottom of the sprite, then it compares both the regions
|
|
646 |
to check whether content are same.
|
|
647 |
|
|
648 |
@SYMTestExpectedResults The content of both halves of the screen should match.
|
|
649 |
*/
|
|
650 |
void CTScreenModeScaling::SpriteTestL()
|
|
651 |
{
|
|
652 |
CTClient* client=new(ELeave) CTClient();
|
|
653 |
CleanupStack::PushL(client);
|
|
654 |
client->SetScreenNumber(iTest->iScreenNumber);
|
|
655 |
client->ConstructL();
|
|
656 |
client->iGroup=new(ELeave) TestWindowGroup(client);
|
|
657 |
client->iGroup->ConstructL();
|
|
658 |
client->iGroup->WinTreeNode()->SetOrdinalPosition(1);
|
|
659 |
RBlankWindow color256(client->iWs);
|
|
660 |
User::LeaveIfError(color256.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle));
|
|
661 |
CleanupClosePushL(color256);
|
|
662 |
color256.SetRequiredDisplayMode(EColor256);
|
|
663 |
color256.Activate();
|
|
664 |
TInt numOfModes=TheClient->iScreenModes.Count();
|
|
665 |
TInt flushState=TheClient->iWs.SetAutoFlush(ETrue);
|
|
666 |
TInt ii;
|
|
667 |
for (ii=0; ii<numOfModes; ++ii)
|
|
668 |
{
|
|
669 |
iCurrentMode=TheClient->iScreenModes[ii];
|
|
670 |
TPixelsAndRotation pixelsAndRotation;
|
|
671 |
iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(iCurrentMode);
|
|
672 |
iCurrentScreenModeScale=TheClient->iScreen->GetScreenModeScale(iCurrentMode);
|
|
673 |
TheClient->iScreen->GetScreenModeSizeAndRotation(iCurrentMode,pixelsAndRotation);
|
|
674 |
DoSpriteTestsL();
|
|
675 |
client->iScreen->SetAppScreenMode(iCurrentMode);
|
|
676 |
client->Flush();
|
|
677 |
}
|
|
678 |
iCurrentMode=TheClient->iScreenModes[numOfModes-1];
|
|
679 |
TheClient->iScreen->SetAppScreenMode(iCurrentMode);
|
|
680 |
TheClient->iScreen->SetScreenMode(iCurrentMode);
|
|
681 |
TSizeMode storeModeData=TheClient->iScreen->GetCurrentScreenModeAttributes();
|
|
682 |
TSizeMode testMode=storeModeData;
|
|
683 |
for (TInt xScale=1;xScale<4;xScale++)
|
|
684 |
{
|
|
685 |
for (TInt yScale=1;yScale<4;yScale++)
|
|
686 |
{
|
|
687 |
testMode.iScreenScale=TSize(xScale,yScale);
|
|
688 |
TestDifferentOriginAndScaleForSpritesL(testMode,TPoint(20,20));
|
|
689 |
TestDifferentOriginAndScaleForSpritesL(testMode,TPoint(20,30));
|
|
690 |
TestDifferentOriginAndScaleForSpritesL(testMode,TPoint(30,20));
|
|
691 |
TestDifferentOriginAndScaleForSpritesL(testMode,TPoint(FullScreenModeSize.iWidth/2+10,60));
|
|
692 |
}
|
|
693 |
}
|
|
694 |
TheClient->iScreen->SetScreenMode(iCurrentMode);
|
|
695 |
TheClient->iScreen->SetCurrentScreenModeAttributes(storeModeData);
|
|
696 |
TInt defaultMode=TheClient->iScreenModes[0];
|
|
697 |
TheClient->iScreen->SetAppScreenMode(defaultMode);
|
|
698 |
TheClient->iScreen->SetScreenMode(defaultMode);
|
|
699 |
CleanupStack::PopAndDestroy(2,client);
|
|
700 |
TheClient->iWs.SetAutoFlush(flushState);
|
|
701 |
}
|
|
702 |
|
|
703 |
void CTScreenModeScaling::TestDifferentOriginAndScaleForSpritesL(TSizeMode &aMode, TPoint aOrigin)
|
|
704 |
{
|
|
705 |
TheClient->iScreen->SetScreenMode(iCurrentMode);
|
|
706 |
aMode.iOrigin=aOrigin;
|
|
707 |
TheClient->iScreen->SetCurrentScreenModeAttributes(aMode);
|
|
708 |
iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(iCurrentMode);
|
|
709 |
iCurrentScreenModeScale=TheClient->iScreen->GetScreenModeScale(iCurrentMode);
|
|
710 |
DoSpriteTestsL();
|
|
711 |
}
|
|
712 |
|
|
713 |
void CTScreenModeScaling::DoSpriteTestsL()
|
|
714 |
{
|
|
715 |
TheClient->iScreen->SetAppScreenMode(iCurrentMode);
|
|
716 |
TheClient->iScreen->SetScreenMode(iCurrentMode);
|
|
717 |
TPixelsAndRotation pixelsAndRotation;
|
|
718 |
TheClient->iScreen->GetScreenModeSizeAndRotation(iCurrentMode,pixelsAndRotation);
|
|
719 |
RWsSprite sprite;
|
|
720 |
TSize spriteSize=iSpriteBitmap.SizeInPixels();
|
|
721 |
if (spriteSize.iWidth*iCurrentScreenModeScale.iWidth>FullScreenModeSize.iWidth/2)
|
|
722 |
spriteSize.iWidth=(FullScreenModeSize.iWidth/2-20)/iCurrentScreenModeScale.iWidth;
|
|
723 |
SetUpSpriteLC(sprite,TheClient->iWs,*iBlankWin->BaseWin());
|
|
724 |
sprite.SetPosition(TPoint());
|
|
725 |
CTestSpriteWin* spriteWin=new(ELeave) CTestSpriteWin(iSpriteBitmap);
|
|
726 |
CleanupStack::PushL(spriteWin);
|
|
727 |
spriteWin->ConstructExtLD(*TheClient->iGroup,PhysicalToLogical(TPoint()-iCurrentScreenModeOrigin,iCurrentScreenModeScale),spriteSize);
|
|
728 |
User::LeaveIfError(spriteWin->BaseWin()->SetRequiredDisplayMode(EColor256));
|
|
729 |
spriteWin->AssignGC(*TheClient->iGc);
|
|
730 |
spriteWin->SetVisible(ETrue);
|
|
731 |
spriteWin->Activate();
|
|
732 |
spriteWin->UpdateWin(TPoint());
|
|
733 |
spriteWin->BaseWin()->SetShadowDisabled(ETrue);
|
|
734 |
spriteWin->BaseWin()->SetShadowHeight(0);
|
|
735 |
TheClient->Flush();
|
|
736 |
TheClient->WaitForRedrawsToFinish();
|
|
737 |
TPoint spritePosition;
|
|
738 |
if (iCurrentScreenModeOrigin.iX<=spriteSize.iWidth || iCurrentScreenModeOrigin.iY<=spriteSize.iHeight)
|
|
739 |
{
|
|
740 |
if (pixelsAndRotation.iRotation==CFbsBitGc::EGraphicsOrientationNormal || pixelsAndRotation.iRotation==CFbsBitGc::EGraphicsOrientationRotated180)
|
|
741 |
spritePosition=TPoint(spriteSize.iWidth+1,0);
|
|
742 |
else
|
|
743 |
spritePosition=TPoint(0,spriteSize.iHeight+1);
|
|
744 |
}
|
|
745 |
sprite.SetPosition(spritePosition);
|
|
746 |
const TInt KAnimationGrace = 35000; //defined in server.cpp, but can be changed in wsini.ini
|
|
747 |
User::After(KAnimationGrace);
|
|
748 |
TBool retVal = TheClient->iScreen->RectCompare(TRect(PhysicalToLogical(TPoint()-iCurrentScreenModeOrigin,iCurrentScreenModeScale),spriteSize),TRect(spritePosition,spriteSize),CWsScreenDevice::EIncludeSprite);
|
|
749 |
TEST(retVal);
|
|
750 |
if (!retVal)
|
|
751 |
INFO_PRINTF3(_L("TheClient->iScreen->RectCompare(rect1,rect2) return value - Expected: %d, Actual: %d"), ETrue, retVal);
|
|
752 |
|
|
753 |
sprite.SetPosition(TPoint());
|
|
754 |
CleanupStack::PopAndDestroy(spriteWin);
|
|
755 |
CleanupStack::PopAndDestroy(&sprite);
|
|
756 |
}
|
|
757 |
|
|
758 |
/**
|
|
759 |
@SYMTestCaseID GRAPHICS-WSERV-0095
|
|
760 |
|
|
761 |
@SYMDEF DEF081259
|
|
762 |
|
|
763 |
@SYMTestCaseDesc Rotation Tests
|
|
764 |
REQUIREMENT: PREQ673 (Screen Scaling)
|
|
765 |
API: RWindowBase::InquireOffset(), RWindowBase::AbsPosition(),RWindowBase::Position()
|
|
766 |
|
|
767 |
@SYMTestPriority High
|
|
768 |
|
|
769 |
@SYMTestStatus Implemented
|
|
770 |
|
|
771 |
@SYMTestActions For each of the screen mode with all its rotation it checks whether the window
|
|
772 |
is correctly placed in particular screen mode. Then it creates a child window
|
|
773 |
and checks whether it s correctly placed.
|
|
774 |
|
|
775 |
@SYMTestExpectedResults Checks the windows are positioned correctly according to the origin,scale and rotation
|
|
776 |
of the new screen mode.
|
|
777 |
*/
|
|
778 |
void CTScreenModeScaling::RotationTestsL()
|
|
779 |
{
|
|
780 |
CTClient* client=new(ELeave) CTClient();
|
|
781 |
CleanupStack::PushL(client);
|
|
782 |
client->SetScreenNumber(iTest->iScreenNumber);
|
|
783 |
client->ConstructL();
|
|
784 |
client->iGroup=new(ELeave) TestWindowGroup(client);
|
|
785 |
client->iGroup->ConstructL();
|
|
786 |
client->iGroup->WinTreeNode()->SetOrdinalPosition(1);
|
|
787 |
RBlankWindow color256(client->iWs);
|
|
788 |
User::LeaveIfError(color256.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle));
|
|
789 |
CleanupClosePushL(color256);
|
|
790 |
color256.SetRequiredDisplayMode(EColor256);
|
|
791 |
color256.Activate();
|
|
792 |
TInt oldCurrentMode=0;
|
|
793 |
TInt ii;
|
|
794 |
//TInt screenMode=TheClient->iScreen->CurrentScreenMode();
|
|
795 |
for (ii=0;ii<TheClient->iScreenModes.Count();)
|
|
796 |
{
|
|
797 |
iCurrentMode=TheClient->iScreenModes[ii];
|
|
798 |
if (iCurrentMode!=oldCurrentMode)
|
|
799 |
{
|
|
800 |
client->iScreen->SetAppScreenMode(iCurrentMode);
|
|
801 |
TheClient->iScreen->SetScreenMode(iCurrentMode);
|
|
802 |
TheClient->iScreen->SetAppScreenMode(iCurrentMode);
|
|
803 |
}
|
|
804 |
TPixelsAndRotation pixelsAndRotation;
|
|
805 |
TheClient->iScreen->GetDefaultScreenSizeAndRotation(pixelsAndRotation);
|
|
806 |
oldCurrentMode=iCurrentMode;
|
|
807 |
CArrayFixFlat<TInt>* rotations=new(ELeave) CArrayFixFlat<TInt>(1);
|
|
808 |
CleanupStack::PushL(rotations);
|
|
809 |
User::LeaveIfError(TheClient->iScreen->GetRotationsList(iCurrentMode,rotations));
|
|
810 |
TInt count=rotations->Count();
|
|
811 |
TInt jj=0;
|
|
812 |
if (count>1)
|
|
813 |
{
|
|
814 |
for (jj=0;jj<count;)
|
|
815 |
{
|
|
816 |
if ((*rotations)[jj++]==pixelsAndRotation.iRotation)
|
|
817 |
{
|
|
818 |
break;
|
|
819 |
}
|
|
820 |
}
|
|
821 |
if (jj==count)
|
|
822 |
{
|
|
823 |
jj=0;
|
|
824 |
}
|
|
825 |
}
|
|
826 |
if (jj==0)
|
|
827 |
{
|
|
828 |
ii++;
|
|
829 |
}
|
|
830 |
TInt currentRotation=(*rotations)[jj];
|
|
831 |
TheClient->iScreen->SetCurrentRotations(oldCurrentMode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,currentRotation));
|
|
832 |
CleanupStack::PopAndDestroy(rotations);
|
|
833 |
iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(oldCurrentMode);
|
|
834 |
iCurrentScreenModeScale=TheClient->iScreen->GetScreenModeScale(oldCurrentMode);
|
|
835 |
TRect testWinRect(PhysicalToLogical(TPoint(),iCurrentScreenModeScale),
|
|
836 |
PhysicalToLogical(TPoint((Copy2ndHalfOfScreen ? FullScreenModeSize.iWidth : FullScreenModeSize.iWidth/2),FullScreenModeSize.iHeight)-iCurrentScreenModeOrigin,iCurrentScreenModeScale)
|
|
837 |
);
|
|
838 |
testWinRect.Shrink(10,10);
|
|
839 |
iTestWin->SetExtL(testWinRect.iTl,testWinRect.Size());
|
|
840 |
iTestWin->Invalidate();
|
|
841 |
iTestWin->SetVisible(ETrue);
|
|
842 |
TheClient->Flush();
|
|
843 |
TheClient->WaitForRedrawsToFinish();
|
|
844 |
TestTopClientWindowPositionAPIs(testWinRect.iTl,iTestWin->BaseWin());
|
|
845 |
TPoint backedUpWinPt=TPoint(testWinRect.Width()/3,testWinRect.Height()/4);
|
|
846 |
iBackedUpWin->SetVisible(ETrue);
|
|
847 |
iBackedUpWin->SetExtL(backedUpWinPt,TSize(testWinRect.Width()/6,testWinRect.Height()/6));
|
|
848 |
TestChildWindowPositionAPIs(backedUpWinPt,testWinRect.iTl,iBackedUpWin->BaseWin(),iTestWin->BaseWin());
|
|
849 |
iTestWin->SetVisible(EFalse);
|
|
850 |
iBackedUpWin->SetVisible(EFalse);
|
|
851 |
}
|
|
852 |
CleanupStack::PopAndDestroy(2,client);
|
|
853 |
}
|
|
854 |
|
|
855 |
void CTScreenModeScaling::DrawTransparentWindows()
|
|
856 |
{
|
|
857 |
//.. First Draw on Backgroundbitmap
|
|
858 |
iBackgroundBitmap->Gc().SetBrushColor(TRgb(255,0,255));
|
|
859 |
iBackgroundBitmap->Gc().SetBrushStyle(CGraphicsContext::ESolidBrush);
|
|
860 |
iBackgroundBitmap->Gc().SetPenStyle(CGraphicsContext::ENullPen);
|
|
861 |
iBackgroundBitmap->Gc().DrawRect(iWinSize);
|
|
862 |
|
|
863 |
//.. Invalidate the background bitmap and do bitBlt to iCheckBitmap also
|
|
864 |
iBackgroundWin->BaseWin()->SetVisible(ETrue);
|
|
865 |
iBackgroundWin->DrawNow();
|
|
866 |
|
|
867 |
//.. Copy to checkbitmap
|
|
868 |
iCheckBitmap->Gc().SetFaded(EFalse);
|
|
869 |
iCheckBitmap->Gc().BitBlt(TPoint(),&iBackgroundBitmap->Bitmap());
|
|
870 |
|
|
871 |
//.. Set the grade of transperency
|
|
872 |
iTransparencyBitmap->Gc().SetBrushColor(TRgb::Gray256(128));
|
|
873 |
iTransparencyBitmap->Gc().SetBrushStyle(CGraphicsContext::ESolidBrush);
|
|
874 |
iTransparencyBitmap->Gc().SetPenStyle(CGraphicsContext::ENullPen);
|
|
875 |
iTransparencyBitmap->Gc().DrawRect(iWinSize);
|
|
876 |
|
|
877 |
//.. Then draw to the fore ground bitmap and invalidate the second window
|
|
878 |
iForegroundBitmap->Gc().Reset();
|
|
879 |
iForegroundBitmap->Gc().SetPenStyle(CGraphicsContext::ESolidPen);
|
|
880 |
iForegroundBitmap->Gc().SetPenSize(TSize(1,1));
|
|
881 |
iForegroundBitmap->Gc().SetPenColor(TRgb(0,0,0));
|
|
882 |
iForegroundBitmap->Gc().DrawLine(TPoint(0,0),TPoint(iWinSize.iWidth,iWinSize.iHeight));
|
|
883 |
iForegroundBitmap->Gc().DrawLine(TPoint(iWinSize.iWidth,0),TPoint(0,iWinSize.iHeight));
|
|
884 |
iTransWin->BaseWin()->SetVisible(ETrue);
|
|
885 |
iTransWin->Invalidate();
|
|
886 |
iTransWin->DrawNow();
|
|
887 |
|
|
888 |
iCheckBitmap->Gc().AlphaBlendBitmaps(TPoint(0,0),&iForegroundBitmap->Bitmap(),&iCheckBitmap->Bitmap()
|
|
889 |
,TRect(iWinSize),TPoint(0,0),&iTransparencyBitmap->Bitmap(),TPoint(0,0));
|
|
890 |
iCheckWin->BaseWin()->SetVisible(ETrue);
|
|
891 |
iCheckWin->BackedUpWin()->UpdateScreen();
|
|
892 |
TheClient->Flush();
|
|
893 |
TheClient->WaitForRedrawsToFinish();
|
|
894 |
CheckRect(iTransWin,iCheckWin,TRect(iWinSize),_L("DrawTransparentWindows() CheckRect failed"));
|
|
895 |
}
|
|
896 |
|
|
897 |
// !!! THE COMMENT BELOW IS DISABLED BECAUSE TransparentTests() METHOD IS NOT USED !!!
|
|
898 |
//**
|
|
899 |
//@SYMTestCaseID GRAPHICS-WSERV-0096
|
|
900 |
//
|
|
901 |
//@SYMDEF DEF081259
|
|
902 |
//
|
|
903 |
//@SYMTestCaseDesc TransparentTests
|
|
904 |
// REQUIREMENT: PREQ673 (Screen Scaling)
|
|
905 |
// API: CWindowGc::AlphaBlendBitmaps()
|
|
906 |
//
|
|
907 |
//@SYMTestPriority High
|
|
908 |
//
|
|
909 |
//@SYMTestStatus Implemented
|
|
910 |
//
|
|
911 |
//@SYMTestActions The main logic behind this test is to copy the content of the background window
|
|
912 |
// bitmap to checkwindow bitmap and then use the foreground window bitmap and transparency bitmap
|
|
913 |
// with the function AlphaBlendBitmaps() to get the content present on the combination of
|
|
914 |
// foreground(transparent) window and background window. Then compare both the regions of the
|
|
915 |
// window to check whether the content is same.
|
|
916 |
//
|
|
917 |
//@SYMTestExpectedResults The content of both halves of the screen should match.
|
|
918 |
//*/
|
|
919 |
void CTScreenModeScaling::TransparentTestsL()
|
|
920 |
{
|
|
921 |
TInt flushState=TheClient->iWs.SetAutoFlush(ETrue);
|
|
922 |
TInt defaultMode=TheClient->iScreenModes[0];
|
|
923 |
TheClient->iScreen->SetAppScreenMode(defaultMode);
|
|
924 |
TheClient->iScreen->SetScreenMode(defaultMode);
|
|
925 |
CTClient* client=new(ELeave) CTClient();
|
|
926 |
CleanupStack::PushL(client);
|
|
927 |
client->SetScreenNumber(iTest->iScreenNumber);
|
|
928 |
client->ConstructL();
|
|
929 |
client->iGroup=new(ELeave) TestWindowGroup(client);
|
|
930 |
client->iGroup->ConstructL();
|
|
931 |
client->iGroup->WinTreeNode()->SetOrdinalPosition(1);
|
|
932 |
RBlankWindow color256(client->iWs);
|
|
933 |
User::LeaveIfError(color256.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle));
|
|
934 |
CleanupClosePushL(color256);
|
|
935 |
color256.SetRequiredDisplayMode(EColor256);
|
|
936 |
color256.Activate();
|
|
937 |
client->Flush();
|
|
938 |
DrawTransparentWindows();
|
|
939 |
iCurrentMode=TheClient->iScreenModes[TheClient->iScreenModes.Count()-1];
|
|
940 |
TheClient->iScreen->SetAppScreenMode(iCurrentMode);
|
|
941 |
TheClient->iScreen->SetScreenMode(iCurrentMode);
|
|
942 |
TSizeMode storeModeData=TheClient->iScreen->GetCurrentScreenModeAttributes();
|
|
943 |
TSizeMode testMode=storeModeData;
|
|
944 |
for (TInt xScale=1;xScale<4;xScale++)
|
|
945 |
{
|
|
946 |
for (TInt yScale=1;yScale<4;yScale++)
|
|
947 |
{
|
|
948 |
testMode.iScreenScale=TSize(xScale,yScale);
|
|
949 |
TestDifferentOriginAndScaleForTranspWin(testMode,TPoint(20,20));
|
|
950 |
TestDifferentOriginAndScaleForTranspWin(testMode,TPoint(20,30));
|
|
951 |
TestDifferentOriginAndScaleForTranspWin(testMode,TPoint(30,20));
|
|
952 |
TestDifferentOriginAndScaleForTranspWin(testMode,TPoint(FullScreenModeSize.iWidth/2+1,60));
|
|
953 |
}
|
|
954 |
}
|
|
955 |
TheClient->iScreen->SetScreenMode(iCurrentMode);
|
|
956 |
TheClient->iScreen->SetCurrentScreenModeAttributes(storeModeData);
|
|
957 |
client->iScreen->SetAppScreenMode(iCurrentMode);
|
|
958 |
client->Flush();
|
|
959 |
TheClient->iScreen->SetAppScreenMode(defaultMode);
|
|
960 |
TheClient->iScreen->SetScreenMode(defaultMode);
|
|
961 |
TheClient->iWs.SetAutoFlush(flushState);
|
|
962 |
CleanupStack::PopAndDestroy(2,client);
|
|
963 |
}
|
|
964 |
|
|
965 |
void CTScreenModeScaling::TestDifferentOriginAndScaleForTranspWin(TSizeMode &aMode,TPoint aOrigin)
|
|
966 |
{
|
|
967 |
TheClient->iScreen->SetScreenMode(iCurrentMode);
|
|
968 |
aMode.iOrigin=aOrigin;
|
|
969 |
TheClient->iScreen->SetCurrentScreenModeAttributes(aMode);
|
|
970 |
TheClient->iScreen->SetAppScreenMode(iCurrentMode);
|
|
971 |
TheClient->iScreen->SetScreenMode(iCurrentMode);
|
|
972 |
TRAPD(ret,DrawTransparentWindows());
|
|
973 |
TEST(ret==KErrNone);
|
|
974 |
if (ret!=KErrNone)
|
|
975 |
INFO_PRINTF3(_L("DrawTransparentWindows() return value - Expected: %d, Actual: %d"), KErrNone, ret);
|
|
976 |
|
|
977 |
}
|
|
978 |
|
|
979 |
/**
|
|
980 |
@SYMTestCaseID GRAPHICS-WSERV-0097
|
|
981 |
|
|
982 |
@SYMDEF DEF081259
|
|
983 |
|
|
984 |
@SYMTestCaseDesc AppScreenModeTest
|
|
985 |
REQUIREMENT: PREQ673 (Screen Scaling)
|
|
986 |
API: CWsScreenDevice::SetAppScreenMode()
|
|
987 |
|
|
988 |
@SYMTestPriority High
|
|
989 |
|
|
990 |
@SYMTestStatus Implemented
|
|
991 |
|
|
992 |
@SYMTestActions Enable the visibility of Test window, Call SetAppScreenMode() API with different
|
|
993 |
screen mode. Check the variable which is set in its draw function.
|
|
994 |
|
|
995 |
@SYMTestExpectedResults The variable should not be set when the application screen mode is different
|
|
996 |
then current screen mode.
|
|
997 |
*/
|
|
998 |
void CTScreenModeScaling::AppScreenModeTestL()
|
|
999 |
{
|
|
1000 |
TheClient->iScreen->SetAppScreenMode(0);
|
|
1001 |
TheClient->iScreen->SetScreenMode(0);
|
|
1002 |
iTestWin->iDrawn=EFalse;
|
|
1003 |
iTestWin->SetExtL(TPoint(),TSize(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight));
|
|
1004 |
iTestWin->SetVisible(ETrue);
|
|
1005 |
TheClient->Flush();
|
|
1006 |
TheClient->WaitForRedrawsToFinish();
|
|
1007 |
TEST(iTestWin->iDrawn);
|
|
1008 |
if (!iTestWin->iDrawn)
|
|
1009 |
INFO_PRINTF3(_L("iTestWin->iDrawn - Expected: %d, Actual: %d"), ETrue, iTestWin->iDrawn);
|
|
1010 |
|
|
1011 |
iTestWin->iDrawn=EFalse;
|
|
1012 |
TheClient->iScreen->SetAppScreenMode(2);
|
|
1013 |
TheClient->iScreen->SetScreenMode(0);
|
|
1014 |
iTestWin->Invalidate();
|
|
1015 |
TheClient->Flush();
|
|
1016 |
TEST(!iTestWin->iDrawn);
|
|
1017 |
if (iTestWin->iDrawn)
|
|
1018 |
INFO_PRINTF3(_L("iTestWin->iDrawn - Expected: %d, Actual: %d"), EFalse, iTestWin->iDrawn);
|
|
1019 |
|
|
1020 |
TheClient->iScreen->SetAppScreenMode(0);
|
|
1021 |
TheClient->Flush();
|
|
1022 |
TheClient->WaitForRedrawsToFinish();
|
|
1023 |
TEST(iTestWin->iDrawn);
|
|
1024 |
if (!iTestWin->iDrawn)
|
|
1025 |
INFO_PRINTF3(_L("iTestWin->iDrawn - Expected: %d, Actual: %d"), ETrue, iTestWin->iDrawn);
|
|
1026 |
|
|
1027 |
iTestWin->iDrawn=EFalse;
|
|
1028 |
TheClient->iScreen->SetScreenMode(1);
|
|
1029 |
iTestWin->Invalidate();
|
|
1030 |
TheClient->Flush();
|
|
1031 |
TEST(!iTestWin->iDrawn);
|
|
1032 |
if (iTestWin->iDrawn)
|
|
1033 |
INFO_PRINTF3(_L("iTestWin->iDrawn - Expected: %d, Actual: %d"), EFalse, iTestWin->iDrawn);
|
|
1034 |
|
|
1035 |
iTestWin->SetVisible(EFalse);
|
|
1036 |
TheClient->iScreen->SetAppScreenMode(0);
|
|
1037 |
TheClient->iScreen->SetScreenMode(0);
|
|
1038 |
}
|
|
1039 |
|
|
1040 |
void CTScreenModeScaling::RunTestCaseL(TInt /*aCurTestCase*/)
|
|
1041 |
{
|
|
1042 |
_LIT(KWindowTests,"Window Tests");
|
|
1043 |
_LIT(KSpriteTest,"Sprite Test");
|
|
1044 |
_LIT(KRotationTests,"Rotation Tests");
|
|
1045 |
_LIT(KTransparentTests,"Transparent Tests");
|
|
1046 |
_LIT(KAppScreenModeTest,"AppScreenMode Test");
|
|
1047 |
_LIT(KScalling,"Scaling not Supported");
|
|
1048 |
_LIT(KModes,"Only one Screen Size Mode");
|
|
1049 |
|
|
1050 |
((CTScreenModeScalingStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
|
|
1051 |
switch(++iTest->iState)
|
|
1052 |
{
|
|
1053 |
case 1:
|
|
1054 |
{
|
|
1055 |
((CTScreenModeScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0097"));
|
|
1056 |
TInt numScrModes=TheClient->iScreen->NumScreenModes();
|
|
1057 |
if (numScrModes<2 || !CheckScalingSupportedOrNot())
|
|
1058 |
{
|
|
1059 |
if (numScrModes<2)
|
|
1060 |
LOG_MESSAGE(KModes);
|
|
1061 |
else
|
|
1062 |
LOG_MESSAGE(KScalling);
|
|
1063 |
TestComplete();
|
|
1064 |
return;
|
|
1065 |
}
|
|
1066 |
iTest->LogSubTest(KAppScreenModeTest);
|
|
1067 |
AppScreenModeTestL();
|
|
1068 |
}
|
|
1069 |
break;
|
|
1070 |
case 2:
|
|
1071 |
((CTScreenModeScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0093"));
|
|
1072 |
iTest->LogSubTest(KWindowTests);
|
|
1073 |
WindowTestsL();
|
|
1074 |
break;
|
|
1075 |
case 3:
|
|
1076 |
((CTScreenModeScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0094"));
|
|
1077 |
iTest->LogSubTest(KSpriteTest);
|
|
1078 |
SpriteTestL();
|
|
1079 |
break;
|
|
1080 |
case 4:
|
|
1081 |
((CTScreenModeScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0095"));
|
|
1082 |
iTest->LogSubTest(KRotationTests);
|
|
1083 |
RotationTestsL();
|
|
1084 |
break;
|
|
1085 |
case 5:
|
|
1086 |
((CTScreenModeScalingStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
|
|
1087 |
iTest->LogSubTest(KTransparentTests);
|
|
1088 |
//TransparentTestsL(); //This tests currently fails sometimes for reasons not understood ####
|
|
1089 |
break;
|
|
1090 |
default:
|
|
1091 |
{
|
|
1092 |
TInt defaultMode=TheClient->iScreenModes[0];
|
|
1093 |
TheClient->iScreen->SetAppScreenMode(defaultMode);
|
|
1094 |
TheClient->iScreen->SetScreenMode(defaultMode);
|
|
1095 |
}
|
|
1096 |
((CTScreenModeScalingStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
|
|
1097 |
((CTScreenModeScalingStep*)iStep)->CloseTMSGraphicsStep();
|
|
1098 |
TestComplete();
|
|
1099 |
return;
|
|
1100 |
}
|
|
1101 |
((CTScreenModeScalingStep*)iStep)->RecordTestResultL();
|
|
1102 |
}
|
|
1103 |
|
|
1104 |
__WS_CONSTRUCT_STEP__(ScreenModeScaling)
|