crypto/weakcrypto/test/tasymmetric/performancetest.cpp
changeset 0 2c201484c85f
equal deleted inserted replaced
-1:000000000000 0:2c201484c85f
       
     1 /*
       
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     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".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 /**
       
    22  @file
       
    23 */
       
    24 
       
    25 #include "performancetest.h"
       
    26 #include "t_input.h"
       
    27 #include "tvectorutils.h"
       
    28 
       
    29 _LIT8(KPerformanceTestStart, "<KPerformanceTesting>");
       
    30 _LIT8(KPerformanceTestEnd, "</KPerformanceTesting>");
       
    31 
       
    32 /*static*/ CPerformance* CPerformance::iPerformanceTester = NULL;
       
    33 
       
    34 /*static*/ CPerformance* CPerformance::NewL()
       
    35 {
       
    36 	if (!iPerformanceTester)
       
    37 	{
       
    38 		iPerformanceTester = new (ELeave) CPerformance();
       
    39 	}
       
    40 
       
    41 	return (iPerformanceTester);
       
    42 }
       
    43 
       
    44 /*static*/ CPerformance* CPerformance::PerformanceTester()
       
    45 {
       
    46 	ASSERT(iPerformanceTester);
       
    47 	return (iPerformanceTester);
       
    48 }
       
    49 
       
    50 /*static*/ void CPerformance::ClosePerformanceTester()
       
    51 {
       
    52 	delete iPerformanceTester;
       
    53 	iPerformanceTester = NULL;
       
    54 }
       
    55 
       
    56 
       
    57 CPerformance::CPerformance()
       
    58 :	iTestingPerformance(EFalse)	//	Default to no performance testing
       
    59 {}
       
    60 
       
    61 CPerformance::~CPerformance()
       
    62 {}
       
    63 
       
    64 ////////////////////////////////////////////////////////////////////////
       
    65 //	Use this class as a place holder to turn performance testing on/off
       
    66 ////////////////////////////////////////////////////////////////////////
       
    67 	
       
    68 CTestAction* CPerformanceTest::NewL(RFs& aFs, CConsoleBase& aConsole, Output& aOut, const TTestActionSpec& aTestActionSpec)
       
    69 {
       
    70 	CTestAction* me = CPerformanceTest::NewLC(aFs, aConsole, aOut, aTestActionSpec);
       
    71 	CleanupStack::Pop(me);
       
    72 	return (me);
       
    73 }
       
    74 
       
    75 CTestAction* CPerformanceTest::NewLC(RFs& /*aFs*/, CConsoleBase& aConsole, Output& aOut, const TTestActionSpec& aTestActionSpec)
       
    76 {
       
    77 	CPerformanceTest* me = new (ELeave) CPerformanceTest(aConsole, aOut);
       
    78 	CleanupStack::PushL(me);
       
    79 	me->ConstructL(aTestActionSpec);
       
    80 	return (static_cast<CTestAction*>(me));
       
    81 }
       
    82 
       
    83 
       
    84 CPerformanceTest::CPerformanceTest(CConsoleBase& aConsole, Output& aOut)
       
    85     : CTestAction(aConsole, aOut)
       
    86     {
       
    87     }
       
    88 
       
    89 CPerformanceTest::~CPerformanceTest()
       
    90     {
       
    91     }
       
    92 
       
    93 void CPerformanceTest::ConstructL(const TTestActionSpec& aTestActionSpec)
       
    94 {
       
    95 	CTestAction::ConstructL(aTestActionSpec);
       
    96 
       
    97 //	Switch on performance testing?    
       
    98 	TPtrC8 enablePtr = Input::ParseElement(aTestActionSpec.iActionBody, KPerformanceTestStart, KPerformanceTestEnd);
       
    99     TBool enablePerformance = VectorUtils::ParseBoolL(enablePtr);
       
   100 	CPerformance::PerformanceTester()->SetTestingPerformance(enablePerformance);
       
   101 	
       
   102 	iExpectedResult = KErrNone;
       
   103 }
       
   104 
       
   105 void CPerformanceTest::DoPerformPrerequisite(TRequestStatus& aStatus)
       
   106 	{
       
   107 	TRequestStatus* status = &aStatus;
       
   108 	User::RequestComplete(status, KErrNone);
       
   109 	iActionState = CTestAction::EAction;
       
   110 	}
       
   111 
       
   112 void CPerformanceTest::DoPerformPostrequisite(TRequestStatus& aStatus)
       
   113 	{
       
   114 	TRequestStatus* status = &aStatus;
       
   115 	iFinished = ETrue;
       
   116 	User::RequestComplete(status, KErrNone);
       
   117 	}
       
   118 
       
   119 void CPerformanceTest::PerformAction(TRequestStatus& aStatus)
       
   120 {
       
   121 	iResult = ETrue;
       
   122 	iFinished = ETrue;
       
   123 	TRequestStatus* status = &aStatus;
       
   124 	User::RequestComplete(status, KErrNone);	
       
   125 }