Update contrib.
1 // Copyright (c) 2005-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 __TGRAPHICSHARNESS_H__
17 #define __TGRAPHICSHARNESS_H__
19 #include <test/testexecutestepbase.h>
21 #include <test/ttmsgraphicsstep.h>
25 A main interface for implementation test cases
30 virtual void RunTestCaseL(TInt aCurTestCase) = 0; // this function needs to be implemented by the derived class
31 virtual TInt RunTestCaseLeft(TInt aError) = 0;
37 The abstract class is base for test programs, encapsulates the MTestCases interface.
39 All test cases must be implemented in derived classes.
41 class CTGraphicsBase : public CBase, public MTestCases
43 friend class CTGraphicsStep;
45 IMPORT_C static const TDesC& ColorModeName(TDisplayMode aMode);
46 inline static const TDesC& ColorModeName(TInt aMode);
47 IMPORT_C static const TDesC& RotationName(CFbsBitGc::TGraphicsOrientation aOrientation);
48 inline static const TDesC& RotationName(TInt aOrientation);
49 IMPORT_C static void SaveScreenShotL(CFbsScreenDevice* aScdv);
50 IMPORT_C CTGraphicsBase(CTestStep* aStep);
51 IMPORT_C ~CTGraphicsBase();
52 CTestExecuteLogger& Logger() {return iStep->Logger();}
54 inline void testBooleanTrue(TBool aCondition, const TText8* aFile, TInt aLine);
55 inline void testBooleanTrueWithErrorCode(TBool aCondition, TInt aErrorCode, const TText8* aFile, TInt aLine);
57 inline void testSoftFailWinscw(TBool aCondition, const TText8* aFile, TInt aLine);
60 IMPORT_C void TestComplete(); //test program has to call this function in order to
61 //stop the consequence of test cases and quit the step
62 IMPORT_C void SetSelfDrive(TBool aSelfDrive);
63 IMPORT_C void CaseComplete();
64 virtual void ConstructL(){}
65 IMPORT_C void ResetCounter(TInt aNewCurrentTestCase = 0);
69 IMPORT_C TInt RunTestCaseLeft(TInt aError);
73 CTestManager* iTestManager;
76 /** Base class for test step */
77 class CTGraphicsStep : public CTTMSGraphicsStep
81 virtual ~CTGraphicsStep(){}
83 void SetLogHeapInfo(TBool aLogHeapInfo) {iLogHeapInfo = aLogHeapInfo;}
85 virtual CTGraphicsBase* CreateTestL() = 0;
86 //allocate all test rersources here
87 virtual void TestSetupL(){}
88 //delete all allocated resourses here
89 virtual void TestClose(){}
91 IMPORT_C virtual TVerdict doTestStepL();
94 TInt GetScreenSize(TSize& aSize) const;
95 void SetupCleanup(CTrapCleanup*& tc);
96 void CloseAllPanicWindows(TInt aId, RWsSession& ws) const;
97 void LogHeapInfo(RWsSession &aWs, TBool aStart);
99 TBool iLogHeapInfo; // Only perform wserv heap memory checks when this is true (commonly for wserv testing only)
102 #define TEST2(a, b) testBooleanTrue((a == b), (TText8*)__FILE__, __LINE__)
103 #define TEST_SOFTFAIL_WINSCW(a) testSoftFailWinscw((a), (TText8*)__FILE__, __LINE__)
105 inline const TDesC& CTGraphicsBase::ColorModeName(TInt aMode)
106 {return ColorModeName(reinterpret_cast<TDisplayMode&>(aMode));}
107 inline const TDesC& CTGraphicsBase::RotationName(TInt aOrientation)
108 {return RotationName(reinterpret_cast<CFbsBitGc::TGraphicsOrientation&>(aOrientation));}
110 // Macro for defining test step constructor and creating a test.
111 // Work for the following name convention:
112 // step class - CTXXStep
113 // test class - CTXX,
116 #define __CONSTRUCT_STEP__(a) \
117 CT##a##Step::CT##a##Step() \
119 SetTestStepName(KT##a##Step); \
122 CTGraphicsBase* CT##a##Step::CreateTestL() \
124 return new (ELeave) CT##a (this); \
127 // Macros to automatically test error condition and report when test fails.
128 // Essentially same as TESTE(a,b) MACRO that CTestStep uses, except error to
129 // check is also error that is reported.
130 #define TESTNOERROR(a) \
133 TBool c = (b == KErrNone);\
134 testBooleanTrueWithErrorCode((c), (b), (TText8*)__FILE__, __LINE__);\
137 inline void CTGraphicsBase::testBooleanTrue(TBool aCondition, const TText8* aFile, TInt aLine)
139 ((CTGraphicsStep*)iStep)->MQCTest(aCondition, aFile, aLine);
142 inline void CTGraphicsBase::testBooleanTrueWithErrorCode(TBool aCondition, TInt aErrorCode, const TText8* aFile, TInt aLine)
144 ((CTGraphicsStep*)iStep)->MQCTestWithErrorCode(aCondition, aErrorCode, aFile, aLine);
147 inline void CTGraphicsBase::testSoftFailWinscw(TBool aCondition, const TText8* aFile, TInt aLine)
152 _LIT(KMessage,"ERROR: Test Failed but is ignored on WINSCW");
153 Logger().LogExtra(aFile, aLine, ESevrErr, KMessage);
156 testBooleanTrue(aCondition, aFile, aLine);