author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 24 Nov 2009 08:56:33 +0200 | |
changeset 33 | 50974a8b132e |
parent 19 | 989d2f495d90 |
permissions | -rw-r--r-- |
19 | 1 |
/* |
2 |
* Copyright (c) 2002 - 2007 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: ?Description |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
||
21 |
// INCLUDE FILES |
|
22 |
#include <e32svr.h> |
|
23 |
#include <StifParser.h> |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
24 |
#include <StifTestInterface.h> |
19 | 25 |
#include "tcal_changenotify.h" |
26 |
#include "calendarheader.h" |
|
27 |
#include "calendarservice.h" |
|
28 |
#include "entryattributes.h" |
|
29 |
#include "teststartconsolealarmserver.h" |
|
30 |
#include <calchangecallback.h> |
|
31 |
||
32 |
_LIT(KTestCal1File ,"c:testcal1"); |
|
33 |
_LIT(KTestCal2File ,"c:testcal2"); |
|
34 |
_LIT(KCalName ,"c:Calendar"); |
|
35 |
||
36 |
class CChangeNotifyTest : public CActive, public MCalCallbackBase |
|
37 |
{ |
|
38 |
||
39 |
enum TTestCaseType |
|
40 |
{ |
|
41 |
KNotifyAdd =0, |
|
42 |
KNotifyDelete, |
|
43 |
KNotifyUpdate, |
|
44 |
}; |
|
45 |
public: |
|
46 |
static CChangeNotifyTest* NewL(TInt& aResult); |
|
47 |
||
48 |
~CChangeNotifyTest(); |
|
49 |
||
50 |
void NotifyResultL(TInt aErrCode, TAny* aResult); |
|
51 |
||
52 |
void Start(TInt aChange); |
|
53 |
||
54 |
void CancelNotification(); |
|
55 |
||
56 |
private: |
|
57 |
CChangeNotifyTest(TInt& aResult); |
|
58 |
||
59 |
void ConstructL(); |
|
60 |
||
61 |
void RunL(); |
|
62 |
||
63 |
void DoCancel(); |
|
64 |
||
65 |
void DoChangesAdd(); |
|
66 |
void DoChangesDelete(); |
|
67 |
void DoChangesUpdate(); |
|
68 |
void DoAddDelete(); |
|
69 |
||
70 |
||
71 |
private: |
|
72 |
CActiveSchedulerWait* iWaitscheduler; |
|
73 |
||
74 |
CCalendarService* iService; |
|
75 |
||
76 |
TInt iChange; |
|
77 |
||
78 |
TInt& iResult; |
|
79 |
||
80 |
TUIDSet* iUidSet; |
|
81 |
}; |
|
82 |
||
83 |
CChangeNotifyTest* CChangeNotifyTest::NewL(TInt& aResult) |
|
84 |
{ |
|
85 |
CChangeNotifyTest* self = new(ELeave) CChangeNotifyTest(aResult); |
|
86 |
CleanupStack::PushL(self); |
|
87 |
self->ConstructL(); |
|
88 |
CleanupStack::Pop(self); |
|
89 |
return self; |
|
90 |
} |
|
91 |
||
92 |
CChangeNotifyTest::~CChangeNotifyTest() |
|
93 |
{ |
|
94 |
Cancel(); |
|
95 |
||
96 |
if(iWaitscheduler->IsStarted()) |
|
97 |
iWaitscheduler->AsyncStop(); |
|
98 |
||
99 |
delete iWaitscheduler; |
|
100 |
||
101 |
RemoveCalendarFile(iService, KTestCal1File); |
|
102 |
delete iService; |
|
103 |
||
104 |
delete iUidSet; |
|
105 |
} |
|
106 |
||
107 |
void CChangeNotifyTest::NotifyResultL(TInt aErrCode, TAny* aResult) |
|
108 |
{ |
|
109 |
||
110 |
||
111 |
RArray<TCalChangeEntry>& outputChangeSet = *((RArray<TCalChangeEntry>*)aResult); |
|
112 |
||
113 |
TInt value = iChange; |
|
114 |
||
115 |
||
116 |
||
117 |
if(aErrCode != KErrCancel) |
|
118 |
{ |
|
119 |
iResult = aErrCode; |
|
120 |
TInt count = outputChangeSet.Count(); |
|
121 |
TInt type = outputChangeSet[0].iChangeType; |
|
122 |
switch(iChange) |
|
123 |
{ |
|
124 |
case 1 : |
|
125 |
if(outputChangeSet[0].iChangeType != MCalChangeCallBack2::EChangeAdd) |
|
126 |
iResult = KErrGeneral; |
|
127 |
break; |
|
128 |
||
129 |
case 2 : |
|
130 |
if(outputChangeSet[0].iChangeType != MCalChangeCallBack2::EChangeDelete) |
|
131 |
iResult = KErrGeneral; |
|
132 |
break; |
|
133 |
||
134 |
case 3: |
|
135 |
if(outputChangeSet[0].iChangeType != MCalChangeCallBack2::EChangeModify) |
|
136 |
iResult = KErrGeneral; |
|
137 |
break; |
|
138 |
case 4 : |
|
139 |
if(outputChangeSet[0].iChangeType != 1) |
|
140 |
iResult = KErrGeneral; |
|
141 |
break; |
|
142 |
||
143 |
} |
|
144 |
} |
|
145 |
||
146 |
||
147 |
||
148 |
if(iWaitscheduler->IsStarted()) |
|
149 |
iWaitscheduler->AsyncStop(); |
|
150 |
||
151 |
} |
|
152 |
||
153 |
void CChangeNotifyTest::Start(TInt aChange) |
|
154 |
{ |
|
155 |
iChange = aChange; |
|
156 |
AddCalendarFile(iService, KTestCal1File); |
|
157 |
CCalendarFilter* filter = CCalendarFilter::NewL(); |
|
158 |
||
159 |
if( aChange == 2 || aChange == 3 || aChange ==4) //in case of change notify or delete notify add an default entry |
|
160 |
{ //and then do deletion/Change |
|
161 |
AddAppointment(iService, KTestCal1File, iUidSet); |
|
162 |
filter->AddLocalUid(345); |
|
163 |
filter->AddLocalUid(346); |
|
164 |
filter->AddLocalUid( iUidSet->iLocalUID ); |
|
165 |
} |
|
166 |
||
167 |
||
168 |
iService->StartChangeNotifyL( KTestCal1File, filter, this ); |
|
169 |
||
170 |
delete filter; |
|
171 |
||
172 |
SetActive(); |
|
173 |
||
174 |
TRequestStatus* temp = &iStatus; |
|
175 |
||
176 |
User::RequestComplete( temp, KErrNone ); |
|
177 |
||
178 |
iWaitscheduler->Start(); |
|
179 |
||
180 |
RemoveCalendarFile(iService, KTestCal1File); |
|
181 |
} |
|
182 |
||
183 |
void CChangeNotifyTest::CancelNotification() |
|
184 |
{ |
|
185 |
iService->Cancel(0); |
|
186 |
} |
|
187 |
||
188 |
CChangeNotifyTest::CChangeNotifyTest(TInt& aResult): |
|
189 |
CActive(EPriorityStandard),iUidSet(NULL), iResult(aResult) |
|
190 |
{ |
|
191 |
iTransactionId = 0; |
|
192 |
CActiveScheduler::Add(this); |
|
193 |
} |
|
194 |
||
195 |
void CChangeNotifyTest::ConstructL() |
|
196 |
{ |
|
197 |
iService = CCalendarService::NewL(); |
|
198 |
iWaitscheduler = new(ELeave) CActiveSchedulerWait; |
|
199 |
} |
|
200 |
||
201 |
void CChangeNotifyTest::RunL() |
|
202 |
{ |
|
203 |
TInt err = iStatus.Int(); |
|
204 |
||
205 |
if(err == KErrNone) |
|
206 |
{ |
|
207 |
if(iChange == 1) |
|
208 |
DoChangesAdd(); |
|
209 |
if(iChange == 2) |
|
210 |
DoChangesDelete(); |
|
211 |
if(iChange == 3) |
|
212 |
DoChangesUpdate(); |
|
213 |
if(iChange ==4) |
|
214 |
DoAddDelete(); |
|
215 |
||
216 |
} |
|
217 |
else |
|
218 |
{ |
|
219 |
||
220 |
} |
|
221 |
} |
|
222 |
||
223 |
void CChangeNotifyTest::DoCancel() |
|
224 |
{ |
|
225 |
||
226 |
} |
|
227 |
||
228 |
void CChangeNotifyTest::DoChangesAdd() |
|
229 |
{ |
|
230 |
TUIDSet* uids = NULL; |
|
231 |
||
232 |
AddAppointment(iService, KTestCal1File, uids); |
|
233 |
||
234 |
delete uids; |
|
235 |
} |
|
236 |
||
237 |
void CChangeNotifyTest::DoChangesDelete() |
|
238 |
{ |
|
239 |
CCalendarFilter* filter = CCalendarFilter::NewL(); |
|
240 |
||
241 |
filter->AddGuidL( iUidSet->iGlobalUID->Des() ); |
|
242 |
||
243 |
iService->DeleteL( KTestCal1File , filter ); |
|
244 |
||
245 |
delete filter; |
|
246 |
} |
|
247 |
||
248 |
void CChangeNotifyTest::DoChangesUpdate() |
|
249 |
{ |
|
250 |
CEntryAttributes* entry = CEntryAttributes::NewL(); |
|
251 |
||
252 |
TUIDSet* tempLUid = NULL; |
|
253 |
||
254 |
entry->SetLocalUid( iUidSet->iLocalUID ); |
|
255 |
||
256 |
entry->SetLocationL(_L("Newyorkkkkk")); |
|
257 |
||
258 |
iService->AddL( KTestCal1File , entry , tempLUid ); |
|
259 |
||
260 |
delete tempLUid; |
|
261 |
||
262 |
delete entry; |
|
263 |
||
264 |
} |
|
265 |
||
266 |
void CChangeNotifyTest::DoAddDelete() |
|
267 |
{ |
|
268 |
TUIDSet* uids = NULL; |
|
269 |
TUIDSet* tempLUid = NULL; |
|
270 |
AddAppointment(iService, KTestCal1File, uids); |
|
271 |
delete uids; |
|
272 |
CCalendarFilter* filter = CCalendarFilter::NewL(); |
|
273 |
filter->AddGuidL( iUidSet->iGlobalUID->Des() ); |
|
274 |
iService->DeleteL( KTestCal1File , filter ); |
|
275 |
uids = NULL; |
|
276 |
delete filter; |
|
277 |
||
278 |
||
279 |
} |
|
280 |
||
281 |
||
282 |
// ============================ MEMBER FUNCTIONS =============================== |
|
283 |
||
284 |
// ----------------------------------------------------------------------------- |
|
285 |
// Ctcal_changenotify::Delete |
|
286 |
// Delete here all resources allocated and opened from test methods. |
|
287 |
// Called from destructor. |
|
288 |
// ----------------------------------------------------------------------------- |
|
289 |
// |
|
290 |
void Ctcal_changenotify::Delete() |
|
291 |
{ |
|
292 |
||
293 |
} |
|
294 |
||
295 |
// ----------------------------------------------------------------------------- |
|
296 |
// Ctcal_changenotify::RunMethodL |
|
297 |
// Run specified method. Contains also table of test mothods and their names. |
|
298 |
// ----------------------------------------------------------------------------- |
|
299 |
// |
|
300 |
TInt Ctcal_changenotify::RunMethodL( |
|
301 |
CStifItemParser& aItem ) |
|
302 |
{ |
|
303 |
||
304 |
static TStifFunctionInfo const KFunctions[] = |
|
305 |
{ |
|
306 |
// Copy this line for every implemented function. |
|
307 |
// First string is the function name used in TestScripter script file. |
|
308 |
// Second is the actual implementation member function. |
|
309 |
ENTRY( "GetAddNotification", Ctcal_changenotify::GetAddNotification ), |
|
310 |
ENTRY( "GetDeleteNotification", Ctcal_changenotify::GetDeleteNotification ), |
|
311 |
ENTRY( "GetUpdateNotification", Ctcal_changenotify::GetUpdateNotification ), |
|
312 |
ENTRY( "GetAddDeleteNotification", Ctcal_changenotify::GetAddDeleteNotification ), |
|
313 |
||
314 |
//ADD NEW ENTRY HERE |
|
315 |
||
316 |
}; |
|
317 |
||
318 |
const TInt count = sizeof( KFunctions ) / |
|
319 |
sizeof( TStifFunctionInfo ); |
|
320 |
||
321 |
return RunInternalL( KFunctions, count, aItem ); |
|
322 |
||
323 |
} |
|
324 |
||
325 |
// ----------------------------------------------------------------------------- |
|
326 |
// Ctcal_changenotify::GetAddNotification |
|
327 |
// Example test method function to check notification for add. |
|
328 |
// (other items were commented in a header). |
|
329 |
// ----------------------------------------------------------------------------- |
|
330 |
// |
|
331 |
TInt Ctcal_changenotify::GetAddNotification( CStifItemParser& aItem ) |
|
332 |
{ |
|
333 |
||
334 |
TInt result = KErrNone; |
|
335 |
__UHEAP_MARK; |
|
336 |
TInt cells = User::CountAllocCells(); |
|
337 |
CChangeNotifyTest* test = CChangeNotifyTest::NewL(result); |
|
338 |
cells = User::CountAllocCells(); |
|
339 |
test->Start(1); |
|
340 |
test->CancelNotification(); |
|
341 |
cells = User::CountAllocCells(); |
|
342 |
delete test; |
|
343 |
cells = User::CountAllocCells(); |
|
344 |
__UHEAP_MARKEND; |
|
345 |
return result; |
|
346 |
||
347 |
} |
|
348 |
||
349 |
// ----------------------------------------------------------------------------- |
|
350 |
// Ctcal_changenotify::GetDeleteNotification |
|
351 |
// Example test method function to check notification for update. |
|
352 |
// (other items were commented in a header). |
|
353 |
// ----------------------------------------------------------------------------- |
|
354 |
// |
|
355 |
TInt Ctcal_changenotify::GetDeleteNotification( CStifItemParser& aItem ) |
|
356 |
{ |
|
357 |
||
358 |
TInt result = KErrNone; |
|
359 |
__UHEAP_MARK; |
|
360 |
TInt cells = User::CountAllocCells(); |
|
361 |
CChangeNotifyTest* test = CChangeNotifyTest::NewL(result); |
|
362 |
cells = User::CountAllocCells(); |
|
363 |
test->Start(2); |
|
364 |
test->CancelNotification(); |
|
365 |
cells = User::CountAllocCells(); |
|
366 |
delete test; |
|
367 |
cells = User::CountAllocCells(); |
|
368 |
__UHEAP_MARKEND; |
|
369 |
return result; |
|
370 |
||
371 |
} |
|
372 |
||
373 |
||
374 |
// ----------------------------------------------------------------------------- |
|
375 |
// Ctcal_changenotify::GetUpdateNotification |
|
376 |
// Example test method function to check notification for delete. |
|
377 |
// (other items were commented in a header). |
|
378 |
// ----------------------------------------------------------------------------- |
|
379 |
// |
|
380 |
TInt Ctcal_changenotify::GetUpdateNotification( CStifItemParser& aItem ) |
|
381 |
{ |
|
382 |
||
383 |
TInt result = KErrNone; |
|
384 |
__UHEAP_MARK; |
|
385 |
TInt cells = User::CountAllocCells(); |
|
386 |
CChangeNotifyTest* test = CChangeNotifyTest::NewL(result); |
|
387 |
cells = User::CountAllocCells(); |
|
388 |
test->Start(3); |
|
389 |
test->CancelNotification(); |
|
390 |
cells = User::CountAllocCells(); |
|
391 |
delete test; |
|
392 |
cells = User::CountAllocCells(); |
|
393 |
__UHEAP_MARKEND; |
|
394 |
return result; |
|
395 |
||
396 |
} |
|
397 |
||
398 |
// ----------------------------------------------------------------------------- |
|
399 |
// Ctcal_changenotify::GetAddDeleteNotification |
|
400 |
// Example test method function to check notification for add+delete. |
|
401 |
// (other items were commented in a header). |
|
402 |
// ----------------------------------------------------------------------------- |
|
403 |
// |
|
404 |
TInt Ctcal_changenotify::GetAddDeleteNotification( CStifItemParser& aItem ) |
|
405 |
{ |
|
406 |
||
407 |
TInt result = KErrNone; |
|
408 |
__UHEAP_MARK; |
|
409 |
TInt cells = User::CountAllocCells(); |
|
410 |
CChangeNotifyTest* test = CChangeNotifyTest::NewL(result); |
|
411 |
cells = User::CountAllocCells(); |
|
412 |
test->Start(4); |
|
413 |
test->CancelNotification(); |
|
414 |
cells = User::CountAllocCells(); |
|
415 |
delete test; |
|
416 |
cells = User::CountAllocCells(); |
|
417 |
__UHEAP_MARKEND; |
|
418 |
return result; |
|
419 |
||
420 |
} |
|
421 |
||
422 |
||
423 |
// ----------------------------------------------------------------------------- |
|
424 |
// Ctcal_changenotify::?member_function |
|
425 |
// ?implementation_description |
|
426 |
// (other items were commented in a header). |
|
427 |
// ----------------------------------------------------------------------------- |
|
428 |
// |
|
429 |
/* |
|
430 |
TInt Ctcal_changenotify::?member_function( |
|
431 |
CItemParser& aItem ) |
|
432 |
{ |
|
433 |
||
434 |
?code |
|
435 |
||
436 |
} |
|
437 |
*/ |
|
438 |
||
439 |
// ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
440 |
// None |
|
441 |
||
442 |
// End of File |