os/ossrv/lowlevellibsandfws/pluginfw/TestExecute/EComPerfTest/src/Te_EComPerfTestStep.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/lowlevellibsandfws/pluginfw/TestExecute/EComPerfTest/src/Te_EComPerfTestStep.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,162 @@
1.4 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Base test step for ECom performance tests
1.18 +//
1.19 +//
1.20 +
1.21 +/**
1.22 + @file
1.23 + @internalComponent
1.24 +*/
1.25 +
1.26 +#include <ecom/ecom.h>
1.27 +#include "Te_EComPerfTestStep.h"
1.28 +#include "EcomTestUtils.h"
1.29 +
1.30 +#ifdef __ECOM_SERVER_PERFORMANCE__
1.31 +const TInt KOneSecond = 1000000;
1.32 +#endif
1.33 +
1.34 +CEComPerfTestBase::CEComPerfTestBase(const TDesC& aStepName)
1.35 + {
1.36 + SetTestStepName(aStepName);
1.37 + }
1.38 +
1.39 +CEComPerfTestBase::~CEComPerfTestBase()
1.40 + {
1.41 + }
1.42 +
1.43 +/**
1.44 + Set-up ECom performance tests by starting the ECom server and then waiting to allow start-up to complete
1.45 +*/
1.46 +TVerdict CEComPerfTestBase::doTestStepPreambleL()
1.47 + {
1.48 +#ifdef __ECOM_SERVER_PERFORMANCE__
1.49 + //Open the ecom session which in turn should start the ecom server.
1.50 + //Next, wait to make sure that startup is complete before requesting timing data.
1.51 + //Finally, get rid of the ecom session.
1.52 + REComSession& ecomSession = REComSession::OpenL();
1.53 + CleanupClosePushL(ecomSession);
1.54 + User::After(KOneSecond*15); //delay for 15 sec to ensure ecom start up has completed
1.55 + CleanupStack::PopAndDestroy(&ecomSession);
1.56 +
1.57 +#endif
1.58 + return TestStepResult() ;
1.59 + }
1.60 +
1.61 +TVerdict CEComPerfTestBase::doTestStepPostambleL()
1.62 + {
1.63 + return TestStepResult() ;
1.64 + }
1.65 +
1.66 +/**
1.67 + Fails the test if the measured time is less than the maximum time
1.68 + This test is only enabled on hardware non-DP release builds
1.69 + (testing for DP builds was disabled due to inconsistency of the results)
1.70 + @param aActualTime The measured time
1.71 + @param aMaxTime The maximum time
1.72 + */
1.73 +#if defined(__EPOC32__) && !defined(_DEBUG)
1.74 +void CEComPerfTestBase::CheckPerformance(TReal aActualTime, TReal aMaxTime, TPtrC aTimingMessage)
1.75 + {
1.76 + THardwareConfiguration hardware_configuration = EComTestUtils::GetHardwareConfiguration();
1.77 + if ( hardware_configuration != EPlatformH4NANDDP )
1.78 + {
1.79 + if (aActualTime < aMaxTime)
1.80 + {
1.81 + INFO_PRINTF4(_L("Performance test for [%S] passed (Measured time [%f] mSecs, Time limit [%f] mSecs\n"), &aTimingMessage, aActualTime, aMaxTime);
1.82 + }
1.83 + else
1.84 + {
1.85 + INFO_PRINTF4(_L("Performance test for [%S] FAILED (Measured time [%f] mSecs, Time limit [%f] mSecs\n"), &aTimingMessage, aActualTime, aMaxTime);
1.86 + }
1.87 + TEST(aActualTime < aMaxTime);
1.88 + }
1.89 + else
1.90 +#else
1.91 +void CEComPerfTestBase::CheckPerformance(TReal aActualTime, TReal /*aMaxTime*/, TPtrC aTimingMessage)
1.92 + {
1.93 +#endif
1.94 + /*Stub implementation used when performance testing is disabled
1.95 + Performance testing is not enabled on debug, emulator and DP builds*/
1.96 + INFO_PRINTF3(_L("Performance check disabled. Measured time for [%S] is [%f] mSecs\n"), &aTimingMessage, aActualTime);
1.97 + }
1.98 +
1.99 +
1.100 +#ifdef __ECOM_SERVER_PERFORMANCE__
1.101 +
1.102 +_LIT(KUnknownDesC, "Unknown");
1.103 +_LIT(KCreateDesC, "Create");
1.104 +_LIT(KListDesC, "List");
1.105 +_LIT(KNotifyOnChangeDesC, "Notify On Change");
1.106 +_LIT(KCancelNotifyOnChangeDesC, "Cancel Notify On Change");
1.107 +_LIT(KCollectImplementationsDesC, "Collect Implementations");
1.108 +_LIT(KListExtendedInterfacesDesC, "List extended interfaces");
1.109 +/**
1.110 + Converts a client request type into a string description of the enumeration
1.111 + @param aClientRequest The client request to retrieve a string description of
1.112 + @return The string description of aClientRequest
1.113 + */
1.114 +TPtrC CEComPerfTestBase::ClientRequestTypeName(TEComClientRequestType aClientRequestType)
1.115 + {
1.116 + switch (aClientRequestType)
1.117 + {
1.118 + case EEComCreateRequestType:
1.119 + return (TDesC&)KCreateDesC;
1.120 + case EEComListRequestType:
1.121 + return (TDesC&)KListDesC;
1.122 + case EEComNotifyOnChangeRequestType:
1.123 + return (TDesC&)KNotifyOnChangeDesC;
1.124 + case EEComCancelNotifyOnChangeRequestType:
1.125 + return (TDesC&)KCancelNotifyOnChangeDesC;
1.126 + case EEComCollectImplementationsRequestType:
1.127 + return (TDesC&)KCollectImplementationsDesC;
1.128 + case EEComListExtendedInterfacesRequestType:
1.129 + return (TDesC&)KListExtendedInterfacesDesC;
1.130 + default:
1.131 + return (TDesC&)KUnknownDesC;
1.132 + }
1.133 + }
1.134 +
1.135 +_LIT(KCriticalStaticDesC, "CriticalStatic");
1.136 +_LIT(KCriticalDynamicDesC, "CriticalDynamic");
1.137 +_LIT(KNonCriticalDesC, "NonCritical");
1.138 +/**
1.139 + Converts a startup state into a string description of the enumeration
1.140 + @param aStartupStateIdentifier The startup state to retrieve a string description of
1.141 + @return The string description of aStartupStateIdentifier
1.142 + */
1.143 +TPtrC CEComPerfTestBase::StartupStateName(TStartupStateIdentifier aStartupStateIdentifier)
1.144 + {
1.145 + switch (aStartupStateIdentifier)
1.146 + {
1.147 + case EStartupStateCriticalStatic:
1.148 + return (TDesC&)KCriticalStaticDesC;
1.149 + case EStartupStateCriticalDynamic:
1.150 + return (TDesC&)KCriticalDynamicDesC;
1.151 + case EStartupStateNonCritical:
1.152 + return (TDesC&)KNonCriticalDesC;
1.153 + default:
1.154 + return (TDesC&)KUnknownDesC;
1.155 + }
1.156 + }
1.157 +#endif // #ifdef __ECOM_SERVER_PERFORMANCE__
1.158 +
1.159 +#ifndef __ECOM_SERVER_PERFORMANCE__
1.160 +void CEComPerfTestBase::MacroNotDefinedError()
1.161 + {
1.162 + SetTestStepResult(EFail);
1.163 + INFO_PRINTF1(_L("***Please define __ECOM_SERVER_PERFORMANCE__ macro to run this test ***"));
1.164 + }
1.165 +#endif // #ifndef __ECOM_SERVER_PERFORMANCE__