|
1 /* |
|
2 * Copyright (c) 2005 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 "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: |
|
15 * ?description_line |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDES |
|
21 #include "FT_CPosTp117.h" |
|
22 #include <EPos_CPosLandmarkDatabase.h> |
|
23 #include <d32dbms.h> |
|
24 #include <StifLogger.h> |
|
25 |
|
26 //#include <ss_std.h> |
|
27 // CONSTANTS |
|
28 |
|
29 // ================= MEMBER FUNCTIONS ======================= |
|
30 |
|
31 // --------------------------------------------------------- |
|
32 // CPosTp117::CloseTest |
|
33 // |
|
34 // (other items were commented in a header). |
|
35 // --------------------------------------------------------- |
|
36 // |
|
37 void CPosTp117::CloseTest() |
|
38 { |
|
39 iLog->Log(_L("CloseTest")); |
|
40 delete iActiveLmEvent; |
|
41 iActiveLmEvent = NULL; |
|
42 |
|
43 iThread.Close(); |
|
44 } |
|
45 |
|
46 // --------------------------------------------------------- |
|
47 // CPosTp117::StartL |
|
48 // |
|
49 // (other items were commented in a header). |
|
50 // --------------------------------------------------------- |
|
51 // |
|
52 void CPosTp117::StartL() |
|
53 { |
|
54 |
|
55 // Remove all landmark databases |
|
56 RemoveAllLmDatabasesL(); |
|
57 LandmarkQueuedEvenTestL(); |
|
58 |
|
59 // Remove all landmark databases |
|
60 RemoveAllLmDatabasesL(); |
|
61 LandmarkQueuedEvenTest2L(); |
|
62 |
|
63 // Remove all landmark databases |
|
64 RemoveAllLmDatabasesL(); |
|
65 // Start test |
|
66 LandmarkEventTestL(); |
|
67 |
|
68 // Remove all landmark databases |
|
69 RemoveAllLmDatabasesL(); |
|
70 |
|
71 // Pancic test |
|
72 iActiveLmEvent = CTP117ActiveLmEvent::NewL(iLog); |
|
73 iExpectedExitType = ExitPanic; |
|
74 iLog->Log(_L("Panic test 1")); |
|
75 iTestCase = 1; |
|
76 /* EPosEventNotifierAlreadyHasOutstandingRequest defined in EPos_LandmarksServerPanics.h */ |
|
77 iExpectedErrorCode = 2; |
|
78 ResumeThreadAndVerifyExit(); |
|
79 |
|
80 delete iActiveLmEvent; |
|
81 iActiveLmEvent = NULL; |
|
82 |
|
83 |
|
84 if (iErrorsFound != KErrNone) |
|
85 { |
|
86 |
|
87 iLog->Log(_L("Errors found in TP117")); |
|
88 User::Leave(-1); |
|
89 |
|
90 } |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------- |
|
94 // CPosTp28::LandmarkQueuedEvenTestL |
|
95 // |
|
96 // (other items were commented in a header). |
|
97 // --------------------------------------------------------- |
|
98 // |
|
99 void CPosTp117::LandmarkQueuedEvenTestL() |
|
100 { |
|
101 iLog->Log(_L(">>>>>>>>>>LandmarkQueuedEvenTestL<<<<<<<<<")); |
|
102 |
|
103 _LIT(KDatabase1, "c:Tp117DummyLmDb_1.ldb"); |
|
104 _LIT(KDatabase2, "c:Tp117DummyLmDb_2.ldb"); |
|
105 _LIT(KDatabase3, "c:Tp117DummyLmDb_3.ldb"); |
|
106 _LIT(KDatabase4, "c:Tp117DummyLmDb_4.ldb"); |
|
107 |
|
108 CTP117ActiveLmEvent* client1 = CTP117ActiveLmEvent::NewL(iLog); |
|
109 CleanupStack::PushL(client1); |
|
110 |
|
111 CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); |
|
112 CleanupStack::PushL(manager); |
|
113 |
|
114 // Creates db2, which should exist (deleted below) |
|
115 client1->Start(); |
|
116 HPosLmDatabaseInfo* dbInfo2 = HPosLmDatabaseInfo::NewLC(KDatabase2); |
|
117 manager->CreateDatabaseL(*dbInfo2); |
|
118 CleanupStack::PopAndDestroy(dbInfo2); |
|
119 client1->iExpectedEvent = EPosLmDbDatabaseRegistered; |
|
120 client1->SetExpectedDatabase(KDatabase2); |
|
121 CActiveScheduler::Start(); |
|
122 |
|
123 // *********Start test************* |
|
124 iLog->Log(_L("*********Start test*************")); |
|
125 // 1) Enable client1 |
|
126 client1->Start(); |
|
127 client1->iExpectedEvent = EPosLmDbDatabaseRegistered; |
|
128 client1->SetExpectedDatabase(KDatabase1); |
|
129 |
|
130 // 2) Client2 creates a database, db1 |
|
131 iLog->Log(_L("Client2 creates a database, db1")); |
|
132 HPosLmDatabaseInfo* dbInfo1 = HPosLmDatabaseInfo::NewLC(KDatabase1); |
|
133 manager->CreateDatabaseL(*dbInfo1); |
|
134 CleanupStack::PopAndDestroy(dbInfo1); |
|
135 |
|
136 // 3) Client1 NotifyDatabaseEvent, should be event from create operation in step2 |
|
137 iLog->Log(_L("Client1 will get EDatabaseCreated event")); |
|
138 CActiveScheduler::Start(); |
|
139 |
|
140 iLog->Log(_L("Delete, Copy, Create db")); |
|
141 //4) Client2 deletes db2 |
|
142 manager->DeleteDatabaseL(KDatabase2); |
|
143 |
|
144 //5) Client2 copies db1 to db3 |
|
145 manager->CopyDatabaseL(KDatabase1, KDatabase3); |
|
146 |
|
147 //6) Client2 creates db4 |
|
148 HPosLmDatabaseInfo* dbInfo4 = HPosLmDatabaseInfo::NewLC(KDatabase4); |
|
149 manager->CreateDatabaseL(*dbInfo4); |
|
150 CleanupStack::PopAndDestroy(dbInfo4); |
|
151 |
|
152 // 7) Client1 NotifyDatabaseEvent, should be event from delete operation in step4 |
|
153 iLog->Log(_L("7) Client1 NotifyDatabaseEvent")); |
|
154 client1->Start(); |
|
155 // Dont check URI here |
|
156 client1->iCheckUri = EFalse; |
|
157 client1->iExpectedEvent = EPosLmDbDatabaseUnregistered; |
|
158 client1->SetExpectedDatabase(KDatabase2); |
|
159 CActiveScheduler::Start(); |
|
160 |
|
161 // 8) Client1 NotifyDatabaseEvent, should be event from copy operation in step5 |
|
162 iLog->Log(_L("8) Client1 NotifyDatabaseEvent")); |
|
163 client1->Start(); |
|
164 // Dont check URI here |
|
165 client1->iExpectedEvent = EPosLmDbDatabaseRegistered; |
|
166 client1->SetExpectedDatabase(KDatabase3); |
|
167 CActiveScheduler::Start(); |
|
168 |
|
169 // 9) Client1 NotifyDatabaseEvent, should be event from create operation in step6 |
|
170 iLog->Log(_L("9) Client1 NotifyDatabaseEvent")); |
|
171 // Check URI here |
|
172 client1->iCheckUri = ETrue; |
|
173 client1->Start(); |
|
174 client1->iExpectedEvent = EPosLmDbDatabaseRegistered; |
|
175 client1->SetExpectedDatabase(KDatabase4); |
|
176 CActiveScheduler::Start(); |
|
177 |
|
178 iErrorsFound+=client1->GetErrors(); |
|
179 |
|
180 CleanupStack::PopAndDestroy(manager); |
|
181 CleanupStack::PopAndDestroy(client1); |
|
182 } |
|
183 |
|
184 // --------------------------------------------------------- |
|
185 // CPosTp28::LandmarkQueuedEvenTest2L |
|
186 // |
|
187 // (other items were commented in a header). |
|
188 // --------------------------------------------------------- |
|
189 // |
|
190 void CPosTp117::LandmarkQueuedEvenTest2L() |
|
191 { |
|
192 iLog->Log(_L(">>>>>>>>>>LandmarkQueuedEvenTest2L>>>>>>>>>>")); |
|
193 |
|
194 _LIT(KDatabase1, "c:Tp117DummyLmDb_1.ldb"); |
|
195 _LIT(KDatabase2, "c:Tp117DummyLmDb_2.ldb"); |
|
196 _LIT(KDatabase3, "c:Tp117DummyLmDb_3.ldb"); |
|
197 _LIT(KDatabase4, "c:Tp117DummyLmDb_4.ldb"); |
|
198 _LIT(KDatabase5, "c:Tp117DummyLmDb_5.ldb"); |
|
199 |
|
200 CTP117ActiveLmEvent* client1 = CTP117ActiveLmEvent::NewL(iLog); |
|
201 CleanupStack::PushL(client1); |
|
202 |
|
203 CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); |
|
204 CleanupStack::PushL(manager); |
|
205 |
|
206 // Creates db2, which should exist (deleted below) |
|
207 client1->Start(); |
|
208 HPosLmDatabaseInfo* dbInfo2 = HPosLmDatabaseInfo::NewLC(KDatabase2); |
|
209 manager->CreateDatabaseL(*dbInfo2); |
|
210 CleanupStack::PopAndDestroy(dbInfo2); |
|
211 client1->iExpectedEvent = EPosLmDbDatabaseRegistered; |
|
212 client1->SetExpectedDatabase(KDatabase2); |
|
213 CActiveScheduler::Start(); |
|
214 |
|
215 // *********Start test************* |
|
216 iLog->Log(_L("*********Start test*************")); |
|
217 // 1) Enable client1 |
|
218 client1->Start(); |
|
219 client1->iExpectedEvent = EPosLmDbDatabaseRegistered; |
|
220 client1->SetExpectedDatabase(KDatabase1); |
|
221 |
|
222 // 2) Client2 creates a database, db1 |
|
223 iLog->Log(_L("Client2 creates a database, db1")); |
|
224 HPosLmDatabaseInfo* dbInfo1 = HPosLmDatabaseInfo::NewLC(KDatabase1); |
|
225 manager->CreateDatabaseL(*dbInfo1); |
|
226 CleanupStack::PopAndDestroy(dbInfo1); |
|
227 |
|
228 // 3) Client1 NotifyDatabaseEvent, should be event from create operation in step2 |
|
229 iLog->Log(_L("Client1 will get EDatabaseCreated event")); |
|
230 CActiveScheduler::Start(); |
|
231 |
|
232 iLog->Log(_L("Delete, Copy, Create, Delete, Copy, Delete")); |
|
233 //4) Client2 deletes db2 |
|
234 manager->DeleteDatabaseL(KDatabase2); |
|
235 |
|
236 //5) Client2 copies db1 to db3 |
|
237 manager->CopyDatabaseL(KDatabase1, KDatabase3); |
|
238 |
|
239 //6) Client2 creates db4 |
|
240 HPosLmDatabaseInfo* dbInfo4 = HPosLmDatabaseInfo::NewLC(KDatabase4); |
|
241 manager->CreateDatabaseL(*dbInfo4); |
|
242 CleanupStack::PopAndDestroy(dbInfo4); |
|
243 |
|
244 //7) Client2 deletes db3 |
|
245 manager->DeleteDatabaseL(KDatabase3); |
|
246 |
|
247 //8) Client2 copies db2 to db5 |
|
248 manager->CopyDatabaseL(KDatabase1, KDatabase5); |
|
249 |
|
250 //7) Client2 deletes db2 |
|
251 manager->DeleteDatabaseL(KDatabase5); |
|
252 |
|
253 // 9) Client1 NotifyDatabaseEvent, should be unknown event since too many events in queue |
|
254 // After unknown event the queue should be empty again, verified in step10 |
|
255 iLog->Log(_L("9) Client1 NotifyDatabaseEvent")); |
|
256 client1->Start(); |
|
257 client1->iExpectedEvent = EPosLmDbUnknownEvent; |
|
258 client1->SetExpectedDatabase(KNullDesC); |
|
259 CActiveScheduler::Start(); |
|
260 |
|
261 //10) Client1 deletes db4 |
|
262 client1->Start(); |
|
263 iLog->Log(_L("10) Client1 NotifyDatabaseEvent")); |
|
264 manager->DeleteDatabaseL(KDatabase4); |
|
265 client1->iExpectedEvent = EPosLmDbDatabaseUnregistered; |
|
266 client1->SetExpectedDatabase(KDatabase4); |
|
267 CActiveScheduler::Start(); |
|
268 |
|
269 iErrorsFound+=client1->GetErrors(); |
|
270 |
|
271 CleanupStack::PopAndDestroy(manager); |
|
272 CleanupStack::PopAndDestroy(client1); |
|
273 } |
|
274 |
|
275 // --------------------------------------------------------- |
|
276 // CPosTp28::LandmarkEventTestL |
|
277 // |
|
278 // (other items were commented in a header). |
|
279 // --------------------------------------------------------- |
|
280 // |
|
281 void CPosTp117::LandmarkEventTestL() |
|
282 { |
|
283 iLog->Log(_L(">>>>>>>>>>LandmarkEventTestL<<<<<<<<<<<<<<")); |
|
284 |
|
285 _LIT(KDatabase1, "c:Tp117DummyLmDb_1.ldb"); |
|
286 _LIT(KDatabase2, "c:Tp117DummyLmDb_2.ldb"); |
|
287 _LIT(KDatabase3, "c:Tp117DummyLmDb_3.ldb"); |
|
288 _LIT(KDatabase4, "c:Tp117DummyLmDb_4.ldb"); |
|
289 |
|
290 _LIT(KDatabase5, "c:Tp117DummyLmDb_5.ldb"); |
|
291 _LIT(KDatabase6, "c:Tp117DummyLmDb_6.ldb"); |
|
292 |
|
293 iActiveLmEvent = CTP117ActiveLmEvent::NewL(iLog); |
|
294 |
|
295 CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); |
|
296 CleanupStack::PushL(manager); |
|
297 |
|
298 // 1) Just do something to cause an event |
|
299 iActiveLmEvent->Start(); |
|
300 HPosLmDatabaseInfo* dbInfo1 = HPosLmDatabaseInfo::NewLC(KDatabase1); |
|
301 manager->CreateDatabaseL(*dbInfo1); |
|
302 CleanupStack::PopAndDestroy(dbInfo1); |
|
303 iActiveLmEvent->iExpectedEvent = EPosLmDbDatabaseRegistered; |
|
304 iActiveLmEvent->SetExpectedDatabase(KDatabase1); |
|
305 CActiveScheduler::Start(); |
|
306 |
|
307 iLog->Log(_L("Test 1_1")); |
|
308 iActiveLmEvent->Start(); |
|
309 HPosLmDatabaseInfo* dbInfo2 = HPosLmDatabaseInfo::NewLC(KDatabase2); |
|
310 manager->CreateDatabaseL(*dbInfo2); |
|
311 CleanupStack::PopAndDestroy(dbInfo2); |
|
312 |
|
313 iActiveLmEvent->iExpectedEvent = EPosLmDbDatabaseRegistered; |
|
314 iActiveLmEvent->SetExpectedDatabase(KDatabase2); |
|
315 CActiveScheduler::Start(); |
|
316 |
|
317 iLog->Log(_L("Cancel NotifyDatabaseEvent 1")); |
|
318 // Cancel NotifyDatabaseEvent |
|
319 iActiveLmEvent->Start(); |
|
320 iActiveLmEvent->Cancel(); |
|
321 iActiveLmEvent->Start(); |
|
322 iActiveLmEvent->Cancel(); |
|
323 |
|
324 iActiveLmEvent->Start(); |
|
325 HPosLmDatabaseInfo* dbInfo3 = HPosLmDatabaseInfo::NewLC(KDatabase3); |
|
326 manager->CreateDatabaseL(*dbInfo3); |
|
327 CleanupStack::PopAndDestroy(dbInfo3); |
|
328 iActiveLmEvent->iExpectedEvent = EPosLmDbDatabaseRegistered; |
|
329 iActiveLmEvent->SetExpectedDatabase(KDatabase3); |
|
330 CActiveScheduler::Start(); |
|
331 |
|
332 iLog->Log(_L("Cancel NotifyDatabaseEvent 2")); |
|
333 // Cancel NotifyDatabaseEvent |
|
334 iActiveLmEvent->Start(); |
|
335 iActiveLmEvent->Cancel(); |
|
336 iActiveLmEvent->Cancel(); |
|
337 |
|
338 iLog->Log(_L("Test event after cancel")); |
|
339 iActiveLmEvent->Start(); |
|
340 HPosLmDatabaseInfo* dbInfo4 = HPosLmDatabaseInfo::NewLC(KDatabase4); |
|
341 manager->CreateDatabaseL(*dbInfo4); |
|
342 CleanupStack::PopAndDestroy(dbInfo4); |
|
343 iActiveLmEvent->iExpectedEvent = EPosLmDbDatabaseRegistered; |
|
344 iActiveLmEvent->SetExpectedDatabase(KDatabase4); |
|
345 CActiveScheduler::Start(); |
|
346 |
|
347 iLog->Log(_L("Test to call DatabaseUriFromLastEventLC before events occurr")); |
|
348 iActiveLmEvent->Start(); |
|
349 HPosLmDatabaseInfo* dbInfo5 = HPosLmDatabaseInfo::NewLC(KDatabase5); |
|
350 manager->CreateDatabaseL(*dbInfo5); |
|
351 CleanupStack::PopAndDestroy(dbInfo5); |
|
352 iActiveLmEvent->iExpectedEvent = EPosLmDbDatabaseRegistered; |
|
353 iActiveLmEvent->SetExpectedDatabase(KDatabase5); |
|
354 iActiveLmEvent->CallDatabaseUriFromLastEventLC(); |
|
355 // Need to cancel this notifyDatabaseEvent call |
|
356 iActiveLmEvent->Cancel(); |
|
357 |
|
358 iLog->Log(_L("Test event3 after DatabaseUriFromLastEventLC")); |
|
359 iActiveLmEvent->Start(); |
|
360 HPosLmDatabaseInfo* dbInfo6 = HPosLmDatabaseInfo::NewLC(KDatabase6); |
|
361 manager->CreateDatabaseL(*dbInfo6); |
|
362 CleanupStack::PopAndDestroy(dbInfo6); |
|
363 iActiveLmEvent->iExpectedEvent = EPosLmDbDatabaseRegistered; |
|
364 iActiveLmEvent->SetExpectedDatabase(KDatabase6); |
|
365 CActiveScheduler::Start(); |
|
366 |
|
367 CleanupStack::PopAndDestroy(manager); |
|
368 |
|
369 iErrorsFound+=iActiveLmEvent->GetErrors(); |
|
370 |
|
371 delete iActiveLmEvent; |
|
372 iActiveLmEvent = NULL; |
|
373 } |
|
374 |
|
375 // --------------------------------------------------------- |
|
376 // CPosTp117::ResumeThreadAndVerifyExit |
|
377 // |
|
378 // (other items were commented in a header). |
|
379 // --------------------------------------------------------- |
|
380 // |
|
381 void CPosTp117::ResumeThreadAndVerifyExit() |
|
382 { |
|
383 iLog->Log(_L("ResumeThreadAndVerifyExit")); |
|
384 _LIT(KPanicErr, "Method didn't Panic when expected"); |
|
385 _LIT(KPanicCodeErr, "Paniced with unexpected panic code"); |
|
386 _LIT(KLeaveErr, "Method didn't end correctly"); |
|
387 _LIT(KLeaveCodeErr, "Unexpected leave error"); |
|
388 |
|
389 CreateThreadL(); |
|
390 TRequestStatus status; |
|
391 iThread.Logon(status); |
|
392 iThread.Resume(); |
|
393 |
|
394 User::WaitForRequest(status); |
|
395 |
|
396 // Used for debugging |
|
397 TBuf<100> buf; |
|
398 buf.Format(_L("ExitType %d Exit reason %d"), iThread.ExitType(), iThread.ExitReason()); |
|
399 iLog->Log(buf); |
|
400 |
|
401 if (iExpectedExitType == ExitPanic) |
|
402 { |
|
403 AssertTrueSecL(iThread.ExitType() == EExitPanic, KPanicErr); |
|
404 AssertTrueSecL(iThread.ExitReason() == iExpectedErrorCode, KPanicCodeErr); |
|
405 } |
|
406 else if (iExpectedExitType == ExitLeave) |
|
407 { |
|
408 AssertTrueSecL(iThread.ExitType() == EExitKill, KLeaveErr); |
|
409 AssertTrueSecL(iThread.ExitReason() == iExpectedErrorCode, KLeaveCodeErr); |
|
410 } |
|
411 iThread.Close(); |
|
412 } |
|
413 |
|
414 |
|
415 // --------------------------------------------------------- |
|
416 // CPosTp117::RunPanicTestL |
|
417 // |
|
418 // (other items were commented in a header). |
|
419 // --------------------------------------------------------- |
|
420 void CPosTp117::RunPanicTestL(TAny* /*aData*/) |
|
421 { |
|
422 |
|
423 CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); |
|
424 CleanupStack::PushL(manager); |
|
425 |
|
426 TPosLmDatabaseEvent event; |
|
427 TRequestStatus status; |
|
428 manager->NotifyDatabaseEvent(event, status); |
|
429 |
|
430 // TBD There might be timing problems on target |
|
431 User::After(100000); |
|
432 // The second call causes Panic EPosEventNotifierAlreadyHasOutstandingRequest |
|
433 manager->NotifyDatabaseEvent(event, status); |
|
434 User::After(100000); |
|
435 |
|
436 CleanupStack::PopAndDestroy(manager); |
|
437 |
|
438 } |
|
439 |
|
440 // --------------------------------------------------------- |
|
441 // LOCAL_C ThreadFunction |
|
442 // |
|
443 // (other items were commented in a header). |
|
444 // --------------------------------------------------------- |
|
445 // |
|
446 LOCAL_C TInt ThreadFunction(TAny* aData) |
|
447 { |
|
448 CTrapCleanup* cleanup=CTrapCleanup::New(); |
|
449 |
|
450 CActiveScheduler* actSch = new (ELeave) CActiveScheduler; |
|
451 CActiveScheduler::Install(actSch); |
|
452 |
|
453 TRAPD(err, CPosTp117::RunPanicTestL(aData)); |
|
454 |
|
455 delete actSch; |
|
456 delete cleanup; |
|
457 return err; |
|
458 } |
|
459 |
|
460 // --------------------------------------------------------- |
|
461 // CPosTp117::CreateThreadL |
|
462 // |
|
463 // (other items were commented in a header). |
|
464 // --------------------------------------------------------- |
|
465 // |
|
466 void CPosTp117::CreateThreadL() |
|
467 { |
|
468 _LIT(KThreadName, "Tp117 test thread"); |
|
469 _LIT(KCreateThreadErr, "Create thread failed with %d"); |
|
470 |
|
471 TInt err=0; |
|
472 err = iThread.Create(KThreadName, ThreadFunction, KDefaultStackSize, KMinHeapSize, KMaxHeapSize, this); |
|
473 AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); |
|
474 } |
|
475 |
|
476 // ----------------------------------------------------------------------------- |
|
477 // CTP117ActiveLmEvent::NewL |
|
478 // |
|
479 //(other items were commented in a header). |
|
480 // ----------------------------------------------------------------------------- |
|
481 // |
|
482 CTP117ActiveLmEvent* CTP117ActiveLmEvent::NewL(CStifLogger* aLog) |
|
483 { |
|
484 CTP117ActiveLmEvent* self = new(ELeave) CTP117ActiveLmEvent(aLog); |
|
485 CleanupStack::PushL(self); |
|
486 self->ConstructL(); |
|
487 CleanupStack::Pop(); |
|
488 return self; |
|
489 } |
|
490 |
|
491 // ----------------------------------------------------------------------------- |
|
492 // CTP117ActiveLmEvent::ConstructL |
|
493 // |
|
494 //(other items were commented in a header). |
|
495 // ----------------------------------------------------------------------------- |
|
496 // |
|
497 void CTP117ActiveLmEvent::ConstructL() |
|
498 { |
|
499 iManager = CPosLmDatabaseManager::NewL(); |
|
500 } |
|
501 |
|
502 // ----------------------------------------------------------------------------- |
|
503 // CTP117ActiveLmEvent::CTP117ActiveLmEvent |
|
504 // C++ default constructor can NOT contain any code, that |
|
505 // might leave. |
|
506 // ----------------------------------------------------------------------------- |
|
507 // |
|
508 |
|
509 CTP117ActiveLmEvent::CTP117ActiveLmEvent(CStifLogger* aLog) : |
|
510 CActive(EPriorityNormal), |
|
511 iLog(aLog) |
|
512 { |
|
513 CActiveScheduler::Add(this); |
|
514 iGlobalErr=KErrNone; |
|
515 iCheckUri = ETrue; |
|
516 } |
|
517 |
|
518 // Destructor |
|
519 CTP117ActiveLmEvent::~CTP117ActiveLmEvent() |
|
520 { |
|
521 Cancel(); |
|
522 delete iManager; |
|
523 iManager = NULL; |
|
524 } |
|
525 |
|
526 // --------------------------------------------------------- |
|
527 // CTP117ActiveLmEvent::SetExpectedDatabase |
|
528 // |
|
529 // (other items were commented in a header). |
|
530 // --------------------------------------------------------- |
|
531 // |
|
532 void CTP117ActiveLmEvent::SetExpectedDatabase(const TDesC& aDatabaseUri) |
|
533 { |
|
534 iExpectedDatabase.Zero(); |
|
535 iExpectedDatabase.Append(_L("file://")); |
|
536 iExpectedDatabase.Append(aDatabaseUri); |
|
537 } |
|
538 |
|
539 // --------------------------------------------------------- |
|
540 // CTP117ActiveLmEvent::CallNotifyDatabaseEvent |
|
541 // |
|
542 // (other items were commented in a header). |
|
543 // --------------------------------------------------------- |
|
544 // |
|
545 void CTP117ActiveLmEvent::CallNotifyDatabaseEvent() |
|
546 { |
|
547 iLog->Log(_L("CallNotifyDatabaseEvent")); |
|
548 iManager->NotifyDatabaseEvent(iEvent, iStatus); |
|
549 SetActive(); |
|
550 } |
|
551 |
|
552 // --------------------------------------------------------- |
|
553 // CTP117ActiveLmEvent::CallDatabaseUriFromLastEventLC |
|
554 // |
|
555 // (other items were commented in a header). |
|
556 // --------------------------------------------------------- |
|
557 // |
|
558 void CTP117ActiveLmEvent::CallDatabaseUriFromLastEventLC() |
|
559 { |
|
560 iLog->Log(_L("CallDatabaseUriFromLastEventLC")); |
|
561 TRAPD(err, |
|
562 CleanupStack::PopAndDestroy(iManager->DatabaseUriFromLastEventLC())); |
|
563 if (err !=KErrNone) |
|
564 { |
|
565 if (err == KErrNotFound) |
|
566 { |
|
567 iLog->Log(_L("DatabaseUriFromLastEventLC leaved with KErrNotFound")); |
|
568 } |
|
569 else |
|
570 { |
|
571 iLog->Log(_L("DatabaseUriFromLastEventLC leaved with error")); |
|
572 } |
|
573 } |
|
574 else |
|
575 { |
|
576 // No error from second call to DatabaseUriFromLastEventLC |
|
577 |
|
578 } |
|
579 } |
|
580 |
|
581 // --------------------------------------------------------- |
|
582 // CTP117ActiveLmEvent::Start |
|
583 // |
|
584 // (other items were commented in a header). |
|
585 // --------------------------------------------------------- |
|
586 // |
|
587 void CTP117ActiveLmEvent::Start() |
|
588 { |
|
589 iLog->Log(_L("CTP117ActiveLmEvent::Start")); |
|
590 // Get ready for event |
|
591 iManager->NotifyDatabaseEvent(iEvent, iStatus); |
|
592 SetActive(); |
|
593 } |
|
594 |
|
595 // --------------------------------------------------------- |
|
596 // CTP117ActiveLmEvent::RunL |
|
597 // |
|
598 // (other items were commented in a header). |
|
599 // --------------------------------------------------------- |
|
600 // |
|
601 void CTP117ActiveLmEvent::RunL() |
|
602 { |
|
603 iLog->Log(_L("CTP117ActiveLmEvent::RunL")); |
|
604 VerifyEventL(); |
|
605 } |
|
606 |
|
607 // --------------------------------------------------------- |
|
608 // CTP117ActiveLmEvent::RunError |
|
609 // |
|
610 // (other items were commented in a header). |
|
611 // --------------------------------------------------------- |
|
612 // |
|
613 TInt CTP117ActiveLmEvent::RunError(TInt aError) |
|
614 { |
|
615 iLog->Log(_L("CTP117ActiveLmEvent::RunError")); |
|
616 TBuf<100> buf; |
|
617 buf.Format(_L("Errorcode in RunError: %d"), aError); |
|
618 iLog->Log(buf); |
|
619 iGlobalErr++; |
|
620 //Error in RunL |
|
621 Cancel(); |
|
622 CActiveScheduler::Stop(); |
|
623 return aError; |
|
624 } |
|
625 |
|
626 // --------------------------------------------------------- |
|
627 // CActiveLmOperation::DoCancel |
|
628 // |
|
629 // (other items were commented in a header). |
|
630 // --------------------------------------------------------- |
|
631 // |
|
632 void CTP117ActiveLmEvent::DoCancel() |
|
633 { |
|
634 iLog->Log(_L("CTP117ActiveLmEvent::DoCancel")); |
|
635 iManager->CancelNotifyDatabaseEvent(); |
|
636 iLog->Log(_L("CTP117ActiveLmEvent::DoCancel Done")); |
|
637 } |
|
638 |
|
639 // --------------------------------------------------------- |
|
640 // CActiveLmOperation::GetErrors |
|
641 // |
|
642 // (other items were commented in a header). |
|
643 // --------------------------------------------------------- |
|
644 // |
|
645 TInt CTP117ActiveLmEvent::GetErrors() |
|
646 { |
|
647 return iGlobalErr; |
|
648 } |
|
649 |
|
650 // --------------------------------------------------------- |
|
651 // CTP117ActiveLmEvent::VerifyEvent |
|
652 // |
|
653 // (other items were commented in a header). |
|
654 // --------------------------------------------------------- |
|
655 // |
|
656 void CTP117ActiveLmEvent::VerifyEventL() |
|
657 { |
|
658 iLog->Log(_L("CTP117ActiveLmEvent::VerifyEvent")); |
|
659 |
|
660 TBuf<150> buffe; |
|
661 |
|
662 buffe.Format(_L("VerifyEvent Event: %d "), iEvent.iEventType); |
|
663 iLog->Log(buffe); |
|
664 |
|
665 // Verify event here |
|
666 if (iEvent.iEventType != iExpectedEvent) |
|
667 { |
|
668 buffe.Zero(); |
|
669 buffe.Format(_L("ERROR: Wrong event: exp %d got %d"),iExpectedEvent, iEvent.iEventType); |
|
670 iLog->Log(buffe); |
|
671 iGlobalErr++; |
|
672 } |
|
673 |
|
674 // Only do check of DatabaseUriFromLastEventLC when event is differet from unknown |
|
675 // because when this event occurs the uri is not set |
|
676 if (iCheckUri && iEvent.iEventType != EPosLmDbUnknownEvent) |
|
677 { |
|
678 HBufC16* dbUri = iManager->DatabaseUriFromLastEventLC(); |
|
679 buffe.Zero(); |
|
680 buffe.Format(_L("Event: %d URI %S"), iEvent.iEventType, dbUri); |
|
681 iLog->Log(buffe); |
|
682 |
|
683 if (iExpectedDatabase.CompareC(*dbUri) != 0) |
|
684 { |
|
685 iLog->Log(_L("ERROR: Wrong db name")); |
|
686 buffe.Zero(); |
|
687 buffe.Append(_L("Should be ")); |
|
688 buffe.Append(iExpectedDatabase); |
|
689 iLog->Log(buffe); |
|
690 iGlobalErr++; |
|
691 } |
|
692 CleanupStack::PopAndDestroy(dbUri); |
|
693 |
|
694 // Call DatabaseUriFromLastEventLC again |
|
695 TRAPD(err, |
|
696 CleanupStack::PopAndDestroy(iManager->DatabaseUriFromLastEventLC())); |
|
697 if (err !=KErrNone) |
|
698 { |
|
699 if (err == KErrNotFound) |
|
700 { |
|
701 iLog->Log(_L("Second call to DatabaseUriFromLastEventLC leaved with KErrNotFound")); |
|
702 } |
|
703 else |
|
704 { |
|
705 iLog->Log(_L("Second call to DatabaseUriFromLastEventLC leaved with error")); |
|
706 } |
|
707 } |
|
708 else |
|
709 { |
|
710 // No error from second call to DatabaseUriFromLastEventLC |
|
711 |
|
712 } |
|
713 } |
|
714 else |
|
715 { |
|
716 iLog->Log(_L("URI was not checked")); |
|
717 } |
|
718 |
|
719 CActiveScheduler::Stop(); |
|
720 |
|
721 iLog->Log(_L("VerifyEvent Done")); |
|
722 } |
|
723 |
|
724 // End of File |