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 // General window tests
21 @internalComponent - Internal Symbian test code
26 const TInt ENumCornerInsets=6;
27 const TInt corner0[ENumCornerInsets]={0,0,0,0,0,0};
28 const TInt corner1[ENumCornerInsets]={1,0,0,0,0,0};
29 const TInt corner2[ENumCornerInsets]={2,1,0,0,0,0};
30 const TInt corner3[ENumCornerInsets]={3,1,1,0,0,0};
31 const TInt corner5[ENumCornerInsets]={5,3,2,1,1,0};
32 const TInt KBaseUserEvent=61750; //0xF136 - a random number that is unlikely to be used by other applicaions for user event sending
36 CWinTestWindow::CWinTestWindow(TRgb aCol) : CBlankWindow(aCol)
40 CWinTestWindow::~CWinTestWindow()
45 void CWinTestWindow::ConstructL(TPoint pos,TSize size,CTWinBase *aParent, CWindowGc &aGc, TInt aDepth)
47 iWin=RWindow(TheClient->iWs);
48 User::LeaveIfError(iWin.Construct(*(aParent->WinTreeNode()),ENullWsHandle));
52 iChild=new(ELeave) CWinTestWindow(TRgb::Gray256(iCol.Gray256()+34));
55 iChild->ConstructL(TPoint(4,4),size,this,aGc,aDepth+1);
63 CEvWindowGroup* CEvWindowGroup::NewLC(CTClient* aClient,CTWsGraphicsBase* aTest)
65 CEvWindowGroup* self=new(ELeave) CEvWindowGroup(aClient,aTest);
66 CleanupStack::PushL(self);
71 CEvWindowGroup::CEvWindowGroup(CTClient* aClient,CTWsGraphicsBase* aTest) : CTWindowGroup(aClient), iTest(aTest)
74 void CEvWindowGroup::ConstructL()
76 CTWindowGroup::ConstructL();
77 iGroupWin.EnableReceiptOfFocus(EFalse);
80 void CEvWindowGroup::SetExpectedEvent(TInt aType)
82 iTest->TEST(!iExpectingEvent);
85 _LIT(KLog,"Setting expected event of type %d, when previouse event of type %d has not arrived (GpWinId=%d).");
86 iTest->LOG_MESSAGE4(KLog,aType,iExpectedEvent,iGroupWin.Identifier());
89 iExpectingEvent=ETrue;
92 void CEvWindowGroup::SendEvent(TInt aType)
96 iClient->iWs.SendEventToWindowGroup(iGroupWin.Identifier(),event);
97 SetExpectedEvent(aType);
101 void CEvWindowGroup::UserEvent(TInt aEventType)
103 iTest->TEST(iExpectingEvent && iExpectedEvent==aEventType);
104 if (!iExpectingEvent || iExpectedEvent!=aEventType)
106 TInt id=iGroupWin.Identifier();
107 if (!iExpectingEvent)
109 _LIT(KLog,"Event of type %d recieved when not expecting an event (GpWinId=%d).");
110 iTest->LOG_MESSAGE3(KLog,aEventType,id);
114 _LIT(KLog,"Event of type %d when expecting an event of type %d (GpWinId=%d).");
115 iTest->LOG_MESSAGE4(KLog,aEventType,iExpectingEvent,id);
118 iExpectingEvent=EFalse;
123 CTWindowTest::CTWindowTest(CTestStep* aStep) : CTWsGraphicsBase(aStep)
126 CTWindowTest::~CTWindowTest()
131 void CTWindowTest::ConstructL()
134 TInt CTWindowTest::MoveGroup(TAny* aParam)
137 TInt err=ws.Connect();
140 TInt command=static_cast<TWindowThreadParam*>(aParam)->iCommand;
141 err=ws.SetWindowGroupOrdinalPosition(command&EIdMask,(command&EPosMask)>>EPosShift);
148 void CTWindowTest::CreateTestWindowL()
150 iWin=new(ELeave) CWinTestWindow(TRgb(0,0,0));
151 iWin->ConstructL(TPoint(1,1),TSize(TestWin->Size().iWidth/2,TestWin->Size().iHeight/2),TheClient->iGroup,*TheClient->iGc,0);
154 void CTWindowTest::DrawWindows(CWinTestWindow *aWin)
157 DrawWindows(aWin->iChild);
158 aWin->Win()->BeginRedraw();
159 TheGc->Activate(*aWin->Win());
160 TheGc->DrawRect(TRect(aWin->Win()->Size()));
162 aWin->Win()->EndRedraw();
163 TheClient->iWs.Flush();
166 void CTWindowTest::CheckAndDestroyWindows()
173 void CTWindowTest::DestroyWindowWithActiveGc()
175 iWin->Win()->BeginRedraw();
176 TheGc->Activate(*iWin->Win());
182 void CTWindowTest::DestroyWindowWithActiveGc2L()
184 iWin->Win()->BeginRedraw();
185 TheGc->Activate(*iWin->Win());
186 CWindowGc *gc1=new(ELeave) CWindowGc(TheClient->iScreen);
187 CWindowGc *gc2=new(ELeave) CWindowGc(TheClient->iScreen);
188 CWindowGc *gc3=new(ELeave) CWindowGc(TheClient->iScreen);
192 gc1->Activate(*iWin->Win());
193 gc2->Activate(*iWin->Win());
194 gc3->Activate(*iWin->Win());
203 LOCAL_C TInt DoPanicTest(TInt aInt, TAny *aScreenNumber)
206 User::LeaveIfError(ws.Connect());
207 // use correct screen
209 CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
210 User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
212 RWindowGroup group(ws);
213 group.Construct(888);
214 group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close
217 redraw.Construct(group,88);
219 RBackedUpWindow backedUp(ws);
220 backedUp.Construct(group,EGray16,99);
222 RBlankWindow blank(ws);
223 blank.Construct(group,111);
225 RWindowBase *base=NULL;
226 TInt source=aInt/10000;
227 TInt target=(aInt%10000)/100;
245 RWindow *win=(RWindow *)base;
252 ws.SetAutoFlush(ETrue);
253 win->BeginRedraw(TRect(0,0,1,1));
254 ws.SetAutoFlush(EFalse);
257 ws.SetAutoFlush(ETrue);
259 ws.SetAutoFlush(EFalse);
265 win->Invalidate(TRect(0,0,1,1));
270 win->GetInvalidRegion(region);
274 win->SetBackgroundColor(TRgb(0,0,0));
277 return(EWsExitReasonFinished);
283 RBackedUpWindow *win=(RBackedUpWindow *)base;
293 win->UpdateScreen(TRegionFix<1>(TRect(10,10,20,20)));
296 win->UpdateBackupBitmap();
299 win->MaintainBackup();
302 return(EWsExitReasonFinished);
308 RBlankWindow *win=(RBlankWindow *)base;
312 win->SetColor(TRgb(0));
315 return(EWsExitReasonFinished);
321 return(EWsExitReasonBad); // Should never get here, but it's baaddd if it does
324 struct TWsLocalStructure
332 LOCAL_C TInt DoPanicTest2(TInt aInt, TAny *aScreenNumber)
335 User::LeaveIfError(ws.Connect());
337 CWsScreenDevice *screen=new(ELeave) CWsScreenDevice(ws);
338 screen->Construct((TInt)aScreenNumber);
340 RWindowGroup group(ws);
341 group.Construct(999);
342 group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close
345 win.Construct(group,122);
354 screen->CreateContext(gc);
357 screen->GetNearestFontToDesignHeightInTwips((CFont *&)font,TFontSpec());
359 TWsLocalStructure params;
363 TPckgC<TWsLocalStructure> pkg(params);
364 TPtr8 ptr(NULL,10,10);
365 ws.TestWriteReplyByProvidingRemoteReadAccess(gc->WsHandle(),EWsGcOpDrawTextPtr,pkg,ptr); // Bad source descriptor
370 TPtr8 bad(NULL,0); // Bad descriptor
371 ws.TestWriteReplyP(win.WsHandle(),EWsWinOpSize,NULL,0,&bad); // Bad descriptor
377 TPtr8 bad((TUint8 *)&size,4,4); // Short descriptor
378 ws.TestWriteReplyP(win.WsHandle(),EWsWinOpSize,NULL,0,&bad); // Short descriptor
382 win.EnablePointerMoveBuffer();
386 RBackedUpWindow backup(ws);
387 backup.Construct(group,EGray16,123);
389 backup.SetRequiredDisplayMode(EGray16);
393 return(EWsExitReasonFinished);
396 return(EWsExitReasonBad); // Should never get here, but it's baaddd if it does
399 LOCAL_C TInt CallWindowFuction(RWindowTreeNode* aWin,TInt aWinType,TInt aFunc,RWsSession aWs)
403 case 0: //Call functions from RWindowTreeNode
405 RWindowTreeNode* win=aWin;
409 win->OrdinalPosition();
412 win->SetOrdinalPosition(1);
415 win->SetOrdinalPosition(1,2);
418 win->FullOrdinalPosition();
427 win->SetFaded(0,RWindowTreeNode::EFadeIncludeChildren);
430 win->WindowGroupId();
432 //The following can be called on a window with no parent without panicking
434 win->ClearPointerCursor();
440 win->DisableErrorMessages();
443 win->DisableFocusChangeEvents();
446 win->DisableGroupChangeEvents();
449 win->DisableGroupListChangeEvents();
452 win->DisableModifierChangedEvents();
455 win->DisableOnEvents();
458 win->DisableVisibilityChangeEvents();
461 win->EnableErrorMessages(EEventControlAlways);
464 win->EnableFocusChangeEvents();
467 win->EnableGroupChangeEvents();
470 win->EnableGroupListChangeEvents();
473 win->EnableModifierChangedEvents(0,EEventControlAlways);
476 win->EnableVisibilityChangeEvents();
482 win->OrdinalPriority();
485 win->SetNonFading(0);
488 win->SetPointerCursor(0);
494 return(EWsExitReasonFinished);
499 case 1: //Call functions from RWindowGroup
501 RWindowGroup* win=(RWindowGroup*)aWin;
505 win->EnableReceiptOfFocus(ETrue);
508 win->AutoForeground(ETrue);
511 win->SetOrdinalPriorityAdjust(5);
514 win->CaptureKey(20,0,0);
517 win->CaptureKeyUpAndDowns(20,0,0);
522 RWindowGroup group(aWs);
523 group.Construct(876);
524 group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close
526 win->CancelCaptureKey(group.CaptureKey(20,0,0));
528 win->CancelCaptureKeyUpAndDowns(group.CaptureKeyUpAndDowns(20,0,0));
532 win->AddPriorityKey(20,0,0);
535 win->RemovePriorityKey(20,0,0);
540 RWindowGroup group(aWs);
541 group.Construct(765);
542 group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close
544 window.Construct(group,79);
546 win->SetTextCursor(window,TPoint(45,46),TTextCursor());
548 win->SetTextCursor(window,TPoint(55,66),TTextCursor(),TRect(TSize(5,8)));
552 win->CancelTextCursor();
555 win->SetOwningWindowGroup(456);
558 win->DefaultOwningWindow();
562 TBufC<8> text(_L("abcdef"));
569 User::LeaveIfError(win->Name(text));
576 win->DisableKeyClick(ETrue);
582 User::LeaveIfError(win->FetchMessage(uid,text));
587 User::LeaveIfError(win->EnableScreenChangeEvents());
590 win->EnableScreenChangeEvents();
593 win->DisableScreenChangeEvents();
596 win->SimulatePointerEvent(TRawEvent());
598 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
600 win->SimulateAdvancedPointerEvent(TRawEvent());
603 return(EWsExitReasonFinished);
606 return(EWsExitReasonFinished);
612 case 2: //Call functions from RWindowBase
614 RWindowBase* win=(RWindowBase*)aWin;
618 win->SetPosition(TPoint(7,8));
621 User::LeaveIfError(win->SetSizeErr(TSize(21,22)));
624 User::LeaveIfError(win->SetExtentErr(TPoint(8,9),TSize(21,22)));
627 win->ClaimPointerGrab();
630 win->SetVisible(ETrue);
636 win->RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32(100000),TRect());
639 win->PasswordWindow(EPasswordCancel);
642 win->FadeBehind(ETrue);
644 //These can all be called on a window with no parent without panicking
646 win->SetVisible(EFalse);
650 RWindowGroup group(aWs);
651 group.Construct(567);
652 group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close
654 window.Construct(group,97);
655 win->InquireOffset(window);
659 win->PointerFilter(0,0);
662 win->SetPointerGrab(ETrue);
665 win->SetPointerCapture(0);
674 User::LeaveIfError(win->SetCornerType(EWindowCorner5,0));
678 TRegionFix<3> region;
679 User::LeaveIfError(win->SetShape(region));
683 User::LeaveIfError(win->SetRequiredDisplayMode(EColor16));
689 win->CancelPointerRepeatEventRequest();
692 win->AllocPointerMoveBuffer(10,0);
695 win->FreePointerMoveBuffer();
698 win->DisablePointerMoveBuffer();
703 win->RetrievePointerMoveBuffer(buf);
707 win->DiscardPointerMoveBuffer();
710 User::LeaveIfError(win->AddKeyRect(TRect(TSize(10,10)),20,ETrue));
713 win->RemoveAllKeyRects();
716 win->EnablePointerMoveBuffer();
719 return(EWsExitReasonFinished);
724 case 3: //Call functions from RDrawableWindow
726 RDrawableWindow* win=(RDrawableWindow*)aWin;
729 //The following can be called on a window with no parent without panicking
731 win->Scroll(TPoint(7,8));
734 win->Scroll(TRect(9,10,11,12),TPoint(13,14));
737 win->Scroll(TPoint(15,16),TRect(17,18,19,20));
740 win->Scroll(TRect(21,22,23,24),TPoint(25,26),TRect(27,28,29,30));
743 return(EWsExitReasonFinished);
748 case 4: //Call functions from RBlankWindow
750 RBlankWindow* win=(RBlankWindow*)aWin;
754 win->SetSize(TSize(7,8));
757 win->SetExtent(TPoint(27,28),TSize(17,18));
759 //The following function can be called on a window with no parent without panicking
761 win->SetColor(TRgb::Gray4(2));
764 return(EWsExitReasonFinished);
769 case 5: //Call functions from RWindow
771 RWindow* win=(RWindow*)aWin;
778 aWs.SetAutoFlush(ETrue);
779 win->BeginRedraw(TRect(31,32,43,44));
780 aWs.SetAutoFlush(EFalse);
783 win->SetSize(TSize(5,6));
786 win->SetExtent(TPoint(25,26),TSize(15,16));
788 //The following can be called on a window with no parent without panicking
793 win->Invalidate(TRect(51,52,63,64));
795 case 6: //These ones don't panic
796 aWs.SetAutoFlush(ETrue);
798 aWs.SetAutoFlush(EFalse);
803 win->GetInvalidRegion(region);
807 win->SetBackgroundColor(TRgb::Gray4(1));
810 win->SetBackgroundColor();
813 return(EWsExitReasonFinished);
818 case 6: //Call functions from RBackedUpWindow
820 RBackedUpWindow* win=(RBackedUpWindow*)aWin;
821 switch(aFunc) //None of these functions panic
823 //The following can be called on a window with no parent without panicking
828 win->UpdateBackupBitmap();
831 win->MaintainBackup();
837 win->UpdateScreen(TRegionFix<1>(TRect(1,1,22,22)));
840 return(EWsExitReasonFinished);
847 return(EWsExitReasonBad); // Should never get here, but it's baaddd if it does
850 LOCAL_C TInt DoPanicTest3(TInt aInt, TAny *aScreenNumber)
852 TInt winType=aInt/CTWindowTest::EWinTypeFactor;
853 TInt func=aInt%CTWindowTest::EWinTypeFactor;
855 User::LeaveIfError(ws.Connect());
856 // use correct screen
858 CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
859 User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
861 RWindowGroup group(ws);
862 group.Construct(888);
863 group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close
865 window.Construct(group,789);
866 RWindowTreeNode* win;
872 return CallWindowFuction(win,winType,func,ws);
876 //This function is called from DoPanicTest4 for window functions that should run without
877 //panicking the user thread if its parent has been deleted.
878 TInt PanicTestNoPanic(RWindowTreeNode* aWin,TInt aWinType,TInt aFunc,RWsSession aWs,const TInt* const aFuncToSkip)
883 if (aFuncToSkip && *aFuncToSkip == aFunc)
887 funcReturn = CallWindowFuction(aWin,aWinType,aFunc,aWs);
888 if (funcReturn==EWsExitReasonBad)
892 else if (funcReturn==EWsExitReasonFinished)
894 return EWsExitReasonFinished;
898 return EWsExitReasonBad;
903 LOCAL_C TInt DoPanicTest4(TInt aInt, TAny *aScreenNumber)
905 TInt winType=aInt/CTWindowTest::EWinTypeFactor;
906 TInt func=aInt%CTWindowTest::EWinTypeFactor;
908 User::LeaveIfError(ws.Connect());
909 // use correct screen
911 CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
912 User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
914 RWindowGroup group(ws);
915 group.Construct(234);
916 group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close
918 window.Construct(group,897);
919 RBackedUpWindow backedUp(ws);
920 backedUp.Construct(group,EGray16,98);
921 RBlankWindow blank(ws);
922 blank.Construct(group,169);
923 RWindowTreeNode* win=&window;
928 if (func > 8) //if a func 8+ had panicked, fail the test
930 return EWsExitReasonBad;
935 return PanicTestNoPanic(win,winType,func,ws,NULL);
941 if (func>9) //if a func 9+ had panicked, fail the test
943 return EWsExitReasonBad;
945 else if (func==9) //set window visible so that SetVisible(EFalse) (func 9) would crash before fix
947 window.SetVisible(ETrue);
950 TInt funcToSkip = 28; //this call needs to have already successfully allocated a pointer cursor
951 return PanicTestNoPanic(win,winType,func,ws,&funcToSkip);
958 if (func>2) //if a func 2+ had panicked, fail the test
960 return EWsExitReasonBad;
965 return PanicTestNoPanic(win,winType,func,ws,NULL);
971 if (func>6) //if a func 4+ had panicked, fail the test
973 return EWsExitReasonBad;
975 else if (func==4 || func==5)
977 if (CallWindowFuction(win,winType,func,ws)==EWsExitReasonBad)
983 return EWsExitReasonBad;
989 TInt funcToSkip = 6; //Skip the call to EndRedraw in CallWindowFunction, it is not safe to call it on Window casts.
990 return PanicTestNoPanic(win,winType,func,ws,&funcToSkip);
998 return EWsExitReasonBad;
1005 while (CallWindowFuction(win,winType,func,ws)==EWsExitReasonBad && ++func<end)
1007 if (func==end && end==2)
1014 return EWsExitReasonFinished;
1016 return EWsExitReasonBad;
1023 return CallWindowFuction(win,winType,func,ws);
1026 LOCAL_C TInt DoPanicTest5(TInt aTest, TAny *aScreenNumber)
1029 User::LeaveIfError(ws.Connect());
1031 CWsScreenDevice *scrDev=new(ELeave) CWsScreenDevice(ws);
1032 scrDev->Construct((TInt)aScreenNumber);
1034 RWindowGroup group(ws);
1035 group.Construct(235);
1036 group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close
1038 window.Construct(group,896);
1039 CWindowGc *gc=new(ELeave) CWindowGc(scrDev);
1041 gc->Activate(window);
1047 gc->Activate(window);
1050 gc->DrawLine(TPoint(0,0),TPoint(10,10));
1053 return(EWsExitReasonFinished);
1056 return(EWsExitReasonBad); // Should never get here, but it's baaddd if it does
1060 LOCAL_C TInt DoPanicTest6(TInt /*aInt*/, TAny *aScreenNumber)
1063 User::LeaveIfError(ws.Connect());
1064 RWindowGroup group1(ws);
1065 CWsScreenDevice* screen=new(ELeave) CWsScreenDevice(ws);
1066 User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
1067 group1.Construct(123456,ETrue,screen);
1068 RWindowGroup group2(ws);
1069 group2.Construct(123456,ETrue,screen); // Should panic client here
1070 return(EWsExitReasonBad); // Should never get here
1074 void CTWindowTest::TestInvalidFunctionsL()
1076 // This code casts windows to be different types and then sends messages for the 'cast' that
1077 // should not be sent to the original type of window. These should all result in panics
1080 static TClientPanic PanicCode[]={EWservPanicDescriptor,EWservPanicDescriptor,EWservPanicDescriptor,
1081 EWservPanicNoPointerBuffer,EWservPanicBackupDisplayMode,
1082 EWservPanicNoFont}; // Dummy end value to catch out overflowing the array
1083 INFO_PRINTF1(_L("AUTO Test Invalid Functions "));
1084 INFO_PRINTF1(_L(" Opcode Panics"));
1086 for (TInt source=0;source<3;source++)
1087 for (TInt target=0;target<3;target++)
1089 for (TInt panic=0;;panic++)
1091 TBool testFinished=EFalse;
1092 TEST(iTest->TestWsPanicL(DoPanicTest,EWservPanicOpcode,source*10000+target*100+panic,(TAny*)iTest->iScreenNumber,&testFinished));
1096 _LIT(KSet,"Various Different Panics");
1098 RDebug::Print(KPlatsecBegin);
1099 for(TInt index=0;;index++)
1101 TBool testFinished=EFalse;
1102 TEST(iTest->TestWsPanicL(DoPanicTest2,PanicCode[index],index,(TAny*)iTest->iScreenNumber,&testFinished));
1106 RDebug::Print(KPlatsecEnd);
1107 iTest->CloseAllPanicWindows();
1110 void CTWindowTest::ShadowAutoClearTest()
1112 RWindowGroup group(TheClient->iWs);
1113 group.Construct(1111);
1114 group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close
1116 RWindow background(TheClient->iWs);
1117 background.Construct(group,133);
1118 background.SetBackgroundColor();
1119 background.Activate();
1121 background.BeginRedraw();
1122 TheClient->iGc->Activate(background);
1123 TheClient->iGc->SetBrushColor(TRgb::Gray4(1));
1124 TheClient->iGc->Clear();
1125 background.EndRedraw();
1127 RBlankWindow tab2(TheClient->iWs);
1128 tab2.Construct(group,144);
1129 tab2.SetExtent(TPoint(10,00),TSize(200,10));
1130 tab2.SetColor(TRgb::Gray256(170));
1131 tab2.SetShadowHeight(1);
1133 RBlankWindow tab1(TheClient->iWs);
1134 tab1.Construct(group,155);
1135 tab1.SetExtent(TPoint(70,00),TSize(10,10));
1136 tab1.SetColor(TRgb::Gray256(170));
1137 tab1.SetShadowHeight(1);
1139 RBlankWindow blank(TheClient->iWs);
1140 blank.Construct(group,156);
1141 blank.SetExtent(TPoint(50,10),TSize(100,100));
1142 blank.SetColor(TRgb::Gray256(170));
1143 blank.SetShadowHeight(0);
1147 tab1.Construct(group,166);
1148 tab1.SetExtent(TPoint(50,00),TSize(10,10));
1149 tab1.SetColor(TRgb::Gray256(170));
1150 tab1.SetShadowHeight(1);
1153 RBlankWindow blank2(TheClient->iWs);
1154 blank2.Construct(group,177);
1155 blank2.SetColor(TRgb::Gray256(255));
1156 blank2.SetExtent(TPoint(10,10),TSize(100,120));
1157 blank2.SetShadowHeight(2);
1159 TheClient->iWs.Flush();
1161 background.BeginRedraw();
1162 TheClient->iGc->SetBrushColor(TRgb::Gray4(1));
1163 TheClient->iGc->Clear();
1164 background.EndRedraw();
1169 background.BeginRedraw();
1170 TheClient->iGc->Clear();
1171 TheClient->iGc->Deactivate();
1172 background.EndRedraw();
1173 TheClient->iWs.Finish();
1174 TSize size=TheClient->iScreen->SizeInPixels();
1175 TBool rectCompare = TheClient->iScreen->RectCompare(TRect(0,0,size.iWidth>>1,size.iHeight),TRect(size.iWidth>>1,0,(size.iWidth>>1)<<1,size.iHeight));
1178 INFO_PRINTF3(_L("TheClient->iScreen->RectCompare return value - Expected: %d, Actual: %d"), ETrue, rectCompare);
1183 void CTWindowTest::ClearRedraw(RWindow &aWindow, TRgb aRgb)
1185 aWindow.BeginRedraw();
1186 TheClient->iGc->Activate(aWindow);
1187 TheClient->iGc->SetBrushColor(aRgb);
1188 TheClient->iGc->Clear();
1189 TheClient->iGc->Deactivate();
1190 aWindow.EndRedraw();
1193 void CTWindowTest::CheckCorner(TCorner aCorner, const TInt *aInsetList)
1195 TRect rect(TPoint(1,1),iBlankWin2->Size());
1198 if (aCorner==ECornerTL || aCorner==ECornerTR)
1205 pos.iY=rect.iBr.iY-1;
1208 if (aCorner==ECornerTL || aCorner==ECornerBL)
1211 pos.iX=rect.iBr.iX-8;
1213 TPtr8 desc((TUint8 *)rgbBuf,sizeof(rgbBuf));
1214 for(TInt count=0;count<ENumCornerInsets;count++,pos.iY+=direction)
1216 iScreenDev->GetScanLine(desc,pos,8,EColor16MA);
1217 if (aCorner==ECornerTR || aCorner==ECornerBR)
1219 for(TInt loop=0;loop<4;loop++)
1221 TRgb tmp=rgbBuf[loop];
1222 rgbBuf[loop]=rgbBuf[8-1-loop];
1223 rgbBuf[8-1-loop]=tmp;
1226 // We can't compare rgb value from original source against screen value in EColor64K mode as
1227 // the color component might be truncated (EColor64K is 16-bit using format RGB565),
1228 // ie R or B components might be reduced from 8-bit to 5-bit and G from 8-bit to 6-bit
1230 // For example: RGB value of Gray4(1) is 0x555555, it is drawn to screen in RGB565 as 0x52AA,
1231 // when it's converted back to RGB for comparison, the value becomes 0x525552
1232 TRgb col1=TRgb::Gray4(1);
1233 TRgb col2=TRgb::Gray4(3);
1234 if (iScreenDev->DisplayMode()==EColor64K)
1236 col1=TRgb::Color64K(col1.Color64K());
1237 col2=TRgb::Color64K(col2.Color64K());
1240 for(;loop2<aInsetList[count];loop2++)
1242 TEST(rgbBuf[loop2]==col1);
1244 for(;loop2<8;loop2++)
1246 TEST(rgbBuf[loop2]==col2);
1251 void CTWindowTest::doCornerTest(TCornerType aCornerType, TInt aFlags)
1253 const TInt *corners=corner0;
1256 case EWindowCorner1:
1259 case EWindowCorner2:
1262 case EWindowCorner3:
1265 case EWindowCorner5:
1271 iBlankWin2->BaseWin()->SetCornerType(aCornerType,aFlags);
1272 if (!(aFlags&EWindowCornerNotTL))
1273 CheckCorner(ECornerTL, corners);
1274 if (!(aFlags&EWindowCornerNotTR))
1275 CheckCorner(ECornerTR, corners);
1276 if (!(aFlags&EWindowCornerNotBL))
1277 CheckCorner(ECornerBL, corners);
1278 if (!(aFlags&EWindowCornerNotBR))
1279 CheckCorner(ECornerBR, corners);
1281 if (aFlags&EWindowCornerNotTL)
1282 CheckCorner(ECornerTL, corner0);
1283 if (aFlags&EWindowCornerNotTR)
1284 CheckCorner(ECornerTR, corner0);
1285 if (aFlags&EWindowCornerNotBL)
1286 CheckCorner(ECornerBL, corner0);
1287 if (aFlags&EWindowCornerNotBR)
1288 CheckCorner(ECornerBR, corner0);
1291 void CTWindowTest::doCornerTestsL()
1293 iScreenDev=new(ELeave) CWsScreenDevice(TheClient->iWs);
1294 User::LeaveIfError(iScreenDev->Construct(iTest->iScreenNumber));
1295 iBlankWin1=new(ELeave) CTBlankWindow();
1296 iBlankWin1->SetUpL(TPoint(1,1),TSize(100,50),TheClient->iGroup,*TheClient->iGc);
1297 iBlankWin1->SetColor(TRgb::Gray4(1));
1298 iBlankWin2=new(ELeave) CTBlankWindow();
1299 iBlankWin2->SetUpL(TPoint(1,1),iBlankWin1->Size(),TheClient->iGroup,*TheClient->iGc);
1300 iBlankWin2->SetColor(TRgb::Gray4(3));
1301 iBlankWin2->BaseWin()->SetShadowHeight(0);
1302 doCornerTest(EWindowCornerSquare,0);
1303 doCornerTest(EWindowCornerSquare,EWindowCornerNotBL);
1304 doCornerTest(EWindowCorner1,0); // 0 + all corners missing
1305 doCornerTest(EWindowCorner1,EWindowCornerNotTL|EWindowCornerNotTR|EWindowCornerNotBL|EWindowCornerNotBR);
1306 doCornerTest(EWindowCorner2,0); // 0 + all sets of 3 corners missing
1307 doCornerTest(EWindowCorner2,EWindowCornerNotTR|EWindowCornerNotBL|EWindowCornerNotBR);
1308 doCornerTest(EWindowCorner2,EWindowCornerNotTL|EWindowCornerNotBL|EWindowCornerNotBR);
1309 doCornerTest(EWindowCorner2,EWindowCornerNotTL|EWindowCornerNotTR|EWindowCornerNotBR);
1310 doCornerTest(EWindowCorner2,EWindowCornerNotTL|EWindowCornerNotTR|EWindowCornerNotBL);
1311 doCornerTest(EWindowCorner3,0); // 0 + all 4 individual corners missing
1312 doCornerTest(EWindowCorner3,EWindowCornerNotTL);
1313 doCornerTest(EWindowCorner3,EWindowCornerNotTR);
1314 doCornerTest(EWindowCorner3,EWindowCornerNotBL);
1315 doCornerTest(EWindowCorner3,EWindowCornerNotBR);
1316 doCornerTest(EWindowCorner5,0); // 0 + all pairs of corners missing
1317 doCornerTest(EWindowCorner5,EWindowCornerNotTL|EWindowCornerNotTR);
1318 doCornerTest(EWindowCorner5,EWindowCornerNotTL|EWindowCornerNotBL);
1319 doCornerTest(EWindowCorner5,EWindowCornerNotTL|EWindowCornerNotBR);
1320 doCornerTest(EWindowCorner5,EWindowCornerNotTR|EWindowCornerNotBL);
1321 doCornerTest(EWindowCorner5,EWindowCornerNotTR|EWindowCornerNotBR);
1322 doCornerTest(EWindowCorner5,EWindowCornerNotBL|EWindowCornerNotBR);
1325 void CTWindowTest::CornerTests()
1327 TRAP_IGNORE(doCornerTestsL());
1333 LOCAL_C void doMegaTreeThread(TInt aScreenNumber)
1335 CTrapCleanup::New();
1338 CWsScreenDevice *scrDev=new(ELeave) CWsScreenDevice(ws);
1339 scrDev->Construct(aScreenNumber);
1340 RWindowGroup group(ws);
1342 group.EnableReceiptOfFocus(EFalse);
1344 parent.Construct(group,123);
1346 CWindowGc *gc=new(ELeave) CWindowGc(scrDev);
1348 TSize max(parent.Size());
1349 RWindow prev=parent;
1352 for(TInt count=0;count<100;count++)
1355 if (win.Construct(prev,ENullWsHandle)!=KErrNone)
1357 win.SetExtent(horiz?TPoint(1,0):TPoint(0,1),max);
1358 win.SetBackgroundColor(TRgb::Gray4(color));
1369 parent.SetVisible(EFalse);
1370 parent.SetVisible(ETrue);
1371 parent.SetPosition(TPoint(-1,-1));
1372 parent.SetPosition(TPoint(0,0));
1377 LOCAL_C TInt MegaTreeThread(TAny *aScreenNumber)
1379 TRAPD(err,doMegaTreeThread((TInt)aScreenNumber));
1383 void CTWindowTest::CreateMegaTree()
1385 const TUint KThreadHeapSize=0x2000;
1387 if (thread.Create(_L("MegaTree"),MegaTreeThread,KDefaultStackSize,KThreadHeapSize,KThreadHeapSize,(TAny*)iTest->iScreenNumber,EOwnerThread)==KErrNone)
1389 TRequestStatus stat;
1392 User::WaitForRequest(stat);
1393 TEST(stat==KErrNone);
1398 void CTWindowTest::TiledWindowTestL()
1400 RWindow parent(TheClient->iWs);
1401 User::LeaveIfError(parent.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle));
1402 CleanupStack::PushL(TCleanupItem(CleanUpWindow,&parent));
1403 parent.SetExtent(TPoint(10,10),TSize(50,50));
1406 RWindow child1(TheClient->iWs);
1407 User::LeaveIfError(child1.Construct(parent,ENullWsHandle));
1408 CleanupStack::PushL(TCleanupItem(CleanUpWindow,&child1));
1409 child1.SetExtent(TPoint(0,0),TSize(50,20));
1412 RWindow child2(TheClient->iWs);
1413 User::LeaveIfError(child2.Construct(parent,ENullWsHandle));
1414 CleanupStack::PushL(TCleanupItem(CleanUpWindow,&child2));
1415 child2.SetExtent(TPoint(0,20),TSize(50,30));
1418 child1.BeginRedraw();
1419 TSize rect1Size(25,20);
1420 TheGc->Activate(child1);
1421 TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1422 TheGc->DrawRect(TRect(rect1Size));
1423 TheGc->DrawRect(TRect(TPoint(rect1Size.iWidth,0),rect1Size));
1424 TheGc->Deactivate();
1427 child2.BeginRedraw();
1428 TSize rect2Size(25,30);
1429 TheGc->Activate(child2);
1430 TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1431 TheGc->DrawRect(TRect(rect2Size));
1432 TheGc->DrawRect(TRect(TPoint(rect2Size.iWidth,0),rect2Size));
1433 TheGc->Deactivate();
1436 // Left and right halves should be identical
1438 TBool rectCompare = !TheClient->iScreen->RectCompare(TRect(10,10,35,60),TRect(35,10,70,60));
1441 INFO_PRINTF3(_L("TheClient->iScreen->RectCompare return value - Expected: %d, Actual: %d"), ETrue, rectCompare);
1443 CleanupStack::PopAndDestroy(3);
1446 void CTWindowTest::TiledWindowTest2L()
1448 TSize size(200,240); //Parent Windows
1449 TSize childSize(TSize(size.iWidth/2,size.iHeight/2)); //Child Windows
1450 TSize dialogueSize(50,50);
1452 TheClient->iWs.SetAutoFlush(ETrue);
1453 RBlankWindow parent1(TheClient->iWs);
1454 User::LeaveIfError(parent1.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle));
1455 CleanupStack::PushL(TCleanupItem(CleanUpWindow,&parent1));
1456 parent1.SetExtent(TPoint(240,0),size);
1457 parent1.SetColor(TRgb::Gray4(2));
1460 TheClient->iWs.SetAutoFlush(ETrue);
1461 RBlankWindow parent2(TheClient->iWs);
1462 User::LeaveIfError(parent2.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle));
1463 CleanupStack::PushL(TCleanupItem(CleanUpWindow,&parent2));
1464 parent2.SetExtent(TPoint(440,0),size);
1465 parent2.SetColor(TRgb::Gray4(2));
1468 TheClient->iWs.SetAutoFlush(ETrue);
1469 RBlankWindow child1(TheClient->iWs);
1470 User::LeaveIfError(child1.Construct(parent1,ENullWsHandle));
1471 CleanupStack::PushL(TCleanupItem(CleanUpWindow,&child1));
1472 child1.SetExtent(TPoint(0,0),childSize);
1473 child1.SetColor(TRgb::Gray4(2));
1476 TheClient->iWs.SetAutoFlush(ETrue);
1477 RBlankWindow child2(TheClient->iWs);
1478 User::LeaveIfError(child2.Construct(parent1,ENullWsHandle));
1479 CleanupStack::PushL(TCleanupItem(CleanUpWindow,&child2));
1480 child2.SetExtent(TPoint(0,childSize.iHeight),childSize);
1481 child2.SetColor(TRgb::Gray4(2));
1484 TheClient->iWs.SetAutoFlush(ETrue);
1485 RBlankWindow child3(TheClient->iWs);
1486 User::LeaveIfError(child3.Construct(parent1,ENullWsHandle));
1487 CleanupStack::PushL(TCleanupItem(CleanUpWindow,&child3));
1488 child3.SetExtent(TPoint(childSize.iWidth,0),TSize(childSize.iWidth,size.iHeight));
1489 child3.SetColor(TRgb::Gray4(2));
1492 TPoint dialoguePos(375,93);
1493 TheClient->iWs.SetAutoFlush(ETrue);
1494 RBlankWindow dialog1(TheClient->iWs);
1495 User::LeaveIfError(dialog1.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle));
1496 CleanupStack::PushL(TCleanupItem(CleanUpWindow,&dialog1));
1497 dialog1.SetExtent(dialoguePos,dialogueSize);
1498 dialog1.SetColor(TRgb::Gray4(3));
1499 dialog1.SetShadowHeight(4);
1502 TheClient->iWs.SetAutoFlush(ETrue);
1503 RBlankWindow dialog2(TheClient->iWs);
1504 User::LeaveIfError(dialog2.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle));
1505 CleanupStack::PushL(TCleanupItem(CleanUpWindow,&dialog2));
1506 dialog2.SetExtent(TPoint(dialoguePos.iX+size.iWidth,dialoguePos.iY),dialogueSize);
1507 dialog2.SetColor(TRgb::Gray4(3));
1508 dialog2.SetShadowHeight(0);
1512 for (ii=400;ii>374;ii-=25)
1513 dialog1.SetPosition(TPoint(ii,93));
1514 TheClient->iWs.SetAutoFlush(EFalse);
1515 CleanupStack::PopAndDestroy(7);
1518 void CTWindowTest::ColorTestL()
1520 if (iTest->MaxGrays() == 0)
1523 _LIT(KSet,"AUTO Color Test ");
1525 RWindow window(TheClient->iWs);
1526 User::LeaveIfError(window.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle));
1527 PushWindowL(&window);
1528 window.SetExtent(TPoint(10,10),TSize(50,50));
1530 TInt colorMode,mode;
1531 TInt currentMode=TheClient->iScreen->DisplayMode();
1532 TEST(currentMode==EGray4 || currentMode==EColor16 || currentMode==EColor256 || currentMode == EColor64K);
1533 if(currentMode!=EGray4 && currentMode!=EColor16 && currentMode!=EColor256 && currentMode != EColor64K)
1534 INFO_PRINTF5(_L("TheClient->iScreen->DisplayMode() return value - Expected: %d or %d or %d, Actual: %d"), EGray4, EColor16, EColor256, currentMode);
1535 INFO_PRINTF1(_L(" Done Setup"));
1536 for(colorMode=EGray4;colorMode<EColorLast;colorMode++)
1538 INFO_PRINTF1(_L(" Loop 1"));
1539 if (colorMode==ERgb || (colorMode==EGray256 && TDisplayModeUtils::IsDisplayModeColor(REINTERPRET_CAST(TDisplayMode&,currentMode))) || (colorMode==EGray256 && TDisplayModeUtils::IsDisplayModeColor(REINTERPRET_CAST(TDisplayMode&,currentMode))) )
1541 User::LeaveIfError(window.SetRequiredDisplayMode((TDisplayMode&)colorMode));
1542 mode=window.DisplayMode();
1543 if (!(mode==currentMode || mode==colorMode))
1545 _LIT(KModes," Failed in Loop1 SetTo=%d, Actual=%d, Current=%d");
1547 log.Format(KModes,colorMode,mode,currentMode);
1550 if (mode>ERgb && colorMode==EColor64K)
1552 TEST(mode==currentMode || mode==colorMode );
1553 if (mode!=currentMode && mode!=colorMode)
1554 INFO_PRINTF4(_L("window.DisplayMode() return value - Expected: %d or %d, Actual: %d"), currentMode, colorMode, mode);
1555 INFO_PRINTF1(_L(" Loop 2"));
1556 if (mode>currentMode)
1558 if (colorMode==EColor16)
1559 window.SetSize(TSize(40,60));
1560 else if (colorMode==EColor4K)
1561 window.SetSize(TSize(60,40));
1562 mode=TheClient->iScreen->DisplayMode();
1563 if(TDisplayModeUtils::NumDisplayModeColors(STATIC_CAST(TDisplayMode,currentMode))==16777216)
1565 TEST(mode==CFbsDevice::DisplayMode16M());
1566 if (mode!=CFbsDevice::DisplayMode16M())
1567 INFO_PRINTF3(_L("window.DisplayMode() return value - Expected: %d, Actual: %d"), CFbsDevice::DisplayMode16M(), mode);
1571 TEST(currentMode==mode || currentMode==colorMode);
1572 if (currentMode!=mode && currentMode!=colorMode)
1573 INFO_PRINTF3(_L("TheClient->iScreen->DisplayMode() return value return value - Expected: %d , Actual: %d"), currentMode, mode);
1576 INFO_PRINTF1(_L(" Done First Loop"));
1578 TDisplayMode defMode=TheClient->iWs.GetDefModeMaxNumColors(color,gray);
1579 TInt screenNo =TheClient->iScreen->GetScreenNumber();
1580 TDisplayMode defModeForScreen=TheClient->iWs.GetDefModeMaxNumColors(screenNo,color,gray);
1581 TEST(defMode==defModeForScreen);
1582 if (defMode!=defModeForScreen)
1583 INFO_PRINTF3(_L("TheClient->iScreen->DisplayMode() return value return value - Expected: %d , Actual: %d"), defMode, defModeForScreen);
1584 if (color==16777216 && gray==256)
1586 TEST(defMode==EGray4 || defMode==EColor256 || defMode==EColor64K); //WINS
1587 if (defMode!=EGray4 && defMode!=EColor256 && defMode != EColor64K)
1588 INFO_PRINTF4(_L("TheClient->iWs.GetDefModeMaxNumColors(color,gray) return value return value - Expected: %d or %d, Actual: %d"), EGray4, EColor256, defMode);
1592 if (color==0 && gray==16)
1594 TEST(defMode==EGray4); //S5 family
1595 if (defMode!=EGray4)
1596 INFO_PRINTF3(_L("TheClient->iScreen->DisplayMode() return value return value - Expected: %d , Actual: %d"), EGray4, defMode);
1600 TLogMessageText buf;
1601 _LIT(KColorSettings,"##Data Most Colors=%d, Most Greys=%d, DefMode=%d");
1602 buf.Format(KColorSettings,color,gray,defMode);
1603 TheClient->iWs.LogMessage(buf);
1604 TheClient->iWs.Flush();
1605 TEST(defMode==EGray4 || defMode==EColor256);
1606 if (defMode!=EGray4 && defMode!=EColor256)
1607 INFO_PRINTF4(_L("TheClient->iWs.GetDefModeMaxNumColors(color,gray) return value return value - Expected: %d or %d, Actual: %d"), EGray4, EColor256, defMode);
1610 CArrayFixFlat<TInt> *colorModes=new(ELeave) CArrayFixFlat<TInt>(1);
1611 CleanupStack::PushL(colorModes);
1612 User::LeaveIfError(TheClient->iWs.GetColorModeList(screenNo,colorModes));
1613 TDisplayMode mostColor=ENone;
1614 TDisplayMode lastGray=ENone;
1615 TDisplayMode dispMode;
1617 TInt colorModes16M = 0;
1618 INFO_PRINTF1(_L(" Done Setup 2"));
1619 for (ii=0;ii<colorModes->Count();ii++)
1621 dispMode=(TDisplayMode)(*colorModes)[ii];
1622 TEST(dispMode!=ERgb);
1624 INFO_PRINTF3(_L("(TDisplayMode)(*colorModes)[i] return value - Not Expected: %d , Actual: %d"), ERgb, dispMode);
1625 TEST(dispMode!=ENone);
1626 if (dispMode==ENone)
1627 INFO_PRINTF3(_L("(TDisplayMode)(*colorModes)[i] return value - Not Expected: %d , Actual: %d"), ENone, dispMode);
1628 if (dispMode<=EGray256)
1632 if(dispMode == EColor16M || dispMode == EColor16MU || dispMode == EColor16MA)
1635 TEST(mostColor!=ERgb);
1636 if (mostColor==ERgb)
1637 INFO_PRINTF3(_L("mostColor - Not Expected: %d , Actual: %d"), ERgb, mostColor);
1638 TEST(colorModes16M <= 1);
1639 if (colorModes16M > 1)
1640 INFO_PRINTF3(_L("Number of times color Modes 16M - less than or equal to: %d , Actual: %d"), 1, colorModes16M);
1641 #if defined(__WINS__)
1642 TEST(colorModes16M == 1);
1643 if (colorModes16M != 1)
1644 INFO_PRINTF3(_L("Number of times color Modes 16M on wins - equal to: %d , Actual: %d"), 1, colorModes16M);
1649 TEST(mostColor==ENone);
1650 if (mostColor!=ENone)
1651 INFO_PRINTF3(_L("Most color - equal to: %d , Actual: %d"), ENone ,mostColor);
1655 retVal = TDisplayModeUtils::NumDisplayModeColors(mostColor);
1656 TEST(color==retVal);
1658 INFO_PRINTF3(_L("TDisplayModeUtils::NumDisplayModeColors(mostColor) return value - equal to: %d , Actual: %d"), TDisplayModeUtils::NumDisplayModeColors(mostColor), retVal);
1662 TEST(lastGray==ENone);
1663 if (lastGray!=ENone)
1664 INFO_PRINTF3(_L("LastGray - equal to: %d , Actual: %d"), ENone, lastGray);
1668 retVal = TDisplayModeUtils::NumDisplayModeColors(lastGray);
1671 INFO_PRINTF3(_L("Gray - equal to: %d , Actual: %d"), retVal, gray);
1673 retVal = TDisplayModeUtils::NumDisplayModeColors(ENone);
1676 INFO_PRINTF3(_L("TDisplayModeUtils::NumDisplayModeColors(ENone) return value - equal to: %d , Actual: %d"), 0, retVal);
1677 CleanupStack::PopAndDestroy(2); //window and mode-array
1680 void CTWindowTest::TestInvalidFunctions2L()
1682 // This code casts windows to group windows and vice-versa and then sends messages for the 'cast' that
1683 // should not be sent to the original type of window. These should all result in panics
1686 for (TInt winType=1;winType<7;++winType) //Skip type 0 (RWindowTreeNode)
1687 for (TInt panic=0;;panic++)
1689 TBool testFinished=EFalse;
1690 TEST(iTest->TestWsPanicL(DoPanicTest3,EWservPanicOpcode,EWinTypeFactor*winType+panic,(TAny*)iTest->iScreenNumber,&testFinished));
1694 iTest->CloseAllPanicWindows();
1697 void CTWindowTest::TestDeletedParentPanics1L()
1699 for (TInt winType=0;winType<7;++winType)
1701 if (winType==1) //Skip type 1 (RWindowGroup)
1703 for (TInt panic=0;;panic++)
1705 TBool testFinished=EFalse;
1706 TEST(iTest->TestWsPanicL(DoPanicTest4,EWservPanicParentDeleted,EWinTypeFactor*winType+panic,(TAny*)iTest->iScreenNumber,&testFinished));
1711 iTest->CloseAllPanicWindows();
1714 void CTWindowTest::TestDeletedParentPanics2L()
1716 for (TInt panic=0;;panic++)
1718 TBool testFinished=EFalse;
1719 TEST(iTest->TestWsPanicL(DoPanicTest5,EWservPanicParentDeleted,panic,(TAny*)iTest->iScreenNumber,&testFinished));
1723 iTest->CloseAllPanicWindows();
1726 void CTWindowTest::Bug1L()
1728 // Test a defect found with WSERV 099 that caused a full Eikon ROM to crash before even the splach screen appeared
1732 User::LeaveIfError(ws.Connect());
1733 // use correct screen
1734 CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
1735 CleanupStack::PushL(screen);
1736 User::LeaveIfError(screen->Construct(iTest->iScreenNumber));
1738 RWindowGroup group(ws);
1739 group.Construct(344);
1740 group.EnableReceiptOfFocus(EFalse); //Not done by Eikon, but needed to stop shell window comming to front.
1741 RBlankWindow blank(ws);
1742 blank.Construct(group,345);
1743 blank.SetOrdinalPosition(0,1000);
1746 window.Construct(group,346);
1748 //Must delete this window to tidy up
1753 CleanupStack::PopAndDestroy(screen);
1757 void CTWindowTest::TestWindowDelete()
1760 TInt err = KErrNone;
1762 TInt allocFailRate = 0;
1764 RWindowGroup group(TheClient->iWs);
1765 RWindow parent1(TheClient->iWs);
1766 RWindow child1(TheClient->iWs);
1767 RWindow testWindow(TheClient->iWs);
1771 err = group.Construct(++handles, EFalse);
1772 if (err == KErrNone)
1774 TheClient->iWs.HeapSetFail(RHeap::EDeterministic, allocFailRate);
1777 err = parent1.Construct(group,++handles);
1778 if (err == KErrNone)
1780 parent1.SetExtent(TPoint(10,10),TSize(50,50));
1785 if (err == KErrNone)
1787 err = child1.Construct(parent1,++handles);
1788 if (err == KErrNone)
1790 child1.SetExtent(TPoint(),TSize(50,20));
1793 //Only delete the parent 1, but not the child 1
1797 if (err == KErrNone)
1800 err = testWindow.Construct(group,++handles);
1801 if (err == KErrNone)
1803 testWindow.SetExtent(TPoint(0,20),TSize(50,30));
1804 testWindow.Activate();
1807 TheClient->iWs.HeapSetFail(RAllocator::ENone, 0);
1813 loop = (err == KErrNone) ? loop + 1 : 0;
1816 void CTWindowTest::Bug2L()
1818 // Test a defect ...
1821 TSize offset(20,20);
1822 TRect screen(TheClient->iScreen->SizeInPixels()-offset);
1825 User::LeaveIfError(ws1.Connect());
1826 ws1.SetAutoFlush(ETrue);
1828 // use correct screen
1830 CWsScreenDevice* scr1 = new (ELeave) CWsScreenDevice(ws1);
1831 CleanupStack::PushL(scr1);
1832 User::LeaveIfError(scr1->Construct(iTest->iScreenNumber));
1835 User::LeaveIfError(ws2.Connect());
1836 ws2.SetAutoFlush(ETrue);
1838 // use correct screen
1840 CWsScreenDevice* scr2 = new (ELeave) CWsScreenDevice(ws2);
1841 CleanupStack::PushL(scr2);
1842 User::LeaveIfError(scr2->Construct(iTest->iScreenNumber));
1844 RWindowGroup group1a(ws1);
1845 group1a.Construct(344);
1846 group1a.EnableReceiptOfFocus(EFalse);
1847 group1a.SetOrdinalPosition(0,5);
1848 RBlankWindow blank1a(ws1);
1849 blank1a.Construct(group1a,345);
1850 color=TRgb::Gray4(0);
1851 blank1a.SetColor(color);
1852 blank1a.SetExtent(screen.iTl,screen.Size());
1853 blank1a.EnableBackup();
1856 RWindowGroup group2(ws2);
1857 group2.Construct(342);
1858 group2.EnableReceiptOfFocus(EFalse);
1859 group2.SetOrdinalPosition(0,5);
1860 RBlankWindow blank2(ws2);
1861 blank2.Construct(group2,347);
1862 color=TRgb::Gray4(1);
1863 blank2.SetColor(color);
1864 blank2.SetExtent(screen.iTl+TSize(20,0),screen.Size());
1865 blank2.EnableBackup();
1868 RWindowGroup group1b(ws1);
1869 group1b.Construct(343);
1870 //group1b.EnableReceiptOfFocus(EFalse);
1871 group1b.SetOrdinalPosition(0,5);
1872 RBlankWindow blank1b(ws1);
1873 blank1b.Construct(group1b,346);
1874 color=TRgb::Gray4(2);
1875 blank1b.SetColor(color);
1876 blank1b.SetExtent(screen.iTl+offset,screen.Size());
1877 blank1b.EnableBackup();
1887 CleanupStack::PopAndDestroy(2,scr1);
1892 void CTWindowTest::Bug3L()
1894 // Actiate then make visible and backup behind window caused panic.
1897 TSize offset(20,20);
1898 TRect screen(TheClient->iScreen->SizeInPixels()-offset);
1901 User::LeaveIfError(ws.Connect());
1902 ws.SetAutoFlush(ETrue);
1904 // use correct screen
1906 CWsScreenDevice* scr = new (ELeave) CWsScreenDevice(ws);
1907 CleanupStack::PushL(scr);
1908 User::LeaveIfError(scr->Construct(iTest->iScreenNumber));
1910 RWindowGroup group(ws);
1911 group.Construct(348);
1912 group.EnableReceiptOfFocus(EFalse);
1913 RBlankWindow blank1(ws);
1914 blank1.Construct(group,341);
1915 color=TRgb::Gray4(1);
1916 blank1.SetColor(color);
1917 blank1.SetExtent(screen.iTl,screen.Size());
1918 blank1.EnableBackup();
1919 blank1.SetVisible(EFalse);
1921 blank1.SetVisible(ETrue);
1922 RBlankWindow blank2(ws);
1923 blank2.Construct(group,342);
1924 color=TRgb::Gray4(2);
1925 blank2.SetColor(color);
1926 blank2.SetExtent(screen.iTl,screen.Size());
1927 blank2.EnableBackup();
1928 blank2.SetVisible(EFalse);
1929 blank2.SetVisible(ETrue);
1935 CleanupStack::PopAndDestroy(scr);
1939 void CTWindowTest::ErrorCodesL()
1942 User::LeaveIfError(ws.Connect());
1943 // use correct screen
1945 CWsScreenDevice* scr = new (ELeave) CWsScreenDevice(ws);
1946 CleanupStack::PushL(scr);
1947 User::LeaveIfError(scr->Construct(iTest->iScreenNumber));
1950 RWindowGroup group(ws);
1951 group.Construct(349);
1952 group.EnableReceiptOfFocus(EFalse);
1953 RWindow window(TheClient->iWs);
1954 User::LeaveIfError(window.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle));
1955 TInt retVal = window.MoveToGroup(22222);
1956 TEST(retVal==KErrNotFound);
1957 if (retVal!=KErrNotFound)
1958 INFO_PRINTF3(_L("window.MoveToGroup(22222) return value - equal to: %d , Actual: %d"), KErrNotFound, retVal);
1959 retVal = window.MoveToGroup(group.Identifier());
1960 TEST(retVal==KErrNotFound);
1961 if (retVal!=KErrNotFound)
1962 INFO_PRINTF3(_L("window.MoveToGroup(group.Identifier()) return value - equal to: %d , Actual: %d"), KErrNotFound, retVal);
1966 CleanupStack::PopAndDestroy(scr);
1970 void CTWindowTest::BackColorBugL()
1972 // Test a defect with window being drawn with the wrong background color when they are moved on the screen
1975 TSize scrSize(TheClient->iScreen->SizeInPixels());
1976 TSize checkSize(12,10); //X-Size needs to be multiple of 4 due to BITGDI change/defect
1978 win=new(ELeave) CBlankWindow(TRgb(16,16,240));
1979 CleanupStack::PushL(win);
1980 win->SetUpL(TPoint(5,5),scrSize-TSize(10,10),TheClient->iGroup,*TheClient->iGc);
1981 TInt mode=win->BaseWin()->SetRequiredDisplayMode(EColor256);
1982 const TDisplayMode actualMode=reinterpret_cast<TDisplayMode&>(mode);
1983 if (!TDisplayModeUtils::IsDisplayModeColor(actualMode) || TDisplayModeUtils::NumDisplayModeColors(actualMode)<256)
1985 CleanupStack::PopAndDestroy(win);
1988 win->RealDraw(ETrue);
1989 win->Win()->SetBackgroundColor(TRgb(64,224,64));
1991 win3=new(ELeave) CBlankWindow(TRgb::Gray16(8));
1992 CleanupStack::PushL(win3);
1993 win3->SetUpL(TPoint(12,12),checkSize,TheClient->iGroup,*TheClient->iGc);
1994 win3->BaseWin()->SetRequiredDisplayMode(EColor256);
1996 win2=new(ELeave) CBlankWindow(TRgb(240,16,16));
1997 CleanupStack::PushL(win2);
1998 win2->SetUpL(TPoint(10,scrSize.iHeight/2),TSize(scrSize.iWidth/3,scrSize.iHeight/2-10),TheClient->iGroup,*TheClient->iGc);
1999 win2->BaseWin()->SetRequiredDisplayMode(EColor256);
2000 win2->RealDraw(EFalse);
2002 win2->Win()->SetBackgroundColor(TRgb::Gray16(8));
2003 win2->SetExt(TPoint(scrSize.iWidth/4,30),TSize(scrSize.iWidth/2,2*scrSize.iHeight/3));
2004 TheClient->iWs.Finish();
2005 TheClient->WaitForRedrawsToFinish();
2006 if (!CheckRect(win2,win3,TRect(checkSize)))
2008 _LIT(KLog,"After window is moved and resizes it doesn't matches the other window");
2010 //Code to save a screen shot useful if this test fails
2011 /*_LIT(KTest,"E:\\logs\\testexecute\\Window%d");
2013 buf.Format(KTest,iTest->iState);
2014 TInt err=iTest->SaveScreen(buf);
2015 _LIT(KLogSave,"Saved screenshot to file %S, (err=%d)");
2016 LOG_MESSAGE3(KLogSave,&buf,err);*/
2018 TheClient->WaitForRedrawsToFinish();
2019 CleanupStack::PopAndDestroy(3,win);
2022 void CTWindowTest::FocusChangedL()
2024 // Test that the focus change is available when the redraw is
2025 // it should be available before, but it isn't always possible to test that
2028 _LIT(KThreadName,"MoveGroup");
2029 _LIT(KEventWaiting,"Event Waiting when none expected.");
2031 iThreadParam.iScreenNumber=iTest->iScreenNumber;
2032 iFirstFunction=TThreadStartUp(CTWindowTest::MoveGroup,&iThreadParam);
2033 TRequestStatus status;
2034 TSize scrSize(TheClient->iScreen->SizeInPixels());
2035 CTWindowGroup* group1=new(ELeave) CTWindowGroup(TheClient);
2036 group1->ConstructL();
2037 CleanupStack::PushL(group1);
2038 TInt winId1=group1->GroupWin()->Identifier();
2039 CBlankWindow* win1=new(ELeave) CBlankWindow(TRgb::Gray4(1));
2040 CleanupStack::PushL(win1);
2041 win1->SetUpL(TPoint(1,1),TSize(2*scrSize.iWidth/3,2*scrSize.iHeight/3),group1,*TheClient->iGc);
2042 win1->RealDraw(ETrue);
2043 win1->Win()->SetBackgroundColor(TRgb::Gray4(3));
2044 CTWindowGroup* group2=new(ELeave) CTWindowGroup(TheClient);
2045 group2->ConstructL();
2046 CleanupStack::PushL(group2);
2047 TInt winId2=group2->GroupWin()->Identifier();
2048 CBlankWindow* win2=new(ELeave) CBlankWindow(TRgb::Gray4(2));
2049 CleanupStack::PushL(win2);
2050 win2->SetUpL(TPoint(scrSize.iWidth/3-5,scrSize.iHeight/3-5),TSize(2*scrSize.iWidth/3,2*scrSize.iHeight/3),group2,*TheClient->iGc);
2051 win2->RealDraw(ETrue);
2052 win2->Win()->SetBackgroundColor(TRgb::Gray4(0));
2054 TheClient->WaitForRedrawsToFinish();
2055 TheClient->WaitForAllEventProcessingToFinish();
2057 iThreadParam.iCommand=command;
2058 TBool noEventWaiting=!TheClient->IsEventWaiting();
2059 TEST(noEventWaiting);
2060 if (!noEventWaiting)
2061 LOG_MESSAGE(KEventWaiting);
2062 _LIT(KTest1,"FocusChangedL: 1st test completed");
2063 LOG_MESSAGE(KTest1);
2064 CProcess* iMoveGroup=CProcess::NewSimpleThreadL(KThreadName,&iFirstFunction,&status);
2065 User::WaitForRequest(status);
2067 TEST(TheClient->WaitForEvent());
2068 TheClient->WaitForAllEventProcessingToFinish();
2071 iThreadParam.iCommand=command;
2072 TheClient->WaitForRedrawsToFinish();
2073 noEventWaiting=!TheClient->IsEventWaiting();
2074 TEST(noEventWaiting);
2075 if (!noEventWaiting)
2076 LOG_MESSAGE(KEventWaiting);
2077 _LIT(KTest2,"FocusChangedL: 2nd test completed");
2078 LOG_MESSAGE(KTest2);
2079 iMoveGroup=CProcess::NewSimpleThreadL(KThreadName,&iFirstFunction,&status);
2080 User::WaitForRequest(status);
2082 TEST(TheClient->WaitForEvent());
2083 TheClient->WaitForAllEventProcessingToFinish();
2085 command=winId2|(1<<EPosShift);
2086 iThreadParam.iCommand=command;
2087 TheClient->WaitForRedrawsToFinish();
2088 noEventWaiting=!TheClient->IsEventWaiting();
2089 TEST(noEventWaiting);
2090 if (!noEventWaiting)
2091 LOG_MESSAGE(KEventWaiting);
2092 _LIT(KTest3,"FocusChangedL: 3rd test completed");
2093 LOG_MESSAGE(KTest3);
2094 iMoveGroup=CProcess::NewSimpleThreadL(KThreadName,&iFirstFunction,&status);
2095 User::WaitForRequest(status);
2097 TEST(TheClient->WaitForEvent());
2098 TheClient->WaitForAllEventProcessingToFinish();
2100 command=winId1|(1<<EPosShift);
2101 iThreadParam.iCommand=command;
2102 TheClient->WaitForRedrawsToFinish();
2103 noEventWaiting=!TheClient->IsEventWaiting();
2104 TEST(noEventWaiting);
2105 if (!noEventWaiting)
2106 LOG_MESSAGE(KEventWaiting);
2107 _LIT(KTest4,"FocusChangedL: 4th test completed");
2108 LOG_MESSAGE(KTest4);
2109 iMoveGroup=CProcess::NewSimpleThreadL(KThreadName,&iFirstFunction,&status);
2110 User::WaitForRequest(status);
2112 TEST(TheClient->WaitForEvent());
2113 TheClient->WaitForAllEventProcessingToFinish();
2115 TheClient->WaitForRedrawsToFinish();
2116 noEventWaiting=!TheClient->IsEventWaiting();
2117 TEST(noEventWaiting);
2118 if (!noEventWaiting)
2119 LOG_MESSAGE(KEventWaiting);
2120 _LIT(KTest5,"FocusChangedL: 5th and last test completed");
2121 LOG_MESSAGE(KTest5);
2122 CleanupStack::PopAndDestroy(2,group2);
2124 TEST(TheClient->WaitForEvent());
2125 TheClient->WaitForAllEventProcessingToFinish();
2126 CleanupStack::PopAndDestroy(2,group1);
2130 void CTWindowTest::EventsToAllL()
2132 CTClient* client1=new(ELeave) CTClient;
2133 CleanupStack::PushL(client1);
2134 client1->SetScreenNumber(iTest->iScreenNumber);
2135 client1->ConstructL();
2136 CTClient* client2=new(ELeave) CTClient;
2137 CleanupStack::PushL(client2);
2138 client2->SetScreenNumber(iTest->iScreenNumber);
2139 client2->ConstructL();
2140 CEvWindowGroup* group1a=CEvWindowGroup::NewLC(client1,this);
2141 CEvWindowGroup* group1b=CEvWindowGroup::NewLC(client1,this);
2142 CEvWindowGroup* group2a=CEvWindowGroup::NewLC(client2,this);
2143 CEvWindowGroup* group2b=CEvWindowGroup::NewLC(client2,this);
2144 /*_LIT(KLog,"Window Group Id's: %d,%d,%d,%d");
2145 LOG_MESSAGE5(KLog,group1a->GroupWin()->Identifier(),group1b->GroupWin()->Identifier(),group2a->GroupWin()->Identifier(),group2b->GroupWin()->Identifier());*/
2146 group1a->SendEvent(KBaseUserEvent+1);
2147 group2b->SendEvent(KBaseUserEvent+2);
2148 client1->WaitForAllEventProcessingToFinish();
2149 client2->WaitForAllEventProcessingToFinish();
2151 // Assigned random value because before PREQ1226, TWsevent's data wasn't zero initialised.
2152 // In techview, following function
2153 // void CEikServAppUi::HandleSystemEventL(const TWsEvent& aEvent)
2154 // was relaying on TWsevent's data not be zero
2155 *(event.Int()) = 0XCCCCCCCC;
2156 event.SetType(KBaseUserEvent+3);
2157 group1a->SetExpectedEvent(KBaseUserEvent+3);
2158 group1b->SetExpectedEvent(KBaseUserEvent+3);
2159 group2a->SetExpectedEvent(KBaseUserEvent+3);
2160 group2b->SetExpectedEvent(KBaseUserEvent+3);
2161 TheClient->iWs.SendEventToAllWindowGroups(event);
2162 client1->WaitForAllEventProcessingToFinish();
2163 client2->WaitForAllEventProcessingToFinish();
2164 event.SetType(KBaseUserEvent+4);
2165 group1a->SetExpectedEvent(KBaseUserEvent+4);
2166 group1b->SetExpectedEvent(KBaseUserEvent+4);
2167 group2a->SetExpectedEvent(KBaseUserEvent+4);
2168 group2b->SetExpectedEvent(KBaseUserEvent+4);
2169 TheClient->iWs.SendEventToAllWindowGroups(event);
2170 client1->WaitForAllEventProcessingToFinish();
2171 client2->WaitForAllEventProcessingToFinish();
2172 event.SetType(KBaseUserEvent+5);
2173 //group1a->SetExpectedEvent(KBaseUserEvent+5);
2174 group1b->SetExpectedEvent(KBaseUserEvent+5);
2175 //group2a->SetExpectedEvent(KBaseUserEvent+5);
2176 group2b->SetExpectedEvent(KBaseUserEvent+5);
2177 TheClient->iWs.SendEventToOneWindowGroupsPerClient(event);
2178 client1->WaitForAllEventProcessingToFinish();
2179 client2->WaitForAllEventProcessingToFinish();
2180 group1a->WinTreeNode()->SetOrdinalPosition(0);
2182 event.SetType(KBaseUserEvent+6);
2183 group1a->SetExpectedEvent(KBaseUserEvent+6);
2184 group2b->SetExpectedEvent(KBaseUserEvent+6);
2185 TheClient->iWs.SendEventToOneWindowGroupsPerClient(event);
2186 client1->WaitForAllEventProcessingToFinish();
2187 client2->WaitForAllEventProcessingToFinish();
2188 group2b->WinTreeNode()->SetOrdinalPosition(6);
2190 event.SetType(KBaseUserEvent+7);
2191 group1a->SetExpectedEvent(KBaseUserEvent+7);
2192 group2a->SetExpectedEvent(KBaseUserEvent+7);
2193 TheClient->iWs.SendEventToOneWindowGroupsPerClient(event);
2194 client1->WaitForAllEventProcessingToFinish();
2195 client2->WaitForAllEventProcessingToFinish();
2196 event.SetType(KBaseUserEvent+8);
2197 group1a->SetExpectedEvent(KBaseUserEvent+8);
2198 group1b->SetExpectedEvent(KBaseUserEvent+8);
2199 group2a->SetExpectedEvent(KBaseUserEvent+8);
2200 group2b->SetExpectedEvent(KBaseUserEvent+8);
2201 TheClient->iWs.SendEventToAllWindowGroups(0,event);
2202 group1a->WinTreeNode()->SetOrdinalPosition(0,ALT_PRI);
2204 client1->WaitForAllEventProcessingToFinish();
2205 client2->WaitForAllEventProcessingToFinish();
2206 event.SetType(KBaseUserEvent+9);
2207 group1a->SetExpectedEvent(KBaseUserEvent+9);
2208 TheClient->iWs.SendEventToAllWindowGroups(ALT_PRI,event);
2209 client1->WaitForAllEventProcessingToFinish();
2210 client2->WaitForAllEventProcessingToFinish();
2211 group2b->WinTreeNode()->SetOrdinalPosition(0,ALT_PRI);
2213 client1->WaitForAllEventProcessingToFinish();
2214 client2->WaitForAllEventProcessingToFinish();
2215 event.SetType(KBaseUserEvent+10);
2216 group1a->SetExpectedEvent(KBaseUserEvent+10);
2217 group2b->SetExpectedEvent(KBaseUserEvent+10);
2218 TheClient->iWs.SendEventToAllWindowGroups(ALT_PRI,event);
2219 client1->WaitForAllEventProcessingToFinish();
2220 client2->WaitForAllEventProcessingToFinish();
2221 event.SetType(KBaseUserEvent+11);
2222 group1b->SetExpectedEvent(KBaseUserEvent+11);
2223 group2a->SetExpectedEvent(KBaseUserEvent+11);
2224 TheClient->iWs.SendEventToAllWindowGroups(0,event);
2225 client1->WaitForAllEventProcessingToFinish();
2226 client2->WaitForAllEventProcessingToFinish();
2227 event.SetType(KBaseUserEvent);
2228 group1a->SetExpectedEvent(KBaseUserEvent);
2229 group1b->SetExpectedEvent(KBaseUserEvent);
2230 group2a->SetExpectedEvent(KBaseUserEvent);
2231 group2b->SetExpectedEvent(KBaseUserEvent);
2232 TheClient->iWs.SendEventToAllWindowGroups(event);
2233 client1->WaitForAllEventProcessingToFinish();
2234 client2->WaitForAllEventProcessingToFinish();
2235 CleanupStack::PopAndDestroy(6,client1);
2238 void DestroyWindow(TAny* aWindow)
2240 static_cast<RWindowTreeNode*>(aWindow)->Destroy();
2243 void CTWindowTest::GroupIdL()
2245 const TInt numWindows=10;
2246 RWindowGroup group(TheClient->iWs);
2247 CleanupClosePushL(group);
2248 User::LeaveIfError(group.Construct(ENullWsHandle));
2249 TInt id=group.Identifier();
2250 RWindowTreeNode* prevWindow=&group;
2252 for (ii=0;ii<numWindows;++ii)
2254 RBlankWindow* window=new(ELeave) RBlankWindow(TheClient->iWs);
2255 CleanupStack::PushL(TCleanupItem(&DestroyWindow,window));
2256 User::LeaveIfError(window->Construct(*prevWindow,ENullWsHandle));
2257 TInt retVal = window->WindowGroupId();
2260 INFO_PRINTF3(_L("window->WindowGroupId() return value - equal to: %d , Actual: %d"), id, retVal);
2263 CleanupStack::PopAndDestroy(numWindows+1);
2267 @SYMTestCaseID GRAPHICS-WSERV-0495
2271 @SYMTestCaseDesc Sending Events using one of the functions SendEventToWindowGroup, SendEventToAllWindowGroups (x2)
2272 and SendEventToOneWindowGroupsPerClient when an event queue is full returns an error
2274 @SYMTestPriority Low
2276 @SYMTestStatus Implemented
2278 @SYMTestActions Call the functions repeatly many times and check that an error gets returned eventually
2280 @SYMTestExpectedResults Functions return the error KErrNoMemory
2282 const TInt numTest=75; //Must be at least 33
2283 void CTWindowTest::SaturateSendEvent()
2285 const TInt id=TheClient->iGroup->GroupWin()->Identifier();
2287 event.SetType(KBaseUserEvent);
2291 for (ii=0; ii<=numTest && err==KErrNone;)
2294 err=TheClient->iWs.SendEventToWindowGroup(id,event);
2296 TEST(err==KErrNoMemory);
2297 if (err!=KErrNoMemory)
2299 _LIT(KLog,"After %d/%d iterations SendEventToWindowGroup returned the error %d");
2300 LOG_MESSAGE4(KLog,ii,numTest,err);
2302 TheClient->WaitForAllEventProcessingToFinish();
2305 for (ii=0; ii<=numTest && err==KErrNone;)
2308 err=TheClient->iWs.SendEventToAllWindowGroups(event);
2310 TEST(err==KErrNoMemory);
2311 if (err!=KErrNoMemory)
2313 _LIT(KLog,"After %d/%d iterations SendEventToAllWindowGroups returned the error %d");
2314 LOG_MESSAGE4(KLog,ii,numTest,err);
2316 TheClient->WaitForAllEventProcessingToFinish();
2317 User::After(1000000); //1sec, give other sessions a chance to respond to the events
2320 for (ii=0; ii<=numTest && err==KErrNone;)
2323 err=TheClient->iWs.SendEventToAllWindowGroups(0,event);
2325 TEST(err==KErrNoMemory);
2326 if (err!=KErrNoMemory)
2328 _LIT(KLog,"After %d/%d iterations SendEventToAllWindowGroups_Priority0 returned the error %d");
2329 LOG_MESSAGE4(KLog,ii,numTest,err);
2331 TheClient->WaitForAllEventProcessingToFinish();
2332 User::After(1000000); //1sec, give other sessions a chance to respond to the events
2335 for (ii=0; ii<=numTest && err==KErrNone;)
2338 err=TheClient->iWs.SendEventToOneWindowGroupsPerClient(event);
2340 TEST(err==KErrNoMemory);
2341 if (err!=KErrNoMemory)
2343 _LIT(KLog,"After %d/%d iterations SendEventToOneWindowGroupsPerClient returned the error %d");
2344 LOG_MESSAGE4(KLog,ii,numTest,err);
2346 TheClient->WaitForAllEventProcessingToFinish();
2347 User::After(1000000); //1sec, give other sessions a chance to respond to the events
2350 void CTWindowTest::TestNotSupportedFunctionality()
2352 TInt err = KErrNone;
2353 TSize windowSize = TSize(10,10);
2354 TSize testSize = TSize();
2356 RWindowGroup group(TheClient->iWs);
2357 RWindow window(TheClient->iWs);
2359 err = group.Construct((TUint32)&group, EFalse);
2360 TEST(err==KErrNone);
2361 err = window.Construct(group,(TUint32)&window);
2362 TEST(err==KErrNone);
2364 window.SetExtent(TPoint(0,0),windowSize);
2367 testSize = window.Size();
2368 TEST((testSize.iWidth==windowSize.iWidth) && (testSize.iHeight==windowSize.iHeight));
2370 testSize = window.Size();
2371 TEST((testSize.iWidth==windowSize.iWidth) && (testSize.iHeight==windowSize.iHeight));
2377 void CTWindowTest::RunTestCaseL(TInt /*aCurTestCase*/)
2379 _LIT(KTest1,"Window");
2380 _LIT(KTest2,"DestroyWindowWithActiveGc");
2381 _LIT(KTest3,"Shadow/NoAutoClear");
2382 _LIT(KTest4,"Corner Tests");
2383 _LIT(KTest5,"Invalid Window Functions");
2384 _LIT(KTest7,"Mega-Tree");
2385 _LIT(KTest8,"Tiled Window One");
2386 _LIT(KTest9,"Tiled Window Two");
2387 _LIT(KTest10,"Color Test");
2388 _LIT(KTest11,"Invalid Window Functions2");
2389 _LIT(KTest12,"Defect 1");
2390 _LIT(KTest13,"Defect 2");
2391 _LIT(KTest14,"Parent Deleted 1");
2392 _LIT(KTest15,"Parent Deleted 2");
2393 _LIT(KTest16,"Defect 3");
2394 _LIT(KTest17,"Background Color");
2395 _LIT(KTest18,"Focus Changed");
2396 _LIT(KTest21,"Events To All");
2397 _LIT(KTest22,"Error Codes");
2398 _LIT(KTest23,"Group Id");
2399 _LIT(KTest24,"DeleteParentWindowOnly");
2401 _LIT(KTest25,"DuplicateWindowHandles");
2403 _LIT(KTest25skipped,"DuplicateWindowHandles skipped");
2406 ((CTWindowTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
2408 _LIT(KTest26,"Saturate SendEvent");
2409 _LIT(KTest27,"Not Supported Functionality");
2411 switch(++iTest->iState)
2414 @SYMTestCaseID GRAPHICS-WSERV-0029
2418 @SYMTestCaseDesc Test window can be created and destroyed correctly
2420 @SYMTestPriority High
2422 @SYMTestStatus Implemented
2424 @SYMTestActions Creates and destroys a window
2426 @SYMTestExpectedResults Window is created and destroyed without error
2429 ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0029"));
2430 iTest->LogSubTest(KTest1);
2431 CreateTestWindowL();
2432 CheckAndDestroyWindows();
2436 @SYMTestCaseID GRAPHICS-WSERV-0030
2440 @SYMTestCaseDesc Creates and destroys window with an active gc
2442 @SYMTestPriority High
2444 @SYMTestStatus Implemented
2446 @SYMTestActions Create and destroy a window with an active gc
2448 @SYMTestExpectedResults Window is created and destroyed without error
2451 ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0030"));
2452 iTest->LogSubTest(KTest2);
2453 CreateTestWindowL();
2454 DestroyWindowWithActiveGc();
2455 CreateTestWindowL();
2456 DestroyWindowWithActiveGc2L();
2459 @SYMTestCaseID GRAPHICS-WSERV-0031
2463 @SYMTestCaseDesc Test that shadow is not automatically cleared when
2466 @SYMTestPriority High
2468 @SYMTestStatus Implemented
2470 @SYMTestActions Draw windows and check that the shadow is not automatically
2473 @SYMTestExpectedResults Screen comparison returns that the shadow was not cleared
2476 ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0031"));
2477 //window shadowing is no longer supported. keep the test to make sure clients can still call the methods
2478 iTest->LogSubTest(KTest3);
2479 ShadowAutoClearTest();
2482 @SYMTestCaseID GRAPHICS-WSERV-0032
2486 @SYMTestCaseDesc Test the drawing of different types of corner of
2489 @SYMTestPriority High
2491 @SYMTestStatus Implemented
2493 @SYMTestActions Draw a window with different types of corner
2495 @SYMTestExpectedResults The window is drawn correctly for each corner type
2498 ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0032"));
2499 iTest->LogSubTest(KTest4);
2503 @SYMTestCaseID GRAPHICS-WSERV-0033
2507 @SYMTestCaseDesc Test for panics when window is sent wrong requests
2509 @SYMTestPriority High
2511 @SYMTestStatus Implemented
2513 @SYMTestActions Send wrong requests to windows and deal with panic
2515 @SYMTestExpectedResults The windows panic as expected
2518 ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0033"));
2519 iTest->LogSubTest(KTest5);
2520 TestInvalidFunctionsL();
2523 @SYMTestCaseID GRAPHICS-WSERV-0035
2527 @SYMTestCaseDesc Draw 100 windows from a thread
2529 @SYMTestPriority High
2531 @SYMTestStatus Implemented
2533 @SYMTestActions Draw 100 windows from the same thread
2535 @SYMTestExpectedResults The windows are all drawn without error
2538 ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0035"));
2539 iTest->LogSubTest(KTest7);
2543 @SYMTestCaseID GRAPHICS-WSERV-0036
2547 @SYMTestCaseDesc Check that windows can be drawn in a tiled format
2549 @SYMTestPriority High
2551 @SYMTestStatus Implemented
2553 @SYMTestActions Draw two windows in a tiled format and check they
2556 @SYMTestExpectedResults The tiled windows are identical
2559 ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0036"));
2561 iTest->LogSubTest(KTest8);
2565 @SYMTestCaseID GRAPHICS-WSERV-0037
2569 @SYMTestCaseDesc Check that windows and dialogs can be drawn in a
2572 @SYMTestPriority High
2574 @SYMTestStatus Implemented
2576 @SYMTestActions Draw windows and dialogs in a tiled format
2578 @SYMTestExpectedResults The windows and dialogs are drawn correctly
2581 ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0037"));
2582 iTest->LogSubTest(KTest9);
2583 TiledWindowTest2L();
2586 @SYMTestCaseID GRAPHICS-WSERV-0038
2590 @SYMTestCaseDesc Check drawing into a window with different
2593 @SYMTestPriority High
2595 @SYMTestStatus Implemented
2597 @SYMTestActions Draw in a window using different colour
2600 @SYMTestExpectedResults The different colours are drawn correctly
2603 ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0038"));
2604 iTest->LogSubTest(KTest10);
2608 @SYMTestCaseID GRAPHICS-WSERV-0039
2612 @SYMTestCaseDesc Test for panics when window is sent wrong requests
2614 @SYMTestPriority High
2616 @SYMTestStatus Implemented
2618 @SYMTestActions Send wrong requests to windows and deal with panic
2620 @SYMTestExpectedResults The windows panic as expected
2623 ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0039"));
2624 iTest->LogSubTest(KTest11);
2625 TestInvalidFunctions2L();
2628 @SYMTestCaseID GRAPHICS-WSERV-0040
2632 @SYMTestCaseDesc Test for a defect that causes ROM to crash
2634 @SYMTestPriority High
2636 @SYMTestStatus Implemented
2638 @SYMTestActions Test a defect is not present which causes the ROM
2641 @SYMTestExpectedResults The defect is not present
2644 ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0040"));
2645 iTest->LogSubTest(KTest12);
2649 @SYMTestCaseID GRAPHICS-WSERV-0041
2653 @SYMTestCaseDesc Test a previous defect has not returned
2655 @SYMTestPriority High
2657 @SYMTestStatus Implemented
2659 @SYMTestActions Exercise the code the defect was discovered in
2661 @SYMTestExpectedResults The defect is not present
2664 ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0041"));
2665 iTest->LogSubTest(KTest13);
2669 @SYMTestCaseID GRAPHICS-WSERV-0042
2674 @SYMTestCaseDesc Test that when a parent window is deleted a panic
2677 @SYMTestPriority High
2679 @SYMTestStatus Implemented
2681 @SYMTestActions Delete a parent window and check for a panic
2682 NOTE: DEF115543 has corrected GRAPHICS-WSERV-0042, and added a lot
2683 more window functions.
2685 @SYMTestExpectedResults All functions either:
2686 Panic the owner thread with EWservPanicParentDeleted or
2687 Get performed without accessing any NULL iParent pointers in the WSERV thread
2690 ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0042"));
2691 iTest->LogSubTest(KTest14);
2692 TestDeletedParentPanics1L();
2695 @SYMTestCaseID GRAPHICS-WSERV-0043
2699 @SYMTestCaseDesc Test that when a parent window is deleted a panic
2702 @SYMTestPriority High
2704 @SYMTestStatus Implemented
2706 @SYMTestActions Delete a parent window and check for a panic
2708 @SYMTestExpectedResults The panic occurs as expected
2711 ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0043"));
2712 iTest->LogSubTest(KTest15);
2713 TestDeletedParentPanics2L();
2716 @SYMTestCaseID GRAPHICS-WSERV-0044
2720 @SYMTestCaseDesc Check that activate then make visible and backup
2721 behind a window does not panic.
2723 @SYMTestPriority High
2725 @SYMTestStatus Implemented
2727 @SYMTestActions Activate then make visible and backup
2730 @SYMTestExpectedResults No panic occurs
2733 ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0044"));
2734 iTest->LogSubTest(KTest16);
2738 @SYMTestCaseID GRAPHICS-WSERV-0045
2742 @SYMTestCaseDesc Test window being drawn with the correct background
2743 color when they are moved on the screen
2745 @SYMTestPriority High
2747 @SYMTestStatus Implemented
2749 @SYMTestActions Move window on the screen and check it is drawn with
2750 the correct background colour
2752 @SYMTestExpectedResults The background coloour is correct
2755 ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0045"));
2756 iTest->LogSubTest(KTest17);
2760 @SYMTestCaseID GRAPHICS-WSERV-0046
2764 @SYMTestCaseDesc Test that the focus change is available after redraw
2766 @SYMTestPriority High
2768 @SYMTestStatus Implemented
2770 @SYMTestActions Redraw and check the focus change is available
2772 @SYMTestExpectedResults The focus change is available
2775 ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0046"));
2776 iTest->LogSubTest(KTest18);
2780 @SYMTestCaseID GRAPHICS-WSERV-0048
2784 @SYMTestCaseDesc Test that events can be sent to a number of window
2785 groups simultaneously
2787 @SYMTestPriority High
2789 @SYMTestStatus Implemented
2791 @SYMTestActions Send events to a number of window groups and check
2792 that they all receive them
2794 @SYMTestExpectedResults The events and sent to the window groups correctly
2797 ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0048"));
2798 iTest->LogSubTest(KTest21);
2802 @SYMTestCaseID GRAPHICS-WSERV-0049
2806 @SYMTestCaseDesc Test error code when incorrectly moving a window to
2809 @SYMTestPriority High
2811 @SYMTestStatus Implemented
2813 @SYMTestActions Try to move a window to a group and check the error
2816 @SYMTestExpectedResults The correct error codes are returned
2819 ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0049"));
2820 iTest->LogSubTest(KTest22);
2823 @SYMTestCaseID GRAPHICS-WSERV-0050
2827 @SYMTestCaseDesc Check that the correct group id is assigned to a
2830 @SYMTestPriority High
2832 @SYMTestStatus Implemented
2834 @SYMTestActions Create a chain of windows in the same group and check
2835 the all have the same group id
2837 @SYMTestExpectedResults The windows all have the same group id
2840 ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0050"));
2841 iTest->LogSubTest(KTest23);
2846 @SYMTestCaseID GRAPHICS-WSERV-0461
2850 @SYMTestCaseDesc Test window redraw queue cleanup when window is deleted in low memory conditions
2852 @SYMTestPriority High
2854 @SYMTestStatus Implemented
2856 @SYMTestActions Have a loop which increases the number of allocations in the server thread before failure;
2858 1) Create a parent window and a child window of the parent;
2859 2) Delete the parent window only, but not the child window;
2860 3) Create a testWindow. This new window gets added to the redraw queue which will force it
2861 reordering. This would crash WSERV due to this defect because the orphaned window (which is
2862 the previous child window) is still in the redraw queue
2863 4) Delete all the windows involved;
2865 @SYMTestExpectedResults The window redraw queue should be cleaned up when the first window is deleted;
2866 WSERV should not crash. The test should pass.
2869 ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0461"));
2870 iTest->LogSubTest(KTest24);
2875 @SYMTestCaseID GRAPHICS-WSERV-0463
2879 @SYMTestCaseDesc Two RWindowGroup objects using same window client handle cause Emulator crash
2881 @SYMTestPriority Medium
2883 @SYMTestStatus Implemented
2885 @SYMTestActions Create two window groups with the same handle.
2887 @SYMTestExpectedResults WSERV should panic the client thread with the code EWservPanicDuplicateHandle
2888 and then destroy the window groups without crashing WSERV
2892 ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0463"));
2893 iTest->LogSubTest(KTest25);
2894 TEST(iTest->TestWsPanicL(DoPanicTest6,EWservPanicDuplicateHandle,0,(TAny*)iTest->iScreenNumber,NULL));
2895 iTest->CloseAllPanicWindows();
2897 iTest->LogSubTest(KTest25skipped); //Client side panic will only occur in debug builds of WServ
2901 ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0495"));
2902 iTest->LogSubTest(KTest26);
2903 SaturateSendEvent();
2906 @SYMTestCaseID GRAPHICS-WSERV-0655
2908 @SYMDEF ou1cimx1#329309
2910 @SYMTestCaseDesc Fix native orientation functionality not supported
2912 @SYMTestPriority Medium
2914 @SYMTestStatus Implemented
2916 @SYMTestActions Call fucntions related to fix native orientation on a window
2918 @SYMTestExpectedResults Fix native orientation functionality not supported
2921 ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0655"));
2922 iTest->LogSubTest(KTest27);
2923 TestNotSupportedFunctionality();
2926 ((CTWindowTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
2927 ((CTWindowTestStep*)iStep)->CloseTMSGraphicsStep();
2931 ((CTWindowTestStep*)iStep)->RecordTestResultL();
2934 __WS_CONSTRUCT_STEP__(WindowTest)