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: // twsgcetestwinbase.h sl@0: // sl@0: // sl@0: sl@0: #ifndef TWSDYNAMICRESWINBASE_H_ sl@0: #define TWSDYNAMICRESWINBASE_H_ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "wsgcedebugsession.h" sl@0: struct TWsDebugWindowId; sl@0: sl@0: /** sl@0: * Base class sets up the tryptich of test windows. sl@0: * sl@0: * sl@0: **/ sl@0: class CWsDynamicResWinBase : public CTestFixture sl@0: { sl@0: public: sl@0: CWsDynamicResWinBase(); sl@0: virtual ~CWsDynamicResWinBase(); sl@0: virtual void SetupL(); sl@0: virtual void SetupL(TBool aUseOtherScreenForInfo); sl@0: sl@0: virtual void TearDownL(); sl@0: virtual void TearDownFromDeleteL(); sl@0: sl@0: static TBool ActivateWithWipe(CWindowGc* aGc,RWindow& aWin,TRgb aColor=TRgb(0,0)); sl@0: 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: static void Pause(TInt aMilliseconds=200); sl@0: sl@0: TBool GCEIsSupported() const; sl@0: static TBool GCEIsSupportedStatic(); sl@0: sl@0: TBool DisplayHasAlpha() const; sl@0: TBool SelectChromaCompositionMode(); sl@0: TBool SelectAlphaCompositionMode(TDisplayMode aMode = EColor16MA); sl@0: TRgb GceHoleColor(RWindowBase& aWin)const; sl@0: void DrawUIContent(RWindow& aWindow); sl@0: void DrawPlainUI(RWindow& aWindow,TBool aInvalidate,TRgb aWipeColor=TRgb(0,0)); sl@0: void DrawCross(RWindow& aWindow, TRgb aColor, TInt aThickness=1); sl@0: void TestPixelL(TPoint aPt, TRgb aColor, TBool aMatch); sl@0: TBool TestRectL(TRect aRect,TRgb aInnerColor,TInt aOtherInnerColors,TRgb aOuterColor,TInt aOtherOuterColors,TInt aCornerSize); sl@0: void MakeTitleAndCompareWindowsL(TRefByValue aTitle,TRefByValue aDetail=_L("")); sl@0: void LargerCompareWindow(TBool aGoLarger=ETrue); sl@0: void UpdateTitleWindowL(TRefByValue aDetail,TInt aIndex=0); sl@0: void RepaintTitleWindowL(); sl@0: void TefUnitFailLeaveL(); sl@0: CWindowGc* GcForWindow(RWindow& aWin); sl@0: TBool InvalidateRegion(const TRegion& aRegion,RWindow& aWin); 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: /** Helper method to find a named screen region sl@0: * start/end letter should be 'a' to 'y' (yes that includes 'i') sl@0: **/ sl@0: static TRect PentCellRect(const TRect& aFullRect,char aStartLetter,char aEndLetter=0); sl@0: void CheckAndConnectScreen(); sl@0: sl@0: protected: sl@0: static const TInt KSurfaceWidth = 50; sl@0: static const TInt KSurfaceHeight = 50; sl@0: TBool iDoTearDown; sl@0: RWsDebugSession iSession; sl@0: RWindowGroup iGroup; sl@0: RWindowGroup iInfoGroupInstance; sl@0: RWindowGroup* iInfoGroup; sl@0: CWsScreenDevice* iScreenDevice; sl@0: CWsScreenDevice* iInfoScreenDevice; sl@0: CWindowGc* iGc; sl@0: CWindowGc* iInfoGc; sl@0: TInt iWindowHandle; sl@0: static TBool iTransparencyEnabled; sl@0: TRgb iRed, iGreen, iBlue, iCyan, iMagenta, iYellow, iWhite; sl@0: TRgb TITLE_BACKGROUND; sl@0: TRgb COMPARE_BACKGROUND; sl@0: RBlankWindow iBackground; sl@0: RWindow iCompare; sl@0: RWindow iTitle; sl@0: TRect iTestPos; sl@0: TRect iCenteredFrontWinRect; sl@0: TPoint iTestPointCentre; sl@0: TDisplayMode iDisplayMode; sl@0: static const TInt KMaxTestName = 80; sl@0: typedef TBuf TTestName; sl@0: mutable TRgb iLastGceHoleColor; sl@0: TTestName iTestName; sl@0: static const TInt KMaxInfoLines=5; sl@0: TTestName iTestInfo[KMaxInfoLines]; sl@0: static CActiveScheduler iScheduler; sl@0: }; sl@0: sl@0: // This little helper class checks that the given bytes contain the expected pattern. sl@0: namespace Pattern sl@0: { sl@0: void Fill(void* aTrg,TInt aOffset,TInt aLength); sl@0: TBool Check(void* aTrg,TInt aOffset,TInt aLength); sl@0: TBool CheckVal(void* aTrg,TInt aOffset,TInt aLength,char val=0); sl@0: } sl@0: sl@0: //This wrapper for the configuration class allows stress testing of the configuration object sl@0: sl@0: template sl@0: class TestExtend: public TXxxConfiguration sl@0: { sl@0: public: sl@0: char iExtraData[aExtraSize]; sl@0: TestExtend(): sl@0: TXxxConfiguration(aFalseSize) sl@0: { sl@0: TXxxConfiguration::iSize=aFalseSize; sl@0: Pattern::Fill(this,aFalseSize,sizeof(*this)-aFalseSize); sl@0: } sl@0: void* operator new(unsigned int,TestExtend* inplace) sl@0: { //Use this inplace operator new to pre-initialise the memory sl@0: return inplace; sl@0: } sl@0: void operator delete(void*,TestExtend*) sl@0: { //Stops the warning! sl@0: } sl@0: TestExtend(const TXxxConfiguration&i): sl@0: TXxxConfiguration(i) sl@0: { sl@0: Pattern::Check(this,sizeof(TXxxConfiguration),aExtraSize); sl@0: } sl@0: TBool WasExtraOverwritten() sl@0: { sl@0: return Pattern::Check(this,sizeof(TXxxConfiguration),aExtraSize); sl@0: } sl@0: TBool WasFalseSizeOverwritten() sl@0: { sl@0: return Pattern::Check(this,aFalseSize,sizeof(*this)-aFalseSize); sl@0: } sl@0: TBool WasFalseSizeZero() sl@0: { sl@0: return Pattern::CheckVal(this,aFalseSize,sizeof(TXxxConfiguration)-aFalseSize); sl@0: } sl@0: void StompValue(TInt aOffsetInLongs,TInt aNewValue) sl@0: { sl@0: *((TInt*)this+aOffsetInLongs)=aNewValue; sl@0: } sl@0: TInt ReadValue(TInt aOffsetInLongs) sl@0: { sl@0: return *((TInt*)this+aOffsetInLongs); sl@0: } sl@0: }; sl@0: #endif /*TWSDYNAMICRESWINBASE_H_*/