os/security/cryptomgmtlibs/securitytestfw/test/captestframework/captestutility.cpp
Update contrib.
2 * Copyright (c) 2005-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.
25 #include "captestutility.h"
27 // CDefaultCapabilityTest
29 EXPORT_C CDefaultCapabilityTest::~CDefaultCapabilityTest()
35 iLogWriteStream->WriteInt32L(EFileEnd); // End marker
36 iLogWriteStream->Close();
37 delete iLogWriteStream;
42 EXPORT_C void CDefaultCapabilityTest::SetNameL(const TDesC& aName)
46 iTestName=HBufC::NewL(aName.Length());
47 TPtr testNamePtr=iTestName->Des();
48 testNamePtr.Copy(aName);
51 EXPORT_C TInt CDefaultCapabilityTest::CheckFailL(TInt aResult, const TDesC& aTestName)
53 _LIT(KColourRed, "<font color=FF0000>");
54 _LIT(KColourGreen, "<font color=00AF00>");
55 _LIT(KFontEndColour, "</font>");
58 if (iExpectPermissionDenied && aResult==KErrPermissionDenied)
60 buf.Format(_L("%S%S: Permission Denied, Err=%d%S"), &KColourGreen, &aTestName, aResult, &KFontEndColour);
61 iLogWriteStream->WriteInt32L(ETestPassed);
62 *iLogWriteStream << buf;
65 else if (!iExpectPermissionDenied && aResult!=KErrPermissionDenied)
67 buf.Format(_L("%S%S: Succeeded, Err=%d%S"), &KColourGreen, &aTestName, aResult, &KFontEndColour);
68 iLogWriteStream->WriteInt32L(ETestPassed);
69 *iLogWriteStream << buf;
73 // Test failed, do something with error.
74 if (aResult == KErrPermissionDenied)
76 buf.Format(_L("%S%S: Permission denied! (Unexpected), Err=%d%S"), &KColourRed, &aTestName, aResult, &KFontEndColour);
77 iLogWriteStream->WriteInt32L(ETestFailed);
78 *iLogWriteStream << buf;
82 buf.Format(_L("%S%S: Succeeded! (Unexpected), Err=%d%S"), &KColourRed, &aTestName, aResult, &KFontEndColour);
83 iLogWriteStream->WriteInt32L(ETestFailed);
84 *iLogWriteStream << buf;
91 EXPORT_C void CDefaultCapabilityTest::RunTestL(RFile& aLogFile)
98 iLogWriteStream->Close();
99 delete iLogWriteStream;
102 iLogWriteStream=new(ELeave) RFileWriteStream(aLogFile, 0);
109 iLogWriteStream->WriteInt32L(ETestsEnded); // Test ended ok
113 EXPORT_C const TDesC& CDefaultCapabilityTest::Name() const
122 EXPORT_C const TDesC& CDefaultCapabilityTest::SubName() const
126 return *iTestSubName;
131 EXPORT_C TCapabilitySet CDefaultCapabilityTest::CapabilitiesRequired() const
133 return iCapabilitySet;
136 EXPORT_C TUid CDefaultCapabilityTest::VidRequired() const
141 EXPORT_C TUid CDefaultCapabilityTest::SidRequired() const
146 EXPORT_C void CDefaultCapabilityTest::SetCapabilityRequired(const TCapability& aCapability)
148 iCapabilitySet.AddCapability(aCapability);
151 EXPORT_C void CDefaultCapabilityTest::SetSidRequired(const TUid& aSid)
156 EXPORT_C void CDefaultCapabilityTest::SetVidRequired(const TUid& aVid)
161 // CDefaultCapabilityTestFactory
162 EXPORT_C MCapabilityTest* CDefaultCapabilityTestFactory::Test(TInt aTestNumber)
164 return iTests[aTestNumber];
167 EXPORT_C TInt CDefaultCapabilityTestFactory::NumberOfTests()
169 return iTests.Count();
172 EXPORT_C void CDefaultCapabilityTestFactory::AddTestL(CDefaultCapabilityTest* aTest)
174 iTests.AppendL(aTest);
178 EXPORT_C CDefaultCapabilityTestFactory::~CDefaultCapabilityTestFactory()
180 for (TInt i=0; i< iTests.Count(); ++i)