1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/windowing/windowserver/test/tauto/TMDISPLAY.CPP Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,232 @@
1.4 +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Multiple display test
1.18 +//
1.19 +//
1.20 +
1.21 +/**
1.22 + @file
1.23 + @test
1.24 + @internalComponent - Internal Symbian test code
1.25 +*/
1.26 +
1.27 +
1.28 +
1.29 +#include "TMDISPLAY.H"
1.30 +#include <hal.h>
1.31 +//
1.32 +//
1.33 +CTClient* CreateClientL()
1.34 + {
1.35 + return (TheClient=new(ELeave) TestClient());
1.36 + }
1.37 +
1.38 +TInt ProcMultiDisplay(TAny* aScreenNo)
1.39 + {
1.40 + return TestLibStartUp(CreateClientL,(TInt)aScreenNo);
1.41 + }
1.42 +
1.43 +
1.44 +//
1.45 +//
1.46 +
1.47 +CTMultiDisplay::CTMultiDisplay(CTestStep* aStep) : CTWsGraphicsBase(aStep)
1.48 + {
1.49 + INFO_PRINTF1(_L("Testing Mutli display functions"));
1.50 + }
1.51 +
1.52 +void CTMultiDisplay::ConstructL()
1.53 + {
1.54 + }
1.55 +
1.56 +CTMultiDisplay::~CTMultiDisplay()
1.57 + {
1.58 + }
1.59 +
1.60 +TInt DoSetFocusScreenL(TInt aFocusScreen,TAny* /*aArg*/)
1.61 + {
1.62 + RWsSession ws;
1.63 + User::LeaveIfError(ws.Connect());
1.64 + ws.SetFocusScreen(aFocusScreen);
1.65 + ws.Close();
1.66 + return EWsExitReasonBad;
1.67 + }
1.68 +
1.69 +/**
1.70 +@SYMTestCaseID GRAPHICS-WSERV-0051
1.71 +
1.72 +@SYMDEF DEF081259
1.73 +
1.74 +@SYMTestCaseDesc Test focusing on the two different screens
1.75 + available
1.76 +
1.77 +@SYMTestPriority High
1.78 +
1.79 +@SYMTestStatus Implemented
1.80 +
1.81 +@SYMTestActions Test the response to different calls to focus
1.82 + on the two screens available
1.83 +
1.84 +@SYMTestExpectedResults Foucisng on the different screens is correct
1.85 +*/
1.86 +void CTMultiDisplay::DoFocusScreenTestL()
1.87 + {
1.88 + _LIT(KSubTitle,"FocusScreen API");
1.89 + INFO_PRINTF1(KSubTitle);
1.90 +
1.91 + TInt numberOfScreens;
1.92 + HAL::Get(HALData::EDisplayNumberOfScreens, numberOfScreens);
1.93 + TInt oldFocus=TheClient->iWs.GetFocusScreen();
1.94 +
1.95 + // test case #1: out of bounds screen number
1.96 + // expected result: client panic and focus stays on current screen
1.97 + TEST(iTest->TestWsPanicL(&DoSetFocusScreenL,EWservPanicScreenNumber,-1,NULL));
1.98 + TEST(TheClient->iWs.GetFocusScreen()==oldFocus);
1.99 + if (TheClient->iWs.GetFocusScreen()!=oldFocus)
1.100 + INFO_PRINTF3(_L("TheClient->iWs.GetFocusScreen() return value - Expected: %d, Actual: %d"), oldFocus, TheClient->iWs.GetFocusScreen());
1.101 +
1.102 + TEST(iTest->TestWsPanicL(&DoSetFocusScreenL,EWservPanicScreenNumber,numberOfScreens,NULL));
1.103 + TEST(TheClient->iWs.GetFocusScreen()==oldFocus);
1.104 + if (TheClient->iWs.GetFocusScreen()!=oldFocus)
1.105 + INFO_PRINTF3(_L("TheClient->iWs.GetFocusScreen() return value - Expected: %d, Actual: %d"), oldFocus, TheClient->iWs.GetFocusScreen());
1.106 +
1.107 +
1.108 + // test case #2: new focus equals to current focus
1.109 + // expected result: KErrNone and focus stays on current screen
1.110 + TInt ret = TheClient->iWs.SetFocusScreen(oldFocus);
1.111 + TEST(ret==KErrNone && TheClient->iWs.GetFocusScreen()==oldFocus);
1.112 + if (ret!=KErrNone || TheClient->iWs.GetFocusScreen()!=oldFocus)
1.113 + 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());
1.114 +
1.115 +
1.116 + // test case #3: set focus to screen N where screen N is empty (doesn't have any windows)
1.117 + // expected result: KErrNotFound and focus stays on current screen
1.118 + TInt i;
1.119 + for(i=1;i<numberOfScreens;++i)
1.120 + {
1.121 + ret = TheClient->iWs.SetFocusScreen(i);
1.122 + TEST(ret==KErrNotReady && TheClient->iWs.GetFocusScreen()==oldFocus);
1.123 + if (ret!=KErrNotReady || TheClient->iWs.GetFocusScreen()!=oldFocus)
1.124 + 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());
1.125 + }
1.126 +
1.127 + // test case #4: set focus to screen N where screen N has focus-able window
1.128 + // expected result: KErrNone and focus is set to screen N
1.129 + CArrayPtrFlat<CMinWin>* wins;
1.130 + wins=new(ELeave) CArrayPtrFlat<CMinWin>(numberOfScreens);
1.131 + CleanupStack::PushL(wins);
1.132 + for(i=0;i<numberOfScreens;++i)
1.133 + {
1.134 + CMinWin* win=new(ELeave) CMinWin(i);
1.135 + CleanupStack::PushL(win);
1.136 + win->ConstructL();
1.137 + wins->AppendL(win);
1.138 + }
1.139 +
1.140 + for(i=1;i<numberOfScreens;++i)
1.141 + {
1.142 + ret = TheClient->iWs.SetFocusScreen(i);
1.143 + TEST(ret==KErrNone && TheClient->iWs.GetFocusScreen()==i);
1.144 + if (ret!=KErrNone || TheClient->iWs.GetFocusScreen()!=i)
1.145 + 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());
1.146 +
1.147 + }
1.148 +
1.149 + // test case #5: set focus back from screen N to main screen (screen 0)
1.150 + // expected result: KErrNone and focus is set to screen 0
1.151 + ret = TheClient->iWs.SetFocusScreen(0);
1.152 + TEST(ret==KErrNone && TheClient->iWs.GetFocusScreen()==0);
1.153 + if (ret!=KErrNone || TheClient->iWs.GetFocusScreen()!=0)
1.154 + 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());
1.155 +
1.156 + CleanupStack::PopAndDestroy(numberOfScreens+1,wins);
1.157 + }
1.158 +
1.159 +/**
1.160 +@SYMTestCaseID GRAPHICS-WSERV-0052
1.161 +
1.162 +@SYMDEF DEF081259
1.163 +
1.164 +@SYMTestCaseDesc Launch a test from a new process and check
1.165 + that it passes indepenedent of screen focus
1.166 +
1.167 +@SYMTestPriority High
1.168 +
1.169 +@SYMTestStatus Implemented
1.170 +
1.171 +@SYMTestActions Focus on a screen, launch a test process,
1.172 + switch to focus on the other screen, then
1.173 + then check the test process passed
1.174 +
1.175 +@SYMTestExpectedResults The test in the process passed
1.176 +*/
1.177 +void CTMultiDisplay::DoScreenTestL(TInt aScreenNo)
1.178 + {
1.179 + _LIT(KSubTest,"Screen %d");
1.180 + TBuf<16> subMsg;
1.181 +
1.182 + const TInt numScreens=TheClient->iWs.NumberOfScreens();
1.183 + if (numScreens<=aScreenNo)
1.184 + {
1.185 + _LIT(KLog,"WARNING!! Cannot run test for screen %d as the device only has %d screens.");
1.186 + LOG_MESSAGE3(KLog,aScreenNo,numScreens);
1.187 + aScreenNo=numScreens-1;
1.188 + }
1.189 +
1.190 + subMsg.AppendFormat(KSubTest,aScreenNo);
1.191 + LOG_MESSAGE(subMsg);
1.192 +
1.193 + // Must switch focus screen to relevant screen manually
1.194 + CMinWin* win=new(ELeave) CMinWin(aScreenNo);
1.195 + CleanupStack::PushL(win);
1.196 + win->ConstructL();
1.197 + TheClient->iWs.SetFocusScreen(aScreenNo);
1.198 +
1.199 + CleanupStack::PopAndDestroy(win);
1.200 + TheClient->iWs.SetFocusScreen(0);
1.201 + CTestBase::iScreenNo=aScreenNo;
1.202 +
1.203 + //Set CTestBase::iNumberOfGrpWndsOnPrimaryScreenWithZeroPriority with the number of window groups
1.204 + //in default screen with priority zero. This will be used in TGwHandle test case.
1.205 + CTestBase::iNumberOfGrpWndsOnPrimaryScreenWithZeroPriority = TheClient->iWs.NumWindowGroups(0) - 1;
1.206 + }
1.207 +
1.208 +void CTMultiDisplay::RunTestCaseL(TInt /*aCurTestCase*/)
1.209 + {
1.210 + _LIT(KTest1,"Focus Screen");
1.211 + _LIT(KTest2,"Screen");
1.212 + ((CTMultiDisplayStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
1.213 +
1.214 + switch (++iTest->iState)
1.215 + {
1.216 + case 1:
1.217 + ((CTMultiDisplayStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0051"));
1.218 + iTest->LogSubTest(KTest1);
1.219 + DoFocusScreenTestL();
1.220 + break;
1.221 + case 2:
1.222 + ((CTMultiDisplayStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0052"));
1.223 + iTest->LogSubTest(KTest2);
1.224 + DoScreenTestL(1);
1.225 + break;
1.226 + default:
1.227 + ((CTMultiDisplayStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
1.228 + ((CTMultiDisplayStep*)iStep)->CloseTMSGraphicsStep();
1.229 + TestComplete();
1.230 + break;
1.231 + }
1.232 + ((CTMultiDisplayStep*)iStep)->RecordTestResultL();
1.233 + }
1.234 +
1.235 +__WS_CONSTRUCT_STEP__(MultiDisplay)