|
1 // Copyright (c) 2005-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 // Contains implementation of CTestMultipleAlarmsServer class |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalTechnology |
|
21 */ |
|
22 |
|
23 // User Includes |
|
24 #include "AlarmControlsManager.h" |
|
25 |
|
26 // Test Server |
|
27 #include "TestMultipleAlarmsServer.h" |
|
28 |
|
29 // Test Steps |
|
30 #include "TestStartAlertServerStep.h" |
|
31 #include "TestWaitStep.h" |
|
32 #include "TestCreateCalEntriesStep.h" |
|
33 #include "TestAlarmSnoozeStep.h" |
|
34 #include "TestAlarmControlStateStep.h" |
|
35 #include "TestAlarmSnoozeStep.h" |
|
36 #include "TestAlarmClearStep.h" |
|
37 #include "TestAssociatedDataStep.h" |
|
38 #include "TestKillAlertServerStep.h" |
|
39 #include "TestCleanupStep.h" |
|
40 #include "TestPerformanceStep.h" |
|
41 #include "TestCreateEntriesOOMStep.h" |
|
42 #include "TestAlarmContentOOMStep.h" |
|
43 |
|
44 // System Include |
|
45 #include <e32base.h> |
|
46 |
|
47 /*@{*/ |
|
48 // The system-wide unique name for the test-server |
|
49 _LIT(KServerName, "TestMultipleAlarmsServer"); |
|
50 /*@}*/ |
|
51 |
|
52 /** |
|
53 Static factory constructor. Creates and returns instance of the test server |
|
54 @internalTechnology |
|
55 @test |
|
56 @return A pointer to the newly created CTestMultipleAlarmsServer object |
|
57 */ |
|
58 CTestMultipleAlarmsServer* CTestMultipleAlarmsServer::NewL() |
|
59 { |
|
60 // Construct the server |
|
61 CTestMultipleAlarmsServer* server = new(ELeave) CTestMultipleAlarmsServer(); |
|
62 CleanupStack::PushL(server); |
|
63 |
|
64 server->ConstructL(); |
|
65 |
|
66 CleanupStack::Pop(server); |
|
67 return server; |
|
68 } |
|
69 |
|
70 /** |
|
71 Second phase constructor. Calls base class onstructL. |
|
72 And calls ShareAuto on the Logger session. |
|
73 @internalTechnology |
|
74 @test |
|
75 */ |
|
76 void CTestMultipleAlarmsServer::ConstructL() |
|
77 { |
|
78 TInt error = KErrNone; |
|
79 |
|
80 // CTestServer base class call |
|
81 // Names the server using the system-wide unique string |
|
82 // and also starts the server's logger. This logger is used |
|
83 // by the alert server thread |
|
84 CTestServer::ConstructL(KServerName); |
|
85 |
|
86 // The dummy alarm control running from the alert server thread needs to |
|
87 // share the test server's logger session to do some logging. As it is |
|
88 // non-shareable by default unless we uncomment those lines in |
|
89 // testexecute.cfg, we explicitly ShareAuto() it here. |
|
90 error = Logger().ShareAuto(); |
|
91 if(error != KErrNone) |
|
92 { |
|
93 INFO_PRINTF2(_L("Error occured while doing ShareAuto(): %D, The alert server thread will not perform any logging"), error); |
|
94 } |
|
95 else |
|
96 { |
|
97 iLogSessionShared = ETrue; |
|
98 } |
|
99 } |
|
100 |
|
101 /** |
|
102 Destructor. |
|
103 @internalTechnology |
|
104 @test |
|
105 */ |
|
106 CTestMultipleAlarmsServer::~CTestMultipleAlarmsServer() |
|
107 { |
|
108 } |
|
109 |
|
110 /** |
|
111 EKA2 version of MainL() |
|
112 Uses the new Rendezvous call instead of the older semaphore. |
|
113 */ |
|
114 LOCAL_C void MainL() |
|
115 { |
|
116 // For platform security |
|
117 #if (defined __DATA_CAGING__) |
|
118 RProcess().DataCaging(RProcess::EDataCagingOn); |
|
119 RProcess().SecureApi(RProcess::ESecureApiOn); |
|
120 #endif |
|
121 |
|
122 CActiveScheduler* sched = new(ELeave) CActiveScheduler; |
|
123 CActiveScheduler::Install(sched); |
|
124 CTestMultipleAlarmsServer* server = NULL; |
|
125 |
|
126 // Create the test-server |
|
127 TRAPD(err, server = CTestMultipleAlarmsServer::NewL()); |
|
128 |
|
129 if(!err) |
|
130 { |
|
131 // Sync with the client and enter the active scheduler |
|
132 RProcess::Rendezvous(KErrNone); |
|
133 sched->Start(); |
|
134 } |
|
135 delete server; |
|
136 delete sched; |
|
137 } |
|
138 |
|
139 /** |
|
140 Exe entry point code |
|
141 */ |
|
142 GLDEF_C TInt E32Main() |
|
143 { |
|
144 __UHEAP_MARK; |
|
145 CTrapCleanup *cleanup = CTrapCleanup::New(); |
|
146 if (cleanup == NULL) |
|
147 { |
|
148 return KErrNoMemory; |
|
149 } |
|
150 TInt err = KErrNone; |
|
151 TRAP(err, MainL()); |
|
152 delete cleanup; |
|
153 __UHEAP_MARKEND; |
|
154 return KErrNone; |
|
155 } |
|
156 |
|
157 /** |
|
158 Base class pure virtual, called by TEF |
|
159 @param aStepName Descriptor containing the test-step name |
|
160 @return Instance of the test step |
|
161 @internalTechnology |
|
162 @test |
|
163 */ |
|
164 CTestStep* CTestMultipleAlarmsServer::CreateTestStep(const TDesC& aStepName) |
|
165 { |
|
166 CTestStep *testStep = NULL; |
|
167 |
|
168 if (aStepName == KTestStartAlertServerStep) |
|
169 { |
|
170 testStep = new (ELeave) CTestStartAlertServerStep(*this); // Method could leave while construction |
|
171 } |
|
172 else if (aStepName == KTestWaitStep) |
|
173 { |
|
174 testStep = new (ELeave) CTestWaitStep(*this); |
|
175 } |
|
176 else if (aStepName == KTestCreateCalEntriesStep) |
|
177 { |
|
178 testStep = new (ELeave) CTestCreateCalEntriesStep(*this); |
|
179 } |
|
180 else if (aStepName == KTestAlarmControlStateStep) |
|
181 { |
|
182 testStep = new (ELeave) CTestAlarmControlStateStep(*this); |
|
183 } |
|
184 else if (aStepName == KTestAlarmSnoozeStep) |
|
185 { |
|
186 testStep = new (ELeave) CTestAlarmSnoozeStep(*this); |
|
187 } |
|
188 else if (aStepName == KTestAlarmClearStep) |
|
189 { |
|
190 testStep = new (ELeave) CTestAlarmClearStep(*this); |
|
191 } |
|
192 else if (aStepName == KTestAssociatedDataStep) |
|
193 { |
|
194 testStep = new (ELeave) CTestAssociatedDataStep(*this); |
|
195 } |
|
196 else if (aStepName == KTestKillAlertServerStep) |
|
197 { |
|
198 testStep = new (ELeave) CTestKillAlertServerStep(*this); |
|
199 } |
|
200 else if (aStepName == KTestCleanupStep) |
|
201 { |
|
202 testStep = new (ELeave) CTestCleanupStep(*this); |
|
203 } |
|
204 else if (aStepName == KTestPerformanceStep) |
|
205 { |
|
206 testStep = new (ELeave) CTestPerformanceStep(*this); |
|
207 } |
|
208 else if (aStepName == KTestCreateEntriesOOMStep) |
|
209 { |
|
210 testStep = new (ELeave) CTestCreateEntriesOOMStep(*this); |
|
211 } |
|
212 else if (aStepName == KTestAlarmContentOOMStep) |
|
213 { |
|
214 testStep = new (ELeave) CTestAlarmContentOOMStep(*this); |
|
215 } |
|
216 return testStep; |
|
217 } |
|
218 |
|
219 /** |
|
220 Returns a refernce to the current max alarms value. Set by the |
|
221 TestStartAlertServerStep |
|
222 @return A reference to the current max alarms value |
|
223 @internalTechnology |
|
224 @test |
|
225 */ |
|
226 TInt& CTestMultipleAlarmsServer::CurrentMaxAlarms() |
|
227 { |
|
228 return iCurrentMaxAlarms; |
|
229 } |
|
230 |
|
231 /** |
|
232 Returns the current max alarms value. Set by the TestStartAlertServerStep |
|
233 @return The current max alarms value |
|
234 @internalTechnology |
|
235 @test |
|
236 */ |
|
237 TInt CTestMultipleAlarmsServer::CurrentMaxAlarms() const |
|
238 { |
|
239 return iCurrentMaxAlarms; |
|
240 } |
|
241 |
|
242 /** |
|
243 Returns a reference to the pointer to CAlarmControlsManager |
|
244 @return Reference to the pointer to CAlarmControlsManager |
|
245 @internalTechnology |
|
246 @test |
|
247 */ |
|
248 CAlarmControlsManager*& CTestMultipleAlarmsServer::AlarmControlsManager() |
|
249 { |
|
250 return iAlmCtrlsMgr; |
|
251 } |
|
252 |
|
253 /** |
|
254 Returns a reference to the pointer to CEikServAlarmAlertServer |
|
255 @return Reference to the pointer to CEikServAlarmAlertServer |
|
256 @internalTechnology |
|
257 @test |
|
258 */ |
|
259 CEikServAlarmAlertServer*& CTestMultipleAlarmsServer::AlertServer() |
|
260 { |
|
261 return iAlertServer; |
|
262 } |
|
263 |
|
264 /** |
|
265 Returns the number of currently notifying alarms |
|
266 This flag is incremented / decremented when CDummyAlarmControls are |
|
267 notified of alarms that expire |
|
268 @return The number of currently notifying alarms |
|
269 @internalTechnology |
|
270 @test |
|
271 */ |
|
272 TInt& CTestMultipleAlarmsServer::NoOfCurrentlyNotifyingAlarms() |
|
273 { |
|
274 return iNoOfCurrentlyNotifyingAlarms; |
|
275 } |
|
276 /** |
|
277 Returns the Id of the alarm which was the last to start playing |
|
278 @return The Id of the alarm which was the last to start playing |
|
279 @internalTechnology |
|
280 @test |
|
281 */ |
|
282 TAlarmId& CTestMultipleAlarmsServer::CurrentlyPlayingAlarmId() |
|
283 { |
|
284 return iCurrentlyPlayingAlarmId; |
|
285 } |
|
286 |
|
287 /** |
|
288 Returns a refernce to the thread that starts Alert Server |
|
289 @return Refernce to the thread that starts Alert Server |
|
290 @internalTechnology |
|
291 @test |
|
292 */ |
|
293 RThread& CTestMultipleAlarmsServer::AltSrvThread() |
|
294 { |
|
295 return iAltSrvThread; |
|
296 } |
|
297 |
|
298 /** |
|
299 Returns whether we were successful in making the Logger shareable between threads |
|
300 @return Whether we were successful in making the Logger shareable between threads |
|
301 @internalTechnology |
|
302 @test |
|
303 */ |
|
304 TBool CTestMultipleAlarmsServer::LogSessionShared() |
|
305 { |
|
306 return iLogSessionShared; |
|
307 } |