loggingservices/eventlogger/test/src/t_logcompat.cpp
changeset 0 08ec8eefde2f
child 11 667e88a979d7
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     1 // Copyright (c) 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 // t_logcompat.cpp - verification that old databases without SimId column in Event table can be opened
       
    15 //                   and events added, viewed, etc.  
       
    16 // 
       
    17 //
       
    18 #include <s32file.h>
       
    19 #include <s32mem.h>
       
    20 #include <e32math.h>
       
    21 #include <bautils.h>
       
    22 #include <logview.h>
       
    23 #include "TEST.H"
       
    24 
       
    25 #undef test  //there is a "test" macro which hides "RTest test" declaration.
       
    26 
       
    27 RTest test(_L("LogEng compatibility"));
       
    28 
       
    29 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
       
    30 
       
    31 // These values are stored in "oldLogdb.dat"
       
    32 _LIT(KEventNum1, "00000");
       
    33 _LIT(KEventNum2, "11111");
       
    34 _LIT(KEventNum3, "22222");
       
    35 _LIT(KEventNum4, "012345678901234567");
       
    36 const TLogId KEventId1 = 0;
       
    37 const TLogId KEventId2 = 1;
       
    38 const TLogId KEventId3 = 2;
       
    39 const TLogId KEventId4 = 3;
       
    40 
       
    41 //New events, added by this test
       
    42 _LIT(KEventNum5, "123411119");
       
    43 _LIT(KEventNum6, "999911221");
       
    44 TLogId TheEventId5 = KLogNullId;
       
    45 TLogId TheEventId6 = KLogNullId;
       
    46 
       
    47 //Stored events properties
       
    48 _LIT(KTestEventDesc1, "Event Type Description");
       
    49 _LIT(KTestRemoteParty1, "Remote Party");
       
    50 _LIT(KTestDirection1, "Direction");
       
    51 _LIT(KTestStatus1, "Status");
       
    52 _LIT(KTestSubject1, "Subject");
       
    53 const TUid KTestEventUid = {0x10005393};
       
    54 const TLogDurationType KTestDurationType1 = 1;
       
    55 const TLogDuration KTestDuration1 = 0x1234;
       
    56 const TLogContactItemId KTestContact1 = 0x1234;
       
    57 const TLogLink KTestLink1 = 0x1234;
       
    58 _LIT8(KTestData1, "ABCDEFGH");
       
    59 const TLogFlags KTestFlags1 = 0x5;
       
    60 
       
    61 //Sim Ids used by the test
       
    62 const TSimId KSimId1 = 1;
       
    63 const TSimId KSimId3 = 3900100200U;
       
    64 
       
    65 void CheckEventProperties(CLogEvent& aEvent, TLogId aEventId, const TDesC& aEventNumber, TSimId aSimId)
       
    66 	{
       
    67 	TEST(aEvent.Id() == aEventId);
       
    68 	TEST(aEvent.Time() > TTime(0));
       
    69 	TEST(aEvent.Description() == KTestEventDesc1);
       
    70 	TEST(aEvent.EventType() == KTestEventUid);
       
    71 	TEST(aEvent.RemoteParty() == KTestRemoteParty1);
       
    72 	TEST(aEvent.Direction() == KTestDirection1);
       
    73 	TEST(aEvent.DurationType() == KTestDurationType1);
       
    74 	TEST(aEvent.Duration() == KTestDuration1);
       
    75 	TEST(aEvent.Status() == KTestStatus1);
       
    76 	TEST(aEvent.Subject() == KTestSubject1);
       
    77 	TEST(aEvent.Contact() == KTestContact1);
       
    78 	TEST(aEvent.Link() == KTestLink1);
       
    79 	TEST(aEvent.Data() == KTestData1);
       
    80 	TEST(aEvent.Flags() == KTestFlags1);
       
    81 	TEST(aEvent.Number() == aEventNumber);
       
    82 	TEST(aEvent.SimId() == aSimId);
       
    83 	TPtrC eventStatus = aEvent.Subject();
       
    84 	TPtrC eventNumber = aEvent.Number();
       
    85 	test.Printf(_L("Id:%d No:%S Sub:%S Contact Id:0x%x SimId:%u\n"), aEvent.Id(), &eventNumber, &eventStatus, aEvent.Contact(), aEvent.SimId());
       
    86 	}
       
    87 
       
    88 void DoGetEventTestL(TLogId aEventId, const TDesC& aEventNumber, TSimId aSimId, CTestActive& aActive, CLogClient& aLogClient)
       
    89 	{
       
    90 	CLogEvent* event = CLogEvent::NewL();
       
    91 	CleanupStack::PushL(event);
       
    92 
       
    93 	// set the id of the event to be fetched
       
    94 	event->SetId(aEventId);
       
    95 
       
    96 	aActive.StartL();
       
    97 	aLogClient.GetEvent(*event, aActive.iStatus);
       
    98 	CActiveScheduler::Start();
       
    99 	TEST2(aActive.iStatus.Int(), KErrNone);
       
   100 	
       
   101 	CheckEventProperties(*event, aEventId, aEventNumber, aSimId);
       
   102 	
       
   103 	CleanupStack::PopAndDestroy(event);
       
   104 	}
       
   105 
       
   106 void DoChangeEventTestL(TLogId aEventId, const TDesC& aEventNumber, TSimId aSimId, CTestActive& aActive, CLogClient& aLogClient)
       
   107 	{
       
   108 	CLogEvent* event = CLogEvent::NewL();
       
   109 	CleanupStack::PushL(event);
       
   110 
       
   111 	//Retrieve the event.
       
   112 	event->SetId(aEventId);
       
   113 	aActive.StartL();
       
   114 	aLogClient.GetEvent(*event, aActive.iStatus);
       
   115 	CActiveScheduler::Start();
       
   116 	TEST2(aActive.iStatus.Int(), KErrNone);
       
   117 	CheckEventProperties(*event, aEventId, aEventNumber, KLogNullSimId);
       
   118 	//Change event's SimId.
       
   119 	event->SetSimId(aSimId);
       
   120 	aActive.StartL();
       
   121 	aLogClient.ChangeEvent(*event, aActive.iStatus);
       
   122 	CActiveScheduler::Start();
       
   123 	TEST2(aActive.iStatus.Int(), KErrNone);
       
   124 	CheckEventProperties(*event, aEventId, aEventNumber, aSimId);
       
   125 	
       
   126 	CleanupStack::PopAndDestroy(event);
       
   127 	}
       
   128 
       
   129 TInt DoAddEventTestL(const TDesC& aEventNumber, TSimId aSimId, CTestActive& aActive, CLogClient& aLogClient)
       
   130 	{
       
   131 	CLogEvent* event = CLogEvent::NewL();
       
   132 	CleanupStack::PushL(event);
       
   133 
       
   134 	TTime now;
       
   135 	now.UniversalTime();
       
   136 	
       
   137 	event->SetEventType(KTestEventUid);
       
   138 	event->SetRemoteParty(KTestRemoteParty1);
       
   139 	event->SetDirection(KTestDirection1);
       
   140 	event->SetDurationType(KTestDurationType1);
       
   141 	event->SetDuration(KTestDuration1);
       
   142 	event->SetStatus(KTestStatus1);
       
   143 	event->SetSubject(KTestSubject1);
       
   144 	event->SetNumber(aEventNumber);
       
   145 	event->SetContact(KTestContact1);
       
   146 	event->SetLink(KTestLink1);
       
   147 	event->SetDataL(KTestData1);
       
   148 	event->SetFlags(KTestFlags1);
       
   149 	if(aSimId != KLogNullSimId)
       
   150 		{
       
   151 		event->SetSimId(aSimId);
       
   152 		}
       
   153 
       
   154 	aActive.StartL();
       
   155 	aLogClient.AddEvent(*event, aActive.iStatus);
       
   156 	CActiveScheduler::Start();
       
   157 	TEST(!aActive.IsActive());
       
   158 	TEST2(aActive.iStatus.Int(), KErrNone);
       
   159 	
       
   160 	TLogId eventId = event->Id();
       
   161 	TEST(eventId != KLogNullId);
       
   162 	TEST(event->Time() >= now);
       
   163 	
       
   164 	CleanupStack::PopAndDestroy(event);
       
   165 	return eventId;
       
   166 	}
       
   167 
       
   168 /**
       
   169 @SYMTestCaseID			PDS-LOGENG-UT-4018
       
   170 @SYMTestCaseDesc		Retrieving events from a database without "SimId" column in the "Event" table.
       
   171 						The test uses the OldLogdbu.dat database, created before introducing the new 
       
   172 						"SimId" column. The test checks that the events in the database can be accessed and 
       
   173 						retrieved. The event's SimID property value should be 0.
       
   174 @SYMTestActions			Retrieving events from a database without "SimId" column in the "Event" table.
       
   175 @SYMTestExpectedResults Test must not fail
       
   176 @SYMTestPriority		Medium
       
   177 @SYMREQ					REQ12746
       
   178 */
       
   179 void GetEventTestL()
       
   180 	{
       
   181 	CLogClient* client = CLogClient::NewL(theFs);
       
   182 	CleanupStack::PushL(client);
       
   183 	
       
   184 	CTestActive* active = new(ELeave)CTestActive();
       
   185 	CleanupStack::PushL(active);
       
   186 
       
   187 	DoGetEventTestL(KEventId1, KEventNum1, KLogNullSimId, *active, *client);
       
   188 	DoGetEventTestL(KEventId2, KEventNum2, KLogNullSimId, *active, *client);
       
   189 	DoGetEventTestL(KEventId3, KEventNum3, KLogNullSimId, *active, *client);
       
   190 	DoGetEventTestL(KEventId4, KEventNum4, KLogNullSimId, *active, *client);
       
   191 
       
   192 	CleanupStack::PopAndDestroy(active);
       
   193 	CleanupStack::PopAndDestroy(client);
       
   194 	}
       
   195 
       
   196 /**
       
   197 @SYMTestCaseID			PDS-LOGENG-UT-4019
       
   198 @SYMTestCaseDesc		Changing events from a database without "SimId" column in the "Event" table.
       
   199 						The test uses the OldLogdbu.dat database, created before introducing the new 
       
   200 						"SimId" column. The test checks that the events in the database can be accessed and 
       
   201 						retrieved. After that the test changes some of the events, updating events properties
       
   202 						with a non-zero SimId. The test checks that the updated event really got its SimId 
       
   203 						property value changed.
       
   204 @SYMTestActions			Changing events from a database without "SimId" column in the "Event" table.
       
   205 @SYMTestExpectedResults Test must not fail
       
   206 @SYMTestPriority		Medium
       
   207 @SYMREQ					REQ12746
       
   208 */
       
   209 void ChangeEventTestL()
       
   210 	{
       
   211 	CLogClient* client = CLogClient::NewL(theFs);
       
   212 	CleanupStack::PushL(client);
       
   213 	
       
   214 	CTestActive* active = new(ELeave)CTestActive();
       
   215 	CleanupStack::PushL(active);
       
   216 	
       
   217 	//Change two of the events
       
   218 	DoChangeEventTestL(KEventId1, KEventNum1, KSimId1, *active, *client);
       
   219 	DoChangeEventTestL(KEventId3, KEventNum3, KSimId3, *active, *client);
       
   220 	//Check that the other two events are unchanged
       
   221 	DoGetEventTestL(KEventId2, KEventNum2, KLogNullSimId, *active, *client);
       
   222 	DoGetEventTestL(KEventId4, KEventNum4, KLogNullSimId, *active, *client);
       
   223 	
       
   224 	CleanupStack::PopAndDestroy(active);
       
   225 	CleanupStack::PopAndDestroy(client);
       
   226 	}
       
   227 
       
   228 /**
       
   229 @SYMTestCaseID			PDS-LOGENG-UT-4020
       
   230 @SYMTestCaseDesc		Add events to a database without "SimId" column in the "Event" table.
       
   231 						The test uses the OldLogdbu.dat database, created before introducing the new 
       
   232 						"SimId" column. The test adds two events to the database, then checks that the
       
   233 						events can be accessed and retrieved.
       
   234 @SYMTestActions			Add events to a database without "SimId" column in the "Event" table.
       
   235 @SYMTestExpectedResults Test must not fail
       
   236 @SYMTestPriority		Medium
       
   237 @SYMREQ					REQ12746
       
   238 */
       
   239 void AddEventTestL()
       
   240 	{
       
   241 	CLogClient* client = CLogClient::NewL(theFs);
       
   242 	CleanupStack::PushL(client);
       
   243 	
       
   244 	CTestActive* active = new(ELeave)CTestActive();
       
   245 	CleanupStack::PushL(active);
       
   246 	
       
   247 	//Add an event without SimId
       
   248 	TheEventId5 = DoAddEventTestL(KEventNum5, KLogNullSimId, *active, *client);
       
   249 	//Add an event with SimId
       
   250 	TheEventId6 = DoAddEventTestL(KEventNum6, KSimId1, *active, *client);
       
   251 	//Check that the other 4 events are unchanged
       
   252 	DoGetEventTestL(KEventId1, KEventNum1, KSimId1, *active, *client);//KSimId1 - set by ChangeEventTestL() 
       
   253 	DoGetEventTestL(KEventId2, KEventNum2, KLogNullSimId, *active, *client);
       
   254 	DoGetEventTestL(KEventId3, KEventNum3, KSimId3, *active, *client);//KSimId3 - set by ChangeEventTestL()
       
   255 	DoGetEventTestL(KEventId4, KEventNum4, KLogNullSimId, *active, *client);
       
   256 	//Check the first added event
       
   257 	DoGetEventTestL(TheEventId5, KEventNum5, KLogNullSimId, *active, *client);
       
   258 	//Check the second added event
       
   259 	DoGetEventTestL(TheEventId6, KEventNum6, KSimId1, *active, *client);
       
   260 	
       
   261 	CleanupStack::PopAndDestroy(active);
       
   262 	CleanupStack::PopAndDestroy(client);
       
   263 	}
       
   264 
       
   265 /**
       
   266 @SYMTestCaseID			PDS-LOGENG-UT-4021
       
   267 @SYMTestCaseDesc		Delete events from a database without "SimId" column in the "Event" table.
       
   268 						The test uses the OldLogdbu.dat database, created before introducing the new 
       
   269 						"SimId" column. The test deletes an event from the database and checks then that
       
   270 						the other events are intact, the deleted event is really deleted.
       
   271 @SYMTestActions			Delete events from a database without "SimId" column in the "Event" table.
       
   272 @SYMTestExpectedResults Test must not fail
       
   273 @SYMTestPriority		Medium
       
   274 @SYMREQ					REQ12746
       
   275 */
       
   276 void DeleteEventTestL()
       
   277 	{
       
   278 	CLogClient* client = CLogClient::NewL(theFs);
       
   279 	CleanupStack::PushL(client);
       
   280 	
       
   281 	CTestActive* active = new(ELeave)CTestActive();
       
   282 	CleanupStack::PushL(active);
       
   283 
       
   284 	//Delete an event
       
   285 	active->StartL();
       
   286 	client->DeleteEvent(KEventId2, active->iStatus);
       
   287 	CActiveScheduler::Start();
       
   288 	TEST(!active->IsActive());
       
   289 	TEST2(active->iStatus.Int(), KErrNone);
       
   290 	
       
   291 	//Check that the other 5 events are unchanged
       
   292 	DoGetEventTestL(KEventId1, KEventNum1, KSimId1, *active, *client);//KSimId1 - set by ChangeEventTestL()
       
   293 	DoGetEventTestL(KEventId3, KEventNum3, KSimId3, *active, *client);//KSimId3 - set by ChangeEventTestL()
       
   294 	DoGetEventTestL(KEventId4, KEventNum4, KLogNullSimId, *active, *client);
       
   295 	DoGetEventTestL(TheEventId5, KEventNum5, KLogNullSimId, *active, *client);
       
   296 	DoGetEventTestL(TheEventId6, KEventNum6, KSimId1, *active, *client);
       
   297 	
       
   298 	//Check that event 2 was really deleted
       
   299 	CLogEvent* event = CLogEvent::NewL();
       
   300 	CleanupStack::PushL(event);
       
   301 	event->SetId(KEventId2);
       
   302 	active->StartL();
       
   303 	client->GetEvent(*event, active->iStatus);
       
   304 	CActiveScheduler::Start();
       
   305 	TEST2(active->iStatus.Int(), KErrNotFound);
       
   306 	
       
   307 	CleanupStack::PopAndDestroy(event);
       
   308 	CleanupStack::PopAndDestroy(active);
       
   309 	CleanupStack::PopAndDestroy(client);
       
   310 	}
       
   311 
       
   312 /**
       
   313 @SYMTestCaseID			PDS-LOGENG-UT-4022
       
   314 @SYMTestCaseDesc		Event View test with an old database (without SimId).
       
   315 						The test uses the OldLogdbu.dat database, created before introducing the new 
       
   316 						"SimId" column. The test creates an event view and iterates over the events in the view.
       
   317 						The test checks that events without SimId property set can be retrieved.
       
   318 @SYMTestActions			Event View test with an old database (without SimId).
       
   319 @SYMTestExpectedResults Test must not fail
       
   320 @SYMTestPriority		Medium
       
   321 @SYMREQ					REQ12747
       
   322 */
       
   323 void EventViewTestL()
       
   324 	{
       
   325 	CLogClient* client = CLogClient::NewL(theFs);
       
   326 	CleanupStack::PushL(client);
       
   327 	
       
   328 	CTestActive* active = new(ELeave)CTestActive();
       
   329 	CleanupStack::PushL(active);
       
   330 
       
   331 	CLogViewChangeObserver* observer = CLogViewChangeObserver::NewLC();
       
   332 	observer->SetActive();
       
   333 	
       
   334 	CLogViewEvent* view = CLogViewEvent::NewL(*client, *observer);
       
   335 	CleanupStack::PushL(view);
       
   336 
       
   337 	CLogFilter* filter = CLogFilter::NewL();
       
   338 	CleanupStack::PushL(filter);
       
   339 	TBool res = view->SetFilterL(*filter, active->iStatus);
       
   340 	TEST(res);
       
   341 	
       
   342 	//SimId:                      KSimId1    KSimId3    KLogNullSimId  KLogNullSimId   KSimId1 
       
   343 	const TLogId KLogEventIds[] ={KEventId1, KEventId3, KEventId4,  TheEventId5, TheEventId6};
       
   344 	TBool logEventVisited[] =    {EFalse,    EFalse,    EFalse,     EFalse,      EFalse};
       
   345 	const TInt KLogEventCnt = sizeof(KLogEventIds)/sizeof(KLogEventIds[0]); 
       
   346 
       
   347 	do	{
       
   348 		active->StartL();
       
   349 		CActiveScheduler::Start();
       
   350 		TEST2(active->iStatus.Int(), KErrNone);
       
   351 
       
   352 		const TInt viewCount = view->CountL();
       
   353 		TEST2(viewCount, KLogEventCnt);
       
   354 		
       
   355 		TInt eventId = view->Event().Id();
       
   356 		TInt i = 0;
       
   357 		for(;i<KLogEventCnt;++i)
       
   358 			{
       
   359 			if(KLogEventIds[i] == eventId)
       
   360 				{
       
   361 				break;
       
   362 				}
       
   363 			}
       
   364 		TEST(i < KLogEventCnt);
       
   365 		logEventVisited[i] = ETrue;
       
   366 		}
       
   367 	while(view->NextL(active->iStatus));
       
   368 
       
   369 	//Check that all events were visited. 
       
   370 	for(TInt i=0;i<KLogEventCnt;++i)
       
   371 		{
       
   372 		TEST(logEventVisited[i]);
       
   373 		}
       
   374 	
       
   375 	CleanupStack::PopAndDestroy(filter);
       
   376 	CleanupStack::PopAndDestroy(view);
       
   377 	CleanupStack::PopAndDestroy(observer);
       
   378 	CleanupStack::PopAndDestroy(active);
       
   379 	CleanupStack::PopAndDestroy(client);
       
   380 	}
       
   381 
       
   382 /**
       
   383 @SYMTestCaseID			PDS-LOGENG-UT-4023
       
   384 @SYMTestCaseDesc		Event View test with an old database (without SimId).
       
   385 						The test uses the OldLogdbu.dat database, created before introducing the new 
       
   386 						"SimId" column. The test creates an event view and iterates over the events in the view.
       
   387 						The test checks that events without SimId property set can be retrieved. The test is very
       
   388 						similar to the EventViewTestL() test, except the fact that the filter filters out all events
       
   389 						with non-zero SimId.
       
   390 @SYMTestActions			Event View test with an old database (without SimId).
       
   391 @SYMTestExpectedResults Test must not fail
       
   392 @SYMTestPriority		Medium
       
   393 @SYMREQ					REQ12747
       
   394 */
       
   395 void EventViewTest2L()
       
   396 	{
       
   397 	CLogClient* client = CLogClient::NewL(theFs);
       
   398 	CleanupStack::PushL(client);
       
   399 	
       
   400 	CTestActive* active = new(ELeave)CTestActive();
       
   401 	CleanupStack::PushL(active);
       
   402 
       
   403 	CLogViewChangeObserver* observer = CLogViewChangeObserver::NewLC();
       
   404 	observer->SetActive();
       
   405 	
       
   406 	CLogViewEvent* view = CLogViewEvent::NewL(*client, *observer);
       
   407 	CleanupStack::PushL(view);
       
   408 
       
   409 	CLogFilter* filter = CLogFilter::NewL();
       
   410 	CleanupStack::PushL(filter);
       
   411 	filter->SetNullFields(ELogSimIdField);
       
   412 	TBool res = view->SetFilterL(*filter, active->iStatus);
       
   413 	TEST(res);
       
   414 	
       
   415 	//Only events KEventId4 and TheEventId5 are with zero SimId.
       
   416 	const TLogId KLogEventIds[] ={KEventId4,  TheEventId5};
       
   417 	TBool logEventVisited[] =    {EFalse,    EFalse};
       
   418 	const TInt KLogEventCnt = sizeof(KLogEventIds)/sizeof(KLogEventIds[0]); 
       
   419 
       
   420 	do	{
       
   421 		active->StartL();
       
   422 		CActiveScheduler::Start();
       
   423 		TEST2(active->iStatus.Int(), KErrNone);
       
   424 
       
   425 		const TInt viewCount = view->CountL();
       
   426 		TEST2(viewCount, KLogEventCnt);
       
   427 		
       
   428 		TInt eventId = view->Event().Id();
       
   429 		TInt i = 0;
       
   430 		for(;i<KLogEventCnt;++i)
       
   431 			{
       
   432 			if(KLogEventIds[i] == eventId)
       
   433 				{
       
   434 				break;
       
   435 				}
       
   436 			}
       
   437 		TEST(i < KLogEventCnt);
       
   438 		logEventVisited[i] = ETrue;
       
   439 		}
       
   440 	while(view->NextL(active->iStatus));
       
   441 
       
   442 	//Check that all events were visited. 
       
   443 	for(TInt i=0;i<KLogEventCnt;++i)
       
   444 		{
       
   445 		TEST(logEventVisited[i]);
       
   446 		}
       
   447 	
       
   448 	CleanupStack::PopAndDestroy(filter);
       
   449 	CleanupStack::PopAndDestroy(view);
       
   450 	CleanupStack::PopAndDestroy(observer);
       
   451 	CleanupStack::PopAndDestroy(active);
       
   452 	CleanupStack::PopAndDestroy(client);
       
   453 	}
       
   454 
       
   455 /**
       
   456 @SYMTestCaseID			PDS-LOGENG-UT-4024
       
   457 @SYMTestCaseDesc		Event View test with an old database (without SimId).
       
   458 						The test uses the OldLogdbu.dat database, created before introducing the new 
       
   459 						"SimId" column. The test creates an event view, sets a filter with a non-zero SimId 
       
   460 						and iterates over the events in the view. It should be possible to view events with SimId
       
   461 						set, when the database was created using the old format.
       
   462 @SYMTestActions			Event View test with an old database (without SimId).
       
   463 @SYMTestExpectedResults Test must not fail
       
   464 @SYMTestPriority		Medium
       
   465 @SYMREQ					REQ12747
       
   466 */
       
   467 void EventViewTest3L()
       
   468 	{
       
   469 	CLogClient* client = CLogClient::NewL(theFs);
       
   470 	CleanupStack::PushL(client);
       
   471 	
       
   472 	CTestActive* active = new(ELeave)CTestActive();
       
   473 	CleanupStack::PushL(active);
       
   474 
       
   475 	CLogViewChangeObserver* observer = CLogViewChangeObserver::NewLC();
       
   476 	observer->SetActive();
       
   477 	
       
   478 	CLogViewEvent* view = CLogViewEvent::NewL(*client, *observer);
       
   479 	CleanupStack::PushL(view);
       
   480 
       
   481 	CLogFilter* filter = CLogFilter::NewL();
       
   482 	CleanupStack::PushL(filter);
       
   483 	filter->SetSimId(KSimId1);
       
   484 	TSimId simId = filter->SimId();
       
   485 	TEST2(simId, KSimId1);
       
   486 	TBool res = view->SetFilterL(*filter, active->iStatus);
       
   487 	TEST(res);
       
   488 	
       
   489 	//Only events KEventId1 and TheEventId6 are with KSimId1.
       
   490 	const TLogId KLogEventIds[] ={KEventId1,  TheEventId6};
       
   491 	TBool logEventVisited[] =    {EFalse,    EFalse};
       
   492 	const TInt KLogEventCnt = sizeof(KLogEventIds)/sizeof(KLogEventIds[0]); 
       
   493 
       
   494 	do	{
       
   495 		active->StartL();
       
   496 		CActiveScheduler::Start();
       
   497 		TEST2(active->iStatus.Int(), KErrNone);
       
   498 
       
   499 		const TInt viewCount = view->CountL();
       
   500 		TEST2(viewCount, KLogEventCnt);
       
   501 		
       
   502 		TInt eventId = view->Event().Id();
       
   503 		TInt i = 0;
       
   504 		for(;i<KLogEventCnt;++i)
       
   505 			{
       
   506 			if(KLogEventIds[i] == eventId)
       
   507 				{
       
   508 				break;
       
   509 				}
       
   510 			}
       
   511 		TEST(i < KLogEventCnt);
       
   512 		logEventVisited[i] = ETrue;
       
   513 		}
       
   514 	while(view->NextL(active->iStatus));
       
   515 
       
   516 	//Check that all events were visited. 
       
   517 	for(TInt i=0;i<KLogEventCnt;++i)
       
   518 		{
       
   519 		TEST(logEventVisited[i]);
       
   520 		}
       
   521 	
       
   522 	CleanupStack::PopAndDestroy(filter);
       
   523 	CleanupStack::PopAndDestroy(view);
       
   524 	CleanupStack::PopAndDestroy(observer);
       
   525 	CleanupStack::PopAndDestroy(active);
       
   526 	CleanupStack::PopAndDestroy(client);
       
   527 	}
       
   528 
       
   529 /**
       
   530 @SYMTestCaseID			PDS-LOGENG-UT-4043
       
   531 @SYMTestCaseDesc		CLogEvent - data compatibility test.
       
   532 						The test uses data externalized from an event prior the "dual SIM support"
       
   533 						changes were introduced. The test internalizes the event data and checks 
       
   534 						that the data is interpreted correctly.
       
   535 @SYMTestActions			CLogEvent - data compatibility test.
       
   536 @SYMTestExpectedResults Test must not fail
       
   537 @SYMTestPriority		Medium
       
   538 @SYMREQ					REQ12746
       
   539 */
       
   540 void EventDataTestL()
       
   541 	{
       
   542 	//Externalized to a buffer event data where the following property values have been set:
       
   543 	// Id=1, Type=2, "RemoteParty", "Direction", "Data"
       
   544 	//The used event format is before the "dual SIM support" changes were introduced.
       
   545 	const TUint8 KEvtData1[] =
       
   546 		//  0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F   
       
   547 		{ 
       
   548 		    1,  0,  0,  0,  2,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
       
   549 		  255,  0,  0,  0,  0,255,255,255,255,  0,  0,  0,  0,  0,  0, 44,
       
   550 		   82,101,109,111,116,101, 80, 97,114,116,121, 36, 68,105,114,101, 
       
   551 		   99,116,105,111,110,  0,  0,  0,  4,  0,  0,  0, 18, 68, 97,116,
       
   552 		   97
       
   553 		};
       
   554 
       
   555 	CLogEvent* evt1 = CLogEvent::NewL();
       
   556 	CleanupStack::PushL(evt1);
       
   557 	TPtrC8 ptr1(KEvtData1, sizeof(KEvtData1) / sizeof(KEvtData1[0]));
       
   558 	RDesReadStream strm1(ptr1);
       
   559 	strm1 >> *evt1;
       
   560 	strm1.Close();
       
   561 	TEST2(evt1->Id(), 1);
       
   562 	TEST(evt1->EventType() == TUid::Uid(2));
       
   563 	_LIT(KRemoteParty, "RemoteParty");
       
   564 	TEST(evt1->RemoteParty() == KRemoteParty);
       
   565 	_LIT(KDirection, "Direction");
       
   566 	TEST(evt1->Direction() == KDirection);
       
   567 	_LIT8(KData, "Data");
       
   568 	TEST(evt1->Data() == KData);
       
   569 	TEST(evt1->SimId() == KLogNullSimId);
       
   570 	CleanupStack::PopAndDestroy(evt1);
       
   571 	
       
   572 	//Externalized to a buffer event data where the following property values have been set:
       
   573 	// Id=3, Type=4, "RemoteParty2", "Direction2"
       
   574 	//The used event format is before the "dual SIM support" changes were introduced.
       
   575 	const TUint8 KEvtData2[] =
       
   576 		//  0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F   
       
   577 		{ 
       
   578 		    3,  0,  0,  0,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
       
   579 		  255,  0,  0,  0,  0,255,255,255,255,  0,  0,  0,  0,  0,  0, 48,
       
   580 		   82,101,109,111,116,101, 80, 97,114,116,121, 50, 40, 68,105,114, 
       
   581 		  101, 99,116,105,111,110, 50,  0,  0,  0,  0,  0,  0,  0
       
   582 		};
       
   583 
       
   584 	CLogEvent* evt2 = CLogEvent::NewL();
       
   585 	CleanupStack::PushL(evt2);
       
   586 	TPtrC8 ptr2(KEvtData2, sizeof(KEvtData2) / sizeof(KEvtData2[0]));
       
   587 	RDesReadStream strm2(ptr2);
       
   588 	strm2 >> *evt2;
       
   589 	strm2.Close();
       
   590 	TEST2(evt2->Id(), 3);
       
   591 	TEST(evt2->EventType() == TUid::Uid(4));
       
   592 	_LIT(KRemoteParty2, "RemoteParty2");
       
   593 	TEST(evt2->RemoteParty() == KRemoteParty2);
       
   594 	_LIT(KDirection2, "Direction2");
       
   595 	TEST(evt2->Direction() == KDirection2);
       
   596 	TEST(evt2->SimId() == KLogNullSimId);
       
   597 	CleanupStack::PopAndDestroy(evt2);
       
   598 	}
       
   599 
       
   600 /**
       
   601 @SYMTestCaseID			PDS-LOGENG-UT-4046
       
   602 @SYMTestCaseDesc		CLogClient::ClearLog() - data compatibility test.
       
   603 						The test uses the OldLogdbu.dat database, created before introducing the new 
       
   604 						"SimId" column. The test verifies that CLogClient::ClearLog() can work with 
       
   605 						database with the old format. 
       
   606 @SYMTestActions			CLogClient::ClearLog() - data compatibility test.
       
   607 @SYMTestExpectedResults Test must not fail
       
   608 @SYMTestPriority		Medium
       
   609 @SYMREQ					REQ12748
       
   610 */
       
   611 void ClearLogTestL()
       
   612 	{
       
   613 	CLogClient* client = CLogClient::NewL(theFs);
       
   614 	CleanupStack::PushL(client);
       
   615 	
       
   616 	CTestActive* active = new(ELeave)CTestActive();
       
   617 	CleanupStack::PushL(active);
       
   618 
       
   619 	//Get one of the events
       
   620 	CLogEvent* event = CLogEvent::NewL();
       
   621 	CleanupStack::PushL(event);
       
   622 	event->SetId(KEventId1);
       
   623 	active->StartL();
       
   624 	client->GetEvent(*event, active->iStatus);
       
   625 	CActiveScheduler::Start();
       
   626 	TEST2(active->iStatus.Int(), KErrNone);
       
   627 	TTime evtTime = event->Time();
       
   628 	CleanupStack::PopAndDestroy(event);
       
   629 	event = NULL;
       
   630 	
       
   631 	//Delete all events with time < (evtTime + 1s). 
       
   632 	evtTime += TTimeIntervalSeconds(1);
       
   633 	active->StartL();
       
   634 	client->ClearLog(evtTime, active->iStatus);
       
   635 	CActiveScheduler::Start();
       
   636 	TEST2(active->iStatus.Int(), KErrNone);
       
   637 
       
   638 	//The event with time "evtTime" should not be in the log anymore.
       
   639 	event = CLogEvent::NewL();
       
   640 	CleanupStack::PushL(event);
       
   641 	event->SetId(KEventId1);
       
   642 	active->StartL();
       
   643 	client->GetEvent(*event, active->iStatus);
       
   644 	CActiveScheduler::Start();
       
   645 	TEST2(active->iStatus.Int(), KErrNotFound);
       
   646 	CleanupStack::PopAndDestroy(event);
       
   647 	
       
   648 	CleanupStack::PopAndDestroy(active);
       
   649 	CleanupStack::PopAndDestroy(client);
       
   650 	}
       
   651 
       
   652 void doTestsL()
       
   653 	{
       
   654 #ifdef _DEBUG	
       
   655 	test.Start(_L("Copy the old LogEng database"));
       
   656 	TestUtils::CopyOldDbL();
       
   657 	//
       
   658 	test.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4018: \"Get Event\" compatibility test"));
       
   659 	GetEventTestL();
       
   660 	test.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4019: \"Change Event\" compatibility test"));
       
   661 	ChangeEventTestL();
       
   662 	test.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4020: \"Add Event\" compatibility test"));
       
   663 	AddEventTestL();
       
   664 	test.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4021: \"Delete Event\" compatibility test"));
       
   665 	DeleteEventTestL();
       
   666 	test.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4022: \"Event View\" compatibility test"));
       
   667 	EventViewTestL();
       
   668 	test.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4023: \"Event View 2\" compatibility test"));
       
   669 	EventViewTest2L();
       
   670 	test.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4024: \"Event View 3\" compatibility test"));
       
   671 	EventViewTest3L();
       
   672 	test.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4043: \"CLogEvent data\" compatibility test"));
       
   673 	EventDataTestL();
       
   674 	test.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4046: \"CLogClient::ClearLog()\" compatibility test"));
       
   675 	ClearLogTestL();
       
   676 	//
       
   677 	TestUtils::DeleteDatabaseL();
       
   678 #else
       
   679 	test.Start(_L("This test works only in debug mode, otherwise the LogEng server cannot be stopped. See TestUtils::CopyOldDbL()"));
       
   680 #endif
       
   681 	}
       
   682 
       
   683 #else//SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
       
   684 
       
   685 void doTestsL()
       
   686 	{
       
   687 	test.Start(_L("The LogEng compatibility test cases are compiled only when SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM macro is defined!"));
       
   688 	}
       
   689 
       
   690 #endif//SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM