1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 /* |
2 // All rights reserved. |
2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
3 // This component and the accompanying materials are made available |
3 * All rights reserved. |
4 // under the terms of "Eclipse Public License v1.0" |
4 * This component and the accompanying materials are made available |
5 // which accompanies this distribution, and is available |
5 * under the terms of "Eclipse Public License v1.0" |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 * which accompanies this distribution, and is available |
7 // |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 // Initial Contributors: |
8 * |
9 // Nokia Corporation - initial contribution. |
9 * Initial Contributors: |
10 // |
10 * Nokia Corporation - initial contribution. |
11 // Contributors: |
11 * |
12 // |
12 * Contributors: |
13 // Description: |
13 * |
14 // |
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
15 |
18 |
16 #ifndef __T_CURRENTDB_H__ |
19 #ifndef __T_CURRENTDB_H__ |
17 #define __T_CURRENTDB_H__ |
20 #define __T_CURRENTDB_H__ |
18 |
21 |
19 // System includes |
22 // System includes |
51 ETest8, |
54 ETest8, |
52 ETest9, |
55 ETest9, |
53 EEndTests |
56 EEndTests |
54 }; |
57 }; |
55 |
58 |
56 // |
59 //////////////////////////////////////////////////////////////////////////////////// |
57 public: // STATIC CONSTRUCT / DESTRUCT |
60 public: // STATIC CONSTRUCT / DESTRUCT |
58 // |
61 //////////////////////////////////////////////////////////////////////////////////// |
59 ~CTestBase(); |
62 ~CTestBase(); |
60 |
63 |
61 // |
64 //////////////////////////////////////////////////////////////////////////////////// |
62 public: // ACCESS |
65 public: // ACCESS |
63 // |
66 //////////////////////////////////////////////////////////////////////////////////// |
64 void Complete(TInt aReason); |
67 void Complete(TInt aReason); |
65 inline TInt CurrentTest() const { return iCurrentTest; } |
68 inline TInt CurrentTest() const { return iCurrentTest; } |
66 inline RThread& Thread() { return iThread; } |
69 inline RThread& Thread() { return iThread; } |
67 inline TBool Waiting() const { return iWaiting || iWaitingForAnyEvent; } |
70 inline TBool Waiting() const { return iWaiting || iWaitingForAnyEvent; } |
68 |
71 |
69 // |
72 //////////////////////////////////////////////////////////////////////////////////// |
70 protected: // INTERNAL CONSTRUCTION |
73 protected: // INTERNAL CONSTRUCTION |
71 // |
74 //////////////////////////////////////////////////////////////////////////////////// |
72 CTestBase(CTestManager& aTester, TInt aClientNumber, TThreadPriority aThreadPriority, TInt aPriority); |
75 CTestBase(CTestManager& aTester, TInt aClientNumber, TThreadPriority aThreadPriority, TInt aPriority); |
73 virtual void ConstructL(const TDesC& aName); |
76 virtual void ConstructL(const TDesC& aName); |
74 // |
77 // |
75 static TInt ThreadFunction(TAny *aParam); |
78 static TInt ThreadFunction(TAny *aParam); |
76 void RunTestsL(); |
79 void RunTestsL(); |
77 |
80 |
78 // |
81 //////////////////////////////////////////////////////////////////////////////////// |
79 protected: // TEST FRAMEWORK |
82 protected: // TEST FRAMEWORK |
80 // |
83 //////////////////////////////////////////////////////////////////////////////////// |
81 virtual void OpenDatabaseL() = 0; |
84 virtual void OpenDatabaseL() = 0; |
82 virtual TInt HandleThreadCreationL(); |
85 virtual TInt HandleThreadCreationL(); |
83 virtual void HandleThreadDeletionL(); |
86 virtual void HandleThreadDeletionL(); |
84 |
87 |
85 // |
88 //////////////////////////////////////////////////////////////////////////////////// |
86 protected: // FROM MContactDbObserver |
89 protected: // FROM MContactDbObserver |
87 // |
90 //////////////////////////////////////////////////////////////////////////////////// |
88 void HandleDatabaseEventL(TContactDbObserverEvent aEvent); |
91 void HandleDatabaseEventL(TContactDbObserverEvent aEvent); |
89 |
92 |
90 // |
93 //////////////////////////////////////////////////////////////////////////////////// |
91 private: // FROM CActive |
94 private: // FROM CActive |
92 // |
95 //////////////////////////////////////////////////////////////////////////////////// |
93 void RunL(); |
96 void RunL(); |
94 void DoCancel(); |
97 void DoCancel(); |
95 |
98 |
96 // |
99 //////////////////////////////////////////////////////////////////////////////////// |
97 protected: // TEST RELATED |
100 protected: // TEST RELATED |
98 // |
101 //////////////////////////////////////////////////////////////////////////////////// |
99 void ReadyForNextTest(); |
102 void ReadyForNextTest(); |
100 void WaitForContactsEvent(TContactDbObserverEventType aEvent, TInt aTimeInSecondsToWaitFor = 30); |
103 void WaitForContactsEvent(TContactDbObserverEventType aEvent, TInt aTimeInSecondsToWaitFor = 30); |
101 void WaitForAnyContactsEvent(TInt aTimeInSecondsToWaitFor = 30); |
104 void WaitForAnyContactsEvent(TInt aTimeInSecondsToWaitFor = 30); |
102 |
105 |
103 virtual void DoTestL(TInt aTestNumber) = 0; |
106 virtual void DoTestL(TInt aTestNumber) = 0; |
104 void OpenSemaphoreL(); |
107 void OpenSemaphoreL(); |
105 void CloseSemaphore(); |
108 void CloseSemaphore(); |
106 |
109 |
107 // |
110 //////////////////////////////////////////////////////////////////////////////////// |
108 protected: // MEMBER DATA |
111 protected: // MEMBER DATA |
109 // |
112 //////////////////////////////////////////////////////////////////////////////////// |
110 CTestManager& iTestCoordinator; |
113 CTestManager& iTestCoordinator; |
111 |
114 |
112 // Owned by this class after the thread has been created |
115 // Owned by this class after the thread has been created |
113 CCntTest* iContactsTest; |
116 CCntTest* iContactsTest; |
114 CConsoleBase* iConsole; |
117 CConsoleBase* iConsole; |
129 RSemaphore iSemaphoreOne; |
132 RSemaphore iSemaphoreOne; |
130 RSemaphore iSemaphoreTwo; |
133 RSemaphore iSemaphoreTwo; |
131 }; |
134 }; |
132 |
135 |
133 |
136 |
134 // |
137 //////////////////////////////////////////////////////////////////////////////////// |
135 // -------> CTestThreadOne (header) |
138 // -------> CTestThreadOne (header) |
136 // |
139 //////////////////////////////////////////////////////////////////////////////////// |
137 class CTestThreadOne : public CTestBase |
140 class CTestThreadOne : public CTestBase |
138 { |
141 { |
139 // |
142 //////////////////////////////////////////////////////////////////////////////////// |
140 public: // FROM CTestBase |
143 public: // FROM CTestBase |
141 // |
144 //////////////////////////////////////////////////////////////////////////////////// |
142 static CTestThreadOne* NewL(TInt aClientNumber, const TDesC& aName, CTestManager& aTester, TThreadPriority aThreadPriority = EPriorityNormal, TInt aPriority = EPriorityStandard); |
145 static CTestThreadOne* NewL(TInt aClientNumber, const TDesC& aName, CTestManager& aTester, TThreadPriority aThreadPriority = EPriorityNormal, TInt aPriority = EPriorityStandard); |
143 void DoTestL(TInt aTestNumber); |
146 void DoTestL(TInt aTestNumber); |
144 void OpenDatabaseL(); |
147 void OpenDatabaseL(); |
145 |
148 |
146 // |
149 //////////////////////////////////////////////////////////////////////////////////// |
147 private: // INTERNAL |
150 private: // INTERNAL |
148 // |
151 //////////////////////////////////////////////////////////////////////////////////// |
149 CTestThreadOne(CTestManager& aTester, TInt aClientNumber, TThreadPriority aThreadPriority, TInt aPriority); |
152 CTestThreadOne(CTestManager& aTester, TInt aClientNumber, TThreadPriority aThreadPriority, TInt aPriority); |
150 // |
153 // |
151 void DoTest1L(); |
154 void DoTest1L(); |
152 void DoTest2L(); |
155 void DoTest2L(); |
153 void DoTest3L(); |
156 void DoTest3L(); |
158 void DoTest8L(); |
161 void DoTest8L(); |
159 void DoTest9L(); |
162 void DoTest9L(); |
160 }; |
163 }; |
161 |
164 |
162 |
165 |
163 // |
166 //////////////////////////////////////////////////////////////////////////////////// |
164 // -------> CTestThreadTwo (header) |
167 // -------> CTestThreadTwo (header) |
165 // |
168 //////////////////////////////////////////////////////////////////////////////////// |
166 class CTestThreadTwo : public CTestBase |
169 class CTestThreadTwo : public CTestBase |
167 { |
170 { |
168 // |
171 //////////////////////////////////////////////////////////////////////////////////// |
169 public: // FROM CTestBase |
172 public: // FROM CTestBase |
170 // |
173 //////////////////////////////////////////////////////////////////////////////////// |
171 static CTestThreadTwo* NewL(TInt aClientNumber, const TDesC& aName, CTestManager& aTester, TThreadPriority aThreadPriority, TInt aPriority = EPriorityStandard); |
174 static CTestThreadTwo* NewL(TInt aClientNumber, const TDesC& aName, CTestManager& aTester, TThreadPriority aThreadPriority, TInt aPriority = EPriorityStandard); |
172 void DoTestL(TInt aTestNumber); |
175 void DoTestL(TInt aTestNumber); |
173 void OpenDatabaseL(); |
176 void OpenDatabaseL(); |
174 |
177 |
175 // |
178 //////////////////////////////////////////////////////////////////////////////////// |
176 private: // INTERNAL |
179 private: // INTERNAL |
177 // |
180 //////////////////////////////////////////////////////////////////////////////////// |
178 CTestThreadTwo(CTestManager& aTester, TInt aClientNumber, TThreadPriority aThreadPriority, TInt aPriority); |
181 CTestThreadTwo(CTestManager& aTester, TInt aClientNumber, TThreadPriority aThreadPriority, TInt aPriority); |
179 // |
182 // |
180 void DoTest1L(); |
183 void DoTest1L(); |
181 void DoTest2L(); |
184 void DoTest2L(); |
182 void DoTest3L(); |
185 void DoTest3L(); |
187 void DoTest8L(); |
190 void DoTest8L(); |
188 void DoTest9L(); |
191 void DoTest9L(); |
189 }; |
192 }; |
190 |
193 |
191 |
194 |
192 // |
195 //////////////////////////////////////////////////////////////////////////////////// |
193 // -------> CTestManager (header) |
196 // -------> CTestManager (header) |
194 // |
197 //////////////////////////////////////////////////////////////////////////////////// |
195 class CTestManager : public CTimer |
198 class CTestManager : public CTimer |
196 { |
199 { |
197 // |
200 //////////////////////////////////////////////////////////////////////////////////// |
198 public: // STATIC CONSTRUCT |
201 public: // STATIC CONSTRUCT |
199 // |
202 //////////////////////////////////////////////////////////////////////////////////// |
200 static CTestManager* NewLC(); |
203 static CTestManager* NewLC(); |
201 static CTestManager* NewL(); |
204 static CTestManager* NewL(); |
202 ~CTestManager(); |
205 ~CTestManager(); |
203 |
206 |
204 // |
207 //////////////////////////////////////////////////////////////////////////////////// |
205 private: // INTERNAL CONSTRUCT |
208 private: // INTERNAL CONSTRUCT |
206 // |
209 //////////////////////////////////////////////////////////////////////////////////// |
207 CTestManager(TInt aPriority = EPriorityStandard); |
210 CTestManager(TInt aPriority = EPriorityStandard); |
208 void ConstructL(); |
211 void ConstructL(); |
209 |
212 |
210 // |
213 //////////////////////////////////////////////////////////////////////////////////// |
211 private: // FROM CActive |
214 private: // FROM CActive |
212 // |
215 //////////////////////////////////////////////////////////////////////////////////// |
213 void RunL(); |
216 void RunL(); |
214 |
217 |
215 // |
218 //////////////////////////////////////////////////////////////////////////////////// |
216 private: // NEW FUNCTIONS |
219 private: // NEW FUNCTIONS |
217 // |
220 //////////////////////////////////////////////////////////////////////////////////// |
218 void IssueTimerRequest(); |
221 void IssueTimerRequest(); |
219 |
222 |
220 // |
223 //////////////////////////////////////////////////////////////////////////////////// |
221 private: // MEMBER DATA |
224 private: // MEMBER DATA |
222 // |
225 //////////////////////////////////////////////////////////////////////////////////// |
223 TInt iTestNumber; |
226 TInt iTestNumber; |
224 // |
227 // |
225 CTestThreadOne* iClient1; |
228 CTestThreadOne* iClient1; |
226 CTestThreadTwo* iClient2; |
229 CTestThreadTwo* iClient2; |
227 }; |
230 }; |