1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/windowing/windowserver/test/tauto/TDERIVED.CPP Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,435 @@
1.4 +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Test classes derived from Wserv client side classes
1.18 +//
1.19 +//
1.20 +
1.21 +/**
1.22 + @file
1.23 + @test
1.24 + @internalComponent - Internal Symbian test code
1.25 +*/
1.26 +
1.27 +#include "TDERIVED.H"
1.28 +
1.29 +CTDerived::CTDerived(CTestStep* aStep) : CTWsGraphicsBase(aStep)
1.30 + {
1.31 + }
1.32 +
1.33 +CTDerived::~CTDerived()
1.34 + {
1.35 + }
1.36 +
1.37 +//
1.38 +// CDerivedWindowGc //
1.39 +//
1.40 +
1.41 +CDerivedWindowGc::CDerivedWindowGc(CWsScreenDevice *aDevice) : CWindowGc(aDevice)
1.42 + {
1.43 + }
1.44 +
1.45 +CDerivedWindowGc::~CDerivedWindowGc()
1.46 + {
1.47 + }
1.48 +
1.49 +void CDerivedWindowGc::DrawLine(const TPoint &aPoint1,const TPoint &aPoint2)
1.50 + {
1.51 + CWindowGc::DrawLine(aPoint1+TPoint(10,10), aPoint2-TPoint(10,10));
1.52 + }
1.53 +
1.54 +//
1.55 +// RDerivedSession //
1.56 +//
1.57 +
1.58 +TInt RDerivedSession::ResourceCount()
1.59 + {
1.60 + return(RWsSession::ResourceCount()+1);
1.61 + }
1.62 +
1.63 +void RDerivedSession::EnableAutoFlush()
1.64 + {
1.65 + SetAutoFlush(ETrue);
1.66 + }
1.67 +
1.68 +//
1.69 +// Derived windows //
1.70 +//
1.71 +
1.72 +RDerivedBlankWindow::RDerivedBlankWindow()
1.73 + {}
1.74 +RDerivedBlankWindow::RDerivedBlankWindow(RWsSession &aWs) : RBlankWindow(aWs)
1.75 + {
1.76 + }
1.77 +
1.78 +void RDerivedBlankWindow::SetColor(TRgb aColor)
1.79 + {
1.80 + RBlankWindow::SetColor(~aColor);
1.81 + }
1.82 +
1.83 +void RDerivedBlankWindow::SetColorGray()
1.84 + {
1.85 + RBlankWindow::SetColor(TRgb::Gray16(8));
1.86 + }
1.87 +
1.88 +RDerivedWindow::RDerivedWindow()
1.89 + {}
1.90 +RDerivedWindow::RDerivedWindow(RWsSession &aWs) : RWindow(aWs)
1.91 + {
1.92 + }
1.93 +
1.94 +void RDerivedWindow::SetBackgroundColor(TRgb aColor)
1.95 + {
1.96 + RWindow::SetBackgroundColor(~aColor);
1.97 + }
1.98 +
1.99 +void RDerivedWindow::SetBackgroundColorGray()
1.100 + {
1.101 + RWindow::SetBackgroundColor(TRgb::Gray16(8));
1.102 + }
1.103 +
1.104 +RDerivedBackedUpWindow::RDerivedBackedUpWindow()
1.105 + {}
1.106 +RDerivedBackedUpWindow::RDerivedBackedUpWindow(RWsSession &aWs) : RBackedUpWindow(aWs)
1.107 + {
1.108 + }
1.109 +
1.110 +TInt RDerivedBackedUpWindow::BitmapHandle()
1.111 + {
1.112 + MaintainBackup();
1.113 + return(RBackedUpWindow::BitmapHandle()+1);
1.114 + };
1.115 +
1.116 +RDerivedWindowGroup::RDerivedWindowGroup()
1.117 + {}
1.118 +
1.119 +RDerivedWindowGroup::RDerivedWindowGroup(RWsSession &aWs) : RWindowGroup(aWs)
1.120 + {
1.121 + }
1.122 +
1.123 +TName RDerivedWindowGroup::Name() const
1.124 + {
1.125 + return(_L("Fred"));
1.126 + }
1.127 +
1.128 +//
1.129 +// CDerivedScreenDevice //
1.130 +//
1.131 +
1.132 +CDerivedScreenDevice::CDerivedScreenDevice()
1.133 + {}
1.134 +
1.135 +CDerivedScreenDevice::CDerivedScreenDevice(RWsSession &aWs) : CWsScreenDevice(aWs)
1.136 + {}
1.137 +
1.138 +TSize CDerivedScreenDevice::SizeInPixels() const
1.139 + {
1.140 + TSize size=CWsScreenDevice::SizeInPixels();
1.141 + return(TSize(size.iWidth*2,size.iHeight*2));
1.142 + }
1.143 +
1.144 +//
1.145 +// Derived Sprite/Pointer cursor //
1.146 +//
1.147 +
1.148 +RDerivedSprite::RDerivedSprite()
1.149 + {
1.150 + }
1.151 +
1.152 +RDerivedSprite::RDerivedSprite(RWsSession &aWs) : RWsSprite(aWs)
1.153 + {
1.154 + }
1.155 +
1.156 +RDerivedPointerCursor::RDerivedPointerCursor()
1.157 + {
1.158 + }
1.159 +
1.160 +RDerivedPointerCursor::RDerivedPointerCursor(RWsSession &aWs) : RWsPointerCursor(aWs)
1.161 + {
1.162 + }
1.163 +
1.164 +//
1.165 +
1.166 +void CTDerived::ConstructL()
1.167 + {
1.168 + TheGc->Activate(*BaseWin->Win());
1.169 + TheGc->Clear();
1.170 + TheGc->SetBrushColor(TRgb::Gray16(12));
1.171 + TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1.172 + TheGc->SetPenStyle(CGraphicsContext::ENullPen);
1.173 + TheGc->DrawRect(TRect(BaseWin->Win()->Size()));
1.174 + TheGc->Deactivate();
1.175 + TheGc->Activate(*TestWin->Win());
1.176 + TheGc->Clear();
1.177 + TheGc->SetBrushColor(TRgb::Gray16(4));
1.178 + TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1.179 + TheGc->SetPenStyle(CGraphicsContext::ENullPen);
1.180 + TheGc->DrawRect(TRect(TestWin->Win()->Size()));
1.181 + TheGc->Deactivate();
1.182 + }
1.183 +
1.184 +void CTDerived::DerivedWindowGcL()
1.185 + {
1.186 + CDerivedWindowGc *dgc=new(ELeave) CDerivedWindowGc(TheClient->iScreen);
1.187 + dgc->Construct();
1.188 + dgc->Activate(*TestWin->Win());
1.189 + dgc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1.190 + TestWin->Win()->BeginRedraw();
1.191 + dgc->DrawRect(TRect(TestWin->Win()->Size()));
1.192 + dgc->DrawLine(TPoint(0,0),TestWin->Win()->Size().AsPoint());
1.193 + TestWin->Win()->EndRedraw();
1.194 + dgc->Deactivate();
1.195 + delete dgc;
1.196 + dgc = NULL;
1.197 + CWindowGc *wgc=new(ELeave) CWindowGc(TheClient->iScreen);
1.198 + wgc->Construct();
1.199 + wgc->Activate(*BaseWin->Win());
1.200 + wgc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1.201 + BaseWin->Win()->BeginRedraw();
1.202 + wgc->DrawRect(TRect(TestWin->Win()->Size()));
1.203 + wgc->DrawLine(TPoint(10,10),TestWin->Win()->Size().AsPoint()-TPoint(10,10));
1.204 + BaseWin->Win()->EndRedraw();
1.205 + wgc->Deactivate();
1.206 + delete wgc;
1.207 + wgc = NULL;
1.208 + CompareWindows(_L("CTDerived::DerivedWindowGcL()"));
1.209 + }
1.210 +
1.211 +void CTDerived::DerivedSession()
1.212 + {
1.213 + TInt err;
1.214 + err = iDSession.Connect();
1.215 + if (err!=KErrNone)
1.216 + return;
1.217 +
1.218 + // use the correct screen
1.219 + CWsScreenDevice* screen = NULL;
1.220 + TRAP(err, screen = new (ELeave) CWsScreenDevice(iDSession));
1.221 + if (err!=KErrNone)
1.222 + {
1.223 + iDSession.Close();
1.224 + return;
1.225 + }
1.226 +
1.227 + if ((err=screen->Construct(iTest->iScreenNumber))!=KErrNone)
1.228 + {
1.229 + delete screen;
1.230 + iDSession.Close();
1.231 + return;
1.232 + }
1.233 +
1.234 + delete screen;
1.235 +
1.236 + TInt retVal = iDSession.ResourceCount();
1.237 + TEST(retVal==1);
1.238 + if (retVal!=1)
1.239 + INFO_PRINTF3(_L("iDSession.ResourceCount() return value - Expected: %d, Actual: %d"), 1, retVal);
1.240 +
1.241 + iDSession.SetAutoFlush(EFalse);
1.242 + iDSession.EnableAutoFlush();
1.243 +
1.244 + TBool retBool = iDSession.SetAutoFlush(EFalse);
1.245 + TEST(retBool);
1.246 + if (!retBool)
1.247 + INFO_PRINTF3(_L("iDSession.SetAutoFlush(EFalse) return value - Expected: %d, Actual: %d"), ETrue, retBool);
1.248 +
1.249 + iDSession.Close();
1.250 + }
1.251 +
1.252 +void CTDerived::DerivedWindows()
1.253 + {
1.254 +//
1.255 +// Window group
1.256 +//
1.257 + iDGroup=RDerivedWindowGroup(TheClient->iWs);
1.258 + iDGroup.Construct(222);
1.259 + iDGroup.Name();
1.260 +//
1.261 +// Redraw up window
1.262 +//
1.263 + iDRedraw=RDerivedWindow(TheClient->iWs);
1.264 + iDRedraw.Construct(iDGroup,12);
1.265 + iDRedraw.SetBackgroundColor(TRgb(1,2,3));
1.266 + iDRedraw.SetBackgroundColorGray();
1.267 + iDRedraw.Close();
1.268 +//
1.269 +// Blank up window
1.270 +//
1.271 + iDBlank=RDerivedBlankWindow(TheClient->iWs);
1.272 + iDBlank.Construct(iDGroup,123);
1.273 + iDBlank.SetColor(TRgb(1,20,50));
1.274 + iDBlank.SetColorGray();
1.275 + iDBlank.Close();
1.276 +//
1.277 +// Backed up window
1.278 +//
1.279 + iDBackedUp=RDerivedBackedUpWindow(TheClient->iWs);
1.280 + iDBackedUp.Construct(iDGroup,EGray4,1234);
1.281 + iDBackedUp.BitmapHandle();
1.282 + iDBackedUp.Close();
1.283 +//
1.284 + iDGroup.Close();
1.285 + }
1.286 +
1.287 +void CTDerived::DerivedScreenDeviceL()
1.288 + {
1.289 + CWsScreenDevice *wsd=new(ELeave) CWsScreenDevice(TheClient->iWs);
1.290 + User::LeaveIfError(wsd->Construct(iTest->iScreenNumber));
1.291 + TSize size1(wsd->SizeInPixels());
1.292 + delete wsd;
1.293 + CDerivedScreenDevice *dsd=new(ELeave) CDerivedScreenDevice(TheClient->iWs);
1.294 + User::LeaveIfError(dsd->Construct(iTest->iScreenNumber));
1.295 + TSize size2(dsd->SizeInPixels());
1.296 + delete dsd;
1.297 + TEST(size2.iWidth==size1.iWidth*2 && size2.iHeight==size1.iHeight*2);
1.298 + }
1.299 +
1.300 +void CTDerived::DerivedSprite()
1.301 + {
1.302 + iDSprite=RDerivedSprite(TheClient->iWs);
1.303 + TSpriteMember spm;
1.304 + spm.iBitmap=NULL;
1.305 + spm.iMaskBitmap=NULL;
1.306 + spm.iInvertMask=EFalse;
1.307 + spm.iOffset=TPoint(0,0); // Offset from sprites central position
1.308 + spm.iInterval=TTimeIntervalMicroSeconds32(1000000);
1.309 + iDSprite.Construct(*TestWin->Win(), TPoint(10,10), 0);
1.310 + iDSprite.Close();
1.311 +//
1.312 + iDPCursor=RDerivedPointerCursor(TheClient->iWs);
1.313 + iDPCursor.Construct(0);
1.314 + iDPCursor.Close();
1.315 + };
1.316 +
1.317 +void CTDerived::RunTestCaseL(TInt /*aCurTestCase*/)
1.318 + {
1.319 + ((CTDerivedStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
1.320 + switch(++iTest->iState)
1.321 + {
1.322 +/**
1.323 +@SYMTestCaseID GRAPHICS-WSERV-0075
1.324 +
1.325 +@SYMDEF DEF081259
1.326 +
1.327 +@SYMTestCaseDesc Test derived window graphics context
1.328 +
1.329 +@SYMTestPriority High
1.330 +
1.331 +@SYMTestStatus Implemented
1.332 +
1.333 +@SYMTestActions Draw using a derived window gc and a normal
1.334 + window gc and check the dawing is the same
1.335 +
1.336 +@SYMTestExpectedResults Drawing is the same with a derived window gc
1.337 +*/
1.338 + case 1:
1.339 + ((CTDerivedStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0075"));
1.340 + iTest->LogSubTest(_L("Derived Gc"));
1.341 + DerivedWindowGcL();
1.342 + break;
1.343 +/**
1.344 +@SYMTestCaseID GRAPHICS-WSERV-0076
1.345 +
1.346 +@SYMDEF DEF081259
1.347 +
1.348 +@SYMTestCaseDesc Test derived window server session
1.349 +
1.350 +@SYMTestPriority High
1.351 +
1.352 +@SYMTestStatus Implemented
1.353 +
1.354 +@SYMTestActions Test that a derived window server session functions
1.355 + the same as a normal window server session
1.356 +
1.357 +@SYMTestExpectedResults The derived window server session functions correctly
1.358 +*/
1.359 + case 2:
1.360 + ((CTDerivedStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0076"));
1.361 + iTest->LogSubTest(_L("Derived Session"));
1.362 + DerivedSession();
1.363 + break;
1.364 +/**
1.365 +@SYMTestCaseID GRAPHICS-WSERV-0077
1.366 +
1.367 +@SYMDEF DEF081259
1.368 +
1.369 +@SYMTestCaseDesc Test derived windows and window groups function correctly
1.370 +
1.371 +@SYMTestPriority High
1.372 +
1.373 +@SYMTestStatus Implemented
1.374 +
1.375 +@SYMTestActions Test that a derived windows and window groups function
1.376 + the same as the classes they are derived from
1.377 +
1.378 +@SYMTestExpectedResults The derived windows and window group functions correctly
1.379 +*/
1.380 + case 3:
1.381 + ((CTDerivedStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0077"));
1.382 + iTest->LogSubTest(_L("Derived Blank Window"));
1.383 + DerivedWindows();
1.384 + break;
1.385 +/**
1.386 +@SYMTestCaseID GRAPHICS-WSERV-0078
1.387 +
1.388 +@SYMDEF DEF081259
1.389 +
1.390 +@SYMTestCaseDesc Test derived screen devices function correctly
1.391 +
1.392 +@SYMTestPriority High
1.393 +
1.394 +@SYMTestStatus Implemented
1.395 +
1.396 +@SYMTestActions Test that a derived screen device function
1.397 + the same as the class it is derived from
1.398 +
1.399 +@SYMTestExpectedResults The derived screen device functions correctly
1.400 +*/
1.401 + case 4:
1.402 + ((CTDerivedStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0078"));
1.403 + iTest->LogSubTest(_L("Derived Screed Device"));
1.404 + DerivedScreenDeviceL();
1.405 + break;
1.406 +/**
1.407 +@SYMTestCaseID GRAPHICS-WSERV-0079
1.408 +
1.409 +@SYMDEF DEF081259
1.410 +
1.411 +@SYMTestCaseDesc Test derived sprites and pointer cursors function
1.412 + correctly
1.413 +
1.414 +@SYMTestPriority High
1.415 +
1.416 +@SYMTestStatus Implemented
1.417 +
1.418 +@SYMTestActions Test that a derived sprite and pointer cursor
1.419 + function correctly
1.420 +
1.421 +@SYMTestExpectedResults The derived sprite and pointer cursor function
1.422 + correctly
1.423 +*/
1.424 + case 5:
1.425 + ((CTDerivedStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0079"));
1.426 + iTest->LogSubTest(_L("Derived Sprites"));
1.427 + DerivedSprite();
1.428 + break;
1.429 + case 6:
1.430 + ((CTDerivedStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
1.431 + ((CTDerivedStep*)iStep)->CloseTMSGraphicsStep();
1.432 + TestComplete();
1.433 + break;
1.434 + }
1.435 + ((CTDerivedStep*)iStep)->RecordTestResultL();
1.436 + }
1.437 +
1.438 +__WS_CONSTRUCT_STEP__(Derived)