sl@0: /* 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 the License "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: * sl@0: */ sl@0: sl@0: sl@0: #include "util.h" sl@0: sl@0: using namespace UserPromptService; sl@0: sl@0: const TDesC& OptionToString(CPolicy::TOptions aOption) sl@0: { sl@0: switch (aOption) sl@0: { sl@0: case CPolicy::EYes: sl@0: _LIT(KYes, "Yes"); sl@0: return KYes; sl@0: case CPolicy::ENo: sl@0: _LIT(KNo, "No"); sl@0: return KNo; sl@0: case CPolicy::ESessionYes: sl@0: _LIT(KSessionYes, "SessionYes"); sl@0: return KSessionYes; sl@0: case CPolicy::ESessionNo: sl@0: _LIT(KSessionNo, "SessionNo"); sl@0: return KSessionNo; sl@0: case CPolicy::EAlways: sl@0: _LIT(KAlways, "Always"); sl@0: return KAlways; sl@0: case CPolicy::ENever: sl@0: _LIT(KNever, "Never"); sl@0: return KNever; sl@0: default: sl@0: _LIT(KUnknown, "Unknown"); sl@0: return KUnknown; sl@0: } sl@0: } sl@0: sl@0: TInt StringToOptionL(const TDesC& aString) sl@0: { sl@0: if (aString.MatchF(_L("yes"))) sl@0: return CPolicy::EYes; sl@0: else if (aString.MatchF(_L("no"))) sl@0: return CPolicy::ENo; sl@0: else if (aString.MatchF(_L("session"))) sl@0: return CPolicy::ESessionYes; sl@0: else if (aString.MatchF(_L("sessionyes"))) sl@0: return CPolicy::ESessionYes; sl@0: else if (aString.MatchF(_L("sessionno"))) sl@0: return CPolicy::ESessionNo; sl@0: else if (aString.MatchF(_L("always"))) sl@0: return CPolicy::EAlways; sl@0: else if (aString.MatchF(_L("never"))) sl@0: return CPolicy::ENever; sl@0: sl@0: User::Leave(KErrGeneral); sl@0: /*lint -unreachable*/ sl@0: return 0; sl@0: } sl@0: sl@0: TBool CheckExpectedError(CTestExecuteLogger& aLogger, TInt aExpected, TInt aActual) sl@0: /** sl@0: Compares the expected and the actual error and logs the result. sl@0: @param aExpected The expected error code. sl@0: @param aActual The actual error. sl@0: @return ETrue, if the expected and actual errors matched; otherwise, EFalse is returned. sl@0: */ sl@0: { sl@0: if (aActual == KErrNone && aExpected == KErrNone) sl@0: { sl@0: aLogger.LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, sl@0: _L("Passed - no error")); sl@0: return ETrue; sl@0: } sl@0: else if (aActual == aExpected) sl@0: { sl@0: aLogger.LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, sl@0: _L("Encountered expected error %d"), aActual); sl@0: return ETrue; sl@0: } sl@0: else if (aActual == KErrNone) sl@0: { sl@0: aLogger.LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, sl@0: _L("Did not encounter expected error %d"), aExpected); sl@0: return EFalse; sl@0: } sl@0: else sl@0: { sl@0: aLogger.LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, sl@0: _L("Unexpected error %d"), aActual); sl@0: return EFalse; sl@0: } sl@0: }