sl@0: // Copyright (c) 2008-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: // sl@0: sl@0: /** sl@0: @file sl@0: @test sl@0: @internalComponent - Internal Symbian test coverage code for GraphicDrawer related code sl@0: */ sl@0: sl@0: #include "gdcoverage.h" sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: const TInt KDefaultScreen = 0; sl@0: sl@0: // sl@0: CWsGraphicDrawerCoverage* CWsGraphicDrawerCoverage::NewL() sl@0: { sl@0: return new(ELeave) CWsGraphicDrawerCoverage; sl@0: } sl@0: sl@0: CWsGraphicDrawerCoverage::~CWsGraphicDrawerCoverage() sl@0: { sl@0: } sl@0: sl@0: void CWsGraphicDrawerCoverage::ConstructL( sl@0: MWsGraphicDrawerEnvironment& aEnv, sl@0: const TGraphicDrawerId& aId, sl@0: MWsClient& aOwner, sl@0: const TDesC8& aData) sl@0: { sl@0: BaseConstructL(aEnv, aId, aOwner); sl@0: sl@0: iScreenId = KDefaultScreen; sl@0: if (aData.Length()>0) sl@0: iScreenId = aData[0]; sl@0: MWsScreen* scr = aEnv.Screen(iScreenId); sl@0: User::LeaveIfNull(scr); sl@0: sl@0: //NGA supports MWsScreenDevice and non-NGA supports MWsScreenConfig, MWsFrontBuffer, MWsBackBuffer sl@0: MWsScreenDevice* screenDevice = scr->ObjectInterface(); sl@0: if(screenDevice) sl@0: { sl@0: //empty for now sl@0: } sl@0: else sl@0: { sl@0: MWsScreenConfig* cfg = scr->ObjectInterface(); sl@0: User::LeaveIfNull(cfg); sl@0: TSize sizeInPixels = cfg->ScreenModeSizeInPixels(); sl@0: __ASSERT_ALWAYS(sizeInPixels.iWidth>0 && sizeInPixels.iHeight>0, User::Invariant()); sl@0: __ASSERT_ALWAYS(cfg->Stride()>0, User::Invariant()); sl@0: __ASSERT_ALWAYS(cfg->ScalingFactor()==TSize(1,1), User::Invariant()); sl@0: __ASSERT_ALWAYS(cfg->Origin()==TPoint(0,0), User::Invariant()); sl@0: sl@0: MWsFrontBuffer* fBuffer = scr->ObjectInterface(); sl@0: User::LeaveIfNull(fBuffer); sl@0: __ASSERT_ALWAYS(fBuffer->GetBits()!=NULL, User::Invariant()); sl@0: __ASSERT_ALWAYS(fBuffer->GetBitGc()!=NULL, User::Invariant()); sl@0: } sl@0: sl@0: MWsScreenRedraw* redraw = scr->ObjectInterface(); sl@0: User::LeaveIfNull(redraw); sl@0: } sl@0: sl@0: void CWsGraphicDrawerCoverage::HandleMessage(const TDesC8& aData) sl@0: { sl@0: // wserv already check data size, and won't invoke this handler if it's empty sl@0: TBuf8<1> ack; sl@0: ack.Append(KGdCoverageInfoSig); sl@0: sl@0: MWsGraphicDrawerEnvironment& env = Env(); sl@0: MWsScreen* scr = env.Screen(iScreenId); sl@0: MWsScreenRedraw* redraw = scr->ObjectInterface(); sl@0: sl@0: switch (aData[0]) sl@0: { sl@0: case KGdCoverageCmdQuery: sl@0: SendInfo(); sl@0: break; sl@0: sl@0: case KGdCoverageCmdCoverRedraw: sl@0: { sl@0: //Hint: for extra coverage in ScheduleRender find a way to call sl@0: //CWsTop::WindowServer()->AnimationScheduler()->Animate(*scr); sl@0: sl@0: //cannot create a real observer, for coverage null is sufficient sl@0: redraw->SetObserver(NULL); sl@0: redraw->IsUpdatePending(); sl@0: TTimeIntervalMicroSeconds interval(1); sl@0: redraw->ScheduleRender(interval); sl@0: const TRegion *r = redraw->AnimationRegion(); sl@0: redraw->UpdateDevice(); sl@0: //although redraw is actually a CScreenRedraw, we cannot include sl@0: //the ScreenRedraw.h here so the following methods are not available: sl@0: //redraw->AddRedrawRegion(*r, ETrue, ERedrawTopOnly); sl@0: //redraw->OnAnimation(); sl@0: break; sl@0: } sl@0: sl@0: default: sl@0: SendMessage(ack); sl@0: break; sl@0: } sl@0: } sl@0: sl@0: void CWsGraphicDrawerCoverage::DoDraw(MWsGc& /*aGc*/, const TRect& /*aRect*/, const TDesC8& /*aData*/) const sl@0: { sl@0: } sl@0: sl@0: void CWsGraphicDrawerCoverage::SendInfo() sl@0: { sl@0: TPckgBuf buf; sl@0: MWsScreen* scr = Env().Screen(iScreenId); sl@0: if (scr) sl@0: { sl@0: buf().iSignature = KGdCoverageInfoSig; sl@0: buf().iNumTests = 1; sl@0: } sl@0: TInt err = SendMessage(buf); sl@0: __ASSERT_ALWAYS(err>=KErrNone, User::Invariant()); sl@0: } sl@0: