os/ossrv/lowlevellibsandfws/pluginfw/TestExecute/EComPerfTest/src/Te_EComPerfTestStep.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // Base test step for ECom performance tests
    15 // 
    16 //
    17 
    18 /**
    19  @file
    20  @internalComponent
    21 */
    22 
    23 #include <ecom/ecom.h>
    24 #include "Te_EComPerfTestStep.h"
    25 #include "EcomTestUtils.h"
    26 
    27 #ifdef __ECOM_SERVER_PERFORMANCE__
    28 const TInt KOneSecond = 1000000;
    29 #endif
    30 
    31 CEComPerfTestBase::CEComPerfTestBase(const TDesC& aStepName)
    32 	{
    33 	SetTestStepName(aStepName);
    34 	}
    35 
    36 CEComPerfTestBase::~CEComPerfTestBase()
    37 	{
    38 	}
    39 
    40 /**
    41  Set-up ECom performance tests by starting the ECom server and then waiting to allow start-up to complete
    42 */
    43 TVerdict CEComPerfTestBase::doTestStepPreambleL()
    44 	{
    45 #ifdef __ECOM_SERVER_PERFORMANCE__
    46 	//Open the ecom session which in turn should start the ecom server.
    47 	//Next, wait to make sure that startup is complete before requesting timing data.
    48 	//Finally, get rid of the ecom session.
    49 	REComSession& ecomSession = REComSession::OpenL();
    50 	CleanupClosePushL(ecomSession);
    51 	User::After(KOneSecond*15); //delay for 15 sec to ensure ecom start up has completed
    52 	CleanupStack::PopAndDestroy(&ecomSession);
    53 
    54 #endif
    55 	return TestStepResult() ;
    56 	}
    57 
    58 TVerdict CEComPerfTestBase::doTestStepPostambleL()
    59 	{
    60  	return TestStepResult() ;
    61 	}
    62 
    63 /**
    64  Fails the test if the measured time is less than the maximum time
    65  This test is only enabled on hardware non-DP release builds
    66  (testing for DP builds was disabled due to inconsistency of the results)
    67  @param aActualTime The measured time
    68  @param aMaxTime The maximum time
    69  */
    70 #if defined(__EPOC32__) && !defined(_DEBUG)
    71 void CEComPerfTestBase::CheckPerformance(TReal aActualTime, TReal aMaxTime, TPtrC aTimingMessage)
    72 	{
    73 	THardwareConfiguration hardware_configuration = EComTestUtils::GetHardwareConfiguration();
    74     if ( hardware_configuration != EPlatformH4NANDDP )
    75 		{	
    76 		if (aActualTime < aMaxTime)
    77 			{
    78 			INFO_PRINTF4(_L("Performance test for [%S] passed (Measured time [%f] mSecs, Time limit [%f] mSecs\n"), &aTimingMessage, aActualTime, aMaxTime);
    79 			}
    80 		else
    81 			{
    82 			INFO_PRINTF4(_L("Performance test for [%S] FAILED (Measured time [%f] mSecs, Time limit [%f] mSecs\n"), &aTimingMessage, aActualTime, aMaxTime);
    83 			}
    84 		TEST(aActualTime < aMaxTime);		
    85 		}
    86 	else
    87 #else
    88 void CEComPerfTestBase::CheckPerformance(TReal aActualTime, TReal /*aMaxTime*/, TPtrC aTimingMessage)
    89 	{
    90 #endif
    91 		/*Stub implementation used when performance testing is disabled
    92 		Performance testing is not enabled on debug, emulator and DP builds*/
    93 		INFO_PRINTF3(_L("Performance check disabled. Measured time for [%S] is [%f] mSecs\n"), &aTimingMessage, aActualTime);
    94 	}
    95 
    96 
    97 #ifdef __ECOM_SERVER_PERFORMANCE__
    98 
    99 _LIT(KUnknownDesC, "Unknown");
   100 _LIT(KCreateDesC, "Create");
   101 _LIT(KListDesC, "List");
   102 _LIT(KNotifyOnChangeDesC, "Notify On Change");
   103 _LIT(KCancelNotifyOnChangeDesC, "Cancel Notify On Change");
   104 _LIT(KCollectImplementationsDesC, "Collect Implementations");
   105 _LIT(KListExtendedInterfacesDesC, "List extended interfaces");
   106 /**
   107  Converts a client request type into a string description of the enumeration
   108  @param aClientRequest The client request to retrieve a string description of
   109  @return The string description of aClientRequest
   110  */
   111 TPtrC CEComPerfTestBase::ClientRequestTypeName(TEComClientRequestType aClientRequestType)
   112 	{
   113 	switch (aClientRequestType)
   114 		{
   115 		case EEComCreateRequestType:
   116 			return (TDesC&)KCreateDesC;
   117 		case EEComListRequestType:
   118 			return (TDesC&)KListDesC;
   119 		case EEComNotifyOnChangeRequestType:
   120 			return (TDesC&)KNotifyOnChangeDesC;
   121 		case EEComCancelNotifyOnChangeRequestType:
   122 			return (TDesC&)KCancelNotifyOnChangeDesC;
   123 		case EEComCollectImplementationsRequestType:
   124 			return (TDesC&)KCollectImplementationsDesC;
   125 		case EEComListExtendedInterfacesRequestType:
   126 			return (TDesC&)KListExtendedInterfacesDesC;
   127 		default:
   128 			return (TDesC&)KUnknownDesC;
   129 		}
   130 	}
   131 
   132 _LIT(KCriticalStaticDesC, "CriticalStatic");
   133 _LIT(KCriticalDynamicDesC, "CriticalDynamic");
   134 _LIT(KNonCriticalDesC, "NonCritical");
   135 /**
   136  Converts a startup state into a string description of the enumeration
   137  @param aStartupStateIdentifier The startup state to retrieve a string description of
   138  @return The string description of aStartupStateIdentifier
   139  */
   140 TPtrC CEComPerfTestBase::StartupStateName(TStartupStateIdentifier aStartupStateIdentifier)
   141 	{
   142 	switch (aStartupStateIdentifier)
   143 		{
   144 		case EStartupStateCriticalStatic:
   145 			return (TDesC&)KCriticalStaticDesC;
   146 		case EStartupStateCriticalDynamic:
   147 			return (TDesC&)KCriticalDynamicDesC;
   148 		case EStartupStateNonCritical:
   149 			return (TDesC&)KNonCriticalDesC;
   150 		default:
   151 			return (TDesC&)KUnknownDesC;
   152 		}
   153 	}
   154 #endif // #ifdef __ECOM_SERVER_PERFORMANCE__
   155 
   156 #ifndef __ECOM_SERVER_PERFORMANCE__
   157 void CEComPerfTestBase::MacroNotDefinedError()
   158 	{
   159 	SetTestStepResult(EFail);
   160 	INFO_PRINTF1(_L("***Please define __ECOM_SERVER_PERFORMANCE__ macro to run this test ***"));
   161 	}
   162 #endif // #ifndef __ECOM_SERVER_PERFORMANCE__