First public contribution.
1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Test classes derived from Wserv client side classes
21 @internalComponent - Internal Symbian test code
26 CTDerived::CTDerived(CTestStep* aStep) : CTWsGraphicsBase(aStep)
30 CTDerived::~CTDerived()
35 // CDerivedWindowGc //
38 CDerivedWindowGc::CDerivedWindowGc(CWsScreenDevice *aDevice) : CWindowGc(aDevice)
42 CDerivedWindowGc::~CDerivedWindowGc()
46 void CDerivedWindowGc::DrawLine(const TPoint &aPoint1,const TPoint &aPoint2)
48 CWindowGc::DrawLine(aPoint1+TPoint(10,10), aPoint2-TPoint(10,10));
55 TInt RDerivedSession::ResourceCount()
57 return(RWsSession::ResourceCount()+1);
60 void RDerivedSession::EnableAutoFlush()
69 RDerivedBlankWindow::RDerivedBlankWindow()
71 RDerivedBlankWindow::RDerivedBlankWindow(RWsSession &aWs) : RBlankWindow(aWs)
75 void RDerivedBlankWindow::SetColor(TRgb aColor)
77 RBlankWindow::SetColor(~aColor);
80 void RDerivedBlankWindow::SetColorGray()
82 RBlankWindow::SetColor(TRgb::Gray16(8));
85 RDerivedWindow::RDerivedWindow()
87 RDerivedWindow::RDerivedWindow(RWsSession &aWs) : RWindow(aWs)
91 void RDerivedWindow::SetBackgroundColor(TRgb aColor)
93 RWindow::SetBackgroundColor(~aColor);
96 void RDerivedWindow::SetBackgroundColorGray()
98 RWindow::SetBackgroundColor(TRgb::Gray16(8));
101 RDerivedBackedUpWindow::RDerivedBackedUpWindow()
103 RDerivedBackedUpWindow::RDerivedBackedUpWindow(RWsSession &aWs) : RBackedUpWindow(aWs)
107 TInt RDerivedBackedUpWindow::BitmapHandle()
110 return(RBackedUpWindow::BitmapHandle()+1);
113 RDerivedWindowGroup::RDerivedWindowGroup()
116 RDerivedWindowGroup::RDerivedWindowGroup(RWsSession &aWs) : RWindowGroup(aWs)
120 TName RDerivedWindowGroup::Name() const
126 // CDerivedScreenDevice //
129 CDerivedScreenDevice::CDerivedScreenDevice()
132 CDerivedScreenDevice::CDerivedScreenDevice(RWsSession &aWs) : CWsScreenDevice(aWs)
135 TSize CDerivedScreenDevice::SizeInPixels() const
137 TSize size=CWsScreenDevice::SizeInPixels();
138 return(TSize(size.iWidth*2,size.iHeight*2));
142 // Derived Sprite/Pointer cursor //
145 RDerivedSprite::RDerivedSprite()
149 RDerivedSprite::RDerivedSprite(RWsSession &aWs) : RWsSprite(aWs)
153 RDerivedPointerCursor::RDerivedPointerCursor()
157 RDerivedPointerCursor::RDerivedPointerCursor(RWsSession &aWs) : RWsPointerCursor(aWs)
163 void CTDerived::ConstructL()
165 TheGc->Activate(*BaseWin->Win());
167 TheGc->SetBrushColor(TRgb::Gray16(12));
168 TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
169 TheGc->SetPenStyle(CGraphicsContext::ENullPen);
170 TheGc->DrawRect(TRect(BaseWin->Win()->Size()));
172 TheGc->Activate(*TestWin->Win());
174 TheGc->SetBrushColor(TRgb::Gray16(4));
175 TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
176 TheGc->SetPenStyle(CGraphicsContext::ENullPen);
177 TheGc->DrawRect(TRect(TestWin->Win()->Size()));
181 void CTDerived::DerivedWindowGcL()
183 CDerivedWindowGc *dgc=new(ELeave) CDerivedWindowGc(TheClient->iScreen);
185 dgc->Activate(*TestWin->Win());
186 dgc->SetBrushStyle(CGraphicsContext::ESolidBrush);
187 TestWin->Win()->BeginRedraw();
188 dgc->DrawRect(TRect(TestWin->Win()->Size()));
189 dgc->DrawLine(TPoint(0,0),TestWin->Win()->Size().AsPoint());
190 TestWin->Win()->EndRedraw();
194 CWindowGc *wgc=new(ELeave) CWindowGc(TheClient->iScreen);
196 wgc->Activate(*BaseWin->Win());
197 wgc->SetBrushStyle(CGraphicsContext::ESolidBrush);
198 BaseWin->Win()->BeginRedraw();
199 wgc->DrawRect(TRect(TestWin->Win()->Size()));
200 wgc->DrawLine(TPoint(10,10),TestWin->Win()->Size().AsPoint()-TPoint(10,10));
201 BaseWin->Win()->EndRedraw();
205 CompareWindows(_L("CTDerived::DerivedWindowGcL()"));
208 void CTDerived::DerivedSession()
211 err = iDSession.Connect();
215 // use the correct screen
216 CWsScreenDevice* screen = NULL;
217 TRAP(err, screen = new (ELeave) CWsScreenDevice(iDSession));
224 if ((err=screen->Construct(iTest->iScreenNumber))!=KErrNone)
233 TInt retVal = iDSession.ResourceCount();
236 INFO_PRINTF3(_L("iDSession.ResourceCount() return value - Expected: %d, Actual: %d"), 1, retVal);
238 iDSession.SetAutoFlush(EFalse);
239 iDSession.EnableAutoFlush();
241 TBool retBool = iDSession.SetAutoFlush(EFalse);
244 INFO_PRINTF3(_L("iDSession.SetAutoFlush(EFalse) return value - Expected: %d, Actual: %d"), ETrue, retBool);
249 void CTDerived::DerivedWindows()
254 iDGroup=RDerivedWindowGroup(TheClient->iWs);
255 iDGroup.Construct(222);
260 iDRedraw=RDerivedWindow(TheClient->iWs);
261 iDRedraw.Construct(iDGroup,12);
262 iDRedraw.SetBackgroundColor(TRgb(1,2,3));
263 iDRedraw.SetBackgroundColorGray();
268 iDBlank=RDerivedBlankWindow(TheClient->iWs);
269 iDBlank.Construct(iDGroup,123);
270 iDBlank.SetColor(TRgb(1,20,50));
271 iDBlank.SetColorGray();
276 iDBackedUp=RDerivedBackedUpWindow(TheClient->iWs);
277 iDBackedUp.Construct(iDGroup,EGray4,1234);
278 iDBackedUp.BitmapHandle();
284 void CTDerived::DerivedScreenDeviceL()
286 CWsScreenDevice *wsd=new(ELeave) CWsScreenDevice(TheClient->iWs);
287 User::LeaveIfError(wsd->Construct(iTest->iScreenNumber));
288 TSize size1(wsd->SizeInPixels());
290 CDerivedScreenDevice *dsd=new(ELeave) CDerivedScreenDevice(TheClient->iWs);
291 User::LeaveIfError(dsd->Construct(iTest->iScreenNumber));
292 TSize size2(dsd->SizeInPixels());
294 TEST(size2.iWidth==size1.iWidth*2 && size2.iHeight==size1.iHeight*2);
297 void CTDerived::DerivedSprite()
299 iDSprite=RDerivedSprite(TheClient->iWs);
302 spm.iMaskBitmap=NULL;
303 spm.iInvertMask=EFalse;
304 spm.iOffset=TPoint(0,0); // Offset from sprites central position
305 spm.iInterval=TTimeIntervalMicroSeconds32(1000000);
306 iDSprite.Construct(*TestWin->Win(), TPoint(10,10), 0);
309 iDPCursor=RDerivedPointerCursor(TheClient->iWs);
310 iDPCursor.Construct(0);
314 void CTDerived::RunTestCaseL(TInt /*aCurTestCase*/)
316 ((CTDerivedStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
317 switch(++iTest->iState)
320 @SYMTestCaseID GRAPHICS-WSERV-0075
324 @SYMTestCaseDesc Test derived window graphics context
326 @SYMTestPriority High
328 @SYMTestStatus Implemented
330 @SYMTestActions Draw using a derived window gc and a normal
331 window gc and check the dawing is the same
333 @SYMTestExpectedResults Drawing is the same with a derived window gc
336 ((CTDerivedStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0075"));
337 iTest->LogSubTest(_L("Derived Gc"));
341 @SYMTestCaseID GRAPHICS-WSERV-0076
345 @SYMTestCaseDesc Test derived window server session
347 @SYMTestPriority High
349 @SYMTestStatus Implemented
351 @SYMTestActions Test that a derived window server session functions
352 the same as a normal window server session
354 @SYMTestExpectedResults The derived window server session functions correctly
357 ((CTDerivedStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0076"));
358 iTest->LogSubTest(_L("Derived Session"));
362 @SYMTestCaseID GRAPHICS-WSERV-0077
366 @SYMTestCaseDesc Test derived windows and window groups function correctly
368 @SYMTestPriority High
370 @SYMTestStatus Implemented
372 @SYMTestActions Test that a derived windows and window groups function
373 the same as the classes they are derived from
375 @SYMTestExpectedResults The derived windows and window group functions correctly
378 ((CTDerivedStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0077"));
379 iTest->LogSubTest(_L("Derived Blank Window"));
383 @SYMTestCaseID GRAPHICS-WSERV-0078
387 @SYMTestCaseDesc Test derived screen devices function correctly
389 @SYMTestPriority High
391 @SYMTestStatus Implemented
393 @SYMTestActions Test that a derived screen device function
394 the same as the class it is derived from
396 @SYMTestExpectedResults The derived screen device functions correctly
399 ((CTDerivedStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0078"));
400 iTest->LogSubTest(_L("Derived Screed Device"));
401 DerivedScreenDeviceL();
404 @SYMTestCaseID GRAPHICS-WSERV-0079
408 @SYMTestCaseDesc Test derived sprites and pointer cursors function
411 @SYMTestPriority High
413 @SYMTestStatus Implemented
415 @SYMTestActions Test that a derived sprite and pointer cursor
418 @SYMTestExpectedResults The derived sprite and pointer cursor function
422 ((CTDerivedStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0079"));
423 iTest->LogSubTest(_L("Derived Sprites"));
427 ((CTDerivedStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
428 ((CTDerivedStep*)iStep)->CloseTMSGraphicsStep();
432 ((CTDerivedStep*)iStep)->RecordTestResultL();
435 __WS_CONSTRUCT_STEP__(Derived)