|
1 // Copyright (c) 2004-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_SCHEDULESEND_H__ |
|
17 #define __T_SCHEDULESEND_H__ |
|
18 |
|
19 #include <e32base.h> |
|
20 #include "msvtestutils.h" |
|
21 |
|
22 |
|
23 class RTest; |
|
24 |
|
25 class CScheduleSendTestUtils : public CMsvTestUtils |
|
26 { |
|
27 public: |
|
28 |
|
29 static CScheduleSendTestUtils* NewL(RTest& aTest, TUint aCreationFlags = ETuMinimalClientSide); |
|
30 virtual ~CScheduleSendTestUtils(); |
|
31 |
|
32 void DeletePigeonMessagesL(TMsvId aFolder); |
|
33 TMsvId ServiceId(); |
|
34 |
|
35 void NotifySaPhoneOnL(); |
|
36 void NotifySaPhoneOffL(); |
|
37 |
|
38 void NotifySaSimOkL(); |
|
39 void NotifySaSimNotPresentL(); |
|
40 |
|
41 void NotifySaNetworkAvailableL(); |
|
42 void NotifySaNetworkUnAvailableL(); |
|
43 |
|
44 void UpdateSysAgentConditionsL(); |
|
45 void UpdatePendingConditionsTimeoutL(TTimeIntervalMinutes aTimeout); |
|
46 |
|
47 public: // methods from CMsvTestUtils |
|
48 |
|
49 virtual void InstantiateClientMtmsL(){}; |
|
50 virtual void InstantiateServerMtmsL(){}; |
|
51 virtual void DeleteServicesL(); |
|
52 virtual void CreateServicesL(); |
|
53 virtual void FindExistingServicesL(){}; |
|
54 virtual void InstallMtmGroupsL(); |
|
55 virtual void CreateServerMtmRegsL(); |
|
56 |
|
57 public: // methods from CTestUtils |
|
58 |
|
59 virtual void Panic(TInt aPanic); |
|
60 |
|
61 private: |
|
62 |
|
63 CScheduleSendTestUtils(RTest& aTest); |
|
64 void ConstructL(TUint aCreationFlags); |
|
65 |
|
66 void InstallPigeonMtmGroupL(); |
|
67 void CreatePigeonServerMtmRegL(); |
|
68 |
|
69 private: |
|
70 |
|
71 TMsvId iServiceId; |
|
72 }; |
|
73 |
|
74 class CTestEngine : public CBase |
|
75 { |
|
76 public: |
|
77 |
|
78 static CTestEngine* NewL(RTest& aTest); |
|
79 virtual ~CTestEngine(); |
|
80 |
|
81 void DoTestsL(); |
|
82 |
|
83 private: |
|
84 |
|
85 CTestEngine(); |
|
86 void ConstructL(RTest& aTest); |
|
87 |
|
88 private: |
|
89 |
|
90 CScheduleSendTestUtils* iTestUtils; |
|
91 |
|
92 }; |
|
93 |
|
94 class MTestFolderObserverCallback |
|
95 { |
|
96 public: |
|
97 virtual void UpdatedMessageL(TMsvId aFolderId, TMsvId aMessage) =0; |
|
98 virtual CMsvEntry* CreateEntryL(TMsvId aFolderId) =0; |
|
99 }; |
|
100 |
|
101 class CTestFolderObserver : public CBase, |
|
102 public MMsvEntryObserver |
|
103 { |
|
104 public: |
|
105 |
|
106 static CTestFolderObserver* NewL(MTestFolderObserverCallback& aCallback, TMsvId aFolderId); |
|
107 virtual ~CTestFolderObserver(); |
|
108 |
|
109 void StartObserverL(); |
|
110 void StopObserver(); |
|
111 |
|
112 private: // methods from MMsvEntryObserver |
|
113 |
|
114 virtual void HandleEntryEventL(TMsvEntryEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3); |
|
115 |
|
116 private: |
|
117 |
|
118 CTestFolderObserver(MTestFolderObserverCallback& aCallback, TMsvId aFolderId); |
|
119 void ConstructL(); |
|
120 |
|
121 private: |
|
122 |
|
123 MTestFolderObserverCallback& iCallback; |
|
124 TMsvId iFolderId; |
|
125 CMsvEntry* iEntryForObserver; |
|
126 }; |
|
127 |
|
128 |
|
129 /** |
|
130 Base class for test cases. |
|
131 |
|
132 Runs through state machine. Testing is done on sending state, schedule flag and |
|
133 the pending conditions flag. |
|
134 |
|
135 NOTE - the pending conditions should be checked only if the message has been |
|
136 scheduled for pending conditions. In this test harness, this indicated by the |
|
137 error value of the messsage being KErrorActionConditions. |
|
138 |
|
139 The values are checked after the messages are created - message created done by |
|
140 derived test cases. Then after the scheduling - again derived classed do the |
|
141 scheduling. The values are then checked after SchSendExe actually runs the schedule |
|
142 and then after the pigeon MTM does the send. |
|
143 |
|
144 NOTE - after the post-scheduling check, the test may may stop - the derived class |
|
145 controls this. |
|
146 |
|
147 Sending state and schedule flag values and whether to check the pending conditions |
|
148 flag or not - |
|
149 |
|
150 Post creation - KMsvSendStateWaiting, false, false |
|
151 |
|
152 Post scheduling - test-case dependent, true, false |
|
153 |
|
154 Pre-sending - KMsvSendStateWaiting, true, false |
|
155 |
|
156 Post-sending - KMsvSendStateSent, true, false |
|
157 |
|
158 Also, during the post-sending check, the schedule time is compared against the |
|
159 current time. In most cases, the current time should be the same or later than |
|
160 the schedule time. In the cases where the message was scheduled for pending |
|
161 conditions and the conditions were met, then the current time should be before |
|
162 the scheduled time. Although for messages scheduled for pending conditions but |
|
163 the conditions have not been met, then the current time should be the same or |
|
164 later than the schedule time. |
|
165 */ |
|
166 class CTestScheduleSendBase : public CActive, |
|
167 public MTestFolderObserverCallback |
|
168 { |
|
169 public: |
|
170 |
|
171 virtual ~CTestScheduleSendBase(); |
|
172 void Start(); |
|
173 |
|
174 private: // methods from CActive |
|
175 |
|
176 virtual void RunL(); |
|
177 virtual void DoCancel(); |
|
178 virtual TInt RunError(TInt aError); |
|
179 |
|
180 private: // methods from MTestFolderObserverCallback |
|
181 |
|
182 virtual void UpdatedMessageL(TMsvId aFolderId, TMsvId aMessage); |
|
183 virtual CMsvEntry* CreateEntryL(TMsvId aFolderId); |
|
184 |
|
185 protected: |
|
186 |
|
187 CTestScheduleSendBase(CScheduleSendTestUtils& aTestUtils); |
|
188 void ConstructL(); |
|
189 |
|
190 void CompleteSelf(); |
|
191 void ClearFoldersL(); |
|
192 void TestComplete(); |
|
193 TMsvId CreateMessageL(TTime& aTime, TInt aError); |
|
194 void TransferCommandL(TInt aCommand); |
|
195 void CheckMessageDetailsL(TMsvId aId, TInt aState, TBool aScheduled, TBool aPendingConditions); |
|
196 |
|
197 CMsvSession& Session(); |
|
198 CMsvEntry& MsvEntry(); |
|
199 |
|
200 protected: |
|
201 |
|
202 CScheduleSendTestUtils& iTestUtils; |
|
203 CMsvEntrySelection* iSelection; |
|
204 CMsvEntrySelection* iPendingSent; |
|
205 CMsvOperation* iOperation; |
|
206 TInt iMessagesDone; |
|
207 TBool iConditionsMet; |
|
208 |
|
209 private: |
|
210 |
|
211 const TDesC& GetStateText(TInt aState) const; |
|
212 const TDesC& GetBoolText(TBool aBool) const; |
|
213 |
|
214 TBool ConditionsMet() const; |
|
215 |
|
216 virtual void UpdateSysAgentConditionsL(); |
|
217 virtual void CheckCreatedMessagesL(); |
|
218 virtual void CheckScheduledMessagesL(); |
|
219 virtual TBool NotifyMessagesScheduledL(); |
|
220 |
|
221 virtual void CheckPreSendMessageL(TMsvId aId); |
|
222 virtual void CheckSentMessageL(TMsvId aId); |
|
223 |
|
224 virtual TInt PreSendState(); |
|
225 virtual TInt SentState(); |
|
226 |
|
227 virtual void CreateMessagesL() =0; |
|
228 virtual void ScheduleMessagesL() =0; |
|
229 virtual TInt ScheduledState() =0; |
|
230 virtual const TDesC& TestName() =0; |
|
231 |
|
232 private: |
|
233 |
|
234 enum TScheduleSendTestState |
|
235 { |
|
236 EClearFolders, |
|
237 EUpdateSysAgentConditions, |
|
238 ECreateMessages, |
|
239 ECheckCreatedMessages, |
|
240 EScheduleMessages, |
|
241 ECheckScheduledMessages, |
|
242 EPendingMessagesSent, |
|
243 EDone |
|
244 }; |
|
245 |
|
246 private: |
|
247 |
|
248 CTestFolderObserver* iOutboxObserver; |
|
249 CTestFolderObserver* iSentFolderObserver; |
|
250 TScheduleSendTestState iState; |
|
251 |
|
252 }; |
|
253 |
|
254 /** |
|
255 Tests the CMsvScheduleSend::ScheduleL API. |
|
256 |
|
257 Creates 2 pigeon messages that are both schedule for immediate sending. |
|
258 |
|
259 Post scheduling sending state values - KMsvSendStateScheduled. |
|
260 */ |
|
261 class CTestSchedule : public CTestScheduleSendBase |
|
262 { |
|
263 public: |
|
264 |
|
265 static CTestSchedule* NewL(CScheduleSendTestUtils& aTestUtils); |
|
266 virtual ~CTestSchedule(); |
|
267 |
|
268 private: // methods from CTestScheduleSendBase |
|
269 |
|
270 virtual void CreateMessagesL(); |
|
271 virtual void ScheduleMessagesL(); |
|
272 virtual TInt ScheduledState(); |
|
273 virtual const TDesC& TestName(); |
|
274 |
|
275 private: |
|
276 |
|
277 CTestSchedule(CScheduleSendTestUtils& aTestUtils); |
|
278 |
|
279 }; |
|
280 |
|
281 /** |
|
282 Tests the CMsvScheduleSend::ReScheduleL API. |
|
283 |
|
284 Creates 2 pigeon messages that are both re-schedule for immediate sending. |
|
285 |
|
286 Post scheduling sending state values - KMsvSendStateResend. |
|
287 */ |
|
288 class CTestReScheduleTime_1 : public CTestScheduleSendBase |
|
289 { |
|
290 public: |
|
291 |
|
292 static CTestReScheduleTime_1* NewL(CScheduleSendTestUtils& aTestUtils); |
|
293 virtual ~CTestReScheduleTime_1(); |
|
294 |
|
295 private: // methods from CTestScheduleSendBase |
|
296 |
|
297 virtual void CreateMessagesL(); |
|
298 virtual void ScheduleMessagesL(); |
|
299 virtual TInt ScheduledState(); |
|
300 virtual const TDesC& TestName(); |
|
301 |
|
302 private: |
|
303 |
|
304 CTestReScheduleTime_1(CScheduleSendTestUtils& aTestUtils); |
|
305 |
|
306 }; |
|
307 |
|
308 /** |
|
309 Tests the CMsvScheduleSend::ReScheduleL API. |
|
310 |
|
311 Creates 2 pigeon messages - one is scheduled for immeduate sending and the other |
|
312 is scheduled for later sending. |
|
313 |
|
314 Post scheduling sending state values - KMsvSendStateResend. |
|
315 */ |
|
316 class CTestReScheduleTime_2 : public CTestScheduleSendBase |
|
317 { |
|
318 public: |
|
319 |
|
320 static CTestReScheduleTime_2* NewL(CScheduleSendTestUtils& aTestUtils); |
|
321 virtual ~CTestReScheduleTime_2(); |
|
322 |
|
323 private: // methods from CTestScheduleSendBase |
|
324 |
|
325 virtual void CreateMessagesL(); |
|
326 virtual void ScheduleMessagesL(); |
|
327 virtual TInt ScheduledState(); |
|
328 virtual const TDesC& TestName(); |
|
329 |
|
330 private: |
|
331 |
|
332 CTestReScheduleTime_2(CScheduleSendTestUtils& aTestUtils); |
|
333 |
|
334 }; |
|
335 |
|
336 /** |
|
337 Tests the CMsvScheduleSend::ReScheduleL API. |
|
338 |
|
339 Creates 2 pigeon messages that are both re-schedule for pending conditions. No |
|
340 timeout value is specified. The conditions are met. |
|
341 |
|
342 Post scheduling sending state values - KMsvSendStateResend. |
|
343 */ |
|
344 class CTestRescheduleConditions_1 : public CTestScheduleSendBase |
|
345 { |
|
346 public: |
|
347 |
|
348 static CTestRescheduleConditions_1* NewL(CScheduleSendTestUtils& aTestUtils); |
|
349 virtual ~CTestRescheduleConditions_1(); |
|
350 |
|
351 private: // methods from CTestScheduleSendBase |
|
352 |
|
353 virtual void UpdateSysAgentConditionsL(); |
|
354 virtual TBool NotifyMessagesScheduledL(); |
|
355 virtual void CreateMessagesL(); |
|
356 virtual void ScheduleMessagesL(); |
|
357 virtual TInt ScheduledState(); |
|
358 virtual const TDesC& TestName(); |
|
359 |
|
360 private: |
|
361 |
|
362 CTestRescheduleConditions_1(CScheduleSendTestUtils& aTestUtils); |
|
363 |
|
364 }; |
|
365 |
|
366 /** |
|
367 Tests the CMsvScheduleSend::ReScheduleL API. |
|
368 |
|
369 Creates 2 pigeon messages that are both re-schedule for pending conditions. A |
|
370 short timeout value is specified. The conditions are met. |
|
371 |
|
372 Post scheduling sending state values - KMsvSendStateResend. |
|
373 */ |
|
374 class CTestRescheduleConditions_2 : public CTestScheduleSendBase |
|
375 { |
|
376 public: |
|
377 |
|
378 static CTestRescheduleConditions_2* NewL(CScheduleSendTestUtils& aTestUtils); |
|
379 virtual ~CTestRescheduleConditions_2(); |
|
380 |
|
381 private: // methods from CTestScheduleSendBase |
|
382 |
|
383 virtual void UpdateSysAgentConditionsL(); |
|
384 virtual TBool NotifyMessagesScheduledL(); |
|
385 virtual void CreateMessagesL(); |
|
386 virtual void ScheduleMessagesL(); |
|
387 virtual TInt ScheduledState(); |
|
388 virtual const TDesC& TestName(); |
|
389 |
|
390 private: |
|
391 |
|
392 CTestRescheduleConditions_2(CScheduleSendTestUtils& aTestUtils); |
|
393 |
|
394 }; |
|
395 |
|
396 /** |
|
397 Tests the CMsvScheduleSend::ReScheduleL API. |
|
398 |
|
399 Creates 2 pigeon messages that are both re-schedule for pending conditions. A |
|
400 short timeout value is specified. Only one conditions is met - therefore timeout |
|
401 should occur. |
|
402 |
|
403 Post scheduling sending state values - KMsvSendStateResend. |
|
404 */ |
|
405 class CTestRescheduleConditions_3 : public CTestScheduleSendBase |
|
406 { |
|
407 public: |
|
408 |
|
409 static CTestRescheduleConditions_3* NewL(CScheduleSendTestUtils& aTestUtils); |
|
410 virtual ~CTestRescheduleConditions_3(); |
|
411 |
|
412 private: // methods from CTestScheduleSendBase |
|
413 |
|
414 virtual void UpdateSysAgentConditionsL(); |
|
415 virtual TBool NotifyMessagesScheduledL(); |
|
416 virtual void CreateMessagesL(); |
|
417 virtual void ScheduleMessagesL(); |
|
418 virtual TInt ScheduledState(); |
|
419 virtual const TDesC& TestName(); |
|
420 |
|
421 private: |
|
422 |
|
423 CTestRescheduleConditions_3(CScheduleSendTestUtils& aTestUtils); |
|
424 |
|
425 }; |
|
426 |
|
427 /** |
|
428 Tests the CMsvScheduleSend::ReScheduleL API. |
|
429 |
|
430 Creates 2 pigeon messages - one is scheduled for immeduate sending and the other |
|
431 is scheduled for pending conditions. A short timeout value is specified. The |
|
432 conditions are met. |
|
433 |
|
434 Post scheduling sending state values - KMsvSendStateResend. |
|
435 */ |
|
436 class CTestRescheduleMixed_1 : public CTestScheduleSendBase |
|
437 { |
|
438 public: |
|
439 |
|
440 static CTestRescheduleMixed_1* NewL(CScheduleSendTestUtils& aTestUtils); |
|
441 virtual ~CTestRescheduleMixed_1(); |
|
442 |
|
443 private: // methods from CTestScheduleSendBase |
|
444 |
|
445 virtual void UpdateSysAgentConditionsL(); |
|
446 virtual TBool NotifyMessagesScheduledL(); |
|
447 virtual void CreateMessagesL(); |
|
448 virtual void ScheduleMessagesL(); |
|
449 virtual TInt ScheduledState(); |
|
450 virtual const TDesC& TestName(); |
|
451 |
|
452 private: |
|
453 |
|
454 CTestRescheduleMixed_1(CScheduleSendTestUtils& aTestUtils); |
|
455 |
|
456 }; |
|
457 |
|
458 /** |
|
459 Tests the CMsvScheduleSend::ReScheduleL API. |
|
460 |
|
461 Creates 2 pigeon messages that are both re-schedule to fail. |
|
462 |
|
463 Post scheduling sending state values - KMsvSendStateWaiting. The schedule send |
|
464 component does not alter messages that are not re-scheduled. |
|
465 */ |
|
466 class CTestFailed_1 : public CTestScheduleSendBase |
|
467 { |
|
468 public: |
|
469 |
|
470 static CTestFailed_1* NewL(CScheduleSendTestUtils& aTestUtils); |
|
471 virtual ~CTestFailed_1(); |
|
472 |
|
473 private: // methods from CTestScheduleSendBase |
|
474 |
|
475 virtual TBool NotifyMessagesScheduledL(); |
|
476 virtual void CreateMessagesL(); |
|
477 virtual void ScheduleMessagesL(); |
|
478 virtual TInt ScheduledState(); |
|
479 virtual const TDesC& TestName(); |
|
480 |
|
481 private: |
|
482 |
|
483 CTestFailed_1(CScheduleSendTestUtils& aTestUtils); |
|
484 |
|
485 }; |
|
486 |
|
487 /** |
|
488 Tests the CMsvScheduleSend::ReScheduleL API. |
|
489 |
|
490 Creates 2 pigeon messages that are both re-schedule to fail, but on a second re-schedule. |
|
491 |
|
492 Post scheduling sending state values - KMsvSendStateResend. |
|
493 Sent sending state value - KMsvSendStateWaiting. The schedule send |
|
494 component does not alter messages that are not re-scheduled. |
|
495 */ |
|
496 class CTestFailed_2 : public CTestScheduleSendBase |
|
497 { |
|
498 public: |
|
499 |
|
500 static CTestFailed_2* NewL(CScheduleSendTestUtils& aTestUtils); |
|
501 virtual ~CTestFailed_2(); |
|
502 |
|
503 private: // methods from CTestScheduleSendBase |
|
504 |
|
505 virtual TBool NotifyMessagesScheduledL(); |
|
506 virtual void CreateMessagesL(); |
|
507 virtual void ScheduleMessagesL(); |
|
508 virtual TInt ScheduledState(); |
|
509 virtual TInt SentState(); |
|
510 virtual const TDesC& TestName(); |
|
511 |
|
512 private: |
|
513 |
|
514 CTestFailed_2(CScheduleSendTestUtils& aTestUtils); |
|
515 |
|
516 }; |
|
517 |
|
518 #endif // __T_SCHEDULESEND_H__ |