sl@0: // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Multiple display test sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @test sl@0: @internalComponent - Internal Symbian test code sl@0: */ sl@0: sl@0: sl@0: sl@0: #include "TMDISPLAY.H" sl@0: #include sl@0: // sl@0: // sl@0: CTClient* CreateClientL() sl@0: { sl@0: return (TheClient=new(ELeave) TestClient()); sl@0: } sl@0: sl@0: TInt ProcMultiDisplay(TAny* aScreenNo) sl@0: { sl@0: return TestLibStartUp(CreateClientL,(TInt)aScreenNo); sl@0: } sl@0: sl@0: sl@0: // sl@0: // sl@0: sl@0: CTMultiDisplay::CTMultiDisplay(CTestStep* aStep) : CTWsGraphicsBase(aStep) sl@0: { sl@0: INFO_PRINTF1(_L("Testing Mutli display functions")); sl@0: } sl@0: sl@0: void CTMultiDisplay::ConstructL() sl@0: { sl@0: } sl@0: sl@0: CTMultiDisplay::~CTMultiDisplay() sl@0: { sl@0: } sl@0: sl@0: TInt DoSetFocusScreenL(TInt aFocusScreen,TAny* /*aArg*/) sl@0: { sl@0: RWsSession ws; sl@0: User::LeaveIfError(ws.Connect()); sl@0: ws.SetFocusScreen(aFocusScreen); sl@0: ws.Close(); sl@0: return EWsExitReasonBad; sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0051 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Test focusing on the two different screens sl@0: available sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Test the response to different calls to focus sl@0: on the two screens available sl@0: sl@0: @SYMTestExpectedResults Foucisng on the different screens is correct sl@0: */ sl@0: void CTMultiDisplay::DoFocusScreenTestL() sl@0: { sl@0: _LIT(KSubTitle,"FocusScreen API"); sl@0: INFO_PRINTF1(KSubTitle); sl@0: sl@0: TInt numberOfScreens; sl@0: HAL::Get(HALData::EDisplayNumberOfScreens, numberOfScreens); sl@0: TInt oldFocus=TheClient->iWs.GetFocusScreen(); sl@0: sl@0: // test case #1: out of bounds screen number sl@0: // expected result: client panic and focus stays on current screen sl@0: TEST(iTest->TestWsPanicL(&DoSetFocusScreenL,EWservPanicScreenNumber,-1,NULL)); sl@0: TEST(TheClient->iWs.GetFocusScreen()==oldFocus); sl@0: if (TheClient->iWs.GetFocusScreen()!=oldFocus) sl@0: INFO_PRINTF3(_L("TheClient->iWs.GetFocusScreen() return value - Expected: %d, Actual: %d"), oldFocus, TheClient->iWs.GetFocusScreen()); sl@0: sl@0: TEST(iTest->TestWsPanicL(&DoSetFocusScreenL,EWservPanicScreenNumber,numberOfScreens,NULL)); sl@0: TEST(TheClient->iWs.GetFocusScreen()==oldFocus); sl@0: if (TheClient->iWs.GetFocusScreen()!=oldFocus) sl@0: INFO_PRINTF3(_L("TheClient->iWs.GetFocusScreen() return value - Expected: %d, Actual: %d"), oldFocus, TheClient->iWs.GetFocusScreen()); sl@0: sl@0: sl@0: // test case #2: new focus equals to current focus sl@0: // expected result: KErrNone and focus stays on current screen sl@0: TInt ret = TheClient->iWs.SetFocusScreen(oldFocus); sl@0: TEST(ret==KErrNone && TheClient->iWs.GetFocusScreen()==oldFocus); sl@0: if (ret!=KErrNone || TheClient->iWs.GetFocusScreen()!=oldFocus) sl@0: 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: sl@0: sl@0: // test case #3: set focus to screen N where screen N is empty (doesn't have any windows) sl@0: // expected result: KErrNotFound and focus stays on current screen sl@0: TInt i; sl@0: for(i=1;iiWs.SetFocusScreen(i); sl@0: TEST(ret==KErrNotReady && TheClient->iWs.GetFocusScreen()==oldFocus); sl@0: if (ret!=KErrNotReady || TheClient->iWs.GetFocusScreen()!=oldFocus) sl@0: 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: } sl@0: sl@0: // test case #4: set focus to screen N where screen N has focus-able window sl@0: // expected result: KErrNone and focus is set to screen N sl@0: CArrayPtrFlat* wins; sl@0: wins=new(ELeave) CArrayPtrFlat(numberOfScreens); sl@0: CleanupStack::PushL(wins); sl@0: for(i=0;iConstructL(); sl@0: wins->AppendL(win); sl@0: } sl@0: sl@0: for(i=1;iiWs.SetFocusScreen(i); sl@0: TEST(ret==KErrNone && TheClient->iWs.GetFocusScreen()==i); sl@0: if (ret!=KErrNone || TheClient->iWs.GetFocusScreen()!=i) sl@0: 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: sl@0: } sl@0: sl@0: // test case #5: set focus back from screen N to main screen (screen 0) sl@0: // expected result: KErrNone and focus is set to screen 0 sl@0: ret = TheClient->iWs.SetFocusScreen(0); sl@0: TEST(ret==KErrNone && TheClient->iWs.GetFocusScreen()==0); sl@0: if (ret!=KErrNone || TheClient->iWs.GetFocusScreen()!=0) sl@0: 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: sl@0: CleanupStack::PopAndDestroy(numberOfScreens+1,wins); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0052 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Launch a test from a new process and check sl@0: that it passes indepenedent of screen focus sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Focus on a screen, launch a test process, sl@0: switch to focus on the other screen, then sl@0: then check the test process passed sl@0: sl@0: @SYMTestExpectedResults The test in the process passed sl@0: */ sl@0: void CTMultiDisplay::DoScreenTestL(TInt aScreenNo) sl@0: { sl@0: _LIT(KSubTest,"Screen %d"); sl@0: TBuf<16> subMsg; sl@0: sl@0: const TInt numScreens=TheClient->iWs.NumberOfScreens(); sl@0: if (numScreens<=aScreenNo) sl@0: { sl@0: _LIT(KLog,"WARNING!! Cannot run test for screen %d as the device only has %d screens."); sl@0: LOG_MESSAGE3(KLog,aScreenNo,numScreens); sl@0: aScreenNo=numScreens-1; sl@0: } sl@0: sl@0: subMsg.AppendFormat(KSubTest,aScreenNo); sl@0: LOG_MESSAGE(subMsg); sl@0: sl@0: // Must switch focus screen to relevant screen manually sl@0: CMinWin* win=new(ELeave) CMinWin(aScreenNo); sl@0: CleanupStack::PushL(win); sl@0: win->ConstructL(); sl@0: TheClient->iWs.SetFocusScreen(aScreenNo); sl@0: sl@0: CleanupStack::PopAndDestroy(win); sl@0: TheClient->iWs.SetFocusScreen(0); sl@0: CTestBase::iScreenNo=aScreenNo; sl@0: sl@0: //Set CTestBase::iNumberOfGrpWndsOnPrimaryScreenWithZeroPriority with the number of window groups sl@0: //in default screen with priority zero. This will be used in TGwHandle test case. sl@0: CTestBase::iNumberOfGrpWndsOnPrimaryScreenWithZeroPriority = TheClient->iWs.NumWindowGroups(0) - 1; sl@0: } sl@0: sl@0: void CTMultiDisplay::RunTestCaseL(TInt /*aCurTestCase*/) sl@0: { sl@0: _LIT(KTest1,"Focus Screen"); sl@0: _LIT(KTest2,"Screen"); sl@0: ((CTMultiDisplayStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); sl@0: sl@0: switch (++iTest->iState) sl@0: { sl@0: case 1: sl@0: ((CTMultiDisplayStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0051")); sl@0: iTest->LogSubTest(KTest1); sl@0: DoFocusScreenTestL(); sl@0: break; sl@0: case 2: sl@0: ((CTMultiDisplayStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0052")); sl@0: iTest->LogSubTest(KTest2); sl@0: DoScreenTestL(1); sl@0: break; sl@0: default: sl@0: ((CTMultiDisplayStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); sl@0: ((CTMultiDisplayStep*)iStep)->CloseTMSGraphicsStep(); sl@0: TestComplete(); sl@0: break; sl@0: } sl@0: ((CTMultiDisplayStep*)iStep)->RecordTestResultL(); sl@0: } sl@0: sl@0: __WS_CONSTRUCT_STEP__(MultiDisplay)