sl@0
|
1 |
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#ifndef __TGRAPHICSHARNESS_H__
|
sl@0
|
17 |
#define __TGRAPHICSHARNESS_H__
|
sl@0
|
18 |
|
sl@0
|
19 |
#include <test/testexecutestepbase.h>
|
sl@0
|
20 |
#include <w32std.h>
|
sl@0
|
21 |
#include <test/ttmsgraphicsstep.h>
|
sl@0
|
22 |
|
sl@0
|
23 |
|
sl@0
|
24 |
/**
|
sl@0
|
25 |
A main interface for implementation test cases
|
sl@0
|
26 |
*/
|
sl@0
|
27 |
class MTestCases
|
sl@0
|
28 |
{
|
sl@0
|
29 |
public:
|
sl@0
|
30 |
virtual void RunTestCaseL(TInt aCurTestCase) = 0; // this function needs to be implemented by the derived class
|
sl@0
|
31 |
virtual TInt RunTestCaseLeft(TInt aError) = 0;
|
sl@0
|
32 |
};
|
sl@0
|
33 |
|
sl@0
|
34 |
class CTestManager;
|
sl@0
|
35 |
|
sl@0
|
36 |
/**
|
sl@0
|
37 |
The abstract class is base for test programs, encapsulates the MTestCases interface.
|
sl@0
|
38 |
|
sl@0
|
39 |
All test cases must be implemented in derived classes.
|
sl@0
|
40 |
*/
|
sl@0
|
41 |
class CTGraphicsBase : public CBase, public MTestCases
|
sl@0
|
42 |
{
|
sl@0
|
43 |
friend class CTGraphicsStep;
|
sl@0
|
44 |
public:
|
sl@0
|
45 |
IMPORT_C static const TDesC& ColorModeName(TDisplayMode aMode);
|
sl@0
|
46 |
inline static const TDesC& ColorModeName(TInt aMode);
|
sl@0
|
47 |
IMPORT_C static const TDesC& RotationName(CFbsBitGc::TGraphicsOrientation aOrientation);
|
sl@0
|
48 |
inline static const TDesC& RotationName(TInt aOrientation);
|
sl@0
|
49 |
IMPORT_C static void SaveScreenShotL(CFbsScreenDevice* aScdv);
|
sl@0
|
50 |
IMPORT_C CTGraphicsBase(CTestStep* aStep);
|
sl@0
|
51 |
IMPORT_C ~CTGraphicsBase();
|
sl@0
|
52 |
CTestExecuteLogger& Logger() {return iStep->Logger();}
|
sl@0
|
53 |
// LEGACY methods
|
sl@0
|
54 |
inline void testBooleanTrue(TBool aCondition, const TText8* aFile, TInt aLine);
|
sl@0
|
55 |
inline void testBooleanTrueWithErrorCode(TBool aCondition, TInt aErrorCode, const TText8* aFile, TInt aLine);
|
sl@0
|
56 |
|
sl@0
|
57 |
inline void testSoftFailWinscw(TBool aCondition, const TText8* aFile, TInt aLine);
|
sl@0
|
58 |
|
sl@0
|
59 |
protected:
|
sl@0
|
60 |
IMPORT_C void TestComplete(); //test program has to call this function in order to
|
sl@0
|
61 |
//stop the consequence of test cases and quit the step
|
sl@0
|
62 |
IMPORT_C void SetSelfDrive(TBool aSelfDrive);
|
sl@0
|
63 |
IMPORT_C void CaseComplete();
|
sl@0
|
64 |
virtual void ConstructL(){}
|
sl@0
|
65 |
IMPORT_C void ResetCounter(TInt aNewCurrentTestCase = 0);
|
sl@0
|
66 |
private:
|
sl@0
|
67 |
void Execute();
|
sl@0
|
68 |
void InitializeL();
|
sl@0
|
69 |
IMPORT_C TInt RunTestCaseLeft(TInt aError);
|
sl@0
|
70 |
protected:
|
sl@0
|
71 |
CTestStep* iStep;
|
sl@0
|
72 |
private:
|
sl@0
|
73 |
CTestManager* iTestManager;
|
sl@0
|
74 |
};
|
sl@0
|
75 |
|
sl@0
|
76 |
/** Base class for test step */
|
sl@0
|
77 |
class CTGraphicsStep : public CTTMSGraphicsStep
|
sl@0
|
78 |
{
|
sl@0
|
79 |
public:
|
sl@0
|
80 |
CTGraphicsStep(){}
|
sl@0
|
81 |
virtual ~CTGraphicsStep(){}
|
sl@0
|
82 |
public:
|
sl@0
|
83 |
void SetLogHeapInfo(TBool aLogHeapInfo) {iLogHeapInfo = aLogHeapInfo;}
|
sl@0
|
84 |
protected:
|
sl@0
|
85 |
virtual CTGraphicsBase* CreateTestL() = 0;
|
sl@0
|
86 |
//allocate all test rersources here
|
sl@0
|
87 |
virtual void TestSetupL(){}
|
sl@0
|
88 |
//delete all allocated resourses here
|
sl@0
|
89 |
virtual void TestClose(){}
|
sl@0
|
90 |
//from CTestStep
|
sl@0
|
91 |
IMPORT_C virtual TVerdict doTestStepL();
|
sl@0
|
92 |
private:
|
sl@0
|
93 |
void ExecuteL();
|
sl@0
|
94 |
TInt GetScreenSize(TSize& aSize) const;
|
sl@0
|
95 |
void SetupCleanup(CTrapCleanup*& tc);
|
sl@0
|
96 |
void CloseAllPanicWindows(TInt aId, RWsSession& ws) const;
|
sl@0
|
97 |
void LogHeapInfo(RWsSession &aWs, TBool aStart);
|
sl@0
|
98 |
private:
|
sl@0
|
99 |
TBool iLogHeapInfo; // Only perform wserv heap memory checks when this is true (commonly for wserv testing only)
|
sl@0
|
100 |
};
|
sl@0
|
101 |
|
sl@0
|
102 |
#define TEST2(a, b) testBooleanTrue((a == b), (TText8*)__FILE__, __LINE__)
|
sl@0
|
103 |
#define TEST_SOFTFAIL_WINSCW(a) testSoftFailWinscw((a), (TText8*)__FILE__, __LINE__)
|
sl@0
|
104 |
|
sl@0
|
105 |
inline const TDesC& CTGraphicsBase::ColorModeName(TInt aMode)
|
sl@0
|
106 |
{return ColorModeName(reinterpret_cast<TDisplayMode&>(aMode));}
|
sl@0
|
107 |
inline const TDesC& CTGraphicsBase::RotationName(TInt aOrientation)
|
sl@0
|
108 |
{return RotationName(reinterpret_cast<CFbsBitGc::TGraphicsOrientation&>(aOrientation));}
|
sl@0
|
109 |
|
sl@0
|
110 |
// Macro for defining test step constructor and creating a test.
|
sl@0
|
111 |
// Work for the following name convention:
|
sl@0
|
112 |
// step class - CTXXStep
|
sl@0
|
113 |
// test class - CTXX,
|
sl@0
|
114 |
// where XX any name
|
sl@0
|
115 |
|
sl@0
|
116 |
#define __CONSTRUCT_STEP__(a) \
|
sl@0
|
117 |
CT##a##Step::CT##a##Step() \
|
sl@0
|
118 |
{ \
|
sl@0
|
119 |
SetTestStepName(KT##a##Step); \
|
sl@0
|
120 |
} \
|
sl@0
|
121 |
\
|
sl@0
|
122 |
CTGraphicsBase* CT##a##Step::CreateTestL() \
|
sl@0
|
123 |
{ \
|
sl@0
|
124 |
return new (ELeave) CT##a (this); \
|
sl@0
|
125 |
}
|
sl@0
|
126 |
|
sl@0
|
127 |
// Macros to automatically test error condition and report when test fails.
|
sl@0
|
128 |
// Essentially same as TESTE(a,b) MACRO that CTestStep uses, except error to
|
sl@0
|
129 |
// check is also error that is reported.
|
sl@0
|
130 |
#define TESTNOERROR(a) \
|
sl@0
|
131 |
{\
|
sl@0
|
132 |
TInt b = a;\
|
sl@0
|
133 |
TBool c = (b == KErrNone);\
|
sl@0
|
134 |
testBooleanTrueWithErrorCode((c), (b), (TText8*)__FILE__, __LINE__);\
|
sl@0
|
135 |
}
|
sl@0
|
136 |
|
sl@0
|
137 |
inline void CTGraphicsBase::testBooleanTrue(TBool aCondition, const TText8* aFile, TInt aLine)
|
sl@0
|
138 |
{
|
sl@0
|
139 |
((CTGraphicsStep*)iStep)->MQCTest(aCondition, aFile, aLine);
|
sl@0
|
140 |
}
|
sl@0
|
141 |
|
sl@0
|
142 |
inline void CTGraphicsBase::testBooleanTrueWithErrorCode(TBool aCondition, TInt aErrorCode, const TText8* aFile, TInt aLine)
|
sl@0
|
143 |
{
|
sl@0
|
144 |
((CTGraphicsStep*)iStep)->MQCTestWithErrorCode(aCondition, aErrorCode, aFile, aLine);
|
sl@0
|
145 |
}
|
sl@0
|
146 |
|
sl@0
|
147 |
inline void CTGraphicsBase::testSoftFailWinscw(TBool aCondition, const TText8* aFile, TInt aLine)
|
sl@0
|
148 |
{
|
sl@0
|
149 |
#ifdef __WINS__
|
sl@0
|
150 |
if (!aCondition)
|
sl@0
|
151 |
{
|
sl@0
|
152 |
_LIT(KMessage,"ERROR: Test Failed but is ignored on WINSCW");
|
sl@0
|
153 |
Logger().LogExtra(aFile, aLine, ESevrErr, KMessage);
|
sl@0
|
154 |
}
|
sl@0
|
155 |
#else // __WINS__
|
sl@0
|
156 |
testBooleanTrue(aCondition, aFile, aLine);
|
sl@0
|
157 |
#endif //__WINS__
|
sl@0
|
158 |
}
|
sl@0
|
159 |
#endif
|