First public contribution.
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef WSDYNAMICRESBASE_H_
17 #define WSDYNAMICRESBASE_H_
19 #include "t_wsdynamicreswinbase.h"
20 #include <graphics/surface.h>
21 #include "surfaceutility.h"
23 //************************************
25 // Asserting wrapper around dereferencing a pointer that might be NULL.
26 // I don't want to fill the test code with checks that this pointer is not null before calling surface utility methods....
28 //************************************
30 template <class Referee,class LoggerOwner>
34 SafePointer(LoggerOwner* aOwner,Referee* aReferee=NULL):
35 iOwner(aOwner), iReferee(aReferee)
37 Referee* operator=(Referee* aReferee)
39 return iReferee=aReferee;
41 Referee*& operator()()
49 iOwner -> INFO_PRINTF1(_L("Tried to dereference a pointer that is null!"));
50 User::Panic(_L("null pointer"),__LINE__);
60 * Base class test harness that provides facilities for windowing and surface testing
63 class CWsDynamicResBase : public CWsDynamicResWinBase
67 virtual ~CWsDynamicResBase();
69 virtual void SetupL();
70 virtual void SetupL(TBool aUseOtherScreenForInfo);
71 virtual void TearDownL();
72 virtual void TearDownFromDeleteL();
73 /* Note that each derived test class needs to declare a static function to register tests.
74 * This should match the following prototype:
75 static CTestSuite* CreateSuiteL( const TDesC& aName );
79 void UISurfaceL(TSurfaceId& aSurfaceId) const;
80 void CommonSurfaceWindowSetupL(RWindow& aWindow, TSurfaceId& aSurface, const TRgb& aColor);
81 void CommonOverlayWindowSetupL(RWindow& aWindow, const TRgb& aColor);
82 void ResizeTestCommonSetupL(RWindow& aWindow, const TRgb& aColor);
84 void LargerTestWindow(TInt aPercentOfBack=80);
85 void MakeExtraChildWindowL(const RWindowBase& aFromParent,TRect aChildRect,TRgb aChildColor);
87 LoopingGcPtr LoopBeginActivateWithWipe(const TRegion& aRegion,RWindow& aWin,TRgb aColor);
88 CWindowGc* BeginActivateWithWipe(TBool aInvalidate,RWindow& aWin,TRgb aColor=TRgb(0,0));
89 CWindowGc* BeginActivateWithWipe(TBool aInvalidate,TRect aRect,RWindow& aWin,TRgb aColor=TRgb(0,0));
90 CWindowGc* BeginActivateWithWipe(const TRegion& aRegion,RWindow& aWin,TRgb aColor);
91 static CFbsBitmap* RotateBitmapLC(const CFbsBitmap* aSrcBitmap);
93 void Pause(TInt aMilliseconds);
94 TInt RegionDiffForUiLayer(TInt aUiLayer); //returns values from TRegionExtend::TOverlapFlags enumeration
96 { //Tereat this as bit flags or distinct states as you wish.
100 EFpUiComplex=3, //If ony this is set then both blended and opaque are full=screen
101 EFpUiRegions=4, //If this FLAG is set then the regions are less than full-screen. Never occurs on its own
102 EFpUiRegionsOpaque=5, //If this is set then the regions are less than full-screen
103 EFpUiRegionsBlended=6, //If this is set then the regions are less than full-screen
104 EFpUiRegionsComplex=7 //This is the expected setting for windowed cr1108 optimisation.
106 FastPathMode DeduceUiFastPathMode();
108 SafePointer<CSurfaceUtility,CWsDynamicResBase> iUtility;
109 class TPostTestCleanup
112 TPostTestCleanup() {}
114 mutable CSurfaceUtility* iSharedUtility;
115 mutable TBool iCleanedUpOnExit;
116 void CreateSharedUtilityL()const ;
118 static const TPostTestCleanup& PostTestCleanupInstance();
119 RBlankWindow iTestBack;
122 RWindow iTestSecondChild;
123 static const TUidPixelFormat KSurfaceFormat = EUidPixelFormatXRGB_8888;
124 static const TInt KBytesPerPixel = 4; // Four bytes per pixel for the format above.
129 struct CWsDynamicResBase::LoopingGcPtr
131 LoopingGcPtr(const TRegion& aRegion,RWindow& aWin,TRgb aColor,CWindowGc *aGc)
132 : iRegion(aRegion), iWin(aWin), iColor(aColor), iGc(aGc), iPass(-1)
134 LoopingGcPtr(const LoopingGcPtr& aRhs)
135 : iRegion(aRhs.iRegion), iWin(aRhs.iWin),
136 iColor(aRhs.iColor), iGc(aRhs.iGc),
140 operator bool() { return iPass>=0?iGc:(CWindowGc *)NULL; }
141 CWindowGc * operator ->() { return iPass>=0?iGc:(CWindowGc *)NULL; }
142 const TRegion& iRegion;
149 #define LOG_AND_PANIC_IF_NOT_GCE \
151 if (!GCEIsSupported()) \
153 INFO_PRINTF1(_L("Test skipped: GCE support is not loaded")); \
154 User::Panic(_L("GCE.Wrong.Mode"),1); \
159 #endif /*WSDYNAMICRESBASE_H_*/