os/ossrv/lowlevellibsandfws/pluginfw/TestExecute/EComPerfTest/src/Te_EComPerfTestStep.cpp
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Base test step for ECom performance tests
23 #include <ecom/ecom.h>
24 #include "Te_EComPerfTestStep.h"
25 #include "EcomTestUtils.h"
27 #ifdef __ECOM_SERVER_PERFORMANCE__
28 const TInt KOneSecond = 1000000;
31 CEComPerfTestBase::CEComPerfTestBase(const TDesC& aStepName)
33 SetTestStepName(aStepName);
36 CEComPerfTestBase::~CEComPerfTestBase()
41 Set-up ECom performance tests by starting the ECom server and then waiting to allow start-up to complete
43 TVerdict CEComPerfTestBase::doTestStepPreambleL()
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);
55 return TestStepResult() ;
58 TVerdict CEComPerfTestBase::doTestStepPostambleL()
60 return TestStepResult() ;
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
70 #if defined(__EPOC32__) && !defined(_DEBUG)
71 void CEComPerfTestBase::CheckPerformance(TReal aActualTime, TReal aMaxTime, TPtrC aTimingMessage)
73 THardwareConfiguration hardware_configuration = EComTestUtils::GetHardwareConfiguration();
74 if ( hardware_configuration != EPlatformH4NANDDP )
76 if (aActualTime < aMaxTime)
78 INFO_PRINTF4(_L("Performance test for [%S] passed (Measured time [%f] mSecs, Time limit [%f] mSecs\n"), &aTimingMessage, aActualTime, aMaxTime);
82 INFO_PRINTF4(_L("Performance test for [%S] FAILED (Measured time [%f] mSecs, Time limit [%f] mSecs\n"), &aTimingMessage, aActualTime, aMaxTime);
84 TEST(aActualTime < aMaxTime);
88 void CEComPerfTestBase::CheckPerformance(TReal aActualTime, TReal /*aMaxTime*/, TPtrC aTimingMessage)
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);
97 #ifdef __ECOM_SERVER_PERFORMANCE__
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");
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
111 TPtrC CEComPerfTestBase::ClientRequestTypeName(TEComClientRequestType aClientRequestType)
113 switch (aClientRequestType)
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;
128 return (TDesC&)KUnknownDesC;
132 _LIT(KCriticalStaticDesC, "CriticalStatic");
133 _LIT(KCriticalDynamicDesC, "CriticalDynamic");
134 _LIT(KNonCriticalDesC, "NonCritical");
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
140 TPtrC CEComPerfTestBase::StartupStateName(TStartupStateIdentifier aStartupStateIdentifier)
142 switch (aStartupStateIdentifier)
144 case EStartupStateCriticalStatic:
145 return (TDesC&)KCriticalStaticDesC;
146 case EStartupStateCriticalDynamic:
147 return (TDesC&)KCriticalDynamicDesC;
148 case EStartupStateNonCritical:
149 return (TDesC&)KNonCriticalDesC;
151 return (TDesC&)KUnknownDesC;
154 #endif // #ifdef __ECOM_SERVER_PERFORMANCE__
156 #ifndef __ECOM_SERVER_PERFORMANCE__
157 void CEComPerfTestBase::MacroNotDefinedError()
159 SetTestStepResult(EFail);
160 INFO_PRINTF1(_L("***Please define __ECOM_SERVER_PERFORMANCE__ macro to run this test ***"));
162 #endif // #ifndef __ECOM_SERVER_PERFORMANCE__