loggingservices/eventlogger/test/src/t_logpurge.cpp
changeset 0 08ec8eefde2f
child 9 667e88a979d7
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     1 // Copyright (c) 2003-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 //
       
    15 
       
    16 #include <s32file.h>
       
    17 #include "TEST.H"
       
    18 #include <logview.h>
       
    19 
       
    20 #undef test  //there is a "test" macro which hides "RTest test" declaration.
       
    21 
       
    22 RTest test(_L("Log Purge Test Harness"));
       
    23 
       
    24 const TInt KTestEventNum = 10;
       
    25 const TInt KTestEventAge = 5;
       
    26 const TInt KTestRecentNum = 10;
       
    27 const TInt KTestDuplicateNum = 10;
       
    28 
       
    29 _LIT(KTestRemoteParty, "Test Remote Party %d");
       
    30 
       
    31 /**
       
    32 @SYMTestCaseID          SYSLIB-LOGENG-CT-0875
       
    33 @SYMTestCaseDesc	    Tests for maximum logging of configuration data 
       
    34 @SYMTestPriority 	    High
       
    35 @SYMTestActions  	    Get the event type configuration data.Set the log size to maximum.
       
    36                         Change the log engine configuration data with the new one.Add events to the log
       
    37                         Set the filter on the view and check for KErrNone flag.
       
    38 						Add a new event and disable logging by setting the maximum logging size to zero
       
    39 						Clear all the events and test for KErrNone and the total count of events.
       
    40 @SYMTestExpectedResults Test must not fail
       
    41 @SYMREQ                 REQ0000
       
    42 */
       
    43 LOCAL_C void TestMaxLogSizeL(CLogClient& aClient)
       
    44 	{
       
    45 	test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0875 "));
       
    46 	CLogEvent* event = CLogEvent::NewL();
       
    47 	CleanupStack::PushL(event);
       
    48 	event->SetEventType(KLogCallEventTypeUid);
       
    49 
       
    50 	CTestActive* active = new(ELeave)CTestActive();
       
    51 	CleanupStack::PushL(active);
       
    52 
       
    53 	CLogViewEvent* view = CLogViewEvent::NewL(aClient);
       
    54 	CleanupStack::PushL(view);
       
    55 
       
    56 	CLogFilter* filter = CLogFilter::NewL();
       
    57 	CleanupStack::PushL(filter);
       
    58 
       
    59 	TLogConfig config;
       
    60 
       
    61 	// Get log configuration
       
    62 	active->StartL();
       
    63 	aClient.GetConfig(config, active->iStatus);
       
    64 	CActiveScheduler::Start();
       
    65 	TEST2(active->iStatus.Int(), KErrNone);
       
    66 
       
    67 	// Set the maximum log size
       
    68 	config.iMaxLogSize = KTestEventNum;
       
    69 
       
    70 	// Change the log engine config
       
    71 	active->StartL();
       
    72 	aClient.ChangeConfig(config, active->iStatus);
       
    73 	CActiveScheduler::Start();
       
    74 	TEST2(active->iStatus.Int(), KErrNone);
       
    75 
       
    76 	// Initialise the view - There should be no events
       
    77 	TEST(!view->SetFilterL(*filter, active->iStatus));
       
    78 
       
    79 	// Add the number of allowed events
       
    80 	TInt count;
       
    81 	for(count = 0; count < KTestEventNum; count++)
       
    82 		{
       
    83 		active->StartL();
       
    84 		aClient.AddEvent(*event, active->iStatus);
       
    85 		CActiveScheduler::Start();
       
    86 		TEST2(active->iStatus.Int(), KErrNone);
       
    87 		}
       
    88 
       
    89 	TEST(view->SetFilterL(*filter, active->iStatus));
       
    90 	active->StartL();
       
    91 	CActiveScheduler::Start();
       
    92 	TEST2(active->iStatus.Int(), KErrNone);
       
    93 
       
    94 	// The view should now have the correct number of events
       
    95 	TEST(view->CountL() == KTestEventNum);
       
    96 
       
    97 	// Add the same number of events again - the old ones should be deleted
       
    98 	for(count = 0; count < KTestEventNum; count++)
       
    99 		{
       
   100 		TEST(view->SetFilterL(*filter, active->iStatus));
       
   101 		active->StartL();
       
   102 		CActiveScheduler::Start();
       
   103 		TEST2(active->iStatus.Int(), KErrNone);
       
   104 
       
   105 		// Get the last (oldest) event
       
   106 		active->StartL();
       
   107 		view->LastL(active->iStatus);
       
   108 		CActiveScheduler::Start();
       
   109 		TEST2(active->iStatus.Int(), KErrNone);
       
   110 
       
   111 		// Remember the Id
       
   112 		TLogId id = view->Event().Id();
       
   113 
       
   114 		// Add another event - the oldest should be removed
       
   115 		active->StartL();
       
   116 		aClient.AddEvent(*event, active->iStatus);
       
   117 		CActiveScheduler::Start();
       
   118 		TEST2(active->iStatus.Int(), KErrNone);
       
   119 
       
   120 		// There should be the same number of events in view
       
   121 		TEST(view->CountL() == KTestEventNum);
       
   122 		
       
   123 		event->SetId(id);
       
   124 
       
   125 		// Try and get the old event
       
   126 		active->StartL();
       
   127 		aClient.GetEvent(*event, active->iStatus);
       
   128 		CActiveScheduler::Start();
       
   129 		TEST2(active->iStatus.Int(), KErrNotFound);
       
   130 		}
       
   131 
       
   132 	// Add an event
       
   133 	active->StartL();
       
   134 	aClient.AddEvent(*event, active->iStatus);
       
   135 	CActiveScheduler::Start();
       
   136 	TEST2(active->iStatus.Int(), KErrNone);
       
   137 
       
   138 	// Check it's there
       
   139 	active->StartL();
       
   140 	aClient.GetEvent(*event, active->iStatus);
       
   141 	CActiveScheduler::Start();
       
   142 	TEST2(active->iStatus.Int(), KErrNone);
       
   143 
       
   144 	// Set the maximum log size to zero, i.e. disable logging
       
   145 	config.iMaxLogSize = 0;
       
   146 
       
   147 	// Change the log engine config
       
   148 	active->StartL();
       
   149 	aClient.ChangeConfig(config, active->iStatus);
       
   150 	CActiveScheduler::Start();
       
   151 	TEST2(active->iStatus.Int(), KErrNone);
       
   152 
       
   153 	// Check the event has gone
       
   154 	active->StartL();
       
   155 	aClient.GetEvent(*event, active->iStatus);
       
   156 	CActiveScheduler::Start();
       
   157 	TEST2(active->iStatus.Int(), KErrNotFound);;
       
   158 
       
   159 	// Add an event
       
   160 	active->StartL();
       
   161 	aClient.AddEvent(*event, active->iStatus);
       
   162 	CActiveScheduler::Start();
       
   163 	TEST2(active->iStatus.Int(), KErrNotSupported);
       
   164 
       
   165 	// Check that event doesn't exist
       
   166 	active->StartL();
       
   167 	aClient.GetEvent(*event, active->iStatus);
       
   168 	CActiveScheduler::Start();
       
   169 	TEST2(active->iStatus.Int(), KErrNotFound);;
       
   170 
       
   171 	User::After(1000000);
       
   172 
       
   173 	TTime now;
       
   174 	now.UniversalTime();
       
   175 	now+=(TTimeIntervalDays) 1;
       
   176 	// Clear all the events
       
   177 	active->StartL();
       
   178 	aClient.ClearLog(now, active->iStatus);
       
   179 	CActiveScheduler::Start();
       
   180 	TEST2(active->iStatus.Int(), KErrNone);
       
   181 
       
   182 	TEST(!view->SetFilterL(*filter, active->iStatus));
       
   183 	TEST(view->CountL() == 0);
       
   184 
       
   185 	CleanupStack::PopAndDestroy(4); // filter, view, active, event
       
   186 	}
       
   187 
       
   188 /**
       
   189 @SYMTestCaseID          SYSLIB-LOGENG-CT-0876
       
   190 @SYMTestCaseDesc	    Tests for maximum logging of configuration data 
       
   191 @SYMTestPriority 	    High
       
   192 @SYMTestActions  	    Get the event type configuration data.Set the log size to maximum.
       
   193                         Change the log engine configuration data and add the number of allowed events
       
   194                         Reduce the number of allowed events.The old ones should be purged
       
   195 						Change the log engine config and check for the event count.
       
   196 @SYMTestExpectedResults Test must not fail
       
   197 @SYMREQ                 REQ0000
       
   198 */
       
   199 LOCAL_C void TestMaxLogSizeConfigL(CLogClient& aClient)
       
   200 	{
       
   201 	test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0876 "));
       
   202 	CLogEvent* event = CLogEvent::NewL();
       
   203 	CleanupStack::PushL(event);
       
   204 	event->SetEventType(KLogCallEventTypeUid);
       
   205 
       
   206 	CTestActive* active = new(ELeave)CTestActive();
       
   207 	CleanupStack::PushL(active);
       
   208 
       
   209 	CLogViewEvent* view = CLogViewEvent::NewL(aClient);
       
   210 	CleanupStack::PushL(view);
       
   211 
       
   212 	CLogFilter* filter = CLogFilter::NewL();
       
   213 	CleanupStack::PushL(filter);
       
   214 
       
   215 	TLogConfig config;
       
   216 
       
   217 	// Get log configuration
       
   218 	active->StartL();
       
   219 	aClient.GetConfig(config, active->iStatus);
       
   220 	CActiveScheduler::Start();
       
   221 	TEST2(active->iStatus.Int(), KErrNone);
       
   222 
       
   223 	// Set the maximum log size
       
   224 	config.iMaxLogSize = KTestEventNum;
       
   225 
       
   226 	// Change the log engine config
       
   227 	active->StartL();
       
   228 	aClient.ChangeConfig(config, active->iStatus);
       
   229 	CActiveScheduler::Start();
       
   230 	TEST2(active->iStatus.Int(), KErrNone);
       
   231 
       
   232 	// Initialise the view - There should be no events
       
   233 	TEST(!view->SetFilterL(*filter, active->iStatus));
       
   234 
       
   235 	// Add the number of allowed events
       
   236 	TInt count;
       
   237 	for(count = 0; count < KTestEventNum; count++)
       
   238 		{
       
   239 		active->StartL();
       
   240 		aClient.AddEvent(*event, active->iStatus);
       
   241 		CActiveScheduler::Start();
       
   242 		TEST2(active->iStatus.Int(), KErrNone);
       
   243 		}
       
   244 
       
   245 	TEST(view->SetFilterL(*filter, active->iStatus));
       
   246 	active->StartL();
       
   247 	CActiveScheduler::Start();
       
   248 	TEST2(active->iStatus.Int(), KErrNone);
       
   249 
       
   250 	// The view should now have the correct number of events
       
   251 	TEST(view->CountL() == KTestEventNum);
       
   252 
       
   253 	// Reduce the number of allowed events
       
   254 	// The old ones should be purged
       
   255 	config.iMaxLogSize = KTestEventNum / 2;
       
   256 
       
   257 	// Change the log engine config
       
   258 	active->StartL();
       
   259 	aClient.ChangeConfig(config, active->iStatus);
       
   260 	CActiveScheduler::Start();
       
   261 	TEST2(active->iStatus.Int(), KErrNone);
       
   262 
       
   263 	// Check the event count
       
   264 	TEST(view->SetFilterL(*filter, active->iStatus));
       
   265 	active->StartL();
       
   266 	CActiveScheduler::Start();
       
   267 	TEST2(active->iStatus.Int(), KErrNone);
       
   268 	TEST(view->CountL() == KTestEventNum / 2);
       
   269 		
       
   270 	User::After(0x1000000);
       
   271 
       
   272 	TTime now;
       
   273 	now.UniversalTime();
       
   274 	now+=(TTimeIntervalDays )1;
       
   275 	// Clear all the events
       
   276 	active->StartL();
       
   277 	aClient.ClearLog(now, active->iStatus);
       
   278 	CActiveScheduler::Start();
       
   279 	TEST2(active->iStatus.Int(), KErrNone);
       
   280 
       
   281 	TEST(!view->SetFilterL(*filter, active->iStatus));
       
   282 	TEST(view->CountL() == 0);
       
   283 
       
   284 	CleanupStack::PopAndDestroy(4); // filter, view, active, event
       
   285 	}
       
   286 
       
   287 /**
       
   288 @SYMTestCaseID          SYSLIB-LOGENG-CT-0877
       
   289 @SYMTestCaseDesc	    Tests for maximum time for which events can be retained in the log
       
   290 @SYMTestPriority 	    High
       
   291 @SYMTestActions  	    Get the event type configuration data.Set maximum log age.
       
   292                         Change the log engine configuration data with the new one.Add events to the log
       
   293                         Set the date and time of events clear the log and check for errors
       
   294 @SYMTestExpectedResults Test must not fail
       
   295 @SYMREQ                 REQ0000
       
   296 */
       
   297 LOCAL_C void TestMaxLogAgeL(CLogClient& aClient, TLogAge aMaxLogAge)
       
   298 	{
       
   299 	test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0877 "));
       
   300 	CLogEvent* event = CLogEvent::NewL();
       
   301 	CleanupStack::PushL(event);
       
   302 	event->SetEventType(KLogCallEventTypeUid);
       
   303 
       
   304 	CTestActive* active = new(ELeave)CTestActive();
       
   305 	CleanupStack::PushL(active);
       
   306 
       
   307 	CLogViewEvent* view = CLogViewEvent::NewL(aClient);
       
   308 	CleanupStack::PushL(view);
       
   309 
       
   310 	CLogFilter* filter = CLogFilter::NewL();
       
   311 	CleanupStack::PushL(filter);
       
   312 
       
   313 	TLogConfig config;
       
   314 
       
   315 	// Get log configuration
       
   316 	active->StartL();
       
   317 	aClient.GetConfig(config, active->iStatus);
       
   318 	CActiveScheduler::Start();
       
   319 	TEST2(active->iStatus.Int(), KErrNone);
       
   320 
       
   321 	// Set the maximum log age
       
   322 	config.iMaxLogSize = KTestEventAge * 2;
       
   323 	config.iMaxEventAge = aMaxLogAge;
       
   324 
       
   325 	// Change the log engine config
       
   326 	active->StartL();
       
   327 	aClient.ChangeConfig(config, active->iStatus);
       
   328 	CActiveScheduler::Start();
       
   329 	TEST2(active->iStatus.Int(), KErrNone);
       
   330 
       
   331 	// Initialise the view - There should be no events
       
   332 	TEST(!view->SetFilterL(*filter, active->iStatus));
       
   333 
       
   334 	TTime date;
       
   335 	date.UniversalTime();
       
   336 
       
   337 	// Wait a second
       
   338 	User::After(0x1000000);
       
   339 
       
   340 	// Add events
       
   341 	TInt count;
       
   342 	for(count = 0; count < KTestEventAge * 2; count++)
       
   343 		{
       
   344 		active->StartL();
       
   345 		aClient.AddEvent(*event, active->iStatus);
       
   346 		CActiveScheduler::Start();
       
   347 		TEST2(active->iStatus.Int(), KErrNone);
       
   348 
       
   349 		// Set the time and date of the event
       
   350 		event->SetTime(date);
       
   351 		date -= TTimeIntervalDays(1);
       
   352 
       
   353 		active->StartL();
       
   354 		aClient.ChangeEvent(*event, active->iStatus);
       
   355 		CActiveScheduler::Start();
       
   356 		TEST2(active->iStatus.Int(), KErrNone);
       
   357 		User::After(1000000);
       
   358 
       
   359 		TEST(view->SetFilterL(*filter, active->iStatus));
       
   360 		active->StartL();
       
   361 		CActiveScheduler::Start();
       
   362 		TEST2(active->iStatus.Int(), KErrNone);
       
   363 
       
   364 		// Check the old events have been removed
       
   365 		if ((count < KTestEventAge) || !aMaxLogAge)
       
   366 			TEST(view->CountL() == count + 1);
       
   367 		else
       
   368 			TEST(view->CountL() == KTestEventAge);
       
   369 		}
       
   370 
       
   371 	User::After(0x1000000);
       
   372 	date.UniversalTime();
       
   373 
       
   374 	date+=(TTimeIntervalYears )1;
       
   375 
       
   376 	// Clear all the events
       
   377 	active->StartL();
       
   378 	aClient.ClearLog(date, active->iStatus);
       
   379 	CActiveScheduler::Start();
       
   380 	TEST2(active->iStatus.Int(), KErrNone);
       
   381 
       
   382 	TEST(!view->SetFilterL(*filter, active->iStatus));
       
   383 	TEST(view->CountL() == 0);
       
   384 
       
   385 	CleanupStack::PopAndDestroy(4); // filter, view, active, event
       
   386 	}
       
   387 
       
   388 /**
       
   389 @SYMTestCaseID          SYSLIB-LOGENG-CT-0878
       
   390 @SYMTestCaseDesc	    Tests for maximum number of events that a recent event list holds
       
   391 @SYMTestPriority 	    High
       
   392 @SYMTestActions  	    Set the event configuration data of recent log size(10) to maximum and 
       
   393 						Add events to the log.Set the filter on the view and check for NO error.
       
   394 						Add a new event and disable logging by setting the maximum logging size to zero
       
   395 						Clear all the events and test for no errors and the total count of events and the logviewrecent should be zero.
       
   396 @SYMTestExpectedResults Test must not fail
       
   397 @SYMREQ                 REQ0000
       
   398 */
       
   399 LOCAL_C void TestMaxRecentSize1L(CLogClient& aClient)
       
   400 	{
       
   401 	test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0878 "));
       
   402 	CLogEvent* event = CLogEvent::NewL();
       
   403 	CleanupStack::PushL(event);
       
   404 
       
   405 	// Incoming
       
   406 	TBuf<KLogMaxDirectionLength> buf;
       
   407 	aClient.GetString(buf, R_LOG_DIR_IN);
       
   408 
       
   409 	event->SetEventType(KLogCallEventTypeUid);
       
   410 	event->SetDirection(buf);
       
   411 
       
   412 	CTestActive* active = new(ELeave)CTestActive();
       
   413 	CleanupStack::PushL(active);
       
   414 
       
   415 	CLogViewEvent* view = CLogViewEvent::NewL(aClient);
       
   416 	CleanupStack::PushL(view);
       
   417 
       
   418 	CLogViewRecent* recent = CLogViewRecent::NewL(aClient);
       
   419 	CleanupStack::PushL(recent);
       
   420 
       
   421 	CLogFilter* filter = CLogFilter::NewL();
       
   422 	CleanupStack::PushL(filter);
       
   423 
       
   424 	TLogConfig config;
       
   425 
       
   426 	// Get log configuration
       
   427 	active->StartL();
       
   428 	aClient.GetConfig(config, active->iStatus);
       
   429 	CActiveScheduler::Start();
       
   430 	TEST2(active->iStatus.Int(), KErrNone);
       
   431 
       
   432 	// Set the maximum log size
       
   433 	config.iMaxLogSize = KTestRecentNum * 2;
       
   434 	config.iMaxRecentLogSize = KTestRecentNum;
       
   435 
       
   436 	// Change the log engine config
       
   437 	active->StartL();
       
   438 	aClient.ChangeConfig(config, active->iStatus);
       
   439 	CActiveScheduler::Start();
       
   440 	TEST2(active->iStatus.Int(), KErrNone);
       
   441 
       
   442 	// Initialise the views - There should be no events
       
   443 	TEST(!view->SetFilterL(*filter, active->iStatus));
       
   444 	TEST(!recent->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
       
   445 
       
   446 	// Add a number of events
       
   447 	TInt count;
       
   448 	for(count = 0; count < KTestRecentNum; count++)
       
   449 		{
       
   450 		event->SetContact(count);
       
   451 
       
   452 		active->StartL();
       
   453 		aClient.AddEvent(*event, active->iStatus);
       
   454 		CActiveScheduler::Start();
       
   455 		TEST2(active->iStatus.Int(), KErrNone);
       
   456 		}
       
   457 
       
   458 	TEST(recent->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
       
   459 	active->StartL();
       
   460 	CActiveScheduler::Start();
       
   461 	TEST2(active->iStatus.Int(), KErrNone);
       
   462 
       
   463 	TEST(recent->CountL() == KTestRecentNum);
       
   464 
       
   465 	// Add the same number of events again - the old ones should be removed
       
   466 	for(count = 0; count < KTestRecentNum; count++)
       
   467 		{
       
   468 		// Add another event - the oldest should be removed from recent list
       
   469 		active->StartL();
       
   470 		aClient.AddEvent(*event, active->iStatus);
       
   471 		CActiveScheduler::Start();
       
   472 		TEST2(active->iStatus.Int(), KErrNone);
       
   473 
       
   474 		TEST(view->SetFilterL(*filter, active->iStatus));
       
   475 		active->StartL();
       
   476 		CActiveScheduler::Start();
       
   477 		TEST2(active->iStatus.Int(), KErrNone);
       
   478 
       
   479 		TEST(recent->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
       
   480 		active->StartL();
       
   481 		CActiveScheduler::Start();
       
   482 		TEST2(active->iStatus.Int(), KErrNone);
       
   483 
       
   484 		// Check an event has been removed from recent view
       
   485 		TEST(recent->CountL() == KTestRecentNum);
       
   486 		TEST(view->CountL() == count + KTestRecentNum + 1);
       
   487 		}
       
   488 
       
   489 	User::After(0x1000000);
       
   490 
       
   491 	TTime now;
       
   492 	now.UniversalTime();
       
   493 	now+=(TTimeIntervalDays )1;
       
   494 
       
   495 	// Clear all the events
       
   496 	active->StartL();
       
   497 	aClient.ClearLog(now, active->iStatus);
       
   498 	CActiveScheduler::Start();
       
   499 	TEST2(active->iStatus.Int(), KErrNone);
       
   500 
       
   501 	TEST(!view->SetFilterL(*filter, active->iStatus));
       
   502 	TEST(!recent->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
       
   503 	TEST(view->CountL() == 0 && recent->CountL() == 0);
       
   504 
       
   505 	CleanupStack::PopAndDestroy(5); // filter, recent, view, active, event
       
   506 	}
       
   507 
       
   508 /**
       
   509 @SYMTestCaseID          SYSLIB-LOGENG-CT-0879
       
   510 @SYMTestCaseDesc	    Tests for maximum number of events that a recent event list holds
       
   511 @SYMTestPriority 	    High
       
   512 @SYMTestActions  	    Set the event configuration data of recent log size(10) to maximum and 
       
   513 						Add events to the log.Set the filter on the view and check for NO error.
       
   514 	                    Reduce the recent log size(5)  and set the new configuration.
       
   515 						Clear all the events and test for no errors and the total count of events and the logviewrecent should be zero.
       
   516 						Tests for CLogViewRecent::SetRecentListL
       
   517 @SYMTestExpectedResults Test must not fail
       
   518 @SYMREQ                 REQ0000
       
   519 */
       
   520 LOCAL_C void TestMaxRecentSizeConfigL(CLogClient& aClient)
       
   521 	{
       
   522 	test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0879 "));
       
   523 	CLogEvent* event = CLogEvent::NewL();
       
   524 	CleanupStack::PushL(event);
       
   525 
       
   526 	// Incoming
       
   527 	TBuf<KLogMaxDirectionLength> buf;
       
   528 	aClient.GetString(buf, R_LOG_DIR_IN);
       
   529 
       
   530 	event->SetEventType(KLogCallEventTypeUid);
       
   531 	event->SetDirection(buf);
       
   532 
       
   533 	CTestActive* active = new(ELeave)CTestActive();
       
   534 	CleanupStack::PushL(active);
       
   535 
       
   536 	CLogViewRecent* recent = CLogViewRecent::NewL(aClient);
       
   537 	CleanupStack::PushL(recent);
       
   538 
       
   539 	TLogConfig config;
       
   540 
       
   541 	// Get log configuration
       
   542 	active->StartL();
       
   543 	aClient.GetConfig(config, active->iStatus);
       
   544 	CActiveScheduler::Start();
       
   545 	TEST2(active->iStatus.Int(), KErrNone);
       
   546 
       
   547 	// Set the maximum log size
       
   548 	config.iMaxLogSize = KTestRecentNum * 2;
       
   549 	config.iMaxRecentLogSize = KTestRecentNum;
       
   550 
       
   551 	// Change the log engine config
       
   552 	active->StartL();
       
   553 	aClient.ChangeConfig(config, active->iStatus);
       
   554 	CActiveScheduler::Start();
       
   555 	TEST2(active->iStatus.Int(), KErrNone);
       
   556 
       
   557 	// Initialise the views - There should be no events
       
   558 	TEST(!recent->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
       
   559 
       
   560 	// Add a number of events
       
   561 	TInt count;
       
   562 	for(count = 0; count < KTestRecentNum; count++)
       
   563 		{
       
   564 		event->SetContact(count);
       
   565 
       
   566 		active->StartL();
       
   567 		aClient.AddEvent(*event, active->iStatus);
       
   568 		CActiveScheduler::Start();
       
   569 		TEST2(active->iStatus.Int(), KErrNone);
       
   570 		}
       
   571 
       
   572 	TEST(recent->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
       
   573 	active->StartL();
       
   574 	CActiveScheduler::Start();
       
   575 	TEST2(active->iStatus.Int(), KErrNone);
       
   576 
       
   577 	TEST(recent->CountL() == KTestRecentNum);
       
   578 
       
   579 	// Reduce the maximum allowed recent list size
       
   580 	// The oldest ones should be removed
       
   581 	config.iMaxRecentLogSize = KTestRecentNum / 2;
       
   582 
       
   583 	active->StartL();
       
   584 	aClient.ChangeConfig(config, active->iStatus);
       
   585 	CActiveScheduler::Start();
       
   586 	TEST2(active->iStatus.Int(), KErrNone);
       
   587 
       
   588 	TEST(recent->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
       
   589 	active->StartL();
       
   590 	CActiveScheduler::Start();
       
   591 	TEST2(active->iStatus.Int(), KErrNone);
       
   592 
       
   593 	TEST(recent->CountL() == KTestRecentNum / 2);
       
   594 	User::After(0x1000000);
       
   595 
       
   596 	TTime now;
       
   597 	now.UniversalTime();
       
   598 	now+=(TTimeIntervalDays )1;
       
   599 
       
   600 	// Clear all the events
       
   601 	active->StartL();
       
   602 	aClient.ClearLog(now, active->iStatus);
       
   603 	CActiveScheduler::Start();
       
   604 	TEST2(active->iStatus.Int(), KErrNone);
       
   605 
       
   606 	TEST(!recent->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
       
   607 	TEST(recent->CountL() == 0);
       
   608 
       
   609 	CleanupStack::PopAndDestroy(3); // recent, active, event
       
   610 	}
       
   611 
       
   612 /**
       
   613 @SYMTestCaseID          SYSLIB-LOGENG-CT-0880
       
   614 @SYMTestCaseDesc	    Tests for CLogViewRecent::SetRecentListL(),CLogViewRecent::DuplicatesL() functions
       
   615 @SYMTestPriority 	    High
       
   616 @SYMTestActions  	    Set the event configuration data of recent log size(10) to maximum and 
       
   617 						Add events to the log.Set the filter on the view and check for NO error.
       
   618 	                    Reduce the recent log size(5)  and set the new configuration.
       
   619 						Clear all the events and test for no errors and the total count of events and the logviewrecent should be zero.
       
   620 						Tests for CLogViewRecent::SetRecentListL()
       
   621 @SYMTestExpectedResults Test must not fail
       
   622 @SYMREQ                 REQ0000
       
   623 */
       
   624 LOCAL_C void TestMaxRecentSize2L(CLogClient& aClient)
       
   625 	{
       
   626 	test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0880 "));
       
   627 	CLogEvent* event = CLogEvent::NewL();
       
   628 	CleanupStack::PushL(event);
       
   629 
       
   630 	// Incoming
       
   631 	TBuf<KLogMaxDirectionLength> buf;
       
   632 	aClient.GetString(buf, R_LOG_DIR_IN);
       
   633 
       
   634 	event->SetEventType(KLogCallEventTypeUid);
       
   635 	event->SetDirection(buf);
       
   636 
       
   637 	CTestActive* active = new(ELeave)CTestActive();
       
   638 	CleanupStack::PushL(active);
       
   639 
       
   640 	CLogViewRecent* recent = CLogViewRecent::NewL(aClient);
       
   641 	CleanupStack::PushL(recent);
       
   642 
       
   643 	CLogViewDuplicate* dup = CLogViewDuplicate::NewL(aClient);
       
   644 	CleanupStack::PushL(dup);
       
   645 
       
   646 	CLogFilter* filter = CLogFilter::NewL();
       
   647 	CleanupStack::PushL(filter);
       
   648 
       
   649 	TLogConfig config;
       
   650 
       
   651 	// Get log configuration
       
   652 	active->StartL();
       
   653 	aClient.GetConfig(config, active->iStatus);
       
   654 	CActiveScheduler::Start();
       
   655 	TEST2(active->iStatus.Int(), KErrNone);
       
   656 
       
   657 	// Set the maximum log size
       
   658 	config.iMaxLogSize = (KTestRecentNum * KTestDuplicateNum) * 2;
       
   659 	config.iMaxRecentLogSize = KTestRecentNum;
       
   660 
       
   661 	// Change the log engine config
       
   662 	active->StartL();
       
   663 	aClient.ChangeConfig(config, active->iStatus);
       
   664 	CActiveScheduler::Start();
       
   665 	TEST2(active->iStatus.Int(), KErrNone);
       
   666 
       
   667 	// Initialise the view - There should be no events
       
   668 	TEST(!recent->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
       
   669 
       
   670 	// Add a number of events
       
   671 	TInt count;
       
   672 	for(count = 0; count < KTestRecentNum; count++)
       
   673 		{
       
   674 		TBuf<KLogMaxRemotePartyLength> buf;
       
   675 		buf.Format(KTestRemoteParty, count);
       
   676 		event->SetRemoteParty(buf);
       
   677 
       
   678 		active->StartL();
       
   679 		aClient.AddEvent(*event, active->iStatus);
       
   680 		CActiveScheduler::Start();
       
   681 		TEST2(active->iStatus.Int(), KErrNone);
       
   682 
       
   683 		// Add some duplicates
       
   684 		TInt duplicate;
       
   685 		for(duplicate = 0; duplicate < KTestDuplicateNum; duplicate++)
       
   686 			{
       
   687 			active->StartL();
       
   688 			aClient.AddEvent(*event, active->iStatus);
       
   689 			CActiveScheduler::Start();
       
   690 			TEST2(active->iStatus.Int(), KErrNone);
       
   691 			}
       
   692 
       
   693 		// The views should now have the correct number of events
       
   694 		TEST(recent->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
       
   695 		active->StartL();
       
   696 		CActiveScheduler::Start();
       
   697 		TEST2(active->iStatus.Int(), KErrNone);
       
   698 
       
   699 		TEST(recent->CountL() == count + 1);
       
   700 
       
   701 		TEST(recent->DuplicatesL(*dup, active->iStatus));
       
   702 		active->StartL();
       
   703 		CActiveScheduler::Start();
       
   704 		TEST2(active->iStatus.Int(), KErrNone);
       
   705 
       
   706 		TEST(dup->CountL() == KTestDuplicateNum);
       
   707 		}
       
   708 
       
   709 	event->SetRemoteParty(KNullDesC);
       
   710 
       
   711 	// Add the more events - the old ones should be removed
       
   712 	for(count = 0; count < KTestRecentNum; count++)
       
   713 		{
       
   714 		// Add another event - the oldest should be removed from recent list
       
   715 		active->StartL();
       
   716 		aClient.AddEvent(*event, active->iStatus);
       
   717 		CActiveScheduler::Start();
       
   718 		TEST2(active->iStatus.Int(), KErrNone);
       
   719 
       
   720 		TEST(recent->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
       
   721 		active->StartL();
       
   722 		CActiveScheduler::Start();
       
   723 		TEST2(active->iStatus.Int(), KErrNone);
       
   724 
       
   725 		// Check an event has been removed from recent view
       
   726 		TEST(recent->CountL() == KTestRecentNum);
       
   727 		}
       
   728 
       
   729 	User::After(0x1000000);
       
   730 
       
   731 	TTime now;
       
   732 	now.UniversalTime();
       
   733 	now+=(TTimeIntervalDays )1;
       
   734 
       
   735 	// Clear all the events
       
   736 	active->StartL();
       
   737 	aClient.ClearLog(now, active->iStatus);
       
   738 	CActiveScheduler::Start();
       
   739 	TEST2(active->iStatus.Int(), KErrNone);
       
   740 
       
   741 	TEST(!recent->DuplicatesL(*dup, active->iStatus));
       
   742 
       
   743 	CleanupStack::PopAndDestroy(5); // filter, dup, recent, active, event
       
   744 	}
       
   745 
       
   746 /**
       
   747 @SYMTestCaseID          SYSLIB-LOGENG-CT-0881
       
   748 @SYMTestCaseDesc	    Tests for purge
       
   749 @SYMTestPriority 	    High
       
   750 @SYMTestActions  	    Get the event type data 
       
   751 @SYMTestExpectedResults Test must not fail
       
   752 @SYMREQ                 REQ0000
       
   753 */
       
   754 LOCAL_C void TestNoPurgeWithGetL(CLogClient& aClient)
       
   755 	{
       
   756 	test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0881 "));
       
   757 	CLogEvent* event = CLogEvent::NewL();
       
   758 	CleanupStack::PushL(event);
       
   759 	event->SetEventType(KLogCallEventTypeUid);
       
   760 
       
   761 	CTestActive* active = new(ELeave)CTestActive();
       
   762 	CleanupStack::PushL(active);
       
   763 
       
   764 	TLogConfig config;
       
   765 
       
   766 	// Get log configuration
       
   767 	active->StartL();
       
   768 	aClient.GetConfig(config, active->iStatus);
       
   769 	CActiveScheduler::Start();
       
   770 	TEST2(active->iStatus.Int(), KErrNone);
       
   771 
       
   772 	// Set the maximum log age
       
   773 	TInt oldAge = config.iMaxEventAge;
       
   774 	config.iMaxEventAge = 24 * 60 * 60;
       
   775 
       
   776 	// Change the log engine config
       
   777 	active->StartL();
       
   778 	aClient.ChangeConfig(config, active->iStatus);
       
   779 	CActiveScheduler::Start();
       
   780 	TEST2(active->iStatus.Int(), KErrNone);
       
   781 
       
   782 	active->StartL();
       
   783 	aClient.AddEvent(*event, active->iStatus);
       
   784 	CActiveScheduler::Start();
       
   785 	TEST2(active->iStatus.Int(), KErrNone);
       
   786 
       
   787 	// Check that the event can be retrieved
       
   788 	active->StartL();
       
   789 	aClient.GetEvent(*event, active->iStatus);
       
   790 	CActiveScheduler::Start();
       
   791 	TEST2(active->iStatus.Int(), KErrNone);
       
   792 
       
   793 	// Wait for 15 seconds (just to be safe)
       
   794 	User::After(15000000);
       
   795 
       
   796 	// Check that the event can still be retrieved
       
   797 	active->StartL();
       
   798 	aClient.GetEvent(*event, active->iStatus);
       
   799 	CActiveScheduler::Start();
       
   800 	TEST2(active->iStatus.Int(), KErrNone);
       
   801 
       
   802 	// Perform a dummy change
       
   803 	event->SetTime(event->Time() - TTimeIntervalDays(2));
       
   804 	active->StartL();
       
   805 	aClient.ChangeEvent(*event, active->iStatus);
       
   806 	CActiveScheduler::Start();
       
   807 	TEST2(active->iStatus.Int(), KErrNone);
       
   808 
       
   809 	// Check the event has been removed
       
   810 	active->StartL();
       
   811 	aClient.GetEvent(*event, active->iStatus);
       
   812 	CActiveScheduler::Start();
       
   813 	TEST2(active->iStatus.Int(), KErrNotFound);;
       
   814 
       
   815 	// Reset the config
       
   816 	config.iMaxEventAge = oldAge;
       
   817 
       
   818 	// Change the log engine config
       
   819 	active->StartL();
       
   820 	aClient.ChangeConfig(config, active->iStatus);
       
   821 	CActiveScheduler::Start();
       
   822 	TEST2(active->iStatus.Int(), KErrNone);
       
   823 
       
   824 	CleanupStack::PopAndDestroy(2); // active, event	
       
   825 	}
       
   826 
       
   827 /**
       
   828 @SYMTestCaseID          SYSLIB-LOGENG-CT-0882
       
   829 @SYMTestCaseDesc	    Tests for CLogClient::ClearLog() function
       
   830 @SYMTestPriority 	    High
       
   831 @SYMTestActions  	    Change locale settings and log duration to 1 day and test for number of event types in log 
       
   832 @SYMTestExpectedResults Test must not fail
       
   833 @SYMREQ                 REQ0000
       
   834 */
       
   835 LOCAL_C void TestClearLog1L(CLogClient& aClient)
       
   836 	{
       
   837 	test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0882 "));
       
   838 	CLogEvent* event = CLogEvent::NewL();
       
   839 	CleanupStack::PushL(event);
       
   840 	event->SetEventType(KLogCallEventTypeUid);
       
   841 
       
   842 	CTestActive* active = new(ELeave)CTestActive();
       
   843 	CleanupStack::PushL(active);
       
   844 
       
   845 	CLogViewEvent* view = CLogViewEvent::NewL(aClient);
       
   846 	CleanupStack::PushL(view);
       
   847 
       
   848 	// change Locale
       
   849 	TLocale locale;
       
   850 	locale.SetCountryCode(47);//Norway
       
   851 	locale.SetDateFormat(EDateEuropean);
       
   852 	locale.SetTimeFormat(ETime12);
       
   853 	for (int i=0; i<4; i++)
       
   854          {
       
   855          locale.SetTimeSeparator(TChar('.'),i);
       
   856          locale.SetDateSeparator(TChar(':'),i);
       
   857          }
       
   858 	locale.Set();
       
   859 
       
   860 	// change the log duration settings to 1 day  
       
   861 	TLogConfig config;
       
   862 	active->StartL();
       
   863 	aClient.GetConfig(config, active->iStatus);
       
   864 	CActiveScheduler::Start();
       
   865 	TEST2(active->iStatus.Int(), KErrNone);
       
   866 
       
   867 	config.iMaxLogSize = KTestEventAge * 2;
       
   868 	config.iMaxEventAge = 86400;
       
   869 	active->StartL();
       
   870 	aClient.ChangeConfig(config, active->iStatus);
       
   871 	CActiveScheduler::Start();
       
   872 	TEST2(active->iStatus.Int(), KErrNone);
       
   873 
       
   874 	// add a call event
       
   875 	active->StartL();
       
   876 	aClient.AddEvent(*event, active->iStatus);
       
   877 	CActiveScheduler::Start();
       
   878 	TEST2(active->iStatus.Int(), KErrNone);
       
   879 	User::After(1000000);
       
   880 	TTime now;
       
   881 	now.HomeTime();	
       
   882 	event->SetTime(now);
       
   883 	active->StartL();
       
   884 	aClient.ChangeEvent(*event, active->iStatus);
       
   885 	CActiveScheduler::Start();
       
   886 	TEST2(active->iStatus.Int(), KErrNone);
       
   887 
       
   888 	// forward two days
       
   889 	now+=(TTimeIntervalDays )2;
       
   890 	User::SetHomeTime(now);
       
   891 		
       
   892 	// dummy call ensures ClearLog() is called
       
   893 	active->StartL();
       
   894 	aClient.ChangeConfig(config, active->iStatus);
       
   895 	CActiveScheduler::Start();
       
   896 	TEST2(active->iStatus.Int(), KErrNone);
       
   897 
       
   898 	// try to retrieve event
       
   899 	active->StartL();
       
   900 	aClient.GetEvent(*event, active->iStatus);
       
   901 	CActiveScheduler::Start();
       
   902 	TEST2(active->iStatus.Int(), KErrNotFound);;
       
   903 
       
   904 	TEST(view->CountL() == 0);
       
   905 
       
   906 	CleanupStack::PopAndDestroy(3); // view, active, event
       
   907 	}
       
   908 
       
   909 /**
       
   910 @SYMTestCaseID          SYSLIB-LOGENG-CT-0883
       
   911 @SYMTestCaseDesc	    Tests for CLogClient::ClearLog() function
       
   912 @SYMTestPriority 	    High
       
   913 @SYMTestActions  	    Change locale settings,call up ClearLog and try to retrieve event,test for count of number of events in the view.
       
   914 @SYMTestExpectedResults Test must not fail
       
   915 @SYMREQ                 REQ0000
       
   916 */
       
   917 LOCAL_C void TestClearLog2L(CLogClient& aClient)
       
   918 	{
       
   919 	test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0883 "));
       
   920 	CLogEvent* event = CLogEvent::NewL();
       
   921 	CleanupStack::PushL(event);
       
   922 	event->SetEventType(KLogCallEventTypeUid);
       
   923 
       
   924 	CTestActive* active = new(ELeave)CTestActive();
       
   925 	CleanupStack::PushL(active);
       
   926 
       
   927 	CLogViewEvent* view = CLogViewEvent::NewL(aClient);
       
   928 	CleanupStack::PushL(view);
       
   929 
       
   930 	// change Locale
       
   931 	TLocale locale;
       
   932 	locale.SetCountryCode(47);//Norway
       
   933 	locale.SetDateFormat(EDateEuropean);
       
   934 	locale.SetTimeFormat(ETime12);
       
   935 	for (int i=0; i<4; i++)
       
   936          {
       
   937          locale.SetTimeSeparator(TChar('.'),i);
       
   938          locale.SetDateSeparator(TChar(':'),i);
       
   939          }
       
   940 	locale.Set();
       
   941 
       
   942 	// change the log duration settings to 1 day  
       
   943 	TLogConfig config;
       
   944 	active->StartL();
       
   945 	aClient.GetConfig(config, active->iStatus);
       
   946 	CActiveScheduler::Start();
       
   947 	TEST2(active->iStatus.Int(), KErrNone);
       
   948 
       
   949 	config.iMaxLogSize = KTestEventAge * 2;
       
   950 	config.iMaxEventAge = 86400;
       
   951 	active->StartL();
       
   952 	aClient.ChangeConfig(config, active->iStatus);
       
   953 	CActiveScheduler::Start();
       
   954 	TEST2(active->iStatus.Int(), KErrNone);
       
   955 
       
   956 	// add a call event
       
   957 	active->StartL();
       
   958 	aClient.AddEvent(*event, active->iStatus);
       
   959 	CActiveScheduler::Start();
       
   960 	TEST2(active->iStatus.Int(), KErrNone);
       
   961 	User::After(1000000);
       
   962 	TTime now;
       
   963 	now.HomeTime();	
       
   964 	event->SetTime(now);
       
   965 	active->StartL();
       
   966 	aClient.ChangeEvent(*event, active->iStatus);
       
   967 	CActiveScheduler::Start();
       
   968 	TEST2(active->iStatus.Int(), KErrNone);
       
   969 
       
   970 	// forward two days
       
   971 	now+=(TTimeIntervalDays )2;
       
   972 	User::SetHomeTime(now);
       
   973 		
       
   974 	active->StartL();
       
   975 	aClient.ClearLog(now, active->iStatus);
       
   976 	CActiveScheduler::Start();
       
   977 	TEST2(active->iStatus.Int(), KErrNone);
       
   978 
       
   979 	// try to retrieve event
       
   980 	active->StartL();
       
   981 	aClient.GetEvent(*event, active->iStatus);
       
   982 	CActiveScheduler::Start();
       
   983 	TEST2(active->iStatus.Int(), KErrNotFound);;
       
   984 
       
   985 	TEST(view->CountL() == 0);
       
   986 
       
   987 	CleanupStack::PopAndDestroy(3); // view, active, event
       
   988 	}
       
   989 
       
   990 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
       
   991 
       
   992 /**
       
   993 @SYMTestCaseID			PDS-LOGENG-UT-4036
       
   994 @SYMTestCaseDesc		Clear log events with specific SimId test.
       
   995 						The test adds 3 events with different SimIds and then checks that
       
   996 						CLogEvent::ClearLog() deletes only the event with the specified id.
       
   997 @SYMTestActions			Clear log events with specific SimId test.
       
   998 @SYMTestExpectedResults Test must not fail
       
   999 @SYMTestPriority		High
       
  1000 @SYMREQ					REQ12748
       
  1001 */
       
  1002 void ClearLogSimIdL(CLogClient& aClient)
       
  1003 	{//This test case is compiled only when SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM macro is defined.
       
  1004 	const TSimId KSimId1 = 4100000000U;
       
  1005 	const TSimId KSimId2 = 100;
       
  1006 	const TSimId KSimId3 = 1678;
       
  1007 	
       
  1008 	TTime now;
       
  1009 	now.UniversalTime();
       
  1010 	
       
  1011 	TDateTime dt(now.DateTime());
       
  1012 	dt.SetHour(dt.Hour() - 1);
       
  1013 	TTime date(dt);
       
  1014 	
       
  1015 	TTime threshold(date);
       
  1016 	threshold += TTimeIntervalSeconds(10);
       
  1017 	
       
  1018 	CTestActive* active = new(ELeave)CTestActive();
       
  1019 	CleanupStack::PushL(active);
       
  1020 
       
  1021 	//////// Event1 ///////////////////////////
       
  1022 	CLogEvent* event1 = CLogEvent::NewL();
       
  1023 	CleanupStack::PushL(event1);
       
  1024 	event1->SetEventType(KLogCallEventTypeUid);
       
  1025 	event1->SetSimId(KSimId1);
       
  1026 
       
  1027 	active->StartL();
       
  1028 	aClient.AddEvent(*event1, active->iStatus);
       
  1029 	CActiveScheduler::Start();
       
  1030 	TEST2(active->iStatus.Int(), KErrNone);
       
  1031 
       
  1032 	event1->SetTime(date);
       
  1033 
       
  1034 	active->StartL();
       
  1035 	aClient.ChangeEvent(*event1, active->iStatus);
       
  1036 	CActiveScheduler::Start();
       
  1037 	TEST2(active->iStatus.Int(), KErrNone);
       
  1038 
       
  1039 	//////// Event2 ///////////////////////////
       
  1040 	CLogEvent* event2 = CLogEvent::NewL();
       
  1041 	CleanupStack::PushL(event2);
       
  1042 	event2->SetEventType(KLogCallEventTypeUid);
       
  1043 	event2->SetSimId(KSimId2);
       
  1044 
       
  1045 	active->StartL();
       
  1046 	aClient.AddEvent(*event2, active->iStatus);
       
  1047 	CActiveScheduler::Start();
       
  1048 	TEST2(active->iStatus.Int(), KErrNone);
       
  1049 
       
  1050 	event2->SetTime(date);
       
  1051 
       
  1052 	active->StartL();
       
  1053 	aClient.ChangeEvent(*event2, active->iStatus);
       
  1054 	CActiveScheduler::Start();
       
  1055 	TEST2(active->iStatus.Int(), KErrNone);
       
  1056 
       
  1057 	//////// Event3 ///////////////////////////
       
  1058 	CLogEvent* event3 = CLogEvent::NewL();
       
  1059 	CleanupStack::PushL(event3);
       
  1060 	event3->SetEventType(KLogCallEventTypeUid);
       
  1061 	event3->SetSimId(KSimId3);
       
  1062 
       
  1063 	active->StartL();
       
  1064 	aClient.AddEvent(*event3, active->iStatus);
       
  1065 	CActiveScheduler::Start();
       
  1066 	TEST2(active->iStatus.Int(), KErrNone);
       
  1067 
       
  1068 	event3->SetTime(date);
       
  1069 
       
  1070 	active->StartL();
       
  1071 	aClient.ChangeEvent(*event3, active->iStatus);
       
  1072 	CActiveScheduler::Start();
       
  1073 	TEST2(active->iStatus.Int(), KErrNone);
       
  1074 	
       
  1075 	//////////////////////////////////////////////////////////////////////////////////////////////////
       
  1076 	
       
  1077 	//Delete event3 /////////////////////////
       
  1078 	aClient.ClearLog(threshold, KSimId3, active->iStatus);
       
  1079 	active->StartL();	
       
  1080 	CActiveScheduler::Start();
       
  1081 	TEST2(active->iStatus.Int(), KErrNone);
       
  1082 	//Event1 and event2 should be there
       
  1083 	active->StartL();
       
  1084 	aClient.GetEvent(*event1, active->iStatus);
       
  1085 	CActiveScheduler::Start();
       
  1086 	TEST2(active->iStatus.Int(), KErrNone);
       
  1087 	active->StartL();
       
  1088 	aClient.GetEvent(*event2, active->iStatus);
       
  1089 	CActiveScheduler::Start();
       
  1090 	TEST2(active->iStatus.Int(), KErrNone);
       
  1091 	active->StartL();
       
  1092 	aClient.GetEvent(*event3, active->iStatus);
       
  1093 	CActiveScheduler::Start();
       
  1094 	TEST2(active->iStatus.Int(), KErrNotFound);
       
  1095 	
       
  1096 	//Delete event2 /////////////////////////
       
  1097 	aClient.ClearLog(threshold, KSimId2, active->iStatus);
       
  1098 	active->StartL();	
       
  1099 	CActiveScheduler::Start();
       
  1100 	TEST2(active->iStatus.Int(), KErrNone);
       
  1101 	//Event1 should be there
       
  1102 	active->StartL();
       
  1103 	aClient.GetEvent(*event1, active->iStatus);
       
  1104 	CActiveScheduler::Start();
       
  1105 	TEST2(active->iStatus.Int(), KErrNone);
       
  1106 	active->StartL();
       
  1107 	aClient.GetEvent(*event2, active->iStatus);
       
  1108 	CActiveScheduler::Start();
       
  1109 	TEST2(active->iStatus.Int(), KErrNotFound);
       
  1110 	active->StartL();
       
  1111 	aClient.GetEvent(*event3, active->iStatus);
       
  1112 	CActiveScheduler::Start();
       
  1113 	TEST2(active->iStatus.Int(), KErrNotFound);
       
  1114 	
       
  1115 	//Delete event1 /////////////////////////
       
  1116 	aClient.ClearLog(threshold, KSimId1, active->iStatus);
       
  1117 	active->StartL();	
       
  1118 	CActiveScheduler::Start();
       
  1119 	TEST2(active->iStatus.Int(), KErrNone);
       
  1120 	//All events deleted
       
  1121 	active->StartL();
       
  1122 	aClient.GetEvent(*event1, active->iStatus);
       
  1123 	CActiveScheduler::Start();
       
  1124 	TEST2(active->iStatus.Int(), KErrNotFound);
       
  1125 	active->StartL();
       
  1126 	aClient.GetEvent(*event2, active->iStatus);
       
  1127 	CActiveScheduler::Start();
       
  1128 	TEST2(active->iStatus.Int(), KErrNotFound);
       
  1129 	active->StartL();
       
  1130 	aClient.GetEvent(*event3, active->iStatus);
       
  1131 	CActiveScheduler::Start();
       
  1132 	TEST2(active->iStatus.Int(), KErrNotFound);
       
  1133 
       
  1134 	CleanupStack::PopAndDestroy(4); //event3, event2, event1, active
       
  1135 	}
       
  1136 
       
  1137 /**
       
  1138 @SYMTestCaseID			PDS-LOGENG-UT-4037
       
  1139 @SYMTestCaseDesc		Clear log events from a recent list with specific SimId test.
       
  1140 						The test adds 3 events to a recent list with different SimIds and then checks that
       
  1141 						CLogEvent::ClearLog() deletes only the event with the specified id.
       
  1142 @SYMTestActions			Clear log events from a recent list with specific SimId test.
       
  1143 @SYMTestExpectedResults Test must not fail
       
  1144 @SYMTestPriority 	    High
       
  1145 @SYMREQ					REQ12748
       
  1146 */
       
  1147 void ClearLogRecentSimIdL(CLogClient& aClient)
       
  1148 	{//This test case is compiled only when SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM macro is defined.
       
  1149 	const TSimId KSimId1 = 4200110000U;
       
  1150 	const TSimId KSimId2 = 38223;
       
  1151 	const TSimId KSimId3 = 239816;
       
  1152 	
       
  1153 	const TUid KEvTypeUid = {KLogCallEventType};
       
  1154 	_LIT(KEvDirection, "Missed call");
       
  1155 	
       
  1156 	CTestActive* active = new(ELeave)CTestActive();
       
  1157 	CleanupStack::PushL(active);
       
  1158 
       
  1159 	//////// Event1 ///////////////////////////
       
  1160 	CLogEvent* event1 = CLogEvent::NewL();
       
  1161 	CleanupStack::PushL(event1);
       
  1162 	event1->SetEventType(KEvTypeUid);
       
  1163 	event1->SetDirection(KEvDirection);
       
  1164 	event1->SetNumber(_L("12345678"));
       
  1165 	event1->SetSimId(KSimId1);
       
  1166 	active->StartL();
       
  1167 	aClient.AddEvent(*event1, active->iStatus);
       
  1168 	CActiveScheduler::Start();
       
  1169 	TEST2(active->iStatus.Int(), KErrNone);
       
  1170 	//////// Event2 ///////////////////////////
       
  1171 	CLogEvent* event2 = CLogEvent::NewL();
       
  1172 	CleanupStack::PushL(event2);
       
  1173 	event2->SetEventType(KEvTypeUid);
       
  1174 	event2->SetDirection(KEvDirection);
       
  1175 	event2->SetNumber(_L("87654321"));
       
  1176 	event2->SetSimId(KSimId2);
       
  1177 	active->StartL();
       
  1178 	aClient.AddEvent(*event2, active->iStatus);
       
  1179 	CActiveScheduler::Start();
       
  1180 	TEST2(active->iStatus.Int(), KErrNone);
       
  1181 	//////// Event3 ///////////////////////////
       
  1182 	CLogEvent* event3 = CLogEvent::NewL();
       
  1183 	CleanupStack::PushL(event3);
       
  1184 	event3->SetEventType(KEvTypeUid);
       
  1185 	event3->SetDirection(KEvDirection);
       
  1186 	event3->SetNumber(_L("99229922"));
       
  1187 	event3->SetSimId(KSimId3);
       
  1188 	active->StartL();
       
  1189 	aClient.AddEvent(*event3, active->iStatus);
       
  1190 	CActiveScheduler::Start();
       
  1191 	TEST2(active->iStatus.Int(), KErrNone);
       
  1192 	//////////////////////////////////////////////////////////////////////////////////////////////////
       
  1193 	
       
  1194 	//Delete event3 /////////////////////////
       
  1195 	aClient.ClearLog(KLogRecentMissedCalls, KSimId3, active->iStatus);
       
  1196 	active->StartL();	
       
  1197 	CActiveScheduler::Start();
       
  1198 	TEST2(active->iStatus.Int(), KErrNone);
       
  1199 	//Event1 and event2 should be there
       
  1200 	CLogViewRecent* view = CLogViewRecent::NewL(aClient);
       
  1201 	CleanupStack::PushL(view);
       
  1202 	TBool rc = view->SetRecentListL(KLogRecentMissedCalls, active->iStatus);
       
  1203 	TEST(rc);
       
  1204 	active->StartL();
       
  1205 	CActiveScheduler::Start();
       
  1206 	TEST2(active->iStatus.Int(), KErrNone);
       
  1207 
       
  1208 	TInt count = view->CountL();
       
  1209 	TEST2(count, 2);
       
  1210 	rc = view->FirstL(active->iStatus);
       
  1211 	TEST(rc);
       
  1212 	active->StartL();
       
  1213 	CActiveScheduler::Start();
       
  1214 	TEST2(active->iStatus.Int(), KErrNone);
       
  1215 	const CLogEvent& e1 = view->Event();
       
  1216 	TEST(e1.SimId() == KSimId2 || e1.SimId() == KSimId1);
       
  1217 	rc = view->NextL(active->iStatus);
       
  1218 	TEST(rc);
       
  1219 	active->StartL();
       
  1220 	CActiveScheduler::Start();
       
  1221 	TEST2(active->iStatus.Int(), KErrNone);
       
  1222 	const CLogEvent& e2 = view->Event();
       
  1223 	TEST(e2.SimId() == KSimId2 || e2.SimId() == KSimId1);
       
  1224 	TEST(e1.Id() != e2.Id());
       
  1225 
       
  1226 	CleanupStack::PopAndDestroy(view);
       
  1227 	
       
  1228 	//Delete event1 /////////////////////////
       
  1229 	aClient.ClearLog(KLogRecentMissedCalls, KSimId1, active->iStatus);
       
  1230 	active->StartL();	
       
  1231 	CActiveScheduler::Start();
       
  1232 	TEST2(active->iStatus.Int(), KErrNone);
       
  1233 	//Only event2 should be there
       
  1234 	view = CLogViewRecent::NewL(aClient);
       
  1235 	CleanupStack::PushL(view);
       
  1236 	rc = view->SetRecentListL(KLogRecentMissedCalls, active->iStatus);
       
  1237 	TEST(rc);
       
  1238 	active->StartL();
       
  1239 	CActiveScheduler::Start();
       
  1240 	TEST2(active->iStatus.Int(), KErrNone);
       
  1241 	count = view->CountL();
       
  1242 	TEST2(count, 1);
       
  1243 	rc = view->FirstL(active->iStatus);
       
  1244 	TEST(rc);
       
  1245 	active->StartL();
       
  1246 	CActiveScheduler::Start();
       
  1247 	TEST2(active->iStatus.Int(), KErrNone);
       
  1248 	const CLogEvent& e3 = view->Event();
       
  1249 	TEST(e3.SimId() == KSimId2);
       
  1250 
       
  1251 	CleanupStack::PopAndDestroy(5); //view, event3, event2, event1, active
       
  1252 	}
       
  1253 
       
  1254 #endif//SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
       
  1255 
       
  1256 void doTestsL()
       
  1257 	{
       
  1258 	TestUtils::Initialize(_L("T_LOGPURGE"));
       
  1259 	TestUtils::DeleteDatabaseL();
       
  1260 
       
  1261 	CLogClient* client = CLogClient::NewL(theFs);
       
  1262 	CleanupStack::PushL(client);
       
  1263 
       
  1264 	test.Start(_L("Maximum Log Size"));
       
  1265 	TestMaxLogSizeL(*client);
       
  1266 	theLog.Write(_L8("Test 1 OK\n"));
       
  1267 
       
  1268 	test.Next(_L("Purge Log When Config Changed"));
       
  1269 	TestMaxLogSizeConfigL(*client);
       
  1270 	theLog.Write(_L8("Test 2 OK\n"));
       
  1271 
       
  1272 	test.Next(_L("Test purge by Maximum Log Age enabled/disabled"));
       
  1273 	TestMaxLogAgeL(*client, 0);	// disable purging by age
       
  1274 	TestMaxLogAgeL(*client, KTestEventAge * 60 * 60 * 24);  
       
  1275 	theLog.Write(_L8("Test 3 OK\n"));
       
  1276 
       
  1277 	test.Next(_L("Maximum Recent List Size"));
       
  1278 	TestMaxRecentSize1L(*client);
       
  1279 	theLog.Write(_L8("Test 4 OK\n"));
       
  1280 
       
  1281 	test.Next(_L("Purge Recent Lists When Config Changed"));
       
  1282 	TestMaxRecentSizeConfigL(*client);
       
  1283 	theLog.Write(_L8("Test 5 OK\n"));
       
  1284 
       
  1285 	test.Next(_L("Maximum Recent List Size With Duplicates"));
       
  1286 	TestMaxRecentSize2L(*client);
       
  1287 	theLog.Write(_L8("Test 6 OK\n"));
       
  1288 
       
  1289 	test.Next(_L("Check no purge when retrieving event"));
       
  1290 	TestNoPurgeWithGetL(*client);
       
  1291 	theLog.Write(_L8("Test 7 OK\n"));
       
  1292 
       
  1293 	test.Next(_L("Check ClearLog works for different locales"));
       
  1294 	TestClearLog1L(*client);
       
  1295 	TestClearLog2L(*client);
       
  1296  	theLog.Write(_L8("Test 8 OK\n"));
       
  1297 
       
  1298 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
       
  1299 	test.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4036 CLogClient::ClearLog() + SimId test"));
       
  1300  	ClearLogSimIdL(*client);
       
  1301  	theLog.Write(_L8("Test 9 OK\n"));
       
  1302 
       
  1303 	test.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4037 CLogClient::ClearLog()/recent + SimId test"));
       
  1304  	ClearLogRecentSimIdL(*client);
       
  1305  	theLog.Write(_L8("Test 10 OK\n"));
       
  1306 #endif 	
       
  1307  	
       
  1308 	CleanupStack::PopAndDestroy(); // client;
       
  1309 	}