|
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 pointer capture |
|
15 // |
|
16 // |
|
17 |
|
18 #include <e32std.h> |
|
19 #include <e32svr.h> |
|
20 #include "W32STD.H" |
|
21 #include "../tlib/testbase.h" |
|
22 #include "TMAN.H" |
|
23 |
|
24 enum TTestState |
|
25 { |
|
26 ECaptureDisabled, |
|
27 ENormalCapture, |
|
28 ECaptureAllGroups, |
|
29 EDragDropCapture, |
|
30 EDragDropCaptureAllGroups, |
|
31 ENormalCaptureWithoutFocus, |
|
32 }; |
|
33 |
|
34 enum TTestSubState |
|
35 { |
|
36 EMainWindow, |
|
37 EChildWindow, |
|
38 EOtherGroup, |
|
39 EOtherSession, |
|
40 ERootWindow, |
|
41 }; |
|
42 |
|
43 enum TPointerCheckRet |
|
44 { |
|
45 EFailed, |
|
46 EOkay, |
|
47 ENeedsDDEvent, |
|
48 }; |
|
49 |
|
50 const TInt ESubStates1=2; |
|
51 const TInt ESubStates2=5; |
|
52 const TInt ESubStates3=5; |
|
53 const TInt ESubStates4=5; |
|
54 const TInt ESubStates5=5; |
|
55 const TInt ESubStates6=5; |
|
56 |
|
57 const TInt EWinBorderSize=10; |
|
58 |
|
59 class CPcWindowBase; |
|
60 class TPointerCaptureTest; |
|
61 |
|
62 class CPcConnection : public CTClient |
|
63 { |
|
64 public: |
|
65 CPcConnection(TPointerCaptureTest *aTest); |
|
66 ~CPcConnection(); |
|
67 virtual void ConstructL(); |
|
68 protected: |
|
69 TPointerCaptureTest *iTest; |
|
70 }; |
|
71 |
|
72 class CPcWindowBase : public CTWin |
|
73 { |
|
74 public: |
|
75 CPcWindowBase(TPointerCaptureTest *aTest); |
|
76 void SetUpL(TPoint pos,TSize size,CTWinBase *parent); |
|
77 void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); |
|
78 void Draw(TDesC &aBuf); |
|
79 void PointerL(const TPointerEvent &pointer,const TTime &); |
|
80 void DragDropL(const TPointerEvent &pointer,const TTime &); |
|
81 virtual TPointerCheckRet PointerDown()=0; |
|
82 virtual TPointerCheckRet DragDrop()=0; |
|
83 virtual void SubStateChanged(); |
|
84 protected: |
|
85 TPointerCaptureTest *iTest; |
|
86 TRgb iBack; |
|
87 }; |
|
88 |
|
89 class CPcWindowChild : public CPcWindowBase |
|
90 { |
|
91 public: |
|
92 CPcWindowChild(TPointerCaptureTest *aTest); |
|
93 void Draw(); |
|
94 TPointerCheckRet PointerDown(); |
|
95 TPointerCheckRet DragDrop(); |
|
96 }; |
|
97 |
|
98 class CPcWindowMain : public CPcWindowBase |
|
99 { |
|
100 public: |
|
101 CPcWindowMain(TPointerCaptureTest *aTest); |
|
102 void Draw(); |
|
103 TPointerCheckRet PointerDown(); |
|
104 TPointerCheckRet DragDrop(); |
|
105 void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); |
|
106 }; |
|
107 |
|
108 class CPcWindowAltGroup : public CPcWindowBase |
|
109 { |
|
110 public: |
|
111 CPcWindowAltGroup(TPointerCaptureTest *aTest); |
|
112 void Draw(); |
|
113 TPointerCheckRet PointerDown(); |
|
114 TPointerCheckRet DragDrop(); |
|
115 }; |
|
116 |
|
117 class CPcWindowNickFocusGroup : public CTWindowGroup |
|
118 { |
|
119 public: |
|
120 CPcWindowNickFocusGroup(TPointerCaptureTest *aTest, CTClient *aClient); |
|
121 void KeyL(const TKeyEvent &aKey,const TTime &aTime); |
|
122 private: |
|
123 TPointerCaptureTest *iTest; |
|
124 }; |
|
125 |
|
126 class CPcWindowAltConnection : public CPcWindowBase |
|
127 { |
|
128 public: |
|
129 CPcWindowAltConnection(TPointerCaptureTest *aTest); |
|
130 void Draw(); |
|
131 TPointerCheckRet PointerDown(); |
|
132 TPointerCheckRet DragDrop(); |
|
133 }; |
|
134 |
|
135 class TPointerCaptureTest : public CTestBase |
|
136 { |
|
137 private: |
|
138 enum TDState {DDStateNull, DDStateGot, DDStateWaiting}; |
|
139 public: |
|
140 TPointerCaptureTest(); |
|
141 ~TPointerCaptureTest(); |
|
142 TestState DoTestL(); |
|
143 void ConstructL(); |
|
144 void NextTest(); |
|
145 void AbortTests(); |
|
146 TInt State() const; |
|
147 TInt SubState() const; |
|
148 void doIncSubState(); |
|
149 void IncSubState(TBool aNeedsDD=EFalse); |
|
150 void GotDD(); |
|
151 void StateChanged(); |
|
152 void TestFailed(); |
|
153 void NickFocusL(); |
|
154 void SetCapture(TInt aCaptureFlags); |
|
155 void RestartTest(); |
|
156 private: |
|
157 TInt doTestFailedL(); |
|
158 private: |
|
159 CPcConnection *iAltConnection; |
|
160 CTWindowGroup *iMainGroup; |
|
161 CTWindowGroup *iAltGroup; |
|
162 CPcWindowChild *iChildWin; |
|
163 CPcWindowMain *iMainWin; |
|
164 CPcWindowAltGroup *iAltGroupWin; |
|
165 CPcWindowAltConnection *iAltConnectionWin; |
|
166 CPcWindowNickFocusGroup *iNickFocusGroup; |
|
167 CTBlankWindow *iNickFocusBlankWin; |
|
168 TInt iState; |
|
169 TInt iSubState; |
|
170 TDState iDDState; |
|
171 public: |
|
172 TBool iFailed; |
|
173 }; |
|
174 |
|
175 GLDEF_C CTestBase *CreatePointerCaptureTest() |
|
176 { |
|
177 return(new(ELeave) TPointerCaptureTest()); |
|
178 } |
|
179 |
|
180 // |
|
181 // CMcConnection |
|
182 |
|
183 CPcConnection::CPcConnection(TPointerCaptureTest *aTest) : iTest(aTest) |
|
184 { |
|
185 } |
|
186 |
|
187 CPcConnection::~CPcConnection() |
|
188 { |
|
189 } |
|
190 |
|
191 void CPcConnection::ConstructL() |
|
192 { |
|
193 CTClient::ConstructL(); |
|
194 iGroup=new(ELeave) CTWindowGroup(this); |
|
195 iGroup->ConstructL(); |
|
196 iGroup->GroupWin()->SetOrdinalPosition(0,1); |
|
197 iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); |
|
198 iWs.Flush(); |
|
199 } |
|
200 |
|
201 // |
|
202 // CPcWindow, base class // |
|
203 // |
|
204 |
|
205 CPcWindowBase::CPcWindowBase(TPointerCaptureTest *aTest) : CTWin(), iTest(aTest) |
|
206 { |
|
207 } |
|
208 |
|
209 void CPcWindowBase::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) |
|
210 { |
|
211 ConstructExtLD(*parent,pos,size); |
|
212 iWin.SetBackgroundColor(iBack); |
|
213 Activate(); |
|
214 AssignGC(aGc); |
|
215 } |
|
216 |
|
217 void CPcWindowBase::SetUpL(TPoint pos,TSize size,CTWinBase *parent) |
|
218 { |
|
219 SetUpL(pos,size,parent,*iTest->Client()->iGc); |
|
220 } |
|
221 |
|
222 void CPcWindowBase::SubStateChanged() |
|
223 { |
|
224 iWin.Invalidate(); |
|
225 Client()->iWs.Flush(); |
|
226 } |
|
227 |
|
228 void CPcWindowBase::Draw(TDesC &aBuf) |
|
229 { |
|
230 iGc->Clear(); |
|
231 iGc->SetPenColor(iBack.Gray4()>1 ? TRgb(0,0,0) : TRgb(255,255,255)); |
|
232 iGc->DrawText(aBuf, TPoint(10,20)); |
|
233 } |
|
234 |
|
235 void CPcWindowBase::PointerL(const TPointerEvent &pointer,const TTime &) |
|
236 { |
|
237 if (pointer.iType==TPointerEvent::EButton1Down && !iTest->iFailed) |
|
238 { |
|
239 if (iTest->SubState()==ERootWindow) // Root window click, must not be inside this window |
|
240 { |
|
241 if (TRect(Size()).Contains(pointer.iPosition)) |
|
242 { |
|
243 iTest->TestFailed(); |
|
244 return; |
|
245 } |
|
246 } |
|
247 TInt ret; |
|
248 if ((ret=PointerDown())==EFailed) |
|
249 iTest->TestFailed(); |
|
250 else |
|
251 iTest->IncSubState(ret==ENeedsDDEvent); |
|
252 } |
|
253 } |
|
254 |
|
255 void CPcWindowBase::DragDropL(const TPointerEvent &pointer,const TTime &) |
|
256 { |
|
257 switch(iTest->State()) |
|
258 { |
|
259 case ECaptureDisabled: |
|
260 case ENormalCapture: |
|
261 case ECaptureAllGroups: |
|
262 case ENormalCaptureWithoutFocus: |
|
263 iTest->TestFailed(); |
|
264 break; |
|
265 } |
|
266 if (pointer.iType==TPointerEvent::EButton1Down && !iTest->iFailed) |
|
267 { |
|
268 if (DragDrop()==EFailed) |
|
269 iTest->TestFailed(); |
|
270 else |
|
271 iTest->GotDD(); |
|
272 } |
|
273 } |
|
274 // |
|
275 |
|
276 CPcWindowMain::CPcWindowMain(TPointerCaptureTest *aTest) : CPcWindowBase(aTest) |
|
277 { |
|
278 iBack=TRgb::Gray256(236); |
|
279 } |
|
280 |
|
281 TPointerCheckRet CPcWindowMain::PointerDown() |
|
282 { |
|
283 switch(iTest->State()) |
|
284 { |
|
285 case ECaptureDisabled: |
|
286 if (iTest->SubState()==EMainWindow) |
|
287 return(EOkay); |
|
288 break; |
|
289 case ENormalCapture: |
|
290 switch(iTest->SubState()) |
|
291 { |
|
292 case EMainWindow: |
|
293 case ERootWindow: |
|
294 return(EOkay); |
|
295 default: |
|
296 break; |
|
297 } |
|
298 break; |
|
299 case ECaptureAllGroups: |
|
300 switch(iTest->SubState()) |
|
301 { |
|
302 case EMainWindow: |
|
303 case EOtherGroup: |
|
304 case EOtherSession: |
|
305 case ERootWindow: |
|
306 return(EOkay); |
|
307 default: |
|
308 break; |
|
309 } |
|
310 break; |
|
311 case EDragDropCapture: |
|
312 switch(iTest->SubState()) |
|
313 { |
|
314 case EMainWindow: |
|
315 return(ENeedsDDEvent); |
|
316 case ERootWindow: |
|
317 return(EOkay); |
|
318 default: |
|
319 break; |
|
320 } |
|
321 break; |
|
322 case EDragDropCaptureAllGroups: |
|
323 switch(iTest->SubState()) |
|
324 { |
|
325 case EMainWindow: |
|
326 case EOtherGroup: |
|
327 case EOtherSession: |
|
328 return(ENeedsDDEvent); |
|
329 case ERootWindow: |
|
330 return(EOkay); |
|
331 default: |
|
332 break; |
|
333 } |
|
334 break; |
|
335 case ENormalCaptureWithoutFocus: |
|
336 switch(iTest->SubState()) |
|
337 { |
|
338 case EMainWindow: |
|
339 return(EOkay); |
|
340 default: |
|
341 break; |
|
342 } |
|
343 break; |
|
344 default: |
|
345 break; |
|
346 } |
|
347 return(EFailed); |
|
348 } |
|
349 |
|
350 TPointerCheckRet CPcWindowMain::DragDrop() |
|
351 { |
|
352 switch(iTest->State()) |
|
353 { |
|
354 case EDragDropCapture: |
|
355 case EDragDropCaptureAllGroups: |
|
356 switch(iTest->SubState()) |
|
357 { |
|
358 case EMainWindow: |
|
359 return(EOkay); |
|
360 default: |
|
361 break; |
|
362 } |
|
363 break; |
|
364 default: |
|
365 break; |
|
366 } |
|
367 return(EFailed); |
|
368 } |
|
369 |
|
370 void CPcWindowMain::Draw() |
|
371 { |
|
372 TBuf<0x40> buf; |
|
373 if (iTest->State()==ECaptureDisabled) |
|
374 { |
|
375 switch(iTest->SubState()) |
|
376 { |
|
377 case EMainWindow: |
|
378 buf.Copy(_L("Click on me")); |
|
379 break; |
|
380 } |
|
381 } |
|
382 else |
|
383 { |
|
384 switch(iTest->SubState()) |
|
385 { |
|
386 case EMainWindow: |
|
387 buf.Copy(_L("Click on me")); |
|
388 break; |
|
389 case EChildWindow: |
|
390 case EOtherGroup: |
|
391 case EOtherSession: |
|
392 break; |
|
393 case ERootWindow: |
|
394 if (iTest->State()==ENormalCaptureWithoutFocus) |
|
395 buf.Copy(_L("Click on the root window, then press <Escape>")); |
|
396 else |
|
397 buf.Copy(_L("Click on the root window")); |
|
398 break; |
|
399 } |
|
400 } |
|
401 CPcWindowBase::Draw(buf); |
|
402 } |
|
403 |
|
404 void CPcWindowMain::WinKeyL(const TKeyEvent &aKey,const TTime &) |
|
405 { |
|
406 switch(aKey.iCode) |
|
407 { |
|
408 case EKeyEscape: |
|
409 iTest->AbortTests(); |
|
410 break; |
|
411 } |
|
412 } |
|
413 |
|
414 // |
|
415 |
|
416 CPcWindowChild::CPcWindowChild(TPointerCaptureTest *aTest) : CPcWindowBase(aTest) |
|
417 { |
|
418 iBack=TRgb::Gray256(85); |
|
419 } |
|
420 |
|
421 TPointerCheckRet CPcWindowChild::PointerDown() |
|
422 { |
|
423 switch(iTest->State()) |
|
424 { |
|
425 case ECaptureDisabled: |
|
426 break; |
|
427 default: |
|
428 switch(iTest->SubState()) |
|
429 { |
|
430 case EChildWindow: |
|
431 return(EOkay); |
|
432 default: |
|
433 break; |
|
434 } |
|
435 break; |
|
436 } |
|
437 return(EFailed); |
|
438 } |
|
439 |
|
440 TPointerCheckRet CPcWindowChild::DragDrop() |
|
441 { |
|
442 switch(iTest->State()) |
|
443 { |
|
444 case EDragDropCapture: |
|
445 case EDragDropCaptureAllGroups: |
|
446 switch(iTest->SubState()) |
|
447 { |
|
448 case EChildWindow: |
|
449 return(EOkay); |
|
450 default: |
|
451 break; |
|
452 } |
|
453 break; |
|
454 default: |
|
455 break; |
|
456 } |
|
457 return(EFailed); |
|
458 } |
|
459 |
|
460 void CPcWindowChild::Draw() |
|
461 { |
|
462 TBuf<0x40> buf; |
|
463 if (iTest->State()!=ECaptureDisabled) |
|
464 { |
|
465 switch(iTest->SubState()) |
|
466 { |
|
467 case EChildWindow: |
|
468 buf.Copy(_L("Click on me")); |
|
469 break; |
|
470 default: |
|
471 break; |
|
472 } |
|
473 } |
|
474 CPcWindowBase::Draw(buf); |
|
475 } |
|
476 |
|
477 // |
|
478 |
|
479 CPcWindowNickFocusGroup::CPcWindowNickFocusGroup(TPointerCaptureTest *aTest, CTClient *aClient) : CTWindowGroup(aClient), iTest(aTest) |
|
480 { |
|
481 } |
|
482 |
|
483 void CPcWindowNickFocusGroup::KeyL(const TKeyEvent &aKey,const TTime &) |
|
484 { |
|
485 if (aKey.iCode==EKeyEscape) |
|
486 iTest->IncSubState(EFalse); |
|
487 } |
|
488 |
|
489 // |
|
490 |
|
491 CPcWindowAltGroup::CPcWindowAltGroup(TPointerCaptureTest *aTest) : CPcWindowBase(aTest) |
|
492 { |
|
493 iBack=TRgb::Gray256(236); |
|
494 } |
|
495 |
|
496 TPointerCheckRet CPcWindowAltGroup::PointerDown() |
|
497 { |
|
498 switch(iTest->State()) |
|
499 { |
|
500 case ECaptureDisabled: |
|
501 if (iTest->SubState()==EChildWindow) |
|
502 return(EOkay); |
|
503 break; |
|
504 case ENormalCapture: |
|
505 case EDragDropCapture: |
|
506 case ENormalCaptureWithoutFocus: |
|
507 switch(iTest->SubState()) |
|
508 { |
|
509 case EOtherGroup: |
|
510 return(EOkay); |
|
511 default: |
|
512 break; |
|
513 } |
|
514 break; |
|
515 default: |
|
516 break; |
|
517 } |
|
518 return(EFailed); |
|
519 } |
|
520 |
|
521 TPointerCheckRet CPcWindowAltGroup::DragDrop() |
|
522 { |
|
523 switch(iTest->State()) |
|
524 { |
|
525 case EDragDropCapture: |
|
526 case EDragDropCaptureAllGroups: |
|
527 switch(iTest->SubState()) |
|
528 { |
|
529 case EOtherGroup: |
|
530 return(EOkay); |
|
531 default: |
|
532 break; |
|
533 } |
|
534 break; |
|
535 default: |
|
536 break; |
|
537 } |
|
538 return(EFailed); |
|
539 } |
|
540 |
|
541 void CPcWindowAltGroup::Draw() |
|
542 { |
|
543 TBuf<0x40> buf; |
|
544 if (iTest->State()==ECaptureDisabled) |
|
545 { |
|
546 switch(iTest->SubState()) |
|
547 { |
|
548 case EMainWindow: |
|
549 break; |
|
550 case EChildWindow: |
|
551 buf.Copy(_L("Click on me")); |
|
552 break; |
|
553 } |
|
554 } |
|
555 else |
|
556 { |
|
557 switch(iTest->SubState()) |
|
558 { |
|
559 case EOtherGroup: |
|
560 buf.Copy(_L("Click on me")); |
|
561 break; |
|
562 default: |
|
563 break; |
|
564 } |
|
565 } |
|
566 CPcWindowBase::Draw(buf); |
|
567 } |
|
568 |
|
569 // |
|
570 |
|
571 CPcWindowAltConnection::CPcWindowAltConnection(TPointerCaptureTest *aTest) : CPcWindowBase(aTest) |
|
572 { |
|
573 iBack=TRgb::Gray256(236); |
|
574 } |
|
575 |
|
576 TPointerCheckRet CPcWindowAltConnection::PointerDown() |
|
577 { |
|
578 switch(iTest->State()) |
|
579 { |
|
580 case ECaptureDisabled: |
|
581 if (iTest->SubState()==EChildWindow) |
|
582 return(EOkay); |
|
583 break; |
|
584 case ENormalCapture: |
|
585 case EDragDropCapture: |
|
586 case ENormalCaptureWithoutFocus: |
|
587 switch(iTest->SubState()) |
|
588 { |
|
589 case EOtherSession: |
|
590 return(EOkay); |
|
591 default: |
|
592 break; |
|
593 } |
|
594 break; |
|
595 default: |
|
596 break; |
|
597 } |
|
598 return(EFailed); |
|
599 } |
|
600 |
|
601 TPointerCheckRet CPcWindowAltConnection::DragDrop() |
|
602 { |
|
603 switch(iTest->State()) |
|
604 { |
|
605 case EDragDropCapture: |
|
606 case EDragDropCaptureAllGroups: |
|
607 switch(iTest->SubState()) |
|
608 { |
|
609 case EOtherSession: |
|
610 return(EOkay); |
|
611 default: |
|
612 break; |
|
613 } |
|
614 break; |
|
615 default: |
|
616 break; |
|
617 } |
|
618 return(EFailed); |
|
619 } |
|
620 |
|
621 void CPcWindowAltConnection::Draw() |
|
622 { |
|
623 TBuf<0x40> buf; |
|
624 if (iTest->State()!=ECaptureDisabled) |
|
625 { |
|
626 switch(iTest->SubState()) |
|
627 { |
|
628 case EOtherSession: |
|
629 buf.Copy(_L("Click on me")); |
|
630 break; |
|
631 default: |
|
632 break; |
|
633 } |
|
634 } |
|
635 CPcWindowBase::Draw(buf); |
|
636 } |
|
637 |
|
638 // |
|
639 |
|
640 TPointerCaptureTest::TPointerCaptureTest() : CTestBase(_L("Pointer Capture")) |
|
641 {} |
|
642 |
|
643 TPointerCaptureTest::~TPointerCaptureTest() |
|
644 { |
|
645 delete iNickFocusBlankWin; |
|
646 delete iNickFocusGroup; |
|
647 delete iAltConnectionWin; |
|
648 delete iAltConnection; |
|
649 delete iChildWin; |
|
650 delete iMainWin; |
|
651 delete iMainGroup; |
|
652 delete iAltGroupWin; |
|
653 delete iAltGroup; |
|
654 } |
|
655 |
|
656 void TPointerCaptureTest::TestFailed() |
|
657 { |
|
658 __ASSERT_DEBUG(iFailed==EFalse,TManPanic(ETManPanicPcFailed)); |
|
659 iFailed=ETrue; |
|
660 Client()->iGroup->GroupWin()->SetOrdinalPosition(0,10); // Put error dialog on top of test windows |
|
661 TInt dRet=1; |
|
662 TRAPD(err,dRet=doTestFailedL()); |
|
663 Client()->iGroup->GroupWin()->SetOrdinalPosition(0,0); |
|
664 switch(dRet) |
|
665 { |
|
666 case 0: |
|
667 RestartTest(); |
|
668 break; |
|
669 case 1: |
|
670 TRAP(err,TestL(EFalse)); |
|
671 break; |
|
672 } |
|
673 } |
|
674 |
|
675 TInt TPointerCaptureTest::doTestFailedL() |
|
676 { |
|
677 CTDialog *dialog=new(ELeave) CTDialog(); |
|
678 dialog->SetTitle(_L("Pointer capture test failed")); |
|
679 dialog->SetNumButtons(2); |
|
680 dialog->SetButtonText(0,_L("Retest")); |
|
681 dialog->SetButtonText(1,_L("Fail")); |
|
682 dialog->ConstructLD(*Client()->iGroup,*Client()->iGc); |
|
683 return dialog->Display(); |
|
684 } |
|
685 |
|
686 TInt TPointerCaptureTest::State() const |
|
687 { |
|
688 return(iState); |
|
689 } |
|
690 |
|
691 TInt TPointerCaptureTest::SubState() const |
|
692 { |
|
693 return(iSubState); |
|
694 } |
|
695 |
|
696 void TPointerCaptureTest::doIncSubState() |
|
697 { |
|
698 iSubState++; |
|
699 TInt max=0; |
|
700 switch(iState) |
|
701 { |
|
702 case ECaptureDisabled: |
|
703 max=ESubStates1; |
|
704 break; |
|
705 case ENormalCapture: |
|
706 max=ESubStates2; |
|
707 break; |
|
708 case ECaptureAllGroups: |
|
709 max=ESubStates3; |
|
710 break; |
|
711 case EDragDropCapture: |
|
712 max=ESubStates4; |
|
713 break; |
|
714 case EDragDropCaptureAllGroups: |
|
715 max=ESubStates5; |
|
716 break; |
|
717 case ENormalCaptureWithoutFocus: |
|
718 max=ESubStates6; |
|
719 break; |
|
720 } |
|
721 if (iSubState==max) |
|
722 NextTest(); |
|
723 StateChanged(); |
|
724 } |
|
725 |
|
726 void TPointerCaptureTest::GotDD() |
|
727 { |
|
728 if (iDDState==DDStateWaiting) |
|
729 doIncSubState(); |
|
730 else |
|
731 iDDState=DDStateGot; |
|
732 } |
|
733 |
|
734 void TPointerCaptureTest::IncSubState(TBool aNeedsDD) |
|
735 { |
|
736 if (!aNeedsDD) |
|
737 { |
|
738 if (iDDState!=DDStateNull) |
|
739 TestFailed(); |
|
740 else |
|
741 doIncSubState(); |
|
742 } |
|
743 else if (iDDState==DDStateGot) |
|
744 doIncSubState(); |
|
745 else |
|
746 iDDState=DDStateWaiting; |
|
747 } |
|
748 |
|
749 void TPointerCaptureTest::StateChanged() |
|
750 { |
|
751 iDDState=DDStateNull; |
|
752 iChildWin->SubStateChanged(); |
|
753 iMainWin->SubStateChanged(); |
|
754 iAltGroupWin->SubStateChanged(); |
|
755 iAltConnectionWin->SubStateChanged(); |
|
756 } |
|
757 |
|
758 void TPointerCaptureTest::AbortTests() |
|
759 { |
|
760 iState=99; |
|
761 Request(); |
|
762 } |
|
763 |
|
764 void TPointerCaptureTest::NextTest() |
|
765 { |
|
766 iState++; |
|
767 Request(); |
|
768 } |
|
769 |
|
770 void TPointerCaptureTest::RestartTest() |
|
771 { |
|
772 Request(); |
|
773 } |
|
774 |
|
775 void TPointerCaptureTest::ConstructL() |
|
776 { |
|
777 TSize size(Client()->iGroup->Size()); |
|
778 TInt winWidth2=size.iWidth/2-EWinBorderSize*2; |
|
779 TInt winWidth4=size.iWidth/4-EWinBorderSize*2; |
|
780 TInt winHeight=size.iHeight/2-EWinBorderSize*2; |
|
781 // |
|
782 iMainGroup=new(ELeave) CTWindowGroup(Client()); |
|
783 iMainGroup->ConstructL(); |
|
784 iMainGroup->GroupWin()->SetOrdinalPosition(0,1); |
|
785 iMainWin=new(ELeave) CPcWindowMain(this); |
|
786 iMainWin->SetUpL(TPoint(EWinBorderSize,EWinBorderSize) ,TSize(winWidth2,winHeight) ,iMainGroup); |
|
787 iMainGroup->SetCurrentWindow(iMainWin); |
|
788 iChildWin=new(ELeave) CPcWindowChild(this); |
|
789 iChildWin->SetUpL(TPoint(0,winHeight/2) ,TSize(winWidth2,winHeight/2) ,iMainWin); |
|
790 // |
|
791 iAltGroup=new(ELeave) CTWindowGroup(Client()); |
|
792 iAltGroup->ConstructL(); |
|
793 iAltGroup->GroupWin()->SetOrdinalPosition(0,1); |
|
794 iAltGroup->GroupWin()->EnableReceiptOfFocus(EFalse); |
|
795 iAltGroupWin=new(ELeave) CPcWindowAltGroup(this); |
|
796 iAltGroupWin->SetUpL(TPoint(size.iWidth/2+EWinBorderSize,EWinBorderSize) ,TSize(winWidth4,winHeight) ,iAltGroup); |
|
797 // |
|
798 iAltConnection=new(ELeave) CPcConnection(this); |
|
799 iAltConnection->ConstructL(); |
|
800 iAltConnectionWin=new(ELeave) CPcWindowAltConnection(this); |
|
801 iAltConnectionWin->SetUpL(TPoint(size.iWidth/4*3+EWinBorderSize,EWinBorderSize) ,TSize(winWidth4,winHeight),iAltConnection->iGroup,*iAltConnection->iGc); |
|
802 } |
|
803 |
|
804 void TPointerCaptureTest::NickFocusL() |
|
805 { |
|
806 iNickFocusGroup=new(ELeave) CPcWindowNickFocusGroup(this,Client()); |
|
807 iNickFocusGroup->ConstructL(); |
|
808 iNickFocusGroup->GroupWin()->SetOrdinalPosition(0,2); |
|
809 iNickFocusBlankWin=new(ELeave) CTBlankWindow(); |
|
810 iNickFocusBlankWin->ConstructL(*iNickFocusGroup); |
|
811 iNickFocusBlankWin->SetSize(TSize(1,1)); |
|
812 iNickFocusBlankWin->Activate(); |
|
813 } |
|
814 |
|
815 void TPointerCaptureTest::SetCapture(TInt aCaptureFlags) |
|
816 { |
|
817 iMainWin->Win()->SetPointerCapture(aCaptureFlags); |
|
818 } |
|
819 |
|
820 TestState TPointerCaptureTest::DoTestL() |
|
821 { |
|
822 iSubState=0; |
|
823 iFailed=EFalse; |
|
824 StateChanged(); |
|
825 switch(iState) |
|
826 { |
|
827 case ECaptureDisabled: |
|
828 LogSubTest(_L("No capture"),1); |
|
829 SetCapture(RWindowBase::TCaptureDisabled); |
|
830 break; |
|
831 case ENormalCapture: |
|
832 LogSubTest(_L("Normal capture"),1); |
|
833 SetCapture(RWindowBase::TCaptureEnabled); |
|
834 break; |
|
835 case ECaptureAllGroups: |
|
836 LogSubTest(_L("All groups"),1); |
|
837 SetCapture(RWindowBase::TCaptureEnabled|RWindowBase::TCaptureFlagAllGroups); |
|
838 break; |
|
839 case EDragDropCapture: |
|
840 LogSubTest(_L("Drag & Drop"),1); |
|
841 SetCapture(RWindowBase::TCaptureDragDrop&~RWindowBase::TCaptureFlagAllGroups); |
|
842 break; |
|
843 case EDragDropCaptureAllGroups: |
|
844 LogSubTest(_L("Drag & Drop All groups"),1); |
|
845 SetCapture(RWindowBase::TCaptureDragDrop); |
|
846 break; |
|
847 case ENormalCaptureWithoutFocus: |
|
848 LogSubTest(_L("Without focus"),1); |
|
849 NickFocusL(); |
|
850 SetCapture(RWindowBase::TCaptureEnabled); |
|
851 break; |
|
852 default: |
|
853 return(EFinished); |
|
854 } |
|
855 return(EContinue); |
|
856 } |