|
1 /* |
|
2 * Copyright (c) 2002 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 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <e32math.h> |
|
23 #include "FavouritesEngineTest.h" |
|
24 #include "FavouritesDbTestObserver.h" |
|
25 |
|
26 // EXTERNAL DATA STRUCTURES |
|
27 // None |
|
28 |
|
29 // EXTERNAL FUNCTION PROTOTYPES |
|
30 // None |
|
31 |
|
32 // CONSTANTS |
|
33 // None |
|
34 |
|
35 // MACROS |
|
36 // None |
|
37 |
|
38 // LOCAL CONSTANTS AND MACROS |
|
39 // None |
|
40 |
|
41 // MODULE DATA STRUCTURES |
|
42 // None |
|
43 |
|
44 // LOCAL FUNCTION PROTOTYPES |
|
45 // None |
|
46 |
|
47 // FORWARD DECLARATIONS |
|
48 // None |
|
49 |
|
50 // ==================== LOCAL FUNCTIONS ======================================= |
|
51 |
|
52 |
|
53 // ============================ MEMBER FUNCTIONS =============================== |
|
54 |
|
55 /* |
|
56 ------------------------------------------------------------------------------- |
|
57 |
|
58 Class: CFavouritesEngineTest |
|
59 |
|
60 Method: NotifierConstructorTestL |
|
61 |
|
62 Description: Test the CActiveFavouritesDbNotifier constructor method. |
|
63 |
|
64 Parameters: TTestResult& aErrorDescription: out: |
|
65 Test result and on error case a short description of error |
|
66 |
|
67 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
68 |
|
69 Errors/Exceptions: None |
|
70 |
|
71 Status: Approved |
|
72 |
|
73 ------------------------------------------------------------------------------- |
|
74 */ |
|
75 TInt CFavouritesEngineTest::NotifierConstructorTestL( TTestResult& aResult ) |
|
76 { |
|
77 /* Simple server connect */ |
|
78 _LIT( KDefinition ,"State" ); |
|
79 _LIT( KData ,"Test the CActiveFavouritesDbNotifier constructor method" ); |
|
80 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
81 |
|
82 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
83 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
84 |
|
85 CreatePopulatedDbL(); |
|
86 |
|
87 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
88 CleanupStack::PushL( scheduler ); |
|
89 CActiveScheduler::Install( scheduler ); |
|
90 |
|
91 CFavouritesDbTestObserver* observer = new (ELeave) CFavouritesDbTestObserver( *this ); |
|
92 CleanupStack::PushL( observer ); |
|
93 |
|
94 observer->Start(); |
|
95 CActiveScheduler::Start(); |
|
96 |
|
97 CActiveFavouritesDbNotifier* notifier = new (ELeave) CActiveFavouritesDbNotifier( iFavouritesDb, (MFavouritesDbObserver &)*this ); |
|
98 CleanupStack::PushL( notifier ); |
|
99 |
|
100 _LIT( KData2 ,"Finished" ); |
|
101 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
102 |
|
103 if( notifier ) |
|
104 { |
|
105 _LIT( KDescription , "Test case passed" ); |
|
106 aResult.SetResult( KErrNone, KDescription ); |
|
107 } |
|
108 else |
|
109 { |
|
110 _LIT( KDescription , "Test case failed" ); |
|
111 aResult.SetResult( KErrGeneral, KDescription ); |
|
112 } |
|
113 |
|
114 CleanupStack::PopAndDestroy(4); // iFavouritesDb, observer, notifier |
|
115 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
116 |
|
117 // Case was executed |
|
118 return KErrNone; |
|
119 } |
|
120 |
|
121 /* |
|
122 ------------------------------------------------------------------------------- |
|
123 |
|
124 Class: CFavouritesEngineTest |
|
125 |
|
126 Method: NotifierDestructorTestL |
|
127 |
|
128 Description: Test the CActiveFavouritesDbNotifier destructor method. |
|
129 |
|
130 Parameters: TTestResult& aErrorDescription: out: |
|
131 Test result and on error case a short description of error |
|
132 |
|
133 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
134 |
|
135 Errors/Exceptions: None |
|
136 |
|
137 Status: Approved |
|
138 |
|
139 ------------------------------------------------------------------------------- |
|
140 */ |
|
141 TInt CFavouritesEngineTest::NotifierDestructorTestL( TTestResult& aResult ) |
|
142 { |
|
143 /* Simple server connect */ |
|
144 _LIT( KDefinition ,"State" ); |
|
145 _LIT( KData ,"Test the CActiveFavouritesDbNotifier destructor method" ); |
|
146 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
147 |
|
148 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
149 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
150 |
|
151 CreatePopulatedDbL(); |
|
152 |
|
153 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
154 CleanupStack::PushL( scheduler ); |
|
155 CActiveScheduler::Install( scheduler ); |
|
156 |
|
157 CFavouritesDbTestObserver* observer = new (ELeave) CFavouritesDbTestObserver( *this ); |
|
158 CleanupStack::PushL( observer ); |
|
159 |
|
160 observer->Start(); |
|
161 CActiveScheduler::Start(); |
|
162 |
|
163 CActiveFavouritesDbNotifier* notifier = new (ELeave) CActiveFavouritesDbNotifier( iFavouritesDb, (MFavouritesDbObserver &)*this ); |
|
164 CleanupStack::PushL( notifier ); |
|
165 |
|
166 notifier->~CActiveFavouritesDbNotifier(); |
|
167 |
|
168 _LIT( KData2 ,"Finished" ); |
|
169 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
170 |
|
171 if( notifier ) |
|
172 { |
|
173 _LIT( KDescription , "Test case passed" ); |
|
174 aResult.SetResult( KErrNone, KDescription ); |
|
175 } |
|
176 else |
|
177 { |
|
178 _LIT( KDescription , "Test case failed" ); |
|
179 aResult.SetResult( KErrGeneral, KDescription ); |
|
180 } |
|
181 |
|
182 CleanupStack::PopAndDestroy(4); // iFavouritesDb, observer, notifier |
|
183 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
184 |
|
185 // Case was executed |
|
186 return KErrNone; |
|
187 } |
|
188 |
|
189 /* |
|
190 ------------------------------------------------------------------------------- |
|
191 |
|
192 Class: CFavouritesEngineTest |
|
193 |
|
194 Method: NotifierStartTestL |
|
195 |
|
196 Description: Test the CActiveFavouritesDbNotifier Start method. |
|
197 |
|
198 Parameters: TTestResult& aErrorDescription: out: |
|
199 Test result and on error case a short description of error |
|
200 |
|
201 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
202 |
|
203 Errors/Exceptions: None |
|
204 |
|
205 Status: Approved |
|
206 |
|
207 ------------------------------------------------------------------------------- |
|
208 */ |
|
209 TInt CFavouritesEngineTest::NotifierStartTestL( TTestResult& aResult ) |
|
210 { |
|
211 /* Simple server connect */ |
|
212 _LIT( KDefinition ,"State" ); |
|
213 _LIT( KData ,"Test the CActiveFavouritesDbNotifier Start method" ); |
|
214 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
215 |
|
216 iFavouritesDb.Open( iFavouritesSession, KTestDbName ); |
|
217 CleanupClosePushL<RFavouritesDb>( iFavouritesDb ); |
|
218 |
|
219 CreatePopulatedDbL(); |
|
220 |
|
221 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
222 CleanupStack::PushL( scheduler ); |
|
223 CActiveScheduler::Install( scheduler ); |
|
224 |
|
225 CFavouritesDbTestObserver* observer = new (ELeave) CFavouritesDbTestObserver( *this ); |
|
226 CleanupStack::PushL( observer ); |
|
227 |
|
228 observer->Start(); |
|
229 CActiveScheduler::Start(); |
|
230 |
|
231 CActiveFavouritesDbNotifier* notifier = new (ELeave) CActiveFavouritesDbNotifier( iFavouritesDb, (MFavouritesDbObserver &)*this ); |
|
232 CleanupStack::PushL( notifier ); |
|
233 |
|
234 TInt result = notifier->Start(); |
|
235 |
|
236 _LIT( KData2 ,"Finished" ); |
|
237 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
238 |
|
239 if( result == KErrNone ) |
|
240 { |
|
241 _LIT( KDescription , "Test case passed" ); |
|
242 aResult.SetResult( KErrNone, KDescription ); |
|
243 } |
|
244 else |
|
245 { |
|
246 _LIT( KDescription , "Test case failed" ); |
|
247 aResult.SetResult( KErrGeneral, KDescription ); |
|
248 } |
|
249 |
|
250 CleanupStack::PopAndDestroy(4); // iFavouritesDb, observer, notifier |
|
251 iFavouritesSession.DeleteDatabase( KTestDbName ); |
|
252 |
|
253 // Case was executed |
|
254 return KErrNone; |
|
255 } |
|
256 |
|
257 // ================= OTHER EXPORTED FUNCTIONS ================================= |
|
258 |
|
259 // End of File |