sl@0: // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Base test step for ECom performance tests sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: */ sl@0: sl@0: #include sl@0: #include "Te_EComPerfTestStep.h" sl@0: #include "EcomTestUtils.h" sl@0: sl@0: #ifdef __ECOM_SERVER_PERFORMANCE__ sl@0: const TInt KOneSecond = 1000000; sl@0: #endif sl@0: sl@0: CEComPerfTestBase::CEComPerfTestBase(const TDesC& aStepName) sl@0: { sl@0: SetTestStepName(aStepName); sl@0: } sl@0: sl@0: CEComPerfTestBase::~CEComPerfTestBase() sl@0: { sl@0: } sl@0: sl@0: /** sl@0: Set-up ECom performance tests by starting the ECom server and then waiting to allow start-up to complete sl@0: */ sl@0: TVerdict CEComPerfTestBase::doTestStepPreambleL() sl@0: { sl@0: #ifdef __ECOM_SERVER_PERFORMANCE__ sl@0: //Open the ecom session which in turn should start the ecom server. sl@0: //Next, wait to make sure that startup is complete before requesting timing data. sl@0: //Finally, get rid of the ecom session. sl@0: REComSession& ecomSession = REComSession::OpenL(); sl@0: CleanupClosePushL(ecomSession); sl@0: User::After(KOneSecond*15); //delay for 15 sec to ensure ecom start up has completed sl@0: CleanupStack::PopAndDestroy(&ecomSession); sl@0: sl@0: #endif sl@0: return TestStepResult() ; sl@0: } sl@0: sl@0: TVerdict CEComPerfTestBase::doTestStepPostambleL() sl@0: { sl@0: return TestStepResult() ; sl@0: } sl@0: sl@0: /** sl@0: Fails the test if the measured time is less than the maximum time sl@0: This test is only enabled on hardware non-DP release builds sl@0: (testing for DP builds was disabled due to inconsistency of the results) sl@0: @param aActualTime The measured time sl@0: @param aMaxTime The maximum time sl@0: */ sl@0: #if defined(__EPOC32__) && !defined(_DEBUG) sl@0: void CEComPerfTestBase::CheckPerformance(TReal aActualTime, TReal aMaxTime, TPtrC aTimingMessage) sl@0: { sl@0: THardwareConfiguration hardware_configuration = EComTestUtils::GetHardwareConfiguration(); sl@0: if ( hardware_configuration != EPlatformH4NANDDP ) sl@0: { sl@0: if (aActualTime < aMaxTime) sl@0: { sl@0: INFO_PRINTF4(_L("Performance test for [%S] passed (Measured time [%f] mSecs, Time limit [%f] mSecs\n"), &aTimingMessage, aActualTime, aMaxTime); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF4(_L("Performance test for [%S] FAILED (Measured time [%f] mSecs, Time limit [%f] mSecs\n"), &aTimingMessage, aActualTime, aMaxTime); sl@0: } sl@0: TEST(aActualTime < aMaxTime); sl@0: } sl@0: else sl@0: #else sl@0: void CEComPerfTestBase::CheckPerformance(TReal aActualTime, TReal /*aMaxTime*/, TPtrC aTimingMessage) sl@0: { sl@0: #endif sl@0: /*Stub implementation used when performance testing is disabled sl@0: Performance testing is not enabled on debug, emulator and DP builds*/ sl@0: INFO_PRINTF3(_L("Performance check disabled. Measured time for [%S] is [%f] mSecs\n"), &aTimingMessage, aActualTime); sl@0: } sl@0: sl@0: sl@0: #ifdef __ECOM_SERVER_PERFORMANCE__ sl@0: sl@0: _LIT(KUnknownDesC, "Unknown"); sl@0: _LIT(KCreateDesC, "Create"); sl@0: _LIT(KListDesC, "List"); sl@0: _LIT(KNotifyOnChangeDesC, "Notify On Change"); sl@0: _LIT(KCancelNotifyOnChangeDesC, "Cancel Notify On Change"); sl@0: _LIT(KCollectImplementationsDesC, "Collect Implementations"); sl@0: _LIT(KListExtendedInterfacesDesC, "List extended interfaces"); sl@0: /** sl@0: Converts a client request type into a string description of the enumeration sl@0: @param aClientRequest The client request to retrieve a string description of sl@0: @return The string description of aClientRequest sl@0: */ sl@0: TPtrC CEComPerfTestBase::ClientRequestTypeName(TEComClientRequestType aClientRequestType) sl@0: { sl@0: switch (aClientRequestType) sl@0: { sl@0: case EEComCreateRequestType: sl@0: return (TDesC&)KCreateDesC; sl@0: case EEComListRequestType: sl@0: return (TDesC&)KListDesC; sl@0: case EEComNotifyOnChangeRequestType: sl@0: return (TDesC&)KNotifyOnChangeDesC; sl@0: case EEComCancelNotifyOnChangeRequestType: sl@0: return (TDesC&)KCancelNotifyOnChangeDesC; sl@0: case EEComCollectImplementationsRequestType: sl@0: return (TDesC&)KCollectImplementationsDesC; sl@0: case EEComListExtendedInterfacesRequestType: sl@0: return (TDesC&)KListExtendedInterfacesDesC; sl@0: default: sl@0: return (TDesC&)KUnknownDesC; sl@0: } sl@0: } sl@0: sl@0: _LIT(KCriticalStaticDesC, "CriticalStatic"); sl@0: _LIT(KCriticalDynamicDesC, "CriticalDynamic"); sl@0: _LIT(KNonCriticalDesC, "NonCritical"); sl@0: /** sl@0: Converts a startup state into a string description of the enumeration sl@0: @param aStartupStateIdentifier The startup state to retrieve a string description of sl@0: @return The string description of aStartupStateIdentifier sl@0: */ sl@0: TPtrC CEComPerfTestBase::StartupStateName(TStartupStateIdentifier aStartupStateIdentifier) sl@0: { sl@0: switch (aStartupStateIdentifier) sl@0: { sl@0: case EStartupStateCriticalStatic: sl@0: return (TDesC&)KCriticalStaticDesC; sl@0: case EStartupStateCriticalDynamic: sl@0: return (TDesC&)KCriticalDynamicDesC; sl@0: case EStartupStateNonCritical: sl@0: return (TDesC&)KNonCriticalDesC; sl@0: default: sl@0: return (TDesC&)KUnknownDesC; sl@0: } sl@0: } sl@0: #endif // #ifdef __ECOM_SERVER_PERFORMANCE__ sl@0: sl@0: #ifndef __ECOM_SERVER_PERFORMANCE__ sl@0: void CEComPerfTestBase::MacroNotDefinedError() sl@0: { sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF1(_L("***Please define __ECOM_SERVER_PERFORMANCE__ macro to run this test ***")); sl@0: } sl@0: #endif // #ifndef __ECOM_SERVER_PERFORMANCE__