|
1 // Copyright (c) 2007-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 // tcal_servershutdown: |
|
15 // This test is intended to test the delay added to the calendar file before it is closed |
|
16 // |
|
17 // |
|
18 |
|
19 #ifndef __TCAL_SERVERSHUTDOWN_H__ |
|
20 #define __TCAL_SERVERSHUTDOWN_H__ |
|
21 |
|
22 #include <calsession.h> |
|
23 #include <calentryview.h> |
|
24 #include <hal.h> |
|
25 #include <ecom/ecom.h> |
|
26 #include <calprogresscallback.h> |
|
27 #include <coreappstest/testserver.h> |
|
28 #include "caltestoom.h" |
|
29 #include "caltestlib.h" |
|
30 |
|
31 |
|
32 #ifdef SYMBIAN_SYSTEM_STATE_MANAGEMENT |
|
33 #include <e32property.h> |
|
34 #include "ASCliSession.h" |
|
35 class CCalInstanceView; |
|
36 #endif |
|
37 |
|
38 |
|
39 |
|
40 _LIT(KTestName, "TCal_ServerShutdown"); |
|
41 RTest test(KTestName); |
|
42 |
|
43 // Two sample calendar files |
|
44 _LIT(KServerShutdownCalFile, "c:tcal_servershutdown_calfile"); |
|
45 _LIT(KServerShutdownCalFileMultifFile, "c:tcal_servershutdown_calfile_multi_file"); |
|
46 |
|
47 // v9.1 calendar file - conversion test |
|
48 _LIT(KServerShutdown91CalFile, "c:tcal_servershutdown_calfile_v91"); |
|
49 |
|
50 // Calendar file - delete test |
|
51 _LIT(KServerShutdownCalFileToDelete, "c:tcal_servershutdown_calfile_ToDelete"); |
|
52 _LIT(KServerShutdownCalFileToDeleteRAM, "c:\\private\\10003a5b\\tcal_servershutdown_calfile_ToDelete"); |
|
53 |
|
54 _LIT(KServerShutdownCalFileToDeleteOOM, "c:tcal_servershutdown_calfile_ToDelete"); |
|
55 _LIT(KServerShutdownCalFileToDeleteRAM_OOM, "c:\\private\\10003a5b\\tcal_servershutdown_calfile_ToDelete"); |
|
56 |
|
57 // Non-existent calendar filename |
|
58 _LIT(KServerShutdownBadCalFileName, "c:tcal_servershutdown_calfile_ShouldNotExist"); |
|
59 |
|
60 // Calendar files in ROM (origin) |
|
61 _LIT(KServerShutdownCalFileROM, "z:\\private\\10003a5b\\tcal_servershutdown_calfile"); |
|
62 _LIT(KServerShutdownCalFileMultiFileROM, "z:\\private\\10003a5b\\tcal_servershutdown_calfile_multi_file"); |
|
63 _LIT(KServerShutdown91CalFileROM, "z:\\private\\10003a5b\\tcal_servershutdown_calfile_v91"); |
|
64 |
|
65 // Calendar files in RAM (Destination) |
|
66 _LIT(KServerShutdownCalFileRAM, "c:\\private\\10003a5b\\tcal_servershutdown_calfile"); |
|
67 _LIT(KServerShutdownCalFileMultiFileRAM, "c:\\private\\10003a5b\\tcal_servershutdown_calfile_multi_file"); |
|
68 _LIT(KServerShutdown91CalFileRAM, "c:\\private\\10003a5b\\tcal_servershutdown_calfile_v91"); |
|
69 |
|
70 // Expectd minimum delay before the calendar file is closed |
|
71 const TTimeIntervalMicroSeconds32 KServerShutdownDelayMin = 5000000; |
|
72 // Maximum possible delay before the calendar file is closed |
|
73 const TTimeIntervalMicroSeconds32 KServerShutdownDelayMax = 6000000; |
|
74 |
|
75 // Delay to test the cancellation of the calendar close delay timers |
|
76 const TTimeIntervalMicroSeconds32 KServerCancelDelay = 3000000; |
|
77 |
|
78 const TUid KServerUid2 = {0x1000008D}; |
|
79 const TUid KServerUid3 = {0x101F502A}; |
|
80 _LIT(KConsoleAlarmAlertServerImg, "ConsoleAlarmAlertServer"); |
|
81 |
|
82 class CServerShutdownTestManager : public CActive, public MCalProgressCallBack, public MCalTestOomCallBack |
|
83 { |
|
84 public: |
|
85 enum TTestCases |
|
86 { |
|
87 ETestServerShutdownWithIndex, |
|
88 ETestServerShutdownCancelWithIndexStart, |
|
89 ETestServerShutdownCancelWithIndexCancelled, |
|
90 ETestServerShutdownCancelWithIndexShutdown, |
|
91 ETestServerShutdownDeleteFile, |
|
92 ETestServerShutdownDeleteMultiFiles, |
|
93 ETestServerShutdownProcessExit, |
|
94 ETestServerShutdownOOMDeleteFile, |
|
95 ETestServerShutdownOOMOpenCloseFile, |
|
96 ETestServerSingleSessionOpenTwiceStart, |
|
97 ETestServerSingleSessionOpenTwiceShutdown, |
|
98 ETestServerMultiSessionSingleFileOpenStart, |
|
99 ETestServerMultiSessionSingleFileOpen, |
|
100 ETestServerMultiSessionSingleFileOpenShutdown, |
|
101 ETestServerMultiSessionMultiFileOpenStart, |
|
102 ETestServerMultiSessionMultiFileOpenShutdown, |
|
103 ETestServerShutdownOpenInvalidFileLeave, |
|
104 ETestServerShutdownv91CalendarFileConversion, |
|
105 #ifdef SYMBIAN_SYSTEM_STATE_MANAGEMENT |
|
106 ETestServerShutdownWithSystemStateNotification, |
|
107 ETestServerShutdownWithSystemStateNotificationAsync, |
|
108 ETestServerShutdownWithSystemStateNotificationInstance, |
|
109 ETestServerShutdownWithSystemStateNotificationNormal |
|
110 #endif |
|
111 }; |
|
112 |
|
113 #ifdef SYMBIAN_SYSTEM_STATE_MANAGEMENT |
|
114 enum TSystemStateNotifications |
|
115 { |
|
116 ESystemStateNormal, |
|
117 ESystemStateShutdown, |
|
118 ESystemStateAck |
|
119 }; |
|
120 #endif |
|
121 |
|
122 static CServerShutdownTestManager* NewLC(TInt aPriority); |
|
123 ~CServerShutdownTestManager(); |
|
124 |
|
125 void RunAllTestsL(); |
|
126 |
|
127 private: |
|
128 void RunL(); |
|
129 void DoCancel(); |
|
130 |
|
131 void ProcessLogonL(); |
|
132 void ShutdownProcessL(const TDesC& aProcessUid); |
|
133 |
|
134 // from MCalProgressCallBack |
|
135 void Progress(TInt aPercentageCompleted); |
|
136 void Completed(TInt aError); |
|
137 TBool NotifyProgress(); |
|
138 |
|
139 // from MCalTestOomCallBack |
|
140 void OomTestL(TType aType, TInt aFailAt); |
|
141 |
|
142 CServerShutdownTestManager(TInt aPriority); |
|
143 void ConstructL(); |
|
144 |
|
145 void TestServerShutdownWithIndexL(); |
|
146 void TestServerShutdownCancelWithIndexL(); |
|
147 void TestServerShutdownDeleteFileL(); |
|
148 void TestServerShutdownDeleteMultiFilesL(); |
|
149 void TestServerShutdownDeleteFileOOML(TInt aFailAt); |
|
150 void TestServerShutdownOpenCloseFileOOML(); |
|
151 void TestServerShutdownProcessExitL(); |
|
152 void TestServerShutdownOOML(); |
|
153 void TestServerShutdownSingleSessionOpenTwiceL(); |
|
154 void TestServerShutdownMultiSessionSingleFileOpenL(); |
|
155 void TestServerShutdownMultiSessionMultiFileOpenL(); |
|
156 void TestServerShutdownOpenInvalidFileLeaveL(); |
|
157 void TestServerShutdownTestOldCalendarFileConversionL(); |
|
158 #ifdef SYMBIAN_SYSTEM_STATE_MANAGEMENT |
|
159 void TestServerShutdownWithSystemStateNotificationsL(); |
|
160 void TestServerShutdownWithSystemStateNotificationsAsyncL(); |
|
161 void TestServerShutdownWithStateNotificationAndInstanceViewL(); |
|
162 void TestServerShutdownWithNormalSystemStateNotification(); |
|
163 void CreateSystemStateNotificationProperty(); |
|
164 void TestSystemAckNotification(); |
|
165 void TestPostShutdownOperationsL(const TDesC8& aGuid, TInt aErr, TInt aAlarmCount = 0); |
|
166 void TestAsycnDeleteOperationL(); |
|
167 void TestInstanceViewOperationsL(); |
|
168 void ClearAllAlarmsL(); |
|
169 #endif |
|
170 |
|
171 // Record a timestamp before initiating server shutdown |
|
172 void RecordTimeStampBeforeServerShutdown(); |
|
173 // Record a timestamp after initiating server shutdown, calculate the period of shutdown and ensure that is within the expected range |
|
174 void TestServerShutdownTime(); |
|
175 |
|
176 void CreateSessionL(); |
|
177 void CreateAdditionalSessionL(); |
|
178 |
|
179 void CloseSession(TBool aWaitToClose); |
|
180 void CloseAdditionalSession(TBool aWaitToClose); |
|
181 #ifdef SYMBIAN_SYSTEM_STATE_MANAGEMENT |
|
182 void CreateEntry(const TDesC8& aGuid); |
|
183 void CreateRecurringEntriesL(const TDesC8& aGuid); |
|
184 void CreateInstanceViewL(TBool aWaitToOpen); |
|
185 #endif |
|
186 void CreateEntryViewL(const TDesC& aCalFile, TBool aWaitToOpen); |
|
187 |
|
188 void CreateAdditionalEntryViewL(const TDesC& aCalFile, TBool aWaitToOpen); |
|
189 |
|
190 void CloseEntryView(); |
|
191 void CloseAdditionalEntryView(); |
|
192 #ifdef SYMBIAN_SYSTEM_STATE_MANAGEMENT |
|
193 void CloseInstanceView(); |
|
194 void SendSystemStateNotification(TSystemStateNotifications aSystemStateNotification); |
|
195 void SubscribeToSystemNotification(); |
|
196 #endif |
|
197 |
|
198 // Async delay helper functions |
|
199 void AsyncDelay(TTimeIntervalMicroSeconds32 aMicroseconds); |
|
200 static TInt AsyncDelayCallBack(TAny* aPtr); |
|
201 |
|
202 RProcess iProcess; |
|
203 RPIMTestServer iPIMTestServer; |
|
204 CTestRegister* iFileRegister; |
|
205 |
|
206 CPeriodic* iPeriodic; |
|
207 |
|
208 CCalSession* iSession; |
|
209 CCalSession* iAdditionalSession; |
|
210 CCalEntryView* iEntryView; |
|
211 CCalEntryView* iAdditionalEntryView; |
|
212 |
|
213 TUint32 iSrvTimerStartTicks; |
|
214 TInt iNanoTickPeriod; |
|
215 |
|
216 TInt iTestCase; |
|
217 #ifdef SYMBIAN_SYSTEM_STATE_MANAGEMENT |
|
218 CCalInstanceView* iInstanceView; |
|
219 RProperty iSystemStateNotification; |
|
220 TUid iMyUid; |
|
221 TInt itcal_key; |
|
222 RASCliSession iAlarmServer; |
|
223 #endif |
|
224 }; |
|
225 |
|
226 #endif |