loggingservices/eventlogger/test/src/t_logapi.cpp
branchRCL_3
changeset 50 8dc8494f1e0e
parent 45 cc28652e0254
child 56 839ea9debada
equal deleted inserted replaced
47:047f208ea78f 50:8dc8494f1e0e
    16 #include <s32file.h>
    16 #include <s32file.h>
    17 #include <e32math.h>
    17 #include <e32math.h>
    18 #include <logview.h>
    18 #include <logview.h>
    19 #include <s32mem.h> 
    19 #include <s32mem.h> 
    20 #include "t_logutil2.h"
    20 #include "t_logutil2.h"
       
    21 #include "t_logutil3.h"
    21 
    22 
    22 #define UNUSED_VAR(a) a = a
    23 #define UNUSED_VAR(a) a = a
    23 
    24 
    24 const TLogContactItemId KTestContact = 0x1234;
    25 const TLogContactItemId KTestContact = 0x1234;
    25 const TInt KTestEventNum = 10;
    26 const TInt KTestEventNum = 10;
   197                         Add the event once again and check for the already exits condition.
   198                         Add the event once again and check for the already exits condition.
   198 @SYMTestExpectedResults Test must not fail
   199 @SYMTestExpectedResults Test must not fail
   199 @SYMREQ                 REQ0000
   200 @SYMREQ                 REQ0000
   200 */
   201 */
   201 LOCAL_C void TestAddEventTypeL(CLogClient& aClient)
   202 LOCAL_C void TestAddEventTypeL(CLogClient& aClient)
   202 //
       
   203 //
       
   204 //
       
   205 	{
   203 	{
   206 	LOGTEXT("TestAddEventTypeL()");	
   204 	LOGTEXT("TestAddEventTypeL()");	
   207 	CLogEventType* type = CLogEventType::NewL();
   205 	CLogEventType* type = CLogEventType::NewL();
   208 	CleanupStack::PushL(type);
   206 	CleanupStack::PushL(type);
   209 
   207 
   242 @SYMTestActions  	    Tests for the retrieved information of event type. 
   240 @SYMTestActions  	    Tests for the retrieved information of event type. 
   243 @SYMTestExpectedResults Test must not fail
   241 @SYMTestExpectedResults Test must not fail
   244 @SYMREQ                 REQ0000
   242 @SYMREQ                 REQ0000
   245 */
   243 */
   246 LOCAL_C void TestGetEventTypeL(CLogClient& aClient)
   244 LOCAL_C void TestGetEventTypeL(CLogClient& aClient)
   247 //
       
   248 //
       
   249 //
       
   250 	{
   245 	{
   251 	LOGTEXT("TestGetEventTypeL()");	
   246 	LOGTEXT("TestGetEventTypeL()");	
   252 	CLogEventType* type = CLogEventType::NewL();
   247 	CLogEventType* type = CLogEventType::NewL();
   253 	CleanupStack::PushL(type);
   248 	CleanupStack::PushL(type);
   254 
   249 
   285 @SYMTestActions  	    Create a new event type,change the event type and check for any errors
   280 @SYMTestActions  	    Create a new event type,change the event type and check for any errors
   286 @SYMTestExpectedResults Test must not fail
   281 @SYMTestExpectedResults Test must not fail
   287 @SYMREQ                 REQ0000
   282 @SYMREQ                 REQ0000
   288 */
   283 */
   289 LOCAL_C void TestChangeEventTypeL(CLogClient& aClient)
   284 LOCAL_C void TestChangeEventTypeL(CLogClient& aClient)
   290 //
       
   291 //
       
   292 //
       
   293 	{
   285 	{
   294 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0836 "));
   286 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0836 "));
   295 	LOGTEXT("TestChangeEventTypeL()");	
   287 	LOGTEXT("TestChangeEventTypeL()");	
   296 	CTestActive* active = new(ELeave)CTestActive();
   288 	CTestActive* active = new(ELeave)CTestActive();
   297 	CleanupStack::PushL(active);
   289 	CleanupStack::PushL(active);
   343 @SYMTestActions  	    Delete an event type from log database and test for no errors found
   335 @SYMTestActions  	    Delete an event type from log database and test for no errors found
   344 @SYMTestExpectedResults Test must not fail
   336 @SYMTestExpectedResults Test must not fail
   345 @SYMREQ                 REQ0000
   337 @SYMREQ                 REQ0000
   346 */
   338 */
   347 LOCAL_C void TestDeleteEventTypeL(CLogClient& aClient)
   339 LOCAL_C void TestDeleteEventTypeL(CLogClient& aClient)
   348 //
       
   349 //
       
   350 //
       
   351 	{
   340 	{
   352 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0837 "));
   341 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0837 "));
   353 	LOGTEXT("TestChangeEventTypeL()");	
   342 	LOGTEXT("TestChangeEventTypeL()");	
   354 	CTestActive* active = new(ELeave)CTestActive();
   343 	CTestActive* active = new(ELeave)CTestActive();
   355 	CleanupStack::PushL(active);
   344 	CleanupStack::PushL(active);
   388 @SYMTestActions  	    Add an event type to the log database and test for no errors found
   377 @SYMTestActions  	    Add an event type to the log database and test for no errors found
   389 @SYMTestExpectedResults Test must not fail
   378 @SYMTestExpectedResults Test must not fail
   390 @SYMREQ                 REQ0000
   379 @SYMREQ                 REQ0000
   391 */
   380 */
   392 LOCAL_C void TestAddEventL(CLogClient& aClient)
   381 LOCAL_C void TestAddEventL(CLogClient& aClient)
   393 //
       
   394 //
       
   395 //
       
   396 	{
   382 	{
   397 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1329 "));	
   383 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1329 "));	
   398 	CLogEventType* type = CLogEventType::NewL();
   384 	CLogEventType* type = CLogEventType::NewL();
   399 	CleanupStack::PushL(type);
   385 	CleanupStack::PushL(type);
   400 
   386 
   496 @SYMTestExpectedResults Test must not fail
   482 @SYMTestExpectedResults Test must not fail
   497 @SYMREQ                 REQ0000
   483 @SYMREQ                 REQ0000
   498 */
   484 */
   499 
   485 
   500 LOCAL_C void TestGetEventL(CLogClient& aClient)
   486 LOCAL_C void TestGetEventL(CLogClient& aClient)
   501 //
       
   502 //
       
   503 //
       
   504 	{
   487 	{
   505 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0839 "));
   488 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0839 "));
   506 	CTestActive* active = new(ELeave)CTestActive();
   489 	CTestActive* active = new(ELeave)CTestActive();
   507 	CleanupStack::PushL(active);
   490 	CleanupStack::PushL(active);
   508 
   491 
   586                         Check for any errors.
   569                         Check for any errors.
   587 @SYMTestExpectedResults Test must not fail
   570 @SYMTestExpectedResults Test must not fail
   588 @SYMREQ                 REQ0000
   571 @SYMREQ                 REQ0000
   589 */
   572 */
   590 LOCAL_C void TestChangeEventL(CLogClient& aClient)
   573 LOCAL_C void TestChangeEventL(CLogClient& aClient)
   591 //
       
   592 //
       
   593 //
       
   594 	{
   574 	{
   595 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0840 "));
   575 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0840 "));
   596 	CTestActive* active = new(ELeave)CTestActive();
   576 	CTestActive* active = new(ELeave)CTestActive();
   597 	CleanupStack::PushL(active);
   577 	CleanupStack::PushL(active);
   598 
   578 
   666 @SYMTestActions  	    Delete the event and test for no errors found.
   646 @SYMTestActions  	    Delete the event and test for no errors found.
   667 @SYMTestExpectedResults Test must not fail
   647 @SYMTestExpectedResults Test must not fail
   668 @SYMREQ                 REQ0000
   648 @SYMREQ                 REQ0000
   669 */
   649 */
   670 LOCAL_C void TestDeleteEventL(CLogClient& aClient)
   650 LOCAL_C void TestDeleteEventL(CLogClient& aClient)
   671 //
       
   672 //
       
   673 //
       
   674 	{
   651 	{
   675 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0841 "));
   652 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0841 "));
   676 	CTestActive* active = new(ELeave)CTestActive();
   653 	CTestActive* active = new(ELeave)CTestActive();
   677 	CleanupStack::PushL(active);
   654 	CleanupStack::PushL(active);
   678 
   655 
   701 	CleanupStack::PopAndDestroy(2); // event, active
   678 	CleanupStack::PopAndDestroy(2); // event, active
   702 	}
   679 	}
   703 
   680 
   704 
   681 
   705 #ifdef SYSLIBS_TEST
   682 #ifdef SYSLIBS_TEST
       
   683 
   706 /**
   684 /**
   707 @SYMTestCaseID          SYSLIB-LOGENG-UT-4015
   685 @SYMTestCaseID          SYSLIB-LOGENG-UT-4015
   708 @SYMTestCaseDesc	    Test the behaviour implemented by PREQ2103
   686 @SYMTestCaseDesc	    Test the behaviour implemented by PREQ2103
   709 @SYMTestPriority 	    Medium
   687 @SYMTestPriority 	    Medium
   710 @SYMTestActions  	    Get the settings from logeng repository file / resource file.
   688 @SYMTestActions  	    Get the settings from logeng repository file or their default values.
   711 @SYMTestExpectedResults Test must not fail
   689 @SYMTestExpectedResults Test must not fail
   712 @SYMREQ                 REQ11125
   690 @SYMREQ                 REQ11125
   713                         REQ11126
   691                         REQ11126
   714                         REQ11127
   692                         REQ11127
   715                         REQ11128
   693                         REQ11128
   716 */
   694 */
   717 LOCAL_C void TestGetConfigSettingsFromRepositoryFileL(CLogClient& aClient)
   695 LOCAL_C void TestGetConfigSettingsFromRepositoryFileL(CLogClient& aClient)
   718 	{
   696 	{
   719 	//Note: if this test starts failing, then go and check the CentralRepository private data cage 
       
   720 	//(c:\\private\\10202be9 or z:\\private\\10202be9) if 101f401d.txt file is there.
       
   721 	//If it is then delete it and try the test again.
       
   722 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-UT-4015 "));
   697 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-UT-4015 "));
   723 	//Get the contact match count and contact name format.This should be from resource file.
   698 	
   724 	TInt16 contactMatchCount;
   699 	TInt contactMatchCount1;
   725 	TInt16 contactNameFormat;
   700 	TLogContactNameFormat contactNameFormat1;
       
   701 	LogGetContactmatchCountAndNameFormatL(contactMatchCount1, contactNameFormat1);
       
   702 	TheTest.Printf(_L("Contact match count = %d, contact name format = %d\r\n"), contactMatchCount1, (TInt)contactNameFormat1);
       
   703 	//contactMatchCount1 and contactNameFormat1 are loaded directly from the repository, if exists.
       
   704 	//Otherwise they are initialzied with their default values from the LogServ resource file.
       
   705 	//The LogEng server should load these resource values in a similar way.
       
   706 	//They will be stored in contactMatchCount2 and contactNameFormat2.  
       
   707 	TInt16 contactMatchCount2;
       
   708 	TInt16 contactNameFormat2;
   726 	RFs fs;
   709 	RFs fs;
   727 	
   710 	
   728 	LEAVE_IF_ERROR(fs.Connect());
   711 	LEAVE_IF_ERROR(fs.Connect());
   729 	CleanupClosePushL(fs);
   712 	CleanupClosePushL(fs);
   730 	
   713 	
   731 	//Creating a new CLogClient Object make the server getting the contact match settings. 
   714 	//Creating a new CLogClient Object make the server getting the contact match settings. 
   732 	//As the database is deleted it get them from the resource file.
   715 	//As the database is deleted it gets them from the LogEng repository.
   733 	CLogClient* client2 = CLogClient::NewL(fs);
   716 	CLogClient* client2 = CLogClient::NewL(fs);
   734 	CleanupStack::PushL(client2);
   717 	CleanupStack::PushL(client2);
   735 	CleanupStack::PopAndDestroy(client2);
   718 	CleanupStack::PopAndDestroy(client2);
   736 		
   719 		
   737 	//Read these settings via "reader" object.
   720 	//Read these settings via "reader" object.
   741 	CleanupClosePushL(resFileFormat_reader);
   724 	CleanupClosePushL(resFileFormat_reader);
   742 	_LIT(KLogengTestFileNameCount, "c:\\test\\test_logengconfig_count.ini");
   725 	_LIT(KLogengTestFileNameCount, "c:\\test\\test_logengconfig_count.ini");
   743 	_LIT(KLogengTestFileNameFormat, "c:\\test\\test_logengconfig_format.ini");
   726 	_LIT(KLogengTestFileNameFormat, "c:\\test\\test_logengconfig_format.ini");
   744 	LEAVE_IF_ERROR(resFileCount_reader.Open(fs, KLogengTestFileNameCount, EFileRead));
   727 	LEAVE_IF_ERROR(resFileCount_reader.Open(fs, KLogengTestFileNameCount, EFileRead));
   745 	LEAVE_IF_ERROR(resFileFormat_reader.Open(fs, KLogengTestFileNameFormat, EFileRead));		
   728 	LEAVE_IF_ERROR(resFileFormat_reader.Open(fs, KLogengTestFileNameFormat, EFileRead));		
   746 	contactMatchCount = resFileCount_reader.ReadInt32L();
   729 	contactMatchCount2 = resFileCount_reader.ReadInt32L();
   747 	contactNameFormat = resFileFormat_reader.ReadInt32L();
   730 	contactNameFormat2 = resFileFormat_reader.ReadInt32L();
   748 		
   731 		
   749 	//The settings should match the ones from resource file.
   732 	//The settings loaded by the LogEng server should match the ones loaded by this test.
   750 	TEST(contactMatchCount == 8);
   733 	TEST(contactMatchCount1 == contactMatchCount2);
   751 	TEST(contactNameFormat == 0);
   734 	TEST(contactNameFormat1 == contactNameFormat2);
   752 		
   735 		
   753 	CleanupStack::PopAndDestroy(&resFileFormat_reader);
   736 	CleanupStack::PopAndDestroy(&resFileFormat_reader);
   754 	CleanupStack::PopAndDestroy(&resFileCount_reader);
   737 	CleanupStack::PopAndDestroy(&resFileCount_reader);
   755 	
   738 	
   756 	//Get the config settings (Three config settings). 
   739 	//Get the config settings (Three config settings). 
   765 	active->StartL();
   748 	active->StartL();
   766 	aClient.GetConfig(config, active->iStatus);	
   749 	aClient.GetConfig(config, active->iStatus);	
   767 	CActiveScheduler::Start();
   750 	CActiveScheduler::Start();
   768 	TEST2(active->iStatus.Int(), KErrNone);
   751 	TEST2(active->iStatus.Int(), KErrNone);
   769 	
   752 	
   770 	//The config settings should match the ones from the resource file.
   753 	//The config settings should match the ones from the repository.
   771 	TEST(config.iMaxEventAge == 2592000);
   754 	TEST(config.iMaxEventAge == 2592000);
   772 	TEST(config.iMaxLogSize == 1000);
   755 	TEST(config.iMaxLogSize == 1000);
   773 	TEST(config.iMaxRecentLogSize == 20);
   756 	TEST(config.iMaxRecentLogSize == 20);
   774 	
   757 	
   775 	
   758 	
   815 	CleanupClosePushL(repFileCount_reader);
   798 	CleanupClosePushL(repFileCount_reader);
   816 	RFileReadStream repFileFormat_reader;
   799 	RFileReadStream repFileFormat_reader;
   817 	CleanupClosePushL(repFileFormat_reader);
   800 	CleanupClosePushL(repFileFormat_reader);
   818 	LEAVE_IF_ERROR(repFileCount_reader.Open(fs, KLogengTestFileNameCount, EFileRead));
   801 	LEAVE_IF_ERROR(repFileCount_reader.Open(fs, KLogengTestFileNameCount, EFileRead));
   819 	LEAVE_IF_ERROR(repFileFormat_reader.Open(fs, KLogengTestFileNameFormat, EFileRead));		
   802 	LEAVE_IF_ERROR(repFileFormat_reader.Open(fs, KLogengTestFileNameFormat, EFileRead));		
   820 	contactMatchCount = repFileCount_reader.ReadInt32L();
   803 	contactMatchCount2 = repFileCount_reader.ReadInt32L();
   821 	contactNameFormat = repFileFormat_reader.ReadInt32L();
   804 	contactNameFormat2 = repFileFormat_reader.ReadInt32L();
   822 	CleanupStack::PopAndDestroy(&repFileFormat_reader);
   805 	CleanupStack::PopAndDestroy(&repFileFormat_reader);
   823 	CleanupStack::PopAndDestroy(&repFileCount_reader);
   806 	CleanupStack::PopAndDestroy(&repFileCount_reader);
   824 	CleanupStack::PopAndDestroy(&fs);
   807 	CleanupStack::PopAndDestroy(&fs);
   825 	
   808 	
   826 	//The values should match the ones from the repository file.
   809 	//The values should match the ones from the repository file.
   827 	TEST(contactMatchCount == 6);
   810 	TEST(contactMatchCount2 == 6);
   828 	TEST(contactNameFormat == 1);
   811 	TEST(contactNameFormat2 == 1);
   829 	
   812 	
   830 	//delete the repository file c:\\private\\10202be9\\101f401d.txt.
   813 	//delete the repository file c:\\private\\10202be9\\101f401d.txt.
   831 	_LIT(KCommandParameters2,		"c:\\private\\10202be9\\101f401d.txt;private\\10202be9\101f401d.txt;2");
   814 	_LIT(KCommandParameters2,		"c:\\private\\10202be9\\101f401d.txt;private\\10202be9\101f401d.txt;2");
   832 	r = process.Create(KExecutableFileName, KCommandParameters2); 
   815 	r = process.Create(KExecutableFileName, KCommandParameters2); 
   833 	process.Resume();
   816 	process.Resume();
   848 @SYMTestActions  	    Tests for CLogClient::GetConfig() function,check for the integrity of the data
   831 @SYMTestActions  	    Tests for CLogClient::GetConfig() function,check for the integrity of the data
   849 @SYMTestExpectedResults Test must not fail
   832 @SYMTestExpectedResults Test must not fail
   850 @SYMREQ                 REQ0000
   833 @SYMREQ                 REQ0000
   851 */
   834 */
   852 LOCAL_C void TestGetConfigL(CLogClient& aClient)
   835 LOCAL_C void TestGetConfigL(CLogClient& aClient)
   853 //
       
   854 //
       
   855 //
       
   856 	{
   836 	{
   857 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0842 "));
   837 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0842 "));
   858 	CTestActive* active = new(ELeave)CTestActive();
   838 	CTestActive* active = new(ELeave)CTestActive();
   859 	CleanupStack::PushL(active);
   839 	CleanupStack::PushL(active);
   860 
   840 
   890 @SYMTestActions  	    Change the configuration data and test for the integrity.
   870 @SYMTestActions  	    Change the configuration data and test for the integrity.
   891 @SYMTestExpectedResults Test must not fail
   871 @SYMTestExpectedResults Test must not fail
   892 @SYMREQ                 REQ0000
   872 @SYMREQ                 REQ0000
   893 */
   873 */
   894 LOCAL_C void TestChangeConfigL(CLogClient& aClient)
   874 LOCAL_C void TestChangeConfigL(CLogClient& aClient)
   895 //
       
   896 //
       
   897 //
       
   898 	{
   875 	{
   899 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0843 "));
   876 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0843 "));
   900 	CTestActive* active = new(ELeave)CTestActive();
   877 	CTestActive* active = new(ELeave)CTestActive();
   901 	CleanupStack::PushL(active);
   878 	CleanupStack::PushL(active);
   902 
   879 
   932 @SYMTestActions  	    Get the string from the resource file and check for no errors and the zero string length
   909 @SYMTestActions  	    Get the string from the resource file and check for no errors and the zero string length
   933 @SYMTestExpectedResults Test must not fail
   910 @SYMTestExpectedResults Test must not fail
   934 @SYMREQ                 REQ0000
   911 @SYMREQ                 REQ0000
   935 */
   912 */
   936 LOCAL_C void TestGetStringL(CLogClient& aClient)
   913 LOCAL_C void TestGetStringL(CLogClient& aClient)
   937 //
       
   938 //
       
   939 //
       
   940 	{
   914 	{
   941 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0844 "));
   915 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0844 "));
   942 	TBuf<KLogMaxSharedStringLength> str;
   916 	TBuf<KLogMaxSharedStringLength> str;
   943 	
   917 	
   944 	TInt err = aClient.GetString(str, R_LOG_DIR_IN);
   918 	TInt err = aClient.GetString(str, R_LOG_DIR_IN);