sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Contains implementation of CTestTelUriValidationStep class sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @internalTechnology sl@0: */ sl@0: sl@0: // User Include sl@0: #include "TestTelUriValidationStep.h" sl@0: // System Include sl@0: #include sl@0: #include sl@0: sl@0: /** sl@0: Constructor: Sets the test step name. sl@0: @internalTechnology sl@0: @test sl@0: */ sl@0: CTestTelUriValidationStep::CTestTelUriValidationStep() sl@0: { sl@0: //Call base class method to set human readable name for test step sl@0: SetTestStepName(KTestTelUriValidationStep); sl@0: } sl@0: sl@0: /** sl@0: Destructor sl@0: @internalTechnology sl@0: @test sl@0: */ sl@0: CTestTelUriValidationStep::~CTestTelUriValidationStep() sl@0: { sl@0: sl@0: } sl@0: sl@0: /** sl@0: Does the main functionality of a test step. sl@0: Here, reads values from INI file sl@0: and calls TestTelUriValidate() which does validation of a tel uri. sl@0: @internalTechnology sl@0: @param None sl@0: @return EPass or EFail indicating the success or failure of the test step sl@0: */ sl@0: TVerdict CTestTelUriValidationStep::doTestStepL() sl@0: { sl@0: __UHEAP_MARK; sl@0: INFO_PRINTF1(_L("\n")); sl@0: // Get necessary information from INI file sl@0: TPtrC telUri; sl@0: TInt expRetCode; sl@0: sl@0: if(!GetStringFromConfig(ConfigSection(), KIniUri, telUri) || sl@0: !GetIntFromConfig(ConfigSection(), KIniExpectedRetCode, expRetCode) ) sl@0: { sl@0: ERR_PRINTF3(_L("Problem in reading values from ini. \ sl@0: \nExpected fields are: \n%S\n%S\n" ),&KIniUri, &KIniExpectedRetCode ); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: else sl@0: { sl@0: // No problem in reading values from INI file. Proceed. sl@0: // Calling TestTelUriValidate which does validation of tel uri and comparing results. sl@0: TRAPD(err, TestTelUriValidateAndCompareL(telUri,expRetCode)); sl@0: if(err != KErrNone) sl@0: { sl@0: ERR_PRINTF1(_L("Test step failed: Leave occured in TestTelUriValidateAndCompareL \n")); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: } sl@0: __UHEAP_MARKEND; sl@0: INFO_PRINTF1(_L("\nTest of TelUri Validation is Executed")); sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: /** sl@0: Performs tel uri validation and compares actual & expected result. sl@0: @param aTelUri A reference to tel-uri to be validated. sl@0: @param aExpRetCode An expected retrn code to be compared. sl@0: */ sl@0: void CTestTelUriValidationStep::TestTelUriValidateAndCompareL(const TDesC16& aTelUri, const TInt aExpRetCode) sl@0: { sl@0: CUri8* cUri8 = UriUtils::CreateUriL(aTelUri); sl@0: const TUriC8& telUri(cUri8->Uri()); sl@0: // Validating tel uri sl@0: TInt errCode = telUri.Validate(); sl@0: if(errCode != aExpRetCode) sl@0: { sl@0: ERR_PRINTF2(_L("Tel URI validation failed %D\n"), errCode); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: delete cUri8; sl@0: } sl@0: sl@0: /** sl@0: Constructor: Sets the test step name. sl@0: @internalTechnology sl@0: @test sl@0: */ sl@0: CTestTelUriValidationOomStep::CTestTelUriValidationOomStep() sl@0: { sl@0: //Call base class method to set human readable name for test step sl@0: SetTestStepName(KTestOomTelUriValidationStep); sl@0: } sl@0: sl@0: /** sl@0: Destructor sl@0: @internalTechnology sl@0: @test sl@0: */ sl@0: CTestTelUriValidationOomStep::~CTestTelUriValidationOomStep() sl@0: { sl@0: sl@0: } sl@0: sl@0: /** sl@0: Does the main functionality of a test step and performs OOM test. sl@0: Here, reads values from INI file sl@0: and calls TestTelUriValidate() which does validation of a tel uri. sl@0: @internalTechnology sl@0: @param None sl@0: @return EPass or EFail indicating the success or failure of the test step sl@0: */ sl@0: TVerdict CTestTelUriValidationOomStep::doTestStepL() sl@0: { sl@0: __UHEAP_MARK; sl@0: TPtrC telUri; sl@0: if(!GetStringFromConfig(ConfigSection(), KIniUri, telUri) ) sl@0: { sl@0: ERR_PRINTF2(_L("Problem in reading values from ini. \ sl@0: \nExpected fields are: \n%S\n" ), &KIniUri); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: else sl@0: { sl@0: CUri8* cUri8 = UriUtils::CreateUriL(telUri); sl@0: const TUriC8& telUri(cUri8->Uri()); sl@0: INFO_PRINTF1(_L("Calling telUri.Validate() which does tel-Uri Validation.")); sl@0: TInt ret = KErrNoMemory; sl@0: TInt failAt = 0; sl@0: while(ret != KErrNone) sl@0: { sl@0: failAt++; sl@0: INFO_PRINTF2(_L("OOM test step: %d\n"),failAt); sl@0: sl@0: __UHEAP_SETFAIL( RHeap::EDeterministic, failAt ); sl@0: __UHEAP_MARK; sl@0: TRAP( ret, telUri.Validate()); sl@0: __UHEAP_MARKEND; sl@0: __UHEAP_RESET; sl@0: if((ret == KErrNoMemory) || (ret == KErrNone)) sl@0: { sl@0: INFO_PRINTF2(_L("Error/RetCode : %D\n"),ret); sl@0: } sl@0: } sl@0: delete cUri8; sl@0: } sl@0: __UHEAP_MARKEND; sl@0: INFO_PRINTF1(_L("\n OOM Test of TelUri Validation is Executed")); sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: