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: #ifndef WSDYNAMICRESBASE_H_ sl@0: #define WSDYNAMICRESBASE_H_ sl@0: sl@0: #include "t_wsdynamicreswinbase.h" sl@0: #include sl@0: #include "surfaceutility.h" sl@0: sl@0: //************************************ sl@0: // sl@0: // Asserting wrapper around dereferencing a pointer that might be NULL. sl@0: // I don't want to fill the test code with checks that this pointer is not null before calling surface utility methods.... sl@0: // sl@0: //************************************ sl@0: sl@0: template sl@0: class SafePointer sl@0: { sl@0: public: sl@0: SafePointer(LoggerOwner* aOwner,Referee* aReferee=NULL): sl@0: iOwner(aOwner), iReferee(aReferee) sl@0: {} sl@0: Referee* operator=(Referee* aReferee) sl@0: { sl@0: return iReferee=aReferee; sl@0: } sl@0: Referee*& operator()() sl@0: { sl@0: return iReferee; sl@0: } sl@0: Referee* operator->() sl@0: { sl@0: if (iReferee==NULL) sl@0: { sl@0: iOwner -> INFO_PRINTF1(_L("Tried to dereference a pointer that is null!")); sl@0: User::Panic(_L("null pointer"),__LINE__); sl@0: } sl@0: return iReferee; sl@0: } sl@0: private: sl@0: LoggerOwner* iOwner; sl@0: Referee* iReferee; sl@0: }; sl@0: sl@0: /** sl@0: * Base class test harness that provides facilities for windowing and surface testing sl@0: * sl@0: **/ sl@0: class CWsDynamicResBase : public CWsDynamicResWinBase sl@0: { sl@0: public: sl@0: CWsDynamicResBase(); sl@0: virtual ~CWsDynamicResBase(); sl@0: sl@0: virtual void SetupL(); sl@0: virtual void SetupL(TBool aUseOtherScreenForInfo); sl@0: virtual void TearDownL(); sl@0: virtual void TearDownFromDeleteL(); sl@0: /* Note that each derived test class needs to declare a static function to register tests. sl@0: * This should match the following prototype: sl@0: static CTestSuite* CreateSuiteL( const TDesC& aName ); sl@0: */ sl@0: sl@0: protected: sl@0: void UISurfaceL(TSurfaceId& aSurfaceId) const; sl@0: void CommonSurfaceWindowSetupL(RWindow& aWindow, TSurfaceId& aSurface, const TRgb& aColor); sl@0: void CommonOverlayWindowSetupL(RWindow& aWindow, const TRgb& aColor); sl@0: void ResizeTestCommonSetupL(RWindow& aWindow, const TRgb& aColor); sl@0: sl@0: void LargerTestWindow(TInt aPercentOfBack=80); sl@0: void MakeExtraChildWindowL(const RWindowBase& aFromParent,TRect aChildRect,TRgb aChildColor); sl@0: struct LoopingGcPtr; sl@0: LoopingGcPtr LoopBeginActivateWithWipe(const TRegion& aRegion,RWindow& aWin,TRgb aColor); sl@0: CWindowGc* BeginActivateWithWipe(TBool aInvalidate,RWindow& aWin,TRgb aColor=TRgb(0,0)); sl@0: CWindowGc* BeginActivateWithWipe(TBool aInvalidate,TRect aRect,RWindow& aWin,TRgb aColor=TRgb(0,0)); sl@0: CWindowGc* BeginActivateWithWipe(const TRegion& aRegion,RWindow& aWin,TRgb aColor); sl@0: static CFbsBitmap* RotateBitmapLC(const CFbsBitmap* aSrcBitmap); sl@0: sl@0: void Pause(TInt aMilliseconds); sl@0: TInt RegionDiffForUiLayer(TInt aUiLayer); //returns values from TRegionExtend::TOverlapFlags enumeration sl@0: enum FastPathMode sl@0: { //Tereat this as bit flags or distinct states as you wish. sl@0: EFpExternalOpaque=0, sl@0: EFpUiOpaque=1, sl@0: EFpUiBlended=2, sl@0: EFpUiComplex=3, //If ony this is set then both blended and opaque are full=screen sl@0: EFpUiRegions=4, //If this FLAG is set then the regions are less than full-screen. Never occurs on its own sl@0: EFpUiRegionsOpaque=5, //If this is set then the regions are less than full-screen sl@0: EFpUiRegionsBlended=6, //If this is set then the regions are less than full-screen sl@0: EFpUiRegionsComplex=7 //This is the expected setting for windowed cr1108 optimisation. sl@0: }; sl@0: FastPathMode DeduceUiFastPathMode(); sl@0: protected: sl@0: SafePointer iUtility; sl@0: class TPostTestCleanup sl@0: { sl@0: protected: sl@0: TPostTestCleanup() {} sl@0: public: sl@0: mutable CSurfaceUtility* iSharedUtility; sl@0: mutable TBool iCleanedUpOnExit; sl@0: void CreateSharedUtilityL()const ; sl@0: }; sl@0: static const TPostTestCleanup& PostTestCleanupInstance(); sl@0: RBlankWindow iTestBack; sl@0: RWindow iTestFront; sl@0: RWindow iTestChild; sl@0: RWindow iTestSecondChild; sl@0: static const TUidPixelFormat KSurfaceFormat = EUidPixelFormatXRGB_8888; sl@0: static const TInt KBytesPerPixel = 4; // Four bytes per pixel for the format above. sl@0: private: sl@0: sl@0: }; sl@0: sl@0: struct CWsDynamicResBase::LoopingGcPtr sl@0: { sl@0: LoopingGcPtr(const TRegion& aRegion,RWindow& aWin,TRgb aColor,CWindowGc *aGc) sl@0: : iRegion(aRegion), iWin(aWin), iColor(aColor), iGc(aGc), iPass(-1) sl@0: { operator++(); } sl@0: LoopingGcPtr(const LoopingGcPtr& aRhs) sl@0: : iRegion(aRhs.iRegion), iWin(aRhs.iWin), sl@0: iColor(aRhs.iColor), iGc(aRhs.iGc), sl@0: iPass(aRhs.iPass) sl@0: {} sl@0: void operator ++(); sl@0: operator bool() { return iPass>=0?iGc:(CWindowGc *)NULL; } sl@0: CWindowGc * operator ->() { return iPass>=0?iGc:(CWindowGc *)NULL; } sl@0: const TRegion& iRegion; sl@0: RWindow& iWin; sl@0: TRgb iColor; sl@0: CWindowGc *iGc; sl@0: TInt iPass; sl@0: }; sl@0: sl@0: #define LOG_AND_PANIC_IF_NOT_GCE \ sl@0: { \ sl@0: if (!GCEIsSupported()) \ sl@0: { \ sl@0: INFO_PRINTF1(_L("Test skipped: GCE support is not loaded")); \ sl@0: User::Panic(_L("GCE.Wrong.Mode"),1); \ sl@0: return; \ sl@0: } \ sl@0: } sl@0: sl@0: #endif /*WSDYNAMICRESBASE_H_*/