First public contribution.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Multiple display test
21 @internalComponent - Internal Symbian test code
26 #include "TMDISPLAY.H"
30 CTClient* CreateClientL()
32 return (TheClient=new(ELeave) TestClient());
35 TInt ProcMultiDisplay(TAny* aScreenNo)
37 return TestLibStartUp(CreateClientL,(TInt)aScreenNo);
44 CTMultiDisplay::CTMultiDisplay(CTestStep* aStep) : CTWsGraphicsBase(aStep)
46 INFO_PRINTF1(_L("Testing Mutli display functions"));
49 void CTMultiDisplay::ConstructL()
53 CTMultiDisplay::~CTMultiDisplay()
57 TInt DoSetFocusScreenL(TInt aFocusScreen,TAny* /*aArg*/)
60 User::LeaveIfError(ws.Connect());
61 ws.SetFocusScreen(aFocusScreen);
63 return EWsExitReasonBad;
67 @SYMTestCaseID GRAPHICS-WSERV-0051
71 @SYMTestCaseDesc Test focusing on the two different screens
76 @SYMTestStatus Implemented
78 @SYMTestActions Test the response to different calls to focus
79 on the two screens available
81 @SYMTestExpectedResults Foucisng on the different screens is correct
83 void CTMultiDisplay::DoFocusScreenTestL()
85 _LIT(KSubTitle,"FocusScreen API");
86 INFO_PRINTF1(KSubTitle);
89 HAL::Get(HALData::EDisplayNumberOfScreens, numberOfScreens);
90 TInt oldFocus=TheClient->iWs.GetFocusScreen();
92 // test case #1: out of bounds screen number
93 // expected result: client panic and focus stays on current screen
94 TEST(iTest->TestWsPanicL(&DoSetFocusScreenL,EWservPanicScreenNumber,-1,NULL));
95 TEST(TheClient->iWs.GetFocusScreen()==oldFocus);
96 if (TheClient->iWs.GetFocusScreen()!=oldFocus)
97 INFO_PRINTF3(_L("TheClient->iWs.GetFocusScreen() return value - Expected: %d, Actual: %d"), oldFocus, TheClient->iWs.GetFocusScreen());
99 TEST(iTest->TestWsPanicL(&DoSetFocusScreenL,EWservPanicScreenNumber,numberOfScreens,NULL));
100 TEST(TheClient->iWs.GetFocusScreen()==oldFocus);
101 if (TheClient->iWs.GetFocusScreen()!=oldFocus)
102 INFO_PRINTF3(_L("TheClient->iWs.GetFocusScreen() return value - Expected: %d, Actual: %d"), oldFocus, TheClient->iWs.GetFocusScreen());
105 // test case #2: new focus equals to current focus
106 // expected result: KErrNone and focus stays on current screen
107 TInt ret = TheClient->iWs.SetFocusScreen(oldFocus);
108 TEST(ret==KErrNone && TheClient->iWs.GetFocusScreen()==oldFocus);
109 if (ret!=KErrNone || TheClient->iWs.GetFocusScreen()!=oldFocus)
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());
113 // test case #3: set focus to screen N where screen N is empty (doesn't have any windows)
114 // expected result: KErrNotFound and focus stays on current screen
116 for(i=1;i<numberOfScreens;++i)
118 ret = TheClient->iWs.SetFocusScreen(i);
119 TEST(ret==KErrNotReady && TheClient->iWs.GetFocusScreen()==oldFocus);
120 if (ret!=KErrNotReady || TheClient->iWs.GetFocusScreen()!=oldFocus)
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());
124 // test case #4: set focus to screen N where screen N has focus-able window
125 // expected result: KErrNone and focus is set to screen N
126 CArrayPtrFlat<CMinWin>* wins;
127 wins=new(ELeave) CArrayPtrFlat<CMinWin>(numberOfScreens);
128 CleanupStack::PushL(wins);
129 for(i=0;i<numberOfScreens;++i)
131 CMinWin* win=new(ELeave) CMinWin(i);
132 CleanupStack::PushL(win);
137 for(i=1;i<numberOfScreens;++i)
139 ret = TheClient->iWs.SetFocusScreen(i);
140 TEST(ret==KErrNone && TheClient->iWs.GetFocusScreen()==i);
141 if (ret!=KErrNone || TheClient->iWs.GetFocusScreen()!=i)
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());
146 // test case #5: set focus back from screen N to main screen (screen 0)
147 // expected result: KErrNone and focus is set to screen 0
148 ret = TheClient->iWs.SetFocusScreen(0);
149 TEST(ret==KErrNone && TheClient->iWs.GetFocusScreen()==0);
150 if (ret!=KErrNone || TheClient->iWs.GetFocusScreen()!=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());
153 CleanupStack::PopAndDestroy(numberOfScreens+1,wins);
157 @SYMTestCaseID GRAPHICS-WSERV-0052
161 @SYMTestCaseDesc Launch a test from a new process and check
162 that it passes indepenedent of screen focus
164 @SYMTestPriority High
166 @SYMTestStatus Implemented
168 @SYMTestActions Focus on a screen, launch a test process,
169 switch to focus on the other screen, then
170 then check the test process passed
172 @SYMTestExpectedResults The test in the process passed
174 void CTMultiDisplay::DoScreenTestL(TInt aScreenNo)
176 _LIT(KSubTest,"Screen %d");
179 const TInt numScreens=TheClient->iWs.NumberOfScreens();
180 if (numScreens<=aScreenNo)
182 _LIT(KLog,"WARNING!! Cannot run test for screen %d as the device only has %d screens.");
183 LOG_MESSAGE3(KLog,aScreenNo,numScreens);
184 aScreenNo=numScreens-1;
187 subMsg.AppendFormat(KSubTest,aScreenNo);
190 // Must switch focus screen to relevant screen manually
191 CMinWin* win=new(ELeave) CMinWin(aScreenNo);
192 CleanupStack::PushL(win);
194 TheClient->iWs.SetFocusScreen(aScreenNo);
196 CleanupStack::PopAndDestroy(win);
197 TheClient->iWs.SetFocusScreen(0);
198 CTestBase::iScreenNo=aScreenNo;
200 //Set CTestBase::iNumberOfGrpWndsOnPrimaryScreenWithZeroPriority with the number of window groups
201 //in default screen with priority zero. This will be used in TGwHandle test case.
202 CTestBase::iNumberOfGrpWndsOnPrimaryScreenWithZeroPriority = TheClient->iWs.NumWindowGroups(0) - 1;
205 void CTMultiDisplay::RunTestCaseL(TInt /*aCurTestCase*/)
207 _LIT(KTest1,"Focus Screen");
208 _LIT(KTest2,"Screen");
209 ((CTMultiDisplayStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
211 switch (++iTest->iState)
214 ((CTMultiDisplayStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0051"));
215 iTest->LogSubTest(KTest1);
216 DoFocusScreenTestL();
219 ((CTMultiDisplayStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0052"));
220 iTest->LogSubTest(KTest2);
224 ((CTMultiDisplayStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
225 ((CTMultiDisplayStep*)iStep)->CloseTMSGraphicsStep();
229 ((CTMultiDisplayStep*)iStep)->RecordTestResultL();
232 __WS_CONSTRUCT_STEP__(MultiDisplay)