1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/windowing/windowserver/test/tdynamicres/inc/wsdynamicresbase.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,159 @@
1.4 +// Copyright (c) 2008-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 +//
1.18 +
1.19 +#ifndef WSDYNAMICRESBASE_H_
1.20 +#define WSDYNAMICRESBASE_H_
1.21 +
1.22 +#include "t_wsdynamicreswinbase.h"
1.23 +#include <graphics/surface.h>
1.24 +#include "surfaceutility.h"
1.25 +
1.26 +//************************************
1.27 +//
1.28 +// Asserting wrapper around dereferencing a pointer that might be NULL.
1.29 +// I don't want to fill the test code with checks that this pointer is not null before calling surface utility methods....
1.30 +//
1.31 +//************************************
1.32 +
1.33 +template <class Referee,class LoggerOwner>
1.34 +class SafePointer
1.35 + {
1.36 +public:
1.37 + SafePointer(LoggerOwner* aOwner,Referee* aReferee=NULL):
1.38 + iOwner(aOwner), iReferee(aReferee)
1.39 + {}
1.40 + Referee* operator=(Referee* aReferee)
1.41 + {
1.42 + return iReferee=aReferee;
1.43 + }
1.44 + Referee*& operator()()
1.45 + {
1.46 + return iReferee;
1.47 + }
1.48 + Referee* operator->()
1.49 + {
1.50 + if (iReferee==NULL)
1.51 + {
1.52 + iOwner -> INFO_PRINTF1(_L("Tried to dereference a pointer that is null!"));
1.53 + User::Panic(_L("null pointer"),__LINE__);
1.54 + }
1.55 + return iReferee;
1.56 + }
1.57 +private:
1.58 + LoggerOwner* iOwner;
1.59 + Referee* iReferee;
1.60 + };
1.61 +
1.62 +/**
1.63 + * Base class test harness that provides facilities for windowing and surface testing
1.64 + *
1.65 + **/
1.66 +class CWsDynamicResBase : public CWsDynamicResWinBase
1.67 +{
1.68 +public:
1.69 + CWsDynamicResBase();
1.70 + virtual ~CWsDynamicResBase();
1.71 +
1.72 + virtual void SetupL();
1.73 + virtual void SetupL(TBool aUseOtherScreenForInfo);
1.74 + virtual void TearDownL();
1.75 + virtual void TearDownFromDeleteL();
1.76 + /* Note that each derived test class needs to declare a static function to register tests.
1.77 + * This should match the following prototype:
1.78 + static CTestSuite* CreateSuiteL( const TDesC& aName );
1.79 + */
1.80 +
1.81 + protected:
1.82 + void UISurfaceL(TSurfaceId& aSurfaceId) const;
1.83 + void CommonSurfaceWindowSetupL(RWindow& aWindow, TSurfaceId& aSurface, const TRgb& aColor);
1.84 + void CommonOverlayWindowSetupL(RWindow& aWindow, const TRgb& aColor);
1.85 + void ResizeTestCommonSetupL(RWindow& aWindow, const TRgb& aColor);
1.86 +
1.87 + void LargerTestWindow(TInt aPercentOfBack=80);
1.88 + void MakeExtraChildWindowL(const RWindowBase& aFromParent,TRect aChildRect,TRgb aChildColor);
1.89 + struct LoopingGcPtr;
1.90 + LoopingGcPtr LoopBeginActivateWithWipe(const TRegion& aRegion,RWindow& aWin,TRgb aColor);
1.91 + CWindowGc* BeginActivateWithWipe(TBool aInvalidate,RWindow& aWin,TRgb aColor=TRgb(0,0));
1.92 + CWindowGc* BeginActivateWithWipe(TBool aInvalidate,TRect aRect,RWindow& aWin,TRgb aColor=TRgb(0,0));
1.93 + CWindowGc* BeginActivateWithWipe(const TRegion& aRegion,RWindow& aWin,TRgb aColor);
1.94 + static CFbsBitmap* RotateBitmapLC(const CFbsBitmap* aSrcBitmap);
1.95 +
1.96 + void Pause(TInt aMilliseconds);
1.97 + TInt RegionDiffForUiLayer(TInt aUiLayer); //returns values from TRegionExtend::TOverlapFlags enumeration
1.98 + enum FastPathMode
1.99 + { //Tereat this as bit flags or distinct states as you wish.
1.100 + EFpExternalOpaque=0,
1.101 + EFpUiOpaque=1,
1.102 + EFpUiBlended=2,
1.103 + EFpUiComplex=3, //If ony this is set then both blended and opaque are full=screen
1.104 + EFpUiRegions=4, //If this FLAG is set then the regions are less than full-screen. Never occurs on its own
1.105 + EFpUiRegionsOpaque=5, //If this is set then the regions are less than full-screen
1.106 + EFpUiRegionsBlended=6, //If this is set then the regions are less than full-screen
1.107 + EFpUiRegionsComplex=7 //This is the expected setting for windowed cr1108 optimisation.
1.108 + };
1.109 + FastPathMode DeduceUiFastPathMode();
1.110 +protected:
1.111 + SafePointer<CSurfaceUtility,CWsDynamicResBase> iUtility;
1.112 + class TPostTestCleanup
1.113 + {
1.114 + protected:
1.115 + TPostTestCleanup() {}
1.116 + public:
1.117 + mutable CSurfaceUtility* iSharedUtility;
1.118 + mutable TBool iCleanedUpOnExit;
1.119 + void CreateSharedUtilityL()const ;
1.120 + };
1.121 + static const TPostTestCleanup& PostTestCleanupInstance();
1.122 + RBlankWindow iTestBack;
1.123 + RWindow iTestFront;
1.124 + RWindow iTestChild;
1.125 + RWindow iTestSecondChild;
1.126 + static const TUidPixelFormat KSurfaceFormat = EUidPixelFormatXRGB_8888;
1.127 + static const TInt KBytesPerPixel = 4; // Four bytes per pixel for the format above.
1.128 +private:
1.129 +
1.130 +};
1.131 +
1.132 +struct CWsDynamicResBase::LoopingGcPtr
1.133 + {
1.134 + LoopingGcPtr(const TRegion& aRegion,RWindow& aWin,TRgb aColor,CWindowGc *aGc)
1.135 + : iRegion(aRegion), iWin(aWin), iColor(aColor), iGc(aGc), iPass(-1)
1.136 + { operator++(); }
1.137 + LoopingGcPtr(const LoopingGcPtr& aRhs)
1.138 + : iRegion(aRhs.iRegion), iWin(aRhs.iWin),
1.139 + iColor(aRhs.iColor), iGc(aRhs.iGc),
1.140 + iPass(aRhs.iPass)
1.141 + {}
1.142 + void operator ++();
1.143 + operator bool() { return iPass>=0?iGc:(CWindowGc *)NULL; }
1.144 + CWindowGc * operator ->() { return iPass>=0?iGc:(CWindowGc *)NULL; }
1.145 + const TRegion& iRegion;
1.146 + RWindow& iWin;
1.147 + TRgb iColor;
1.148 + CWindowGc *iGc;
1.149 + TInt iPass;
1.150 + };
1.151 +
1.152 +#define LOG_AND_PANIC_IF_NOT_GCE \
1.153 + { \
1.154 + if (!GCEIsSupported()) \
1.155 + { \
1.156 + INFO_PRINTF1(_L("Test skipped: GCE support is not loaded")); \
1.157 + User::Panic(_L("GCE.Wrong.Mode"),1); \
1.158 + return; \
1.159 + } \
1.160 + }
1.161 +
1.162 +#endif /*WSDYNAMICRESBASE_H_*/