sl@0: // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Test classes derived from Wserv client side classes sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @test sl@0: @internalComponent - Internal Symbian test code sl@0: */ sl@0: sl@0: #include "TDERIVED.H" sl@0: sl@0: CTDerived::CTDerived(CTestStep* aStep) : CTWsGraphicsBase(aStep) sl@0: { sl@0: } sl@0: sl@0: CTDerived::~CTDerived() sl@0: { sl@0: } sl@0: sl@0: // sl@0: // CDerivedWindowGc // sl@0: // sl@0: sl@0: CDerivedWindowGc::CDerivedWindowGc(CWsScreenDevice *aDevice) : CWindowGc(aDevice) sl@0: { sl@0: } sl@0: sl@0: CDerivedWindowGc::~CDerivedWindowGc() sl@0: { sl@0: } sl@0: sl@0: void CDerivedWindowGc::DrawLine(const TPoint &aPoint1,const TPoint &aPoint2) sl@0: { sl@0: CWindowGc::DrawLine(aPoint1+TPoint(10,10), aPoint2-TPoint(10,10)); sl@0: } sl@0: sl@0: // sl@0: // RDerivedSession // sl@0: // sl@0: sl@0: TInt RDerivedSession::ResourceCount() sl@0: { sl@0: return(RWsSession::ResourceCount()+1); sl@0: } sl@0: sl@0: void RDerivedSession::EnableAutoFlush() sl@0: { sl@0: SetAutoFlush(ETrue); sl@0: } sl@0: sl@0: // sl@0: // Derived windows // sl@0: // sl@0: sl@0: RDerivedBlankWindow::RDerivedBlankWindow() sl@0: {} sl@0: RDerivedBlankWindow::RDerivedBlankWindow(RWsSession &aWs) : RBlankWindow(aWs) sl@0: { sl@0: } sl@0: sl@0: void RDerivedBlankWindow::SetColor(TRgb aColor) sl@0: { sl@0: RBlankWindow::SetColor(~aColor); sl@0: } sl@0: sl@0: void RDerivedBlankWindow::SetColorGray() sl@0: { sl@0: RBlankWindow::SetColor(TRgb::Gray16(8)); sl@0: } sl@0: sl@0: RDerivedWindow::RDerivedWindow() sl@0: {} sl@0: RDerivedWindow::RDerivedWindow(RWsSession &aWs) : RWindow(aWs) sl@0: { sl@0: } sl@0: sl@0: void RDerivedWindow::SetBackgroundColor(TRgb aColor) sl@0: { sl@0: RWindow::SetBackgroundColor(~aColor); sl@0: } sl@0: sl@0: void RDerivedWindow::SetBackgroundColorGray() sl@0: { sl@0: RWindow::SetBackgroundColor(TRgb::Gray16(8)); sl@0: } sl@0: sl@0: RDerivedBackedUpWindow::RDerivedBackedUpWindow() sl@0: {} sl@0: RDerivedBackedUpWindow::RDerivedBackedUpWindow(RWsSession &aWs) : RBackedUpWindow(aWs) sl@0: { sl@0: } sl@0: sl@0: TInt RDerivedBackedUpWindow::BitmapHandle() sl@0: { sl@0: MaintainBackup(); sl@0: return(RBackedUpWindow::BitmapHandle()+1); sl@0: }; sl@0: sl@0: RDerivedWindowGroup::RDerivedWindowGroup() sl@0: {} sl@0: sl@0: RDerivedWindowGroup::RDerivedWindowGroup(RWsSession &aWs) : RWindowGroup(aWs) sl@0: { sl@0: } sl@0: sl@0: TName RDerivedWindowGroup::Name() const sl@0: { sl@0: return(_L("Fred")); sl@0: } sl@0: sl@0: // sl@0: // CDerivedScreenDevice // sl@0: // sl@0: sl@0: CDerivedScreenDevice::CDerivedScreenDevice() sl@0: {} sl@0: sl@0: CDerivedScreenDevice::CDerivedScreenDevice(RWsSession &aWs) : CWsScreenDevice(aWs) sl@0: {} sl@0: sl@0: TSize CDerivedScreenDevice::SizeInPixels() const sl@0: { sl@0: TSize size=CWsScreenDevice::SizeInPixels(); sl@0: return(TSize(size.iWidth*2,size.iHeight*2)); sl@0: } sl@0: sl@0: // sl@0: // Derived Sprite/Pointer cursor // sl@0: // sl@0: sl@0: RDerivedSprite::RDerivedSprite() sl@0: { sl@0: } sl@0: sl@0: RDerivedSprite::RDerivedSprite(RWsSession &aWs) : RWsSprite(aWs) sl@0: { sl@0: } sl@0: sl@0: RDerivedPointerCursor::RDerivedPointerCursor() sl@0: { sl@0: } sl@0: sl@0: RDerivedPointerCursor::RDerivedPointerCursor(RWsSession &aWs) : RWsPointerCursor(aWs) sl@0: { sl@0: } sl@0: sl@0: // sl@0: sl@0: void CTDerived::ConstructL() sl@0: { sl@0: TheGc->Activate(*BaseWin->Win()); sl@0: TheGc->Clear(); sl@0: TheGc->SetBrushColor(TRgb::Gray16(12)); sl@0: TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: TheGc->SetPenStyle(CGraphicsContext::ENullPen); sl@0: TheGc->DrawRect(TRect(BaseWin->Win()->Size())); sl@0: TheGc->Deactivate(); sl@0: TheGc->Activate(*TestWin->Win()); sl@0: TheGc->Clear(); sl@0: TheGc->SetBrushColor(TRgb::Gray16(4)); sl@0: TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: TheGc->SetPenStyle(CGraphicsContext::ENullPen); sl@0: TheGc->DrawRect(TRect(TestWin->Win()->Size())); sl@0: TheGc->Deactivate(); sl@0: } sl@0: sl@0: void CTDerived::DerivedWindowGcL() sl@0: { sl@0: CDerivedWindowGc *dgc=new(ELeave) CDerivedWindowGc(TheClient->iScreen); sl@0: dgc->Construct(); sl@0: dgc->Activate(*TestWin->Win()); sl@0: dgc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: TestWin->Win()->BeginRedraw(); sl@0: dgc->DrawRect(TRect(TestWin->Win()->Size())); sl@0: dgc->DrawLine(TPoint(0,0),TestWin->Win()->Size().AsPoint()); sl@0: TestWin->Win()->EndRedraw(); sl@0: dgc->Deactivate(); sl@0: delete dgc; sl@0: dgc = NULL; sl@0: CWindowGc *wgc=new(ELeave) CWindowGc(TheClient->iScreen); sl@0: wgc->Construct(); sl@0: wgc->Activate(*BaseWin->Win()); sl@0: wgc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: BaseWin->Win()->BeginRedraw(); sl@0: wgc->DrawRect(TRect(TestWin->Win()->Size())); sl@0: wgc->DrawLine(TPoint(10,10),TestWin->Win()->Size().AsPoint()-TPoint(10,10)); sl@0: BaseWin->Win()->EndRedraw(); sl@0: wgc->Deactivate(); sl@0: delete wgc; sl@0: wgc = NULL; sl@0: CompareWindows(_L("CTDerived::DerivedWindowGcL()")); sl@0: } sl@0: sl@0: void CTDerived::DerivedSession() sl@0: { sl@0: TInt err; sl@0: err = iDSession.Connect(); sl@0: if (err!=KErrNone) sl@0: return; sl@0: sl@0: // use the correct screen sl@0: CWsScreenDevice* screen = NULL; sl@0: TRAP(err, screen = new (ELeave) CWsScreenDevice(iDSession)); sl@0: if (err!=KErrNone) sl@0: { sl@0: iDSession.Close(); sl@0: return; sl@0: } sl@0: sl@0: if ((err=screen->Construct(iTest->iScreenNumber))!=KErrNone) sl@0: { sl@0: delete screen; sl@0: iDSession.Close(); sl@0: return; sl@0: } sl@0: sl@0: delete screen; sl@0: sl@0: TInt retVal = iDSession.ResourceCount(); sl@0: TEST(retVal==1); sl@0: if (retVal!=1) sl@0: INFO_PRINTF3(_L("iDSession.ResourceCount() return value - Expected: %d, Actual: %d"), 1, retVal); sl@0: sl@0: iDSession.SetAutoFlush(EFalse); sl@0: iDSession.EnableAutoFlush(); sl@0: sl@0: TBool retBool = iDSession.SetAutoFlush(EFalse); sl@0: TEST(retBool); sl@0: if (!retBool) sl@0: INFO_PRINTF3(_L("iDSession.SetAutoFlush(EFalse) return value - Expected: %d, Actual: %d"), ETrue, retBool); sl@0: sl@0: iDSession.Close(); sl@0: } sl@0: sl@0: void CTDerived::DerivedWindows() sl@0: { sl@0: // sl@0: // Window group sl@0: // sl@0: iDGroup=RDerivedWindowGroup(TheClient->iWs); sl@0: iDGroup.Construct(222); sl@0: iDGroup.Name(); sl@0: // sl@0: // Redraw up window sl@0: // sl@0: iDRedraw=RDerivedWindow(TheClient->iWs); sl@0: iDRedraw.Construct(iDGroup,12); sl@0: iDRedraw.SetBackgroundColor(TRgb(1,2,3)); sl@0: iDRedraw.SetBackgroundColorGray(); sl@0: iDRedraw.Close(); sl@0: // sl@0: // Blank up window sl@0: // sl@0: iDBlank=RDerivedBlankWindow(TheClient->iWs); sl@0: iDBlank.Construct(iDGroup,123); sl@0: iDBlank.SetColor(TRgb(1,20,50)); sl@0: iDBlank.SetColorGray(); sl@0: iDBlank.Close(); sl@0: // sl@0: // Backed up window sl@0: // sl@0: iDBackedUp=RDerivedBackedUpWindow(TheClient->iWs); sl@0: iDBackedUp.Construct(iDGroup,EGray4,1234); sl@0: iDBackedUp.BitmapHandle(); sl@0: iDBackedUp.Close(); sl@0: // sl@0: iDGroup.Close(); sl@0: } sl@0: sl@0: void CTDerived::DerivedScreenDeviceL() sl@0: { sl@0: CWsScreenDevice *wsd=new(ELeave) CWsScreenDevice(TheClient->iWs); sl@0: User::LeaveIfError(wsd->Construct(iTest->iScreenNumber)); sl@0: TSize size1(wsd->SizeInPixels()); sl@0: delete wsd; sl@0: CDerivedScreenDevice *dsd=new(ELeave) CDerivedScreenDevice(TheClient->iWs); sl@0: User::LeaveIfError(dsd->Construct(iTest->iScreenNumber)); sl@0: TSize size2(dsd->SizeInPixels()); sl@0: delete dsd; sl@0: TEST(size2.iWidth==size1.iWidth*2 && size2.iHeight==size1.iHeight*2); sl@0: } sl@0: sl@0: void CTDerived::DerivedSprite() sl@0: { sl@0: iDSprite=RDerivedSprite(TheClient->iWs); sl@0: TSpriteMember spm; sl@0: spm.iBitmap=NULL; sl@0: spm.iMaskBitmap=NULL; sl@0: spm.iInvertMask=EFalse; sl@0: spm.iOffset=TPoint(0,0); // Offset from sprites central position sl@0: spm.iInterval=TTimeIntervalMicroSeconds32(1000000); sl@0: iDSprite.Construct(*TestWin->Win(), TPoint(10,10), 0); sl@0: iDSprite.Close(); sl@0: // sl@0: iDPCursor=RDerivedPointerCursor(TheClient->iWs); sl@0: iDPCursor.Construct(0); sl@0: iDPCursor.Close(); sl@0: }; sl@0: sl@0: void CTDerived::RunTestCaseL(TInt /*aCurTestCase*/) sl@0: { sl@0: ((CTDerivedStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); sl@0: switch(++iTest->iState) sl@0: { sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0075 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Test derived window graphics context sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Draw using a derived window gc and a normal sl@0: window gc and check the dawing is the same sl@0: sl@0: @SYMTestExpectedResults Drawing is the same with a derived window gc sl@0: */ sl@0: case 1: sl@0: ((CTDerivedStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0075")); sl@0: iTest->LogSubTest(_L("Derived Gc")); sl@0: DerivedWindowGcL(); sl@0: break; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0076 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Test derived window server session sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Test that a derived window server session functions sl@0: the same as a normal window server session sl@0: sl@0: @SYMTestExpectedResults The derived window server session functions correctly sl@0: */ sl@0: case 2: sl@0: ((CTDerivedStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0076")); sl@0: iTest->LogSubTest(_L("Derived Session")); sl@0: DerivedSession(); sl@0: break; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0077 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Test derived windows and window groups function correctly sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Test that a derived windows and window groups function sl@0: the same as the classes they are derived from sl@0: sl@0: @SYMTestExpectedResults The derived windows and window group functions correctly sl@0: */ sl@0: case 3: sl@0: ((CTDerivedStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0077")); sl@0: iTest->LogSubTest(_L("Derived Blank Window")); sl@0: DerivedWindows(); sl@0: break; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0078 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Test derived screen devices function correctly sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Test that a derived screen device function sl@0: the same as the class it is derived from sl@0: sl@0: @SYMTestExpectedResults The derived screen device functions correctly sl@0: */ sl@0: case 4: sl@0: ((CTDerivedStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0078")); sl@0: iTest->LogSubTest(_L("Derived Screed Device")); sl@0: DerivedScreenDeviceL(); sl@0: break; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0079 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Test derived sprites and pointer cursors function sl@0: correctly sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Test that a derived sprite and pointer cursor sl@0: function correctly sl@0: sl@0: @SYMTestExpectedResults The derived sprite and pointer cursor function sl@0: correctly sl@0: */ sl@0: case 5: sl@0: ((CTDerivedStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0079")); sl@0: iTest->LogSubTest(_L("Derived Sprites")); sl@0: DerivedSprite(); sl@0: break; sl@0: case 6: sl@0: ((CTDerivedStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); sl@0: ((CTDerivedStep*)iStep)->CloseTMSGraphicsStep(); sl@0: TestComplete(); sl@0: break; sl@0: } sl@0: ((CTDerivedStep*)iStep)->RecordTestResultL(); sl@0: } sl@0: sl@0: __WS_CONSTRUCT_STEP__(Derived)