|
1 // Copyright (c) 2003-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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __HARNESS_H |
|
17 #define __HARNESS_H |
|
18 |
|
19 #include <e32test.h> |
|
20 #include <badesca.h> |
|
21 #include <pop3set.h> |
|
22 #include <smtpset.h> |
|
23 #include <imapset.h> |
|
24 #include <smutset.h> |
|
25 #include "msvtestutils.h" |
|
26 #include "testframeutils.h" |
|
27 #include "biotestutils.h" |
|
28 |
|
29 // forward declaration |
|
30 class CEmailAccounts; |
|
31 |
|
32 // |
|
33 // |
|
34 // MBaseTestState |
|
35 // |
|
36 |
|
37 class MBaseTestState |
|
38 { |
|
39 public: |
|
40 virtual void StartL(TRequestStatus& aStatus) = 0; |
|
41 virtual ~MBaseTestState() {}; |
|
42 |
|
43 inline void SetDebugInfo(const TTestDebugInfo& aDebugInfo) { iDebugInfo = aDebugInfo; } |
|
44 const TTestDebugInfo& GetDebugInfo() const {return iDebugInfo;}; |
|
45 |
|
46 protected: |
|
47 TTestDebugInfo iDebugInfo; |
|
48 }; |
|
49 |
|
50 // |
|
51 // |
|
52 // CBaseTestHarness |
|
53 // |
|
54 |
|
55 class CBaseTestHarness : public CActive, public MBaseTestState |
|
56 { |
|
57 public: |
|
58 virtual ~CBaseTestHarness(); |
|
59 virtual void StartL(TRequestStatus& aStatus); |
|
60 virtual void AddStateL(MBaseTestState* aTestState, TTestDebugInfo aDebugInfo); |
|
61 |
|
62 inline virtual void SetHeapFailureTesting(TBool aTest) { iTestHeapFailure = aTest; } |
|
63 inline virtual void LogCommentL(const TDesC& /*aComment*/) {}; |
|
64 inline RTest& TestConsole() { return iTest; } |
|
65 |
|
66 inline void SetExpectedError(TInt aError) { iExpectedError = aError; } |
|
67 |
|
68 // |
|
69 // From CActive |
|
70 virtual void RunL(); |
|
71 inline void DoCancel() {} |
|
72 TInt RunError(TInt aError); |
|
73 |
|
74 protected: |
|
75 virtual void ConstructL(); |
|
76 inline CBaseTestHarness(RTest& aTest, TBool aMarkTestStarts) : CActive(0), iOldCurrentState(-1), iTest(aTest), iMarkTestStarts(aMarkTestStarts) {} |
|
77 |
|
78 // |
|
79 // Mark test start/end - default imp does nothing |
|
80 inline virtual void TestStart(TInt& /*aState*/) {} |
|
81 inline virtual void TestFinish(TInt& /*aState*/, TRequestStatus& /*aStatus*/) {} |
|
82 |
|
83 // |
|
84 // Called when an error occurs |
|
85 virtual void OnStateError(); |
|
86 |
|
87 // |
|
88 // Used to log error |
|
89 TInt LogStateError(); |
|
90 |
|
91 protected: |
|
92 TInt iCurrentState; |
|
93 TInt iOldCurrentState; |
|
94 TRequestStatus* iReportStatus; |
|
95 RTest& iTest; |
|
96 CArrayPtrFlat<MBaseTestState>* iStateList; |
|
97 TBool iTestHeapFailure; |
|
98 TInt iExpectedError; |
|
99 |
|
100 private: |
|
101 TInt iHeapFailureCount; |
|
102 TBool iMarkTestStarts; |
|
103 }; |
|
104 |
|
105 |
|
106 // |
|
107 // |
|
108 // CMainTestHarness |
|
109 // |
|
110 class CBioTestUtils; |
|
111 class CMainTestHarness : public CBaseTestHarness |
|
112 { |
|
113 public: |
|
114 ~CMainTestHarness(); |
|
115 static CMainTestHarness* NewL(RTest& aTest); |
|
116 inline CBioTestUtils& TestUtils() { return *iBioUtils; } |
|
117 |
|
118 protected: |
|
119 virtual void ConstructL(); |
|
120 inline CMainTestHarness(RTest& aTest) : CBaseTestHarness(aTest, ETrue) {} |
|
121 |
|
122 // |
|
123 // Test start/end marking |
|
124 virtual void TestStart(TInt& aState); |
|
125 virtual void TestFinish(TInt& aState, TRequestStatus& aStatus); |
|
126 |
|
127 protected: |
|
128 CBioTestUtils* iBioUtils; |
|
129 TBool iAllTestsSuccessful; |
|
130 }; |
|
131 |
|
132 // |
|
133 // |
|
134 // CClientTestHarness |
|
135 // |
|
136 class CClientTestHarness : public CBaseTestHarness |
|
137 { |
|
138 public: |
|
139 static CClientTestHarness* NewL(CBioTestUtils& aTestUtils, RTest& aTest); |
|
140 inline CBioTestUtils& TestUtils() { return iBioUtils; } |
|
141 virtual void LogCommentL(const TDesC& aComment); |
|
142 inline const TMsvId& CurrentBioMsg() { return iBioMessageData; } |
|
143 inline void SetCurrentBioMsg(const TMsvId& aBioMsg) { iBioMessageData = aBioMsg; } |
|
144 inline ~CClientTestHarness() {delete iPop3Settings;delete iSmtpSettings;delete iImapSettings;delete iSmsSettings;delete iSQL;} |
|
145 |
|
146 void UnInstantiatePop3SettingsL(); |
|
147 void UnInstantiateSmtpSettingsL(); |
|
148 void UnInstantiateImapSettingsL(); |
|
149 void InstantiateNamedPop3SettingsL(const TDesC& aName); |
|
150 void InstantiateNamedSmtpSettingsL(const TDesC& aName); |
|
151 void InstantiateNamedImapSettingsL(const TDesC& aName); |
|
152 void InstantiatePop3SettingsL(); |
|
153 void InstantiateSmtpSettingsL(); |
|
154 void InstantiateImapSettingsL(); |
|
155 void InstantiateSmsSettingsL(); |
|
156 void InstantiateClientMtmL(); |
|
157 void InstantiateServerMtmL(); |
|
158 |
|
159 // |
|
160 // Customized error handeling |
|
161 virtual void OnStateError(); |
|
162 |
|
163 protected: |
|
164 void ConstructL(); |
|
165 inline CClientTestHarness(CBioTestUtils& aTestUtils, RTest& aTest) : CBaseTestHarness(aTest, EFalse), iBioUtils(aTestUtils) {} |
|
166 private: |
|
167 TMsvId GetImapServiceL(CEmailAccounts& aAccounts); |
|
168 TMsvId GetPopServiceL(CEmailAccounts& aAccounts); |
|
169 |
|
170 protected: |
|
171 CBioTestUtils& iBioUtils; |
|
172 |
|
173 public: |
|
174 CImPop3Settings* iPop3Settings; |
|
175 CImSmtpSettings* iSmtpSettings; |
|
176 CImImap4Settings* iImapSettings; |
|
177 CSmsSettings* iSmsSettings; |
|
178 HBufC* iSQL; |
|
179 |
|
180 // |
|
181 // Stores the curent BIO message. All operations that |
|
182 // check bio messages etc will be checking this. |
|
183 TMsvId iBioMessageData; |
|
184 }; |
|
185 #endif |