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 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> |
|
24 |
//#include <SAPI_TEST\testprg.h> |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
25 |
#include <StifTestInterface.h> |
19 | 26 |
#include "calendarheader.h" |
27 |
#include "calendarservice.h" |
|
28 |
#include "entryattributes.h" |
|
29 |
||
30 |
#include "teststartconsolealarmserver.h" |
|
31 |
#include "tcalendarchangenotifytest.h" |
|
32 |
||
33 |
||
34 |
_LIT(KTestCal1File ,"C:getlistcal1"); |
|
35 |
_LIT(KTestCal2File ,"C:getlistcal2"); |
|
36 |
||
37 |
||
38 |
||
39 |
||
40 |
class CChangeNotifyTest : public CActive, public MCalCallbackBase |
|
41 |
{ |
|
42 |
public: |
|
43 |
static CChangeNotifyTest* NewL(); |
|
44 |
||
45 |
~CChangeNotifyTest(); |
|
46 |
||
47 |
void NotifyResultL(TInt aErrCode, TAny* aResult); |
|
48 |
||
49 |
void Start(TInt aChange); |
|
50 |
||
51 |
void CancelNotification(); |
|
52 |
||
53 |
private: |
|
54 |
CChangeNotifyTest(); |
|
55 |
||
56 |
void ConstructL(); |
|
57 |
||
58 |
void RunL(); |
|
59 |
||
60 |
void DoCancel(); |
|
61 |
||
62 |
void DoChangesAdd(); |
|
63 |
void DoChangesDelete(); |
|
64 |
void DoChangesUpdate(); |
|
65 |
||
66 |
private: |
|
67 |
CActiveSchedulerWait* iWaitscheduler; |
|
68 |
||
69 |
CCalendarService* iService; |
|
70 |
||
71 |
TInt iChange; |
|
72 |
||
73 |
TUIDSet* iUidSet; |
|
74 |
}; |
|
75 |
||
76 |
CChangeNotifyTest* CChangeNotifyTest::NewL() |
|
77 |
{ |
|
78 |
CChangeNotifyTest* self = new(ELeave) CChangeNotifyTest; |
|
79 |
CleanupStack::PushL(self); |
|
80 |
self->ConstructL(); |
|
81 |
CleanupStack::Pop(self); |
|
82 |
return self; |
|
83 |
} |
|
84 |
||
85 |
CChangeNotifyTest::~CChangeNotifyTest() |
|
86 |
{ |
|
87 |
Cancel(); |
|
88 |
||
89 |
if(iWaitscheduler->IsStarted()) |
|
90 |
iWaitscheduler->AsyncStop(); |
|
91 |
||
92 |
delete iWaitscheduler; |
|
93 |
||
94 |
delete iService; |
|
95 |
||
96 |
delete iUidSet; |
|
97 |
} |
|
98 |
||
99 |
void CChangeNotifyTest::NotifyResultL(TInt aErrCode, TAny* aResult) |
|
100 |
{ |
|
101 |
if(iWaitscheduler->IsStarted()) |
|
102 |
iWaitscheduler->AsyncStop(); |
|
103 |
} |
|
104 |
||
105 |
void CChangeNotifyTest::Start(TInt aChange) |
|
106 |
{ |
|
107 |
iChange = aChange; |
|
108 |
AddCalendarFile(iService, KTestCal1File); |
|
109 |
CCalendarFilter* filter = CCalendarFilter::NewL(); |
|
110 |
||
111 |
if( aChange == 2 || aChange == 3 ) //in case of change notify or delete notify add an default entry |
|
112 |
{ //and then do deletion/Change |
|
113 |
AddAppointment(iService, KTestCal1File, iUidSet); |
|
114 |
filter->AddLocalUid(345); |
|
115 |
filter->AddLocalUid(346); |
|
116 |
filter->AddLocalUid( iUidSet->iLocalUID ); |
|
117 |
} |
|
118 |
||
119 |
||
120 |
iService->StartChangeNotifyL( KTestCal1File, filter, this ); |
|
121 |
||
122 |
delete filter; |
|
123 |
||
124 |
SetActive(); |
|
125 |
||
126 |
TRequestStatus* temp = &iStatus; |
|
127 |
||
128 |
User::RequestComplete( temp, KErrNone ); |
|
129 |
||
130 |
iWaitscheduler->Start(); |
|
131 |
||
132 |
RemoveCalendarFile(iService, KTestCal1File); |
|
133 |
} |
|
134 |
||
135 |
void CChangeNotifyTest::CancelNotification() |
|
136 |
{ |
|
137 |
iService->Cancel(0); |
|
138 |
} |
|
139 |
||
140 |
CChangeNotifyTest::CChangeNotifyTest(): |
|
141 |
CActive(EPriorityStandard),iUidSet(NULL) |
|
142 |
{ |
|
143 |
iTransactionId = 0; |
|
144 |
CActiveScheduler::Add(this); |
|
145 |
} |
|
146 |
||
147 |
void CChangeNotifyTest::ConstructL() |
|
148 |
{ |
|
149 |
iService = CCalendarService::NewL(); |
|
150 |
iWaitscheduler = new(ELeave) CActiveSchedulerWait; |
|
151 |
} |
|
152 |
||
153 |
void CChangeNotifyTest::RunL() |
|
154 |
{ |
|
155 |
TInt err = iStatus.Int(); |
|
156 |
||
157 |
if(err == KErrNone) |
|
158 |
{ |
|
159 |
if(iChange == 1) |
|
160 |
DoChangesAdd(); |
|
161 |
if(iChange == 2) |
|
162 |
DoChangesDelete(); |
|
163 |
if(iChange == 3) |
|
164 |
DoChangesUpdate(); |
|
165 |
} |
|
166 |
else |
|
167 |
{ |
|
168 |
||
169 |
} |
|
170 |
} |
|
171 |
||
172 |
void CChangeNotifyTest::DoCancel() |
|
173 |
{ |
|
174 |
||
175 |
} |
|
176 |
||
177 |
void CChangeNotifyTest::DoChangesAdd() |
|
178 |
{ |
|
179 |
TUIDSet* uids = NULL; |
|
180 |
||
181 |
AddAppointment(iService, KTestCal1File, uids); |
|
182 |
||
183 |
delete uids; |
|
184 |
} |
|
185 |
||
186 |
void CChangeNotifyTest::DoChangesDelete() |
|
187 |
{ |
|
188 |
CCalendarFilter* filter = CCalendarFilter::NewL(); |
|
189 |
||
190 |
filter->AddGuidL( iUidSet->iGlobalUID->Des() ); |
|
191 |
||
192 |
iService->DeleteL( KTestCal1File , filter ); |
|
193 |
||
194 |
delete filter; |
|
195 |
} |
|
196 |
||
197 |
void CChangeNotifyTest::DoChangesUpdate() |
|
198 |
{ |
|
199 |
CEntryAttributes* entry = CEntryAttributes::NewL(); |
|
200 |
||
201 |
TUIDSet* tempLUid = NULL; |
|
202 |
||
203 |
entry->SetLocalUid( iUidSet->iLocalUID ); |
|
204 |
||
205 |
entry->SetLocationL(_L("Newyorkkkkk")); |
|
206 |
||
207 |
iService->AddL( KTestCal1File , entry , tempLUid ); |
|
208 |
||
209 |
delete tempLUid; |
|
210 |
||
211 |
delete entry; |
|
212 |
||
213 |
} |
|
214 |
||
215 |
// ============================ MEMBER FUNCTIONS =============================== |
|
216 |
||
217 |
// ----------------------------------------------------------------------------- |
|
218 |
// CTCalendarChangeNotifyTest::Delete |
|
219 |
// Delete here all resources allocated and opened from test methods. |
|
220 |
// Called from destructor. |
|
221 |
// ----------------------------------------------------------------------------- |
|
222 |
// |
|
223 |
void CTCalendarChangeNotifyTest::Delete() |
|
224 |
{ |
|
225 |
||
226 |
} |
|
227 |
||
228 |
// ----------------------------------------------------------------------------- |
|
229 |
// CTCalendarChangeNotifyTest::RunMethodL |
|
230 |
// Run specified method. Contains also table of test mothods and their names. |
|
231 |
// ----------------------------------------------------------------------------- |
|
232 |
// |
|
233 |
TInt CTCalendarChangeNotifyTest::RunMethodL( |
|
234 |
CStifItemParser& aItem ) |
|
235 |
{ |
|
236 |
||
237 |
static TStifFunctionInfo const KFunctions[] = |
|
238 |
{ |
|
239 |
// Copy this line for every implemented function. |
|
240 |
// First string is the function name used in TestScripter script file. |
|
241 |
// Second is the actual implementation member function. |
|
242 |
//TRY( "SendMessage", CTDeleteMessageTest::SendMessage ), |
|
243 |
||
244 |
ENTRY( "NotifyAdd", CTCalendarChangeNotifyTest::NotifyAdd), |
|
245 |
ENTRY( "NotifyDelete", CTCalendarChangeNotifyTest::NotifyDelete), |
|
246 |
ENTRY( "NotifyUpdate", CTCalendarChangeNotifyTest::NotifyUpdate), |
|
247 |
||
248 |
}; |
|
249 |
||
250 |
const TInt count = sizeof( KFunctions ) / |
|
251 |
sizeof( TStifFunctionInfo ); |
|
252 |
||
253 |
return RunInternalL( KFunctions, count, aItem ); |
|
254 |
||
255 |
} |
|
256 |
||
257 |
||
258 |
TInt CTCalendarChangeNotifyTest::NotifyAdd(CStifItemParser& /*aItem*/) |
|
259 |
{ |
|
260 |
TInt result = KErrNone; |
|
261 |
__UHEAP_MARK; |
|
262 |
TInt cells = User::CountAllocCells(); |
|
263 |
CChangeNotifyTest* test = CChangeNotifyTest::NewL(); |
|
264 |
cells = User::CountAllocCells(); |
|
265 |
test->Start(1); |
|
266 |
test->CancelNotification(); |
|
267 |
cells = User::CountAllocCells(); |
|
268 |
delete test; |
|
269 |
cells = User::CountAllocCells(); |
|
270 |
__UHEAP_MARKEND; |
|
271 |
return result; |
|
272 |
||
273 |
} |
|
274 |
||
275 |
TInt CTCalendarChangeNotifyTest::NotifyDelete(CStifItemParser& /*aItem*/) |
|
276 |
{ |
|
277 |
TInt result = KErrNone; |
|
278 |
__UHEAP_MARK; |
|
279 |
TInt cells = User::CountAllocCells(); |
|
280 |
CChangeNotifyTest* test = CChangeNotifyTest::NewL(); |
|
281 |
cells = User::CountAllocCells(); |
|
282 |
test->Start(2); |
|
283 |
test->CancelNotification(); |
|
284 |
cells = User::CountAllocCells(); |
|
285 |
delete test; |
|
286 |
cells = User::CountAllocCells(); |
|
287 |
__UHEAP_MARKEND; |
|
288 |
return result; |
|
289 |
||
290 |
} |
|
291 |
||
292 |
TInt CTCalendarChangeNotifyTest::NotifyUpdate(CStifItemParser& /*aItem*/) |
|
293 |
{ |
|
294 |
TInt result = KErrNone; |
|
295 |
__UHEAP_MARK; |
|
296 |
TInt cells = User::CountAllocCells(); |
|
297 |
CChangeNotifyTest* test = CChangeNotifyTest::NewL(); |
|
298 |
cells = User::CountAllocCells(); |
|
299 |
test->Start(3); |
|
300 |
test->CancelNotification(); |
|
301 |
cells = User::CountAllocCells(); |
|
302 |
delete test; |
|
303 |
cells = User::CountAllocCells(); |
|
304 |
__UHEAP_MARKEND; |
|
305 |
return result; |
|
306 |
||
307 |
} |
|
308 |
||
309 |