loggingservices/eventlogger/test/src/t_logsimid.cpp
branchRCL_3
changeset 9 667e88a979d7
parent 0 08ec8eefde2f
equal deleted inserted replaced
8:fa9941cf3867 9:667e88a979d7
     1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    18 #include <s32mem.h>
    18 #include <s32mem.h>
    19 #include <e32math.h>
    19 #include <e32math.h>
    20 #include <bautils.h>
    20 #include <bautils.h>
    21 #include <logview.h>
    21 #include <logview.h>
    22 #include <logcli.h>
    22 #include <logcli.h>
    23 #include "TEST.H"
    23 #include "t_logutil2.h"
    24 #include "LogServSqlStrings.h"
    24 #include "LogServSqlStrings.h"
    25 
    25 
    26 #undef test  //there is a "test" macro which hides "RTest test" declaration.
    26 RTest TheTest(_L("t_logsimid"));
    27 
       
    28 RTest test(_L("LogEng - SimId tests"));
       
    29 
    27 
    30 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
    28 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
    31 
    29 
    32 const TLogId KEvId1 = 101;
    30 const TLogId KEvId1 = 101;
    33 _LIT(KEvDesc1, "Event Type Description 1");
    31 _LIT(KEvDesc1, "Event Type Description 1");
   261 	event->SetDataL(KEvData1);
   259 	event->SetDataL(KEvData1);
   262 	
   260 	
   263 	TTime st_time;
   261 	TTime st_time;
   264 	st_time.UniversalTime();
   262 	st_time.UniversalTime();
   265 	
   263 	
   266 	test.Printf(_L("Added events:\n"));
   264 	TheTest.Printf(_L("Added events:\n"));
   267 	TInt diffEvCount = KDiffEvCount;
   265 	TInt diffEvCount = KDiffEvCount;
   268 	for(TInt i=0;i<TheAddedEventCount;++i)
   266 	for(TInt i=0;i<TheAddedEventCount;++i)
   269 		{
   267 		{
   270 		event->SetSimId(KLogNullSimId);
   268 		event->SetSimId(KLogNullSimId);
   271 		event->SetDurationType(KEvDurationType1);
   269 		event->SetDurationType(KEvDurationType1);
   284 		CActiveScheduler::Start();
   282 		CActiveScheduler::Start();
   285 		TEST(!active->IsActive());
   283 		TEST(!active->IsActive());
   286 		TEST2(active->iStatus.Int(), KErrNone);
   284 		TEST2(active->iStatus.Int(), KErrNone);
   287 		if((i % 50) == 0)
   285 		if((i % 50) == 0)
   288 			{
   286 			{
   289 			test.Printf(_L("%d\r"), i);
   287 			TheTest.Printf(_L("%d\r"), i);
   290 			}
   288 			}
   291 		}
   289 		}
   292 	test.Printf(_L("%d\n"), TheAddedEventCount);
   290 	TheTest.Printf(_L("%d\n"), TheAddedEventCount);
   293 	
   291 	
   294 	TTime end_time;
   292 	TTime end_time;
   295 	end_time.UniversalTime();
   293 	end_time.UniversalTime();
   296 	
   294 	
   297 	CleanupStack::PopAndDestroy(event);
   295 	CleanupStack::PopAndDestroy(event);
   298 	
   296 	
   299 	CleanupStack::PopAndDestroy(active);
   297 	CleanupStack::PopAndDestroy(active);
   300 	CleanupStack::PopAndDestroy(client);
   298 	CleanupStack::PopAndDestroy(client);
   301 	
   299 	
   302 	TTimeIntervalMicroSeconds us = end_time.MicroSecondsFrom(st_time);
   300 	TTimeIntervalMicroSeconds us = end_time.MicroSecondsFrom(st_time);
   303 	test.Printf(_L("%d events added. Time: %ld milliseconds\n"), TheAddedEventCount, us.Int64() / 1000);
   301 	TheTest.Printf(_L("%d events added. Time: %ld milliseconds\n"), TheAddedEventCount, us.Int64() / 1000);
   304 	}
   302 	}
   305 
   303 
   306 void DoSetFilterL(TLogViewSimId aViewSimId, TInt aExpectedEventCount, 
   304 void DoSetFilterL(TLogViewSimId aViewSimId, TInt aExpectedEventCount, 
   307 				 CLogViewEvent& aLogView, CLogFilter& aLogFilter, CTestActive& aActive)
   305 				 CLogViewEvent& aLogView, CLogFilter& aLogFilter, CTestActive& aActive)
   308 	{
   306 	{
   327 	TEST(res);
   325 	TEST(res);
   328 	aActive.StartL();
   326 	aActive.StartL();
   329 	CActiveScheduler::Start();
   327 	CActiveScheduler::Start();
   330 	TEST2(aActive.iStatus.Int(), KErrNone);
   328 	TEST2(aActive.iStatus.Int(), KErrNone);
   331 	TInt count = aLogView.CountL();
   329 	TInt count = aLogView.CountL();
   332 	test.Printf(_L("===Events count: %d\n"), count);
   330 	TheTest.Printf(_L("===Events count: %d\n"), count);
   333 	TEST2(count, aExpectedEventCount);
   331 	TEST2(count, aExpectedEventCount);
   334 	}
   332 	}
   335 
   333 
   336 void DoTestViewEvent(TLogViewSimId aViewSimId, CLogViewEvent& aLogView)
   334 void DoTestViewEvent(TLogViewSimId aViewSimId, CLogViewEvent& aLogView)
   337 	{
   335 	{
   387 	st_time.UniversalTime();
   385 	st_time.UniversalTime();
   388 	DoSetFilterL(aViewSimId, aExpectedEventCount, *view, *filter, *active); 
   386 	DoSetFilterL(aViewSimId, aExpectedEventCount, *view, *filter, *active); 
   389 	TTime end_time;
   387 	TTime end_time;
   390 	end_time.UniversalTime();
   388 	end_time.UniversalTime();
   391 	TTimeIntervalMicroSeconds us = end_time.MicroSecondsFrom(st_time);
   389 	TTimeIntervalMicroSeconds us = end_time.MicroSecondsFrom(st_time);
   392 	test.Printf(_L("SetFilter(). Time: %ld milliseconds\n"), us.Int64() / 1000);
   390 	TheTest.Printf(_L("SetFilter(). Time: %ld milliseconds\n"), us.Int64() / 1000);
   393 	
   391 	
   394 	TInt count = 0; 
   392 	TInt count = 0; 
   395 	st_time.UniversalTime();
   393 	st_time.UniversalTime();
   396 	if(view->FirstL(active->iStatus))
   394 	if(view->FirstL(active->iStatus))
   397 		{
   395 		{
   405 			}
   403 			}
   406 		while(view->NextL(active->iStatus));
   404 		while(view->NextL(active->iStatus));
   407 		}
   405 		}
   408 	end_time.UniversalTime();
   406 	end_time.UniversalTime();
   409 	us = end_time.MicroSecondsFrom(st_time);
   407 	us = end_time.MicroSecondsFrom(st_time);
   410 	test.Printf(_L("Event view walk completed. Events count: %d. Time: %ld milliseconds\n"), count, us.Int64() / 1000);
   408 	TheTest.Printf(_L("Event view walk completed. Events count: %d. Time: %ld milliseconds\n"), count, us.Int64() / 1000);
   411 		
   409 		
   412 	CleanupStack::PopAndDestroy(filter);
   410 	CleanupStack::PopAndDestroy(filter);
   413 	CleanupStack::PopAndDestroy(view);
   411 	CleanupStack::PopAndDestroy(view);
   414 	CleanupStack::PopAndDestroy(active);
   412 	CleanupStack::PopAndDestroy(active);
   415 	CleanupStack::PopAndDestroy(client);
   413 	CleanupStack::PopAndDestroy(client);
   433 	CleanupStack::PopAndDestroy(type);
   431 	CleanupStack::PopAndDestroy(type);
   434 	}
   432 	}
   435 
   433 
   436 void doTestsL()
   434 void doTestsL()
   437 	{
   435 	{
       
   436     TestUtils::Initialize(_L("t_logsimid"));
   438 	TestUtils::DeleteDatabaseL();
   437 	TestUtils::DeleteDatabaseL();
   439 	//
   438 	//
   440 	test.Start(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4025: CLogEvent API test"));
   439 	TheTest.Start(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4025: CLogEvent API test"));
   441 	LogEventApiTestL();
   440 	LogEventApiTestL();
   442 	test.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4026: CLogFilter API test"));
   441 	TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4026: CLogFilter API test"));
   443 	LogFilterApiTestL();
   442 	LogFilterApiTestL();
   444 	test.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4027: Add events test"));
   443 	TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4027: Add events test"));
   445 	LogAddEventsTestL();
   444 	LogAddEventsTestL();
   446 	test.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4028: View events without SimId test"));
   445 	TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4028: View events without SimId test"));
   447 	LogViewEventsTestL(ELogWithoutSimId, TheMaxLogSize / 2);
   446 	LogViewEventsTestL(ELogWithoutSimId, TheMaxLogSize / 2);
   448 	test.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4028: View events with SimId test"));
   447 	TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4028: View events with SimId test"));
   449 	LogViewEventsTestL(ELogWithSimId, TheMaxLogSize / 2);
   448 	LogViewEventsTestL(ELogWithSimId, TheMaxLogSize / 2);
   450 	test.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4028: View events with or without SimId test"));
   449 	TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4028: View events with or without SimId test"));
   451 	LogViewEventsTestL(ELogIgnoreSimId, TheMaxLogSize);
   450 	LogViewEventsTestL(ELogIgnoreSimId, TheMaxLogSize);
   452 	test.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4028: More complex event view test"));
   451 	TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4028: More complex event view test"));
   453 	LogViewEventsTestL(ELogDiffEvents, KDiffEvCount);
   452 	LogViewEventsTestL(ELogDiffEvents, KDiffEvCount);
   454 	//
   453 	//
   455 	TestUtils::DeleteDatabaseL();
   454 	TestUtils::DeleteDatabaseL();
   456 	}
   455 	}
   457 
   456 
   458 #else//SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
   457 #else//SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
   459 
   458 
   460 void doTestsL()
   459 void doTestsL()
   461 	{
   460 	{
   462 	test.Start(_L("The t_simid test cases are compiled only when SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM macro is defined!"));
   461     TestUtils::Initialize(_L("t_logsimid"));
       
   462 	TheTest.Start(_L("The t_simid test cases are compiled only when SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM macro is defined!"));
   463 	}
   463 	}
   464 
   464 
   465 #endif//SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
   465 #endif//SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM