1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/crypto/weakcryptospi/test/tasymmetric/performancetest.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,124 @@
1.4 +/*
1.5 +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +/**
1.23 + @file
1.24 +*/
1.25 +
1.26 +#include "performancetest.h"
1.27 +#include "t_input.h"
1.28 +#include "tvectorutils.h"
1.29 +
1.30 +_LIT8(KPerformanceTestStart, "<KPerformanceTesting>");
1.31 +_LIT8(KPerformanceTestEnd, "</KPerformanceTesting>");
1.32 +
1.33 +/*static*/ CPerformance* CPerformance::iPerformanceTester = NULL;
1.34 +
1.35 +/*static*/ CPerformance* CPerformance::NewL()
1.36 +{
1.37 + if (!iPerformanceTester)
1.38 + {
1.39 + iPerformanceTester = new (ELeave) CPerformance();
1.40 + }
1.41 +
1.42 + return (iPerformanceTester);
1.43 +}
1.44 +
1.45 +/*static*/ CPerformance* CPerformance::PerformanceTester()
1.46 +{
1.47 + ASSERT(iPerformanceTester);
1.48 + return (iPerformanceTester);
1.49 +}
1.50 +
1.51 +/*static*/ void CPerformance::ClosePerformanceTester()
1.52 +{
1.53 + delete iPerformanceTester;
1.54 + iPerformanceTester = NULL;
1.55 +}
1.56 +
1.57 +
1.58 +CPerformance::CPerformance()
1.59 +: iTestingPerformance(EFalse) // Default to no performance testing
1.60 +{}
1.61 +
1.62 +CPerformance::~CPerformance()
1.63 +{}
1.64 +
1.65 +////////////////////////////////////////////////////////////////////////
1.66 +// Use this class as a place holder to turn performance testing on/off
1.67 +////////////////////////////////////////////////////////////////////////
1.68 +
1.69 +CTestAction* CPerformanceTest::NewL(RFs& aFs, CConsoleBase& aConsole, Output& aOut, const TTestActionSpec& aTestActionSpec)
1.70 +{
1.71 + CTestAction* me = CPerformanceTest::NewLC(aFs, aConsole, aOut, aTestActionSpec);
1.72 + CleanupStack::Pop(me);
1.73 + return (me);
1.74 +}
1.75 +
1.76 +CTestAction* CPerformanceTest::NewLC(RFs& /*aFs*/, CConsoleBase& aConsole, Output& aOut, const TTestActionSpec& aTestActionSpec)
1.77 +{
1.78 + CPerformanceTest* me = new (ELeave) CPerformanceTest(aConsole, aOut);
1.79 + CleanupStack::PushL(me);
1.80 + me->ConstructL(aTestActionSpec);
1.81 + return (static_cast<CTestAction*>(me));
1.82 +}
1.83 +
1.84 +
1.85 +CPerformanceTest::CPerformanceTest(CConsoleBase& aConsole, Output& aOut)
1.86 + : CTestAction(aConsole, aOut)
1.87 + {
1.88 + }
1.89 +
1.90 +CPerformanceTest::~CPerformanceTest()
1.91 + {
1.92 + }
1.93 +
1.94 +void CPerformanceTest::ConstructL(const TTestActionSpec& aTestActionSpec)
1.95 +{
1.96 + CTestAction::ConstructL(aTestActionSpec);
1.97 +
1.98 +// Switch on performance testing?
1.99 + TPtrC8 enablePtr = Input::ParseElement(aTestActionSpec.iActionBody, KPerformanceTestStart, KPerformanceTestEnd);
1.100 + TBool enablePerformance = VectorUtils::ParseBoolL(enablePtr);
1.101 + CPerformance::PerformanceTester()->SetTestingPerformance(enablePerformance);
1.102 +
1.103 + iExpectedResult = KErrNone;
1.104 +}
1.105 +
1.106 +void CPerformanceTest::DoPerformPrerequisite(TRequestStatus& aStatus)
1.107 + {
1.108 + TRequestStatus* status = &aStatus;
1.109 + User::RequestComplete(status, KErrNone);
1.110 + iActionState = CTestAction::EAction;
1.111 + }
1.112 +
1.113 +void CPerformanceTest::DoPerformPostrequisite(TRequestStatus& aStatus)
1.114 + {
1.115 + TRequestStatus* status = &aStatus;
1.116 + iFinished = ETrue;
1.117 + User::RequestComplete(status, KErrNone);
1.118 + }
1.119 +
1.120 +void CPerformanceTest::PerformAction(TRequestStatus& aStatus)
1.121 +{
1.122 + iResult = ETrue;
1.123 + iFinished = ETrue;
1.124 + TRequestStatus* status = &aStatus;
1.125 + User::RequestComplete(status, KErrNone);
1.126 +}
1.127 +