os/ossrv/genericservices/httputils/Test/Integration/TestInetProtUtilsSuite/Src/TestTelUriValidationStep.cpp
Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Contains implementation of CTestTelUriValidationStep class
24 #include "TestTelUriValidationStep.h"
30 Constructor: Sets the test step name.
34 CTestTelUriValidationStep::CTestTelUriValidationStep()
36 //Call base class method to set human readable name for test step
37 SetTestStepName(KTestTelUriValidationStep);
45 CTestTelUriValidationStep::~CTestTelUriValidationStep()
51 Does the main functionality of a test step.
52 Here, reads values from INI file
53 and calls TestTelUriValidate() which does validation of a tel uri.
56 @return EPass or EFail indicating the success or failure of the test step
58 TVerdict CTestTelUriValidationStep::doTestStepL()
61 INFO_PRINTF1(_L("\n"));
62 // Get necessary information from INI file
66 if(!GetStringFromConfig(ConfigSection(), KIniUri, telUri) ||
67 !GetIntFromConfig(ConfigSection(), KIniExpectedRetCode, expRetCode) )
69 ERR_PRINTF3(_L("Problem in reading values from ini. \
70 \nExpected fields are: \n%S\n%S\n" ),&KIniUri, &KIniExpectedRetCode );
71 SetTestStepResult(EFail);
75 // No problem in reading values from INI file. Proceed.
76 // Calling TestTelUriValidate which does validation of tel uri and comparing results.
77 TRAPD(err, TestTelUriValidateAndCompareL(telUri,expRetCode));
80 ERR_PRINTF1(_L("Test step failed: Leave occured in TestTelUriValidateAndCompareL \n"));
81 SetTestStepResult(EFail);
85 INFO_PRINTF1(_L("\nTest of TelUri Validation is Executed"));
86 return TestStepResult();
90 Performs tel uri validation and compares actual & expected result.
91 @param aTelUri A reference to tel-uri to be validated.
92 @param aExpRetCode An expected retrn code to be compared.
94 void CTestTelUriValidationStep::TestTelUriValidateAndCompareL(const TDesC16& aTelUri, const TInt aExpRetCode)
96 CUri8* cUri8 = UriUtils::CreateUriL(aTelUri);
97 const TUriC8& telUri(cUri8->Uri());
99 TInt errCode = telUri.Validate();
100 if(errCode != aExpRetCode)
102 ERR_PRINTF2(_L("Tel URI validation failed %D\n"), errCode);
103 SetTestStepResult(EFail);
109 Constructor: Sets the test step name.
113 CTestTelUriValidationOomStep::CTestTelUriValidationOomStep()
115 //Call base class method to set human readable name for test step
116 SetTestStepName(KTestOomTelUriValidationStep);
124 CTestTelUriValidationOomStep::~CTestTelUriValidationOomStep()
130 Does the main functionality of a test step and performs OOM test.
131 Here, reads values from INI file
132 and calls TestTelUriValidate() which does validation of a tel uri.
135 @return EPass or EFail indicating the success or failure of the test step
137 TVerdict CTestTelUriValidationOomStep::doTestStepL()
141 if(!GetStringFromConfig(ConfigSection(), KIniUri, telUri) )
143 ERR_PRINTF2(_L("Problem in reading values from ini. \
144 \nExpected fields are: \n%S\n" ), &KIniUri);
145 SetTestStepResult(EFail);
149 CUri8* cUri8 = UriUtils::CreateUriL(telUri);
150 const TUriC8& telUri(cUri8->Uri());
151 INFO_PRINTF1(_L("Calling telUri.Validate() which does tel-Uri Validation."));
152 TInt ret = KErrNoMemory;
154 while(ret != KErrNone)
157 INFO_PRINTF2(_L("OOM test step: %d\n"),failAt);
159 __UHEAP_SETFAIL( RHeap::EDeterministic, failAt );
161 TRAP( ret, telUri.Validate());
164 if((ret == KErrNoMemory) || (ret == KErrNone))
166 INFO_PRINTF2(_L("Error/RetCode : %D\n"),ret);
172 INFO_PRINTF1(_L("\n OOM Test of TelUri Validation is Executed"));
173 return TestStepResult();