First public contribution.
1 // Copyright (c) 2006-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 // Enable Multiple Displays
21 @internalComponent - Internal Symbian test code
24 #include "TMULSCREENS.h"
26 const TInt KFstScreenNo = 0;
27 const TInt KSndScreenNo = 1;
29 CTMulScreens::CTMulScreens(CTestStep* aStep):
30 CTWsGraphicsBase(aStep)
34 void CTMulScreens::ConstructL()
36 User::LeaveIfError(iRws.Connect());
37 iFstScreenDevice =new(ELeave) CWsScreenDevice(iRws);
38 TInt err = iFstScreenDevice->Construct(KFstScreenNo);
40 User::LeaveIfError(err);
41 iNumScreens = iRws.NumberOfScreens();
42 if(KSndScreenNo<iNumScreens)
44 iSndScreenDevice =new(ELeave) CWsScreenDevice(iRws);
45 err = iSndScreenDevice->Construct(KSndScreenNo);
47 User::LeaveIfError(err);
49 INFO_PRINTF2(_L("The number of screens supported on this device is %d"),iNumScreens);
52 CTMulScreens::~CTMulScreens()
55 if(KSndScreenNo<iNumScreens)
58 delete iSndScreenDevice;
60 delete iFstScreenDevice;
65 @SYMTestCaseID GRAPHICS-WSERV-0383
71 @SYMTestCaseDesc Create Window Group(s) on each screen.
75 @SYMTestStatus Implemented
77 @SYMTestActions Call RWsSession::NumWindowGroups() to get the number of window groups of a given window group priority running on a specified screen.
78 Test the number of Window Groups on each screen.
79 Test the size of the list of window group on each screen.
80 Test the Window Group which has the keyboard focus on the second screen.
82 TInt RWsSession::NumWindowGroups(TInt aScreenNumber,TInt aPriority) const
83 TInt RWsSession::WindowGroupList(CArrayFixFlat<TInt>* aWindowList,TInt aScreenNumber,TInt aPriority)
84 TInt RWindowGroup::Construct(TUint32 aClientHandle,CWsScreenDevice* aScreenDevice)
85 TInt RWsSession::GetFocusWindowGroup(TInt aScreenNumber)
87 @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
88 and two window groups on the second screen.
89 If only one screen is configured, then it will create one group on the primary screen.
90 Otherwise this function leaves with a system-wide error.
93 void CTMulScreens::TestCreateGroupWindowsL()
95 const TInt fstNumWinGps = iRws.NumWindowGroups(KFstScreenNo,EAllPriorities);
96 CArrayFixFlat<TInt>* fstList = new(ELeave) CArrayFixFlat<TInt>(1);
97 CleanupStack::PushL(fstList);
98 TInt err = iRws.WindowGroupList(fstList,KFstScreenNo,EAllPriorities);
100 TEST(fstList->Count()==fstNumWinGps);
101 err = iRws.WindowGroupList(fstList); //test existing api
103 TEST(fstList->Count()==(iRws.NumWindowGroups()));
104 iFstWinGp = RWindowGroup(iRws);
105 TRAP(err,iFstWinGp.Construct(ENullWsHandle,iFstScreenDevice));
109 TEST(iRws.NumWindowGroups(KFstScreenNo,EAllPriorities) == (fstNumWinGps+1));
111 CleanupStack::PopAndDestroy(fstList);
113 //Second screen has been configured.
114 if(KSndScreenNo<iNumScreens)
116 TInt winId = iRws.GetFocusWindowGroup(KSndScreenNo);
117 TEST(winId==KErrGeneral);
118 iSndWinGp = RWindowGroup(iRws);
119 TRAP(err,iSndWinGp.Construct(ENullWsHandle,ETrue,iSndScreenDevice));
123 winId = iRws.GetFocusWindowGroup(KSndScreenNo);
124 TEST(winId==iSndWinGp.Identifier());
125 TEST(iRws.NumWindowGroups(KFstScreenNo,EAllPriorities) == (fstNumWinGps+1)); //test that the no. of screens unchanged on first screen
126 CArrayFixFlat<TInt>* sndList =new(ELeave) CArrayFixFlat<TInt>(1);
127 CleanupStack::PushL(sndList);
128 TInt sndNumWinGps = iRws.NumWindowGroups(KSndScreenNo,iSndWinGp.OrdinalPriority());
129 err = iRws.WindowGroupList(sndList,KSndScreenNo,iSndWinGp.OrdinalPriority());
131 TEST(sndList->Count()==sndNumWinGps);
133 iSndWinGp.SetOrdinalPosition(iSndWinGp.OrdinalPosition(),EAllPriorities);
134 TInt allPriNumWinGps= iRws.NumWindowGroups(EAllPriorities);
135 CArrayFixFlat<TInt>* allPriList =new(ELeave) CArrayFixFlat<TInt>(1);
136 CleanupStack::PushL(allPriList);
137 err = iRws.WindowGroupList(EAllPriorities,allPriList);
139 TEST(allPriList->Count()==allPriNumWinGps);
141 CleanupStack::PopAndDestroy(2,sndList);
143 RWindowGroup trdWinGp = RWindowGroup(iRws);
144 TRAP(err,trdWinGp.Construct(ENullWsHandle,ETrue,iSndScreenDevice));
148 winId = iRws.GetFocusWindowGroup(KSndScreenNo);
149 TEST(winId==trdWinGp.Identifier());
156 @SYMTestCaseID GRAPHICS-WSERV-0384
162 @SYMTestCaseDependencies SYMTestCaseID GRAPHICS-WSERV-0383
164 @SYMTestCaseDesc Create a blank window on each screen.
166 @SYMTestPriority High
168 @SYMTestStatus Implemented
170 @SYMTestActions Test that each blank window is created on a different screen.
172 TInt RBlankWindow::Construct(const RWindowTreeNode &parent, TUint32 aClientHandle) where parent is
173 a Window Group created on each screen.
175 @SYMTestExpectedResults The background colour of the first screen changes to blue and that of the second one changes to green.
176 Otherwise this function leaves with a system-wide error.
178 void CTMulScreens::TestCreateBlankWindowsL()
180 RBlankWindow fstBlankWin(iRws);
181 CleanupClosePushL(fstBlankWin);
182 TRAPD(err,fstBlankWin.Construct(iFstWinGp,ENullWsHandle));
186 fstBlankWin.SetRequiredDisplayMode(EColor256);
187 fstBlankWin.SetColor(TRgb(0,0,255)); // paint the screen blue
188 fstBlankWin.Activate();
190 TheClient->WaitForRedrawsToFinish();
191 User::After(6000000);
193 CleanupStack::PopAndDestroy();//fstBlankWin
196 if(KSndScreenNo<iNumScreens)
198 RBlankWindow sndBlankWin(iRws);
199 CleanupClosePushL(sndBlankWin);
200 TRAP(err,sndBlankWin.Construct(iSndWinGp,ENullWsHandle));
204 sndBlankWin.SetRequiredDisplayMode(EColor256);
205 sndBlankWin.SetColor(TRgb(0,255,0)); //paint the screen green
206 sndBlankWin.Activate(); //there is a defect in Activate() because there is a delay before the second screen turns green
208 TheClient->WaitForRedrawsToFinish();
209 User::After(6000000);
211 CleanupStack::PopAndDestroy(); //sndBlankWin
217 @SYMTestCaseID GRAPHICS-WSERV-0385
223 @SYMTestCaseDependencies SYMTestCaseID GRAPHICS-WSERV-0383
225 @SYMTestCaseDesc Test the Window Group that has the keyboard focus for each screen.
227 @SYMTestPriority High
229 @SYMTestStatus Implemented
231 @SYMTestActions Call RWsSession::GetFocusWindowGroup on each screen.
233 TInt RWsSession::GetFocusWindowGroup(TInt aScreenNumber)
235 @SYMTestExpectedResults The identifier returned by the API for each screen is tested to see if it is the expected Window Group ID; ie the
236 ID of the window group created in the first test case.
238 void CTMulScreens::TestGetFocusWindow()
240 TInt winId = iRws.GetFocusWindowGroup(KFstScreenNo);
241 TEST(winId==iFstWinGp.Identifier());
242 if(KSndScreenNo<iNumScreens)
244 winId = iRws.GetFocusWindowGroup(KSndScreenNo);
245 TEST(winId==iSndWinGp.Identifier());
246 TEST(iRws.GetFocusWindowGroup()==iFstWinGp.Identifier());
251 @SYMTestCaseID GRAPHICS-WSERV-0386
257 @SYMTestCaseDependencies SYMTestCaseID GRAPHICS-WSERV-0383
259 @SYMTestCaseDesc Test the default owning window on each screen.
261 @SYMTestPriority High
263 @SYMTestStatus Implemented
265 @SYMTestActions Call RWsSession::GetDefaultOwningWindow() to return the ID of the default owning window.
266 Call RWsSession::DefaultOwningWindow() on the second Window Group to set it as the default owning window on the second screen.
267 Call new API RWsSession::GetDefaultOwningWindow(TInt aScreenNumber) to get the default owning window on the second screen.
269 TInt RWsSession::GetFocusWindowGroup()
270 TInt RWsSession::GetFocusWindowGroup(TInt aScreenNumber)
272 @SYMTestExpectedResults The identifier returned by the API for each screen is tested to see that they are not the same.
274 void CTMulScreens::TestGetDefaultOwningWindow()
276 if(KSndScreenNo<iNumScreens)
278 TInt prevWinId = iRws.GetDefaultOwningWindow();
279 iSndWinGp.DefaultOwningWindow();
280 TInt winId = iRws.GetDefaultOwningWindow(KSndScreenNo);
281 TEST(winId==iSndWinGp.Identifier());
282 TEST(prevWinId!=winId);
287 @SYMTestCaseID GRAPHICS-WSERV-0387
293 @SYMTestCaseDesc Test the background colour.
295 @SYMTestPriority High
297 @SYMTestStatus Implemented
299 @SYMTestActions Call RWsSession::GetBackgroundColor() to store the default value;Change the background colour by calling RWsSession::SetBackgroundColor();
300 Test that the background has changed; Restore the background colour.
302 TRgb RWsSession::GetBackgroundColor() const
303 void RWsSession::SetBackgroundColor(TRgb colour)
305 @SYMTestExpectedResults Background color should change when SetBackgroundColor is called.
307 void CTMulScreens::TestSetBackgroundColour()
309 TRgb rgb_b4 = iRws.GetBackgroundColor();
310 iRws.SetBackgroundColor(KRgbBlack);
311 TEST(iRws.GetBackgroundColor()==KRgbBlack);
312 iRws.SetBackgroundColor(rgb_b4);
313 TEST(iRws.GetBackgroundColor()==rgb_b4);
317 @SYMTestCaseID GRAPHICS-WSERV-0388
323 @SYMTestCaseDesc Test the shadow vector.
325 @SYMTestPriority High
327 @SYMTestStatus Implemented
329 @SYMTestActions Call RWsSession::ShadowVector() to store the default value;Call RWsSession::SetShadowVector() to change the shadow vector;
330 Test that the shadow vector has changed; Restore the shadow vector.
332 TPoint RWsSession::ShadowVector() const
333 void RWsSession::SetShadowVector(const TPoint &aVector);
335 @SYMTestExpectedResults The shadow vector should change when SetShadowVector is called.
337 void CTMulScreens::TestSetShadowVector()
339 TPoint point_b4 = iRws.ShadowVector();
341 iRws.SetShadowVector(TPoint(3,3));
343 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
344 TEST(iRws.ShadowVector()==TPoint(0,0)); // in NGA SetShadowVector & ShadowVector are deprecated
346 TEST(iRws.ShadowVector()==TPoint(3,3));
349 iRws.SetShadowVector(point_b4);
351 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
352 TEST(iRws.ShadowVector()==TPoint(0,0)); // in NGA SetShadowVector & ShadowVector are deprecated
354 TEST(iRws.ShadowVector()==point_b4);
359 @SYMTestCaseID GRAPHICS-WSERV-0389
365 @SYMTestCaseDesc Negative tests for the APIs listed below.
367 @SYMTestPriority High
369 @SYMTestStatus Implemented
371 @SYMTestActions Launch a thread to call TestInvalidScreenNumber. Pass an invalid screen number to the APIs listed below.
373 TInt RWsSession::NumWindowGroups(TInt aScreenNumber,TInt aPriority) const
374 TInt RWsSession::WindowGroupList(CArrayFixFlat<TInt>* aWindowList,TInt aScreenNumber,TInt aPriority)
375 TInt RWsSession::GetFocusWindowGroup(TInt aScreenNumber)
376 TInt GetDefaultOwningWindow(TInt aScreenNumber)
377 TDisplayMode GetDefModeMaxNumColors(TInt aScreenNumber,TInt& aColor,TInt& aGray) const
378 TInt GetColorModeList(TInt aScreenNumber,CArrayFixFlat<TInt>* aModeList) const
380 @SYMTestExpectedResults The thread panics and exits with reason EWservPanicScreenNumber.
382 void CTMulScreens::TestPanicsL()
386 const TInt KInvalidScreenNumber = 2;
387 for (TInt option=firstTest;option<=lastTest;option++)
389 TEST(iTest->TestWsPanicL(&TestInvalidScreenNumberL,EWservPanicScreenNumber,option,(TAny*)KInvalidScreenNumber));
393 TInt CTMulScreens::TestInvalidScreenNumberL(TInt aOption, TAny *aScreenNumber)
395 RWsSession wsSession;
397 switch((TInt)aOption)
400 wsSession.NumWindowGroups((TInt)aScreenNumber,EAllPriorities);
404 CArrayFixFlat<TInt>* list = new(ELeave) CArrayFixFlat<TInt>(1);
405 wsSession.WindowGroupList(list,(TInt)aScreenNumber,EAllPriorities);
409 wsSession.GetFocusWindowGroup((TInt)aScreenNumber);
412 wsSession.GetDefaultOwningWindow((TInt)aScreenNumber);
416 CArrayFixFlat<TInt>* list = new(ELeave) CArrayFixFlat<TInt>(1);
417 wsSession.GetColorModeList((TInt)aScreenNumber,list);
423 wsSession.GetDefModeMaxNumColors((TInt)aScreenNumber,color,gray);
427 User::Panic(_L("Default panic"),KErrGeneral);
435 @SYMTestCaseID GRAPHICS-WSERV-0390
441 @SYMTestCaseDependencies SYMTestCaseID GRAPHICS-WSERV-0383
443 @SYMTestCaseDesc Test that CWindowGc updates its screendevice each time it is activated on a window.
445 @SYMTestPriority High
447 @SYMTestStatus Implemented
449 @SYMTestActions Activate the gc on both RWindows.CWindowGc::Device() is called after each activation has taken place.
451 void CWindowGc::Activate(RDrawableWindow &aDevice);
452 void CWindowGc::Deactivate();
453 CGraphicsDevice* CWindowGc::Device() const
454 TInt RWindow::Construct(const RWindowTreeNode &parent,TUint32 aHandle);
456 @SYMTestExpectedResults CWindowGc::Device() returns the screendevice on which the gc was last activated.
458 void CTMulScreens::TestDeviceL()
460 RWindow fstWin(iRws);
461 User::LeaveIfError(fstWin.Construct(iFstWinGp,ENullWsHandle));
462 CleanupClosePushL(fstWin);
465 CWindowGc* gc=new (ELeave) CWindowGc(iFstScreenDevice);
466 User::LeaveIfError(gc->Construct());
467 CleanupStack::PushL(gc);
468 gc->Activate(fstWin);
470 TEST((CWsScreenDevice*)gc->Device()==iFstScreenDevice);
473 if(KSndScreenNo<iNumScreens)
475 RWindow sndWin(iRws);
476 User::LeaveIfError(sndWin.Construct(iSndWinGp,ENullWsHandle));
477 CleanupClosePushL(sndWin);
480 gc->Activate(sndWin);
481 TEST((CWsScreenDevice*)gc->Device()==iSndScreenDevice);
483 CleanupStack::PopAndDestroy();
486 CleanupStack::PopAndDestroy(2,&fstWin);
490 @SYMTestCaseID GRAPHICS-WSERV-0034
496 @SYMTestCaseDesc Test that the order of creating a screen device and window group does not matter.
498 @SYMTestPriority High
500 @SYMTestStatus Implemented
502 @SYMTestActions Create a window group before creating the screen device. Create a graphics context and call activate on it.
504 TInt RWindowGroup::Construct(TUint32 aClientHandle)
505 TInt CWsScreenDevice::Construct()
506 void CWindowGc::Activate(RDrawableWindow &aDevice);
507 void CWindowGc::Deactivate();
508 TInt RWindow::Construct(const RWindowTreeNode &parent,TUint32 aHandle);
510 @SYMTestExpectedResults The test code does not panic with EWservPanicGroupWinScreenDeviceDeleted
512 void CTMulScreens::TestInitaliseScreenDeviceL()
515 User::LeaveIfError(rws1.Connect());
516 CleanupClosePushL(rws1);
518 RWindowGroup gw1(rws1);
519 User::LeaveIfError(gw1.Construct(ENullWsHandle));
520 CleanupClosePushL(gw1);
522 CWsScreenDevice* screen1 = new (ELeave) CWsScreenDevice(rws1);
523 User::LeaveIfError(screen1->Construct());
524 CleanupStack::PushL(screen1);
527 User::LeaveIfError(win1.Construct(gw1,ETrue));
528 CleanupClosePushL(win1);
531 CWindowGc* gc=new (ELeave) CWindowGc(screen1);
532 User::LeaveIfError(gc->Construct());
533 CleanupStack::PushL(gc);
536 CleanupStack::PopAndDestroy(5,&rws1);
540 @SYMTestCaseID GRAPHICS-WSERV-0492
544 @SYMTestCaseDesc Test the screen number that a window is located on
546 @SYMTestPriority Medium
548 @SYMTestStatus Implemented
550 @SYMTestActions Create two windows on two screens respectively
551 and check the screen number that each window is located on
553 @SYMTestExpectedResults The screen numbers should match the expected ones
555 void CTMulScreens::TestScreenNumbersOfWindowsL()
558 RWindow fstWin(iRws);
559 CleanupClosePushL(fstWin);
560 TRAPD(err,fstWin.Construct(iFstWinGp,ENullWsHandle));
567 TEST(fstWin.ScreenNumber()==KFstScreenNo);
568 CleanupStack::PopAndDestroy();//fstWin
571 if(KSndScreenNo<iNumScreens)
573 RWindow sndWin(iRws);
574 CleanupClosePushL(sndWin);
575 TRAP(err,sndWin.Construct(iSndWinGp,ENullWsHandle));
582 TEST(sndWin.ScreenNumber()==KSndScreenNo);
583 CleanupStack::PopAndDestroy(); //sndWin
587 void CTMulScreens::RunTestCaseL(TInt aCurTestCase)
589 _LIT(KTest0,"Create a window group on each screen");
590 _LIT(KTest1,"Create a blank window on each screen");
591 _LIT(KTest2,"Get focus window");
592 _LIT(KTest3,"Get default owning window");
593 _LIT(KTest4,"Change background colour");
594 _LIT(KTest5,"Change shadow vector");
595 _LIT(KTest6,"Panic Tests");
596 _LIT(KTest7,"Test device pointer returned by GC");
597 _LIT(KTest8,"Initialise ScreenDevice");
598 _LIT(KTest9,"Test screen numbers that windows are located on");
599 ((CTMulScreensStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
604 ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0383"));
605 INFO_PRINTF1(KTest0);
606 TestCreateGroupWindowsL();
609 ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0384"));
610 INFO_PRINTF1(KTest1);
611 TestCreateBlankWindowsL();
614 ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0385"));
615 INFO_PRINTF1(KTest2);
616 TestGetFocusWindow();
618 ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0386"));
619 INFO_PRINTF1(KTest3);
620 TestGetDefaultOwningWindow();
623 ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0387"));
624 INFO_PRINTF1(KTest4);
625 TestSetBackgroundColour();
628 ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0388"));
629 INFO_PRINTF1(KTest5);
630 TestSetShadowVector();
633 ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0389"));
634 INFO_PRINTF1(KTest6);
638 ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0390"));
639 INFO_PRINTF1(KTest7);
643 ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0034"));
644 INFO_PRINTF1(KTest8);
645 TestInitaliseScreenDeviceL();
648 ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0492"));
649 INFO_PRINTF1(KTest9);
650 TestScreenNumbersOfWindowsL();
652 ((CTMulScreensStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
653 ((CTMulScreensStep*)iStep)->CloseTMSGraphicsStep();
654 INFO_PRINTF1(_L("All tests completed.\n"));
658 ((CTMulScreensStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
659 ((CTMulScreensStep*)iStep)->CloseTMSGraphicsStep();
660 INFO_PRINTF1(_L("CTMulScreens::RunTestCaseL default case\n"));
663 ((CTMulScreensStep*)iStep)->RecordTestResultL();
666 __WS_CONSTRUCT_STEP__(MulScreens)