|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Test multiple connections to the window server |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @test |
|
21 @internalComponent - Internal Symbian test code |
|
22 */ |
|
23 |
|
24 #include "TMULTCON.H" |
|
25 |
|
26 const TInt EMaxSubState=3; |
|
27 |
|
28 //#define LOGGING on //Uncomment this line to get extra logging |
|
29 |
|
30 _LIT(ClickOnMe,"Click on me"); |
|
31 _LIT(KError,"ERROR"); |
|
32 |
|
33 |
|
34 CTMultiCon::CTMultiCon(CTestStep* aStep) : CTWsGraphicsBase(aStep) |
|
35 { |
|
36 } |
|
37 |
|
38 CTMultiCon::~CTMultiCon() |
|
39 { |
|
40 delete iConn1; |
|
41 delete iConn2; |
|
42 delete iConn3; |
|
43 delete iTimeOut; |
|
44 } |
|
45 |
|
46 void CTMultiCon::EndAutoForegroundTest() |
|
47 { |
|
48 #if defined(LOGGING) |
|
49 _LIT(KLog,"EndAutoForegroundTest SubState %d"); |
|
50 LOG_MESSAGE2(KLog,iSubState); |
|
51 #endif |
|
52 iConn1->iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); |
|
53 iConn2->iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); |
|
54 iConn3->iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); |
|
55 CActiveScheduler::Stop(); |
|
56 } |
|
57 |
|
58 void CTMultiCon::ConstructL() |
|
59 { |
|
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); |
|
65 iConn3->ConstructL(); |
|
66 iConn2=new(ELeave) CMcConnection(this); |
|
67 iConn2->ConstructL(); |
|
68 iConn1=new(ELeave) CMcConnectionAf(this); |
|
69 iConn1->ConstructL(); |
|
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); |
|
75 } |
|
76 |
|
77 TInt CTMultiCon::TimeOut(TAny* aTest) //static |
|
78 { |
|
79 static_cast<CTMultiCon*>(aTest)->TimeOut(); |
|
80 return(KErrNone); |
|
81 } |
|
82 |
|
83 void CTMultiCon::TimeOut() |
|
84 { |
|
85 TLogMessageText buf; |
|
86 _LIT(KMultiConTimeOut,"TIMEOUT: Multiple Conection Test, %d, %S"); |
|
87 buf.AppendFormat(KMultiConTimeOut,iTest->iState,&iTest->iSubTitle); |
|
88 TheClient->LogMessage(buf); |
|
89 ++iTimeOutCount; |
|
90 EndAutoForegroundTest(); |
|
91 } |
|
92 |
|
93 |
|
94 // |
|
95 // CMcConnection // |
|
96 // |
|
97 |
|
98 CMcConnectionBase::CMcConnectionBase(CTMultiCon *aTest) : iTest(aTest) |
|
99 { |
|
100 } |
|
101 |
|
102 CMcConnectionBase::~CMcConnectionBase() |
|
103 { |
|
104 CTWin::Delete(iWin); |
|
105 delete iGc; |
|
106 } |
|
107 |
|
108 void CMcConnectionBase::SubStateChanged() |
|
109 { |
|
110 iWin->Invalidate(); |
|
111 iWs.Flush(); |
|
112 } |
|
113 |
|
114 void CMcConnectionBase::ConstructL() |
|
115 { |
|
116 CTClient::SetScreenNumber(iTest->ScreenNumber()); |
|
117 CTClient::ConstructL(); |
|
118 User::LeaveIfError(iScreen->CreateContext(iGc)); |
|
119 } |
|
120 |
|
121 CMcConnection::CMcConnection(CTMultiCon *aTest) : CMcConnectionBase(aTest) |
|
122 { |
|
123 } |
|
124 |
|
125 void CMcConnection::ConstructL() |
|
126 { |
|
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); |
|
136 iWin=win; |
|
137 iWs.Flush(); |
|
138 } |
|
139 |
|
140 CMcConnectionAf::CMcConnectionAf(CTMultiCon *aTest) : CMcConnectionBase(aTest) |
|
141 { |
|
142 } |
|
143 |
|
144 void CMcConnectionAf::ConstructL() |
|
145 { |
|
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); |
|
155 iWin=win; |
|
156 iWs.Flush(); |
|
157 } |
|
158 |
|
159 void CMcConnectionAf::KeyL(const TKeyEvent &aKey) |
|
160 { |
|
161 #if defined(LOGGING) |
|
162 _LIT(KLog1,"KeyL SS=%d (0) GpWinOrdPos=%d (0) Code=%d (32)"); |
|
163 _LIT(KLog2," '%c'"); |
|
164 TLogMessageText buf; |
|
165 buf.Format(KLog1,iTest->SubState(),iGroup->GroupWin()->OrdinalPosition(),aKey.iCode); |
|
166 if (aKey.iCode>0) |
|
167 buf.AppendFormat(KLog2,aKey.iCode); |
|
168 iTest->LOG_MESSAGE(buf); |
|
169 #endif |
|
170 switch(aKey.iCode) |
|
171 { |
|
172 case ' ': |
|
173 if (iTest->SubState()==0) |
|
174 { |
|
175 iTest->TEST(iGroup->GroupWin()->OrdinalPosition()==0); |
|
176 iTest->IncSubState(); |
|
177 } |
|
178 break; |
|
179 case EKeyEscape: |
|
180 iTest->EndAutoForegroundTest(); |
|
181 break; |
|
182 } |
|
183 } |
|
184 |
|
185 CMcConnectionDef::CMcConnectionDef(CTMultiCon *aTest) : CMcConnectionBase(aTest) |
|
186 { |
|
187 } |
|
188 |
|
189 void CMcConnectionDef::ConstructL() |
|
190 { |
|
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); |
|
200 iWin=win; |
|
201 iWs.Flush(); |
|
202 } |
|
203 |
|
204 // |
|
205 // CMcWindow, base class // |
|
206 // |
|
207 |
|
208 CMcWindowBase::CMcWindowBase(CTMultiCon *aTest) : CTWin(), iTest(aTest) |
|
209 { |
|
210 } |
|
211 |
|
212 void CMcWindowBase::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) |
|
213 { |
|
214 ConstructExtLD(*parent,pos,size); |
|
215 iWin.SetBackgroundColor(iBack); |
|
216 Activate(); |
|
217 AssignGC(aGc); |
|
218 } |
|
219 |
|
220 // |
|
221 // CMcWindow, window used to test multiple connections // |
|
222 // |
|
223 |
|
224 CMcWindow::CMcWindow(CTMultiCon *aTest) : CMcWindowBase(aTest) |
|
225 { |
|
226 iBack=TRgb::Gray256(221); |
|
227 } |
|
228 |
|
229 void CMcWindow::PointerL(const TPointerEvent &pointer,const TTime &) |
|
230 { |
|
231 #if defined(LOGGING) |
|
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()); |
|
234 #endif |
|
235 if (pointer.iType==TPointerEvent::EButton1Down) |
|
236 { |
|
237 switch(iTest->SubState()) |
|
238 { |
|
239 case 1: |
|
240 iTest->TEST(Client()->iGroup->GroupWin()->OrdinalPosition()==1); |
|
241 iTest->IncSubState(); |
|
242 break; |
|
243 } |
|
244 } |
|
245 } |
|
246 |
|
247 void CMcWindow::Draw() |
|
248 { |
|
249 iGc->Clear(); |
|
250 TBuf<0x40> buf; |
|
251 switch(iTest->SubState()) |
|
252 { |
|
253 case 1: |
|
254 buf.Copy(ClickOnMe); |
|
255 break; |
|
256 case 0: |
|
257 case 2: |
|
258 case 3: |
|
259 buf.Copy(KNullDesC); |
|
260 break; |
|
261 default: |
|
262 buf.Copy(KError); |
|
263 } |
|
264 iGc->DrawText(buf, TPoint(10,20)); |
|
265 } |
|
266 |
|
267 // |
|
268 // CMcWindowAf, Auto foreground version of CMcWindow // |
|
269 // |
|
270 |
|
271 CMcWindowAf::CMcWindowAf(CTMultiCon *aTest) : CMcWindowBase(aTest) |
|
272 { |
|
273 iBack=TRgb::Gray256(150); |
|
274 } |
|
275 |
|
276 void CMcWindowAf::PointerL(const TPointerEvent &pointer,const TTime &) |
|
277 { |
|
278 #if defined(LOGGING) |
|
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()); |
|
281 #endif |
|
282 if (pointer.iType==TPointerEvent::EButton1Down) |
|
283 { |
|
284 switch(iTest->SubState()) |
|
285 { |
|
286 case 2: |
|
287 iTest->TEST(Client()->iGroup->GroupWin()->OrdinalPosition()==0); |
|
288 iTest->IncSubState(); |
|
289 break; |
|
290 } |
|
291 } |
|
292 } |
|
293 |
|
294 void CMcWindowAf::Draw() |
|
295 { |
|
296 _LIT(PressSpace,"Press <Space>"); |
|
297 iGc->Clear(); |
|
298 TBuf<0x40> buf; |
|
299 switch(iTest->SubState()) |
|
300 { |
|
301 case 1: |
|
302 case 3: |
|
303 break; |
|
304 case 0: |
|
305 buf.Copy(PressSpace); |
|
306 break; |
|
307 case 2: |
|
308 buf.Copy(ClickOnMe); |
|
309 break; |
|
310 default: |
|
311 buf.Copy(KError); |
|
312 } |
|
313 iGc->DrawText(buf, TPoint(10,20)); |
|
314 } |
|
315 |
|
316 // |
|
317 |
|
318 CMcWindowGroupAf::CMcWindowGroupAf(CTClient *aClient) : CTWindowGroup(aClient) |
|
319 {} |
|
320 |
|
321 void CMcWindowGroupAf::KeyL(const TKeyEvent &aKey, const TTime &) |
|
322 { |
|
323 ((CMcConnectionAf *)iClient)->KeyL(aKey); |
|
324 } |
|
325 |
|
326 // |
|
327 // CMcWindowDef, Default auto foreground version of CMcWindow // |
|
328 // |
|
329 |
|
330 CMcWindowDef::CMcWindowDef(CTMultiCon *aTest) : CMcWindowBase(aTest) |
|
331 { |
|
332 iBack=TRgb::Gray256(236); |
|
333 } |
|
334 |
|
335 void CMcWindowDef::PointerL(const TPointerEvent &pointer,const TTime &) |
|
336 { |
|
337 #if defined(LOGGING) |
|
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()); |
|
340 #endif |
|
341 if (pointer.iType==TPointerEvent::EButton1Down) |
|
342 { |
|
343 switch(iTest->SubState()) |
|
344 { |
|
345 case 3: |
|
346 iTest->TEST(Client()->iGroup->GroupWin()->OrdinalPosition()==0); |
|
347 iTest->IncSubState(); |
|
348 break; |
|
349 } |
|
350 } |
|
351 } |
|
352 |
|
353 void CMcWindowDef::Draw() |
|
354 { |
|
355 iGc->Clear(); |
|
356 TBuf<0x40> buf; |
|
357 switch(iTest->SubState()) |
|
358 { |
|
359 case 0: |
|
360 case 1: |
|
361 case 2: |
|
362 break; |
|
363 case 3: |
|
364 buf.Copy(ClickOnMe); |
|
365 break; |
|
366 default: |
|
367 buf.Copy(KError); |
|
368 } |
|
369 iGc->DrawText(buf, TPoint(10,20)); |
|
370 } |
|
371 |
|
372 // |
|
373 |
|
374 TInt CTMultiCon::SubState() const |
|
375 { |
|
376 return(iSubState); |
|
377 } |
|
378 |
|
379 void CTMultiCon::IncSubState() |
|
380 { |
|
381 if (iSubState==EMaxSubState) |
|
382 EndAutoForegroundTest(); |
|
383 else |
|
384 { |
|
385 iSubState++; |
|
386 #if defined(LOGGING) |
|
387 _LIT(KLog,"New SubState %d"); |
|
388 LOG_MESSAGE2(KLog,iSubState); |
|
389 #endif |
|
390 iConn1->SubStateChanged(); |
|
391 iConn2->SubStateChanged(); |
|
392 iConn3->SubStateChanged(); |
|
393 TheClient->WaitForRedrawsToFinish(); |
|
394 SendEvents(); |
|
395 } |
|
396 } |
|
397 |
|
398 void CTMultiCon::SendEvents() |
|
399 { |
|
400 #if defined(LOGGING) |
|
401 _LIT(KLog,"Sending event for substate %d"); |
|
402 LOG_MESSAGE2(KLog,iSubState); |
|
403 #endif |
|
404 |
|
405 switch (iSubState) |
|
406 { |
|
407 case 0: |
|
408 iTest->SimulateKeyDownUp(EStdKeySpace); |
|
409 break; |
|
410 case 1: |
|
411 iTest->SimulatePointerDownUp(iScreenSize.iWidth/6+5,iScreenSize.iHeight/4); |
|
412 break; |
|
413 case 2: |
|
414 iTest->SimulatePointerDownUp(iScreenSize.iWidth/2,iScreenSize.iHeight/4); |
|
415 break; |
|
416 case 3: |
|
417 iTest->SimulatePointerDownUp(iScreenSize.iWidth/3,3*iScreenSize.iHeight/4-5); |
|
418 break; |
|
419 default: |
|
420 TEST(EFalse); |
|
421 } |
|
422 TheClient->iWs.Flush(); |
|
423 } |
|
424 |
|
425 void CTMultiCon::RunTestCaseL(TInt /*aCurTestCase*/) |
|
426 { |
|
427 _LIT(KTestMultiCon1,"MultiCon 1"); |
|
428 _LIT(KTimeOut,"Test Timed Out after %dsecs. SubState=%d"); |
|
429 ((CTMultiConStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); |
|
430 |
|
431 if (!TestBase()->ConfigurationSupportsPointerEventTesting()) |
|
432 { |
|
433 INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing")); |
|
434 TestComplete(); |
|
435 return; |
|
436 } |
|
437 |
|
438 switch(++iTest->iState) |
|
439 { |
|
440 /** |
|
441 |
|
442 @SYMTestCaseID GRAPHICS-WSERV-0289 |
|
443 |
|
444 @SYMDEF DEF081259 |
|
445 |
|
446 @SYMTestCaseDesc Test multiple connections to the window server |
|
447 |
|
448 @SYMTestPriority High |
|
449 |
|
450 @SYMTestStatus Implemented |
|
451 |
|
452 @SYMTestActions Make mutiple connections to the window server and check |
|
453 that the connections are made corectly |
|
454 |
|
455 @SYMTestExpectedResults The connections are made correctly |
|
456 |
|
457 */ |
|
458 case 1: |
|
459 ((CTMultiConStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0289")); |
|
460 iTest->LogSubTest(KTestMultiCon1); |
|
461 iTimeOut->Start(KTimeOutAfter,TCallBack(CTMultiCon::TimeOut,this)); |
|
462 SendEvents(); |
|
463 CActiveScheduler::Start(); |
|
464 iTimeOut->Cancel(); |
|
465 TEST(iTimeOutCount==0); |
|
466 if (iTimeOutCount!=0) |
|
467 LOG_MESSAGE3(KTimeOut,KTimeOutAfter/1000000,iSubState); |
|
468 break; |
|
469 default: |
|
470 ((CTMultiConStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); |
|
471 ((CTMultiConStep*)iStep)->CloseTMSGraphicsStep(); |
|
472 TestComplete(); |
|
473 break; |
|
474 } |
|
475 ((CTMultiConStep*)iStep)->RecordTestResultL(); |
|
476 } |
|
477 |
|
478 __WS_CONSTRUCT_STEP__(MultiCon) |