|
1 /* |
|
2 * Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __T_TESTACTION_H__ |
|
20 #define __T_TESTACTION_H__ |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <f32file.h> |
|
24 #include <testhandler2/t_testactionspec.h> |
|
25 |
|
26 class CConsoleBase; |
|
27 class CConsoleBase; |
|
28 class Output; |
|
29 class CTestHandler; |
|
30 |
|
31 const TInt KMaxErrorSize = 100; |
|
32 |
|
33 class CTestAction : public CBase |
|
34 { |
|
35 public: |
|
36 IMPORT_C virtual ~CTestAction(); |
|
37 |
|
38 public: |
|
39 enum TScriptError |
|
40 { |
|
41 ENone, |
|
42 ESyntax, |
|
43 EFileNotFound |
|
44 }; |
|
45 IMPORT_C virtual void PerformPrerequisite(TRequestStatus& aStatus); |
|
46 virtual void PerformAction(TRequestStatus& aStatus) = 0; |
|
47 IMPORT_C virtual void PerformPostrequisite(TRequestStatus& aStatus); |
|
48 TBool Finished(); |
|
49 IMPORT_C virtual void ReportAction(); |
|
50 IMPORT_C virtual void CheckResult(TInt aError); |
|
51 IMPORT_C void virtual FailTestNow(TRequestStatus& aStatus); |
|
52 IMPORT_C virtual TScriptError ScriptError(void); |
|
53 IMPORT_C virtual void ScriptError(TDes& aError); |
|
54 IMPORT_C virtual void SetScriptError(const TScriptError &iScriptError, const TDesC& aError); |
|
55 |
|
56 // Specific functions for testing cancellation |
|
57 public: |
|
58 IMPORT_C virtual void PerformCancel(); |
|
59 |
|
60 // Specific functions for testing OOM |
|
61 public: |
|
62 IMPORT_C virtual void Reset(); |
|
63 IMPORT_C virtual void AfterOOMFailure(); |
|
64 IMPORT_C virtual void ResetState(); |
|
65 |
|
66 // Functions for accessing data shared between all test actions in a test run |
|
67 public: |
|
68 void SetTestHandler(CTestHandler& aTestHandler); |
|
69 protected: |
|
70 IMPORT_C CBase* SharedData() const; |
|
71 IMPORT_C void SetSharedData(CBase* aData); |
|
72 |
|
73 protected: |
|
74 IMPORT_C CTestAction(CConsoleBase& aConsole, Output& aOut); |
|
75 IMPORT_C void ConstructL(const TTestActionSpec& aTestActionSpec); |
|
76 |
|
77 private: |
|
78 IMPORT_C virtual void DoPerformPrerequisite(TRequestStatus& aStatus); |
|
79 IMPORT_C virtual void DoPerformPostrequisite(TRequestStatus& aStatus); |
|
80 virtual void DoReportAction() = 0; |
|
81 virtual void DoCheckResult(TInt aError) = 0; |
|
82 public: |
|
83 enum TActionState |
|
84 { |
|
85 EPrerequisite, |
|
86 EAction, |
|
87 EPostrequisite |
|
88 }; |
|
89 |
|
90 protected: |
|
91 TBool iFinished; |
|
92 TInt iExpectedResult; |
|
93 |
|
94 public: |
|
95 /** |
|
96 * After the test, this will be ETrue if the test succeeded or EFalse otherwise. |
|
97 */ |
|
98 TBool iResult; |
|
99 /** |
|
100 * Indicates whether the test will fail because of known deferred defects etc |
|
101 */ |
|
102 TBool iKnownFailure; |
|
103 TActionState iActionState; |
|
104 HBufC8* iNameInfo; |
|
105 |
|
106 protected: |
|
107 CConsoleBase& iConsole; |
|
108 Output& iOut; |
|
109 TBuf<KMaxErrorSize> aScriptErrorDescription; |
|
110 TScriptError iScriptError; |
|
111 CTestHandler* iTestHandler; |
|
112 }; |
|
113 |
|
114 #endif |