os/security/authorisation/userpromptservice/policies/test/tupspolicies/source/util.cpp
First public contribution.
2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
21 using namespace UserPromptService;
23 const TDesC& OptionToString(CPolicy::TOptions aOption)
33 case CPolicy::ESessionYes:
34 _LIT(KSessionYes, "SessionYes");
36 case CPolicy::ESessionNo:
37 _LIT(KSessionNo, "SessionNo");
39 case CPolicy::EAlways:
40 _LIT(KAlways, "Always");
43 _LIT(KNever, "Never");
46 _LIT(KUnknown, "Unknown");
51 TInt StringToOptionL(const TDesC& aString)
53 if (aString.MatchF(_L("yes")))
55 else if (aString.MatchF(_L("no")))
57 else if (aString.MatchF(_L("session")))
58 return CPolicy::ESessionYes;
59 else if (aString.MatchF(_L("sessionyes")))
60 return CPolicy::ESessionYes;
61 else if (aString.MatchF(_L("sessionno")))
62 return CPolicy::ESessionNo;
63 else if (aString.MatchF(_L("always")))
64 return CPolicy::EAlways;
65 else if (aString.MatchF(_L("never")))
66 return CPolicy::ENever;
68 User::Leave(KErrGeneral);
73 TBool CheckExpectedError(CTestExecuteLogger& aLogger, TInt aExpected, TInt aActual)
75 Compares the expected and the actual error and logs the result.
76 @param aExpected The expected error code.
77 @param aActual The actual error.
78 @return ETrue, if the expected and actual errors matched; otherwise, EFalse is returned.
81 if (aActual == KErrNone && aExpected == KErrNone)
83 aLogger.LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo,
84 _L("Passed - no error"));
87 else if (aActual == aExpected)
89 aLogger.LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo,
90 _L("Encountered expected error %d"), aActual);
93 else if (aActual == KErrNone)
95 aLogger.LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr,
96 _L("Did not encounter expected error %d"), aExpected);
101 aLogger.LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr,
102 _L("Unexpected error %d"), aActual);