Update contrib.
1 // Copyright (c) 2009-2010 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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // t_logapi2.cpp - LogEng API tests
22 #include "t_logutil2.h"
23 #include "LogServSqlStrings.h"
25 RTest TheTest(_L("t_logapi2"));
27 _LIT(KTestRemoteParty1, "Remote Party");
28 _LIT(KTestDirection1, "Direction");
29 _LIT(KTestStatus1, "Status");
30 _LIT(KTestSubject1, "Subject");
31 const TUid KTestEventUid = {0x10005393};
32 const TLogDurationType KTestDurationType1 = 1;
33 const TLogDuration KTestDuration1 = 0x1234;
34 const TLogContactItemId KTestContact1 = 0x1234;
35 const TLogLink KTestLink1 = 0x1234;
36 _LIT8(KTestData1, "ABCDEFGH");
37 const TLogFlags KTestFlags1 = 0x5;
38 _LIT(KEvNumber1, "11119999");
39 _LIT(KEvNumber2, "22226666");
40 const TLogDurationType KEvDurationType1 = 1;
41 const TLogDurationType KEvDurationType2 = 2;
42 const TLogContactItemId KEvContact1 = 1010;
43 const TLogLink KEvLink1 = 2000;
44 _LIT(KEvDesc1, "Event Type Description 1");
46 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
47 const TSimId KEvSimId1 = 3000000910U;//Bigger than KMaxTInt, to check that SQL statement formatting works as expected
48 const TSimId KEvSimId2 = 2911;
51 const TInt KDiffEvCount = 10;
53 //KEvDirection2 used together with KEvTypeUid guarantees that the properties of the event being changed
54 //match the conditions of one the LogEng server recent lists and thus the "recent list" related functionality
55 //on the server side will be used.
56 _LIT(KEvDirection2, "Incoming");
58 const TUid KEvTypeUid = {KLogCallEventType};
59 const TUid KEvTypeUidLoggingDisabled = {0x447422};
61 enum TLogAddEventOps {ELogOpAddEvent, ELogOpAddEventInvalidType, ELogOpAddEventLoggingDisabled};
62 enum TLogGetEventOps {ELogOpGetEvent, ELogOpGetEventZeroId, ELogOpGetEventNotExists};
65 TInt TheAddedEventCount = -1;
66 TInt TheMaxLogSize = -1;
68 //The default max log size is 1000. But the test timeouts on hardware with max log size of 1000.
69 const TInt KMaxLogSize = 200;
70 const TInt KMaxRecentLogSize = 10; // Default recent log size is 20
71 const TInt KMaxPlusEvCount = 100; //Added events count on top of the max log size
73 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
75 //Add a new event type with "logging disabled"
76 void DoAddEventTypeL(CLogClient& aClient, CTestActive& aActive)
78 CLogEventType* type = CLogEventType::NewL();
79 CleanupStack::PushL(type);
81 type->SetUid(KEvTypeUidLoggingDisabled);
82 type->SetDescription(_L("110111011011"));
83 type->SetLoggingEnabled(EFalse);
85 aClient.AddEventType(*type, aActive.iStatus);
87 CActiveScheduler::Start();
88 TEST2(aActive.iStatus.Int(), KErrNone);
90 CleanupStack::PopAndDestroy(type);
93 void DoSetNewMaxLogSizeL(CLogClient& aClient, CTestActive& aActive)
95 //Check what is the max log size.
98 aClient.GetConfig(config, aActive.iStatus);
99 CActiveScheduler::Start();
100 TEST2(aActive.iStatus.Int(), KErrNone);
101 //Set new max log size
102 config.iMaxLogSize = KMaxLogSize;
104 aClient.ChangeConfig(config, aActive.iStatus);
105 CActiveScheduler::Start();
106 TEST2(aActive.iStatus.Int(), KErrNone);
107 //Test the new max log size
109 aClient.GetConfig(config, aActive.iStatus);
110 CActiveScheduler::Start();
111 TEST2(aActive.iStatus.Int(), KErrNone);
112 TEST2(config.iMaxLogSize, KMaxLogSize);
114 TheMaxLogSize = config.iMaxLogSize;
115 TheAddedEventCount = config.iMaxLogSize + KMaxPlusEvCount;
120 CLogClient* client = CLogClient::NewL(theFs);
121 CleanupStack::PushL(client);
122 CTestActive* active = new(ELeave)CTestActive();
123 CleanupStack::PushL(active);
125 //Set new max log size
126 DoSetNewMaxLogSizeL(*client, *active);
128 //Add TheAddedEventCount events. Some of them with SimId, some - not.
129 //This certainly will involve some log purging operations when the log size reaches the max.
130 CLogEvent* event = CLogEvent::NewL();
131 CleanupStack::PushL(event);
132 event->SetEventType(KLogCallEventTypeUid);
133 event->SetRemoteParty(KTestRemoteParty1);
134 event->SetDirection(KTestDirection1);
135 event->SetDurationType(KEvDurationType1);
136 event->SetDuration(KTestDuration1);
137 event->SetStatus(KTestStatus1);
138 event->SetSubject(KTestSubject1);
139 event->SetNumber(KEvNumber1);
140 event->SetContact(KEvContact1);
141 event->SetLink(KEvLink1);
142 event->SetDescription(KEvDesc1);
143 event->SetFlags(KTestFlags1);
144 event->SetDataL(KTestData1);
147 st_time.UniversalTime();
149 TheTest.Printf(_L("Added events:\n"));
150 TInt diffEvCount = KDiffEvCount;
151 for(TInt i=0;i<TheAddedEventCount;++i)
153 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
154 event->SetSimId(KLogNullSimId);
156 event->SetDurationType(KEvDurationType1);
157 event->SetNumber(KEvNumber1);
160 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
161 event->SetSimId(KEvSimId1);
163 if((i > TheMaxLogSize / 2 + 1) && (i % 10) == 0 && --diffEvCount >= 0)
164 {//Add after the second half because when the log grows above the max log size, the first events will be deleted
165 event->SetDurationType(KEvDurationType2);
166 event->SetNumber(KEvNumber2);
170 client->AddEvent(*event, active->iStatus);
171 CActiveScheduler::Start();
172 TEST(!active->IsActive());
173 TEST2(active->iStatus.Int(), KErrNone);
174 if((i % 50) == 0 && i > 0)
176 TheTest.Printf(_L("%d\r"), i);
179 TheTest.Printf(_L("%d\n"), TheAddedEventCount);
182 end_time.UniversalTime();
184 CleanupStack::PopAndDestroy(event);
186 CleanupStack::PopAndDestroy(active);
187 CleanupStack::PopAndDestroy(client);
189 TTimeIntervalMicroSeconds us = end_time.MicroSecondsFrom(st_time);
190 TheTest.Printf(_L("%d events added. Time: %ld milliseconds\n"), TheAddedEventCount, us.Int64() / 1000);
193 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
196 @SYMTestCaseID PDS-LOGENG-UT-4042
197 @SYMTestCaseDesc "Cancel operation" test.
198 The test uses RLogTestSession to establish a connection with the EventViewer server.
199 The the test initializes an "Add Event" opertaion.
200 But instead of completing the operation the test cancels it.
201 @SYMTestActions "Cancel operation" test.
202 @SYMTestExpectedResults Test must not fail
203 @SYMTestPriority Medium
206 void CancelOperationTest()
208 RLogTestSession sess;
209 TInt err = sess.Connect();
210 TEST2(err, KErrNone);
212 CLogEvent* event = NULL;
213 TRAP(err, event = CLogEvent::NewL());
214 TEST2(err, KErrNone);
215 event->SetEventType(KTestEventUid);
216 event->SetRemoteParty(KTestRemoteParty1);
217 event->SetDirection(KTestDirection1);
218 event->SetDurationType(KTestDurationType1);
219 event->SetDuration(KTestDuration1);
220 event->SetStatus(KTestStatus1);
221 event->SetSubject(KTestSubject1);
222 event->SetContact(KTestContact1);
223 event->SetLink(KTestLink1);
224 TRAP(err, event->SetDataL(KTestData1));
225 TEST2(err, KErrNone);
226 event->SetFlags(KTestFlags1);
229 RDesWriteStream strm(buf);
230 TRAP(err, event->ExternalizeL(strm));
231 TEST2(err, KErrNone);
232 TRAP(err, strm.CommitL());
233 TEST2(err, KErrNone);
235 TPckgBuf<TLogClientServerData> data;
236 data().iOperationType = ELogOperationEventAdd;
237 data().iOperationId = KLogNullOperationId;
240 TIpcArgs args1(&data, &buf);
241 sess.Send(ELogOperationInitiate, args1, stat);
242 TEST2(stat.Int(), KRequestPending);
243 TIpcArgs args2(&data);
244 err = sess.Send(ELogOperationCancel, args2);
245 TEST2(err, KErrCancel);
246 User::WaitForRequest(stat);
248 TEST2(err, KErrCancel);
256 @SYMTestCaseID PDS-LOGENG-UT-4029
257 @SYMTestCaseDesc AddEvent() server side OOM test.
258 This test uses the results from the previous test cases that
259 the LogEng database contains TheMaxLogSize events.
260 This ensures that the "purge main" functionality on the server side
262 The properties of the event being added are such (KEvDirection1 and KEvTypeUid) that
263 one of the LogServ recent lists will be used. This ensures that the "purge recent"
264 LogEng server functionality will be used.
265 The test, as any other of the LogEng server OOM tests, does not fully cover the used on the
266 server side functions, because:
267 1) CLogAddEvent will set the iEventAdded flag right after adding the event to the database.
268 After that, any OOM failure that occurs for example in "purge recent" related calls, will be
270 2) CLogEvent will use the CLogDuplicate active object for the "purge recent" action.
271 When CLogDuplicate fails with KErrNoMemory in DoRunL(), the error is ignored and not reported
273 @SYMTestActions AddEvent() server side OOM test.
274 @SYMTestExpectedResults Test must not fail
275 @SYMTestPriority Medium
278 void AddEventOomTestL(TLogAddEventOps aLogAddEventOp, TInt aExpectedError)
280 CLogClient* client = CLogClient::NewL(theFs);
281 CleanupStack::PushL(client);
282 CTestActive* active = new(ELeave)CTestActive();
283 CleanupStack::PushL(active);
284 CLogEvent* event = CLogEvent::NewL();
285 CleanupStack::PushL(event);
287 if(aLogAddEventOp == ELogOpAddEventLoggingDisabled)
289 DoAddEventTypeL(*client, *active);
295 TUid eventType = KEvTypeUid;
296 if(aLogAddEventOp == ELogOpAddEventInvalidType)
298 eventType = TUid::Uid(0x445972);
300 else if(aLogAddEventOp == ELogOpAddEventLoggingDisabled)
302 eventType = KEvTypeUidLoggingDisabled;
305 event->SetEventType(eventType);
306 event->SetRemoteParty(KTestRemoteParty1);
307 event->SetDirection(KTestDirection1);
308 event->SetDurationType(KEvDurationType1);
309 event->SetDuration(KTestDuration1);
310 event->SetStatus(KTestStatus1);
311 event->SetSubject(KTestSubject1);
312 event->SetNumber(KEvNumber1);
313 event->SetContact(KEvContact1);
314 event->SetLink(KEvLink1);
315 event->SetDescription(KEvDesc1);
316 event->SetFlags(KTestFlags1);
317 event->SetDataL(KTestData1);
318 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
319 event->SetSimId(KEvSimId1);
323 TBool finished = EFalse;
327 __LOGSERV_UHEAP_FAILNEXT(++failCount);
328 client->AddEvent(*event, active->iStatus);
330 CActiveScheduler::Start();
332 if(active->iStatus.Int() == aExpectedError)
337 __LOGSERV_UHEAP_RESET;
339 if(active->iStatus.Int() != aExpectedError)
341 TEST2(active->iStatus.Int(), KErrNoMemory);
345 TEST2(active->iStatus.Int(), aExpectedError);
346 if(aLogAddEventOp == ELogOpAddEvent)
348 TEST(event->Time() >= now);
350 client->GetEvent(*event, active->iStatus);
351 CActiveScheduler::Start();
352 TEST2(active->iStatus.Int(), KErrNone);
353 TheEvId = event->Id();
357 CleanupStack::PopAndDestroy(event);
358 CleanupStack::PopAndDestroy(active);
359 CleanupStack::PopAndDestroy(client);
361 TheTest.Printf(_L("===CLogClient::AddEvent() server side OOM test succeeded at iteration %d\n"), failCount);
365 @SYMTestCaseID PDS-LOGENG-UT-4030
366 @SYMTestCaseDesc ChangeEvent() server side OOM test.
367 This test uses the results from the previous test cases that
368 the LogEng database contains TheMaxLogSize events.
369 This ensures that the "purge main" functionality on the server side
371 The properties of the event being changed are such (KEvDirection2 and KEvTypeUid) that
372 one of the LogServ recent lists will be used. This ensures that the "purge recent"
373 LogEng server functionality will be used.
374 @SYMTestActions ChangeEvent() server side OOM test.
375 @SYMTestExpectedResults Test must not fail
376 @SYMTestPriority Medium
379 void ChangeEventOomTestL(TBool aEventExists)
381 CLogClient* client = CLogClient::NewL(theFs);
382 CleanupStack::PushL(client);
383 CTestActive* active = new(ELeave)CTestActive();
384 CleanupStack::PushL(active);
385 CLogEvent* event = CLogEvent::NewL();
386 CleanupStack::PushL(event);
388 event->SetId(TheEvId);
390 client->GetEvent(*event, active->iStatus);
391 CActiveScheduler::Start();
392 TEST2(active->iStatus.Int(), KErrNone);
393 TEST2(TheEvId, event->Id());
394 event->SetDirection(KEvDirection2);
395 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
396 event->SetSimId(KEvSimId2);
400 TBool finished = EFalse;
403 {//Search for a non-existing event in the OOM loop
404 event->SetId(TheEvId + 5678);
409 __LOGSERV_UHEAP_FAILNEXT(++failCount);
410 client->ChangeEvent(*event, active->iStatus);
412 CActiveScheduler::Start();
414 TInt err = active->iStatus.Int();
415 if(err == (aEventExists ? KErrNone : KErrNotFound))
420 __LOGSERV_UHEAP_RESET;
422 if(err != (aEventExists ? KErrNone : KErrNotFound))
424 TEST2(err, KErrNoMemory);
429 client->GetEvent(*event, active->iStatus);
430 CActiveScheduler::Start();
433 TEST2(active->iStatus.Int(), KErrNone);
434 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
435 TEST2(event->SimId(), KEvSimId2);
440 TEST2(active->iStatus.Int(), KErrNotFound);
443 CleanupStack::PopAndDestroy(event);
444 CleanupStack::PopAndDestroy(active);
445 CleanupStack::PopAndDestroy(client);
447 TheTest.Printf(_L("===CLogClient::ChangeEvent() server side OOM test succeeded at iteration %d\n"), failCount);
451 @SYMTestCaseID PDS-LOGENG-UT-4031
452 @SYMTestCaseDesc DeleteEvent() server side OOM test.
453 This test uses the results from the previous test cases that
454 the LogEng database contains TheMaxLogSize events.
455 This ensures that the "purge main" functionality on the server side
457 @SYMTestActions DeleteEvent() server side OOM test.
458 @SYMTestExpectedResults Test must not fail
459 @SYMTestPriority Medium
462 void DeleteEventOomTestL(TBool aEventExists)
464 CLogClient* client = CLogClient::NewL(theFs);
465 CleanupStack::PushL(client);
466 CTestActive* active = new(ELeave)CTestActive();
467 CleanupStack::PushL(active);
470 TBool finished = EFalse;
474 __LOGSERV_UHEAP_FAILNEXT(++failCount);
475 client->DeleteEvent(TheEvId, active->iStatus);
477 CActiveScheduler::Start();
479 TInt err = active->iStatus.Int();
480 if(err == (aEventExists ? KErrNone : KErrNotFound))
485 __LOGSERV_UHEAP_RESET;
487 if(err != (aEventExists ? KErrNone : KErrNotFound))
489 TEST2(err, KErrNoMemory);
493 CLogEvent* event = CLogEvent::NewL();
494 CleanupStack::PushL(event);
495 event->SetId(TheEvId);
497 client->GetEvent(*event, active->iStatus);
498 CActiveScheduler::Start();
499 TEST2(active->iStatus.Int(), KErrNotFound);
500 CleanupStack::PopAndDestroy(event);
502 CleanupStack::PopAndDestroy(active);
503 CleanupStack::PopAndDestroy(client);
505 TheTest.Printf(_L("===CLogClient::DeleteEvent() server side OOM test succeeded at iteration %d\n"), failCount);
509 @SYMTestCaseID PDS-LOGENG-UT-4032
510 @SYMTestCaseDesc GetEvent() server side OOM test.
511 This test uses the results from the previous test cases that
512 the LogEng database contains TheMaxLogSize events.
513 GetEvent() is executed in OOM loop.
514 @SYMTestActions GetEvent() server side OOM test.
515 @SYMTestExpectedResults Test must not fail
516 @SYMTestPriority Medium
519 void GetEventOomTestL(TLogGetEventOps aGetEventOp, TInt aExpectedError)
521 CLogClient* client = CLogClient::NewL(theFs);
522 CleanupStack::PushL(client);
523 CTestActive* active = new(ELeave)CTestActive();
524 CleanupStack::PushL(active);
525 CLogEvent* event = CLogEvent::NewL();
526 CleanupStack::PushL(event);
528 event->SetId(aGetEventOp == ELogOpGetEvent ? TheEvId : (aGetEventOp == ELogOpGetEventNotExists ? 0x932271F : 0x0));
531 TBool finished = EFalse;
535 __LOGSERV_UHEAP_FAILNEXT(++failCount);
536 client->GetEvent(*event, active->iStatus);
538 CActiveScheduler::Start();
540 if(active->iStatus.Int() == aExpectedError)
545 __LOGSERV_UHEAP_RESET;
547 if(active->iStatus.Int() != aExpectedError)
549 TEST2(active->iStatus.Int(), KErrNoMemory);
553 TEST2(active->iStatus.Int(), aExpectedError);
554 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
555 if(aGetEventOp == ELogOpGetEvent)
557 TEST2(event->SimId(), KEvSimId2);
561 CleanupStack::PopAndDestroy(event);
562 CleanupStack::PopAndDestroy(active);
563 CleanupStack::PopAndDestroy(client);
565 TheTest.Printf(_L("===CLogClient::GetEvent() server side OOM test succeeded at iteration %d\n"), failCount);
569 @SYMTestCaseID PDS-LOGENG-UT-4033
570 @SYMTestCaseDesc Change Event Type test.
571 The test attempts to change the type of an existing event.
572 The attempt must fails with KErrPermissionDenied error.
573 @SYMTestActions Change Event Type test.
574 @SYMTestExpectedResults Test must not fail
575 @SYMTestPriority Medium
578 void ChangeStandardEventTypeTestL()
580 CLogClient* client = CLogClient::NewL(theFs);
581 CleanupStack::PushL(client);
582 CTestActive* active = new(ELeave)CTestActive();
583 CleanupStack::PushL(active);
585 CLogEventType* evType = CLogEventType::NewL();
586 CleanupStack::PushL(evType);
587 TUid uid = {KLogCallEventType};
589 evType->SetDescription(_L("aaaaaaaa"));
592 client->ChangeEventType(*evType, active->iStatus);
593 CActiveScheduler::Start();
594 TEST2(active->iStatus.Int(), KErrPermissionDenied);
596 CleanupStack::PopAndDestroy(evType);
598 CleanupStack::PopAndDestroy(active);
599 CleanupStack::PopAndDestroy(client);
602 CLogFilter* DoCreateFilter1LC()
604 CLogFilter* filter = CLogFilter::NewL();
605 CleanupStack::PushL(filter);
607 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
608 filter->SetSimId(KEvSimId2);
610 filter->SetDurationType(KEvDurationType2);
611 filter->SetNumber(KEvNumber2);
612 filter->SetStatus(KTestStatus1);
613 filter->SetDirection(KTestDirection1);
618 CLogFilter* DoCreateFilter2LC()
620 CLogFilter* filter = CLogFilter::NewL();
621 CleanupStack::PushL(filter);
623 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
624 filter->SetSimId(KEvSimId1);
626 filter->SetDurationType(KEvDurationType1);
627 filter->SetNumber(KEvNumber1);
628 filter->SetStatus(KTestStatus1);
629 filter->SetDirection(KTestDirection1);
630 filter->SetEventType(KEvTypeUid);
631 filter->SetRemoteParty(KTestRemoteParty1);
632 filter->SetNullFields(ELogFlagsField);
637 CLogFilter* DoCreateFilter3LC()
639 CLogFilter* filter = CLogFilter::NewL();
640 CleanupStack::PushL(filter);
642 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
643 filter->SetSimId(KEvSimId1);
645 filter->SetDurationType(KEvDurationType1);
646 filter->SetNumber(KEvNumber1);
647 filter->SetStatus(KTestStatus1);
648 filter->SetDirection(KTestDirection1);
649 filter->SetEventType(KEvTypeUid);
650 filter->SetRemoteParty(KTestRemoteParty1);
651 filter->SetContact(KEvContact1);
652 filter->SetNullFields(ELogFlagsField);
658 @SYMTestCaseID PDS-LOGENG-UT-4034
659 @SYMTestCaseDesc Complex view filter set test.
660 The test creates a set of filters using all event properties and duplicating some of them
661 in the filters. Then sets the set of filters to a view and iterates over the view's events.
662 The idea is to test as much as possible the server side filter processing in TLogFilterExprBuilder
663 class implementation.
664 @SYMTestActions Complex view filter set test.
665 @SYMTestExpectedResults Test must not fail
666 @SYMTestPriority Medium
669 void ComplexFilterSetTestL()
671 CLogClient* client = CLogClient::NewL(theFs);
672 CleanupStack::PushL(client);
673 CTestActive* active = new(ELeave)CTestActive();
674 CleanupStack::PushL(active);
675 CLogViewEvent* view = CLogViewEvent::NewL(*client);
676 CleanupStack::PushL(view);
677 CLogFilter* filter1 = DoCreateFilter1LC();
678 CLogFilter* filter2 = DoCreateFilter2LC();
679 CLogFilter* filter3 = DoCreateFilter3LC();
680 CLogFilterList* filterList = new(ELeave)CLogFilterList;
681 CleanupStack::PushL(filterList);
682 filterList->AppendL(filter1);
683 filterList->AppendL(filter2);
684 filterList->AppendL(filter3);
686 //Check the "copy filter list" operations
687 CLogFilterList* filterList2 = filterList->CopyL();
688 TEST2(filterList2->Count(), filterList->Count());
690 CLogFilterList* filterList3 = filterList->CopyLC();
691 TEST2(filterList3->Count(), filterList->Count());
692 CleanupStack::PopAndDestroy(filterList3);
695 st_time.UniversalTime();
696 TBool res = view->SetFilterL(*filterList, active->iStatus);
699 CActiveScheduler::Start();
700 TEST2(active->iStatus.Int(), KErrNone);
701 TInt count = view->CountL();
702 TheTest.Printf(_L("===Events count: %d\n"), count);
704 end_time.UniversalTime();
705 TTimeIntervalMicroSeconds us = end_time.MicroSecondsFrom(st_time);
706 TheTest.Printf(_L("SetFilter(). Time: %ld milliseconds\n"), us.Int64() / 1000);
708 st_time.UniversalTime();
709 if(view->FirstL(active->iStatus))
715 CActiveScheduler::Start();
716 TEST2(active->iStatus.Int(), KErrNone);
719 while(view->NextL(active->iStatus));
721 end_time.UniversalTime();
722 us = end_time.MicroSecondsFrom(st_time);
723 TheTest.Printf(_L("Event view walk completed. Events count: %d. Time: %ld milliseconds\n"), count, us.Int64() / 1000);
725 CleanupStack::PopAndDestroy(filterList);
726 CleanupStack::PopAndDestroy(filter3);
727 CleanupStack::PopAndDestroy(filter2);
728 CleanupStack::PopAndDestroy(filter1);
729 CleanupStack::PopAndDestroy(view);
730 CleanupStack::PopAndDestroy(active);
731 CleanupStack::PopAndDestroy(client);
735 static void StopLogServerL()
737 static RLogTestSession logServSession;
738 //this function doesn't have any effect on UREL builds as LogEng server doesn't
739 //support the transient mode in UREL builds
740 //Used for LogEng server side heap failure testing.
741 TInt error = KErrNone;
743 if(!logServSession.Handle())
745 error = logServSession.Connect();
748 // Is the server running?
749 if(error == KErrNotFound)
753 LEAVE_IF_ERROR(error);
755 // Make the server transient
757 TIpcArgs ipcArgs(p0);
758 LEAVE_IF_ERROR(logServSession.Send(ELogMakeTransient, ipcArgs));
760 logServSession.Close();
762 User::After(6 * 1000000); // Enough time for the server to exit
765 static void StopLogServerL()
767 TheTest.Printf(_L("StopLogServerL(): the LogEng server cannot be stopped in release mode. ELogMakeTransient is a debug message.\n"));
772 @SYMTestCaseID PDS-LOGENG-UT-4047
773 @SYMTestCaseDesc Configuration value update test.
774 The test changes the configuration values & thne stops the log server. Start the
775 server again & check if the configuration values are updated.
776 Again restores the original value back.
777 @SYMTestActions Configuration value update test.
778 @SYMTestExpectedResults Test must not fail
779 @SYMTestPriority Medium
782 void DoCheckUpdateConfigL()
785 CLogClient* client = CLogClient::NewL(theFs);
786 CleanupStack::PushL(client);
787 CTestActive* active = new(ELeave)CTestActive();
788 CleanupStack::PushL(active);
790 //Check for updated configurations.
793 client->GetConfig(config, active->iStatus);
794 CActiveScheduler::Start();
795 TEST2(active->iStatus.Int(), KErrNone);
797 //Set new max log size
798 TLogSize tmpMaxLogSize = config.iMaxLogSize;
799 config.iMaxLogSize = KMaxLogSize;
800 config.iMaxRecentLogSize = KMaxRecentLogSize;
802 client->ChangeConfig(config, active->iStatus);
803 CActiveScheduler::Start();
804 TEST2(active->iStatus.Int(), KErrNone);
809 //Test the new max log size
811 client->GetConfig(config, active->iStatus);
812 CActiveScheduler::Start();
813 TEST2(active->iStatus.Int(), KErrNone);
814 TEST2(config.iMaxLogSize, KMaxLogSize);
816 //Set original max log size
817 config.iMaxLogSize = tmpMaxLogSize;
819 client->ChangeConfig(config, active->iStatus);
820 CActiveScheduler::Start();
821 TEST2(active->iStatus.Int(), KErrNone);
823 CleanupStack::PopAndDestroy(active);
824 CleanupStack::PopAndDestroy(client);
827 //////////////////////////////////////////////////////////////////////////////////////////////////////
830 TLogId DoAddEvent2TestRecentListL(CLogClient& aClient, CTestActive& aActive)
832 CLogEvent* event = CLogEvent::NewL();
833 CleanupStack::PushL(event);
835 event->SetEventType(KLogCallEventTypeUid);
836 event->SetRemoteParty(KLogRctTListRemoteParty);
837 event->SetDirection(KLogRctTListDirection);
838 event->SetDurationType(KLogRctTListDurationType);
839 event->SetDuration(KTestDuration1);
840 event->SetStatus(KLogRctTListStatus);
841 event->SetSubject(KTestSubject1);
842 event->SetNumber(KLogRctTListNumber);
843 event->SetContact(KEvContact1);
844 event->SetLink(KEvLink1);
845 event->SetDescription(KEvDesc1);
846 event->SetFlags(KLogRctTListFlags);
847 event->SetDataL(KTestData1);
848 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
849 event->SetSimId(KLogRctTListSimId);
853 aClient.AddEvent(*event, aActive.iStatus);
854 CActiveScheduler::Start();
855 TEST(!aActive.IsActive());
856 TEST2(aActive.iStatus.Int(), KErrNone);
857 TLogId logId = event->Id();
859 //Get the just added event
861 aClient.GetEvent(*event, aActive.iStatus);
862 CActiveScheduler::Start();
863 TEST2(aActive.iStatus.Int(), KErrNone);
865 CleanupStack::PopAndDestroy(event);
870 TLogId DoAddEvent2TestRecentListL()
872 CLogClient* client = CLogClient::NewL(theFs);
873 CleanupStack::PushL(client);
874 CTestActive* active = new(ELeave)CTestActive();
875 CleanupStack::PushL(active);
877 TLogId logId = DoAddEvent2TestRecentListL(*client, *active);
879 CleanupStack::PopAndDestroy(active);
880 CleanupStack::PopAndDestroy(client);
885 struct TLogViewTestObserver : public MLogViewChangeObserver
887 TLogViewTestObserver() :
893 virtual void HandleLogViewChangeEventAddedL(TLogId aId, TInt, TInt, TInt)
897 virtual void HandleLogViewChangeEventChangedL(TLogId aId, TInt, TInt, TInt)
901 virtual void HandleLogViewChangeEventDeletedL(TLogId aId, TInt, TInt, TInt)
910 void DoViewEventFromTestRecentListL(TLogId aId1, TLogId aId2)
912 CLogClient* client = CLogClient::NewL(theFs);
913 CleanupStack::PushL(client);
914 CTestActive* active = new(ELeave)CTestActive();
915 CleanupStack::PushL(active);
916 CLogViewRecent* view = CLogViewRecent::NewL(*client);
917 CleanupStack::PushL(view);
918 TLogViewTestObserver observer;
919 CLogViewDuplicate* duplicate = CLogViewDuplicate::NewL(*client, observer);
920 CleanupStack::PushL(duplicate);
922 TBool rc = view->SetRecentListL(KLogRctTListId, active->iStatus);
924 CActiveScheduler::Start();
925 TEST2(active->iStatus.Int(), KErrNone);
928 if(view->FirstL(active->iStatus))
933 CActiveScheduler::Start();
934 TEST2(active->iStatus.Int(), KErrNone);
935 const CLogEvent& e = view->Event();
939 while(view->NextL(active->iStatus));
941 TEST2(count, 1);//The second event is a duplicate => not in the list
945 rc = view->DuplicatesL(*duplicate, active->iStatus);
947 CActiveScheduler::Start();
948 TEST2(active->iStatus.Int(), KErrNone);
949 TEST2(duplicate->CountL(), 1);
951 //Test the duplicated event
952 rc = duplicate->FirstL(active->iStatus);
955 CActiveScheduler::Start();
956 TEST2(active->iStatus.Int(), KErrNone);
957 const CLogEvent& e2 = duplicate->Event();
958 TEST2(aId1, e2.Id());
961 CLogEvent* event = CLogEvent::NewL();
962 CleanupStack::PushL(event);
965 client->GetEvent(*event, active->iStatus);
966 CActiveScheduler::Start();
967 TEST2(active->iStatus.Int(), KErrNone);
969 //Change the event. The observer should register the change.
970 event->SetDataL(_L8("123444555"));
971 client->ChangeEvent(*event, active->iStatus);
973 CActiveScheduler::Start();
974 TEST2(active->iStatus.Int(), KErrNone);
975 TEST2(observer.iIdChanged, event->Id());
977 //Add a new event to the recent list. This operation should be detected as a "delete" one by the observer
978 //and the existing event should be cleared from the recent list.
979 TLogId logId = DoAddEvent2TestRecentListL(*client, *active);
980 TEST2(observer.iIdDeleted, aId1);
981 TEST(logId != observer.iIdDeleted);
982 //No added events detected by the observer
983 TEST2(observer.iIdAdded, -1);
986 CleanupStack::PopAndDestroy(event);
987 CleanupStack::PopAndDestroy(duplicate);
988 CleanupStack::PopAndDestroy(view);
989 CleanupStack::PopAndDestroy(active);
990 CleanupStack::PopAndDestroy(client);
994 @SYMTestCaseID PDS-LOGENG-UT-4035
995 @SYMTestCaseDesc Complex recent list test.
996 The test works only if SYSLIBS_TEST macro is defined, in which case the server side will
997 create a recent list with a lot of fields.
998 The test case will add 2 events with the same properties, such that both will be added
999 to that test recent list. Because the second event is a match of the first one and matches
1000 the recent list "duplicates" mask, the second event will be marked as a duplicate of the
1001 first one. After adding the events a view is used to check for their presence.
1002 @SYMTestActions Complex recent list test.
1003 @SYMTestExpectedResults Test must not fail
1004 @SYMTestPriority Medium
1007 void ComplexRecentListTestL()
1009 TLogId logId1 = DoAddEvent2TestRecentListL();
1010 TLogId logId2 = DoAddEvent2TestRecentListL();
1011 DoViewEventFromTestRecentListL(logId1, logId2);
1014 #endif//SYSLIBS_TEST
1015 //////////////////////////////////////////////////////////////////////////////////////////////////////
1019 TestUtils::Initialize(_L("t_logapi2"));
1020 TestUtils::DeleteDatabaseL();
1022 TheTest.Start(_L("Preparation. Adding 200 events..."));
1024 TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4029: AddEvent() server side OOM test when logged events count is max (200)"));
1025 AddEventOomTestL(ELogOpAddEvent, KErrNone);
1026 TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4029: AddEvent() server side OOM test when logged events count is max (200). Invalid event type."));
1027 AddEventOomTestL(ELogOpAddEventInvalidType, KErrNotFound);
1028 TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4030: AddEvent() server side OOM test when logged events count is max (200). Logging disabled."));
1029 AddEventOomTestL(ELogOpAddEventLoggingDisabled, KErrNotSupported);
1030 TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4030: ChangeEvent() server side OOM test when logged events count is max (200). The event does exist."));
1031 ChangeEventOomTestL(ETrue);
1032 TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4030: ChangeEvent() server side OOM test when logged events count is max (200). The event does not exist."));
1033 ChangeEventOomTestL(EFalse);
1034 TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4032: GetEvent() server side OOM test when logged events count is max (200)."));
1035 GetEventOomTestL(ELogOpGetEvent, KErrNone);
1036 TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4032: GetEvent() server side OOM test when logged events count is max (200). The event does not exist."));
1037 GetEventOomTestL(ELogOpGetEventNotExists, KErrNotFound);
1038 TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4032: GetEvent() server side OOM test when logged events count is max (200). The event id is 0."));
1039 GetEventOomTestL(ELogOpGetEventZeroId, KErrNotFound);
1040 TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4031: DeleteEvent() server side OOM test when logged events count is max (200). The event does exist."));
1041 DeleteEventOomTestL(ETrue);
1042 TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4031: DeleteEvent() server side OOM test when logged events count is max (200). The event does not exist."));
1043 DeleteEventOomTestL(EFalse);
1044 TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4033: Attempt to change one of the standard event types."));
1045 ChangeStandardEventTypeTestL();
1046 TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4042: \"Cancel Operation\" test"));
1047 CancelOperationTest();
1048 TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4034: Complex filter set test."));
1049 ComplexFilterSetTestL();
1050 TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4047: Check for updated configuration values"));
1051 DoCheckUpdateConfigL();
1053 TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4035: Complex recent list test."));
1054 ComplexRecentListTestL();
1057 TestUtils::DeleteDatabaseL();