commonservices/sysutil/test/tef/te_sysutiltestsuite/src/te_sysutilsgetlangswversion.cpp
changeset 0 4e1aa6a622a0
child 21 ccb4f6b3db21
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2007-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 // Get Language Software Version
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file 
       
    20  @internalTechnology
       
    21 */
       
    22 
       
    23 #include "te_sysutilsgetlangswversion.h"
       
    24 
       
    25 /**
       
    26 Destructor
       
    27  */
       
    28 CSysUtilsGetLangSWVersionStep::~CSysUtilsGetLangSWVersionStep()
       
    29 	{
       
    30 	}
       
    31 
       
    32 /**
       
    33 Constructor
       
    34  */
       
    35 CSysUtilsGetLangSWVersionStep::CSysUtilsGetLangSWVersionStep()
       
    36 	{
       
    37 	SetTestStepName(KSysUtilsGetLangSWVersionStep);
       
    38 	}
       
    39 
       
    40 /**
       
    41 @SYMTestCaseID			SYSLIB-BAFL-CT-4002
       
    42 @SYMREQ					REQ1802
       
    43 @SYMTestCaseDesc		GetLangSWVersion
       
    44 @SYMTestPriority		HIGH
       
    45 @SYMTestStatus			Implemented
       
    46 @SYMTestActions			Get the software language version from Z:\resource\versions\langsw.txt 
       
    47 @SYMTestActions			using the SysUtil::GetLangSWVersion method and compare 
       
    48 @SYMTestActions			it against a string literal set in an ini file. The ini 
       
    49 @SYMTestActions			file is located in z:\testdata\inifiles\.
       
    50 @SYMTestExpectedResults The language software version information obtained is a 
       
    51 @SYMTestExpectedResults correctly formatted version of the information in 
       
    52 @SYMTestExpectedResults Z:\resource\versions\langsw.txt.
       
    53 */
       
    54 TVerdict CSysUtilsGetLangSWVersionStep::doTestStepL()
       
    55 	{
       
    56 	TInt err=KErrNone;
       
    57 
       
    58 	_LIT16(KDummy,"xxxxx");
       
    59 	
       
    60 	TBuf16<KSysUtilVersionTextLength> version;
       
    61 
       
    62 	version.Insert(0,KDummy);
       
    63 
       
    64 	TInt fileErr = CheckIsFileExist( _L("Z:\\resource\\versions\\langsw.txt"));
       
    65 
       
    66 	if(fileErr == KErrNone)
       
    67 		{
       
    68 		err = DeletePSProperties();
       
    69 		if(err != KErrNone)
       
    70 			{
       
    71 			ERR_PRINTF2(_L("Could not delete P&S properties. Error = %d"), err);
       
    72 			SetTestStepResult(EAbort);
       
    73 			return TestStepResult();
       
    74 			}
       
    75 		INFO_PRINTF1(_L("Deleted P&S properties successfully."));
       
    76 		
       
    77 		err = SetTestPath(EFalse);
       
    78 		if( err != KErrNone )
       
    79 			{
       
    80 			ERR_PRINTF2(_L("Could not turn test path off. Error = %d"), err);
       
    81 			SetTestStepResult(EAbort);
       
    82 			return TestStepResult();
       
    83 			}
       
    84 		INFO_PRINTF1(_L("Test path turned off."));
       
    85 		
       
    86 		err = SysUtil::GetLangSWVersion( version );
       
    87 		if ( err != KErrNone )
       
    88 			{
       
    89 			ERR_PRINTF2(_L("Get lang SW version failed. Error = %d"), err);
       
    90 			SetTestStepResult(EFail);
       
    91 			}
       
    92 		else
       
    93 			{
       
    94 			// Get the information from the ini file
       
    95 			_LIT(KLangSW, "LangSW");
       
    96 			TPtrC16 line;
       
    97 			
       
    98 			TESTL( GetStringFromConfig(ConfigSection(), KLangSW, line) );
       
    99 			TBuf16<KSysUtilVersionTextLength> testBuf(line);
       
   100 			//Parse the information from the ini file
       
   101 		    // Replace new-line patterns with real ones
       
   102 			_LIT(KNewLinePattern, "\\n");
       
   103 			_LIT( KNewline, "\n" );
       
   104 			
       
   105 			err = testBuf.Find(KNewLinePattern);
       
   106 	        while (err != KErrNotFound)
       
   107 	            {
       
   108 	            // err is a position
       
   109 	            testBuf.Replace(err, KNewLinePattern().Length(), KNewline );
       
   110 	            err = testBuf.Find(KNewLinePattern);
       
   111 	            }
       
   112 	        
       
   113 			if (version.Compare(testBuf)!=0)
       
   114 				{
       
   115 				ERR_PRINTF1(_L("software language formatted incorrectly"));
       
   116 				INFO_PRINTF1(testBuf);
       
   117 				SetTestStepResult(EFail);
       
   118 				}
       
   119 			else
       
   120 				{
       
   121 				INFO_PRINTF1(_L("software version formatted correctly"));
       
   122 				INFO_PRINTF1(_L("from ini file "));
       
   123 				INFO_PRINTF1(testBuf);
       
   124 				INFO_PRINTF1(_L("from txt file "));
       
   125 				INFO_PRINTF1(version);
       
   126 				}
       
   127 			}
       
   128 		}
       
   129 	else
       
   130 		{
       
   131 		ERR_PRINTF1(_L("Langsw.txt is missing, should be included to base packets"));
       
   132 		SetTestStepResult(EFail);
       
   133 		}
       
   134 		
       
   135 	return TestStepResult(); 	
       
   136 	}
       
   137