sl@0
|
1 |
// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// Multiple display test
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
/**
|
sl@0
|
19 |
@file
|
sl@0
|
20 |
@test
|
sl@0
|
21 |
@internalComponent - Internal Symbian test code
|
sl@0
|
22 |
*/
|
sl@0
|
23 |
|
sl@0
|
24 |
|
sl@0
|
25 |
|
sl@0
|
26 |
#include "TMDISPLAY.H"
|
sl@0
|
27 |
#include <hal.h>
|
sl@0
|
28 |
//
|
sl@0
|
29 |
//
|
sl@0
|
30 |
CTClient* CreateClientL()
|
sl@0
|
31 |
{
|
sl@0
|
32 |
return (TheClient=new(ELeave) TestClient());
|
sl@0
|
33 |
}
|
sl@0
|
34 |
|
sl@0
|
35 |
TInt ProcMultiDisplay(TAny* aScreenNo)
|
sl@0
|
36 |
{
|
sl@0
|
37 |
return TestLibStartUp(CreateClientL,(TInt)aScreenNo);
|
sl@0
|
38 |
}
|
sl@0
|
39 |
|
sl@0
|
40 |
|
sl@0
|
41 |
//
|
sl@0
|
42 |
//
|
sl@0
|
43 |
|
sl@0
|
44 |
CTMultiDisplay::CTMultiDisplay(CTestStep* aStep) : CTWsGraphicsBase(aStep)
|
sl@0
|
45 |
{
|
sl@0
|
46 |
INFO_PRINTF1(_L("Testing Mutli display functions"));
|
sl@0
|
47 |
}
|
sl@0
|
48 |
|
sl@0
|
49 |
void CTMultiDisplay::ConstructL()
|
sl@0
|
50 |
{
|
sl@0
|
51 |
}
|
sl@0
|
52 |
|
sl@0
|
53 |
CTMultiDisplay::~CTMultiDisplay()
|
sl@0
|
54 |
{
|
sl@0
|
55 |
}
|
sl@0
|
56 |
|
sl@0
|
57 |
TInt DoSetFocusScreenL(TInt aFocusScreen,TAny* /*aArg*/)
|
sl@0
|
58 |
{
|
sl@0
|
59 |
RWsSession ws;
|
sl@0
|
60 |
User::LeaveIfError(ws.Connect());
|
sl@0
|
61 |
ws.SetFocusScreen(aFocusScreen);
|
sl@0
|
62 |
ws.Close();
|
sl@0
|
63 |
return EWsExitReasonBad;
|
sl@0
|
64 |
}
|
sl@0
|
65 |
|
sl@0
|
66 |
/**
|
sl@0
|
67 |
@SYMTestCaseID GRAPHICS-WSERV-0051
|
sl@0
|
68 |
|
sl@0
|
69 |
@SYMDEF DEF081259
|
sl@0
|
70 |
|
sl@0
|
71 |
@SYMTestCaseDesc Test focusing on the two different screens
|
sl@0
|
72 |
available
|
sl@0
|
73 |
|
sl@0
|
74 |
@SYMTestPriority High
|
sl@0
|
75 |
|
sl@0
|
76 |
@SYMTestStatus Implemented
|
sl@0
|
77 |
|
sl@0
|
78 |
@SYMTestActions Test the response to different calls to focus
|
sl@0
|
79 |
on the two screens available
|
sl@0
|
80 |
|
sl@0
|
81 |
@SYMTestExpectedResults Foucisng on the different screens is correct
|
sl@0
|
82 |
*/
|
sl@0
|
83 |
void CTMultiDisplay::DoFocusScreenTestL()
|
sl@0
|
84 |
{
|
sl@0
|
85 |
_LIT(KSubTitle,"FocusScreen API");
|
sl@0
|
86 |
INFO_PRINTF1(KSubTitle);
|
sl@0
|
87 |
|
sl@0
|
88 |
TInt numberOfScreens;
|
sl@0
|
89 |
HAL::Get(HALData::EDisplayNumberOfScreens, numberOfScreens);
|
sl@0
|
90 |
TInt oldFocus=TheClient->iWs.GetFocusScreen();
|
sl@0
|
91 |
|
sl@0
|
92 |
// test case #1: out of bounds screen number
|
sl@0
|
93 |
// expected result: client panic and focus stays on current screen
|
sl@0
|
94 |
TEST(iTest->TestWsPanicL(&DoSetFocusScreenL,EWservPanicScreenNumber,-1,NULL));
|
sl@0
|
95 |
TEST(TheClient->iWs.GetFocusScreen()==oldFocus);
|
sl@0
|
96 |
if (TheClient->iWs.GetFocusScreen()!=oldFocus)
|
sl@0
|
97 |
INFO_PRINTF3(_L("TheClient->iWs.GetFocusScreen() return value - Expected: %d, Actual: %d"), oldFocus, TheClient->iWs.GetFocusScreen());
|
sl@0
|
98 |
|
sl@0
|
99 |
TEST(iTest->TestWsPanicL(&DoSetFocusScreenL,EWservPanicScreenNumber,numberOfScreens,NULL));
|
sl@0
|
100 |
TEST(TheClient->iWs.GetFocusScreen()==oldFocus);
|
sl@0
|
101 |
if (TheClient->iWs.GetFocusScreen()!=oldFocus)
|
sl@0
|
102 |
INFO_PRINTF3(_L("TheClient->iWs.GetFocusScreen() return value - Expected: %d, Actual: %d"), oldFocus, TheClient->iWs.GetFocusScreen());
|
sl@0
|
103 |
|
sl@0
|
104 |
|
sl@0
|
105 |
// test case #2: new focus equals to current focus
|
sl@0
|
106 |
// expected result: KErrNone and focus stays on current screen
|
sl@0
|
107 |
TInt ret = TheClient->iWs.SetFocusScreen(oldFocus);
|
sl@0
|
108 |
TEST(ret==KErrNone && TheClient->iWs.GetFocusScreen()==oldFocus);
|
sl@0
|
109 |
if (ret!=KErrNone || TheClient->iWs.GetFocusScreen()!=oldFocus)
|
sl@0
|
110 |
INFO_PRINTF5(_L("TheClient->iWs.SetFocusScreen(oldFocus)==KErrNone && TheClient->iWs.GetFocusScreen()==oldFocus - Expected: %d and %d, Actual: %d and %d"),KErrNone, oldFocus, ret, TheClient->iWs.GetFocusScreen());
|
sl@0
|
111 |
|
sl@0
|
112 |
|
sl@0
|
113 |
// test case #3: set focus to screen N where screen N is empty (doesn't have any windows)
|
sl@0
|
114 |
// expected result: KErrNotFound and focus stays on current screen
|
sl@0
|
115 |
TInt i;
|
sl@0
|
116 |
for(i=1;i<numberOfScreens;++i)
|
sl@0
|
117 |
{
|
sl@0
|
118 |
ret = TheClient->iWs.SetFocusScreen(i);
|
sl@0
|
119 |
TEST(ret==KErrNotReady && TheClient->iWs.GetFocusScreen()==oldFocus);
|
sl@0
|
120 |
if (ret!=KErrNotReady || TheClient->iWs.GetFocusScreen()!=oldFocus)
|
sl@0
|
121 |
INFO_PRINTF5(_L("TheClient->iWs.SetFocusScreen(i)==KErrNotReady && TheClient->iWs.GetFocusScreen()==oldFocus - Expected: %d and %d, Actual: %d and %d"),KErrNotReady, oldFocus, ret, TheClient->iWs.GetFocusScreen());
|
sl@0
|
122 |
}
|
sl@0
|
123 |
|
sl@0
|
124 |
// test case #4: set focus to screen N where screen N has focus-able window
|
sl@0
|
125 |
// expected result: KErrNone and focus is set to screen N
|
sl@0
|
126 |
CArrayPtrFlat<CMinWin>* wins;
|
sl@0
|
127 |
wins=new(ELeave) CArrayPtrFlat<CMinWin>(numberOfScreens);
|
sl@0
|
128 |
CleanupStack::PushL(wins);
|
sl@0
|
129 |
for(i=0;i<numberOfScreens;++i)
|
sl@0
|
130 |
{
|
sl@0
|
131 |
CMinWin* win=new(ELeave) CMinWin(i);
|
sl@0
|
132 |
CleanupStack::PushL(win);
|
sl@0
|
133 |
win->ConstructL();
|
sl@0
|
134 |
wins->AppendL(win);
|
sl@0
|
135 |
}
|
sl@0
|
136 |
|
sl@0
|
137 |
for(i=1;i<numberOfScreens;++i)
|
sl@0
|
138 |
{
|
sl@0
|
139 |
ret = TheClient->iWs.SetFocusScreen(i);
|
sl@0
|
140 |
TEST(ret==KErrNone && TheClient->iWs.GetFocusScreen()==i);
|
sl@0
|
141 |
if (ret!=KErrNone || TheClient->iWs.GetFocusScreen()!=i)
|
sl@0
|
142 |
INFO_PRINTF5(_L("TheClient->iWs.SetFocusScreen(i)==KErrNone && TheClient->iWs.GetFocusScreen()==i - Expected: %d and %d, Actual: %d and %d"),KErrNone, i, ret, TheClient->iWs.GetFocusScreen());
|
sl@0
|
143 |
|
sl@0
|
144 |
}
|
sl@0
|
145 |
|
sl@0
|
146 |
// test case #5: set focus back from screen N to main screen (screen 0)
|
sl@0
|
147 |
// expected result: KErrNone and focus is set to screen 0
|
sl@0
|
148 |
ret = TheClient->iWs.SetFocusScreen(0);
|
sl@0
|
149 |
TEST(ret==KErrNone && TheClient->iWs.GetFocusScreen()==0);
|
sl@0
|
150 |
if (ret!=KErrNone || TheClient->iWs.GetFocusScreen()!=0)
|
sl@0
|
151 |
INFO_PRINTF5(_L("TheClient->iWs.SetFocusScreen(0)==KErrNone && TheClient->iWs.GetFocusScreen()==0 - Expected: %d and %d, Actual: %d and %d"),KErrNone, 0, ret, TheClient->iWs.GetFocusScreen());
|
sl@0
|
152 |
|
sl@0
|
153 |
CleanupStack::PopAndDestroy(numberOfScreens+1,wins);
|
sl@0
|
154 |
}
|
sl@0
|
155 |
|
sl@0
|
156 |
/**
|
sl@0
|
157 |
@SYMTestCaseID GRAPHICS-WSERV-0052
|
sl@0
|
158 |
|
sl@0
|
159 |
@SYMDEF DEF081259
|
sl@0
|
160 |
|
sl@0
|
161 |
@SYMTestCaseDesc Launch a test from a new process and check
|
sl@0
|
162 |
that it passes indepenedent of screen focus
|
sl@0
|
163 |
|
sl@0
|
164 |
@SYMTestPriority High
|
sl@0
|
165 |
|
sl@0
|
166 |
@SYMTestStatus Implemented
|
sl@0
|
167 |
|
sl@0
|
168 |
@SYMTestActions Focus on a screen, launch a test process,
|
sl@0
|
169 |
switch to focus on the other screen, then
|
sl@0
|
170 |
then check the test process passed
|
sl@0
|
171 |
|
sl@0
|
172 |
@SYMTestExpectedResults The test in the process passed
|
sl@0
|
173 |
*/
|
sl@0
|
174 |
void CTMultiDisplay::DoScreenTestL(TInt aScreenNo)
|
sl@0
|
175 |
{
|
sl@0
|
176 |
_LIT(KSubTest,"Screen %d");
|
sl@0
|
177 |
TBuf<16> subMsg;
|
sl@0
|
178 |
|
sl@0
|
179 |
const TInt numScreens=TheClient->iWs.NumberOfScreens();
|
sl@0
|
180 |
if (numScreens<=aScreenNo)
|
sl@0
|
181 |
{
|
sl@0
|
182 |
_LIT(KLog,"WARNING!! Cannot run test for screen %d as the device only has %d screens.");
|
sl@0
|
183 |
LOG_MESSAGE3(KLog,aScreenNo,numScreens);
|
sl@0
|
184 |
aScreenNo=numScreens-1;
|
sl@0
|
185 |
}
|
sl@0
|
186 |
|
sl@0
|
187 |
subMsg.AppendFormat(KSubTest,aScreenNo);
|
sl@0
|
188 |
LOG_MESSAGE(subMsg);
|
sl@0
|
189 |
|
sl@0
|
190 |
// Must switch focus screen to relevant screen manually
|
sl@0
|
191 |
CMinWin* win=new(ELeave) CMinWin(aScreenNo);
|
sl@0
|
192 |
CleanupStack::PushL(win);
|
sl@0
|
193 |
win->ConstructL();
|
sl@0
|
194 |
TheClient->iWs.SetFocusScreen(aScreenNo);
|
sl@0
|
195 |
|
sl@0
|
196 |
CleanupStack::PopAndDestroy(win);
|
sl@0
|
197 |
TheClient->iWs.SetFocusScreen(0);
|
sl@0
|
198 |
CTestBase::iScreenNo=aScreenNo;
|
sl@0
|
199 |
|
sl@0
|
200 |
//Set CTestBase::iNumberOfGrpWndsOnPrimaryScreenWithZeroPriority with the number of window groups
|
sl@0
|
201 |
//in default screen with priority zero. This will be used in TGwHandle test case.
|
sl@0
|
202 |
CTestBase::iNumberOfGrpWndsOnPrimaryScreenWithZeroPriority = TheClient->iWs.NumWindowGroups(0) - 1;
|
sl@0
|
203 |
}
|
sl@0
|
204 |
|
sl@0
|
205 |
void CTMultiDisplay::RunTestCaseL(TInt /*aCurTestCase*/)
|
sl@0
|
206 |
{
|
sl@0
|
207 |
_LIT(KTest1,"Focus Screen");
|
sl@0
|
208 |
_LIT(KTest2,"Screen");
|
sl@0
|
209 |
((CTMultiDisplayStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
|
sl@0
|
210 |
|
sl@0
|
211 |
switch (++iTest->iState)
|
sl@0
|
212 |
{
|
sl@0
|
213 |
case 1:
|
sl@0
|
214 |
((CTMultiDisplayStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0051"));
|
sl@0
|
215 |
iTest->LogSubTest(KTest1);
|
sl@0
|
216 |
DoFocusScreenTestL();
|
sl@0
|
217 |
break;
|
sl@0
|
218 |
case 2:
|
sl@0
|
219 |
((CTMultiDisplayStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0052"));
|
sl@0
|
220 |
iTest->LogSubTest(KTest2);
|
sl@0
|
221 |
DoScreenTestL(1);
|
sl@0
|
222 |
break;
|
sl@0
|
223 |
default:
|
sl@0
|
224 |
((CTMultiDisplayStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
|
sl@0
|
225 |
((CTMultiDisplayStep*)iStep)->CloseTMSGraphicsStep();
|
sl@0
|
226 |
TestComplete();
|
sl@0
|
227 |
break;
|
sl@0
|
228 |
}
|
sl@0
|
229 |
((CTMultiDisplayStep*)iStep)->RecordTestResultL();
|
sl@0
|
230 |
}
|
sl@0
|
231 |
|
sl@0
|
232 |
__WS_CONSTRUCT_STEP__(MultiDisplay)
|