|
1 /* |
|
2 * Copyright (c) 2005 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: The Feeds project test harness. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef TEST_HARNESS_H |
|
20 #define TEST_HARNESS_H |
|
21 |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <e32std.h> |
|
26 #include <f32file.h> |
|
27 |
|
28 #include <FeedsServerClient.h> |
|
29 #include <FeedsServerFeed.h> |
|
30 #include <FeedsServerFolderItem.h> |
|
31 #include <FeedsServerSettings.h> |
|
32 #include "FeedsWaitDialog.h" |
|
33 |
|
34 // CONSTANTS |
|
35 |
|
36 // MACROS |
|
37 |
|
38 // DATA TYPES |
|
39 enum TOperation |
|
40 { |
|
41 EParser, |
|
42 EFetchRootFolderItem, |
|
43 EWatchFolderList, |
|
44 EImportOPML, |
|
45 EUpdateAll, |
|
46 EAddFolderItem, |
|
47 EChangeFolderItem, |
|
48 EDeleteFolderItems, |
|
49 EMoveFolderItemsTo, |
|
50 EMoveFolderItems, |
|
51 EUpdateFolderItems, |
|
52 EFetchFeed, |
|
53 EUpdateFeedItemStatus, |
|
54 EPrintDBTables |
|
55 }; |
|
56 |
|
57 // FUNCTION PROTOTYPES |
|
58 |
|
59 // FORWARD DECLARATIONS |
|
60 class CInternetConnectionManager; |
|
61 class CFeedsWaitDialog; |
|
62 |
|
63 // CLASS DECLARATION |
|
64 |
|
65 |
|
66 /** |
|
67 * The TestHarness's observer. |
|
68 * |
|
69 * \b Library: FeedsEngine.lib |
|
70 * |
|
71 * @since 3.0 |
|
72 */ |
|
73 class MTestHarnessObserver |
|
74 { |
|
75 public: |
|
76 /** |
|
77 * Notifies the observer that the test harness is completed. |
|
78 * |
|
79 * @since 3.0 |
|
80 * @return void. |
|
81 */ |
|
82 virtual void Completed() = 0; |
|
83 }; |
|
84 |
|
85 |
|
86 /** |
|
87 * The Feeds project test harness. |
|
88 * |
|
89 * \b Library: FeedsEngine.lib |
|
90 * |
|
91 * @since 3.0 |
|
92 */ |
|
93 class CTestHarness: public CBase, |
|
94 public MFeedsServerObserver, |
|
95 public MFeedObserver, |
|
96 public MFolderItemObserver, |
|
97 public MFeedsWaitDialogListener |
|
98 { |
|
99 public: // Data types |
|
100 enum TTestSuite |
|
101 { |
|
102 ECanned, |
|
103 ECannedShort, |
|
104 ECannedStartAt, |
|
105 ECannedAtom, |
|
106 ELive |
|
107 }; |
|
108 |
|
109 |
|
110 public: // Constructors and destructor |
|
111 /** |
|
112 * Two-phased constructor. |
|
113 */ |
|
114 static CTestHarness* NewL(MTestHarnessObserver& aObserver); |
|
115 |
|
116 /** |
|
117 * Destructor. |
|
118 */ |
|
119 virtual ~CTestHarness(); |
|
120 |
|
121 |
|
122 public: // From MFeedsServerObserver |
|
123 /** |
|
124 * Reports the progress of the UpdateAllFeedsL request. |
|
125 * |
|
126 * @since 3.1 |
|
127 * @param aTotalCount The total count of feeds to be updated. |
|
128 * @param aRemaining The current number of feeds remaining to be updated. |
|
129 * @return void. |
|
130 */ |
|
131 virtual void UpdateAllProgress(TInt /*aTotalCount*/, TInt /*aRemaining*/) {}; |
|
132 |
|
133 /** |
|
134 * Notifies the observer that the feeds server settings have changed. |
|
135 * This is only called when the value was changed by a differnt client. |
|
136 * |
|
137 * @since 3.1 |
|
138 * @return void. |
|
139 */ |
|
140 virtual void SettingsChanged( TInt aStatus ); |
|
141 |
|
142 |
|
143 public: // From MFeedObserver |
|
144 /** |
|
145 * Called when the asynchronous request is complete. |
|
146 * |
|
147 * @since 3.1 |
|
148 * @param aStatusCode The completion status code. |
|
149 * @return void. |
|
150 */ |
|
151 virtual void FeedRequestCompleted(TInt aStatusCode); |
|
152 |
|
153 /** |
|
154 * Notifies the observer that the feed has changed. This method is called |
|
155 * when the feed is updated by the feeds server. |
|
156 * |
|
157 * @since 3.1 |
|
158 * @return void. |
|
159 */ |
|
160 virtual void FeedChanged() {}; |
|
161 |
|
162 /** |
|
163 * Notifies the observer that the feed's item status has changed. |
|
164 * This method is called when __another__ client updates the feed's |
|
165 * item status (via UpdateFeedItemStatusL). |
|
166 * |
|
167 * @since 3.1 |
|
168 * @return void. |
|
169 */ |
|
170 virtual void FeedItemStatusChanged() {}; |
|
171 |
|
172 |
|
173 public: // From MFolderItemObserver |
|
174 /** |
|
175 * Notifies the observer that the root FolderItem is ready or an error occurred. |
|
176 * |
|
177 * @since 3.1 |
|
178 * @param aStatus The result code of the FetchRootFolderItemL method. |
|
179 * @return void. |
|
180 */ |
|
181 void FolderItemRequestCompleted(TInt aStatus); |
|
182 |
|
183 /** |
|
184 * Notifies the observer that the FolderItem has changed. The client |
|
185 * should request an updated copy from the server. |
|
186 * |
|
187 * @since 3.1 |
|
188 * @return void. |
|
189 */ |
|
190 void FolderItemChanged() {}; |
|
191 |
|
192 |
|
193 public: // From MConnectionObserver |
|
194 /** |
|
195 * Request to create a network connection. |
|
196 * |
|
197 * @since 3.1 |
|
198 * @param aConnectionPtr A pointer to the new connection. If NULL, the |
|
199 * proxy filter will automatically create a network connection. |
|
200 * @param aSockSvrHandle A handle to the socket server. |
|
201 * @param aNewConn A flag if a new connection was created. If the |
|
202 * connection is not new, proxy filter optimization will not |
|
203 * read the proxy again from CommsBd. |
|
204 * @param aBearerType The bearer type of the new connection |
|
205 * @return void |
|
206 */ |
|
207 virtual void NetworkConnectionNeededL(TInt* /*aConnectionPtr*/, TInt& /*aSockSvrHandle*/, |
|
208 TBool& /*aNewConn*/, TApBearerType& /*aBearerType*/); |
|
209 |
|
210 |
|
211 public: // From MWaitDialogListener |
|
212 /** |
|
213 * Called when the user presses the cancel button. |
|
214 * |
|
215 * @since 3.0 |
|
216 * @return void. |
|
217 */ |
|
218 void DialogDismissedL(); |
|
219 |
|
220 |
|
221 public: // New Methods. |
|
222 /** |
|
223 * Starts the test harness |
|
224 * |
|
225 * @since 3.0 |
|
226 * @param aSuite The suite to run. |
|
227 * @param aStartAt The starting index. |
|
228 * @return void. |
|
229 */ |
|
230 void Start(TTestSuite aSuite, TInt aStartAt = 0); |
|
231 |
|
232 /** |
|
233 * @since 3.2 |
|
234 */ |
|
235 void FetchRootFolderItemL(); |
|
236 |
|
237 /** |
|
238 * @since 3.2 |
|
239 */ |
|
240 void WatchFolderListL(); |
|
241 |
|
242 /** |
|
243 * @since 3.2 |
|
244 */ |
|
245 void ImportOPMLL( const TDesC& aPath, TBool aClearFolderList = EFalse ); |
|
246 |
|
247 /** |
|
248 * @since 3.2 |
|
249 */ |
|
250 void UpdateAllL(); |
|
251 |
|
252 /** |
|
253 * @since 3.2 |
|
254 */ |
|
255 void AddFolderItemL( TInt aIsFolder ); |
|
256 |
|
257 /** |
|
258 * @since 3.2 |
|
259 */ |
|
260 void ChangeFolderItemL(); |
|
261 |
|
262 /** |
|
263 * @since 3.2 |
|
264 */ |
|
265 void DeleteFolderItemsL(); |
|
266 |
|
267 /** |
|
268 * @since 3.2 |
|
269 */ |
|
270 void DeleteAllFolderItemsL(); |
|
271 |
|
272 /** |
|
273 * @since 3.2 |
|
274 */ |
|
275 void MoveFolderItemsToL(); |
|
276 |
|
277 /** |
|
278 * @since 3.2 |
|
279 */ |
|
280 void MoveFolderItemsL(); |
|
281 |
|
282 /** |
|
283 * @since 3.2 |
|
284 */ |
|
285 void UpdateFolderItemsL(); |
|
286 |
|
287 /** |
|
288 * @since 3.2 |
|
289 */ |
|
290 void FetchFeedL(); |
|
291 |
|
292 /** |
|
293 * @since 3.2 |
|
294 */ |
|
295 void UpdateFeedItemStatusL(); |
|
296 |
|
297 /** |
|
298 * @since 3.2 |
|
299 */ |
|
300 void UpdateSettingsL( TBool aOn ); |
|
301 |
|
302 /** |
|
303 * Returns Feeds Server related settings synchronously. |
|
304 * |
|
305 * @since 3.2 |
|
306 */ |
|
307 void FetchServerSettingsSyncL(); |
|
308 |
|
309 /** |
|
310 * Returns Feeds Server related settings asynchronously. |
|
311 * |
|
312 * @since 3.2 |
|
313 */ |
|
314 void FetchServerSettingsL(); |
|
315 |
|
316 /** |
|
317 * @since 3.2 |
|
318 */ |
|
319 void DisconnectL(); |
|
320 |
|
321 /** |
|
322 * Debug print database tables. |
|
323 * @since 3.2 |
|
324 */ |
|
325 void DebugPrintTablesL(); |
|
326 |
|
327 |
|
328 private: |
|
329 /** |
|
330 * C++ default constructor. |
|
331 */ |
|
332 CTestHarness(MTestHarnessObserver& aObserver); |
|
333 |
|
334 /** |
|
335 * By default Symbian 2nd phase constructor is private. |
|
336 */ |
|
337 void ConstructL(); |
|
338 |
|
339 /** |
|
340 * Tests a single Feed. |
|
341 * |
|
342 * @since 3.0 |
|
343 * @param aPath The path to the feed file. |
|
344 * @return void. |
|
345 */ |
|
346 void TestFeedL(const TDesC& aPath); |
|
347 |
|
348 /** |
|
349 * Tests all feeds in the given folder, where the feeds must be named XX.xml where |
|
350 * XX are consecutive integers (ie 1.xml, 2.xml, etc.). |
|
351 * |
|
352 * @since 3.0 |
|
353 * @param aDirPath The path to the feeds folder. |
|
354 * @param aStartIndex The starting file-name index. |
|
355 * @param aStartIndex The ending file-name index. |
|
356 * @return void. |
|
357 */ |
|
358 void TestFeedsL(const TDesC& aDirPath, TInt aStartIndex, TInt aEndIndex); |
|
359 |
|
360 /** |
|
361 * Tests a single Feed given the current value of iFeedIndex. See TestFeedsL. |
|
362 * |
|
363 * @since 3.0 |
|
364 * @return void. |
|
365 */ |
|
366 void TestNextFeedInSeriesL(); |
|
367 |
|
368 #if 0 |
|
369 /** |
|
370 * Tests all feeds in the OPML file. |
|
371 * |
|
372 * @since 3.0 |
|
373 * @param aPath The url to the OPML file. |
|
374 * @return void. |
|
375 */ |
|
376 void TestFolderL(const TDesC& aPath); |
|
377 |
|
378 /** |
|
379 * Tests a single Feed given the current value of iFeedIndex. See TestFolderL. |
|
380 * |
|
381 * @since 3.0 |
|
382 * @return void. |
|
383 */ |
|
384 void TestNextFeedInFolderL(); |
|
385 #endif |
|
386 |
|
387 /** |
|
388 * Runs the next test. |
|
389 * |
|
390 * @since 3.0 |
|
391 * @param aPtr The this pointer. |
|
392 * @return Always returns EFalse. |
|
393 */ |
|
394 static TInt RunTest(TAny* aPtr); |
|
395 |
|
396 /** |
|
397 * @since 3.2 |
|
398 */ |
|
399 void ConnectToServerL(); |
|
400 |
|
401 /** |
|
402 * @since 3.2 |
|
403 */ |
|
404 void DisconnectFromServer(); |
|
405 |
|
406 /** |
|
407 * @since 3.2 |
|
408 */ |
|
409 void ShowServerError(TInt aStatus); |
|
410 |
|
411 /** |
|
412 * @since 3.2 |
|
413 */ |
|
414 void Debug_Print( const CFolderItem& aFolderItem ) const; |
|
415 |
|
416 /** |
|
417 * @since 3.2 |
|
418 */ |
|
419 TBool CheckRootFolderItem(); |
|
420 |
|
421 |
|
422 private: |
|
423 MTestHarnessObserver& iObserver; |
|
424 |
|
425 RFeedsServer iFeedsServer; |
|
426 RFolderItem iRootFolder; |
|
427 RFeed iFeed; |
|
428 TBool iIsConnected; |
|
429 |
|
430 CFeedsWaitDialog* iWaitDialog; |
|
431 |
|
432 TDesC* iCurrentFeedUrl; |
|
433 |
|
434 TBool iTestingFeedSeries; |
|
435 TBool iTestingFolder; |
|
436 |
|
437 TInt iFeedIndex; |
|
438 TInt iEndFileIndex; |
|
439 TDesC* iDirPath; |
|
440 |
|
441 RFs iFs; |
|
442 RFile iLogFile; |
|
443 RFile iStatusFile; |
|
444 |
|
445 CIdle* iIdle; |
|
446 |
|
447 CInternetConnectionManager* iConMgr; |
|
448 |
|
449 RPointerArray<const CFolderItem> iMovedItems; |
|
450 TInt iOperation; |
|
451 }; |
|
452 |
|
453 #endif // TEST_HARNESS_H |
|
454 |
|
455 // End of File |