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 // Test multiple connections to the window server
21 @internalComponent - Internal Symbian test code
26 const TInt EMaxSubState=3;
28 //#define LOGGING on //Uncomment this line to get extra logging
30 _LIT(ClickOnMe,"Click on me");
34 CTMultiCon::CTMultiCon(CTestStep* aStep) : CTWsGraphicsBase(aStep)
38 CTMultiCon::~CTMultiCon()
46 void CTMultiCon::EndAutoForegroundTest()
49 _LIT(KLog,"EndAutoForegroundTest SubState %d");
50 LOG_MESSAGE2(KLog,iSubState);
52 iConn1->iGroup->GroupWin()->EnableReceiptOfFocus(EFalse);
53 iConn2->iGroup->GroupWin()->EnableReceiptOfFocus(EFalse);
54 iConn3->iGroup->GroupWin()->EnableReceiptOfFocus(EFalse);
55 CActiveScheduler::Stop();
58 void CTMultiCon::ConstructL()
60 iTimeOut=new(ELeave) CTimeOut();
61 iTimeOut->ConstructL();
62 TheClient->iWs.SetPointerCursorArea(iTest->iNormalPointerCursorArea);
63 iScreenSize=TSize(TheClient->iScreen->SizeInPixels());
64 iConn3=new(ELeave) CMcConnectionDef(this);
66 iConn2=new(ELeave) CMcConnection(this);
68 iConn1=new(ELeave) CMcConnectionAf(this);
70 iTest->SimulateKeyDownUp(EStdKeyLeftCtrl);
71 iTest->SimulateKeyDownUp(EStdKeyRightCtrl);
72 TInt mods=TheClient->iWs.GetModifierState();
73 _LIT(KLog,"Initial Modifiers state 0x%x (ideally should be zero)");
74 LOG_MESSAGE2(KLog,mods);
77 TInt CTMultiCon::TimeOut(TAny* aTest) //static
79 static_cast<CTMultiCon*>(aTest)->TimeOut();
83 void CTMultiCon::TimeOut()
86 _LIT(KMultiConTimeOut,"TIMEOUT: Multiple Conection Test, %d, %S");
87 buf.AppendFormat(KMultiConTimeOut,iTest->iState,&iTest->iSubTitle);
88 TheClient->LogMessage(buf);
90 EndAutoForegroundTest();
98 CMcConnectionBase::CMcConnectionBase(CTMultiCon *aTest) : iTest(aTest)
102 CMcConnectionBase::~CMcConnectionBase()
108 void CMcConnectionBase::SubStateChanged()
114 void CMcConnectionBase::ConstructL()
116 CTClient::SetScreenNumber(iTest->ScreenNumber());
117 CTClient::ConstructL();
118 User::LeaveIfError(iScreen->CreateContext(iGc));
121 CMcConnection::CMcConnection(CTMultiCon *aTest) : CMcConnectionBase(aTest)
125 void CMcConnection::ConstructL()
127 CMcConnectionBase::ConstructL();
128 iGroup=new(ELeave) CTWindowGroup(this);
129 iGroup->ConstructL();
130 TSize screenSize=iGroup->Size();
131 TInt winWidth=screenSize.iWidth/3;
132 TInt winHeight=screenSize.iHeight/2-10;
133 iGroup->GroupWin()->AutoForeground(EFalse);
134 CMcWindow *win=new(ELeave) CMcWindow(iTest);
135 win->SetUpL(TPoint(5,5),TSize(winWidth,winHeight),iGroup,*iGc);
140 CMcConnectionAf::CMcConnectionAf(CTMultiCon *aTest) : CMcConnectionBase(aTest)
144 void CMcConnectionAf::ConstructL()
146 CMcConnectionBase::ConstructL();
147 iGroup=new(ELeave) CMcWindowGroupAf(this);
148 iGroup->ConstructL();
149 TSize screenSize=iGroup->Size();
150 TInt winWidth=screenSize.iWidth/3;
151 TInt winHeight=screenSize.iHeight/2-10;
152 iGroup->GroupWin()->AutoForeground(ETrue);
153 CMcWindowAf *win=new(ELeave) CMcWindowAf(iTest);
154 win->SetUpL(TPoint(winWidth,5),TSize(winWidth,winHeight),iGroup,*iGc);
159 void CMcConnectionAf::KeyL(const TKeyEvent &aKey)
162 _LIT(KLog1,"KeyL SS=%d (0) GpWinOrdPos=%d (0) Code=%d (32)");
165 buf.Format(KLog1,iTest->SubState(),iGroup->GroupWin()->OrdinalPosition(),aKey.iCode);
167 buf.AppendFormat(KLog2,aKey.iCode);
168 iTest->LOG_MESSAGE(buf);
173 if (iTest->SubState()==0)
175 iTest->TEST(iGroup->GroupWin()->OrdinalPosition()==0);
176 iTest->IncSubState();
180 iTest->EndAutoForegroundTest();
185 CMcConnectionDef::CMcConnectionDef(CTMultiCon *aTest) : CMcConnectionBase(aTest)
189 void CMcConnectionDef::ConstructL()
191 CMcConnectionBase::ConstructL();
192 iGroup=new(ELeave) CTWindowGroup(this);
193 iGroup->ConstructL();
194 iGroup->GroupWin()->EnableReceiptOfFocus(EFalse);
195 TSize screenSize=iGroup->Size();
196 TInt winWidth=screenSize.iWidth/3-10;
197 TInt winHeight=(screenSize.iHeight/2)-10;
198 CMcWindowDef *win=new(ELeave) CMcWindowDef(iTest);
199 win->SetUpL(TPoint(5+winWidth/2,screenSize.iHeight/2),TSize(winWidth,winHeight),iGroup,*iGc);
205 // CMcWindow, base class //
208 CMcWindowBase::CMcWindowBase(CTMultiCon *aTest) : CTWin(), iTest(aTest)
212 void CMcWindowBase::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc)
214 ConstructExtLD(*parent,pos,size);
215 iWin.SetBackgroundColor(iBack);
221 // CMcWindow, window used to test multiple connections //
224 CMcWindow::CMcWindow(CTMultiCon *aTest) : CMcWindowBase(aTest)
226 iBack=TRgb::Gray256(221);
229 void CMcWindow::PointerL(const TPointerEvent &pointer,const TTime &)
232 _LIT(KLog,"Pointer SS=%d (1) Type=%d (%d) GpWinOrdPos=%d (1)");
233 iTest->LOG_MESSAGE5(KLog,iTest->SubState(),pointer.iType,TPointerEvent::EButton1Down,Client()->iGroup->GroupWin()->OrdinalPosition());
235 if (pointer.iType==TPointerEvent::EButton1Down)
237 switch(iTest->SubState())
240 iTest->TEST(Client()->iGroup->GroupWin()->OrdinalPosition()==1);
241 iTest->IncSubState();
247 void CMcWindow::Draw()
251 switch(iTest->SubState())
264 iGc->DrawText(buf, TPoint(10,20));
268 // CMcWindowAf, Auto foreground version of CMcWindow //
271 CMcWindowAf::CMcWindowAf(CTMultiCon *aTest) : CMcWindowBase(aTest)
273 iBack=TRgb::Gray256(150);
276 void CMcWindowAf::PointerL(const TPointerEvent &pointer,const TTime &)
279 _LIT(KLog,"PointerL SS=%d (2) Type=%d (%d) GpWinOrdPos=%d (0)");
280 iTest->LOG_MESSAGE5(KLog,iTest->SubState(),pointer.iType,TPointerEvent::EButton1Down,Client()->iGroup->GroupWin()->OrdinalPosition());
282 if (pointer.iType==TPointerEvent::EButton1Down)
284 switch(iTest->SubState())
287 iTest->TEST(Client()->iGroup->GroupWin()->OrdinalPosition()==0);
288 iTest->IncSubState();
294 void CMcWindowAf::Draw()
296 _LIT(PressSpace,"Press <Space>");
299 switch(iTest->SubState())
305 buf.Copy(PressSpace);
313 iGc->DrawText(buf, TPoint(10,20));
318 CMcWindowGroupAf::CMcWindowGroupAf(CTClient *aClient) : CTWindowGroup(aClient)
321 void CMcWindowGroupAf::KeyL(const TKeyEvent &aKey, const TTime &)
323 ((CMcConnectionAf *)iClient)->KeyL(aKey);
327 // CMcWindowDef, Default auto foreground version of CMcWindow //
330 CMcWindowDef::CMcWindowDef(CTMultiCon *aTest) : CMcWindowBase(aTest)
332 iBack=TRgb::Gray256(236);
335 void CMcWindowDef::PointerL(const TPointerEvent &pointer,const TTime &)
338 _LIT(KLog,"PointerL SS=%d (3) Type=%d (%d) GpWinOrdPos=%d (0)");
339 iTest->LOG_MESSAGE5(KLog,iTest->SubState(),pointer.iType,TPointerEvent::EButton1Down,Client()->iGroup->GroupWin()->OrdinalPosition());
341 if (pointer.iType==TPointerEvent::EButton1Down)
343 switch(iTest->SubState())
346 iTest->TEST(Client()->iGroup->GroupWin()->OrdinalPosition()==0);
347 iTest->IncSubState();
353 void CMcWindowDef::Draw()
357 switch(iTest->SubState())
369 iGc->DrawText(buf, TPoint(10,20));
374 TInt CTMultiCon::SubState() const
379 void CTMultiCon::IncSubState()
381 if (iSubState==EMaxSubState)
382 EndAutoForegroundTest();
387 _LIT(KLog,"New SubState %d");
388 LOG_MESSAGE2(KLog,iSubState);
390 iConn1->SubStateChanged();
391 iConn2->SubStateChanged();
392 iConn3->SubStateChanged();
393 TheClient->WaitForRedrawsToFinish();
398 void CTMultiCon::SendEvents()
401 _LIT(KLog,"Sending event for substate %d");
402 LOG_MESSAGE2(KLog,iSubState);
408 iTest->SimulateKeyDownUp(EStdKeySpace);
411 iTest->SimulatePointerDownUp(iScreenSize.iWidth/6+5,iScreenSize.iHeight/4);
414 iTest->SimulatePointerDownUp(iScreenSize.iWidth/2,iScreenSize.iHeight/4);
417 iTest->SimulatePointerDownUp(iScreenSize.iWidth/3,3*iScreenSize.iHeight/4-5);
422 TheClient->iWs.Flush();
425 void CTMultiCon::RunTestCaseL(TInt /*aCurTestCase*/)
427 _LIT(KTestMultiCon1,"MultiCon 1");
428 _LIT(KTimeOut,"Test Timed Out after %dsecs. SubState=%d");
429 ((CTMultiConStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
431 if (!TestBase()->ConfigurationSupportsPointerEventTesting())
433 INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing"));
438 switch(++iTest->iState)
442 @SYMTestCaseID GRAPHICS-WSERV-0289
446 @SYMTestCaseDesc Test multiple connections to the window server
448 @SYMTestPriority High
450 @SYMTestStatus Implemented
452 @SYMTestActions Make mutiple connections to the window server and check
453 that the connections are made corectly
455 @SYMTestExpectedResults The connections are made correctly
459 ((CTMultiConStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0289"));
460 iTest->LogSubTest(KTestMultiCon1);
461 iTimeOut->Start(KTimeOutAfter,TCallBack(CTMultiCon::TimeOut,this));
463 CActiveScheduler::Start();
465 TEST(iTimeOutCount==0);
466 if (iTimeOutCount!=0)
467 LOG_MESSAGE3(KTimeOut,KTimeOutAfter/1000000,iSubState);
470 ((CTMultiConStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
471 ((CTMultiConStep*)iStep)->CloseTMSGraphicsStep();
475 ((CTMultiConStep*)iStep)->RecordTestResultL();
478 __WS_CONSTRUCT_STEP__(MultiCon)