commonservices/sysutil/test/tef/te_sysutilburtestsuite/src/te_sysutiltestversioninfo.cpp
changeset 0 4e1aa6a622a0
child 52 d6b9e89d80a3
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2008-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 // file te_sysutiltestversioninfo.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <e32debug.h>
       
    19 #include "te_sysutiltestversioninfo.h"
       
    20 
       
    21 // These values should match those retrieved by the version APIs
       
    22 _LIT(KSWVersion, "V 04.02\n4-06-01\nNHL-2\n(c)NMP");
       
    23 _LIT(KLangVersion, "a");
       
    24 _LIT(KLangSWVersion, "V 04.02\n4-06-01\nNHL-2\n(c)NMP");
       
    25 _LIT(KPRInformation, "custom build\n20090626\nusb fix xyz");
       
    26 
       
    27 // These values should match those returned by the version APIs
       
    28 const TInt KSWVersionError = 0;
       
    29 const TInt KLangVersionError = 0;
       
    30 const TInt KLangSWVersionError = 0;
       
    31 const TInt KPRInformationError = 0;
       
    32 
       
    33 CSysUtilTestVersionInfoStep::~CSysUtilTestVersionInfoStep()
       
    34 	{
       
    35 	}
       
    36 
       
    37 CSysUtilTestVersionInfoStep::CSysUtilTestVersionInfoStep(const TDesC& aStepName, CSysUtilBurTestServer& aTestServer) : iTestServer(aTestServer)
       
    38 	{
       
    39 	SetTestStepName(aStepName);
       
    40 	}
       
    41 
       
    42 TVerdict CSysUtilTestVersionInfoStep::doTestStepL()
       
    43 	{
       
    44 	if(TestStepName() == KSysUtilTestVersionInfoPreBackupRestoreStep)
       
    45 		{
       
    46 		SetTestStepResult(PreBackupRestoreL());
       
    47 		}
       
    48 	else if(TestStepName() == KSysUtilTestVersionInfoPostBackupRestoreStep)
       
    49 		{
       
    50 		SetTestStepResult(PostBackupRestoreL());
       
    51 		}
       
    52 	
       
    53 	return TestStepResult();
       
    54 	}
       
    55 
       
    56 /*
       
    57 Perform any setup that needs doing before the backup and restore takes places
       
    58 */
       
    59 TVerdict CSysUtilTestVersionInfoStep::PreBackupRestoreL()
       
    60 	{
       
    61 	TInt err = DeletePSProperties();
       
    62 	if(err == KErrNone)
       
    63 		{
       
    64 		INFO_PRINTF1(_L("P&S properties successfully deleted."));
       
    65 		SetTestStepResult(EPass);
       
    66 		}
       
    67 	else
       
    68 		{
       
    69 		INFO_PRINTF2(_L("P&S properties could not be deleted. Error = %d"), err);
       
    70 		SetTestStepResult(EAbort);
       
    71 		}
       
    72 	
       
    73 	iTestServer.SetTestStep(EVersionAPIsStep);
       
    74 	
       
    75 	return TestStepResult();
       
    76 	}
       
    77 
       
    78 /*
       
    79 Perform any cleanup that needs doing before the backup and restore takes places
       
    80 */
       
    81 TVerdict CSysUtilTestVersionInfoStep::PostBackupRestoreL()
       
    82 	{
       
    83 	iTestServer.SetTestStep(ENoStep);
       
    84 	
       
    85 	TInt err = iTestServer.GetTestStepError();
       
    86 	if(err != KErrNone)
       
    87 		{
       
    88 		ERR_PRINTF2(_L("An error occured when calling the Version Info APIs during a backup/restore. Error = %d"), err);
       
    89 		SetTestStepResult(EFail);
       
    90 		}
       
    91 	
       
    92 	return TestStepResult();
       
    93 	}
       
    94 
       
    95 /*
       
    96 Call all the version APIs and check that the retrieved values and returned 
       
    97 error codes are those that we expect.
       
    98 */
       
    99 void CSysUtilTestVersionInfoStep::TestAllAPIsL()
       
   100 	{
       
   101 	SetTestPath(EFalse);
       
   102 	
       
   103 	TBool passed = ETrue;
       
   104 	
       
   105 	TBuf16<KSysUtilVersionTextLength> actualValue;
       
   106 	RDebug::Printf("Testing SW Version \n");
       
   107 	TInt actualError = SysUtil::GetSWVersion(actualValue);
       
   108 	if(KSWVersionError != actualError)
       
   109 		{
       
   110 		RDebug::Printf("Actual error = %d\n", actualError);
       
   111 		RDebug::Printf("Expected error = %d\n", KSWVersionError);
       
   112 		passed = EFalse;
       
   113 		}
       
   114 	
       
   115 	if(actualValue.Compare(KSWVersion) != 0)
       
   116 		{
       
   117 		RDebug::Printf("Actual value = %S\n", &actualValue);
       
   118 		RDebug::Printf("Expected value = %S\n", &KSWVersion);
       
   119 		passed = EFalse;
       
   120 		}
       
   121 	
       
   122 	RDebug::Printf("Testing Lang Version \n");
       
   123 	actualValue.Zero();
       
   124 	actualError = SysUtil::GetLangVersion(actualValue);
       
   125 	if(KLangVersionError != actualError)
       
   126 		{
       
   127 		RDebug::Printf("Actual error = %d\n", actualError);
       
   128 		RDebug::Printf("Expected error = %d\n", KLangVersionError);
       
   129 		passed = EFalse;
       
   130 		}
       
   131 	
       
   132 	if(actualValue.Compare(KLangVersion) != 0)
       
   133 		{
       
   134 		RDebug::Printf("Actual value = %S\n", &actualValue);
       
   135 		RDebug::Printf("Expected value = %S\n", &KLangVersion);
       
   136 		passed = EFalse;
       
   137 		}
       
   138 	
       
   139 	RDebug::Printf("Testing Lang SW Version \n");
       
   140 	actualValue.Zero();
       
   141 	actualError = SysUtil::GetLangSWVersion(actualValue);
       
   142 	if(KLangSWVersionError != actualError)
       
   143 		{
       
   144 		RDebug::Printf("Actual error = %d\n", actualError);
       
   145 		RDebug::Printf("Expected error = %d\n", KLangSWVersionError);
       
   146 		passed = EFalse;
       
   147 		}
       
   148 	
       
   149 	if(actualValue.Compare(KLangSWVersion) != 0)
       
   150 		{
       
   151 		RDebug::Printf("Actual value = %S\n", &actualValue);
       
   152 		RDebug::Printf("Expected value = %S\n", &KLangSWVersion);
       
   153 		passed = EFalse;
       
   154 		}
       
   155 	
       
   156 	RDebug::Printf("Testing PR Information \n");
       
   157     actualValue.Zero();
       
   158     actualError = SysUtil::GetPRInformation(actualValue);
       
   159     if(KPRInformationError != actualError)
       
   160         {
       
   161         RDebug::Printf("Actual error = %d\nExpected error = %d\n", actualError, KPRInformationError);
       
   162         passed = EFalse;
       
   163         }
       
   164     
       
   165     if(actualValue.Compare(KPRInformation) != 0)
       
   166         {
       
   167         RDebug::Printf("Actual value = %S\nExpected value = %S\n", &actualValue, &KPRInformation);
       
   168         passed = EFalse;
       
   169         }
       
   170 	    
       
   171 	
       
   172 	if(!passed)
       
   173 		{
       
   174 		User::Leave(KErrGeneral);
       
   175 		}
       
   176 	}