|
1 // Copyright (c) 2002-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 __T_CASESENSITIVEDB_H__ |
|
17 #define __T_CASESENSITIVEDB_H__ |
|
18 |
|
19 // System includes |
|
20 #include <cntdb.h> |
|
21 |
|
22 // Classes referenced |
|
23 class RTest; |
|
24 |
|
25 class CTestBase : public CActive, public MContactDbObserver |
|
26 { |
|
27 public: // ENUMERATIONS SHARED BETWEEN DRIVER & TEST |
|
28 enum |
|
29 { |
|
30 EStartTests = 0, |
|
31 ETest1 = EStartTests, |
|
32 EEndTests |
|
33 }; |
|
34 |
|
35 public: // STATIC CONSTRUCT / DESTRUCT |
|
36 ~CTestBase(); |
|
37 |
|
38 public: // ACCESS |
|
39 void Complete(TInt aReason); |
|
40 inline TBool TestFinished() const { return iTestFinished; } |
|
41 inline RThread& Thread() { return iThread; } |
|
42 inline TBool Waiting() const { return iWaiting; } |
|
43 |
|
44 protected: // INTERNAL CONSTRUCTION |
|
45 CTestBase(TInt aClientNumber, TThreadPriority aThreadPriority, TInt aPriority); |
|
46 virtual void ConstructL(const TDesC& aName); |
|
47 // |
|
48 static TInt ThreadFunction(TAny *aParam); |
|
49 void RunTestsL(); |
|
50 |
|
51 protected: // TEST FRAMEWORK |
|
52 virtual void OpenDatabaseL() = 0; |
|
53 |
|
54 protected: // FROM MContactDbObserver |
|
55 void HandleDatabaseEventL(TContactDbObserverEvent aEvent); |
|
56 |
|
57 private: // FROM CActive |
|
58 void RunL(); |
|
59 void DoCancel(); |
|
60 |
|
61 protected: // TEST RELATED |
|
62 void SetRequestStatus(); |
|
63 void WaitForContactsEvent(TContactDbObserverEventType aEvent, TInt aTimeInSecondsToWaitFor = 5); |
|
64 |
|
65 virtual void DoTestL() = 0; |
|
66 |
|
67 protected: // MEMBER DATA |
|
68 // Owned by this class after the thread has been created |
|
69 CContactDatabase *iDb; |
|
70 RTest *iTest; |
|
71 |
|
72 TInt iClientNumber; |
|
73 RThread iThread; |
|
74 TThreadPriority iThreadPriority; |
|
75 |
|
76 TBool iWaiting; |
|
77 TBool iTestFinished; |
|
78 TContactDbObserverEventType iEvent; |
|
79 RTimer iWaitTimer; |
|
80 }; |
|
81 |
|
82 class CTestThreadOne : public CTestBase |
|
83 { |
|
84 public: // FROM CTestBase |
|
85 static CTestThreadOne* NewL(TInt aClientNumber, const TDesC& aName, TThreadPriority aThreadPriority = EPriorityNormal, TInt aPriority = EPriorityStandard); |
|
86 void DoTestL(); |
|
87 void OpenDatabaseL(); |
|
88 |
|
89 private: // INTERNAL |
|
90 CTestThreadOne(TInt aClientNumber, TThreadPriority aThreadPriority, TInt aPriority); |
|
91 }; |
|
92 |
|
93 class CTestThreadTwo : public CTestBase |
|
94 { |
|
95 public: // FROM CTestBase |
|
96 static CTestThreadTwo* NewL(TInt aClientNumber, const TDesC& aName, TThreadPriority aThreadPriority, TInt aPriority = EPriorityStandard); |
|
97 void DoTestL(); |
|
98 void OpenDatabaseL(); |
|
99 |
|
100 private: // INTERNAL |
|
101 CTestThreadTwo(TInt aClientNumber, TThreadPriority aThreadPriority, TInt aPriority); |
|
102 }; |
|
103 |
|
104 class CTestManager : public CTimer |
|
105 { |
|
106 public: // STATIC CONSTRUCT |
|
107 static CTestManager* NewLC(); |
|
108 static CTestManager* NewL(); |
|
109 ~CTestManager(); |
|
110 |
|
111 private: // INTERNAL CONSTRUCT |
|
112 CTestManager(TInt aPriority = EPriorityStandard); |
|
113 void ConstructL(); |
|
114 |
|
115 private: // FROM CActive |
|
116 void RunL(); |
|
117 |
|
118 private: // NEW FUNCTIONS |
|
119 void IssueTimerRequest(); |
|
120 |
|
121 private: // MEMBER DATA |
|
122 //TInt iTestNumber; |
|
123 // |
|
124 CTestThreadOne* iClient1; |
|
125 CTestThreadTwo* iClient2; |
|
126 }; |
|
127 |
|
128 #endif |