diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TMULSCREENS.CPP --- a/windowing/windowserver/tauto/TMULSCREENS.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,666 +0,0 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Enable Multiple Displays -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TMULSCREENS.h" - -const TInt KFstScreenNo = 0; -const TInt KSndScreenNo = 1; - -CTMulScreens::CTMulScreens(CTestStep* aStep): - CTWsGraphicsBase(aStep) - { - } - -void CTMulScreens::ConstructL() - { - User::LeaveIfError(iRws.Connect()); - iFstScreenDevice =new(ELeave) CWsScreenDevice(iRws); - TInt err = iFstScreenDevice->Construct(KFstScreenNo); - iTest->LogLeave(err); - User::LeaveIfError(err); - iNumScreens = iRws.NumberOfScreens(); - if(KSndScreenNoConstruct(KSndScreenNo); - iTest->LogLeave(err); - User::LeaveIfError(err); - } - INFO_PRINTF2(_L("The number of screens supported on this device is %d"),iNumScreens); - } - -CTMulScreens::~CTMulScreens() - { - iFstWinGp.Close(); - if(KSndScreenNo* aWindowList,TInt aScreenNumber,TInt aPriority) - TInt RWindowGroup::Construct(TUint32 aClientHandle,CWsScreenDevice* aScreenDevice) - TInt RWsSession::GetFocusWindowGroup(TInt aScreenNumber) - - @SYMTestExpectedResults Provided that a second screen is configured in the epoc.ini and the wsini.ini, this test case will create one window group on the first screen - and two window groups on the second screen. - If only one screen is configured, then it will create one group on the primary screen. - Otherwise this function leaves with a system-wide error. -*/ - -void CTMulScreens::TestCreateGroupWindowsL() - { - const TInt fstNumWinGps = iRws.NumWindowGroups(KFstScreenNo,EAllPriorities); - CArrayFixFlat* fstList = new(ELeave) CArrayFixFlat(1); - CleanupStack::PushL(fstList); - TInt err = iRws.WindowGroupList(fstList,KFstScreenNo,EAllPriorities); - TEST(err==KErrNone); - TEST(fstList->Count()==fstNumWinGps); - err = iRws.WindowGroupList(fstList); //test existing api - TEST(err==KErrNone); - TEST(fstList->Count()==(iRws.NumWindowGroups())); - iFstWinGp = RWindowGroup(iRws); - TRAP(err,iFstWinGp.Construct(ENullWsHandle,iFstScreenDevice)); - TEST(err==KErrNone); - if(err==KErrNone) - { - TEST(iRws.NumWindowGroups(KFstScreenNo,EAllPriorities) == (fstNumWinGps+1)); - } - CleanupStack::PopAndDestroy(fstList); - - //Second screen has been configured. - if(KSndScreenNo* sndList =new(ELeave) CArrayFixFlat(1); - CleanupStack::PushL(sndList); - TInt sndNumWinGps = iRws.NumWindowGroups(KSndScreenNo,iSndWinGp.OrdinalPriority()); - err = iRws.WindowGroupList(sndList,KSndScreenNo,iSndWinGp.OrdinalPriority()); - TEST(err==KErrNone); - TEST(sndList->Count()==sndNumWinGps); - - iSndWinGp.SetOrdinalPosition(iSndWinGp.OrdinalPosition(),EAllPriorities); - TInt allPriNumWinGps= iRws.NumWindowGroups(EAllPriorities); - CArrayFixFlat* allPriList =new(ELeave) CArrayFixFlat(1); - CleanupStack::PushL(allPriList); - err = iRws.WindowGroupList(EAllPriorities,allPriList); - TEST(err==KErrNone); - TEST(allPriList->Count()==allPriNumWinGps); - - CleanupStack::PopAndDestroy(2,sndList); - } - RWindowGroup trdWinGp = RWindowGroup(iRws); - TRAP(err,trdWinGp.Construct(ENullWsHandle,ETrue,iSndScreenDevice)); - TEST(err==KErrNone); - if(err==KErrNone) - { - winId = iRws.GetFocusWindowGroup(KSndScreenNo); - TEST(winId==trdWinGp.Identifier()); - trdWinGp.Close(); - } - } - } - -/** - @SYMTestCaseID GRAPHICS-WSERV-0384 - - @SYMPREQ PREQ1227 - - @SYMREQ REQ5541 - - @SYMTestCaseDependencies SYMTestCaseID GRAPHICS-WSERV-0383 - - @SYMTestCaseDesc Create a blank window on each screen. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Test that each blank window is created on a different screen. - API Calls:\n - TInt RBlankWindow::Construct(const RWindowTreeNode &parent, TUint32 aClientHandle) where parent is - a Window Group created on each screen. - - @SYMTestExpectedResults The background colour of the first screen changes to blue and that of the second one changes to green. - Otherwise this function leaves with a system-wide error. -*/ -void CTMulScreens::TestCreateBlankWindowsL() - { - RBlankWindow fstBlankWin(iRws); - CleanupClosePushL(fstBlankWin); - TRAPD(err,fstBlankWin.Construct(iFstWinGp,ENullWsHandle)); - TEST(err==KErrNone); - if(err==KErrNone) - { - fstBlankWin.SetRequiredDisplayMode(EColor256); - fstBlankWin.SetColor(TRgb(0,0,255)); // paint the screen blue - fstBlankWin.Activate(); - iRws.Flush(); - TheClient->WaitForRedrawsToFinish(); - User::After(6000000); - } - CleanupStack::PopAndDestroy();//fstBlankWin - - // Second screen - if(KSndScreenNoWaitForRedrawsToFinish(); - User::After(6000000); - } - CleanupStack::PopAndDestroy(); //sndBlankWin - } - } - - -/** - @SYMTestCaseID GRAPHICS-WSERV-0385 - - @SYMPREQ PREQ1227 - - @SYMREQ REQ5541 - - @SYMTestCaseDependencies SYMTestCaseID GRAPHICS-WSERV-0383 - - @SYMTestCaseDesc Test the Window Group that has the keyboard focus for each screen. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Call RWsSession::GetFocusWindowGroup on each screen. - API Calls:\n - TInt RWsSession::GetFocusWindowGroup(TInt aScreenNumber) - - @SYMTestExpectedResults The identifier returned by the API for each screen is tested to see if it is the expected Window Group ID; ie the - ID of the window group created in the first test case. -*/ -void CTMulScreens::TestGetFocusWindow() - { - TInt winId = iRws.GetFocusWindowGroup(KFstScreenNo); - TEST(winId==iFstWinGp.Identifier()); - if(KSndScreenNo* aWindowList,TInt aScreenNumber,TInt aPriority) - TInt RWsSession::GetFocusWindowGroup(TInt aScreenNumber) - TInt GetDefaultOwningWindow(TInt aScreenNumber) - TDisplayMode GetDefModeMaxNumColors(TInt aScreenNumber,TInt& aColor,TInt& aGray) const - TInt GetColorModeList(TInt aScreenNumber,CArrayFixFlat* aModeList) const - - @SYMTestExpectedResults The thread panics and exits with reason EWservPanicScreenNumber. -*/ -void CTMulScreens::TestPanicsL() - { - TInt firstTest = 1; - TInt lastTest = 6; - const TInt KInvalidScreenNumber = 2; - for (TInt option=firstTest;option<=lastTest;option++) - { - TEST(iTest->TestWsPanicL(&TestInvalidScreenNumberL,EWservPanicScreenNumber,option,(TAny*)KInvalidScreenNumber)); - } - } - -TInt CTMulScreens::TestInvalidScreenNumberL(TInt aOption, TAny *aScreenNumber) - { - RWsSession wsSession; - wsSession.Connect(); - switch((TInt)aOption) - { - case 1: - wsSession.NumWindowGroups((TInt)aScreenNumber,EAllPriorities); - break; - case 2: - { - CArrayFixFlat* list = new(ELeave) CArrayFixFlat(1); - wsSession.WindowGroupList(list,(TInt)aScreenNumber,EAllPriorities); - } - break; - case 3: - wsSession.GetFocusWindowGroup((TInt)aScreenNumber); - break; - case 4: - wsSession.GetDefaultOwningWindow((TInt)aScreenNumber); - break; - case 5: - { - CArrayFixFlat* list = new(ELeave) CArrayFixFlat(1); - wsSession.GetColorModeList((TInt)aScreenNumber,list); - } - break; - case 6: - { - TInt color,gray; - wsSession.GetDefModeMaxNumColors((TInt)aScreenNumber,color,gray); - } - break; - default: - User::Panic(_L("Default panic"),KErrGeneral); - break; - } - return KErrNone; - } - - -/** - @SYMTestCaseID GRAPHICS-WSERV-0390 - - @SYMPREQ PREQ1227 - - @SYMREQ REQ5541 - - @SYMTestCaseDependencies SYMTestCaseID GRAPHICS-WSERV-0383 - - @SYMTestCaseDesc Test that CWindowGc updates its screendevice each time it is activated on a window. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Activate the gc on both RWindows.CWindowGc::Device() is called after each activation has taken place. - API Calls:\n - void CWindowGc::Activate(RDrawableWindow &aDevice); - void CWindowGc::Deactivate(); - CGraphicsDevice* CWindowGc::Device() const - TInt RWindow::Construct(const RWindowTreeNode &parent,TUint32 aHandle); - - @SYMTestExpectedResults CWindowGc::Device() returns the screendevice on which the gc was last activated. -*/ -void CTMulScreens::TestDeviceL() - { - RWindow fstWin(iRws); - User::LeaveIfError(fstWin.Construct(iFstWinGp,ENullWsHandle)); - CleanupClosePushL(fstWin); - fstWin.Activate(); - - CWindowGc* gc=new (ELeave) CWindowGc(iFstScreenDevice); - User::LeaveIfError(gc->Construct()); - CleanupStack::PushL(gc); - gc->Activate(fstWin); - - TEST((CWsScreenDevice*)gc->Device()==iFstScreenDevice); - gc->Deactivate(); - - if(KSndScreenNoActivate(sndWin); - TEST((CWsScreenDevice*)gc->Device()==iSndScreenDevice); - gc->Deactivate(); - CleanupStack::PopAndDestroy(); - } - - CleanupStack::PopAndDestroy(2,&fstWin); - } - -/** - @SYMTestCaseID GRAPHICS-WSERV-0034 - - @SYMPREQ PREQ1227 - - @SYMREQ REQ5541 - - @SYMTestCaseDesc Test that the order of creating a screen device and window group does not matter. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Create a window group before creating the screen device. Create a graphics context and call activate on it. - API Calls:\n - TInt RWindowGroup::Construct(TUint32 aClientHandle) - TInt CWsScreenDevice::Construct() - void CWindowGc::Activate(RDrawableWindow &aDevice); - void CWindowGc::Deactivate(); - TInt RWindow::Construct(const RWindowTreeNode &parent,TUint32 aHandle); - - @SYMTestExpectedResults The test code does not panic with EWservPanicGroupWinScreenDeviceDeleted -*/ -void CTMulScreens::TestInitaliseScreenDeviceL() - { - RWsSession rws1; - User::LeaveIfError(rws1.Connect()); - CleanupClosePushL(rws1); - - RWindowGroup gw1(rws1); - User::LeaveIfError(gw1.Construct(ENullWsHandle)); - CleanupClosePushL(gw1); - - CWsScreenDevice* screen1 = new (ELeave) CWsScreenDevice(rws1); - User::LeaveIfError(screen1->Construct()); - CleanupStack::PushL(screen1); - - RWindow win1(rws1); - User::LeaveIfError(win1.Construct(gw1,ETrue)); - CleanupClosePushL(win1); - win1.Activate(); - - CWindowGc* gc=new (ELeave) CWindowGc(screen1); - User::LeaveIfError(gc->Construct()); - CleanupStack::PushL(gc); - gc->Activate(win1); - - CleanupStack::PopAndDestroy(5,&rws1); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0492 - -@SYMDEF PDEF126432 - -@SYMTestCaseDesc Test the screen number that a window is located on - -@SYMTestPriority Medium - -@SYMTestStatus Implemented - -@SYMTestActions Create two windows on two screens respectively - and check the screen number that each window is located on - -@SYMTestExpectedResults The screen numbers should match the expected ones -*/ -void CTMulScreens::TestScreenNumbersOfWindowsL() - { - // First screen - RWindow fstWin(iRws); - CleanupClosePushL(fstWin); - TRAPD(err,fstWin.Construct(iFstWinGp,ENullWsHandle)); - TEST(err==KErrNone); - if(err==KErrNone) - { - fstWin.Activate(); - iRws.Flush(); - } - TEST(fstWin.ScreenNumber()==KFstScreenNo); - CleanupStack::PopAndDestroy();//fstWin - - // Second screen - if(KSndScreenNoSetTestStepID(KUnknownSYMTestCaseIDName); - - switch(aCurTestCase) - { - case 1: - ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0383")); - INFO_PRINTF1(KTest0); - TestCreateGroupWindowsL(); - break; - case 2: - ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0384")); - INFO_PRINTF1(KTest1); - TestCreateBlankWindowsL(); - break; - case 3: - ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0385")); - INFO_PRINTF1(KTest2); - TestGetFocusWindow(); - case 4: - ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0386")); - INFO_PRINTF1(KTest3); - TestGetDefaultOwningWindow(); - break; - case 5: - ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0387")); - INFO_PRINTF1(KTest4); - TestSetBackgroundColour(); - break; - case 6: - ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0388")); - INFO_PRINTF1(KTest5); - TestSetShadowVector(); - break; - case 7: - ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0389")); - INFO_PRINTF1(KTest6); - TestPanicsL(); - break; - case 8: - ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0390")); - INFO_PRINTF1(KTest7); - TestDeviceL(); - break; - case 9: - ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0034")); - INFO_PRINTF1(KTest8); - TestInitaliseScreenDeviceL(); - break; - case 10: - ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0492")); - INFO_PRINTF1(KTest9); - TestScreenNumbersOfWindowsL(); - case 11: - ((CTMulScreensStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTMulScreensStep*)iStep)->CloseTMSGraphicsStep(); - INFO_PRINTF1(_L("All tests completed.\n")); - TestComplete(); - break; - default: - ((CTMulScreensStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTMulScreensStep*)iStep)->CloseTMSGraphicsStep(); - INFO_PRINTF1(_L("CTMulScreens::RunTestCaseL default case\n")); - break; - } - ((CTMulScreensStep*)iStep)->RecordTestResultL(); - } - -__WS_CONSTRUCT_STEP__(MulScreens)