loggingservices/eventlogger/test/src/t_logcntmatch.cpp
changeset 51 7d4490026038
parent 19 d6ef85bc5971
child 55 44f437012c90
equal deleted inserted replaced
40:b8bdbc8f59c7 51:7d4490026038
    10 //
    10 //
    11 // Contributors:
    11 // Contributors:
    12 //
    12 //
    13 // Description:
    13 // Description:
    14 //
    14 //
    15 // If this test starts failing, then go and check the CentralRepository private data cage 
    15 #include "LOGREPDEFS.H"
    16 // (c:\\private\\10202be9 or z:\\private\\10202be9) if 101f401d.txt file is there.
       
    17 // If it is then delete it and try the test again.
       
    18 // (The problem is that if there is an existing 101f401d.txt file, then the contact match count value
       
    19 // will be loaded from that file, not from the LogEng resource file)
       
    20 //
       
    21 
       
    22 #include <bautils.h>
       
    23 #include <logserv.rsg>
       
    24 #include <barsc.h>
       
    25 #include "t_logutil2.h"
    16 #include "t_logutil2.h"
       
    17 #include "t_logutil3.h"
    26 #include "t_logcntmatchplugin.h"
    18 #include "t_logcntmatchplugin.h"
    27 
    19 
    28 RTest TheTest(_L("t_logcntmatch"));
    20 RTest TheTest(_L("t_logcntmatch"));
       
    21 
       
    22 #ifdef SYSLIBS_TEST
    29 
    23 
    30 TBool TheMatchingIsEnabled = EFalse;
    24 TBool TheMatchingIsEnabled = EFalse;
    31 //TheContactNameFmt variable must be initialized before tests. 
    25 //TheContactNameFmt variable must be initialized before tests. 
    32 //It gives an information what is the contact name format in the logs.
    26 //It gives an information what is the contact name format in the logs.
    33 TLogContactNameFormat TheContactNameFmt = ELogWesternFormat;
    27 TLogContactNameFormat TheContactNameFmt = KLogContactNameFormat;
    34 
    28 
    35 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
    29 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
    36 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
    30 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
    37 
       
    38 //The function opens the LogEng server resource file (logserv.rsc) and gets the value of 
       
    39 //R_LOG_CONTACT_NAME_FORMAT resource. This value will be retured as a result of the call.
       
    40 //It gives an information what is the contact name format in the logs.
       
    41 static TLogContactNameFormat GetContactNameFormatL()
       
    42 	{
       
    43 	// Get language of resource file
       
    44 	_LIT(KLogResourceFile,"z:\\private\\101f401d\\logserv.rsc");
       
    45 	TFileName fileName(KLogResourceFile);
       
    46 	BaflUtils::NearestLanguageFile(theFs, fileName);
       
    47 
       
    48 	// Open resource file
       
    49 	RResourceFile rscFile;
       
    50 	CleanupClosePushL(rscFile);
       
    51 	rscFile.OpenL(theFs, fileName);
       
    52 	HBufC8* buf = rscFile.AllocReadLC(R_LOG_CONTACT_NAME_FORMAT);
       
    53 
       
    54 	TResourceReader reader;
       
    55 	reader.SetBuffer(buf);
       
    56 
       
    57 	TLogContactNameFormat contactNameFmt = static_cast <TLogContactNameFormat> (reader.ReadInt16());
       
    58 	CleanupStack::PopAndDestroy(2, &rscFile);
       
    59 	return contactNameFmt;
       
    60 	}
       
    61 
    31 
    62 //This function checks the logged name is the same as the event name.
    32 //This function checks the logged name is the same as the event name.
    63 //Contact name logging format is taken into account.
    33 //Contact name logging format is taken into account.
    64 static void CheckContactName(CLogEvent& aEvent, const TDesC& aGivenName, const TDesC& aFamilyName)
    34 static void CheckContactName(CLogEvent& aEvent, const TDesC& aGivenName, const TDesC& aFamilyName)
    65 	{
    35 	{
   327 		{
   297 		{
   328 		TheTest.Printf(_L("Contacts matching not enabled. Contacts matching tests NOT run\n"));
   298 		TheTest.Printf(_L("Contacts matching not enabled. Contacts matching tests NOT run\n"));
   329 		return;
   299 		return;
   330 		}
   300 		}
   331 
   301 
   332 	TheContactNameFmt = ::GetContactNameFormatL();
   302 	TInt contactMatchCount = 0;
       
   303 	LogGetContactmatchCountAndNameFormatL(contactMatchCount, TheContactNameFmt);
       
   304 	TheTest.Printf(_L("Contact match count = %d, TheContactNameFmt = %d\r\n"), contactMatchCount, (TInt)TheContactNameFmt);
   333 
   305 
   334 	TestUtils::DeleteDatabaseL();
   306 	TestUtils::DeleteDatabaseL();
   335 
   307 
   336 	CLogClient* client = CLogClient::NewL(theFs);
   308 	CLogClient* client = CLogClient::NewL(theFs);
   337 	CleanupStack::PushL(client);
   309 	CleanupStack::PushL(client);
   338 	
   310 	
   339 	//All tests bellow are likely to fail if:
   311 	//All tests bellow are likely to fail if:
   340 	// 1. 101f401d.txt file exists in CentralRepository private data cage and the contact mach count is set to 0 in that file.
   312 	// 101f401d.txt file exists in CentralRepository private data cage and the contact mach count is set to 0 in that file.
   341 	// 2. SYSLIB_TEST macro is not defined.
       
   342     TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1392: DEF068087: Chinese names don't display in Chinese name format"));
   313     TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1392: DEF068087: Chinese names don't display in Chinese name format"));
   343 	::DEF068087L(*client);
   314 	::DEF068087L(*client);
   344     TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1016: Contacts matching - test1"));
   315     TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1016: Contacts matching - test1"));
   345 	TestContactMatch1L(*client);
   316 	TestContactMatch1L(*client);
   346     TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1017: Contacts matching - test2"));
   317     TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1017: Contacts matching - test2"));
   348 
   319 
   349 	TestUtils::DeleteDatabaseL();
   320 	TestUtils::DeleteDatabaseL();
   350 
   321 
   351 	CleanupStack::PopAndDestroy(client);
   322 	CleanupStack::PopAndDestroy(client);
   352 	}
   323 	}
       
   324 
       
   325 #else //SYSLIBS_TEST
       
   326 
       
   327 void doTestsL()
       
   328 	{
       
   329 	TheTest.Start(_L("This test can be run only when built with SYSLIBS_TEST macro defined!"));
       
   330 	}
       
   331 
       
   332 #endif //SYSLIBS_TEST