# HG changeset patch # User Johnson Ma # Date 1270781188 -28800 # Node ID 8bb370ba6d1d1e84114b848b712441876b679ec1 # Parent bbd31066657eb1d45daf79b4cb25acf55c3ac7d2 contribute STF 1.0.0 diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/group/ReleaseNote.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/group/ReleaseNote.txt Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,12 @@ +======================================================================== +RELEASE NOTE FOR STIF API PLATFORM - STIF_200946 (7.3.20) +SUPPORTING SERIES 60 3.0 -> +======================================================================== + +Product Description: +==================== +STIF API PLATFORM is a part of STIF project. + + +Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +All rights reserved. diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/group/bld.inf Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Build information for STIF API. +* +*/ + +#include + + +PRJ_EXPORTS +../inc/UIStoreIf.h OS_LAYER_PLATFORM_EXPORT_PATH(stifinternal/UIStoreIf.h) +../inc/UIStoreContainer.h OS_LAYER_PLATFORM_EXPORT_PATH(stifinternal/UIStoreContainer.h) +../inc/UIStore.h OS_LAYER_PLATFORM_EXPORT_PATH(stifinternal/UIStore.h) +../inc/UIEngineContainer.h OS_LAYER_PLATFORM_EXPORT_PATH(stifinternal/UIEngineContainer.h) +../inc/UIEngine.h OS_LAYER_PLATFORM_EXPORT_PATH(stifinternal/UIEngine.h) +../inc/RRefArray.h OS_LAYER_PLATFORM_EXPORT_PATH(stifinternal/RRefArray.h) +// ------- files for uitestserverstarter ------- +../inc/TestServerClient.h OS_LAYER_PLATFORM_EXPORT_PATH(stifinternal/TestServerClient.h) +../inc/UiEnvProxy.h OS_LAYER_PLATFORM_EXPORT_PATH(stifinternal/UiEnvProxy.h) +../inc/TestThreadContainerRunnerFactory.h OS_LAYER_PLATFORM_EXPORT_PATH(stifinternal/TestThreadContainerRunnerFactory.h) +// ------- other files ------- +../inc/atslogger.h OS_LAYER_PLATFORM_EXPORT_PATH(atslogger.h) +../inc/StifKernelTestClassBase.h OS_LAYER_PLATFORM_EXPORT_PATH(StifKernelTestClassBase.h) +../inc/StifTFwIf.h OS_LAYER_PLATFORM_EXPORT_PATH(StifTFwIf.h) +../inc/STFLogger.h OS_LAYER_PLATFORM_EXPORT_PATH(STFLogger.h) +../inc/StifLogger.h OS_LAYER_PLATFORM_EXPORT_PATH(StifLogger.h) +../inc/StifParser.h OS_LAYER_PLATFORM_EXPORT_PATH(StifParser.h) +../inc/StifSectionParser.h OS_LAYER_PLATFORM_EXPORT_PATH(StifSectionParser.h) +../inc/StifItemParser.h OS_LAYER_PLATFORM_EXPORT_PATH(StifItemParser.h) +../inc/StifTestInterface.h OS_LAYER_PLATFORM_EXPORT_PATH(StifTestInterface.h) +../inc/StifTestModule.h OS_LAYER_PLATFORM_EXPORT_PATH(StifTestModule.h) +../inc/StifTestEventInterface.h OS_LAYER_PLATFORM_EXPORT_PATH(StifTestEventInterface.h) +../inc/TestScripterInternal.h OS_LAYER_PLATFORM_EXPORT_PATH(TestScripterInternal.h) +../inc/StifHWReset.h OS_LAYER_PLATFORM_EXPORT_PATH(StifHWReset.h) +../inc/StifTestInterference.h OS_LAYER_PLATFORM_EXPORT_PATH(StifTestInterference.h) +../inc/StifCommand.h OS_LAYER_PLATFORM_EXPORT_PATH(StifCommand.h) +../inc/SettingServerClient.h OS_LAYER_PLATFORM_EXPORT_PATH(SettingServerClient.h) +../inc/TestEngineClient.h OS_LAYER_PLATFORM_EXPORT_PATH(TestEngineClient.h) +../inc/TestEngineClient.inl OS_LAYER_PLATFORM_EXPORT_PATH(TestEngineClient.inl) +../inc/StifTFwIfProt.h OS_LAYER_PLATFORM_EXPORT_PATH(StifTFwIfProt.h) +../inc/NormalHardcodedAssert.h OS_LAYER_PLATFORM_EXPORT_PATH(NormalHardcodedAssert.h) +../inc/TestclassAssert.h OS_LAYER_PLATFORM_EXPORT_PATH(TestclassAssert.h) +../inc/StifUnitUtils.inl OS_LAYER_PLATFORM_EXPORT_PATH(StifUnitUtils.inl) +../inc/StifUnitMacros.h OS_LAYER_PLATFORM_EXPORT_PATH(StifUnitMacros.h) +../inc/StifUnitGeneric.h OS_LAYER_PLATFORM_EXPORT_PATH(StifUnitGeneric.h) diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/inc/NormalHardcodedAssert.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/inc/NormalHardcodedAssert.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,380 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the STIF +* normal and hardcoded modules assert macros. +* +*/ + + +#ifndef NormalHardcodedAssert_MACROS_H +#define NormalHardcodedAssert_MACROS_H + +_LIT( KAssertFailedEquals, "AssertEquals Failed [F:%s][L:%d]" ); +_LIT( KAssertFailedNotEquals, "AssertNotEquals Failed [F:%s][L:%d]" ); +_LIT( KAssertFailedNull, "AssertNull Failed [F:%s][L:%d]" ); +_LIT( KAssertFailedNotNull, "AssertNotNull Failed [F:%s][L:%d]" ); +_LIT( KAssertFailedSame, "AssertSame Failed [F:%s][L:%d]" ); +_LIT( KAssertFailedNotSame, "AssertNotSame Failed [F:%s][L:%d]" ); +_LIT( KAssertFailedTrue, "AssertTrue Failed [F:%s][L:%d]" ); +_LIT( KAssertFailedFalse, "AssertFalse Failed [F:%s][L:%d]" ); +_LIT( KAssertFailedNotLeaves, "AssertNotLeaves Failed [F:%s][L:%d]" ); +_LIT( KAssertFailedLeaves, "AssertLeaves Failed [F:%s][L:%d]" ); +_LIT( KAssertFailedLeavesWith, "AssertLeavesWith Failed [F:%s][L:%d]" ); + + +#ifdef _UNICODE + #define __STIF_WIDEN2(x) L ## x + #define __STIF_WIDEN(x) __STIF_WIDEN2(x) + #define __STIF_DBG_FILE__ __STIF_WIDEN(__FILE__) +#else + #define __STIF_DBG_FILE__ __FILE__ +#endif + +#ifdef _UNICODE + #define __STF_WIDEN2(x) L ## x + #define __STF_WIDEN(x) __STF_WIDEN2(x) + #define __STF_DBG_FILE__ __STF_WIDEN(__FILE__) +#else + #define __STF_DBG_FILE__ __FILE__ +#endif + +// Logs to the STIF log file AND to the RDebug +#define STIF_LOG( aMessage ) \ + iLog->Log( _L( aMessage ) ); RDebug::Print( _L( aMessage ) ); + +// Logs to the STF log file AND to the RDebug +#define STF_LOG( aMessage ) \ + iLog->Log( _L( aMessage ) ); RDebug::Print( _L( aMessage ) ); + +/********************************************************************************* + * STF Assert Macros + *********************************************************************************/ +#define __STF_ASSERT_SHARED( aFunction, aMessage ) \ + if(!aFunction) \ + { \ + iLog->Log( aMessage, __STF_DBG_FILE__, __LINE__ );\ + aResult.SetResult( KErrGeneral, _L("Testcase failed"));\ + return KErrNone;\ + } + +#define __STF_ASSERT_SHARED_DESC( aFunction, aMessage, aDesc ) \ + if(!aFunction) \ + { \ + iLog->Log( aMessage, __STF_DBG_FILE__, __LINE__ );\ + aResult.SetResult( KErrGeneral, aDesc );\ + return KErrNone;\ + } \ + else \ + { \ + aResult.SetResult( KErrNone, aDesc ); \ + } + + + +#define STF_ASSERT_EQUALS( aExpected, aActual ) \ + __STF_ASSERT_SHARED( AssertEquals( aExpected, aActual ) , KAssertFailedEquals ); + +#define STF_ASSERT_EQUALS_DESC( aExpected, aActual, aDescription ) \ + __STF_ASSERT_SHARED_DESC( AssertEquals( aExpected, aActual ) , KAssertFailedEquals, aDescription ); + +#define STF_ASSERT_NOT_EQUALS( aExpected, aActual ) \ + __STF_ASSERT_SHARED( !AssertEquals( aExpected, aActual ) , KAssertFailedNotEquals ); + +#define STF_ASSERT_NOT_EQUALS_DESC( aExpected, aActual, aDescription ) \ + __STF_ASSERT_SHARED_DESC( !AssertEquals( aExpected, aActual ) , KAssertFailedNotEquals, aDescription ); + +#define STF_ASSERT_NULL( aPtr ) \ + __STF_ASSERT_SHARED( AssertNull( aPtr ), KAssertFailedNull ); + +#define STF_ASSERT_NULL_DESC( aPtr, aDescription ) \ + __STF_ASSERT_SHARED_DESC( AssertNull( aPtr ), KAssertFailedNull, aDescription ); + +#define STF_ASSERT_NOT_NULL( aPtr ) \ + __STF_ASSERT_SHARED( !AssertNull( aPtr ), KAssertFailedNotNull ); + +#define STF_ASSERT_NOT_NULL_DESC( aPtr, aDescription ) \ + __STF_ASSERT_SHARED_DESC( !AssertNull( aPtr ), KAssertFailedNotNull, aDescription ); + +#define STF_ASSERT_SAME( aExpectedPtr, aActualPtr ) \ + __STF_ASSERT_SHARED( AssertSame( aExpectedPtr, aActualPtr ), KAssertFailedSame ); + +#define STF_ASSERT_SAME_DESC( aExpectedPtr, aActualPtr, aDescription ) \ + __STF_ASSERT_SHARED_DESC( AssertSame( aExpectedPtr, aActualPtr ), KAssertFailedSame, aDescription ); + +#define STF_ASSERT_NOT_SAME( aExpectedPtr, aActualPtr) \ + __STF_ASSERT_SHARED( !AssertSame( aExpectedPtr, aActualPtr ), KAssertFailedNotSame ); + +#define STF_ASSERT_NOT_SAME_DESC( aExpectedPtr, aActualPtr, aDescription ) \ + __STF_ASSERT_SHARED_DESC( !AssertSame( aExpectedPtr, aActualPtr ), KAssertFailedNotSame, aDescription ); + +#define STF_ASSERT_TRUE( aCondition ) \ + __STF_ASSERT_SHARED( AssertTrue( aCondition ), KAssertFailedTrue ); + +#define STF_ASSERT_TRUE_DESC( aCondition, aDescription ) \ + __STF_ASSERT_SHARED_DESC( AssertTrue( aCondition ), KAssertFailedTrue, aDescription ); + +#define STF_ASSERT_FALSE( aCondition ) \ + __STF_ASSERT_SHARED( !AssertTrue( aCondition ), KAssertFailedFalse ); + +#define STF_ASSERT_FALSE_DESC( aCondition, aDescription ) \ + __STF_ASSERT_SHARED_DESC( !AssertTrue( aCondition), KAssertFailedFalse, aDescription ); + +// Eclosing block is used to create the scope for the __leaveValue +#define STF_ASSERT_NOT_LEAVES( aStatement ) \ + { \ + TRAPD( __leaveValue, aStatement ); \ + __STF_ASSERT_SHARED( AssertEquals( __leaveValue, KErrNone ), KAssertFailedNotLeaves ); \ + } + +#define STF_ASSERT_NOT_LEAVES_DESC( aStatement, aDescription ) \ + { \ + TRAPD( __leaveValue, aStatement ); \ + __STF_ASSERT_SHARED_DESC( AssertEquals( __leaveValue, KErrNone ), KAssertFailedNotLeaves, aDescription ); \ + } + +// Eclosing block is used to create the scope for the __leaveValue +#define STF_ASSERT_LEAVES( aStatement ) \ + { \ + TRAPD( __leaveValue, aStatement ); \ + __STF_ASSERT_SHARED( !AssertEquals( __leaveValue, KErrNone ), KAssertFailedLeaves ); \ + } + +#define STF_ASSERT_LEAVES_DESC( aStatement, aDescription ) \ + { \ + TRAPD( __leaveValue, aStatement ); \ + __STF_ASSERT_SHARED_DESC( !AssertEquals( __leaveValue, KErrNone ), KAssertFailedLeaves, aDescription ); \ + } + +// Eclosing block is used to create the scope for the __leaveValue +#define STF_ASSERT_LEAVES_WITH( aLeaveCode, aStatement ) \ + { \ + TRAPD( __leaveValue, aStatement ); \ + __STF_ASSERT_SHARED( AssertEquals( __leaveValue, aLeaveCode ), KAssertFailedLeaves ); \ + } + +#define STF_ASSERT_LEAVES_WITH_DESC( aLeaveCode, aStatement, aDescription ) \ + { \ + TRAPD( __leaveValue, aStatement ); \ + __STF_ASSERT_SHARED_DESC( AssertEquals( __leaveValue, aLeaveCode ), KAssertFailedLeaves, aDescription ); \ + } + +#define STF_ASSERT_PANIC( aPanicCode, aStatement ) \ + { \ + TestModuleIf().SetExitReason( CTestModuleIf::EPanic, aPanicCode ); \ + aStatement; \ + } + +#define STF_ASSERT_PANIC_DESC( aPanicCode, aStatement, aDescription ) \ + { \ + TestModuleIf().SetExitReason( CTestModuleIf::EPanic, aPanicCode ); \ + aResult.SetResult(KErrNone, aDescription); \ + aStatement; \ + } + + +/********************************************************************************* + * STIF Assert Macros + *********************************************************************************/ +#define __STIF_ASSERT_SHARED( aFunction, aMessage ) \ + if(!aFunction) \ + { \ + iLog->Log( aMessage, __STIF_DBG_FILE__, __LINE__ );\ + aResult.SetResult( KErrGeneral, _L("Testcase failed"));\ + return KErrNone;\ + } + +#define __STIF_ASSERT_SHARED_DESC( aFunction, aMessage, aDesc ) \ + if(!aFunction) \ + { \ + iLog->Log( aMessage, __STIF_DBG_FILE__, __LINE__ );\ + aResult.SetResult( KErrGeneral, aDesc );\ + return KErrNone;\ + } \ + else \ + { \ + aResult.SetResult( KErrNone, aDesc ); \ + } + + + +#define STIF_ASSERT_EQUALS( aExpected, aActual ) \ + __STIF_ASSERT_SHARED( AssertEquals( aExpected, aActual ) , KAssertFailedEquals ); + +#define STIF_ASSERT_EQUALS_DESC( aExpected, aActual, aDescription ) \ + __STIF_ASSERT_SHARED_DESC( AssertEquals( aExpected, aActual ) , KAssertFailedEquals, aDescription ); + +#define STIF_ASSERT_NOT_EQUALS( aExpected, aActual ) \ + __STIF_ASSERT_SHARED( !AssertEquals( aExpected, aActual ) , KAssertFailedNotEquals ); + +#define STIF_ASSERT_NOT_EQUALS_DESC( aExpected, aActual, aDescription ) \ + __STIF_ASSERT_SHARED_DESC( !AssertEquals( aExpected, aActual ) , KAssertFailedNotEquals, aDescription ); + +#define STIF_ASSERT_NULL( aPtr ) \ + __STIF_ASSERT_SHARED( AssertNull( aPtr ), KAssertFailedNull ); + +#define STIF_ASSERT_NULL_DESC( aPtr, aDescription ) \ + __STIF_ASSERT_SHARED_DESC( AssertNull( aPtr ), KAssertFailedNull, aDescription ); + +#define STIF_ASSERT_NOT_NULL( aPtr ) \ + __STIF_ASSERT_SHARED( !AssertNull( aPtr ), KAssertFailedNotNull ); + +#define STIF_ASSERT_NOT_NULL_DESC( aPtr, aDescription ) \ + __STIF_ASSERT_SHARED_DESC( !AssertNull( aPtr ), KAssertFailedNotNull, aDescription ); + +#define STIF_ASSERT_SAME( aExpectedPtr, aActualPtr ) \ + __STIF_ASSERT_SHARED( AssertSame( aExpectedPtr, aActualPtr ), KAssertFailedSame ); + +#define STIF_ASSERT_SAME_DESC( aExpectedPtr, aActualPtr, aDescription ) \ + __STIF_ASSERT_SHARED_DESC( AssertSame( aExpectedPtr, aActualPtr ), KAssertFailedSame, aDescription ); + +#define STIF_ASSERT_NOT_SAME( aExpectedPtr, aActualPtr) \ + __STIF_ASSERT_SHARED( !AssertSame( aExpectedPtr, aActualPtr ), KAssertFailedNotSame ); + +#define STIF_ASSERT_NOT_SAME_DESC( aExpectedPtr, aActualPtr, aDescription ) \ + __STIF_ASSERT_SHARED_DESC( !AssertSame( aExpectedPtr, aActualPtr ), KAssertFailedNotSame, aDescription ); + +#define STIF_ASSERT_TRUE( aCondition ) \ + __STIF_ASSERT_SHARED( AssertTrue( aCondition ), KAssertFailedTrue ); + +#define STIF_ASSERT_TRUE_DESC( aCondition, aDescription ) \ + __STIF_ASSERT_SHARED_DESC( AssertTrue( aCondition ), KAssertFailedTrue, aDescription ); + +#define STIF_ASSERT_FALSE( aCondition ) \ + __STIF_ASSERT_SHARED( !AssertTrue( aCondition ), KAssertFailedFalse ); + +#define STIF_ASSERT_FALSE_DESC( aCondition, aDescription ) \ + __STIF_ASSERT_SHARED_DESC( !AssertTrue( aCondition), KAssertFailedFalse, aDescription ); + +// Eclosing block is used to create the scope for the __leaveValue +#define STIF_ASSERT_NOT_LEAVES( aStatement ) \ + { \ + TRAPD( __leaveValue, aStatement ); \ + __STIF_ASSERT_SHARED( AssertEquals( __leaveValue, KErrNone ), KAssertFailedNotLeaves ); \ + } + +#define STIF_ASSERT_NOT_LEAVES_DESC( aStatement, aDescription ) \ + { \ + TRAPD( __leaveValue, aStatement ); \ + __STIF_ASSERT_SHARED_DESC( AssertEquals( __leaveValue, KErrNone ), KAssertFailedNotLeaves, aDescription ); \ + } + +// Eclosing block is used to create the scope for the __leaveValue +#define STIF_ASSERT_LEAVES( aStatement ) \ + { \ + TRAPD( __leaveValue, aStatement ); \ + __STIF_ASSERT_SHARED( !AssertEquals( __leaveValue, KErrNone ), KAssertFailedLeaves ); \ + } + +#define STIF_ASSERT_LEAVES_DESC( aStatement, aDescription ) \ + { \ + TRAPD( __leaveValue, aStatement ); \ + __STIF_ASSERT_SHARED_DESC( !AssertEquals( __leaveValue, KErrNone ), KAssertFailedLeaves, aDescription ); \ + } + +// Eclosing block is used to create the scope for the __leaveValue +#define STIF_ASSERT_LEAVES_WITH( aLeaveCode, aStatement ) \ + { \ + TRAPD( __leaveValue, aStatement ); \ + __STIF_ASSERT_SHARED( AssertEquals( __leaveValue, aLeaveCode ), KAssertFailedLeaves ); \ + } + +#define STIF_ASSERT_LEAVES_WITH_DESC( aLeaveCode, aStatement, aDescription ) \ + { \ + TRAPD( __leaveValue, aStatement ); \ + __STIF_ASSERT_SHARED_DESC( AssertEquals( __leaveValue, aLeaveCode ), KAssertFailedLeaves, aDescription ); \ + } + +#define STIF_ASSERT_PANIC( aPanicCode, aStatement ) \ + { \ + TestModuleIf().SetExitReason( CTestModuleIf::EPanic, aPanicCode ); \ + aStatement; \ + } + +#define STIF_ASSERT_PANIC_DESC( aPanicCode, aStatement, aDescription ) \ + { \ + TestModuleIf().SetExitReason( CTestModuleIf::EPanic, aPanicCode ); \ + aResult.SetResult(KErrNone, aDescription); \ + aStatement; \ + } + +template +inline TBool AssertEquals(const T& aExpected, const T& aActual) +/** + * AssertEquals + * + * + * @param aExpected - Expected result + * @param aActual - Actual result + * @return - True if equal + */ + { + if( aExpected==aActual ) + { + return ETrue; + } + return EFalse; + } + +template +inline TBool AssertNull(const T* aPtr) +/** + * AssertNull + * + * + * @param aPtr - Pointer + * @return - True if NULL + */ + { + if( aPtr==NULL ) + { + return ETrue; + } + return EFalse; + } + +template +inline TBool AssertSame(const T* aExpectedPtr, const T* aActualPtr) +/** + * AssertSame + * + * + * @param aExpectedPtr - Expected pointer + * @param aActualPtr - Actual pointer + * @return - True if equal + */ + { + if( aExpectedPtr==aActualPtr ) + { + return ETrue; + } + return EFalse; + } + +inline TBool AssertTrue(const TBool& aCondition) +/** + * AssertTrue + * + * + * @param aCondition - Condition + * @return - True if aCondition is true + */ + { + if( !aCondition ) + { + return EFalse; + } + return ETrue; + } + +#endif diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/inc/RRefArray.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/inc/RRefArray.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the STIF util +* class RRefArray. +* +*/ + +#ifndef RREFARRAY_H +#define RREFARRAY_H + +// INCLUDES +#include + +// CLASS DECLARATION +/** +* Array class for references. +*/ +template +class RRefArray + :public RPointerArrayBase + { + public: + inline RRefArray():RPointerArrayBase(){}; + inline void Close(){ RPointerArrayBase::Close(); }; + inline TInt Count() const{ return RPointerArrayBase::Count(); }; + inline T const& operator[](TInt anIndex) const + { return *( ( T* ) At(anIndex)); }; + inline T& operator[](TInt anIndex) + { return *( ( T* ) At(anIndex)); }; + inline TInt Append( T const& anEntry ) + { return RPointerArrayBase::Append(( TAny*) &anEntry); }; + inline TInt Insert( T const& anEntry, TInt aPos ) + { return RPointerArrayBase::Insert(( TAny*) &anEntry, aPos ); }; + inline void Remove( TInt anIndex ) + { RPointerArrayBase::Remove( anIndex ); }; + inline void Reset(){ RPointerArrayBase::Reset(); }; + private: + RArray iArray; + }; + + +#endif // RREFARRAY_H + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/inc/STFLogger.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/inc/STFLogger.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,233 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +* +*/ + +// This file defines the API for STFLogger.dll + +#ifndef __STFLOGGER_H__ +#define __STFLOGGER_H__ + +// Include Files + +#include // CBase +#include // TBuf +#include +#include + + +#define __DECLARE_LOG RSTFLogger stf_Logger; +#define __OPENLOGL(D, L) User::LeaveIfError(stf_Logger.Connect()); \ + TParse p; \ + _LIT(KLogFile, L); \ + p.Set(KLogFile(), NULL, NULL); \ + _LIT(KLogDir, D); \ + stf_Logger.CreateL(KLogDir(), p.NameAndExt()); +#define __CLOSELOG stf_Logger.Close(); +extern RSTFLogger stf_Logger; + +//These type of log should be used as: __LOG(_L("test")); +#define __LOG(C) stf_Logger.Log(C); +#define __LOG1(C, Z) stf_Logger.Log(C, Z); +#define __LOG2(C, Z, Y) stf_Logger.Log(C, Z, Y); +#define __LOG3(C, Z, Y, X) stf_Logger.Log(C, Z, Y, X); +#define __LOG4(C, Z, Y, X, W) stf_Logger.Log(C, Z, Y, X, W); +#define __LOG5(C, Z, Y, X, W, V) stf_Logger.Log(C, Z, Y, X, W, V); +#define __LOG6(C, Z, Y, X, W, V, U) stf_Logger.Log(C, Z, Y, X, W, V, U); + + + + +class RSTFLogger : public RSessionBase + { +public: + + // new functions + IMPORT_C TInt Connect(); + +public: // new functions, example API + + IMPORT_C TInt CreateL( const TDesC& aTestPath, + const TDesC& aTestFile, + // Default logger type is .txt + CStifLogger::TLoggerType aLoggerType = CStifLogger::ETxt, + // By default output is file + CStifLogger::TOutput aOutput = CStifLogger::EFile, + // By default overwrite is used + TBool aOverWrite = ETrue, + // By default time stamp is used + TBool aWithTimeStamp = ETrue, + // By default line break is used + TBool aWithLineBreak = ETrue, + // By default even ranking is not + // used + TBool aWithEventRanking = EFalse, + // By default thread id is added + // after the log file + TBool aThreadIdToLogFile = ETrue, + // By default log directory will + // not create + TBool aCreateLogDir = EFalse, + // Static logger implementation is + // not yet permanent, may change + TInt aStaticBufferSize = 0, + // By default files are not written + // in unicode format + TBool aUnicode = EFalse ); + + IMPORT_C TInt CreateL( const TDesC& aTestPath, + const TDesC& aTestFile, + TLoggerSettings& aLoggerSettings ); + + /** + * Log a 16 bit information to some storage e.g. text file. + */ + IMPORT_C TInt Log( const TDesC& aLogInfo ); + + /** + * Log a 8 bit information to some storage e.g. text file. + */ + IMPORT_C TInt Log( const TDesC8& aLogInfo ); + + /** + * Log a 16 bit information to some storage e.g. text file. There is + * also parameter to styling text information e.g. text color. + */ + IMPORT_C TInt Log( TInt aStyle, const TDesC& aLogInfo ); + + /** + * Log a 8 bit information to some storage e.g. text file. There is + * also parameter to styling text information e.g. text color. + */ + IMPORT_C TInt Log( TInt aStyle, const TDesC8& aLogInfo ); + + /** + * Log a 16 bit information to some storage e.g. text file. In this log + * method may set several parameters. + */ + IMPORT_C TInt Log( TRefByValue aLogInfo,... ); + + /** + * Log a 8 bit information to some storage e.g. text file. In this log + * method may set several parameters. + */ + IMPORT_C TInt Log( TRefByValue aLogInfo,... ); + + /** + * Log a 16 bit information to some storage e.g. text file. There is + * also parameter to styling text information e.g. text color. + */ + IMPORT_C TInt Log( TInt aStyle, + TRefByValue aLogInfo,... ); + + /** + * Log a 8 bit information to some storage e.g. text file. There is + * also parameter to styling text information e.g. text color. + */ + IMPORT_C TInt Log( TInt aStyle, + TRefByValue aLogInfo,... ); + + /** + * Log a 16 bit delimiter. Default char is '#' and default + * repeat count is 60. + * This will be used if parameters are not given when calling + * this method. + */ + IMPORT_C TInt WriteDelimiter( const TDesC& aDelimiter = _L( "#"), + TInt aCount = 60 ); + + /** + * Log a 8 bit delimiter. 8 bit delimiter includes no default values. + * Delimiter may be '#' or 'XO' etc. + */ + IMPORT_C TInt WriteDelimiter( const TDesC8& aDelimiter, TInt aCount ); + + /** + * Used when is need to save file or data to storage e.g. web page. + * 16 bit. + */ + IMPORT_C TInt SaveData(const TDesC& aData ); + + /** + * Used when is need to save file or data to storage e.g. web page. + * 8 bit. + */ + IMPORT_C TInt SaveData(const TDesC8& aData ); + + /** + * Get creation result. + */ + IMPORT_C TInt CreationResult(TInt& aResult); + + /** + * Get output type. Valid only if CreationResult returns KErrNone. + */ + IMPORT_C TInt OutputType(CStifLogger::TOutput& aOutputType); + + /** + * Log 16 bit _LIT information to some storage e.g. text file. + */ + template TInt Log( const TLitC& aLogInfo ) + { + return Log( CStifLogger::ENoStyle, (TDesC&)aLogInfo ); + }; + + /** + * Log 8 bit _LIT information to some storage e.g. text file. + */ + template TInt Log( const TLitC8& aLogInfo ) + { + return Log( CStifLogger::ENoStyle, (TDesC8&)aLogInfo ); + }; + + /** + * Log 16 bit _LIT information to some storage e.g. text file. There is + * also parameter to styling text information e.g. text color. + */ + template TInt Log( TInt aStyle, const TLitC& aLogInfo ) + { + return Log( aStyle, (TDesC&)aLogInfo ); + }; + + /** + * Log 8 bit _LIT information to some storage e.g. text file. There is + * also parameter to styling text information e.g. text color. + */ + template TInt Log( TInt aStyle, const TLitC8& aLogInfo ) + { + return Log( aStyle, (TDesC8&)aLogInfo ); + }; + +private: + void OverwriteLoggerSettings( TLoggerSettings& aLoggerSettings, + TName& aTestPath, + TName& aTestFile, + CStifLogger::TLoggerType& aLoggerType, + CStifLogger::TOutput& aOutput, + TBool& aOverWrite, + TBool& aWithTimeStamp, + TBool& aWithLineBreak, + TBool& aWithEventRanking, + TBool& aThreadIdToLogFile, + TBool& aCreateLogDir, + TBool& aUnicode ); + + }; + + + +#endif // __STFLOGGER_H__ + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/inc/SettingServerClient.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/inc/SettingServerClient.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,134 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the +* RSettingServer +* +*/ + +#ifndef SETTING_SERVER_CLIENT_H +#define SETTING_SERVER_CLIENT_H + +// INCLUDES +#include +#include + +#include + +// CONSTANTS + +// FUNCTION PROTOTYPES + +// FORWARD DECLARATIONS + +// CLASS DECLARATION + +// DESCRIPTION +// RSettingServer is a client class of Setting server +// The connect function starts the server, if it not already running. + +class RSettingServer + :public RSessionBase + { + public: // Enumerations + // None + + private: // Enumerations + // None + + public: // Constructors and destructor + + /** + * Constructor. + */ + IMPORT_C RSettingServer(); + + /** + * Closes the RSettingServer session. + */ + IMPORT_C void Close(); + + public: // New functions + + /** + * Connect method creates new RSettingServer session + */ + IMPORT_C TInt Connect(); + + /** + * Version returns the client side version number from the RSettingServer. + */ + IMPORT_C TVersion Version() const; + + /** + * Read Logger setting from initialization file. Mainly use from + * TestEngine side. + */ + IMPORT_C TInt LoadLoggerSettingsFromIniFile( + TLoggerSettings& aLoggerSettings, + const TDesC& aIniFile, + TBool aOverwritePreviousSettings = ETrue ); + + /** + * Get Logger settings. Mainly use from Logger side. + */ + IMPORT_C TInt GetLoggerSettings( TLoggerSettings& aLoggerSettings ); + + /** + * Set new initialization file setting(e.g. SetAttribute). + */ + IMPORT_C TInt SetLoggerOutputPath( const TDesC& aLoggerOutputPath ); + + IMPORT_C TInt ResetLoggerSettings(); + + /** + * Read Logger setting from command line. Mainly use from + * TestEngine side. + */ + IMPORT_C TInt LoadLoggerSettingsFromCommandLine(TDesC& aLoggerSettings); + + public: // Functions from base classes + // None + + protected: // New functions + // None + + protected: // Functions from base classes + // None + + private: // Functions from base classes + // None + + public: // Data + // None + + protected: // Data + // None + + private: // Data + // None + + public: // Friend classes + // None + + protected: // Friend classes + // None + + private: // Friend classes + // None + + }; + +#endif // SETTING_SERVER_CLIENT_H + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/inc/StifCommand.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/inc/StifCommand.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,84 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the type definitions used by +* command feature (i.e. StopExecution). +* +*/ + +#ifndef STIF_COMMAND_H +#define STIF_COMMAND_H + + +// INCLUDES +#include + +// CONSTANTS +const TInt KMaxCommandParamsLength = 50; // DEPRECATED use KMaxCommandParamsLength2 instead +const TInt KMaxCommandParamsLength2 = 600; + +// MACROS + +// FUNCTION PROTOTYPES + +// DATA TYPES + +// This enum type lists all possible commands sent from test case to test engine +enum TCommand + { + EStopExecution, + ESendTestModuleVersion, + }; + +typedef TPckg TCommandPckg; + +// This enum type lists all possible ways of how to run StopExecution command +enum TStopExecutionType + { + EOk, +#ifndef __TEF_EXPORT_CONST_H__ + //EFail & EAbort are overlaped with enum in tefexportconst.h + //TEFTestModule.dll migrates TEF into STIF module, If build TEFTestModule.dll, EFail and EAbort definition will be deleted from STIF. + EFail, + EAbort, +#endif + }; + +// FUNCTION PROTOTYPES + +// FORWARD DECLARATIONS + +// CLASS DECLARATION +struct TStopExecutionCommandParams + { + TInt iTestCaseHandle; + TStopExecutionType iType; + TInt iCode; + }; + +typedef TPckg TStopExecutionCommandParamsPckg; + + +struct TSendTestModuleVesionCommandParams + { + TFileName iTestModuleName; + TInt iMajor; + TInt iMinor; + TInt iBuild; + }; + +typedef TPckg TSendTestModuleVesionCommandParamsPckg; + +#endif //STIF_COMMAND_H + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/inc/StifHWReset.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/inc/StifHWReset.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,117 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of CStifHWReset +* of STIF TestFramework. +* +*/ + +#ifndef STIFHWRESET_H +#define STIFHWRESET_H + +// INCLUDES +#include +#include + +#include "StifTestModule.h" + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION + +// DESCRIPTION +// This is class which can be inherited from own code to perform a +// reset to the system. +// This is used when calling dynamic loaded dll from STIF TestFramework. +class CStifHWReset + :public CBase + { + public: // Enumerations + + // Different reset types. Possibility to do different king of reset. +/* enum TResetType + { + EResetType0, + EResetType1, + EResetType2, + EResetType3, + EResetType4, + EResetType5 + }; +*/ + public: // Enumerations + // None + + private: // Enumerations + // None + + public: // Constructors and destructor + // None + + public: // New functions + + /** + * Defines reset type and forwards information to reset module. + * This method is pure virtual and it is mandatory to implement it + * to specific reset module. + */ + virtual TInt DoReset( CTestModuleIf::TRebootType aResetType ) = 0; + + public: // Functions from base classes + // None + + protected: // New functions + // None + + protected: // Functions from base classes + // None + + private: + // None + + public: // Data + // None + + protected: // Data + // None + + private: // Data + // None + + public: // Friend classes + // None + + protected: // Friend classes + // None + + private: // Friend classes + // None + + }; + +#endif // STIFHWRESET_H + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/inc/StifItemParser.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/inc/StifItemParser.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,296 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the +* CStifItemParser. +* +*/ + +#ifndef STIF_ITEM_PARSER_H +#define STIF_ITEM_PARSER_H + +// INCLUDES +#include +#include +#include + +// CONSTANTS +const TInt KMaxTag = 256; // A tag maximum length + +// MACROS +// None + +// DATA TYPES +// None + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION + +// DESCRIPTION +// CStifItemParser is a STIF Test Framework StifParser class. +// Class contains a configuration file parsing operations. + +class CStifItemParser + :public CBase + { + public: // Enumerations + + // Parsing type can be given when parsing string(GetString and + // GetNextString). This enumeration indicates parsing type. + // ENormalParsing: + // - Indicates normal parsing without any modifications to + // parsed information + // EQuoteStyleParsing: + // - Indicates special parsing. This style of parsing gives to + // quote(" ") characters special meaning. + // - Information between quotes is handled as a one string. Quotes + // not included to information. + enum TParsingType + { + ENormalParsing, // Mode on(Default) + EQuoteStyleParsing, // Mode off + }; + + private: // Enumerations + + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + IMPORT_C static CStifItemParser* NewL( TPtrC aSection, + TInt aStartPos, + TInt aLength ); + + /** + * Destructor. + */ + ~CStifItemParser(); + + public: // New functions + + /** + * Get a string with a tag. + * Returns an error code and a reference to the parsed string. + *If start tag is empty the first string will be parsed and returned. + */ + IMPORT_C TInt GetString( const TDesC& aTag, TPtrC& aString ); + + /** + * Get next string. + * Returns an error code and a reference to the parsed string. + * GetString or GetInt or GetChar must be called before call + * GetNextString method. + */ + IMPORT_C TInt GetNextString( TPtrC& aString ); + + /** + * Get next string with a tag. + * Returns an error code and a reference to the parsed string. + * If start tag is empty the next string will be parsed and returned. + * GetString or GetInt or GetChar must be called before call + * GetNextString method. + */ + IMPORT_C TInt GetNextString( const TDesC& aTag, TPtrC& aString ); + + /** + * Get a integer(TInt) with a tag. + * Returns an error code and a reference to the parsed integer. + * If start tag is empty the first integer will be parsed and returned. + */ + IMPORT_C TInt GetInt( const TDesC& aTag, TInt& aInteger ); + + /** + * Get next integer(TInt). + * Returns an error code and a reference to the parsed integer. + * GetString or GetInt or GetChar must be called before call + * GetNextInt method. + */ + IMPORT_C TInt GetNextInt( TInt& aInteger ); + + /** + * Get next integer(TInt) with a tag. + * Returns an error code and a reference to the parsed integer. + * If start tag is empty the next integer will be parsed and returned. + * GetString or GetInt or GetChar must be called before call + * GetNextInt method. + */ + IMPORT_C TInt GetNextInt( const TDesC& aTag, TInt& aInteger ); + + /** + * Get a integer(TUint) with a tag. + * Returns an error code and a reference to the parsed integer. + * If start tag is empty the first integer will be parsed and returned. + * With TRadix parameter can convert a number into different + * presentation(EBinary, EOctal, EDecimal and EHex). + */ + IMPORT_C TInt GetInt( const TDesC& aTag, + TUint& aInteger, + TRadix aRadix = EDecimal ); + + /** + * Get next integer(TUint). + * Returns an error code and a reference to the parsed integer. + * GetString or GetInt or GetChar must be called before call + * GetNextInt method. + * With TRadix parameter can convert a number into different + * presentation(EBinary, EOctal, EDecimal and EHex). + */ + IMPORT_C TInt GetNextInt( TUint& aInteger, + TRadix aRadix = EDecimal ); + + /** + * Get next integer(TUint) with a tag. + * Returns an error code and a reference to the parsed integer. + * If start tag is empty the next integer will be parsed and returned. + * GetString or GetInt or GetChar must be called before call + * GetNextInt method. + * With TRadix parameter can convert a number into different + * presentation(EBinary, EOctal, EDecimal and EHex). + */ + IMPORT_C TInt GetNextInt( const TDesC& aTag, + TUint& aInteger, + TRadix aRadix = EDecimal ); + + /** + * Get a character with a tag. + * Returns an error code and a reference to the parsed character. + * If start tag is empty the first character will be parsed and + * returned. + */ + IMPORT_C TInt GetChar( const TDesC& aTag, TChar& aCharacter ); + + /** + * Get next character. + * Returns an error code and a reference to the parsed character. + * GetString or GetInt or GetChar must be called before call + * GetNextChar method. + */ + IMPORT_C TInt GetNextChar( TChar& aCharacter ); + + /** + * Get next character with a tag. + * Returns an error code and a reference to the parsed character. + * If start tag is empty the next character will be parsed and returned. + * GetString or GetInt or GetChar must be called before call + * GetNextChar method. + */ + IMPORT_C TInt GetNextChar( const TDesC& aTag, TChar& aCharacter ); + + + /** + * Get remaining strings. + * Returns an error code and a reference to the remainder of the + * parsed line. + * Note: This method does not support the quote(TParsingType) feature, + * only GetString and GetNextString methods include support. + */ + IMPORT_C TInt Remainder( TPtrC& aString ); + + /** + * Parsing type can be given when parsing string(GetString and + * GetNextString). See TParsingType enumeration for more + * inforamtion. + */ + IMPORT_C TInt SetParsingType( CStifItemParser::TParsingType aType ); + + /** + * Get current parsing type. Please see TParsingType enumeration for + * more inforamtion. + */ + IMPORT_C CStifItemParser::TParsingType ParsingType(); + + /** + * Get key-value pair. + * + */ + IMPORT_C TInt GetValueOf(const TDesC& aKey, TDes& aValue); + + public: // Functions from base classes + + protected: // New functions + + protected: // Functions from base classes + + private: + + /** + * C++ default constructor. + */ + CStifItemParser( TPtrC aSection, + TInt aStartPos, + TInt aLength ); + + /** + * By default Symbian OS constructor is private. + */ + void ConstructL(); + + /** + * Generig start and end position parser for given data. + * Returns an error code. + */ + TInt ParseStartAndEndPos( TPtrC aSection, + const TDesC& aStartTag, + TInt& aStartPos, + TInt& aEndPos, + TInt& aLength, + TInt& aExtraEndPos ); + + public: // Data + + protected: // Data + + private: // Data + + /** + * Parsed section with GetItemLineL() or GetNextItemLineL() method. + */ + TPtrC iItemLineSection; + + /** + * Indicates position where start the parsing. + */ + TInt iItemSkipAndMarkPos; + + /** + * Indicator is GetString(), GetInt() or GetChar() called. + */ + TBool iGetMethodsIndicator; + + /** + * Parsing type indicator for GetString and GetNextString use. + */ + CStifItemParser::TParsingType iParsingType; + + public: // Friend classes + + /** + * For testing operations to get length information. + */ + friend class CTestParser; + + protected: // Friend classes + + private: // Friend classes + + }; + +#endif // STIF_ITEM_PARSER_H + +// End of File \ No newline at end of file diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/inc/StifKernelTestClassBase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/inc/StifKernelTestClassBase.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,149 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the STIF +* kernel testclass declaration +* +*/ + +#ifndef STIFKERNELTESTCLASSBASE_H +#define STIFKERNELTESTCLASSBASE_H + +// INCLUDES +#include + + +// CONSTANTS + +// MACROS + + +// In EKA2 kernel only 8bit descriptors are allowed, because of that C++'s +// L makro cannot be used. + +// ENTRY macro is modified and now it stores data as 8bit descriptor. +// In EKA2 kernel TText is 8bit descriptor. + +#define ENTRY(A,B) \ + { (TText*) A, (StifTestFunction) &B } + + +// FUNCTION PROTOTYPES + +// FORWARD DECLARATIONS +class DStifKernelTestClassBase; + +// DATA TYPES +typedef TInt (DStifKernelTestClassBase::* StifTestFunction)( const TDesC& ); + +// CLASS DECLARATION + +/** +* An internal structure containing a test case name and +* the pointer to function doing the test +* +* @lib ?library +* @since ?Series60_version +*/ +class TStifFunctionInfo + { + public: + const TText* iFunctionName; + StifTestFunction iMethod; + }; + +// CLASS DECLARATION + +/** +* DStifKernelTestClassBaseDriver is the device driver factory that will +* instantiate the physical channel, which is the actual +* physical driver. +* +* @lib ?library +* @since ?Series60_version +*/ +class DStifKernelTestClassBaseDriver : public DLogicalDevice + { + + public: + IMPORT_C DStifKernelTestClassBaseDriver( const TDesC& aName ); + IMPORT_C virtual ~DStifKernelTestClassBaseDriver(); + + IMPORT_C virtual TInt Install(); + IMPORT_C virtual void GetCaps(TDes8 &aDes) const; + + virtual TInt Create(DLogicalChannelBase*& aChannel)=0; + + private: + TName iName; + + }; + + +// CLASS DECLARATION + +/** +* DStifKernelTestClassBase is a base class for kernel test class +* for STIF Test Framework TestScripter. +* ?other_description_lines +* +* @lib ?library +* @since ?Series60_version +*/ +class DStifKernelTestClassBase : public DLogicalChannel + { + + public: + IMPORT_C DStifKernelTestClassBase( DLogicalDevice* aDevice ); + IMPORT_C virtual ~DStifKernelTestClassBase(); + + public: + /** + * Runs a script line. Derived class must implement + */ + virtual TInt RunMethodL( const TDesC& aMethod, const TDesC& aParams ) = 0; + + /** + * Called from destructor. Derived class may implement. + */ + virtual void Delete(){}; + + // Processes a message for this logical channel + IMPORT_C virtual void HandleMsg( TMessageBase* aMsg ); + protected: // Derived class uses + + // Internal fuction to run specified method. + IMPORT_C virtual TInt RunInternalL( + const TStifFunctionInfo* const aFunctions, + TInt aCount, + const TDesC& aMethod, + const TDesC& aParams ); + + private: + + // No need to export DoControl in EKA2, because it is called + // from HandleMsg + TInt DoControl( TInt aFunction,TAny* a1,TAny* a2 ); + + // Asynchronous command are not supported + void DoCancel( TInt ){}; + + private: + + DThread* iThread; + + }; + +#endif // STIFKERNELTESTCLASSBASE_H + +// End of File \ No newline at end of file diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/inc/StifLogger.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/inc/StifLogger.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,409 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the +* CStifLogger. +* +*/ + +#ifndef STIFLOGGER_H +#define STIFLOGGER_H + +// INCLUDES +#include +#include // TBuf + + +// If using older STIF TF than STIF200414 there is no this definition. +// If is need to combile e.g. testmodule with older STIF TF there may use +// in the testmodule this flag to indicating which enum definition is used. +// Example: +// #ifdef __NEW_LOGGER_ENUMS_DEFS__ +// logger->Log( CStifLogger::ERed, _L( "Logged text" ) ); +// #else +// logger->Log( ERed, _L( "Logged text" ) ); +// #endif +#define __NEW_LOGGER_ENUMS_DEFS__ + +// Maximum length of the data. Must be over 26 because HTML page initializing. +// Can be only max 254 length because rdebug prints max 256 length text and +// that includes line break(+2 character) +const TInt KMaxLogData = 254; + +// This is for making partitions of the rdebug( minus 3 is for ' ->') +const TInt KMaxRDebug = KMaxLogData - 3; + +// Maximum count of file type plus dot e.g. ".txt" +const TInt KMaxFileType = 10; + +// Maximum length of the date and time logging +// Includes date, time, spaces(5) and end of line(2): +// e.g. "'06.Nov.2003 15:12:18.123 '...logged data...' '" +const TInt KMaxTimeStamp = 30; + +// MACROS +// None + +// DATA TYPES + +// For 16 bit data size definition. +typedef TBuf TLogInfo; + +// For 8 bit data size definition. +typedef TBuf8 TLogInfo8; + +// For file type size definition. +typedef TBuf TFileType; + +// For time stamp size definition. +typedef TBuf8 TStifLoggerTimeStamp; + +// For time stamp size definition. +typedef TBuf TStifLoggerTimeStamp8; + +// FUNCTION PROTOTYPES +// None + + + +// Structs are defined at the end of this file. +struct TOverwritedSettings; +struct TLoggerSettings; + + +// FORWARD DECLARATIONS +class COutput; +class RSTFLogger; + + +// CLASS DECLARATION + +// DESCRIPTION +// CStifLogger is a STIF Test Framework StifLogger class. +// Class contains a file logging operations. + + +class CStifLogger + :public CBase + { + public: // Enumerations + + // Different StifLogger presentations types. + enum TLoggerType + { + ETxt, // txt file logging + EData, // data file logging(e.g. web page downloading ) + EHtml // html file logging + }; + + // Different StifLogger output modules. + enum TOutput + { + EFile, // File logging + ERDebug // RDebug logging + }; + + // Different style forms for text. + enum TStyle + { + ENoStyle = 0x00000, // No style parameter + EBold = 0x00001, // Bold + ECursive = 0x00002, // Cursive + EUnderline = 0x00004, // Underline + EBlue = 0x00008, // Blue + EGreen = 0x00010, // Green + ERed = 0x00020, // Red + EImportant = 0x00040, // Important (Line will starts a 'IMPORTANT' text) + EWarning = 0x00080, // Warning (Line will starts a 'WARNING' text) + EError = 0x00100 // Error (Line will starts a 'ERROR' text) + }; + + private: // Enumerations + + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + IMPORT_C static CStifLogger* NewL( const TDesC& aTestPath, + const TDesC& aTestFile, + // Default logger type is .txt + TLoggerType aLoggerType = ETxt, + // By default output is file + TOutput aOutput = EFile, + // By default overwrite is used + TBool aOverWrite = ETrue, + // By default time stamp is used + TBool aWithTimeStamp = ETrue, + // By default line break is used + TBool aWithLineBreak = ETrue, + // By default even ranking is not + // used + TBool aWithEventRanking = EFalse, + // By default thread id is added + // after the log file + TBool aThreadIdToLogFile = ETrue, + // By default log directory will + // not create + TBool aCreateLogDir = EFalse, + // Static logger implementation is + // not yet permanent, may change + TInt aStaticBufferSize = 0, + // By default files are not written + // in unicode format + TBool aUnicode = EFalse ); + + virtual ~CStifLogger(); + + public: // New functions + + CStifLogger(); + + /** + * Log a 16 bit information to some storage e.g. text file. + */ + IMPORT_C TInt Log( const TDesC& aLogInfo ); + + /** + * Log a 8 bit information to some storage e.g. text file. + */ + IMPORT_C TInt Log( const TDesC8& aLogInfo ); + + /** + * Log a 16 bit information to some storage e.g. text file. There is + * also parameter to styling text information e.g. text color. + */ + IMPORT_C TInt Log( TInt aStyle, const TDesC& aLogInfo ); + + /** + * Log a 8 bit information to some storage e.g. text file. There is + * also parameter to styling text information e.g. text color. + */ + IMPORT_C TInt Log( TInt aStyle, const TDesC8& aLogInfo ); + + /** + * Log a 16 bit information to some storage e.g. text file. In this log + * method may set several parameters. + */ + IMPORT_C TInt Log( TRefByValue aLogInfo,... ); + + /** + * Log a 8 bit information to some storage e.g. text file. In this log + * method may set several parameters. + */ + IMPORT_C TInt Log( TRefByValue aLogInfo,... ); + + /** + * Log a 16 bit information to some storage e.g. text file. There is + * also parameter to styling text information e.g. text color. + */ + IMPORT_C TInt Log( TInt aStyle, + TRefByValue aLogInfo,... ); + + /** + * Log a 8 bit information to some storage e.g. text file. There is + * also parameter to styling text information e.g. text color. + */ + IMPORT_C TInt Log( TInt aStyle, + TRefByValue aLogInfo,... ); + + /** + * Log a 16 bit delimiter. Default char is '#' and default + * repeat count is 60. + * This will be used if parameters are not given when calling + * this method. + */ + IMPORT_C TInt WriteDelimiter( const TDesC& aDelimiter = _L( "#"), + TInt aCount = 60 ); + + /** + * Log a 8 bit delimiter. 8 bit delimiter includes no default values. + * Delimiter may be '#' or 'XO' etc. + */ + IMPORT_C TInt WriteDelimiter( const TDesC8& aDelimiter, TInt aCount ); + + /** + * Used when is need to save file or data to storage e.g. web page. + * 16 bit. + */ + IMPORT_C TInt SaveData( TDesC& aData ); + + /** + * Used when is need to save file or data to storage e.g. web page. + * 8 bit. + */ + IMPORT_C TInt SaveData( TDesC8& aData ); + + /** + * Get creation result. + */ + IMPORT_C TInt CreationResult(); + + /** + * Get output type. Valid only if CreationResult returns KErrNone. + */ + IMPORT_C TOutput OutputType(); + + /** + * Pure virtual. Send style information and data to the output module. + * 16 bit. + */ + virtual TInt Send( TInt /*aStyle*/, const TDesC& /*aData*/ ); + + /** + * Pure virtual. Send style information and data to the output module. + * 8 bit. + */ + virtual TInt Send( TInt /*aStyle*/, const TDesC8& /*aData*/ ); + + /** + * Log 16 bit _LIT information to some storage e.g. text file. + */ + template TInt Log( const TLitC& aLogInfo ) + { + return Send( ENoStyle, (TDesC&)aLogInfo ); + }; + + /** + * Log 8 bit _LIT information to some storage e.g. text file. + */ + template TInt Log( const TLitC8& aLogInfo ) + { + return Send( ENoStyle, (TDesC8&)aLogInfo ); + }; + + /** + * Log 16 bit _LIT information to some storage e.g. text file. There is + * also parameter to styling text information e.g. text color. + */ + template TInt Log( TInt aStyle, const TLitC& aLogInfo ) + { + return Send( aStyle, (TDesC&)aLogInfo ); + }; + + /** + * Log 8 bit _LIT information to some storage e.g. text file. There is + * also parameter to styling text information e.g. text color. + */ + template TInt Log( TInt aStyle, const TLitC8& aLogInfo ) + { + return Send( aStyle, (TDesC8&)aLogInfo ); + }; + + protected: + + IMPORT_C static CStifLogger* NewL( const TDesC& aTestPath, + const TDesC& aTestFile, + TLoggerSettings& aLoggerSettings ); + + protected: + + /** + * Deprecated + */ + static void OverwriteLoggerSettings( TLoggerSettings& aLoggerSettings, + TName& aTestPath, + TName& aTestFile, + TLoggerType& aLoggerType, + TOutput& aOutput, + TBool& aOverWrite, + TBool& aWithTimeStamp, + TBool& aWithLineBreak, + TBool& aWithEventRanking, + TBool& aThreadIdToLogFile, + TBool& aCreateLogDir, + TBool& aUnicode ); + + private: + void ConstructL(const TDesC& aTestPath, + const TDesC& aTestFile, + TLoggerType aLoggerType, + TOutput aOutput, + TBool aOverWrite, + TBool aWithTimeStamp, + TBool aWithLineBreak, + TBool aWithEventRanking, + TBool aThreadIdToLogFile, + TBool aCreateLogDir, + TInt aStaticBufferSize, + TBool aUnicode); + + void ConstructL(const TDesC& aTestPath, + const TDesC& aTestFile, + TLoggerSettings& aLoggerSettings); + + protected: // Data + RSTFLogger* iLogger; + private: // Friend classes + + // TestEngine classes + friend class CTestEngineServer; + friend class CTestReport; + friend class CTestCaseController; + friend class CTestEngine; + + // TestServer classes + friend class CTestModuleContainer; + friend class CTestServer; + friend class CTestThreadContainer; + friend class CTestThreadContainerRunner; + + // UIEngine classes + friend class CUIEngine; + + // SettingServer classes + friend class CSettingServer; + }; + +// Struct to indicate StifLogger's settings overwriting +struct TOverwritedSettings + { + TBool iCreateLogDir; + TBool iPath; + TBool iHwPath; + TBool iFormat; + TBool iHwFormat; + TBool iOutput; + TBool iHwOutput; + TBool iOverwrite; + TBool iTimeStamp; + TBool iLineBreak; + TBool iEventRanking; + TBool iThreadId; + TBool iUnicode; + TBool iAddTestCaseTitle; + }; + +// Struct to StifLogger overwrite settings +struct TLoggerSettings + { + TBool iCreateLogDirectories; + TName iEmulatorPath; + CStifLogger::TLoggerType iEmulatorFormat; + CStifLogger::TOutput iEmulatorOutput; + TName iHardwarePath; + CStifLogger::TLoggerType iHardwareFormat; + CStifLogger::TOutput iHardwareOutput; + TBool iOverwrite; + TBool iTimeStamp; + TBool iLineBreak; + TBool iEventRanking; + TBool iThreadId; + TBool iUnicode; + TBool iAddTestCaseTitle; + TOverwritedSettings iIsDefined; + }; + +#endif // STIFLOGGER_H + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/inc/StifParser.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/inc/StifParser.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,277 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the +* CStifParser. +* +*/ + +#ifndef STIF_PARSER_H +#define STIF_PARSER_H + +// INCLUDES +#include +#include +#include +#include "StifSectionParser.h" +#include "StifItemParser.h" + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +class CStifSectionParser; +class CStifFileParser; + +// CLASS DECLARATION + +// DESCRIPTION +// CStifParser is a STIF Test Framework StifParser class. +// Class contains a configuration file parsing operations. + +class CStifParser + :public CBase + { + public: // Enumerations + + // Indication which type of comments are in use + enum TCommentType + { + ENoComments, // No comments type given, parse all + ECStyleComments, // C-style comments( // and /*...*/ ) are + // removed + }; + + private: // Enumerations + + // Indication which mode of parsing are in use + enum TParsingMode + { + EFileParsing, // Indication for file parsing. + EBufferParsing, // Indication for buffer parsing. + }; + + public: // Constructors and destructor + + /** + * Two-phased constructor. + * Creating parser with path and file information. For default all + * information will be parsed(ENoComments). + */ + IMPORT_C static CStifParser* NewL( const TDesC& aPath, + const TDesC& aConfig, + TCommentType = ENoComments); + + /** + * Two-phased constructor. + * Creating parser with buffer information. For default all + * information will be parsed(ENoComments). + */ + IMPORT_C static CStifParser* NewL( const TDesC& aBuffer, + TCommentType = ENoComments ); + + /** + * Destructor. + */ + IMPORT_C ~CStifParser(); + + public: // New functions + + /** + * Open and read configuration source and parses a required section. + * If start tag is empty the parsing starts beging of the configuration + * file. + * If end tag is empty the parsing goes end of configuration file. + * This method starts always from beginning of configuration file and + * parses first section if aSeeked parameters is not given. + * If configuration file includes several sections with both start and + * end tags so aSeeked parameter seeks the required section. The aSeeked + * parameters indicates section that will be parsed. + */ + IMPORT_C CStifSectionParser* SectionL( const TDesC& aStartTag, + const TDesC& aEndTag, + TInt aSeeked = 1 ); + + /** + * Open and read configuration source and parses a required section. + * If start tag is empty the parsing starts beging of the configuration + * file. + * If end tag is empty the parsing goes end of configuration file. + * This method will parse next section after the earlier section if + * aSeeked parameter is not given. + * If configuration file includes several sections with both start and + * end tags so aSeeked parameter seeks the required section. The aSeeked + * parameters indicates section that will be parsed. + */ + IMPORT_C CStifSectionParser* NextSectionL( const TDesC& aStartTag, + const TDesC& aEndTag, + TInt aSeeked = 1); + + + /** + * Open and read configuration source and parses a required section. + * If start tag is empty the parsing starts beging of the configuration + * file. + * If end tag is empty the parsing goes end of configuration file. + * This method starts always from beginning of configuration file and + * parses first section if aSeeked parameters is not given. + * If configuration file includes several sections with both start and + * end tags so aSeeked parameter seeks the required section. The aSeeked + * parameters indicates section that will be parsed. + */ + IMPORT_C CStifSectionParser* SectionL( const TDesC& aStartTag, + const TDesC& aEndTag, + TInt aSeeked ,TBool aIsHasEndTag); + + /** + * Open and read configuration source and parses a required section. + * If start tag is empty the parsing starts beging of the configuration + * file. + * If end tag is empty the parsing goes end of configuration file. + * This method will parse next section after the earlier section if + * aSeeked parameter is not given. + * If configuration file includes several sections with both start and + * end tags so aSeeked parameter seeks the required section. The aSeeked + * parameters indicates section that will be parsed. + */ + IMPORT_C CStifSectionParser* NextSectionL( const TDesC& aStartTag, + const TDesC& aEndTag, + TInt aSeeked ,TBool aIsHasEndTag ); + + public: // Functions from base classes + + protected: // New functions + + protected: // Functions from base classes + + private: + + /** + * C++ default constructor. + */ + CStifParser( TCommentType aCommentType ); + + /** + * By default Symbian OS constructor is private. + */ + void ConstructL( const TDesC& aPath, + const TDesC& aConfig, + const TDesC& aContent = KNullDesC ); + + /** + * Convert a section without comments. + */ + void ParseCommentsOff( TPtr& aBuf ); + + // + // Handles special marks.( '\/\/', '\/\*' and '*/\/' ). This + // is used when ECStyleComments comment type is used. + // + void HandleSpecialMarks( TPtr& aBuf ); + + /** + * Open and read configuration source and parses a required section. + * If start tag is empty the parsing starts beging of the configuration + * file. + * If end tag is empty the parsing goes end of configuration file. + * This method will parse next section after the earlier section if + * aSeeked parameter is not given. + * If configuration file includes several sections with both start and + * end tags so aSeeked parameter seeks the required section. The aSeeked + * parameters indicates section that will be parsed. + */ + CStifSectionParser *NextSectionMemoryL( const TDesC& aStartTag, + const TDesC& aEndTag, + TInt aSeeked ,TBool aIsHasEndTag=ETrue); + + /** + * Open and read configuration source and parses a required section. + * If start tag is empty the parsing starts beging of the configuration + * file. + * If end tag is empty the parsing goes end of configuration file. + * This method will parse next section after the earlier section if + * aSeeked parameter is not given. + * If configuration file includes several sections with both start and + * end tags so aSeeked parameter seeks the required section. The aSeeked + * parameters indicates section that will be parsed. + */ + CStifSectionParser *NextSectionFileL( const TDesC& aStartTag, + const TDesC& aEndTag, + TInt aSeeked ,TBool aIsHasEndTag=ETrue); + public: // Data + + protected: // Data + + private: // Data + + /** + * For file opening. + */ + RFs iFileServer; + + /** + * For file opening. + */ + RFile iFile; + + /** + * Indicates position where we are currently. + */ + TInt iOffset; + + /** + * Comment type's indication. + */ + TCommentType iCommentType; + + /** + * Indication which mode of parsing are in use. + */ + TParsingMode iParsingMode; + + /** + * For buffer parsing. + */ + HBufC* iBufferTmp; + TPtr iBuffer; + + /** + * Flag indicating if file is unicode. + */ + TBool iIsUnicode; + + /** + * Pointer to file parser. + */ + CStifFileParser* iFileParser; + + public: // Friend classes + + protected: // Friend classes + + private: // Friend classes + + }; + +#endif // STIF_PARSER_H + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/inc/StifSectionParser.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/inc/StifSectionParser.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,286 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the +* CStifSectionParser. +* +*/ + +#ifndef STIF_SECTION_PARSER_H +#define STIF_SECTION_PARSER_H + +// INCLUDES +#include +#include +#include +#include "StifItemParser.h" + +// CONSTANTS +// Indicates is tag included in returned value. +enum TTagToReturnValue + { + ETag, // Return value includes the tag + ENoTag // Return value include no tag + }; + +// MACROS +// None + +// DATA TYPES +// None + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +class CStifItemParser; + +// CLASS DECLARATION + +// DESCRIPTION +// CStifSectionParser is a STIF Test Framework StifParser class. +// Class contains a configuration file parsing operations. + +class CStifSectionParser + :public CBase + { + public: // Enumerations + + private: // Enumerations + + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CStifSectionParser* NewL( const TInt aLength ); + + /** + * Destructor. + */ + ~CStifSectionParser(); + + public: // New functions + + /** + * Parses a line for items parsing with a tag. + * Returns a CStifItemParser object. + * If start tag is empty the parsing starts beging of the section. + * TTagToReturnValue indicates will also the aTag value (if exist) + * include to the returned object(For default the tag will be added). + */ + IMPORT_C CStifItemParser* GetItemLineL( const TDesC& aTag, + TTagToReturnValue aTagIndicator = ETag ); + + /** + * Parses a next line for items parsing. + * Returns a CStifItemParser object. + */ + IMPORT_C CStifItemParser* GetNextItemLineL(); + + /** + * Parses a next line for items parsing with a tag. + * Returns a CStifItemParser object. + * If start tag is empty the parsing starts beging of the section. + * TTagToReturnValue indicates will also the aTag value (if exist) + * include to the returned object(For default the tag will be added). + */ + IMPORT_C CStifItemParser* GetNextItemLineL( const TDesC& aTag, + TTagToReturnValue aTagIndicator = ETag ); + + /** + * Parses a sub sections from the main section with a start and with + * a end tag. + * Returns a CStifSectionParser object. + * If start tag is empty the parsing starts beging of the section. + * If end tag is empty the parsing goes end of section. + * This method will parse next subsection after the earlier subsection + * if aSeeked parameter is not given. + * If configuration file includes several subsections with both start + * and end tags so aSeeked parameter seeks the required subsection. The + * aSeeked parameters indicates subsection that will be parsed. + */ + IMPORT_C CStifSectionParser* SubSectionL( const TDesC& aStartTag, + const TDesC& aEndTag, + TInt aSeeked = 1 ); + + /** + * Parses a next subsections from the main section with a start and with + * a end tag. + * Returns a CStifSectionParser object. + * If start tag is empty the parsing starts beging of the section. + * If end tag is empty the parsing goes end of section. + * This method will parse next subsection after the earlier subsection + * if aSeeked parameter is not given. + * If configuration file includes several subsections with both start + * and end tags so aSeeked parameter seeks the required subsection. The + * aSeeked parameters indicates subsection that will be parsed. + */ + IMPORT_C CStifSectionParser* NextSubSectionL( const TDesC& aStartTag, + const TDesC& aEndTag, + TInt aSeeked = 1 ); + + /** + * Get a line from section with a tag. + * Returns an error code and a reference to the parsed line. + * If start tag is empty the parsing starts beging of the section. + * TTagToReturnValue indicates will also the aTag value(if exist) + * include to the aLine reference(For default the tag will be added). + */ + IMPORT_C TInt GetLine( const TDesC& aTag, TPtrC& aLine, + TTagToReturnValue aTagIndicator = ETag ); + + /** + * Get next line. + * Returns an error code and a reference to the parsed line. + */ + IMPORT_C TInt GetNextLine( TPtrC& aLine ); + + /** + * Get next line with tag. + * Returns an error code and a reference to the parsed line. + * If start tag is empty the parsing starts beging of the section. + * TTagToReturnValue indicates will also the aTag value(if exist) + * include to the aLine reference(For default the tag will be added). + */ + IMPORT_C TInt GetNextLine( const TDesC& aTag, TPtrC& aLine, + TTagToReturnValue aTagIndicator = ETag ); + + /** + * Get current position. + * Returns current parsing position, which + * can be used as parameter for SetPosition afterwards to go back + * to old parsing position. + */ + IMPORT_C TInt GetPosition(); + + /** + * Set position. + * Returns a Symbian OS error code. aPos indicates the position to + * which section parser should go. + * SetPosition can be used to set parsing position, e.g. to rewind + * back to some old position retrieved with GetPosition. + */ + IMPORT_C TInt SetPosition( TInt aPos ); + + /** + * Create a section. + */ + void SetData( TPtr aData, + TInt aStartPos, + TInt aLength ); + + /** + * Returns a current section. + */ + const TPtrC Des(); + + public: // Functions from base classes + + protected: // New functions + + protected: // Functions from base classes + + private: + + /** + * C++ default constructor. + */ + CStifSectionParser( const TInt aLength ); + + /** + * By default Symbian OS constructor is private. + */ + void ConstructL(); + + /** + * Generic start and end position parser for given data. + * Returns an error code. + */ + TInt ParseStartAndEndPos( TPtrC aSection, + const TDesC& aStartTag, + TTagToReturnValue aTagIndicator, + TInt& aStartPos, + TInt& aEndPos, + TInt& aLength ); + + /** + * Generic search for end-of-line. + * Returns position before linefeed and + * lex is posotioned to the beginning of next line. + */ + TInt GotoEndOfLine( TLex& lex ); + + /** + * Substracts line from the begining of selected text. + */ + TPtrC SubstractLine( const TPtrC& aText ); + + /** + * Searches for selected tag in a text. + */ + TInt FindTag( const TDesC& aText, const TDesC& aTag, TInt& aStartPos, TInt& aEndPos ); + + public: // Data + + protected: // Data + + private: // Data + + /** + * Parsed section with SectionL() or SubSectionL() method. + */ + TPtr iSection; + + /** + * Section length definitions. + */ + HBufC* iHBufferSection; + + /** + * Section length + */ + TInt iLength; + + /** + * Indicates position where start the parsing. + */ + TInt iSkipAndMarkPos; + + /** + * For line and item line parsing. Indicator is GetLine() or + * GetItemLineL() method used. + */ + TBool iLineIndicator; + + /** + * Indicates position where we are currently(subsection). + */ + TInt iSubOffset; + + public: // Friend classes + + /** + * For testing operations to get length information. + */ + friend class CTestParser; + + protected: // Friend classes + + private: // Friend classes + + }; + +#endif // STIF_SECTION_PARSER_H + +// End of File \ No newline at end of file diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/inc/StifTFwIf.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/inc/StifTFwIf.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,279 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the CStifTFwIf. +* +*/ + +#ifndef STIF_TFW_IF_H +#define STIF_TFW_IF_H + +// INCLUDES +#include +#include +#include +#include + + +// CONSTANTS +// None + +// MACROS +// Hardcoded deviceid used if DevId function is not overridden +const TUint16 KDefaultDevId = 0x0001; + +// DATA TYPES + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +class CStifTFw; + +// CLASS DECLARATION +// Information of test case +class CTestInfo + :public CBase + { + public: + IMPORT_C static CTestInfo* NewL(); + ~CTestInfo(); + + public: + const TDesC& ModuleName () const { return iModuleName; }; + TInt SetModuleName ( const TDesC& aModuleName ); + const TDesC& TestCaseTitle() const { return iTitle; }; + TInt SetTestCaseTitle ( const TDesC& aTitle ); + const TDesC& TestCaseFile() const { return iTestCaseFile; }; + TInt SetTestCaseFile ( const TDesC& aTestCaseFile ); + TInt TestCaseNum() const { return iCaseNumber; }; + void SetTestCaseNumber ( TInt aTestCaseNumber ) + { iCaseNumber = aTestCaseNumber; }; + TInt Priority() const { return iPriority; }; + void SetPriority ( TInt aPriority ) + { iPriority = aPriority; }; + TTimeIntervalMicroSeconds Timeout() const { return iTimeout; }; + void SetTimeout ( const TTimeIntervalMicroSeconds& aTimeout ) + { iTimeout = aTimeout; }; + TInt ExpectedResult() const { return iExpectedResult; }; + void CopyL( const CTestInfo& aTestInfo ); + TBool operator==(const CTestInfo& aTestInfo) const; + + private: + CTestInfo(); + void ConstructL(); + CTestInfo( const CTestInfo& /*aTestInfo*/ ){}; + CTestInfo& operator= ( const CTestInfo& ); + + private: + TInt iCaseNumber; + TInt iExpectedResult; + TTimeIntervalMicroSeconds iTimeout; + TInt iPriority; + TPtrC iModuleName; + HBufC* iModuleNameBuf; + TPtrC iTitle; + HBufC* iTitleBuf; + TPtrC iTestCaseFile; + HBufC* iTestCaseFileBuf; + + }; + +// CLASS DECLARATION + +// CStifTFwIf is the main class of STIF Test Framework Interface +class CStifTFwIf + :public CBase + { + public: // Enumerations + + protected: // Enumerations + + private: // Enumerations + + public: // Constructors and destructor + + /** + * Destructor. + */ + virtual IMPORT_C ~CStifTFwIf(); + + protected: // Functions that can be called from derived class + + /** + * Used to open TestFramework. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt Open( TDesC& aTestFrameworkIni = (TDesC&) KNullDesC() ); + + /** + * Used to close TestFramework. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt Close(); + + /** + * Used to set attributes for test framework. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt SetAttribute( TAttribute aAttribute, + const TDesC& aValue ); + + /** + * Receive message from ATS. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt AtsReceive( const TDesC& aMessage ); + + /** + * Used to add test module to test framework. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt AddTestModule( TDesC& aModuleName, + TDesC& aIniFile = (TDesC&) KNullDesC() ); + + /** + * Used to remove test module to test framework. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt RemoveTestModule( TDesC& aModuleName ); + + /** + * Used to add test case file for test module. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt AddTestCaseFile( TDesC& aModuleName, + TDesC& aCaseFile ); + + /** + * Used to remove test case file from test module. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt RemoveTestCaseFile( TDesC& aModuleName, + TDesC& aCaseFile ); + + /** + * Get testcases from test modules. Returns test case information + * in aTestinfo. + * Test module name and test case file can be used to limit the + * set of test cases returned. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt GetTestCases( RPointerArray& aTestInfo, + TDesC& aTestModule = (TDesC&) KNullDesC(), + TDesC& aTestCaseFile = (TDesC&) KNullDesC() ); + + /** + * Start selected test case identified with CTestInfo. + * Return TestId, which is handle used in subsequent + * test case execution control. + * + * Returns Symbian OS error code. + */ + + IMPORT_C TInt StartTestCase( TInt& aTestId, + const CTestInfo& aTestInfo ); + + /** + * Cancel test case execution. TestCompleted() will be called + * with aTestExecutionResult set to KErrCancel. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt CancelTestCase( TInt aTestId ); + + /** + * Pause test case execution. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt PauseTestCase( TInt aTestId ); + + /** + * Resume test case execution. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt ResumeTestCase( TInt aTestId ); + + /** + * C++ default constructor. + */ + IMPORT_C CStifTFwIf(); + + protected: // Functions that the derived class may implement. + + /** + * Function is called when test execution is finished + * with information of test case, result of test case execution + * and test case result. + */ + virtual void TestCompleted( TInt aTestId, + TInt aTestExecutionResult, + TTestResult& aTestResult )=0; + + /** + * Function is called when test case prints. + */ + virtual void Print( TInt /*aTestId*/, + TTestProgress& /*iProgress*/ ){}; + + /** + * Send message to ATS. + */ + virtual void AtsSend( const TDesC& /*aMessage*/ ){}; + + /** + * Get device identifier, should be overridden to make them + * unique among slaves. + * Returns default value for every slave otherwise. + */ + virtual TUint16 DevId(){ return KDefaultDevId; }; + + /** + * Reboot indication. + * After this function returns, reboot is done + * by test module or STIF TF. + */ + virtual void GoingToDoReset(){}; + + private: + + public: // Data + + protected: // Data + + private: // Data + + CStifTFw* iStifTFw; + + public: // Friend classes + + protected: // Friend classes + + private: // Friend classes + friend class CStifTFw; + }; + +#endif // STIF_TFW_IF_H + +// End of File \ No newline at end of file diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/inc/StifTFwIfProt.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/inc/StifTFwIfProt.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,423 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the +* CStifTFwIfProt. +* +*/ + +#ifndef STIF_TFW_IF_PROT_H +#define STIF_TFW_IF_PROT_H + +// INCLUDES +#include +#include +#include +#include + +// CONSTANTS +// Protocol identifier length +const TInt KProtocolIdLength=8; +// Default allocation size for message created with CreateL +const TInt KDefaultMsgSize=0x200; +// Maximum length for value added to type-value parameter +const TInt KMaxValueLength=12; + +// MACROS +// Macros for identifier manipulation +#define DEVID(x) ((TUint16)( ( 0xffff0000 & ((TUint32)(x)) ) >> 16 )) +#define TESTID(x) ((TUint16)( 0x0000ffff & ((TUint32)(x)) )) +#define SETID(d,t) ((TUint32)(( ( 0x0000ffff & ((TUint32)(d)) ) << 16 )|( 0x0000ffff & ((TUint32)(t)) ))) +#define GETDEVID(x) ((TUint32)( 0xffff0000 & ((TUint32)(x)) )) + +// DATA TYPES +typedef TPtrC (*KeywordFunc)( TInt aKeyword ); +// typedef TBuf TRemoteProtMsg; + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION + +// DESCRIPTION + +// CStifTFwIfProt is the control protocol interface +class CStifTFwIfProt + :public CBase + { + public: // Enumerations + + // Message type + enum TMsgType + { + EMsgReserve, + EMsgRelease, + EMsgRemote, + EMsgResponse, + }; + + // Command types + enum TCmdType + { + ECmdRun, + ECmdPause, + ECmdResume, + ECmdCancel, + ECmdRequest, + ECmdRelease, + ECmdSendReceive, + ECmdSetEvent, + ECmdUnsetEvent, + + ECmdUnknown, + }; + + // Remote device type + enum TRemoteType + { + ERemotePhone, + //ERemoteCallBox, ... + + ERemoteUnknown, + }; + + // Run parameters + enum TRunParams + { + ERunModule, + ERunInifile, + ERunTestcasefile, + ERunTestcasenum, + ERunTitle, + }; + + // Response parameters + enum TRespParam + { + ERespResult, + }; + + // Run status + enum TRunStatus + { + ERunStarted, + ERunError, + ERunReady, + }; + + // Run status parameters + enum TRunStatusParams + { + ERunResult, + ERunCategory, + }; + + // Execution result category + enum TResultCategory + { + EResultNormal = 0, + EResultPanic, + EResultException, + EResultTimeout, + EResultLeave, + }; + + // Event status + enum TEventStatus + { + EEventActive, + EEventSet, + EEventError, + EEventUnset, + }; + + // Event status + enum TEventStatusParams + { + EEventResult, + EEventType, + }; + + private: // Enumerations + + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + IMPORT_C static CStifTFwIfProt* NewL(); + + /** + * Destructor. + */ + IMPORT_C virtual ~CStifTFwIfProt(); + + public: // New functions + + /* + * Get message handle + */ + virtual const TDesC& Message(){ return iMessage; }; + + /** + * Set message. + */ + IMPORT_C TInt SetL( const TDesC& aMessage ); + + /** + * Create message. + */ + IMPORT_C void CreateL( TInt aLength = KDefaultMsgSize ); + + /** + * Append string to message. + */ + IMPORT_C TInt Append( const TDesC& aStr ); + + /** + * Append hexadecimal protocol identifier to message. + */ + IMPORT_C TInt AppendId( TUint32 aId ); + + /** + * Append keyword string to message. + */ + IMPORT_C TInt Append( KeywordFunc aFunc, TInt aKeyword ); + + /** + * Append keyword type-value string to message. + */ + IMPORT_C TInt Append( KeywordFunc aFunc, TInt aKeyword, TInt aValue ); + + /** + * Append keyword type-value string to message. + */ + IMPORT_C TInt Append( KeywordFunc aFunc, + TInt aKeyword, + const TDesC& aStr ); + + /** + * Append keyword type-value string to message. + */ + IMPORT_C TInt Append( KeywordFunc aFunc, + TInt aKeyword, + KeywordFunc aValueFunc, + TInt aValue ); + + /** + * Get protocol source identifier. + */ + IMPORT_C TUint32 SrcId(); + + /** + * Get protocol source device identifier. + */ + IMPORT_C TUint16 SrcDevId(); + + /** + * Get protocol source test identifier. + */ + IMPORT_C TUint16 SrcTestId(); + + /** + * Get protocol destination identifier. + */ + IMPORT_C TUint32 DstId(); + + /** + * Get protocol destination device identifier. + */ + IMPORT_C TUint16 DstDevId(); + + /** + * Get protocol destination test identifier. + */ + IMPORT_C TUint16 DstTestId(); + + /** + * Set protocol source identifier. + */ + IMPORT_C TInt SetSrcId( TUint32 aSrcId ); + + /** + * Set protocol destination identifier. + */ + IMPORT_C TInt SetDstId( TUint32 aDstId ); + + /** + * Set message type. + */ + IMPORT_C TInt SetMsgType( TMsgType aMsgType ); + + /** + * Set response type. + */ + IMPORT_C TInt SetRespType( TMsgType aRespType ); + + /** + * Set message type. + */ + IMPORT_C TInt SetCmdType( TCmdType aCmdType ); + + /* + * String containers. + */ + IMPORT_C static TPtrC MsgType( TInt aKeyword ); + + IMPORT_C static TPtrC CmdType( TInt aKeyword ); + + IMPORT_C static TPtrC RemoteType( TInt aKeyword ); + + IMPORT_C static TPtrC RunParams( TInt aKeyword ); + + IMPORT_C static TPtrC RunStatus( TInt aKeyword ); + + IMPORT_C static TPtrC RunStatusParams( TInt aKeyword ); + + IMPORT_C static TPtrC ResultCategory( TInt aKeyword ); + + IMPORT_C static TPtrC EventStatus( TInt aKeyword ); + + IMPORT_C static TPtrC EventStatusParams( TInt aKeyword ); + + IMPORT_C static TPtrC EventType( TInt aKeyword ); + + IMPORT_C static TPtrC RespParam( TInt aKeyword ); + + public: // Functions from base classes + + /** + * From + + protected: // New functions + + /** + * + */ + // + + protected: // Functions from base classes + + /** + * From + */ + // + + private: + /** + * C++ default constructor. + */ + CStifTFwIfProt(); + + /** + * By default Symbian OS constructor is private. + */ + void ConstructL(); + + /** + * Parsing functions. + */ + TInt ParseMessageL(); + + void ParseHeaderL(); + + void ParseReserveL(); + + void ParseRemoteL(); + + void ParseResponseL(); + + void ParseCmdResponseL(); + + static TInt Parse( TDesC& aKeyword, KeywordFunc aFunc ); + + static TInt ParseOptArg( const TDesC& aOptArg, TPtrC& aArg, TPtrC& aVal ); + + public: //Data + // Message type + TMsgType iMsgType; + // Remote type + TRemoteType iRemoteType; + // Response request type + TMsgType iRespType; + // Remote command type (valid only if TMsgType is EMsgRemote) + TCmdType iCmdType; + TPtrC iCmdDes; + + // Run parameters (valid only if run command) + // Test module name + TPtrC iModule; + // Test module initialization file + TPtrC iIniFile; + // Test module initialization file + TPtrC iTestCaseFile; + // Test case number + TInt iTestCaseNumber; + // Test case title + TPtrC iTitle; + + // Event parameters + // Event name + TPtrC iEventName; + + // Result from request or command + TInt iResult; + + // Response status + union + { + TRunStatus iRunStatus; + TEventStatus iEventStatus; + }; + // Result category + TResultCategory iResultCategory; + // Event response parameters + // Event type + TEventIf::TEventType iEventType; + + protected: // Data + // + + private: // Data + // Message buffer + HBufC* iMessageBuf; + // Message ptr + TPtr iMessage; + + // Message parser + CStifItemParser* iItem; + + // SrcId + TInt32 iSrcId; + // DstId + TInt32 iDstId; + + public: // Friend classes + // + + protected: // Friend classes + // + + private: // Friend classes + // + + }; + +#endif // STIF_TFW_IF_PROT_H + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/inc/StifTestEventInterface.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/inc/StifTestEventInterface.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,184 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the event +* interface. +* +*/ + +#ifndef TESTEVENTINTERFACE_H +#define TESTEVENTINTERFACE_H + +// INCLUDES +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION + +// DESCRIPTION +// Interface class for the event system. +class TEventIf + { + public: // Enumerations + /** + * Event request types. + */ + enum TReqType + { + // The following can be used by the test module + EReqEvent = 1, + EWaitEvent, + ERelEvent, + ESetEvent, + EUnsetEvent, + + // The rest are special + // Not used by the test module + EEnable, + ESetWaitPending, + ECmdError, + ECancelWait, + }; + + /** + * Event types. + */ + enum TEventType + { + EIndication, + EState, + }; + + private: // Enumerations + + public: // Constructors and destructor + + /** + * C++ constructor with params. + */ + TEventIf( TReqType aType = EEnable, + const TName& aName = KNullDesC(), + TEventType aEventType = EIndication ) + { iType = aType; iName = aName; iEventType = aEventType; } + + public: // New functions + + /** + * Get request type. + */ + inline TReqType Type() const { return iType; } + + /** + * Get event name. + */ + inline const TName& Name() const { return iName; } + + /** + * Get event type. + */ + inline TEventType EventType() const { return iEventType; } + + /** + * Set request type. + */ + inline void SetType( TReqType aType ){ iType = aType; } + + /** + * Set event name. + */ + inline void SetName( const TName& aName ){ iName = aName; } + + /** + * Set event to state event. + */ + inline void SetEventType( TEventType aEventType ) + { iEventType = aEventType; } + + /** + * Set request type and event name. + */ + inline void Set( TReqType aType, const TName& aName ) + { iType = aType; iName = aName; } + + /** + * Set request type, event name and event type. + */ + inline void Set( TReqType aType, + const TName& aName, + TEventType aEventType ) + { iType = aType; iName = aName; iEventType = aEventType; } + + /** + * Copy data from existing TEventIf (or derived class). + */ + inline void Copy( const TEventIf& aEvent) + { iType = aEvent.iType; + iName = aEvent.iName; + iEventType = aEvent.iEventType; } + + public: // Functions from base classes + + protected: // New functions + + protected: // Functions from base classes + + private: + + public: //Data + + protected: // Data + /** + * Request type. + */ + TReqType iType; + + /** + * Event name (must be unique). + */ + TName iName; + + /** + * Event type. + */ + TEventType iEventType; + + private: // Data + + public: // Friend classes + + protected: // Friend classes + + private: // Friend classes + + }; + +// Packaged TEventIf +typedef TPckg TEventIfPckg; + +#endif // TESTEVENTINTERFACE_H + +// End of File \ No newline at end of file diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/inc/StifTestInterface.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/inc/StifTestInterface.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,355 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the +* TestInterface. +* +*/ + +#ifndef TEST_INTERFACE_H +#define TEST_INTERFACE_H + + +// INCLUDES +#include +#include +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FUNCTION PROTOTYPES + +// This defines drive letters that is available in STIF TF. +//@spe IMPORT_C const TChar StifDriveLetters( TInt aDriveNumber, TInt& aCount ); + +// This works and used only in EKA2 environment and used from STIF +// TestFramework internally. +// Executable module uses defined capabilities(PlatSec's Capability model) +// to start session. Function for starting the TestServer and +// Testmodule/TestClass. +IMPORT_C TInt StartSession(); + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION +const TInt KMaxStifInfoName = 0x10; +typedef TBuf TStifInfoName; + +// DESCRIPTION +// TTestInfo defines the information for test case and Test Module. +class TTestInfo + { + public: + IMPORT_C TTestInfo(); + public: + // The name of Test Module. + TName iModuleName; + // Test case info for test case execution. + TTestCaseInfo iTestCaseInfo; + // Config file to be used. + TFileName iConfig; + }; + +// Packaged TTestInfo +typedef TPckg TTestInfoPckg; + +// CLASS DECLARATION + +// DESCRIPTION +// TFullTestResult defines the full test case result information. +class TFullTestResult + { + public: + IMPORT_C TFullTestResult(); + + enum TCaseExecutionResult + { + ECaseOngoing, + ECaseExecuted, + ECaseCancelled, + ECaseErrorFromModule, + ECaseLeave, + ECasePanic, + ECaseException, + ECaseTimeout, + ECaseSuicided, + }; + + public: + // Test case result. + TTestResult iTestResult; + // Timestamp when test case was started. + TTime iStartTime; + // Timestamp when test case was ended. + TTime iEndTime; + + // Test result type + TCaseExecutionResult iCaseExecutionResultType; + // Test result code + TInt iCaseExecutionResultCode; + }; + +// Packaged TFullTestResult +typedef TPckg TFullTestResultPckg; + + +// CLASS DECLARATION + +// DESCRIPTION +// TTestProgress defines the progress information from Test Module. +class TTestProgress + { + public: + IMPORT_C TTestProgress(); + public: + // "Priority" of the progress information. + TInt iPosition; + // Description of the data to be printed. + TStifInfoName iDescription; + // The actual progress information. + TName iText; + }; + +// Packaged TTestProgress +typedef TPckg TTestProgressPckg; + + +// CLASS DECLARATION + +// DESCRIPTION +// TErrorNotification defines the error notifications +class TErrorNotification + { + public: + IMPORT_C TErrorNotification(); + public: + // Error priority + TInt iPriority; + // Module reporting error + TStifInfoName iModule; + // The actual error information. + TName iText; + }; + +// Attributes that can be changed with SetAttribute +enum TAttribute + { + ELogPath, // Log file path + ERebootPath, // Reboot path definition + ERebootFilename, // Reboot filename definition + EStifMeasurementOn, // STIF's Measurement enable + EStifMeasurementOff // STIF's Measurement disable + }; + +// Packaged TErrorNotification +typedef TPckg TErrorNotificationPckg; + +// Different STIF internal commands. +enum TStifCommand + { + EStifCmdReceive, + EStifCmdSend, + EStifCmdReboot, + EStifCmdStoreState, + EStifCmdGetStoredState, + EStifCmdRebootProceed, + EStifCmdReceiveCancel, + EStifCmdMeasurement, + }; +typedef TPckg TStifCommandPckg; + +// Class for Reboot parameter +class TRebootParams + { + public: + CTestModuleIf::TRebootType aType; + }; + +// Class for Reboot state parameters +class TRebootStateParams + { + public: + TInt aCode; + TName aName; + }; + +// Class for Reboot stored parameters +class TGetRebootStoredParams + { + public: + TInt aCode; + TName aName; + }; + +// Class for Reboot stored parameters(references) +class TGetRebootStoredParamsRef + { + public: + TGetRebootStoredParamsRef( + TInt& aCode, TName& aName ):iCode(aCode),iName(aName){}; + public: + TInt& iCode; + TName& iName; + }; + +// Class for measurement stored parameters +class TGetMeasurementOptions + { + public: + TInt iOptions; + }; + +// Class for measurement stored parameters(options) +class TGetMeasurementOptionsRef + { + public: + TGetMeasurementOptionsRef( TInt& aOptions ): iOptions(aOptions){}; + public: + TInt& iOptions; + }; + +// This class offer generic attribute for passing client-server interface +union TParams + { + TDes* aRemoteMsgRef; + const TDesC* aRemoteMsgConstRef; + TRebootParams* aRebootType; + TRebootStateParams* aRebootState; + TGetRebootStoredParamsRef* aRebootStoredRef; + TGetMeasurementOptionsRef* aMeasurementOption; + }; + +// Packaged TRebootParams +typedef TPckg TRebootParamsPckg; + +// Packaged TRebootStateParams +typedef TPckg TRebootStateParamsPckg; + +// Packaged TGetRebootStoredParams +typedef TPckg TGetRebootStoredParamsPckg; + +// Packaged TGetMeasurementParams +typedef TPckg TGetMeasurementOptionsPckg; + + +// CLASS DECLARATION + +// DESCRIPTION +// Base class for test measurement modules. Measurement modules implements +// measurerement operations. +NONSHARABLE_CLASS( CSTIFTestMeasurementImplementation ) : public CBase + { + public: // Enumerations + + private: // Enumerations + + public: // Constructors and destructor + + public: // New functions + + /** + * Pure virtual measurement start command. + * Start method's implementation is in measurement module. + */ + virtual TInt Start( ) = 0; + + /** + * Pure virtual measurement stop command. + * Stop method's implementation is in measurement module. + */ + virtual TInt Stop( ) = 0; + + /** + * Pure virtual measurement stop command. + * Stop method's implementation is in measurement module. + */ + virtual CSTIFTestMeasurement::TSTIFMeasurementType MeasurementType() = 0; + + + public: // Functions from base classes + + protected: // New functions + + protected: // Functions from base classes + + private: + + public: //Data + + protected: // Data + + private: // Data + + public: // Friend classes + + protected: // Friend classes + + private: // Friend classes + + }; + +// STIF utility class +class TStifUtil + { + public: // Enumerations + + private: // Enumerations + + public: // Constructors and destructor + + public: // New functions + /** + * Checks if file path contains drive letter. If not file is serched + * on all drives and first hit is added to file name. + */ + IMPORT_C static void CorrectFilePathL( TDes& aFilePath ); + + /** + * Method used by both STIF and STIF UI to retrieve version of STIF + */ + IMPORT_C static void STIFVersion(TInt& aMajorV, TInt& aMinorV, TInt& aBuildV, TDes& aRelDate); + + public: // Functions from base classes + + protected: // New functions + + protected: // Functions from base classes + + private: + + public: //Data + + protected: // Data + + private: // Data + + public: // Friend classes + + protected: // Friend classes + + private: // Friend classes + + }; + + +#endif // TEST_INTERFACE_H + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/inc/StifTestInterference.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/inc/StifTestInterference.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,221 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the STIF test +* interference module. +* +*/ + +#ifndef STIFTESTINTERFERENCE_H +#define STIFTESTINTERFERENCE_H + +// INCLUDES +#include "StifTestModule.h" +#include +#include +#include +#include + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def + +// DATA TYPES +//enum ?declaration +//typedef ?declaration +//extern ?data_type; + +// FUNCTION PROTOTYPES +//?type ?function_name(?arg_list); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; + +// CLASS DECLARATION + +/** +* This a MSTIFTestInterference class. +* MSTIFTestInterference is an interface class. Purpose is to +* avoid multi heritance in subclasses. +* +* @lib ?library +* @since ?Series60_version +*/ +NONSHARABLE_CLASS( MSTIFTestInterference ) + { + public: // Enumerations + + // Way of using test interference + enum TStifTestInterferenceCategory + { + EActiveObject, // Test interference using active object + EThread, // Test interference using thread + }; + + // Type of the test interference + enum TStifTestInterferenceType + { + ENone, // No test interference + ECpuLoad, // with CPU load + EFileSystemReadC, // with file system load, read from C-drive + EFileSystemReadD, // with file system load, read from D-drive + EFileSystemReadE, // with file system load, read from E-drive + EFileSystemReadZ, // with file system load, read from Z-drive + EFileSystemWriteC, // with file system load, write from C-drive + EFileSystemWriteD, // with file system load, write from D-drive + EFileSystemWriteE, // with file system load, write from E-drive + EFileSystemFillAndEmptyC, // with file system load, fill and empty from + // C-drive + EFileSystemFillAndEmptyD, // with file system load, fill and empty from + // D-drive + EFileSystemFillAndEmptyE, // with file system load, fill and empty from + // E-drive + + ENoneMicroSeconds, // No test interference + ECpuLoadMicroSeconds, // with CPU load + EFileSystemReadCMicroSeconds, // with file system load, read from C-drive + EFileSystemReadDMicroSeconds, // with file system load, read from D-drive + EFileSystemReadEMicroSeconds, // with file system load, read from E-drive + EFileSystemReadZMicroSeconds, // with file system load, read from Z-drive + EFileSystemWriteCMicroSeconds, // with file system load, write from C-drive + EFileSystemWriteDMicroSeconds, // with file system load, write from D-drive + EFileSystemWriteEMicroSeconds, // with file system load, write from E-drive + EFileSystemFillAndEmptyCMicroSeconds, // with file system load, fill and empty from + // C-drive + EFileSystemFillAndEmptyDMicroSeconds, // with file system load, fill and empty from + // D-drive + EFileSystemFillAndEmptyEMicroSeconds // with file system load, fill and empty from + // E-drive + }; + + public: // Constructors and destructor + + /** + * Two-phased constructor. + * @param: aTestModuleBase: CTestModuleBase object for get test + interference handle to STIF's side(Used if test case panic so + test interference thread can be kill by STIF). + * @param: aCategory: Test interference category + * @return: MSTIFTestInterference object + */ + IMPORT_C static MSTIFTestInterference* NewL( + CTestModuleBase* aTestModuleBase, + TStifTestInterferenceCategory aCategory ); + + /** + * Destructor. + */ + virtual ~MSTIFTestInterference(); + + public: // New functions + + /** + * StartL method starts test interference. + * @param: aType: Test interference type. + * @param: aIdleTime: Test interference idle time. + * @param: aActiveTime: Test interference active time. + * @return: Symbian error code. + */ + virtual TInt StartL( TStifTestInterferenceType aType, + TInt aIdleTime, + TInt aActiveTime ) = 0; + + /** + * Stop method stops test interference. + */ + virtual TInt Stop() = 0; + + /** + * Sets thread or active object priority. This should use before + * test interference is started otherwise error code will return. + * + * Thread priority can set during interference executions time. User + * should be sure that given value is acceptable, otherwise SetPriority + * panics. + * + * @param: aPriority: New priority for active object or thread + * @return: Symbian error code. + */ + virtual TInt SetPriority( TInt aPriority ) = 0; + + /** + * ?member_description. + * @since ?Series60_version + * @param ?arg1 ?description + * @return ?description + */ + //?type ?member_function( ?type ?arg1 ); + + public: // Functions from base classes + + /** + * ?member_description. + * @since ?Series60_version + * @param ?arg1 ?description + * @return ?description + */ + //?type ?member_function( ?type ?arg1 ); + + protected: // New functions + + /** + * ?member_description. + * @since ?Series60_version + * @param ?arg1 ?description + * @return ?description + */ + //?type ?member_function( ?type ?arg1 ); + + protected: // Functions from base classes + + /** + * From ?base_class ?member_description + */ + //?type ?member_function(); + + private: + + // Prohibit copy constructor if not deriving from CBase. + // ?classname( const ?classname& ); + // Prohibit assigment operator if not deriving from CBase. + // ?classname& operator=( const ?classname& ); + + public: // Data + // ?one_line_short_description_of_data + //?data_declaration; + + protected: // Data + // ?one_line_short_description_of_data + //?data_declaration; + + private: // Data + // ?one_line_short_description_of_data + //?data_declaration; + + // Reserved pointer for future extension + //TAny* iReserved; + + public: // Friend classes + //?friend_class_declaration; + protected: // Friend classes + //?friend_class_declaration; + private: // Friend classes + //?friend_class_declaration; + + }; + +#endif // STIFTESTINTERFERENCE_H + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/inc/StifTestModule.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/inc/StifTestModule.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,1256 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the +* CTestModuleBase and CTestModuleIf classes. Test Module inherits +* the CTestModuleBase and uses the CTestModuleIf for printing +* to user interface and event system control. +* +* The initialization of this interface must be done from the Test Module Server with: +* CTestModuleXXX *mod = new CTestModuleXXX; +* RThread thread; +* CTestModuleIf::NewL( this, (CTestModuleBase*) mod, thread.Id() ); +* +* CTestModuleIf is deleted by destructor of the CTestModuleBase. +* +*/ + +#ifndef TESTMODULE_H +#define TESTMODULE_H + +// INCLUDES +#include +#include +#include "StifCommand.h" + +// CONSTANTS + +// Define Old Test Module API version - API that doesn't support version of test module +const TInt KOldTestModuleAPIMajor = 1; +const TInt KOldTestModuleAPIMinor = 1; +const TInt KOldTestModuleAPIBuild = 0; + +// Define Test Module API version +const TInt KTestModuleAPIMajor = 1; +const TInt KTestModuleAPIMinor = 2; +const TInt KTestModuleAPIBuild = 0; +const TInt KStifMaxResultDes = 128; // Maximum test result description length + +// Max array value for STIF macros allow result. +const TInt KSTIFMacroResultArraySize = 10; + +// Test module def-file check when setting parameters. +const TUint32 KStifTestModuleParameterChanged = 0xdeadbeef; + +// MACROS +// Test result description. Maximum length is 128 characters. +typedef TBuf TResultDes; + +// Macro for boolean. +#ifdef TL + #pragma message( "============================================================" ) + #pragma message( " TL macro is already defined, now using STIF TF's TL macro" ) + #pragma message( "============================================================" ) +#undef TL +#endif +// Macro for integer and one expected result. +#ifdef T1L + #pragma message( "==============================================================" ) + #pragma message( " T1L macro is already defined, now using STIF TF's T1L macro" ) + #pragma message( "==============================================================" ) +#undef T1L +#endif +// Macro for integer and two expected result. +#ifdef T2L + #pragma message( "==============================================================" ) + #pragma message( " T2L macro is already defined, now using STIF TF's T2L macro" ) + #pragma message( "==============================================================" ) +#undef T2L +#endif +// Macro for integer and three expected result. +#ifdef T3L + #pragma message( "==============================================================" ) + #pragma message( " T3L macro is already defined, now using STIF TF's T3L macro" ) + #pragma message( "==============================================================" ) +#undef T3L +#endif +// Macro for integer and four expected result. +#ifdef T4L + #pragma message( "==============================================================" ) + #pragma message( " T4L macro is already defined, now using STIF TF's T4L macro" ) + #pragma message( "==============================================================" ) +#undef T4L +#endif +// Macro for integer and five expected result. +#ifdef T5L + #pragma message( "==============================================================" ) + #pragma message( " T5L macro is already defined, now using STIF TF's T5L macro" ) + #pragma message( "==============================================================" ) +#undef T5L +#endif + +// Macro for boolean. Recommended use with TestScripter's test class. +#ifdef TAL + #pragma message( "==============================================================" ) + #pragma message( " TAL macro is already defined, now using STIF TF's TAL macro" ) + #pragma message( "==============================================================" ) +#undef TAL +#endif +// Macro for integer and one expected result. Recommended use with TestScripter's test +// class. +#ifdef TA1L + #pragma message( "================================================================" ) + #pragma message( " TA1L macro is already defined, now using STIF TF's TA1L macro" ) + #pragma message( "================================================================" ) +#undef TA1L +#endif +// Macro for integer and two expected result. Recommended use with TestScripter's test +// class. +#ifdef TA2L + #pragma message( "================================================================" ) + #pragma message( " TA2L macro is already defined, now using STIF TF's TA2L macro" ) + #pragma message( "================================================================" ) +#undef TA2L +#endif +// Macro for integer and three expected result. Recommended use with TestScripter's test +// class. +#ifdef TA3L + #pragma message( "================================================================" ) + #pragma message( " TA3L macro is already defined, now using STIF TF's TA3L macro" ) + #pragma message( "================================================================" ) +#undef TA3L +#endif +// Macro for integer and four expected result. Recommended use with TestScripter's test +// class. +#ifdef TA4L + #pragma message( "================================================================" ) + #pragma message( " TA4L macro is already defined, now using STIF TF's TA4L macro" ) + #pragma message( "================================================================" ) +#undef TA4L +#endif +// Macro for integer and five expected result. Recommended use with TestScripter's test +// class. +#ifdef TA5L + #pragma message( "================================================================" ) + #pragma message( " TA5L macro is already defined, now using STIF TF's TA5L macro" ) + #pragma message( "================================================================" ) +#undef TA5L +#endif + + +// TL ======================================================================== +// Macro for verify boolean value. +// Example for use, 1: TL( Open() == KErrNone ); +// 1: TL( VerifyString1() == VerifyString2() ); +// 2: TL( 6 <= 8 ); +// =========================================================================== + #define TL( aIsTrue )\ + if( (!(aIsTrue)) )\ + { TestModuleIf().StifMacroError( (0), (TText8*)__FILE__, __FUNCTION__, __LINE__ );\ + User::Leave( KErrArgument ); }; + +// T1L ======================================================================= +// Macro for verify integer value from the expected 1 value. +// Example: T1L( Open(), KErrNone ); +// =========================================================================== + #define T1L( aResult, aExpected1 )\ + {\ + TInt result = aResult;\ + if( ( (result) != (aExpected1) ) )\ + { TestModuleIf().StifMacroError(\ + (1), (TText8*)__FILE__, __FUNCTION__, __LINE__, (result), (aExpected1) );\ + User::Leave( KErrArgument ); };\ + }; + +// T2L ======================================================================= +// Macro for verify integer value from the expected 1 and 2 values. +// Example for use: T1L( Open(), KErrNone, KErrAlreadyExists ); +// =========================================================================== + #define T2L( aResult, aExpected1, aExpected2 )\ + {\ + TInt result = aResult;\ + if( ( (result) != (aExpected1) && (result) != (aExpected2) ) )\ + { TestModuleIf().StifMacroError(\ + (2), (TText8*)__FILE__, __FUNCTION__, __LINE__, (result), (aExpected1), (aExpected2) );\ + User::Leave( KErrArgument ); };\ + }; + +// T3L ======================================================================= +// Macro for verify integer value from the expected 1, 2 and 3 values. +// Example for use: T1L( Open(), KErrNone, KErrAlreadyExists, KErrDiskFull ); +// =========================================================================== + #define T3L( aResult, aExpected1, aExpected2, aExpected3 )\ + {\ + TInt result = aResult;\ + if( ( (result) != (aExpected1) && (result) != (aExpected2) && (result) != (aExpected3) ) )\ + { TestModuleIf().StifMacroError(\ + (3), (TText8*)__FILE__, __FUNCTION__, __LINE__, (result), (aExpected1), (aExpected2), (aExpected3) );\ + User::Leave( KErrArgument ); };\ + }; + +// T4L ======================================================================= +// Macro for verify integer value from the expected 1, 2, 3 and 4 values. +// Example for use: +// T1L( Open(), KErrNone, KErrAlreadyExists, KErrDiskFull, KErrDisconnected ); +// =========================================================================== + #define T4L( aResult, aExpected1, aExpected2, aExpected3, aExpected4 )\ + {\ + TInt result = aResult;\ + if( ( (result) != (aExpected1) && \ + (result) != (aExpected2) && \ + (result) != (aExpected3) && \ + (result) != (aExpected4) ) )\ + { TestModuleIf().StifMacroError(\ + (4), (TText8*)__FILE__, __FUNCTION__, __LINE__, (result), \ + (aExpected1), (aExpected2), (aExpected3), (aExpected4) );\ + User::Leave( KErrArgument ); };\ + }; + +// T5L ======================================================================= +// Macro for verify integer value from the expected 1, 2, 3, 4 and 5 values. +// Example for use: +// T1L( Open(), KErrNone, KErrDied, KErrInUse, KErrDisconnected, KErrAbort ); +// =========================================================================== + #define T5L( aResult, aExpected1, aExpected2, aExpected3, aExpected4, aExpected5 )\ + {\ + TInt result = aResult;\ + if( ( (result) != (aExpected1) && \ + (result) != (aExpected2) && \ + (result) != (aExpected3) && \ + (result) != (aExpected4) && \ + (result) != (aExpected5) ) )\ + { TestModuleIf().StifMacroError(\ + (5), (TText8*)__FILE__, __FUNCTION__, __LINE__, (result), \ + (aExpected1), (aExpected2), (aExpected3), (aExpected4), (aExpected5) );\ + User::Leave( KErrArgument ); };\ + }; + + +// TAL ======================================================================== +// Macro for verify boolean value. +// Recommended use with TestScripter's test class. Allowed result can be defined +// with 'allownextresult' and 'allowerrorcodes' keywords. +// Example for use, 1: TL( Open() == KErrNone ); +// 1: TL( VerifyString1() == VerifyString2() ); +// 2: TL( 6 <= 8 ); +// ============================================================================= + #define TAL( aIsTrue )\ + if( ( !(aIsTrue) ) && TestModuleIf().CheckAllowResult( 0 /* = EFalse*/ ) )\ + { TestModuleIf().StifMacroError( (0), (TText8*)__FILE__, __FUNCTION__, __LINE__ );\ + User::Leave( KErrArgument ); }; + +// TA1L ======================================================================= +// Macro for verify integer value from the expected 1 value. +// Recommended use with TestScripter's test class. Allowed result can be defined +// with 'allownextresult' and 'allowerrorcodes' keywords. +// Example: T1L( Open(), KErrNone ); +// ============================================================================= + #define TA1L( aResult, aExpected1 )\ + {\ + TInt result = aResult;\ + if( ( (result) != (aExpected1) ) && \ + TestModuleIf().CheckAllowResult( result ) ) \ + { TestModuleIf().StifMacroError(\ + (1), (TText8*)__FILE__, __FUNCTION__, __LINE__, (result), (aExpected1) );\ + User::Leave( KErrArgument ); };\ + }; + +// TA2L ======================================================================= +// Macro for verify integer value from the expected 1 and 2 values. +// Recommended use with TestScripter's test class. Allowed result can be defined +// with 'allownextresult' and 'allowerrorcodes' keywords. +// Example for use: T1L( Open(), KErrNone, KErrAlreadyExists ); +// ============================================================================= + #define TA2L( aResult, aExpected1, aExpected2 )\ + {\ + TInt result = aResult;\ + if( ( (result) != (aExpected1) && (result) != (aExpected2) ) && \ + TestModuleIf().CheckAllowResult( result ) ) \ + { TestModuleIf().StifMacroError(\ + (2), (TText8*)__FILE__, __FUNCTION__, __LINE__, (result), (aExpected1), (aExpected2) );\ + User::Leave( KErrArgument ); };\ + }; + +// TA3L ======================================================================= +// Macro for verify integer value from the expected 1, 2 and 3 values. +// Recommended use with TestScripter's test class. Allowed result can be defined +// with 'allownextresult' and 'allowerrorcodes' keywords. +// Example for use: T1L( Open(), KErrNone, KErrAlreadyExists, KErrDiskFull ); +// ============================================================================= + #define TA3L( aResult, aExpected1, aExpected2, aExpected3 )\ + {\ + TInt result = aResult;\ + if( ( (result) != (aExpected1) && (result) != (aExpected2) && (result) != (aExpected3) ) && \ + TestModuleIf().CheckAllowResult( result ) )\ + { TestModuleIf().StifMacroError(\ + (3), (TText8*)__FILE__, __FUNCTION__, __LINE__, (result), (aExpected1), (aExpected2), (aExpected3) );\ + User::Leave( KErrArgument ); };\ + }; + +// TA4L ======================================================================= +// Macro for verify integer value from the expected 1, 2, 3 and 4 values. +// Recommended use with TestScripter's test class. Allowed result can be defined +// with 'allownextresult' and 'allowerrorcodes' keywords. +// Example for use: +// T1L( Open(), KErrNone, KErrAlreadyExists, KErrDiskFull, KErrDisconnected ); +// ============================================================================= + #define TA4L( aResult, aExpected1, aExpected2, aExpected3, aExpected4 )\ + {\ + TInt result = aResult;\ + if( ( (result) != (aExpected1) && \ + (result) != (aExpected2) && \ + (result) != (aExpected3) && \ + (result) != (aExpected4) ) && \ + TestModuleIf().CheckAllowResult( result ) ) \ + { TestModuleIf().StifMacroError(\ + (4), (TText8*)__FILE__, __FUNCTION__, __LINE__, (result), \ + (aExpected1), (aExpected2), (aExpected3), (aExpected4) );\ + User::Leave( KErrArgument ); };\ + }; + +// TA5L ======================================================================= +// Macro for verify integer value from the expected 1, 2, 3, 4 and 5 values. +// Recommended use with TestScripter's test class. Allowed result can be defined +// with 'allownextresult' and 'allowerrorcodes' keywords. +// Example for use: +// T1L( Open(), KErrNone, KErrDied, KErrInUse, KErrDisconnected, KErrAbort ); +// ============================================================================= + #define TA5L( aResult, aExpected1, aExpected2, aExpected3, aExpected4, aExpected5 )\ + {\ + TInt result = aResult;\ + if( ( (result) != (aExpected1) && \ + (result) != (aExpected2) && \ + (result) != (aExpected3) && \ + (result) != (aExpected4) && \ + (result) != (aExpected5) ) && \ + TestModuleIf().CheckAllowResult( result ) ) \ + { TestModuleIf().StifMacroError(\ + (5), (TText8*)__FILE__, __FUNCTION__, __LINE__, (result), \ + (aExpected1), (aExpected2), (aExpected3), (aExpected4), (aExpected5) );\ + User::Leave( KErrArgument ); };\ + }; + + +// Workaround for ARM RVCT compiler error. This added because if some +// environment do not include this definition. +#if !defined (NONSHARABLE_CLASS) +#define NONSHARABLE_CLASS(x) class x +#endif + +// DATA TYPES +// None + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +class CTestModuleBase; +class TEventIf; +class CTestThreadContainer; +class MSTIFTestInterference; +class CSTIFTestMeasurement; +class CSTIFTestMeasurementImplementation; +class CUiEnvProxy; + +// CLASS DECLARATION + +// DESCRIPTION +// Base class for test case measurement . User can start measurement operations +// via this class. +NONSHARABLE_CLASS( CSTIFTestMeasurement ) + :public CBase + { + public: // Enumerations + + /** + * Enumeration for different measurement types. + */ + enum TSTIFMeasurementType + { + KStifMeasurementEnableAll, + KStifMeasurementPlugin01, + KStifMeasurementPlugin02, + KStifMeasurementPlugin03, + KStifMeasurementPlugin04, + KStifMeasurementPlugin05, + KStifMeasurementBappeaProfiler, + KStifMeasurementDisableAll, + }; + + /** + * Enumeration for different measurement operations. + */ + enum TSTIFMeasurementOperation + { + KMeasurementNew, + KMeasurementStart, + KMeasurementStop, + }; + + /** + * Struct for measurement. + */ + struct TStifMeasurementStruct + { + TSTIFMeasurementType iMeasurementType; + TFileName iConfigurationInfo; + TSTIFMeasurementOperation iMeasurementOperation; + TInt iOperationResult; + CTestModuleBase* iPointerToMeasurementModule; + }; + + private: // Enumerations + + public: // Constructors and destructor + + /** + * Two-phased constructor. Intializes test measurement module. + */ + IMPORT_C static CSTIFTestMeasurement* NewL( + CTestModuleBase* aTestModuleBase, + TSTIFMeasurementType aType, + const TDesC& aConfigurationInfo ); + + public: // New functions + + /** + * Start commant for test measurement module. + * Returns Symbian error code. + */ + IMPORT_C TInt Start(); + + /** + * Stop command for test measurement module. + * Returns Symbian error code. + */ + IMPORT_C TInt Stop(); + + public: // Functions from base classes + + /** + * Destructor + */ + virtual ~CSTIFTestMeasurement(); + + protected: // New functions + + protected: // Functions from base classes + + private: + + /** + * C++ default constructor. + */ + CSTIFTestMeasurement( CTestModuleBase* aTestModuleBase ); + + /** + * By default Symbian OS constructor is private. + */ + void ConstructL( TSTIFMeasurementType aType, + const TDesC& aConfigurationInfo ); + + public: //Data + + protected: // Data + + private: // Data + + // Pointer to STIF side + CTestModuleBase* iTestModuleBase; + + // Stuct that includes measurement related information + TStifMeasurementStruct iMeasurementStruct; + + // Indicates is measurement disable + TInt iMeasurementOption; + + public: // Friend classes + + protected: // Friend classes + + private: // Friend classes + friend class CTestModuleBase; + + }; + + +// CLASS DECLARATION + +// DESCRIPTION +// TTestResult defines the test case result information. +class TTestResult + { + public: + + /** + * Default constructor of TTestResult. + */ + IMPORT_C TTestResult(); + + /** + * Sets result and result description of the test case. + */ + IMPORT_C void SetResult( TInt aResultCode, const TDesC& aResultDes ); + + public: + + // Test case result as Symbian OS error code. + TInt iResult; + // Descriptive test case result. + TResultDes iResultDes; + }; + +// CLASS DECLARATION + +// DESCRIPTION +// TTestCaseInfo defines the information for test case execution. +class TTestCaseInfo + { + public: + // Default test case priority values + enum TPriority + { + EPriorityLow = -100, + EPriorityNormal = 0, + EPriorityHigh = 100, + }; + + public: + + /** + * Default constructor of TTestCaseInfo. + */ + IMPORT_C TTestCaseInfo(); + + public: + + // Test case number. + TInt iCaseNumber; + // Test case title. + TName iTitle; + // Test Case Timeout ( 0 == No timeout ) + TTimeIntervalMicroSeconds iTimeout; + // Test case priority + TInt iPriority; + + }; +// Packaged TTestCaseInfo +typedef TPckg TTestCaseInfoPckg; + +// CLASS DECLARATION +class CScriptBase; +class TScriptObject + { +public: + TName& ObjectId() + { + return iName; + } + TScriptObject(): + iScript(NULL) + { + } + IMPORT_C virtual ~TScriptObject(); +public: + //CScriptBaseProxy iScript; + CScriptBase* iScript; +protected: + TName iName; + }; +// DESCRIPTION +// CTestModuleIf provides interface for Test Module to perform +// printing to user interface and to control event system. +class CTestModuleIf + :public CBase + { + public: // Enumerations + + // Possible test case exit reasons. + enum TExitReason + { + // Case will exit normally AND return test case result. + ENormal, + // Case is expected to panic. + EPanic, + // Case will end to exception. + EException, + }; + + enum TRebootType + { + EDefaultReset = 0, // Do not change the value + EKernelReset, + + EDeviceReset0 = 100, + EDeviceReset1, + EDeviceReset2, + EDeviceReset3, + EDeviceReset4, + EDeviceReset5 + }; + + enum TTestBehavior + { + ETestLeaksMem = 0x00000001, + ETestLeaksRequests = 0x00000002, + ETestLeaksHandles = 0x00000004, + EOOMDisableLeakChecks = 0x00000008, + }; + + private: // Enumerations + + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + IMPORT_C static CTestModuleIf* NewL( CTestThreadContainer* aExecutionSession, + CTestModuleBase* aTestModule ); + + public: // New functions + + /** + * Printf is used to provide different information up to the UI + * that can be then printed e.g. to the Console Screen. + * The definition of data to be printed is copied to aDefinition. + * The aPriority tells how important information is returned. + * The priority can be used in the UI to decide if the information + * received from the Test Module will be discarded or not in + * the different performance situations. The priority is also + * used in the Test Module server and in the Test Engine to queue + * the Printf responses. + * This method is implemented in Test Module Server and the Test Module + * can call it to provide printable information to the UI. + */ + IMPORT_C void Printf( const TInt aPriority, + const TDesC& aDefinition, + TRefByValue aFmt,... ); + + /** + * Event function is used to control and use the event system. + * TEvent &aEvent encapsulates the request type and + * the event name, see StifTestEventInterface.h for more information. + * This method is implemented in Test Module Server and the Test Module + * can call it to control the event system. + */ + IMPORT_C TInt Event( TEventIf& aEvent ); + + /** + * Asynchronous overload function for the previous. Only one + * asynchronous Event call can be active concurrently. Second + * concurrent call will block until first one is completed. + */ + IMPORT_C void Event( TEventIf& aEvent, TRequestStatus& aStatus ); + + /** + * Cancel asynchronous event command. + */ + IMPORT_C TInt CancelEvent( TEventIf& aEvent, + TRequestStatus* aStatus ); + + /** + * SetExitReason function is used to set different crash reasons to + * acceptable test case result. + * Only one exit reason can be set at time. When function is called + * again, previous exit reason is removed and new one is set to + * acceptable exit reason. + * + * Function is typically used to accept test case panics as "passed" + * test cases. + * + * Test case that panics or gets exception is set to passed + * if aExitReason parameter matches with exit reason and + * aExitCode matches with panic code or exception type. + */ + IMPORT_C void SetExitReason( const CTestModuleIf::TExitReason aExitReason, + const TInt aExitCode ); + + + /** + * RemoteSend function is used send remote control protocol messages. + */ + IMPORT_C TInt RemoteSend( const TDesC& aRemoteMsg ); + + /** + * RemoteReceive function is used receive remote + * control protocol messages. + */ + IMPORT_C void RemoteReceive( TDes& aRemoteMsg, + TRequestStatus& aStatus ); + + /** + * RemoteReceiveCancel function is used cancel + * pending RemoteReceive. + */ + IMPORT_C void RemoteReceiveCancel(); + + /** + * Reboot device, StoreState MUST have been called. + */ + IMPORT_C TInt Reboot( TInt aType = EDefaultReset ); + + /** + * Store state before reboot. MUST be called before calling Reboot(). + */ + IMPORT_C TInt StoreState( TInt aCode, TName& aName ); + + /** + * Get state after reboot (stored with StoreState). + */ + IMPORT_C TInt GetStoredState( TInt& aCode, TName& aName ); + + /** + * Set test case behavior, e.g. allow memory leak, handle leak etc. + */ + IMPORT_C TInt SetBehavior( TTestBehavior aType, TAny* aPtr=NULL ); + + /** + * This can be called from test module but it is recommended to use + * TL, T1L, T2L or T3L macro instead of this method. + * For more information see macro definitions above on this file. + */ + IMPORT_C TInt StifMacroError( TInt aMacroType, + const TText8* aFile, + const char* aFunction, + TInt aLine, + TInt aResult = 0, + TInt aExpected1 = 0, + TInt aExpected2 = 0, + TInt aExpected3 = 0, + TInt aExpected4 = 0, + TInt aExpected5 = 0 ); + + /** + * Add thread handle to Array. Via array can handle test interference + * thread's kill in panic etc. cases + */ + TInt AddInterferenceThread( RThread aSTIFTestInterference ); + + /** + * Remove thread handle from Array.Test interference thread is stopped + * and killed successfully + */ + TInt RemoveInterferenceThread( RThread aSTIFTestInterference ); + + /** + * With this can be stored information about test measurement + * to TestServer space. + */ + TInt HandleMeasurementProcess( CSTIFTestMeasurement::TStifMeasurementStruct aSTIFMeasurementInfo ); + + /** + * Get measurement option(s) given from initialization file etc. + */ + IMPORT_C TInt GetMeasurementOptions( TInt& aOptions ); + + /** + * Use with TAL, TA1L, TA2L, TA3L, TA4L and TA5L macros to allow + * results. + * Set test case allow result given by user. In TestScripter cases allow + * result can set by 'allownextresult' or 'allowerrorcodes' keywords. In + * Normal and Hardcoded test modules allow result can be set with this + * method, reset should be done with ResetAllowResult method. + */ + IMPORT_C TInt SetAllowResult( TInt aResult ); + + /** + * This is mainly used by STIF's TAL-TA5L macros internally. + * Check is macros result allowed result. + */ + IMPORT_C TInt CheckAllowResult( TInt aResult ); + + /** + * Use with TAL, TA1L, TA2L, TA3L, TA4L and TA5L macros to reset allowed + * results. + * Reset allow result(s) given with SetAllowResult. In TestScripter + * cases this will be called automatically by STIF. Normal and Hardcoded + * cases this should be called by user. + */ + IMPORT_C TInt ResetAllowResult(); + + /** + * StopExecution function is used to stop the execution of test case. + */ + IMPORT_C TInt StopExecution(TStopExecutionType aType, TInt aCode = KErrNone); + + /** + * SendTestModuleVersion method is used to pass version of test module + * to test engine + */ + IMPORT_C TInt SendTestModuleVersion(TVersion aVersion, TFileName aModuleName); + + /** + * SendTestModuleVersion method is used to pass version of test module + * to test engine. This version with 3 parameters were added because version with + * 2 parameters has arguments passed by value which is incorrect. So the third argument + * was added only to overload the method and enable test modules using "old" version + * (with 2 parameters) to work. Only this version (with three parameters) should be used. + */ + IMPORT_C TInt SendTestModuleVersion(TVersion& aVersion, const TDesC& aModuleName, TBool aNewVersion); + + /** + * Command function is used to send command to test engine. + * It was created to provide possibility to kill test case by itself. + */ + TInt Command(TCommand aCommand, const TDesC8& aParamsPckg); + + /** + * GetTestCaseTitleL function is used to obtain test case title. + */ + IMPORT_C void GetTestCaseTitleL(TDes& aTestCaseTitle); + + /** + * Checks if testserver supports UI testing + */ + IMPORT_C TBool UITesting(); + + /** + * Gets UIEnvProxy + */ + IMPORT_C CUiEnvProxy* GetUiEnvProxy(); + + /** + * + */ + IMPORT_C TBool SeperateProcesses(); + + /** + * Gets CScriptBase + */ + IMPORT_C CScriptBase* GetObjFrmCaseDict(const TDesC& aObjectId); + + public: // Functions from base classes + + protected: // New functions + + /** + * Get TScriptObject + */ + IMPORT_C TScriptObject* GetTestObjFromCaseDict(const TDesC& aObjectId) const; + + /* + * Delete Test Object + */ + IMPORT_C void DelTestObjFromCaseDict(const TDesC& aObjectId); + + /** + * Add Test Object + */ + IMPORT_C void AddTestObjToCaseDictL(TScriptObject* aObject); + + protected: // Functions from base classes + + private: + + /** + * C++ default constructor. + */ + CTestModuleIf( CTestThreadContainer* aTestExecution ); + + /** + * By default Symbian OS constructor is private. + */ + void ConstructL( CTestModuleBase* aTestModule ); + + /** + * Destructor is also private. + * ONLY friend CTestModuleBase can delete CTestModuleIf. + */ + ~CTestModuleIf(); + + /** + * Check that server is alive. + */ + TBool IsServerAlive(); + + protected: // Data + + private: // Data + CTestThreadContainer* iTestExecution; + + // Indicates is reboot operation ready to start. + TBool iIsRebootReady; + + // Indicated StoreState() method's call times. + TInt iStoreStateCounter; + + // Test case allowed results. Array is a static one for avoid dynamic + // allocations. + TInt iTestCaseResults[KSTIFMacroResultArraySize]; + // Test case allowed results count. This is used with + // iTestCaseResults array. + TInt iAllowTestCaseResultsCount; + + public: //Data + TInt iNumberInGlbDict; + public: // Friend classes + + protected: // Friend classes + + private: // Friend classes + friend class CTestModuleBase; + friend class CTestScripter; + + }; + + +// CLASS DECLARATION + +// DESCRIPTION +// Base class for test module parameters. According to parameters may +// configure test module. e.g. heap and stack configuring. +class CTestModuleParam : public CBase + { + + public: // Enumerations + + /** + * Evolution version for test module parameters. + **/ + enum TParameterVersio + { + EVersio1 = 1, // For heap and stack configuring. + EVersio2 = 2, // For future needs. + EVersio3 = 3, // For future needs. + EVersio4 = 4, // For future needs. + EVersio5 = 5, // For future needs. + + }; + + private: // Enumerations + + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + //IMPORT_C static CTestModuleParam* NewL(); + + /** + * + */ + //IMPORT_C ~CTestModuleParam(); + + public: // New functions + + /** + * + */ + virtual TInt Version() = 0; + + public: // Functions from base classes + + protected: // New functions + + protected: // Functions from base classes + + private: + + /** + * C++ default constructor. + */ + //CTestModuleParam(); + + /** + * By default Symbian OS constructor is private. + */ + //void ConstructL(); + + public: //Data + + protected: // Data + + private: // Data + + public: // Friend classes + + protected: // Friend classes + + private: // Friend classes + + }; + +// CLASS DECLARATION + +// DESCRIPTION +// CTestModuleParamVer01 implements evolution version 1 for test module's +// heap and stack configuring. +class CTestModuleParamVer01 : public CTestModuleParam + { + public: // Enumerations + + private: // Enumerations + + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + IMPORT_C static CTestModuleParamVer01* NewL(); + //IMPORT_C CTestModuleParamVer01* NewL(); + + /** + * C++ default constructor. + */ + CTestModuleParamVer01(); + + /** + * Destructor. + */ + IMPORT_C ~CTestModuleParamVer01(); + + private: // Constructors and destructor + + /** + * By default Symbian OS constructor is private. + */ + void ConstructL(); + + public: // New functions + + /** + * + */ + inline TInt Version() { return iVersio; }; + + public: // Functions from base classes + + protected: // New functions + + protected: // Functions from base classes + + private: + + public: // Data + + /** + * Test thread stack size defined by user. + **/ + TInt iTestThreadStackSize; + + /** + * Test thread heap minimum size defined by user. + **/ + TInt iTestThreadMinHeap; + + /** + * Test thread heap maximum size defined by user. + **/ + TInt iTestThreadMaxHeap; + + protected: // Data + + private: // Data + + /** + * + **/ + TInt iVersio; + + public: // Friend classes + + protected: // Friend classes + + private: // Friend classes + + }; + +// CLASS DECLARATION + +// DESCRIPTION +// Test Module inherits the CTestModuleBase class that is used to provide +// simple interface between Test Engine and Test Module. CTestModuleBase +// consists of pure virtual methods that the Test Module shall implement +// and virtual methods that the Test Module should implement. +class CTestModuleBase + :public CBase + { + public: // Enumerations + + // For OOM execution + enum TOOMFailureType + { + EFailNext + }; + private: // Enumerations + + public: // Version query. + + /** + * Returns the API version which this test module complies. + * Test Framework uses this function to verify that loaded module + * can be used in current framework release. + * + * Note that this function must always be the very first function + * that is defined in CTestModuleBase. + */ + virtual inline TVersion Version() + { return TVersion ( KTestModuleAPIMajor, + KTestModuleAPIMinor, + KTestModuleAPIBuild); } + + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CTestModuleBase(): iTestModuleIf(0) {}; + + /** + * Destructor. + */ + virtual ~CTestModuleBase(){ delete iTestModuleIf; }; + + public: // New functions + + /** + * InitL is used to initialize the Test Module. The Test Modules may + * use the initialization file to read parameters for Test Module + * initialization but they can also have their own configure file or + * some other routine to initialize themselves. + * This method is virtual and it is not mandatory to implement it + * to Test Module. + */ + virtual TInt InitL( TFileName& /* aIniFile */, + TBool /* aFirstTime */ ) + { return KErrNone; }; + + /** + * Test cases are inquired from the Test Module by calling + * GetTestCasesL. Test cases may be read from the testcase file + * specified by aTestCaseFile or they can be e.g. hardcoded to testmodule. + * If the Test Module does not use testcase files for test case + * definition it does not use aTestCaseFile parameter. Test cases are + * appended to RPointerArray that is a list + * consisting of several TTestCaseInfo objects. + * The STIF Test Framework will be the owner of the objects stored to + * RPointerArray after the GetTestCasesL has appended them to the list + * and it does the memory deallocation. + * This method is pure virtual and the Test Module must implement it. + */ + virtual TInt GetTestCasesL( const TFileName& aTestCaseFile, + RPointerArray& aTestCases ) = 0; + + /** + * RunTestCaseL is used to run an individual test case specified + * by aCaseNumber and aTestCaseFile (optional). + * This method is synchronous and test case result is returned as + * reference parameter aResult value. + * The function shall return KErrNone if case is started succesfully. + * If test case is not available (i.e invalid testcase file or + * or case number), then function shall return KErrNotFound. In other + * error situations another Symbian error code is returned. + * This method is pure virtual and the Test Module must implement it. + */ + virtual TInt RunTestCaseL( const TInt aCaseNumber, + const TFileName& aTestCaseFile, + TTestResult& aResult ) = 0; + + /** + * TestModuleIf returns the handle to the CTestModuleIf interface. + * This is an utility function that can be used if the upper layer + * interface is needed to be used. + * This method must not be called from the constructor of Test Module + * that derives the CTestModuleBase. + */ + inline CTestModuleIf& TestModuleIf(){ return *iTestModuleIf; }; + + /** + * Used to perform the test environment setup for a particular OOM test + * case. The Test Modules may use the initialization file to read parameters + * for Test Module initialization but they can also have their own + * configure file or some other routine to initialize themselves. + * + * This method is virtual and will be implemented if test case is to be + * executed using OOM conditions. + */ + virtual void OOMTestInitializeL( const TFileName& /* aTestCaseFile */, + const TInt /* aCaseNumber */ ) {}; + + /** + * Used to perform the test environment cleanup for a particular OOM + * test case. + * + * This method is virtual and will be implemented if test case is to be + * executed using OOM conditions. + */ + virtual void OOMTestFinalizeL( const TFileName& /* aTestCaseFile */, + const TInt /* aCaseNumber */ ) {}; + + /** + * Used to check if a particular Test Case should be run in OOM + * conditions and which memory allocations should fail. + * Method returns ETrue if test is should run in OOM conditions, EFalse + * otherwise. + * + * This method is virtual and will be implemented if test case is to be + * executed using OOM conditions. + */ + virtual TBool OOMTestQueryL( const TFileName& /* aTestCaseFile */, + const TInt /* aCaseNumber */, + TOOMFailureType& aFailureType, + TInt& /* aFirstMemFailure */, + TInt& /* aLastMemFailure */ ) + { + aFailureType = EFailNext; + return EFalse; + }; + + /** + * Used in OOM testing only. Provides a way to the derived TestModule to + * handle warnings related to non-leaving or TRAPped allocations. + * + * In some cases the allocation should be skipped, either due to problems + * in the OS code or components used by the code being tested, or even + * inside the tested components which are implemented this way on purpose + * (by design), so it is important to give the tester a way to bypass + * allocation failures. + * + * This method is virtual and will be implemented if test case is to be + * executed using OOM conditions. + */ + virtual void OOMHandleWarningL( const TFileName& /* aTestCaseFile */, + const TInt /* aCaseNumber */, + TInt& /* aFailNextValue */) {}; + + public: // Functions from base classes + + protected: // New functions + + protected: // Functions from base classes + + private: + + public: // Data + + protected: // Data + + private: // Data + CTestModuleIf* iTestModuleIf; + + public: // Friend classes + + protected: // Friend classes + + private: // Friend classes + friend class CTestModuleIf; + friend class CTestModuleParam; + friend class MSTIFTestInterference; + friend class CSTIFInterferenceThread; + friend class CSTIFTestMeasurement; + + }; + +#endif // TESTMODULE_H + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/inc/StifUnitGeneric.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/inc/StifUnitGeneric.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,473 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: STIFUnit module declaration +* +*/ + +#ifndef StifUnitGeneric_H +#define StifUnitGeneric_H + +// INCLUDES +#include +//#include "StifTestModule.h" +#include +#include +#include + +// INCLUDES FROM CASES FILE +#define STIF_UNIT_INCLUDE_SECTION +#include STIF_UNIT_TEST_CASES +#undef STIF_UNIT_INCLUDE_SECTION + +// FORWARD DECLARATIONS +class STIF_UNIT_MODULE_CLASS_NAME; + +// DATA TYPES +// A typedef for function that does the actual testing, +// function is a type +// TInt STIF_UNIT_MODULE_CLASS_NAME:: ( TTestResult& aResult ) +typedef TInt (STIF_UNIT_MODULE_CLASS_NAME::* TestFunction)(TTestResult&); + +// CLASS DECLARATION +/** +* An internal structure containing a test case name and +* the pointer to function doing the test +* +* @lib ?library +* @since ?Series60_version +*/ +class TCaseInfoInternal + { + public: + const TText* iCaseName; + TestFunction iMethod; + TBool iIsOOMTest; + TInt iFirstMemoryAllocation; + TInt iLastMemoryAllocation; + }; + +// CLASS DECLARATION +/** +* A structure containing a test case name and +* the pointer to function doing the test +* +* @lib ?library +* @since ?Series60_version +*/ +class TCaseInfo + { + public: + TPtrC iCaseName; + TestFunction iMethod; + TBool iIsOOMTest; + TInt iFirstMemoryAllocation; + TInt iLastMemoryAllocation; + + TCaseInfo( const TText* a ) : iCaseName( (TText*) a ) + { + }; + + }; + +// CLASS DECLARATION +/** +* STIFUnit class (name of the class is changed by real module name). +*/ +NONSHARABLE_CLASS(STIF_UNIT_MODULE_CLASS_NAME) : public CTestModuleBase + { + public: //Enums + + public: // Constructors and destructor + + + /** + * Two-phased constructor. + */ + static STIF_UNIT_MODULE_CLASS_NAME* NewL() + { + STIF_UNIT_MODULE_CLASS_NAME* self = new (ELeave) STIF_UNIT_MODULE_CLASS_NAME; + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + + return self; + } + + /** + * Destructor. + */ + virtual ~STIF_UNIT_MODULE_CLASS_NAME() + { + delete iLog; + } + + + public: // New functions + + /** + * ?member_description. + * @since ?Series60_version + * @param ?arg1 ?description + * @return ?description + */ + //?type ?member_function( ?type ?arg1 ); + + public: // Functions from base classes + + /** + * From CTestModuleBase InitL is used to initialize the + * STIFUnit module. It is called once for every instance of + * TestModuleUnit after its creation. + * @param aIniFile Initialization file for the test module (optional) + * @param aFirstTime Flag is true when InitL is executed for first + * created instance of STIFUnit module. + * @return Symbian OS error code + */ + TInt InitL( TFileName& /*aIniFile*/, TBool /*aFirstTime*/ ) + { + return KErrNone; + } + + /** + * From CTestModuleBase GetTestCasesL is used to inquiry test cases + * from STIFUnit module. + * @since ?Series60_version + * @param aTestCaseFile Test case file (optional) + * @param aTestCases Array of TestCases returned to test framework + * @return Symbian OS error code + */ + TInt GetTestCasesL( const TFileName& /*aTestCaseFile*/, + RPointerArray& aTestCases ) + { + TTestResult dummyResult; + return MainTestL(EEnumerateTestCases, -1, aTestCases, dummyResult); + } + + /** + * From CTestModuleBase RunTestCaseL is used to run an individual + * test case. + * @since ?Series60_version + * @param aCaseNumber Test case number + * @param aTestCaseFile Test case file (optional) + * @param aResult Test case result returned to test framework (PASS/FAIL) + * @return Symbian OS error code (test case execution error, which is + * not reported in aResult parameter as test case failure). + */ + TInt RunTestCaseL( const TInt aCaseNumber, + const TFileName& /*aTestCaseFile*/, + TTestResult& aResult ) + { + if(!iVersionLogged) + { + SendTestModuleVersion(); + iVersionLogged = ETrue; + } + + RPointerArray aTestCases; //temporary + + // iNumberOfTestCases should contain valid number of test cases present in test module. This info + // is gathered in the enumeration procedure. + // However if test case crashes, test module is loaded again and enumeration is not performed. + // In such case counting procedure must be done. + if(iNumberOfTestCases == 0) + { + TRAPD(errCount, MainTestL(ECountTestCases, aCaseNumber, aTestCases, aResult)); + if(errCount != KErrNone) + { + iLog->Log(_L("Error during counting test cases [%d]"), errCount); + return errCount; + } + } + + /** + * SetupL is responsible for inicialization of all fields (etc.) common for all testcases + * MainTestL starts required testcase + * TeardownL destroys all data that was created by SetupL + */ + TInt errSetup = KErrNone; + TInt errTestcase = KErrNone; + + if(aCaseNumber > iNumberOfTestCases) + return KErrNotFound; + + __UHEAP_MARK; + + TRAP(errSetup, MainTestL(ERunTestCase, STIF_RUN_SETUP, aTestCases, aResult); TRAP(errTestcase, MainTestL(ERunTestCase, aCaseNumber, aTestCases, aResult))\ + MainTestL(ERunTestCase, STIF_RUN_TEARDOWN, aTestCases, aResult)); + + __UHEAP_MARKEND; + + if(errTestcase != KErrNone) + { + aResult.SetResult(errTestcase, _L("Testcase failed")); + } + if(errSetup != KErrNone) + { + aResult.SetResult(errSetup, _L("Setup or teardown failed")); + } + + return KErrNone; + } + + /** + * From CTestModuleBase; OOMTestQueryL is used to specify is particular + * test case going to be executed using OOM conditions + * @param aTestCaseFile Test case file (optional) + * @param aCaseNumber Test case number (optional) + * @param aFailureType OOM failure type (optional) + * @param aFirstMemFailure The first heap memory allocation failure value (optional) + * @param aLastMemFailure The last heap memory allocation failure value (optional) + * @return TBool + */ + #ifdef STIFUNIT_OOMTESTQUERYL + virtual TBool OOMTestQueryL( const TFileName& aTestCaseFile, + const TInt aCaseNumber, + TOOMFailureType& aFailureType, + TInt& aFirstMemFailure, + TInt& aLastMemFailure); + #else + virtual TBool OOMTestQueryL( const TFileName& /* aTestCaseFile */, + const TInt /* aCaseNumber */, + TOOMFailureType& /* aFailureType */, + TInt& /* aFirstMemFailure */, + TInt& /* aLastMemFailure */ ) + { + return EFalse; + } + #endif + + /** + * From CTestModuleBase; OOMTestInitializeL may be used to initialize OOM + * test environment + * @param aTestCaseFile Test case file (optional) + * @param aCaseNumber Test case number (optional) + * @return None + */ + #ifdef STIFUNIT_OOMTESTINITIALIZEL + virtual void OOMTestInitializeL( const TFileName& aTestCaseFile, + const TInt aCaseNumber); + #else + virtual void OOMTestInitializeL( const TFileName& /* aTestCaseFile */, + const TInt /* aCaseNumber */ ) + { + } + #endif + + /** + * From CTestModuleBase; OOMHandleWarningL + * @param aTestCaseFile Test case file (optional) + * @param aCaseNumber Test case number (optional) + * @param aFailNextValue FailNextValue for OOM test execution (optional) + * @return None + * + * User may add implementation for OOM test warning handling. Usually no + * implementation is required. + */ + #ifdef STIFUNIT_OOMHANDLEWARNINGL + virtual void OOMHandleWarningL( const TFileName& aTestCaseFile, + const TInt aCaseNumber, + TInt& aFailNextValue); + #else + virtual void OOMHandleWarningL( const TFileName& /* aTestCaseFile */, + const TInt /* aCaseNumber */, + TInt& /* aFailNextValue */) + { + } + #endif + + /** + * From CTestModuleBase; OOMTestFinalizeL may be used to finalize OOM + * test environment + * @param aTestCaseFile Test case file (optional) + * @param aCaseNumber Test case number (optional) + * @return None + * + */ + #ifdef STIFUNIT_OOMTESTFINALIZEL + virtual void OOMTestFinalizeL( const TFileName& aTestCaseFile, + const TInt aCaseNumber); + #else + virtual void OOMTestFinalizeL( const TFileName& /* aTestCaseFile */, + const TInt /* aCaseNumber */ ) + { + } + #endif + + /** + * Method used to log version of test module + */ + void SendTestModuleVersion() + { + TVersion moduleVersion; + moduleVersion.iMajor = TEST_MODULE_VERSION_MAJOR; + moduleVersion.iMinor = TEST_MODULE_VERSION_MINOR; + moduleVersion.iBuild = TEST_MODULE_VERSION_BUILD; + + TFileName moduleName; + moduleName = STIF_UNIT_MODULE_NAME; + + TBool newVersionOfMethod = ETrue; + TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod); + } + + protected: // New functions + + /** + * ?member_description. + * @since ?Series60_version + * @param ?arg1 ?description + * @return ?description + */ + //?type ?member_function( ?type ?arg1 ); + + protected: // Functions from base classes + + /** + * From ?base_class ?member_description + */ + //?type ?member_function(); + + private: + + /** + * C++ default constructor. + */ + STIF_UNIT_MODULE_CLASS_NAME() + { + } + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL() + { + iLog = CStifLogger::NewL( KUnitLogPath, KUnitLogFile); + + // Sample how to use logging + iLog->Log( KLogStart ); + + iVersionLogged = EFalse; + iNumberOfTestCases = 0; + } + + /** + * Method containing all test cases, setup and teardown sections. + */ + TInt MainTestL(TCallReason aRunReason, TInt aTestToRun, RPointerArray& aTestCases, TTestResult& aResult) + { + aResult.iResult = aResult.iResult; //for avoiding compiler warning when unit test does not use any assert macro + if(aRunReason == ERunTestCase) + { + if(aTestToRun < 0) + { + iLog->Log(_L("Running setup or teardown")); + } + else + { + iLog->Log(_L("Running test case #%d"), aTestToRun); + } + } + else if(aRunReason == EEnumerateTestCases) + { + iLog->Log(_L("Enumerating test cases.")); + } + else if(aRunReason == ECountTestCases) + { + iLog->Log(_L("Counting test cases.")); + } + else + { + iLog->Log(_L("Unknown run reason [%d]."), aRunReason); + return KErrNotSupported; + } + + TInt _test_case_no = -1; + + //test cases, setup and teardown include + #define TEST_CASES + #include STIF_UNIT_TEST_CASES + #undef TEST_CASES + + if(aRunReason == EEnumerateTestCases) + { + iNumberOfTestCases = _test_case_no; + iLog->Log(_L("Enumeration completed.")); + } + else if(aRunReason == ECountTestCases) + { + iNumberOfTestCases = _test_case_no; + iLog->Log(_L("Counting completed.")); + } + + // Test case was executed + return KErrNone; + } + + public: // Data + // ?one_line_short_description_of_data + //?data_declaration; + + protected: // Data + // ?one_line_short_description_of_data + //?data_declaration; + + private: // Data + // Pointer to test (function) to be executed + TestFunction iMethod; + + // Pointer to logger + CStifLogger * iLog; + + // Flag saying if version of test module was already sent + TBool iVersionLogged; + // Total number of test cases + TInt iNumberOfTestCases; + + // ?one_line_short_description_of_data + //?data_declaration; + + // Reserved pointer for future extension + //TAny* iReserved; + + #define TEST_VAR_DECLARATIONS + /** + * all testmodule-global variables declarations are inserted here + */ + #include STIF_UNIT_TEST_CASES + #undef TEST_VAR_DECLARATIONS + + public: // Friend classes + //?friend_class_declaration; + protected: // Friend classes + //?friend_class_declaration; + private: // Friend classes + //?friend_class_declaration; + + }; + +EXPORT_C CTestModuleBase* LibEntryL() + { + return STIF_UNIT_MODULE_CLASS_NAME::NewL(); + } + +EXPORT_C TInt SetRequirements( CTestModuleParam*& /*aTestModuleParam*/, + TUint32& /*aParameterValid*/ ) + { + return KErrNone; + } + +#endif // StifUnitGeneric_H + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/inc/StifUnitMacros.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/inc/StifUnitMacros.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,215 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: STIFUnit macros declarations +* +*/ + +#ifndef STIFUnit_MACROS_H +#define STIFUnit_MACROS_H + +// Enumeration types +// Reason for running test method +enum TCallReason + { + EEnumerateTestCases, + ERunTestCase, + ECountTestCases, //Used to count test cases. + //This should be already done by enumerating procedure, + //however in case of test crash all internal data are + //being lost. + }; + + +// Strings +_LIT( KAssertFailedEquals, "AssertEquals Failed [F:%s][L:%d]" ); +_LIT( KAssertFailedNotEquals, "AssertNotEquals Failed [F:%s][L:%d]" ); +_LIT( KAssertFailedNull, "AssertNull Failed [F:%s][L:%d]" ); +_LIT( KAssertFailedNotNull, "AssertNotNull Failed [F:%s][L:%d]" ); +_LIT( KAssertFailedSame, "AssertSame Failed [F:%s][L:%d]" ); +_LIT( KAssertFailedNotSame, "AssertNotSame Failed [F:%s][L:%d]" ); +_LIT( KAssertFailedTrue, "AssertTrue Failed [F:%s][L:%d]" ); +_LIT( KAssertFailedFalse, "AssertFalse Failed [F:%s][L:%d]" ); +_LIT( KAssertFailedNotLeaves, "AssertNotLeaves Failed [F:%s][L:%d]" ); +_LIT( KAssertFailedLeaves, "AssertLeaves Failed [F:%s][L:%d]" ); +_LIT( KAssertFailedLeavesWith, "AssertLeavesWith Failed [F:%s][L:%d]" ); + + +#ifdef _UNICODE + #define __STIF_WIDEN2(x) L ## x + #define __STIF_WIDEN(x) __STIF_WIDEN2(x) + #define __STIF_DBG_FILE__ __STIF_WIDEN(__FILE__) +#else + #define __STIF_DBG_FILE__ __FILE__ +#endif + + +// Logs to the STIF log file AND to the RDebug +#define STIF_LOG( aMessage ) \ + iLog->Log( _L( aMessage ) ); RDebug::Print( _L( aMessage ) ); + + +// Defines a separate test case which consists of two blocks - one for enumeration of test cases +// second for running the testcase. +#define STIF_TESTDEFINE( aTestName ) \ +_test_case_no++; \ +if( aRunReason == EEnumerateTestCases ) \ + { \ + TTestCaseInfo* newCase = new( ELeave ) TTestCaseInfo(); \ + CleanupStack::PushL( newCase ); \ + newCase->iCaseNumber = _test_case_no; \ + newCase->iTitle.Copy( _L( #aTestName ) ); \ + User::LeaveIfError(aTestCases.Append ( newCase ) ); \ + CleanupStack::Pop( newCase ); \ + } \ +else if(aRunReason == ERunTestCase && _test_case_no == aTestToRun) + +#define STIF_RUN_SETUP -1 +#define STIF_RUN_TEARDOWN -2 + +// Defines a setup section of MainTestL method +#define STIF_SETUP \ + if( aRunReason == ERunTestCase && aTestToRun == STIF_RUN_SETUP ) + +// Defines a teardown section of MainTestL method +#define STIF_TEARDOWN \ + if( aRunReason == ERunTestCase && aTestToRun == STIF_RUN_TEARDOWN ) + +/********************************************************************************* + * Assert Macros + *********************************************************************************/ +#define __STIF_ASSERT_SHARED( aFunction, aMessage ) \ + if(!aFunction) \ + { \ + iLog->Log( aMessage, __STIF_DBG_FILE__, __LINE__ );\ + aResult.SetResult( KErrGeneral, _L("Testcase failed"));\ + User::Leave( KErrGeneral );\ + } + +#define __STIF_ASSERT_SHARED_DESC( aFunction, aMessage, aDesc ) \ + if(!aFunction) \ + { \ + iLog->Log( aMessage, __STIF_DBG_FILE__, __LINE__ );\ + aResult.SetResult( KErrGeneral, aDesc );\ + User::Leave( KErrGeneral );\ + } \ + else \ + { \ + aResult.SetResult( KErrNone, aDesc ); \ + } + + + +#define STIF_ASSERT_EQUALS( aExpected, aActual ) \ + __STIF_ASSERT_SHARED( AssertEquals( aExpected, aActual ) , KAssertFailedEquals ); + +#define STIF_ASSERT_EQUALS_DESC( aExpected, aActual, aDescription ) \ + __STIF_ASSERT_SHARED_DESC( AssertEquals( aExpected, aActual ) , KAssertFailedEquals, aDescription ); + +#define STIF_ASSERT_NOT_EQUALS( aExpected, aActual ) \ + __STIF_ASSERT_SHARED( !AssertEquals( aExpected, aActual ) , KAssertFailedNotEquals ); + +#define STIF_ASSERT_NOT_EQUALS_DESC( aExpected, aActual, aDescription ) \ + __STIF_ASSERT_SHARED_DESC( !AssertEquals( aExpected, aActual ) , KAssertFailedNotEquals, aDescription ); + +#define STIF_ASSERT_NULL( aPtr ) \ + __STIF_ASSERT_SHARED( AssertNull( aPtr ), KAssertFailedNull ); + +#define STIF_ASSERT_NULL_DESC( aPtr, aDescription ) \ + __STIF_ASSERT_SHARED_DESC( AssertNull( aPtr ), KAssertFailedNull, aDescription ); + +#define STIF_ASSERT_NOT_NULL( aPtr ) \ + __STIF_ASSERT_SHARED( !AssertNull( aPtr ), KAssertFailedNotNull ); + +#define STIF_ASSERT_NOT_NULL_DESC( aPtr, aDescription ) \ + __STIF_ASSERT_SHARED_DESC( !AssertNull( aPtr ), KAssertFailedNotNull, aDescription ); + +#define STIF_ASSERT_SAME( aExpectedPtr, aActualPtr ) \ + __STIF_ASSERT_SHARED( AssertSame( aExpectedPtr, aActualPtr ), KAssertFailedSame ); + +#define STIF_ASSERT_SAME_DESC( aExpectedPtr, aActualPtr, aDescription ) \ + __STIF_ASSERT_SHARED_DESC( AssertSame( aExpectedPtr, aActualPtr ), KAssertFailedSame, aDescription ); + +#define STIF_ASSERT_NOT_SAME( aExpectedPtr, aActualPtr) \ + __STIF_ASSERT_SHARED( !AssertSame( aExpectedPtr, aActualPtr ), KAssertFailedNotSame ); + +#define STIF_ASSERT_NOT_SAME_DESC( aExpectedPtr, aActualPtr, aDescription ) \ + __STIF_ASSERT_SHARED_DESC( !AssertSame( aExpectedPtr, aActualPtr ), KAssertFailedNotSame, aDescription ); + +#define STIF_ASSERT_TRUE( aCondition ) \ + __STIF_ASSERT_SHARED( AssertTrue( aCondition ), KAssertFailedTrue ); + +#define STIF_ASSERT_TRUE_DESC( aCondition, aDescription ) \ + __STIF_ASSERT_SHARED_DESC( AssertTrue( aCondition ), KAssertFailedTrue, aDescription ); + +#define STIF_ASSERT_FALSE( aCondition ) \ + __STIF_ASSERT_SHARED( !AssertTrue( aCondition ), KAssertFailedFalse ); + +#define STIF_ASSERT_FALSE_DESC( aCondition, aDescription ) \ + __STIF_ASSERT_SHARED_DESC( !AssertTrue( aCondition), KAssertFailedFalse, aDescription ); + +// Eclosing block is used to create the scope for the __leaveValue +#define STIF_ASSERT_NOT_LEAVES( aStatement ) \ + { \ + TRAPD( __leaveValue, aStatement ); \ + __STIF_ASSERT_SHARED( AssertEquals( __leaveValue, KErrNone ), KAssertFailedNotLeaves ); \ + } + +#define STIF_ASSERT_NOT_LEAVES_DESC( aStatement, aDescription ) \ + { \ + TRAPD( __leaveValue, aStatement ); \ + __STIF_ASSERT_SHARED_DESC( AssertEquals( __leaveValue, KErrNone ), KAssertFailedNotLeaves, aDescription ); \ + } + +// Eclosing block is used to create the scope for the __leaveValue +#define STIF_ASSERT_LEAVES( aStatement ) \ + { \ + TRAPD( __leaveValue, aStatement ); \ + __STIF_ASSERT_SHARED( !AssertEquals( __leaveValue, KErrNone ), KAssertFailedLeaves ); \ + } + +#define STIF_ASSERT_LEAVES_DESC( aStatement, aDescription ) \ + { \ + TRAPD( __leaveValue, aStatement ); \ + __STIF_ASSERT_SHARED_DESC( !AssertEquals( __leaveValue, KErrNone ), KAssertFailedLeaves, aDescription ); \ + } + +// Eclosing block is used to create the scope for the __leaveValue +#define STIF_ASSERT_LEAVES_WITH( aLeaveCode, aStatement ) \ + { \ + TRAPD( __leaveValue, aStatement ); \ + __STIF_ASSERT_SHARED( AssertEquals( __leaveValue, aLeaveCode ), KAssertFailedLeaves ); \ + } + +#define STIF_ASSERT_LEAVES_WITH_DESC( aLeaveCode, aStatement, aDescription ) \ + { \ + TRAPD( __leaveValue, aStatement ); \ + __STIF_ASSERT_SHARED_DESC( AssertEquals( __leaveValue, aLeaveCode ), KAssertFailedLeaves, aDescription ); \ + } + +#define STIF_ASSERT_PANIC( aPanicCode, aStatement ) \ + { \ + TestModuleIf().SetExitReason( CTestModuleIf::EPanic, aPanicCode ); \ + aStatement; \ + } + +#define STIF_ASSERT_PANIC_DESC( aPanicCode, aStatement, aDescription ) \ + { \ + TestModuleIf().SetExitReason( CTestModuleIf::EPanic, aPanicCode ); \ + aResult.SetResult(KErrNone, aDescription); \ + aStatement; \ + } + +#include + +#endif diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/inc/StifUnitUtils.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/inc/StifUnitUtils.inl Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,98 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +template +inline TBool AssertEquals(const T& aExpected, const T& aActual) +/** + * AssertEquals + * + * @prototype + * @test + * + * @param aExpected - Expected result + * @param aActual - Actual result + * @return - True if equal + */ + { + if( aExpected==aActual ) + { + return ETrue; + } + return EFalse; + } + +template +inline TBool AssertNull(const T* aPtr) +/** + * AssertNull + * + * @prototype + * @test + * + * @param aPtr - Pointer + * @return - True if NULL + */ + { + if( aPtr==NULL ) + { + return ETrue; + } + return EFalse; + } + +template +inline TBool AssertSame(const T* aExpectedPtr, const T* aActualPtr) +/** + * AssertSame + * + * @prototype + * @test + * + * @param aExpectedPtr - Expected pointer + * @param aActualPtr - Actual pointer + * @return - True if equal + */ + { + if( aExpectedPtr==aActualPtr ) + { + return ETrue; + } + return EFalse; + } + +inline TBool AssertTrue(const TBool& aCondition) +/** + * AssertTrue + * + * @prototype + * @test + * + * @param aCondition - Condition + * @return - True if aCondition is true + */ + { + if( !aCondition ) + { + return EFalse; + } + return ETrue; + } + + + + +// End of File \ No newline at end of file diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/inc/TestEngineClient.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/inc/TestEngineClient.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,469 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the +* RTestEngineServer, RTestEngine and RTestCase. +* +*/ + +#ifndef TEST_ENGINE_CLIENT_H +#define TEST_ENGINE_CLIENT_H + +// INCLUDES +#include +#include +#include +#include +#include +#include + +#include +#include + +// CONSTANTS +// None + +// Start and end tags for STIF setting denitions +_LIT( KStifSettingsStartTag, "[StifSettings]" ); +_LIT( KStifSettingsEndTag, "[EndStifSettings]" ); +// Tag for cabs modifier name +_LIT( KCapsModifier, "CapsModifier=" ); +// Test module thread heap and stack names +_LIT( KUserDefStackSize, "TestThreadStackSize=" ); +_LIT( KUserDefMinHeap, "TestThreadMinHeap=" ); +_LIT( KUserDefMaxHeap, "TestThreadMaxHeap=" ); + +// MACROS +// None + +// DATA TYPES + +// Package for test case count, used in EnumerateTestCases method +typedef TPckgBuf TCaseCount; + +// A set of test engine settings which can be set/read by SettingServer +struct TEngineSettings + { + TInt iEngineSessionId; + TBool iUITestingSupport; + TBool iSeparateProcesses; + }; + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +// Template class delivering test cases from Test Module +template class CFixedFlatArray; + +// CLASS DECLARATION + +// DESCRIPTION +// RTestEngineServer is a client class of Test Engine Server +// The connect function starts the server, if is not already running. +// An RSessionBase sends messages to the server with +// the function RSessionBase::SendReceive(); +// specifying an opcode (TTestEngineReq) and array of argument pointers. + +class RTestEngine + : public RSessionBase + { + public: // Enumerations + enum TTestEngineAsyncRequest { EErrorNotification, EEvent }; + private: // Enumerations + + public: // Constructors and destructor + + public: // New functions + + /** + * Connect method creates new RTestEngineServer session that is used + * to manage the test case execution. + */ + IMPORT_C TInt Connect(); + + /** + * Version returns client side version number from the + * RTestEngineServer. + */ + IMPORT_C TVersion Version() const; + + /** + * Open creates a subsession to Test Engine and opens new handle to + * RTestEngine. The RTestEngineServer subsession shall be created by + * calling RTestEngineServer::Connect before calling Open to create new + * RTestEngine subsession. + */ + IMPORT_C TInt LoadConfiguration( const TFileName& aIniFile ); + + /** + * Closes the RTestEngine subsession. + */ + IMPORT_C void Close(); + + public: // New functions + + /** + * Sets attributes to Test Framework + */ + IMPORT_C TInt SetAttribute( TAttribute aAttribute, + const TDesC& aValue ); + + /** + * AddTestModule is used to add dynamically a new Test Module to the + * Test Framework. Test cases can then be run from the new Test Module + * without restarting the Test Framework. + * If the Test Module specified by aTestModule doesn't exists this + * method returns KErrNotFound. If the Test Module has been already + * loaded this method returns KErrAlreadyExists. + */ + IMPORT_C TInt AddTestModule( const TName& aTestModule, + const TFileName& aIniFile ); + + /** + * RemoveTestModule is used to remove the existing Test Module from Test + * Framework. If there are not test cases executing in the Test Module + * it will be shut down. + * If there is test case running from the Test Module this method + * returns KErrInUse. + * If the Test Module specified by aTestModule is not loaded this method + * returns KErrNotFound. + */ + IMPORT_C TInt RemoveTestModule( const TName& aTestModule ); + + /** + * AddConfigFile is used to add dynamically a new config file to the + * Test Module specified by aTestModule. New test cases are then + * executed by calling first GetTestCases and then RunTestCase. Thus + * new test cases can be run from the Test Module without restarting + * the Test Framework. + */ + IMPORT_C TInt AddConfigFile( const TName& aTestModule, + const TFileName& aConfigFile ); + + /** + * RemoveConfigFile is used to remove a config file from the + * Test Module specified by aTestModule. + */ + IMPORT_C TInt RemoveConfigFile( const TName& aTestModule, + const TFileName& aConfigFile ); + + /** + * Test cases are inquired by two-phased operation calling first the + * EnumerateTestCases method and then the GetTestCases. Test cases are + * inquired from Test Engine that will inquire them from Test Modules. + * EnumerateTestCases requests the needed array size for test cases that + * will be inquired by GetTestCases method. When the EnumerateTestCases + * is completed succesfully the GetTestCases method is called to + * retrieve test cases to CArrayFixFlat list object. + * + * TTestInfo defines individual test case and, if needed, a test set + * (TName iParent) where the test case belongs to. TTestInfo is used to + * create test case by calling RTestCase::Open that constructs the + * actual test case. Test case is then executed calling + * RTestCase::RunTestCase. + */ + IMPORT_C void EnumerateTestCases( TCaseCount& aCount, + TRequestStatus& aStatus ); + + /** + * GetTestCases retrieves test cases from Test Modules to + * aTestCaseBuffer that is a list consisting of several TTestInfo + * objects. If this method is called without previously succesfully + * called EnumerateTestCases method, this function returns the + * KErrNotReady. + */ + IMPORT_C TInt GetTestCases( + CFixedFlatArray& aTestCaseBuffer ); + + /** + * Asynchronous request can be canceled with CancelAsyncRequest method. + * The aReqToCancel parameter defines the request that will be canceled. + */ + IMPORT_C TInt CancelAsyncRequest( TTestEngineAsyncRequest aReqToCancel ); + + /** + * Event is used to get and set events in STIF Test Framework. + * TEventIf defines the event request information. + */ + IMPORT_C void Event( TEventIfPckg& aEvent, + TRequestStatus& aStatus ); + + /** + * Used to get Logger's overwrite parameters. + */ + IMPORT_C TInt OpenLoggerSession( TLoggerSettings& aLoggerSettings ); + + /** + * ErrorNotification obtains error notifications from test engine. + */ + IMPORT_C void ErrorNotification( TErrorNotificationPckg& aError, + TRequestStatus& aStatus ); + + /** + * Add info about test case to test report. + */ + IMPORT_C TInt AddTestCaseResultToTestReport(const TTestInfo& aTestInfo, + const TFullTestResult& aTestResult, + const TInt aError); + /** + * Update Log Configuration. + */ + IMPORT_C TInt UpdateLogConfiguration(TDesC& aLogConfigList); + /** + * Update Engine Configuration. + */ + IMPORT_C TInt UpdateEngineConfiguration(TDesC& aEngineConfigList); + + public: // Functions from base classes + + protected: // New functions + + protected: // Functions from base classes + + private: // New functions + + public: // Data + + protected: // Data + + private: // Data + + public: // Friend classes + + protected: // Friend classes + + private: // Friend classes + + }; + +// DESCRIPTION + +// RTestCase class represents a subsession with the RTestEngineServer. +// Each RTestCase corresponds to a specific CTestExecution (a CObject +// derived class) in the server. Messages are passed via the RTestEngineServer. +// A RTestCase stores a handle from it's server side CTestExecution, +// and uses this to identify the CTestExecution during communication. + +class RTestCase + : public RSubSessionBase + { + + public: // Structured classes + + public: // Enumerations + enum TTestCaseAsyncRequest { ERunTestCase, ENotifyProgress, ENotifyRemoteType, }; + + private: // Enumerations + + public: // Constructors and destructor + + /** + * Open creates a subsession for new test case. Test case is initialized + * using aTestCaseInfo parameter. The aTestCaseInfo is TTestInfoPckg + * that is a packaged TTestInfo. TTestInfo is got from the Test Engine + * by calling RTestEngine::GetTestCases method. + * If there was previously called RemoveTestModule for the Test Module + * that is defined in aTestCaseInfo this method returns KErrLocked. + * This means that new test cases cannot be run from this Test Module + * and the user should inquire test cases available calling + * RTestEngine::GetTestCases. + */ + IMPORT_C TInt Open( RTestEngine& aServer, + const TTestInfoPckg& aTestCaseInfo ); + + /** + * Closes the RTestCase subsession. Test case is normally closed + * immediately after the test case was completed. + */ + IMPORT_C void Close(); + + public: // New functions + + /** + * RunTestCase is asynchronous method and it is completed when the test + * case is completed. Result of the test case is returned to + * aTestResult. The aTestResult is TFullTestResultPckg that is a + * packaged TFullTestResult. + * The aStatus will have the completion result of this function. If the + * test case could be run (despite of succesfully or not) the KErrNone + * is returned to aStatus. + */ + IMPORT_C void RunTestCase( TFullTestResultPckg& aTestResult, + TRequestStatus& aStatus ); + + /** + * Pause suspends the execution of the test case. The subsession where + * the test case is run is suspended and thus the test case execution is + * suspended. Test case execution can be later resumed by calling + * Resume. + */ + IMPORT_C TInt Pause(); + + /** + * Resume is used to resume the test case suspended by previously called + * Pause method. The test case execution should be continued immediately + * when the Resume is called. + */ + IMPORT_C TInt Resume(); + + /** + * NotifyProgress requests different progress information from the test + * case execution. This information can be printed to UI. The progress + * information is returned to aProgress. The aProgress is + * TTestProgressPckg that is a packaged TTestProgress + */ + IMPORT_C void NotifyProgress( TTestProgressPckg& aProgress, + TRequestStatus& aStatus ); + + /** + * NotifyRemoteType requests enable message waiting. + */ + IMPORT_C void NotifyRemoteType( TStifCommandPckg& aType, + TPckg& aMsgSize, + TRequestStatus& aStatus ); + /** + * NotifyRemoteMsg gets messages. + */ + IMPORT_C TInt NotifyRemoteMsg( TDes8& aMessage, + TStifCommand aType ); + + /** + * Asynchronous request can be canceled with CancelAsyncRequest method. + * The aReqToCancel parameter defines the request that will be canceled. + */ + IMPORT_C TInt CancelAsyncRequest( TTestCaseAsyncRequest aReqToCancel ); + + public: // Functions from base classes + + protected: // New functions + + protected: // Functions from base classes + + private: // New functions + + public: // Data + + protected: // Data + + private: // Data + + public: // Friend classes + + protected: // Friend classes + + private: // Friend classes + + }; + +/* +------------------------------------------------------------------------------- + + DESCRIPTION + + This contains the CFixedFlatArray class definitions. + +------------------------------------------------------------------------------- +*/ +template +class CFixedFlatArray + :public CBase + { + public: // Enumerations + + private: // Enumerations + + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + inline static CFixedFlatArray* NewL(const TInt aSize); + + /** + * Destructor. + */ + inline ~CFixedFlatArray(); + + public: // New functions + + /** + * Return descriptor containing array. Used in server calls + */ + inline TPtr8& Des(); + + /** + * Returns CFixedFlatArray internal array. Used in server calls + */ + inline T& operator[] (TInt aIndex) const; + + /** + * Returns count + */ + inline TInt Count() const; + + /** + * Sets aBuf to array slot specified by aIndex + */ + inline void Set( TInt aIndex, T& aBuf ); + + public: // Functions from base classes + + protected: // New functions + + protected: // Functions from base classes + + private: + + /** + * By default Symbian OS constructor is private. + */ + inline void ConstructL(const TInt aSize); + + /** + * C++ default constructor. + */ + inline CFixedFlatArray(); + + /** + * Check that given index is correct. + */ + inline void CheckIndex( TInt aIndex ) const; + + protected: // Data + + private: // Data + // Array + T* iArray; + + // Count + TInt iCount; + + // Buffer + HBufC8* iBuffer; + TPtr8 iBufferPtr; + + public: // Friend classes + + protected: // Friend classes + + private: // Friend classes + + }; + +#include + + +#endif // TEST_ENGINE_CLIENT_H + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/inc/TestEngineClient.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/inc/TestEngineClient.inl Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,303 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains implementation of TestEngineClient's +* inline functions. +* +*/ + +#ifndef TEST_ENGINE_CLIENT_INL +#define TEST_ENGINE_CLIENT_INL + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION + +/* +------------------------------------------------------------------------------- + + Class:CFixedFlatArray + + Method: CFixedFlatArray + + Description: Default constructor + + C++ default constructor can NOT contain any code, that + might leave. + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Approved + +------------------------------------------------------------------------------- +*/ +template +CFixedFlatArray::CFixedFlatArray() : + iArray( NULL ), + iBufferPtr(0,0) + { + + } + +/* +------------------------------------------------------------------------------- + + Class: CFixedFlatArray + + Method: ConstructL + + Description: Symbian OS second phase constructor + + Symbian OS default constructor can leave. + + Parameters: const TInt aCount: in: Count of contents + + Return Values: None + + Errors/Exceptions: Leaves if memory allocation for iArray of iBuffer fails + + Status: Approved + +------------------------------------------------------------------------------- +*/ +template +void CFixedFlatArray::ConstructL( const TInt aCount ) + { + + iCount = aCount; + iArray = new (ELeave) T[iCount]; + + const TInt size = iCount * sizeof (T); + iBuffer = HBufC8::NewMaxL ( size ); + + iBufferPtr.Set( iBuffer->Des() ); + iBufferPtr.SetLength( size ); + iBufferPtr.Set( (TUint8*) iArray, size,size ); + + } + +/* +------------------------------------------------------------------------------- + + Class: CFixedFlatArray + + Method: NewL + + Description: Two-phased constructor. + + Parameters: None + + Return Values: CFixedFlatArray: Array of CFixedFlatArray objects + + Errors/Exceptions: Leaves if ConstructL leaves + + Status: Approved + +------------------------------------------------------------------------------- +*/ +template +CFixedFlatArray* CFixedFlatArray::NewL(TInt aSize) + { + CFixedFlatArray* self = new ( ELeave ) CFixedFlatArray(); + CleanupStack::PushL( self ); + self->ConstructL(aSize); + CleanupStack::Pop(); + return self; + + } + +/* +------------------------------------------------------------------------------- + + Class: CFixedFlatArray + + Method: ~CFixedFlatArray + + Description: Destructor + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Approved + +------------------------------------------------------------------------------- +*/ +template +CFixedFlatArray::~CFixedFlatArray() + { + delete[] iArray; + delete iBuffer; + + } + +/* +------------------------------------------------------------------------------- + + Class: CFixedFlatArray + + Method: Des + + Description: Returns descriptor for array + + Parameters: None + + Return Values: TPtr8&: Descriptor for array + + Errors/Exceptions: None + + Status: Approved + +------------------------------------------------------------------------------- +*/ +template +TPtr8& CFixedFlatArray::Des() + { + return iBufferPtr; + + } + +/* +------------------------------------------------------------------------------- + + Class: CFixedFlatArray + + Method: operator[] + + Description: Returns index operator + + Parameters: TInt aIndex: in: Index of object to be returned + + Return Values: T&: Reference to requested object + + Errors/Exceptions: Panics if aIndex is out of range + + Status: Approved + +------------------------------------------------------------------------------- +*/ +template +T& CFixedFlatArray::operator[] ( TInt aIndex ) const + { + CheckIndex( aIndex ); + + return iArray[aIndex]; + + } + +/* +------------------------------------------------------------------------------- + + Class: CFixedFlatArray + + Method: Count + + Description: Returns count + + Parameters: None + + Return Values: TInt: iCount + + Errors/Exceptions: None + + Status: Approved + +------------------------------------------------------------------------------- +*/ +template +TInt CFixedFlatArray::Count() const + { + return iCount; + + } + +/* +------------------------------------------------------------------------------- + + Class: CFixedFlatArray + + Method: Set + + Description: Set buffer to array. + + Parameters: TInt aIndex: in: Index + T& aBuf: in: Buffer + + Return Values: None + + Errors/Exceptions: None + + Status: Approved + +------------------------------------------------------------------------------- +*/ +template +void CFixedFlatArray::Set( TInt aIndex, T& aBuf ) + { + CheckIndex( aIndex ); + + iArray[aIndex] = aBuf; + + } + +/* +------------------------------------------------------------------------------- + + Class: CFixedFlatArray + + Method: CheckIndex + + Description: Set buffer to array. + + Parameters: TInt aIndex: in: Index to be checked + + Return Values: None + + Errors/Exceptions: Panics if index is incorrect + + Status: Approved + +------------------------------------------------------------------------------- +*/ +template +void CFixedFlatArray::CheckIndex( TInt aIndex ) const + { + if ( aIndex < 0 || aIndex >= iCount ) + { + User::Panic( _L( "CFixedFlatArray: Array index out of range" ), KErrArgument ); + } + + } + +#endif // TEST_ENGINE_CLIENT_INL + +// End of File \ No newline at end of file diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/inc/TestScripterInternal.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/inc/TestScripterInternal.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,234 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the +* CScriptBase. +* +*/ + +#ifndef SCRIPTRUNNERINTERNAL_H +#define SCRIPTRUNNERINTERNAL_H + +// INCLUDES +#include +#include + +// CONSTANTS +// None + +// MACROS +#define ENTRY(A,B) \ + { (TText*) L ##A, (StifTestFunction) &B } + +// DATA TYPES + +// For function pointer operations. If need a new method that calls +// from testscriptclass the testscripter. Add method's enum definition +// here and implement the new method also TestScripterInternal.h need +// new implementations. +enum TStifTSCallBackType + { + EStifTSCallClass, + EStifTSGetObject, + }; + +// FORWARD DECLARATIONS +class CStifItemParser; +class CTestScripter; +class CScriptBase; + +// DATA TYPES +typedef TInt (CScriptBase::* StifTestFunction)( CStifItemParser& ); +class TStifFunctionInfo + { + public: + const TText* iFunctionName; + StifTestFunction iMethod; + }; + +// FUNCTION PROTOTYPES +// (Function pointer) Used to forward operations from test script class +// to TestScripter. +typedef TInt (*CallBackFunc)( CTestScripter* aTestScripter, + TStifTSCallBackType aType, + const TDesC& aLine ); +// CLASS DECLARATION +// None + +// DESCRIPTION +// This a Test Module interface template +// that does not really do anything. + +class CScriptBase + :public CBase + { + public: // Enumerations + + private: // Enumerations + + public: // Constructors and destructor + + public: // New functions + + /** + * Get reference to TestModuleIf API. + */ + IMPORT_C CTestModuleIf& TestModuleIf(); + + /** + * Signal TestScripter to continue from waittestclass. + */ + IMPORT_C void Signal( TInt aError = KErrNone ); + + // Called from test class. TestScripter forwards + // operations to other test class object. + // aLine: in: + IMPORT_C TInt CallTestClass( const TDesC& aLine ); + + // Get TestClass object pointer. Use CallTestClass instead if + // you can, use this only with your own risk!!! + // aObjectName: in: + IMPORT_C CScriptBase* GetTestObject( const TDesC& aObjectName ); + + // Result description can be set from within the test class method + IMPORT_C void SetResultDescription(const TDesC& aDescription); + + public: + + /** + * Runs a script line, must be implemented in derived class. + */ + virtual TInt RunMethodL( CStifItemParser& aItem ) = 0; + + /** + * Destructor of CScriptBase. + */ + virtual ~CScriptBase(){ iSignalErrors.Reset(); iSignalErrors.Close(); }; + + protected: // New functions + + /** + * Constructor. + */ + IMPORT_C CScriptBase( CTestModuleIf& aTestModuleIf ); + + /** + * Internal fuction to run specified method. + */ + IMPORT_C virtual TInt RunInternalL( + TStifFunctionInfo const aFunctions[], + TInt aCount, + CStifItemParser& aItem ); + + /** + * Internal fuction to get const value defined in + * [Define]...[Enddefine] section of script file + */ + IMPORT_C TInt GetConstantValue( const TDesC& aName, TDes& aValue ); + + + /** + * Internal fuction to get const value defined in + * [Define]...[Enddefine] section of script file + */ + IMPORT_C TInt GetConstantValue( const TDesC& aName, TInt& aValue ); + + + /** + * Internal fuction to get const value defined in + * [Define]...[Enddefine] section of script file + */ + IMPORT_C TInt GetConstantValue( const TDesC& aName, TReal& aValue ); + + /** + * Internal fuction to set value of local variable + */ + IMPORT_C TInt SetLocalValue(const TDesC& aName, const TDesC& aValue); + + /** + * Internal fuction to set value of local variable + */ + IMPORT_C TInt SetLocalValue(const TDesC& aName, const TInt aValue); + + /** + * Internal fuction to set value of local variable + */ + IMPORT_C TInt SetLocalValue(const TDesC& aName, const TReal aValue); + + /** + * Internal fuction to get value of local variable + */ + IMPORT_C TInt GetLocalValue(const TDesC& aName, TDes& aValue); + + /** + * Internal fuction to get value of local variable + */ + IMPORT_C TInt GetLocalValue(const TDesC& aName, TInt& aValue); + + /** + * Internal fuction to get value of local variable + */ + IMPORT_C TInt GetLocalValue(const TDesC& aName, TReal& aValue); + + protected: // Functions from base classes + + private: + + IMPORT_C void EnableSignal( TRequestStatus& aStatus ); + + IMPORT_C void CancelSignal(); + + // This set from TestScripter(Initializes function pointer to use) + IMPORT_C void SetScripter( CallBackFunc aFunc, CTestScripter* aTestScripter ); + + public: // Data + + protected: // Data + + /** + * Logger. + */ + CStifLogger* iLog; + + /** + * Array for handling multiple 'waittestclass' given from testclass's + * test configure file. + */ + RArray iSignalErrors; + + private: // Data + // Backpointer + CTestModuleIf& iTestModuleIf; + + // Completed when test class signals continue script execution + TRequestStatus* iStatus; + + // Backpointer to TestScripter + CallBackFunc iFunc; + + // Backpointer + CTestScripter* iTestScripter; + + public: // Friend classes + + protected: // Friend classes + + private: // Friend classes + friend class CTestScripter; + friend class CTestContinue; + + }; + +#endif // SCRIPTRUNNER_H + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/inc/TestServerClient.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/inc/TestServerClient.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,471 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the +* RTestServer, RTestModule and RTestExecution. +* +*/ + +#ifndef TEST_SERVER_CLIENT_H +#define TEST_SERVER_CLIENT_H + + +// INCLUDES +#include +#include +#include "TestEngineClient.h" +#include "StifTestEventInterface.h" +#include "StifTFwIfProt.h" + +// CONSTANTS +// Global mutex name +_LIT( KStifTestServerStartupMutex, "KStifTestServerStartupMutex" ); + +_LIT( KDefaultExeName, "testserverstarter.exe" ); +_LIT( KDefaultUiExeName, "uitestserverstarter.exe" ); + +// TestScripter related informations +const TInt KTestScripterNameLength = 12; // In STIF are two same name +_LIT( KTestScripterName, "testscripter" ); // constants, change both when + // needed !!! + +// TestCombiner related information +_LIT( KTestCombinerName, "testcombiner" ); + +// Test module thread heap and stack sizes +const TUint32 KTestThreadMinHeap = 4096; // 4K heap min +const TUint32 KTestThreadMaxHeap = 1048576; // 1M heap max +const TUint32 KStackSize = 16384; // 16K stack + +// MACROS + +// DATA TYPES +// Opcodes used in message passing between client and server +enum TTestServerRequests + { + // RTestServer requests + ETestServerCloseSession, + ETestServerGetServerThreadId, + ETestServerPassEngineSessionSettings, + + // RTestModule requests + ETestModuleCreateSubSession, + ETestModuleCloseSubSession, + ETestModuleEnumerateTestCases, + ETestModuleGetTestCases, + ETestModuleCancelAsyncRequest, + ETestModuleErrorNotification, + + // RTestExecution requests + ETestExecutionCreateSubSession, + ETestExecutionCloseSubSession, + ETestExecutionRunTestCase, + ETestExecutionPause, + ETestExecutionResume, + ETestExecutionNotifyProgress, + ETestExecutionNotifyData, + ETestExecutionCancelAsyncRequest, + ETestExecutionNotifyEvent, + ETestExecutionNotifyRemoteCmd, + ETestExecutionReadRemoteCmdInfo, + ETestExecutionNotifyCommand, + }; + +// +typedef TPckgBuf TCaseSize; + +// FORWARD DECLARATIONS +class CTestThreadContainerRunnerFactory; +// FUNCTION PROTOTYPES + +// Function for starting the TestServer Server. +IMPORT_C TInt StartNewServer( const TFileName& aModuleFileName, + TFileName& aServerName + ); + +// Function for starting the TestServer Server in either in +// current thread or in new thread +IMPORT_C TInt StartNewServer( const TFileName& aModuleFileName, + TFileName& aServerName, + const TBool aInNewThread, + RSemaphore aSynchronisation + ); + +IMPORT_C TInt StartNewServer( const TFileName& aModuleFileName, + TFileName& aServerName, + const TBool aInNewThread, + RSemaphore aSynchronisation, + TBool aUiTestingServer, + CTestThreadContainerRunnerFactory* aTestThreadContainerRunnerFactory + ); + +// CLASS DECLARATION + +// DESCRIPTION +// RTestServer is a client class of Test Server +// The connect function starts the server, if it not already running. +// An RSessionBase sends messages to the server with the function +// RSessionBase::SendReceive(); +// specifying an opcode( TTestServerReq ) and array of argument pointers. + +class RTestServer + :public RSessionBase + { + public: // Enumerations + // None + + private: // Enumerations + // None + + public: // Constructors and destructor + + /** + * Constructor. + */ + IMPORT_C RTestServer(); + + /** + * Closes the RTestServer session. + */ + IMPORT_C void Close(); + + public: // New functions + + /** + * Connect method creates new RTestServer session that is used to manage + * the test case execution. + */ + IMPORT_C TInt Connect( const TFileName& aModuleName, + const TDesC& aConfigFile); + + /** + * Version returns the client side version number from the RTestServer. + */ + IMPORT_C TVersion Version() const; + + /** + * GetServerThreadId returns the server thread id from the RTestServer. + */ + IMPORT_C TInt GetServerThreadId( TThreadId& aId ); + + IMPORT_C TInt PassEngineSessionSettings( const TEngineSettings& aEngineSessionSettings ); + public: // Functions from base classes + // None + + protected: // New functions + // None + + protected: // Functions from base classes + // None + + private: // Functions from base classes + // None + + /** + * Find exe(CapsModifier) from file system + */ + TInt FindExeL( TFileName aModuleName, TFileName& aPathAndExeModule ); + + /** + * Get caps modifier module name from TestScripter's test case(config) + * file. + */ + TInt GetCapsModifier( const TDesC& aConfigFile, + TFileName& aCapsModifierName ); + + public: // Data + // None + + protected: // Data + // None + + private: // Data + // None + + public: // Friend classes + // None + + protected: // Friend classes + // None + + private: // Friend classes + // None + + }; + + +// DESCRIPTION + +// RTestModule class represents a subsession with the RTestServer. +// Each RTestModule corresponds to a specific CTestModule( a CObject derived +// class ) in the server. Messages are passed via the RTestServer. +// A RTestModule stores a handle from it's server side CTestModule, and uses +// this to identify the CTestModule during communication. + +class RTestModule + :public RSubSessionBase + { + public: // Enumerations + // None + + private: // Enumerations + // None + + public: // Constructors and destructor + // None + + public: // New functions + + /** + * Open creates a subsession to Test Server and opens handle. + * The RTestServer server session shall be created by calling + * RTestServer::Connect before calling this function to create new + * RTestModule subsession. + */ + IMPORT_C TInt Open( RTestServer& aServer, TFileName& aIniFile ); + + /** + * Closes the RTestModule subsession. + */ + IMPORT_C void Close(); + + /** + * EnumerateTestCases requests the needed array size for test cases that + * will be inquired by GetTestCases method. The aConfigFile specifies the + *( optional ) config file where test cases are defined for this query. + * When the EnumerateTestCases is completed succesfully the GetTestCases + * method is called to retrieve test cases to + * CArrayFixFlat list object. + */ + IMPORT_C void EnumerateTestCases( TDesC& aConfigFile, + TCaseSize& aCount, + TRequestStatus& aStatus ); + + /** + * GetTestCases is used to synchronously get test cases from Test Server. + * The list of test cases is retrieved to aTestCaseBuffer. Test Engine + * allocates needed memory for the test case array by calling + * EnumerateTestCases to inquire needed size of aTestCaseBuffer. + * + * If this method is called without previously succesfully called + * EnumerateTestCases the Test Server shall return KErrNotReady. + */ + IMPORT_C TInt GetTestCases( CFixedFlatArray& aTestCaseBuffer ); + + + /** + * + */ + IMPORT_C void ErrorNotification( TErrorNotificationPckg& aError, + TRequestStatus& aStatus ); + + /** + * Asynchronous request can be canceled with CancelAsyncRequest method. + * The aReqToCancel parameter defines the request that will be canceled. + */ + IMPORT_C TInt CancelAsyncRequest( TInt aReqToCancel ); + + public: // Functions from base classes + // None + + protected: // New functions + // None + + protected: // Functions from base classes + // None + + private: // Functions from base classes + // None + + public: // Data + // None + + protected: // Data + // None + + private: // Data + // None + + public: // Friend classes + // None + + protected: // Friend classes + // None + + private: // Friend classes + // None + + }; + + +// DESCRIPTION + +// RTestExecution class represents a subsession with the RTestServer. +// Each RTestExecution corresponds to a specific CTestExecution( a CObject +// derived class ) in the server. Messages are passed via the RTestServer. +// A RTestExecution stores a handle from it's server side CTestExecution, +// and uses this to identify the CTestExecution during communication. + +class RTestExecution + :public RSubSessionBase + { + public: // Enumerations + // None + + private: // Enumerations + // None + + public: // Constructors and destructor + // None + + public: // New functions + + /** + * Open creates a subsession for new test case. Test case to be executed + * is specified by aTestCaseNumber. The aConfig specifies the optional + * config file where the test case is defined. Test cases that can be + * executed are retrieved from the Test Server by calling two-phased + * RTestModule::GetTestCases operation. + */ + IMPORT_C TInt Open( RTestServer& aServer, + const TInt aCaseNumber, + const TFileName& aConfig ); + + /** + * Closes the RTestExecution subsession. Test case is normally closed + * immediately after the test case was completed. + */ + IMPORT_C void Close(); + + /** + * RunTestCase is used to execute the test case previously initialized by + * Open method. RunTestCase is asynchronous method and it is completed + * when the test case is completed. + * The result of the test case is returned to aStatus. + */ + IMPORT_C void RunTestCase( TFullTestResultPckg& aResult, + TRequestStatus& aStatus ); + + /** + * Pause suspends the execution of the test case. The subsession where + * the test case is run will be suspended and thus the test case + * execution is suspended. The test case execution can be later resumed + * by calling Resume. + */ + IMPORT_C TInt Pause(); + + /** + * Resume is used to resume the test case suspended by previously called + * Pause method. The test case execution should be continued immediately + * after the Resume is called. + */ + IMPORT_C TInt Resume(); + + /** + * NotifyProgress requests different progress information from the Test + * DLL. This information can be e.g. printed to UI. Progress information + * is returned to aProgress. The aProgress is TTestProgressPckg that is + * a packaged TTestProgress. + */ + IMPORT_C TInt NotifyProgress( TTestProgressPckg& aProgress, + TRequestStatus& aStatus ); + + /** + * NotifyData is used to receive different data from the Test Server, + * e.g. images or web pages which can be then viewed to tester or + * forwarded to some kind of comparison tool. + */ + IMPORT_C TInt NotifyData( TDes8& aData, TRequestStatus& aStatus ); + + /** + * Asynchronous request can be canceled with CancelAsyncRequest method. + * The aReqToCancel parameter defines the request that will be canceled. + */ + IMPORT_C TInt CancelAsyncRequest( TInt aReqToCancel ); + + /** + * NotifyEvent is used to control event system. + */ + IMPORT_C TInt NotifyEvent( TEventIfPckg& aEvent, + TRequestStatus& aStatus, + TInt aError=KErrNone ); + + /** + * NotifyRemoteCmd is used to get notify. + */ + IMPORT_C TInt NotifyRemoteCmd( TStifCommandPckg& aRemoteCommand, + TPckg& aMsgSizePckg, + TRequestStatus& aStatus ); + + /** + * ReadRemoteCmdInfo for remote message. + */ + IMPORT_C TInt ReadRemoteCmdInfo( TDes8& aRemoteMsg, + TStifCommand aType, + TInt aError = KErrNone ); + + /** + * NotifyCommand is used to control commands from the test case. + * It was created to allow test case to kill itself. DEPRECATED !! + * Use NotifyCommand2 instead. + */ + IMPORT_C TInt NotifyCommand(TCommandPckg& aCommandPckg, + TBuf8& aParamsPckg, + TRequestStatus& aStatus, + TInt aError = KErrNone); + + /** + * NotifyCommand is used to control commands from the test case. + * It was created to allow test case to kill itself. + */ + IMPORT_C TInt NotifyCommand2(TCommandPckg& aCommandPckg, + TDes8& aParamsPckg, + TRequestStatus& aStatus, + TInt aError = KErrNone); + + public: // Functions from base classes + // None + + protected: // New functions + // None + + protected: // Functions from base classes + // None + + private: // Functions from base classes + // None + + public: // Data + // None + + protected: // Data + // None + + private: // Data + // None + + public: // Friend classes + // None + + protected: // Friend classes + // None + + private: // Friend classes + // None + }; + + +#endif // TEST_SERVER_CLIENT_H + + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/inc/TestThreadContainerRunnerFactory.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/inc/TestThreadContainerRunnerFactory.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,146 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the +* CTestThreadContainerRunnerFactory class implementations. +* +*/ + +#ifndef TESTTHREADCONTAINERRUNNERFACTORY_H_ +#define TESTTHREADCONTAINERRUNNERFACTORY_H_ + +// INCLUDES +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +class CTestThreadContainerRunner; +class CUiEnvProxy; + +// CLASS DECLARATION + +// DESCRIPTION +// CTestThreadContainerRunnerFactory class interface. +class CTestThreadContainerRunnerFactory: public CActive + { + public: // Enumerations + // None + + private: // Enumerations + /** + * .Current operation type + */ + enum TOperationType { ECreate, // Create TestModuleContainer + EDelete, // Delete TestModuleContainer + ENone // No operation + }; + + public: // Constructors and destructor + /** + * C++ destructor. + */ + ~CTestThreadContainerRunnerFactory(); + + private: // Constructors and destructor + // None + + public: // New functions + /** + * NewL is first phase of two-phased constructor. + */ + IMPORT_C static CTestThreadContainerRunnerFactory* NewL( TThreadId aThreadId, CActiveScheduler* aScheduler, CUiEnvProxy* aUiEnvProxy ); + + /** + * Creates new CTestThreadContainerRunner object. + */ + CTestThreadContainerRunner* CreateL(); + + /** + * Deletes CTestThreadContainerRunner object. + */ + void DeleteL( CTestThreadContainerRunner* aTestThreadContainerRunner ); + + /** + * Gets UIEnvProxy. + */ + CUiEnvProxy* GetUiEnvProxy(); + public: // Functions from base classes + /** + * RunL derived from CActive handles the completed requests. + */ + void RunL(); + + /** + * DoCancel derived from CActive handles the Cancel. + */ + void DoCancel(); + + protected: // New functions + // None + + protected: // Functions from base classes + // None + + private: // New functions + /** + * C++ default constructor. + */ + CTestThreadContainerRunnerFactory(); + + /** + * By default Symbian OS constructor is private. + */ + void ConstructL( TThreadId aThreadId, CActiveScheduler* aScheduler, CUiEnvProxy* aUiEnvProxy ); + + private: // Functions from base classes + // None + + public: //Data + // None + + protected: // Data + // None + + private: // Data + TThreadId iThreadId; // Main thread id. + CActiveScheduler* iScheduler; // Active scheduler from main thread. + CUiEnvProxy* iUiEnvProxy; // UIEnvProxy. + + CTestThreadContainerRunner* iTestThreadContainerRunner; // Temporary pointer for CTestThreadContainerRunner + // which was created or should be delated. + TOperationType iOperation; // Indicates current operation. + RSemaphore iOperationEndSemaphore; // Operation end semaphore + + public: // Friend classes + // None + + protected: // Friend classes + // None + + private: // Friend classes + // None + }; + + +#endif /*TESTTHREADCONTAINERRUNNERFACTORY_H_*/ diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/inc/TestclassAssert.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/inc/TestclassAssert.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,350 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the testclass +* assert macros. +* +*/ + +#ifndef TestclassAssert_MACROS_H +#define TestclassAssert_MACROS_H + +_LIT( KAssertFailedEquals, "AssertEquals Failed [F:%s][L:%d]" ); +_LIT( KAssertFailedNotEquals, "AssertNotEquals Failed [F:%s][L:%d]" ); +_LIT( KAssertFailedNull, "AssertNull Failed [F:%s][L:%d]" ); +_LIT( KAssertFailedNotNull, "AssertNotNull Failed [F:%s][L:%d]" ); +_LIT( KAssertFailedSame, "AssertSame Failed [F:%s][L:%d]" ); +_LIT( KAssertFailedNotSame, "AssertNotSame Failed [F:%s][L:%d]" ); +_LIT( KAssertFailedTrue, "AssertTrue Failed [F:%s][L:%d]" ); +_LIT( KAssertFailedFalse, "AssertFalse Failed [F:%s][L:%d]" ); +_LIT( KAssertFailedNotLeaves, "AssertNotLeaves Failed [F:%s][L:%d]" ); +_LIT( KAssertFailedLeaves, "AssertLeaves Failed [F:%s][L:%d]" ); +_LIT( KAssertFailedLeavesWith, "AssertLeavesWith Failed [F:%s][L:%d]" ); + + +#ifdef _UNICODE + #define __STIF_WIDEN2(x) L ## x + #define __STIF_WIDEN(x) __STIF_WIDEN2(x) + #define __STIF_DBG_FILE__ __STIF_WIDEN(__FILE__) +#else + #define __STIF_DBG_FILE__ __FILE__ +#endif + +#ifdef _UNICODE + #define __STF_WIDEN2(x) L ## x + #define __STF_WIDEN(x) __STF_WIDEN2(x) + #define __STF_DBG_FILE__ __STF_WIDEN(__FILE__) +#else + #define __STF_DBG_FILE__ __FILE__ +#endif + +// Logs to the STIF log file AND to the RDebug +#define STIF_LOG( aMessage ) \ + iLog->Log( _L( aMessage ) ); RDebug::Print( _L( aMessage ) ); + +// Logs to the STF log file AND to the RDebug +#define STF_LOG( aMessage ) \ + iLog->Log( _L( aMessage ) ); RDebug::Print( _L( aMessage ) ); + +/********************************************************************************* + * STF Assert Macros + *********************************************************************************/ +#define __STF_ASSERT_SHARED( aFunction, aMessage ) \ + if(!aFunction) \ + { \ + iLog->Log( aMessage, __STF_DBG_FILE__, __LINE__ );\ + return KErrGeneral;\ + } + +#define __STF_ASSERT_SHARED_RET( aFunction, aMessage, aFailedReturn ) \ + if(!aFunction) \ + { \ + iLog->Log( aMessage, __STF_DBG_FILE__, __LINE__ );\ + return aFailedReturn;\ + } + + +#define STF_ASSERT_EQUALS( aExpected, aActual ) \ + __STF_ASSERT_SHARED( AssertEquals( aExpected, aActual ) , KAssertFailedEquals ); + +#define STF_ASSERT_EQUALS_RET( aExpected, aActual, aFailedRet ) \ + __STF_ASSERT_SHARED_RET( AssertEquals( aExpected, aActual ) , KAssertFailedEquals, aFailedRet ); + +#define STF_ASSERT_NOT_EQUALS( aExpected, aActual ) \ + __STF_ASSERT_SHARED( !AssertEquals( aExpected, aActual ) , KAssertFailedNotEquals ); + +#define STF_ASSERT_NOT_EQUALS_RET( aExpected, aActual, aFailedRet ) \ + __STF_ASSERT_SHARED_RET( !AssertEquals( aExpected, aActual ) , KAssertFailedNotEquals, aFailedRet ); + +#define STF_ASSERT_NULL( aPtr ) \ + __STF_ASSERT_SHARED( AssertNull( aPtr ), KAssertFailedNull ); + +#define STF_ASSERT_NULL_RET( aPtr, aFailedRet ) \ + __STF_ASSERT_SHARED_RET( AssertNull( aPtr ), KAssertFailedNull, aFailedRet ); + +#define STF_ASSERT_NOT_NULL( aPtr ) \ + __STF_ASSERT_SHARED( !AssertNull( aPtr ), KAssertFailedNotNull ); + +#define STF_ASSERT_NOT_NULL_RET( aPtr, aFailedRet ) \ + __STF_ASSERT_SHARED_RET( !AssertNull( aPtr ), KAssertFailedNotNull, aFailedRet ); + +#define STF_ASSERT_SAME( aExpectedPtr, aActualPtr ) \ + __STF_ASSERT_SHARED( AssertSame( aExpectedPtr, aActualPtr ), KAssertFailedSame ); + +#define STF_ASSERT_SAME_RET( aExpectedPtr, aActualPtr, aFailedRet ) \ + __STF_ASSERT_SHARED_RET( AssertSame( aExpectedPtr, aActualPtr ), KAssertFailedSame, aFailedRet ); + +#define STF_ASSERT_NOT_SAME( aExpectedPtr, aActualPtr ) \ + __STF_ASSERT_SHARED( !AssertSame( aExpectedPtr, aActualPtr ), KAssertFailedNotSame ); + +#define STF_ASSERT_NOT_SAME_RET( aExpectedPtr, aActualPtr, aFailedRet ) \ + __STF_ASSERT_SHARED_RET( !AssertSame( aExpectedPtr, aActualPtr ), KAssertFailedNotSame, aFailedRet ); + +#define STF_ASSERT_TRUE( aCondition ) \ + __STF_ASSERT_SHARED( AssertTrue( aCondition ), KAssertFailedTrue ); + +#define STF_ASSERT_TRUE_RET( aCondition, aFailedRet ) \ + __STF_ASSERT_SHARED_RET( AssertTrue( aCondition ), KAssertFailedTrue, aFailedRet ); + +#define STF_ASSERT_FALSE( aCondition ) \ + __STF_ASSERT_SHARED( !AssertTrue( aCondition ), KAssertFailedFalse ); + +#define STF_ASSERT_FALSE_RET( aCondition, aFailedRet ) \ + __STF_ASSERT_SHARED_RET( !AssertTrue( aCondition ), KAssertFailedFalse, aFailedRet ); + +// Eclosing block is used to create the scope for the __leaveValue +#define STF_ASSERT_NOT_LEAVES( aStatement ) \ + { \ + TRAPD( __leaveValue, aStatement ); \ + __STF_ASSERT_SHARED( AssertEquals( __leaveValue, KErrNone ), KAssertFailedNotLeaves ); \ + } + +#define STF_ASSERT_NOT_LEAVES_RET( aStatement, aFailedRet ) \ + { \ + TRAPD( __leaveValue, aStatement ); \ + __STF_ASSERT_SHARED_RET( AssertEquals( __leaveValue, KErrNone ), KAssertFailedNotLeaves, aFailedRet ); \ + } + +// Eclosing block is used to create the scope for the __leaveValue +#define STF_ASSERT_LEAVES( aStatement ) \ + { \ + TRAPD( __leaveValue, aStatement ); \ + __STF_ASSERT_SHARED( !AssertEquals( __leaveValue, KErrNone ), KAssertFailedLeaves ); \ + } + +#define STF_ASSERT_LEAVES_RET( aStatement, aFailedRet ) \ + { \ + TRAPD( __leaveValue, aStatement ); \ + __STF_ASSERT_SHARED_RET( !AssertEquals( __leaveValue, KErrNone ), KAssertFailedLeaves, aFailedRet ); \ + } + +// Eclosing block is used to create the scope for the __leaveValue +#define STF_ASSERT_LEAVES_WITH( aLeaveCode, aStatement ) \ + { \ + TRAPD( __leaveValue, aStatement ); \ + __STF_ASSERT_SHARED( AssertEquals( __leaveValue, aLeaveCode ), KAssertFailedLeaves ); \ + } + +#define STF_ASSERT_LEAVES_WITH_RET( aLeaveCode, aStatement, aFailedRet ) \ + { \ + TRAPD( __leaveValue, aStatement ); \ + __STF_ASSERT_SHARED_RET( AssertEquals( __leaveValue, aLeaveCode ), KAssertFailedLeaves, aFailedRet ); \ + } + +#define STF_ASSERT_PANIC( aPanicCode, aStatement ) \ + { \ + TestModuleIf().SetExitReason( CTestModuleIf::EPanic, aPanicCode ); \ + aStatement; \ + } + +/********************************************************************************* + * STIF Assert Macros + *********************************************************************************/ +#define __STIF_ASSERT_SHARED( aFunction, aMessage ) \ + if(!aFunction) \ + { \ + iLog->Log( aMessage, __STIF_DBG_FILE__, __LINE__ );\ + return KErrGeneral;\ + } + +#define __STIF_ASSERT_SHARED_RET( aFunction, aMessage, aFailedReturn ) \ + if(!aFunction) \ + { \ + iLog->Log( aMessage, __STIF_DBG_FILE__, __LINE__ );\ + return aFailedReturn;\ + } + + +#define STIF_ASSERT_EQUALS( aExpected, aActual ) \ + __STIF_ASSERT_SHARED( AssertEquals( aExpected, aActual ) , KAssertFailedEquals ); + +#define STIF_ASSERT_EQUALS_RET( aExpected, aActual, aFailedRet ) \ + __STIF_ASSERT_SHARED_RET( AssertEquals( aExpected, aActual ) , KAssertFailedEquals, aFailedRet ); + +#define STIF_ASSERT_NOT_EQUALS( aExpected, aActual ) \ + __STIF_ASSERT_SHARED( !AssertEquals( aExpected, aActual ) , KAssertFailedNotEquals ); + +#define STIF_ASSERT_NOT_EQUALS_RET( aExpected, aActual, aFailedRet ) \ + __STIF_ASSERT_SHARED_RET( !AssertEquals( aExpected, aActual ) , KAssertFailedNotEquals, aFailedRet ); + +#define STIF_ASSERT_NULL( aPtr ) \ + __STIF_ASSERT_SHARED( AssertNull( aPtr ), KAssertFailedNull ); + +#define STIF_ASSERT_NULL_RET( aPtr, aFailedRet ) \ + __STIF_ASSERT_SHARED_RET( AssertNull( aPtr ), KAssertFailedNull, aFailedRet ); + +#define STIF_ASSERT_NOT_NULL( aPtr ) \ + __STIF_ASSERT_SHARED( !AssertNull( aPtr ), KAssertFailedNotNull ); + +#define STIF_ASSERT_NOT_NULL_RET( aPtr, aFailedRet ) \ + __STIF_ASSERT_SHARED_RET( !AssertNull( aPtr ), KAssertFailedNotNull, aFailedRet ); + +#define STIF_ASSERT_SAME( aExpectedPtr, aActualPtr ) \ + __STIF_ASSERT_SHARED( AssertSame( aExpectedPtr, aActualPtr ), KAssertFailedSame ); + +#define STIF_ASSERT_SAME_RET( aExpectedPtr, aActualPtr, aFailedRet ) \ + __STIF_ASSERT_SHARED_RET( AssertSame( aExpectedPtr, aActualPtr ), KAssertFailedSame, aFailedRet ); + +#define STIF_ASSERT_NOT_SAME( aExpectedPtr, aActualPtr ) \ + __STIF_ASSERT_SHARED( !AssertSame( aExpectedPtr, aActualPtr ), KAssertFailedNotSame ); + +#define STIF_ASSERT_NOT_SAME_RET( aExpectedPtr, aActualPtr, aFailedRet ) \ + __STIF_ASSERT_SHARED_RET( !AssertSame( aExpectedPtr, aActualPtr ), KAssertFailedNotSame, aFailedRet ); + +#define STIF_ASSERT_TRUE( aCondition ) \ + __STIF_ASSERT_SHARED( AssertTrue( aCondition ), KAssertFailedTrue ); + +#define STIF_ASSERT_TRUE_RET( aCondition, aFailedRet ) \ + __STIF_ASSERT_SHARED_RET( AssertTrue( aCondition ), KAssertFailedTrue, aFailedRet ); + +#define STIF_ASSERT_FALSE( aCondition ) \ + __STIF_ASSERT_SHARED( !AssertTrue( aCondition ), KAssertFailedFalse ); + +#define STIF_ASSERT_FALSE_RET( aCondition, aFailedRet ) \ + __STIF_ASSERT_SHARED_RET( !AssertTrue( aCondition ), KAssertFailedFalse, aFailedRet ); + +// Eclosing block is used to create the scope for the __leaveValue +#define STIF_ASSERT_NOT_LEAVES( aStatement ) \ + { \ + TRAPD( __leaveValue, aStatement ); \ + __STIF_ASSERT_SHARED( AssertEquals( __leaveValue, KErrNone ), KAssertFailedNotLeaves ); \ + } + +#define STIF_ASSERT_NOT_LEAVES_RET( aStatement, aFailedRet ) \ + { \ + TRAPD( __leaveValue, aStatement ); \ + __STIF_ASSERT_SHARED_RET( AssertEquals( __leaveValue, KErrNone ), KAssertFailedNotLeaves, aFailedRet ); \ + } + +// Eclosing block is used to create the scope for the __leaveValue +#define STIF_ASSERT_LEAVES( aStatement ) \ + { \ + TRAPD( __leaveValue, aStatement ); \ + __STIF_ASSERT_SHARED( !AssertEquals( __leaveValue, KErrNone ), KAssertFailedLeaves ); \ + } + +#define STIF_ASSERT_LEAVES_RET( aStatement, aFailedRet ) \ + { \ + TRAPD( __leaveValue, aStatement ); \ + __STIF_ASSERT_SHARED_RET( !AssertEquals( __leaveValue, KErrNone ), KAssertFailedLeaves, aFailedRet ); \ + } + +// Eclosing block is used to create the scope for the __leaveValue +#define STIF_ASSERT_LEAVES_WITH( aLeaveCode, aStatement ) \ + { \ + TRAPD( __leaveValue, aStatement ); \ + __STIF_ASSERT_SHARED( AssertEquals( __leaveValue, aLeaveCode ), KAssertFailedLeaves ); \ + } + +#define STIF_ASSERT_LEAVES_WITH_RET( aLeaveCode, aStatement, aFailedRet ) \ + { \ + TRAPD( __leaveValue, aStatement ); \ + __STIF_ASSERT_SHARED_RET( AssertEquals( __leaveValue, aLeaveCode ), KAssertFailedLeaves, aFailedRet ); \ + } + +#define STIF_ASSERT_PANIC( aPanicCode, aStatement ) \ + { \ + TestModuleIf().SetExitReason( CTestModuleIf::EPanic, aPanicCode ); \ + aStatement; \ + } + +template +inline TBool AssertEquals(const T& aExpected, const T& aActual) +/** + * AssertEquals + * + * + * @param aExpected - Expected result + * @param aActual - Actual result + * @return - True if equal + */ + { + if( aExpected==aActual ) + { + return ETrue; + } + return EFalse; + } + +template +inline TBool AssertNull(const T* aPtr) +/** + * AssertNull + * + * + * @param aPtr - Pointer + * @return - True if NULL + */ + { + if( aPtr==NULL ) + { + return ETrue; + } + return EFalse; + } + +template +inline TBool AssertSame(const T* aExpectedPtr, const T* aActualPtr) +/** + * AssertSame + * + * + * @param aExpectedPtr - Expected pointer + * @param aActualPtr - Actual pointer + * @return - True if equal + */ + { + if( aExpectedPtr==aActualPtr ) + { + return ETrue; + } + return EFalse; + } + +inline TBool AssertTrue(const TBool& aCondition) +/** + * AssertTrue + * + * + * @param aCondition - Condition + * @return - True if aCondition is true + */ + { + if( !aCondition ) + { + return EFalse; + } + return ETrue; + } + +#endif diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/inc/UIEngine.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/inc/UIEngine.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,294 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the UIEngine. +* +*/ + +#ifndef UI_ENGINE_H +#define UI_ENGINE_H + +// INCLUDES +#include +#include +#include +#include + +#include +#include + + +// CONSTANTS +// Log dir and file +_LIT( KUiLogDir, "\\Logs\\TestFramework\\ui\\" ); +_LIT( KUiLogFile, "ui.txt" ); + +// TestScripter related informations +const TInt KTestScripterNameLength = 12; +_LIT( KTestScripterName, "testscripter" ); +_LIT( KTestCombinerName, "testcombiner" ); + + +// MACROS +// None + +// DATA TYPES + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +class CUIEngineContainer; +class CUIEngineEvent; +class CUIEngineErrorPrinter; + +// CLASS DECLARATION + +// DESCRIPTION + +// CUIIf is the interface class of STIF Test Framework UI engine +class CUIIf + :public CBase + { + public: // Functions that the derived class may implement. + + /** + * Test case executed. + * + * Returns Symbian OS error code. + */ + virtual void TestExecuted ( CUIEngineContainer* aContainer, + TFullTestResult& aFullTestResult ) = 0; + + /** + * Progress information from Test case execution. + * + * Returns Symbian OS error code. + */ + virtual TInt PrintProg ( CUIEngineContainer* /* aContainer */, + TTestProgress& /* aProgress */ ) + { return KErrNotSupported; }; + + /** + * Error information from Test Framework. + * + * Returns Symbian OS error code. + */ + virtual TInt ErrorPrint ( TErrorNotification& /* aError */ ) + { return KErrNotSupported; }; + + /** + * Forward remote messages. + */ + virtual TInt RemoteMsg( CUIEngineContainer* /* aContainer */, + const TDesC& /* aMessage */ ) + { return KErrNotSupported; }; + + /** + * Forward reboot indication. + */ + virtual TInt GoingToReboot( CUIEngineContainer* /* aContainer */, + TRequestStatus& /* aStatus */ ) + { return KErrNotSupported; }; + + /** + * Initialize logger. + */ + virtual void InitializeLogger( CStifLogger* /*aLogger*/ ){}; + + }; + + +// CUIEngine is the main class of STIF Test Framework UI engine +class CUIEngine + :public CBase + { + public: // Enumerations + + protected: // Enumerations + + private: // Enumerations + + public: // Constructors and destructor + + static CUIEngine* NewL( CUIIf* aUi ); + + /** + * Destructor. + */ + virtual ~CUIEngine(); + + public: // New functions + + RTestEngine& TestEngine(){ return iTestEngine; } + + /** + * Used to open TestFramework. + * + * Returns Symbian OS error code. + */ + TInt Open( const TDesC& aTestFrameworkIni ); + + /** + * Used to close TestFramework. + * + * Returns Symbian OS error code. + */ + TInt Close(); + + /** + * Used to add test module to test framework. + * + * Returns Symbian OS error code. + */ + TInt AddTestModule( const TDesC& aModuleName, + const TDesC& aIniFile ); + + /** + * Used to remove test module to test framework. + * + * Returns Symbian OS error code. + */ + TInt RemoveTestModule( const TDesC& aModuleName ); + + /** + * Used to add test case file for test module. + * + * Returns Symbian OS error code. + */ + TInt AddTestCaseFile( const TDesC& aModuleName, + const TDesC& aCaseFile ); + + /** + * Used to remove test case file from test module. + * + * Returns Symbian OS error code. + */ + TInt RemoveTestCaseFile( const TDesC& aModuleName, + const TDesC& aCaseFile ); + + /** + * Get testcases from test modules. Returns test case information + * in aTestinfo. + * Test module name and test case file can be used to limit the + * set of test cases returned. + * + * Returns Symbian OS error code. + */ + TInt GetTestCasesL( RPointerArray& aTestInfo, + const TDesC& aTestModule = (TDesC&) KNullDesC(), + const TDesC& aTestCaseFile = (TDesC&) KNullDesC() ); + + /** + * Start selected test case identified with CTestInfo. + * Return TestId, which is handle used in subsequent + * test case execution control. + * + * Returns Symbian OS error code. + */ + TInt StartTestCase( CUIEngineContainer*& aContainer, + const CTestInfo& aTestInfo ); + + /** + * Abort started test case. + */ + void AbortStartedTestCase( CUIEngineContainer* aContainer ); + + protected: // Functions that the derived class may implement. + + private: + + /** + * C++ default constructor. + */ + CUIEngine( CUIIf* aUi ); + + /** + * Second phase constructor. + */ + void ConstructL(); + + /** + * Test case executed. + * + * Returns Symbian OS error code. + */ + void TestExecuted ( CUIEngineContainer* aContainer, + TFullTestResult& aFullTestResult ); + + /** + * Progress information from Test case execution. + * + * Returns Symbian OS error code. + */ + TInt PrintProg ( CUIEngineContainer* aContainer, + TTestProgress& aProgress ); + + /** + * Error information from Test framework. + * + * Returns Symbian OS error code. + */ + TInt ErrorPrint ( TErrorNotification& aError ); + + /** + * Forward remote messages. + */ + TInt RemoteMsg( CUIEngineContainer* aContainer, + const TDesC& aMessage ); + + /** + * Forward reboot indication.. + */ + TInt GoingToReboot( CUIEngineContainer* aContainer, TRequestStatus& aStatus ); + + + public: // Data + + // Logger + CStifLogger* iLogger; + + protected: // Data + // None + + private: // Data + + /** + * Handle to UI. + */ + CUIIf* iUi; + + // Handle to Test Engine + RTestEngine iTestEngine; + + // Container array + RPointerArray iContainerArray; + + // Error printer + CUIEngineErrorPrinter* iError; + + public: // Friend classes + // None + + protected: // Friend classes + // None + + private: // Friend classes + friend class CUIEngineContainer; + friend class CUIEngineEvent; + friend class CUIEngineErrorPrinter; + }; + +#endif // UI_ENGINE_H + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/inc/UIEngineContainer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/inc/UIEngineContainer.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,238 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the CUIEngine. +* +*/ + +#ifndef STIF_TFW_IF_CONTAINER_H +#define STIF_TFW_IF_CONTAINER_H + +// INCLUDES +#include +#include +#include + +#include +#include + +// CONSTANTS +// None +_LIT( KUIStoreDefaultDir, "C:\\TestFramework\\" ); +// MACROS +// None + +// DATA TYPES +// None + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +class CUIEngine; +class CUIEngineRunner; +class CUIEnginePrinter; +class CUIEngineErrorPrinter; +class CUIEngineRemote; + +// CLASS DECLARATION + +// DESCRIPTION + +// CUIEngineContainer is interface between main class CUIEngine +// and CUIEngineRunner, which execute test cases +class CUIEngineContainer + : public CBase + { + public: // Enumerations + // Case state + enum TCaseState + { + ENotStarted, + ERunning, + EPaused, + EExecuted, + EFinished, + }; + + private: // Enumerations + // None + + public: // Constructor + + /** + * NewL is two-phased constructor. + */ + static CUIEngineContainer* NewL( CUIEngine* aUIEngine, + const TTestInfo& aTestInfo, + RTestEngine& aTestEngine ); + + public: // New functions + + + public: // Functions from base classes + + /** + * StartContainerL starts test case execution. + * + * Returns Symbian OS error code. + */ + TInt StartContainerL(); + + /** + * TestCaseExecuted informs that test case has executed. + */ + void TestCaseExecuted( TFullTestResult& aResult, TInt aStatus ); + + /** + * PrintProgress forwards print information from test case. + */ + void PrintProgress( TTestProgress& aProgress ); + + /** + * RemoteSend forwards remote protocol messages from master. + */ + void RemoteSend( const TDesC& aRemoteMsg, TInt aStatus ); + + /** + * GoingToReboot forwards reboot indication. + */ + TInt GoingToReboot( TRequestStatus& aStatus ); + + /** + * RemoteReceive forwards remote protocol messages to master. + */ + TInt RemoteReceive( const TDesC& aRemoteMsg ); + + /** + * CancelTest cancels test case execution. TestCompleted() will be called + * with aTestExecutionResult set to KErrCancel. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt CancelTest(); + + /** + * PauseTest pauses test case execution. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt PauseTest(); + + /** + * ResumeTest resumes test case execution. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt ResumeTest(); + + /** + * Return remote identifier. + */ + TUint32 RemoteId() const { return iRemoteId; }; + + /** + * Set remote identifier. + */ + void SetRemoteId( TUint32 aRemoteId ){ iRemoteId = aRemoteId; }; + + /** + * Return master identifier. + */ + TUint32 MasterId() const { return iMasterId; }; + + /** + * Return test case execution state. + */ + TCaseState State() const { return iState; }; + + /** + * Printer signals all prints done event. + */ + void PrintsDone(); + + protected: // New functions + // None + + protected: // Functions from base classes + // None + + private: // Constructors and destructor + + /** + * C++ default constructor. + */ + CUIEngineContainer( CUIEngine* aUIEngine, + const TTestInfo& aTestInfo, + RTestEngine& aTestEngine ); + + /** + * By default Symbian OS constructor is private. + */ + void ConstructL(); + + /** + * Destructor of CUIEngineContainer. + */ + ~CUIEngineContainer(); + + public: //Data + // Pointer to UIEngine + CUIEngine* iUIEngine; + + protected: // Data + // None + + private: // Data + + // Handle to Test Engine + RTestEngine iTestEngine; + + // Handle to Test Case + RTestCase iTestCase; + + // Test case runner + CUIEngineRunner* iRunner; + + // Test case printer + CUIEnginePrinter* iPrinter; + + // Test case remote command handler + CUIEngineRemote* iRemote; + + // Test info and package + TTestInfo iTestInfo; + TTestInfoPckg iTestInfoPckg; + + // Case state + TCaseState iState; + + // Remote protocol identifier + TUint32 iRemoteId; + + // Master protocol identifier + TUint32 iMasterId; + + public: // Friend classes + friend class CUIEngine; + + protected: // Friend classes + + private: // Friend classes + + }; + + +#endif // STIF_TFW_IF_CONTAINER_H + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/inc/UIStore.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/inc/UIStore.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,586 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the CUIStore +* class +* +*/ + +#ifndef UISTORE_H +#define UISTORE_H + + +// INCLUDES +#include +#include + +#include +#include +#include + +#include + +// CONSTANTS +_LIT( KDefaultIni, "\\testframework\\testframework.ini" ); + +// Timeout for popups +const TInt KDefaultPopupTimeout = 2100; // 35s. Note this is maximun time in + // current implementation(used in + // After()-method, 32bit). +// Timeout for popups +const TInt KRebootPopupTimeout = 1; + +// MACROS + +// DATA TYPES + +// Menu update type + +// FUNCTION PROTOTYPES +// +// FORWARD DECLARATIONS +class CUIStoreIf; +class CStartedTestCase; +class CUIEngine; +class CTestInfo; +class CUIEngineContainer; +class CStartedTestSet; +class CUIStorePopup; + +// DESCRIPTION +// CUIStore class +class CUIStore + :public CUIIf + { + public: // Enumerations + + private: // Enumerations + + // Popup priorities + enum TPopupPriority + { + EPopupPriorityHighest, + EPopupPriorityNormal, + EPopupPriorityLow + }; + + public: // Constructors and destructor + + /** + * NewL is first phase of two-phased constructor. + */ + static CUIStore* NewL( CUIStoreIf* iUIStoreIf ); + + /** + * Destructor of CUIStore. + */ + ~CUIStore(); + + + public: // New functions + + /** + * Used to open TestFramework. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt Open( const TDesC& aTestFrameworkIni = KNullDesC ); + + /** + * Used to close TestFramework. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt Close(); + + /** + * Used to add test module to test framework. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt AddTestModule( const TDesC& aModuleName, + const TDesC& aIniFile = KNullDesC ); + + /** + * Used to remove test module to test framework. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt RemoveTestModule( const TDesC& aModuleName ); + + /** + * Used to add test case file for test module. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt AddTestCaseFile( const TDesC& aModuleName, + const TDesC& aCaseFile ); + + /** + * Used to remove test case file from test module. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt RemoveTestCaseFile( const TDesC& aModuleName, + const TDesC& aCaseFile ); + + /** + * Start selected test case identified with CTestInfo. + * anIndex contains index in StartedTestCase array, + * which is valid only during execution of calling + * function. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt StartTestCase( const CTestInfo& aTestInfo, + TInt& anIndex ); + + /** + * Return array of existing test cases. + */ + IMPORT_C TInt TestCases( RRefArray& aTestCases, + const TDesC& aTestModule = (TDesC&) KNullDesC(), + const TDesC& aTestCaseFile = (TDesC&) KNullDesC() ); + + + + /** + * Return started (running/runned) test case + */ + IMPORT_C CStartedTestCase& StartedTestCaseL( TInt anIndex ); + + /** + * Return started (running/runned) test cases + */ + IMPORT_C TInt StartedTestCases( RRefArray& aTestCases, + TInt aStatus = CUIStoreIf::EStatusAll, + const TDesC& aTestModule = (TDesC&) KNullDesC(), + const TDesC& aTestCaseFile = (TDesC&) KNullDesC() ); + + /** + * Return modules array + */ + IMPORT_C TInt Modules( RRefArray& aTestModules ); + + /** + * Return test case files + */ + IMPORT_C TInt TestCaseFiles( RRefArray& aTestCaseFiles, + const TDesC& aTestModule = (TDesC&) KNullDesC() ); + + + /** + * Loads all TestFramework test modules from \sys\bin\ directories + * of all drives. + */ + IMPORT_C TInt LoadAllModules(); + + /** + * Lists all TestFramework test modules from \sys\bin\ directories + * of all drives. + */ + IMPORT_C TInt ListAllModules( RPointerArray& aModuleNames ); + + + /** + * Test set support. + */ + + /** + * Create new test set. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt CreateTestSet( const TDesC& aSetName ); + + /** + * Remove active test set. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt RemoveTestSet( const TDesC& aSetName ); + + /** + * Query test sets. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt TestSets( RRefArray& aSetInfos ); + + /** + * Query test set. + * + * Returns Symbian OS error code. + */ + IMPORT_C const CTestSetInfo& TestSetL( const TDesC& aSetName ); + + /** + * Add test case to test set. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt AddToTestSet( const TDesC& aSetName, const CTestInfo& aTestInfo ); + + /** + * Insert test case to test set. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt InsertToTestSet( const TDesC& aSetName, + const CTestInfo& aTestInfo, + TInt aPos ); + + /** + * Remove test case from test set. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt RemoveFromTestSet( const TDesC& aSetName, const CTestInfo& aTestInfo ); + + /** + * Save test set. Depreceated, SaveTestSet2 to be used instead + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt SaveTestSet( const TDesC& aSetName ); + + /** + * Save test set. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt CUIStore::SaveTestSet2( TDes& aSetName ); + /** + * Load test set. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt LoadTestSet( const TDesC& aSetName ); + + /** + * Load saved test cases. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt LoadSavedTestCases(); + + /** + * Start selected test set identified with CTestSetInfo. + * anIndex contains index in StartedTestSet array, + * which is valid only during execution of calling + * function. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt StartTestSet( const CTestSetInfo& aTestSetInfo, + TInt& anIndex, + CStartedTestSet::TSetType aType = + CStartedTestSet::ESetSequential ); + IMPORT_C TInt StartTestSet( const CTestSetInfo& aTestSetInfo, + TInt& anIndex, + CStartedTestSet::TSetType aType, + TBool aNotStartedCasesMode); + + /** + * Abort running test set. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt AbortTestSet( CStartedTestSet& aSetInfo ); + + /** + * Return started (running/runned) test set + * + * Returns Symbian OS error code. + */ + IMPORT_C CStartedTestSet& StartedTestSetL( TInt anIndex ); + + /** + * Return started (running/runned) test cases + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt StartedTestSets( RRefArray& aTestCases, + TInt aStatus = CUIStoreIf::ESetAll ); + + /** + * Updates information stored about test set in file. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt UpdateTestSet(CTestSetInfo& aSetInfo); + + /** + * Reads filters (if any) from initialization file. + */ + IMPORT_C void ReadFiltersL(RPointerArray& aFilters); + + /** + * Creates list of available Test Sets. + * + * Returns Symbian OS error code. + */ + + IMPORT_C TInt GetTestSetsList( RRefArray& aArray ); + + + public: // Functions from base classes + + + protected: // New functions + // None + + protected: // Functions from base classes + // None + + private: + + /** + * C++ default constructor. + */ + CUIStore( CUIStoreIf* iUIStoreIf ); + + /** + * By default Symbian OS constructor is private. + */ + void ConstructL(); + + /** + * Test case executed. + * + * Returns Symbian OS error code. + */ + void TestExecuted ( CUIEngineContainer* aContainer, + TFullTestResult& aFullTestResult ); + + /** + * Progress information from Test case execution. + * + * Returns Symbian OS error code. + */ + TInt PrintProg ( CUIEngineContainer* aContainer, + TTestProgress& aProgress ); + + /** + * Error information from Test framework. + * + * Returns Symbian OS error code. + */ + TInt ErrorPrint( TErrorNotification& aError ); + + /** + * Remote protocol messages handler. + */ + TInt RemoteMsg( CUIEngineContainer* aContainer, + const TDesC& aMessage ); + /** + * Reboot indication handler. + */ + TInt GoingToReboot( CUIEngineContainer* aContainer, + TRequestStatus& aStatus ); + + TInt MsgRemote( CUIEngineContainer* aContainer, + CStifTFwIfProt& aReq, + CStifTFwIfProt& aResp ); + TInt MsgRemoteRun( CUIEngineContainer* aContainer, + CStifTFwIfProt& aReq, + CStifTFwIfProt& aResp ); + TInt MsgRemoteTestCtl( CUIEngineContainer* aContainer, + CStifTFwIfProt& aReq, + CStifTFwIfProt& aResp ); + TInt MsgRemoteEventCtl( CUIEngineContainer* aContainer, + CStifTFwIfProt& aReq, + CStifTFwIfProt& aResp ); + + /** + * Asynchronous remote sendreceive message. + */ + TInt MsgRemoteSendReceive( CUIEngineContainer* aContainer, + CStifTFwIfProt& aReq, + CStifTFwIfProt& aResp ); + + /** + * Initialize logger from UI engine. + */ + inline void InitializeLogger( CStifLogger* aLogger ) + { iLogger = aLogger; }; + + /** + * Set update flag. + */ + inline void RefreshAllCases() + { iUpdateNeeded = ETrue; }; + + /** + * Update test case list if required. + */ + TInt UpdateCases(); + + /** + * Try to locate default initialization file. + */ + void CheckIniL( TFileName& aIni ); + + /** + * Find testcase by container. + */ + TInt FindByContainer( CUIEngineContainer* const aContainer, + CStartedTestCase*& aTestCase ); + + /** + * Loads all TestFramework test modules from \sys\bin\ directories . + */ + void LoadAllModulesL(); + + /** + * Lists all TestFramework test modules from \sys\bin\ directories. + */ + void ListAllModulesL( RPointerArray& aModuleNames ); + + /** + * Find test set by name. + */ + TInt FindSetByName( const TDesC& aSetName, CTestSetInfo*& aSetInfo ); + + /** + * Find test set by CStartedTestCase. + */ + TInt FindStartedSetByCase( const CStartedTestCase* aTestCase, + CStartedTestSet*& aSet ); + + /** + * Load test set. + */ + void LoadTestSetL( const TDesC& aSetName, const TDesC& aSetFileName ); + + /** + * Save test set. + */ + void SaveTestSetL( CTestSetInfo& aSetInfo, const TDesC& aSetFileName ); + + /** + * Updates in file information about test set. + */ + void UpdateTestSetL(CTestSetInfo& aSetInfo, const TDesC& aSetFileName); + + /** + * Read the whole line from the file. + */ + void ReadLineL(RFile &file, TDes& buffer); + + /** + * Write given line to the file and adds end of line. + */ + void WriteLineL(RFile &file, const TDesC& buffer); + + /** + * Load saved executed test cases. + * + * Returns Symbian OS error code. + */ + void LoadExecutedTestCasesL(); + + /** + * Load test modules and test case files used in + * aTestCases if not already done. + */ + void LoadTestModulesAndTestCaseFilesL( const RRefArray& aTestCases ); + + /** + * Parse test set name from test set file name. + */ + TInt ParseTestSetName( const TDesC& aSetFileName, TPtrC& aSetName, TFileName& aFileName ); + + /** + * Do remote popup. Added aPopupPriority parameter for prioritizing popups @js + */ + TInt RemotePopup( CUIEngineContainer* aContainer, + const TDesC& aReq, + CStifTFwIfProt* aResp, + TPopupPriority aPopupPriority = EPopupPriorityLow); + + /** + * Callback from UIStorePopup. + */ + TInt RemotePopupComplete( CUIStorePopup* aPopup, + TInt aError, + CUIEngineContainer* aContainer, + CStifTFwIfProt* aResp, + TKeyCode aKeyCode ); + /** + * Return slave id. + */ + inline TInt16 DevId(){ return 1; }; + + /** + * Prints the highest priority popup from queue + */ + void SetRemotePopupFromQueue(); + + /** + * Shuffles remote run result popups + */ + void ShuffleRemoteRunResultPopups( CUIStorePopup* aPopup ); + + public: //Data + // Logger + CStifLogger* iLogger; + + protected: // Data + // None + + private: // Data + RPointerArray iFileList; + // Pointer to UI (up) + CUIStoreIf* iUIStoreIf; + + // Pointer to UI engine (down) + CUIEngine* iUIEngine; + + // Available test cases + RPointerArray iTestCases; + // Started test cases + RPointerArray iStartedTestCases; + + // Available test sets + RPointerArray iTestSets; + // Started test sets + RPointerArray iStartedTestSets; + + RPointerArray iPopups; + + // Flag for update for test case list required + TBool iUpdateNeeded; + + // Tells if popup is already active + TBool iPopupActive; + + // Priority of the currently active popup + TPopupPriority iActivePopupPriority; + + TFileName iTestFrameworkIni; + + public: // Friend classes + // None + + protected: // Friend classes + // None + + private: // Friend classes + friend class CUIStorePopup; + + }; + +#endif // UISTORE_H + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/inc/UIStoreContainer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/inc/UIStoreContainer.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,349 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the +* CTestCaseRunnner, CTestCasePrinter and CStartedTestCase +* +*/ + +#ifndef UISTORECASECONTAINER_H +#define UISTORECASECONTAINER_H + + +// INCLUDES +#include +#include + +#include + +#include + +// CONSTANTS + +// MACROS + +// DATA TYPES + +// FUNCTION PROTOTYPES + +// FORWARD DECLARATIONS +class CUIEngineContainer; +class CTestInfo; +class CUIStore; +class CTestSetInfo; + +// DESCRIPTION +// CTestProgress defines the progress information from Test Module. +class CTestProgress + :public CBase + { + public: + static CTestProgress* NewL( const TTestProgress& aProgress ); + + ~CTestProgress(); + + void ReplaceTextL( const TTestProgress& aProgress ); + + private: + void ConstructL( const TTestProgress& aProgress ); + + public: + // "Priority" of the progress information. + TInt iPosition; + // Description of the data to be printed. + TPtrC iDescription; + // The actual progress information. + TPtrC iText; + + private: + // Description of the data to be printed. + HBufC* iDescriptionBuf; + // The actual progress information. + HBufC* iTextBuf; + + }; + +// DESCRIPTION +// CStartedTestCase contains active objects that handles one test case +class CStartedTestCase + :public CBase + { + public: // Enumerations + + private: // Enumerations + + public: // Constructors and destructor + + /** + * NewL is first phase of two-phased constructor. + */ + static CStartedTestCase* NewL( const CTestInfo& aTestInfo, + CUIEngineContainer& aContainer ); + + /** + * Destructor of CStartedTestCase. + */ + virtual ~CStartedTestCase(); + + public: // New functions + + /** + * Get Engine container handle. + */ + IMPORT_C CUIEngineContainer& UIEngineContainer() const; + + /** + * Set case result + */ + void SetResult( const TFullTestResult& aResult ); + + /** + * Get test case info. + */ + inline CTestInfo const& TestInfo() const + { return *iTestInfo; }; + + /** + * Return the result + */ + inline const TFullTestResult& Result() const + { return iResult; }; + + /** + * Return the print array + */ + inline RPointerArray& PrintArray() + { return iPrints; }; + inline const RPointerArray& PrintArray() const + { return iPrints; }; + + /** + * Get status. + */ + inline TInt Status() const { return iStatus; } + + public: // Functions from base classes + + protected: // New functions + + protected: // Functions from base classes + + private: // Functions from base classes + + /** + * C++ default constructor. + */ + CStartedTestCase( CUIEngineContainer& aContainer ); + + /** + * By default Symbian OS constructor is private. + */ + void ConstructL( const CTestInfo& aTestInfo ); + + /** + * Private constructor for internal use. + */ + CStartedTestCase( CTestInfo* aTestInfo, + TFullTestResult aResult, + TInt aStatus ); + + public: //Data + /** + * Backpointer that can be utilized by UI, not used from UI Engine. + */ + TAny* iBackPtr; + + protected: // Data + // None + + private: // Data + CUIEngineContainer* iContainer; + CTestInfo* iTestInfo; + TFullTestResult iResult; // Test case result + + RPointerArray iPrints; // Prints from case + + // Execution status (flags from CUIStoreIf::TUpdateFlags) + TInt iStatus; + + public: // Friend classes + // None + + protected: // Friend classes + // None + + private: // Friend classes + friend class CUIStore; + + }; + +// DESCRIPTION +// CStartedTestSet contains test set information +class CStartedTestSet + :public CBase + { + public: // Enumerations + enum TSetType + { + ESetSequential, + ESetParallel, + }; + + private: // Enumerations + + public: // Constructors and destructor + + /** + * NewL is first phase of two-phased constructor. + */ + static CStartedTestSet* NewL( CUIStore* aUIStore, + const CTestSetInfo& aTestSetInfo, + TSetType aType ); + + /** + * Destructor of CStartedTestCase. + */ + virtual ~CStartedTestSet(); + + public: // New functions + + /** + * Get test case info. + */ + inline CTestSetInfo const& TestSetInfo() const + { return *iTestSetInfo; }; + + /** + * Return the result + */ + inline const TFullTestResult& Result() const + { return iResult; }; + + /** + * Get status. + */ + inline TInt Status() const { return iStatus; } + + /** + * Get test cases runned/running in test set. + */ + inline const RRefArray& TestCases() const + { return iTestCases; }; + + /** + * Get type. + */ + inline TSetType Type(){ return iType; }; + + /** + * Start next testcase. Returns KErrNotFound if does not exits. + */ + TInt StartNext(); + + /** + * Abort running testcases. + */ + TInt Abort(); + + /** + * Check if test case running in this test set. + */ + TBool IsRunning( const CStartedTestCase* aTestCase ); + + /** + * Test from this set completed. + */ + TInt TestCompleted( const CStartedTestCase* aTestCase, + TFullTestResult aResult ); + + /** + * Sets mode in which only not executed tests will be run. + */ + void SetNotStartedCasesMode(TBool aNotStartedCasesMode); + + /** + * Returns pointer to original test set. + */ + CTestSetInfo* GetOriginalTestSet(); + + /** + * Sets pointer to original test set to NULL. + */ + void NullOriginalTestSet(); + + public: // Functions from base classes + + protected: // New functions + + protected: // Functions from base classes + + private: // Functions from base classes + /** + * C++ default constructor. + */ + CStartedTestSet( CUIStore* aUIStore, TSetType aType ); + + /** + * By default Symbian OS constructor is private. + */ + void ConstructL( const CTestSetInfo& aTestSetInfo ); + + public: //Data + /** + * Backpointer that can be utilized by UI, not used from UI Engine. + */ + TAny* iBackPtr; + + protected: // Data + // None + + private: // Data + // Backpointer + CUIStore* iUIStore; + + CTestSetInfo* iTestSetInfo; + TFullTestResult iResult; // Test case result + TBool iResultSet; + + RRefArray iTestCases; + + TSetType iType; + + // Execution status (flags from CUIStoreIf::TUpdateFlags) + TInt iStatus; + + // Next case to start + TInt iNext; + // Number of running cases + TInt iRunningCases; + + // In this mode only not executed tests will be run + TBool iNotStartedCasesMode; + + // Original test set + CTestSetInfo* iOriginalTestSet; + + public: // Friend classes + // None + + protected: // Friend classes + // None + + private: // Friend classes + // None + + }; + +#endif // UISTORECASECONTAINER_H + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/inc/UIStoreIf.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/inc/UIStoreIf.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,267 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the CUIStore. +* +*/ + +#ifndef UISTOREIF_H +#define UISTOREIF_H + +// INCLUDES +#include +#include + +#include + +#include + +// EXTERNAL DATA STRUCTURES + +// EXTERNAL FUNCTION PROTOTYPES + +// CONSTANTS + +// MACROS + +// LOCAL CONSTANTS AND MACROS + +// MODULE DATA STRUCTURES + +// LOCAL FUNCTION PROTOTYPES + +// FORWARD DECLARATIONS +class CUIStore; +class CStartedTestCase; +class CTestInfo; + +// CONSTANTS + +// CLASS DECLARATION + +/** +* UI Store class interface. UI must derive this to use UI Store. +*/ +class CUIStoreIf + :public CBase + { + public: // Enumerations + // Updated flags + enum TUpdateFlags + { + // Test case status updates + EStatusRunning = 0x00000001, + EStatusExecuted = 0x00000002, + EStatusPassed = 0x00000004, + EStatusFailed = 0x00000008, + EStatusAborted = 0x00000010, + EStatusCrashed = 0x00000020, + EStatusAll = 0x000000ff, + // Test set updates + ESetRunning = 0x00000100, + ESetExecuted = 0x00000200, + ESetPassed = 0x00000400, + ESetFailed = 0x00000800, + ESetAll = 0x0000ff00, + // Other updates + EPrintUpdate = 0x00010000, + }; + + private: // Enumerations + // None + + public: // Constructors and destructor + + /** + * Destructor. + */ + IMPORT_C ~CUIStoreIf(); + + protected: + /** + * Constructor + */ + IMPORT_C CUIStoreIf(); + + /** + * Symbian OS second phase constructor. This must be called + * from derived class ConstructL. + */ + IMPORT_C void ConstructL(); + + public: // New functions + /** + * Returns reference to CUIStore object, + * which handles test cases and test modules. + */ + IMPORT_C CUIStore& UIStore(); + + /** + * Receives output update notification from CUIStore. + * UI implements this to get update notifications. + * aFlags are from + */ + virtual void Update( CStartedTestCase* /*aTestCase*/, + TInt /* aFlags */ ){}; + + + /** + * Function is called when test framework prints error. + */ + virtual void Error( TErrorNotification& /*aError*/ ){}; + + /** + * Function is called to print message to UI. + */ + virtual TInt PopupMsg( const TDesC& /* aLine1 */, + const TDesC& /* aLine2 */, + TInt /* aTimeInSecs */ ) + { return KErrNotSupported; }; + + /** + * Function is called to print message to UI + * and wait key pressing. + */ + virtual TInt PopupMsg( const TDesC& /* aLine1 */, + const TDesC& /* aLine2 */, + TInt /* aTimeInSecs */, + TKeyCode& /* aKey */, + TRequestStatus& /* aStatus */ ) + { return KErrNotSupported; }; + + /** + * Function is called to close instances. + */ + virtual void Close( TInt /* aHandle */ ){}; + + public: // Functions from base classes + + private: + + private: + + private: // Data + CUIStore* iUIStore; + + }; + +// CLASS DECLARATION + +// DESCRIPTION +// CTestSetInfo contains test set information +class CTestSetInfo + :public CBase + { + public: // Enumerations + + private: // Enumerations + + public: // Constructors and destructor + + /** + * NewL is first phase of two-phased constructor. + */ + static CTestSetInfo* NewL( const TDesC& aName ); + + /** + * Destructor of CStartedTestCase. + */ + virtual ~CTestSetInfo(); + + public: // New functions + + /** + * Get test set name. + */ + inline const TDesC& Name() const + { return *iName; }; + + /** + * Get test cases. + */ + inline const RRefArray& TestCases() const + { return iTestCaseRefs; }; + + /** + * Add test case to set. + */ + TInt AddTestCase( const CTestInfo& aTestInfo ); + + /** + * Insert test case to specific location. + */ + TInt InsertTestCase( const CTestInfo& aTestInfo, TInt aPos ); + + /** + * Remove test case from set. + */ + TInt RemoveTestCase( const CTestInfo& aTestInfo ); + + /** + * NewL is first phase of two-phased constructor. + */ + void CopyL( const CTestSetInfo& aTestSetInfo ); + + /** + * Sets the info which test case has been started lately. + */ + void SetLastStartedCaseIndex(TUint aLastStartedCaseIndex); + + /** + * Gets the info which test case has been started lately. + */ + TUint GetLastStartedCaseIndex(void); + + public: // Functions from base classes + + protected: // New functions + + protected: // Functions from base classes + + private: // Functions from base classes + /** + * C++ default constructor. + */ + CTestSetInfo(); + + /** + * By default Symbian OS constructor is private. + */ + void ConstructL( const TDesC& aName ); + + public: // Data + + protected: // Data + // None + + private: // Data + RRefArray iTestCaseRefs; + RPointerArray iTestCases; + HBufC* iName; + // Which test case was started as a last one (index) + TUint iLastStartedCaseIndex; + + public: // Friend classes + // None + + protected: // Friend classes + // None + + private: // Friend classes + // None + + }; + +#endif // UISTOREIF_H + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/inc/UiEnvProxy.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/inc/UiEnvProxy.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,151 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the UI Proxy +* interface. +* +*/ + +#ifndef UIENVPROXY_H_ +#define UIENVPROXY_H_ + +// INCLUDES +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION + +// DESCRIPTION +// Interface class for the proxy betweene testscripter and AppUi. +class CUiEnvProxy: public CBase + { + public: // Enumerations + // None + + private: // Enumerations + // None + + public: // Constructors and destructor + // None + + public: // New functions + /** + * Parses key code. + */ + virtual TInt ParseKeyCode( const TDesC& aKeyCodeName, TUint& aKeyCode ) const = 0; + + /** + * Parses key scan code. + */ + virtual TInt ParseKeyScanCode( const TDesC& aKeyScanCodeName, TInt& aKeyScanCode ) const = 0; + + /** + * Parses key modifier. + */ + virtual TInt ParseModifier( const TDesC& aModifierName, TUint& aModifier ) const = 0; + + /** + * Parse pointer event type + */ + virtual TInt ParsePointerEventType( const TDesC& aPointerEventTypeName, TUint& aPointerEventType ) const = 0; + + /** + * Brings UI control container to foreground. + */ + virtual void BringToForeground() = 0; + + /** + * Sends UI control container to background. + */ + virtual void SendToBackground() = 0; + + /** + * Sends local key event to UI control. + */ + virtual void PressKeyL( TRequestStatus* aStatus, TUint aKeyCode, TInt aKeyScanCode = 0, + TUint aKeyModifiers = 0, TInt keyRepeats = 0 ) = 0; + + /** + * Sends local key event to UI control. + */ + virtual void PressKeyL( TUint aKeyCode, TInt aKeyScanCode = 0, + TUint aKeyModifiers = 0, TInt keyRepeats = 0 ) = 0; + + /** + * Sends text to UI control. + */ + virtual void TypeTextL( TRequestStatus* aStatus, const TDesC& aText ) = 0; + + /** + * Sends text to UI control. + */ + virtual void TypeTextL( const TDesC& aText ) = 0; + + /** + * Send pointer event + */ + virtual void SendPointerEventL( TUint aType, const TPoint& aPosition ) = 0; + + /** + * Send local pointer event + */ + virtual void SendPointerEventL( TRequestStatus* aStatus, TUint aType, const TPoint& aPosition ) = 0; + + public: // Functions from base classes + // None + + protected: // New functions + // None + + protected: // Functions from base classes + // None + + private: // New functions + // None + + public: //Data + // None + + protected: // Data + // None + + private: // Data + // None + + public: // Friend classes + // None + + protected: // Friend classes + // None + + private: // Friend classes + // None + }; + +#endif // UIENVPROXY_H_ + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/inc/atslogger.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/inc/atslogger.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,579 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the CAtsLogger +* class. +* +*/ + +#ifndef __ATSLOGGER_H__ +#define __ATSLOGGER_H__ + +// INCLUDES +#include + +// CONSTANTS +_LIT(KAtsLogger, "AtsLogger"); +_LIT(KAtsLoggerNa, "NA"); +_LIT(KAtsLoggerPassed, "PASSED"); +_LIT(KAtsLoggerFailed, "FAILED"); +_LIT(KAtsLoggerSkipped, "SKIPPED"); +_LIT(KAtsLoggerEmpty, ""); +_LIT(KAtsLoggerSemaphore, "AtsLogger"); +_LIT(KAtsLoggerXmlDirectory, "\\SPD_LOGS\\XML\\"); +_LIT(KAtsLoggerRawDirectory, "\\SPD_LOGS\\RAW\\"); +_LIT(KAtsLoggerXmlSuffix, ".xml"); +_LIT(KAtsLoggerRawSuffix, ".log"); + +_LIT(KAtsLoggerTagOpen, "<"); +_LIT(KAtsLoggerSpace, " "); +_LIT(KAtsLoggerAttr, "=\""); +_LIT(KAtsLoggerAttrClose, "\">"); +_LIT(KAtsLoggerTagPost, ">"); +_LIT(KAtsLoggerTagClose, ""); +_LIT(KAtsLoggerQuot, """); +_LIT(KAtsLoggerAmp, "&"); +_LIT(KAtsLoggerApos, "'"); +_LIT(KAtsLoggerLt, "<"); +_LIT(KAtsLoggerGt, ">"); + +_LIT8(KAtsLoggerQuot8, """); +_LIT8(KAtsLoggerAmp8, "&"); +_LIT8(KAtsLoggerApos8, "'"); +_LIT8(KAtsLoggerLt8, "<"); +_LIT8(KAtsLoggerGt8, ">"); +_LIT8(KAtsLoggerEmpty8, ""); + +_LIT(KAtsLoggerTagTestReport, "test-report"); +_LIT(KAtsLoggerTagTestSet, "test-batch"); +_LIT(KAtsLoggerTagTestCase, "test-case"); +_LIT(KAtsLoggerTagTestSetInit, "batch-init"); +_LIT(KAtsLoggerTagDescription, "description"); +_LIT(KAtsLoggerTagDate, "date"); +_LIT(KAtsLoggerTagFactory, "factory"); +_LIT(KAtsLoggerTagComponent, "component"); +_LIT(KAtsLoggerTagName, "name"); +_LIT(KAtsLoggerTagVersion, "version"); +_LIT(KAtsLoggerTagTestSetResult, "batch-result"); +_LIT(KAtsLoggerTagId, "id"); +_LIT(KAtsLoggerTagTestCaseInit, "case-init"); +_LIT(KAtsLoggerTagExpected, "expected-result"); +_LIT(KAtsLoggerTagRunTime, "run-time"); +_LIT(KAtsLoggerTagTestCaseResult, "case-result"); +_LIT(KAtsLoggerTagActual, "actual-result"); +_LIT(KAtsLoggerTagDebug, "debug-info"); +_LIT(KAtsLoggerTagWarning, "warning"); +_LIT(KAtsLoggerTagError, "error"); +_LIT(KAtsLoggerTagStatus, "status"); +_LIT(KAtsLoggerTimeStamp, "time-stamp"); + +const TInt KAtsLoggerBufferSegmentGranularity = 32; + +// CLASS DECLARATION + +// DESCRIPTION +// CAtsLogger defines API for test case result logging. +class CAtsLogger : public CBase + { + public: // Public enumerations + enum TReportStage + { + ENone, + EUninitialized, + EBeginTestReport, + EBeginTestSet, + EBeginTestCase, + ESetTestCaseVerdict, + EEndTestCase, + EEndTestSet, + EEndTestReport, + EFinished + }; + private: // Private enumerations + // None + + public: // Public constructors/desctructors + + /** + * Symbian OS constructor + */ + IMPORT_C static CAtsLogger* NewL( const TDesC& aName, + TBool aAfterReboot = EFalse ); + + /** + * C++ destructor + */ + IMPORT_C ~CAtsLogger(); + + public: // Public new functions + + /** + * Returns error message. Also includes + * base E32 error codes. + */ + IMPORT_C static const TPtrC ErrorMessage(const TInt& aError); + + /** + * Closes opened resources. Desctructor calls + * this if it is not called before. + */ + IMPORT_C void CloseL(); + + /** + * IsValid() returns ETrue if this logger is valid and + * able to write log. + */ + IMPORT_C TBool IsValid(); + + /** + * BeginTestReportL() should be called at the beginning of the program, + * before any testing begins + */ + IMPORT_C void BeginTestReportL(); + + /** + * EndTestReportL() must be called at the end of the program + */ + IMPORT_C void EndTestReportL(); + + /** + * SaveForRebootL() should be called before reboot to save data. + */ + IMPORT_C void SaveForRebootL(); + + /** + * ContinueAfterRebootL() must be called to continue + * after reboot. + */ + IMPORT_C void ContinueAfterRebootL(); + + /** + * BeginTestSetL() must be called when a new test set begins + * + * factory = component factory whose component is being tested + * component = name of the software component being tested + * version = version of the software component + * description = short, optional description of the batch + */ + IMPORT_C void BeginTestSetL(const TDesC& aFactory = KAtsLoggerNa, + const TDesC& aComponent = KAtsLoggerNa, + const TDesC& aVersion = KAtsLoggerNa, + const TDesC& aDescription = KAtsLoggerEmpty); + + /** + * EndTestSetL() must be called as soon as a test set ends + */ + IMPORT_C void EndTestSetL(); + + /** + * BeginTestCaseL() is called whenever an individual testcase begins + * + * id = unique id of the testcase + * expected = expected result of the test (if applicable) + * info = short descritpion of the expected result (if applicable) + */ + IMPORT_C void BeginTestCaseL(const TDesC& aId, + const TDesC& aExpected = KAtsLoggerNa, + const TDesC& aInfo = KAtsLoggerEmpty, + const TDesC& aVersion = KAtsLoggerEmpty); + + /** + * BeginTestCaseL() is called whenever an individual testcase begins + * + * id = unique id of the testcase + * expected = expected result code of the test (if applicable) + * info = short descritpion of the expected result (if applicable) + */ + IMPORT_C void BeginTestCaseL(const TDesC& aId, + const TInt aExpected, + const TDesC& aInfo = KAtsLoggerEmpty, + const TDesC& aVersion = KAtsLoggerEmpty); + + /** + * BeginTestCaseReportL() is called whenever an individual testcase report begins + * + * id = unique id of the testcase + * expected = expected result code of the test (if applicable) + * startTime= test case starting time + * info = short descritpion of the expected result (if applicable) + */ + IMPORT_C void BeginTestCaseReportL( const TDesC& aId, + const TDesC& aExpected, + const TTime& aStartTime, + const TDesC& aInfo = KAtsLoggerEmpty, + const TDesC& aVersion = KAtsLoggerEmpty ); + + /** + * BeginTestCaseReportL() is called whenever an individual testcase report begins + * + * id = unique id of the testcase + * expected = expected result code of the test (if applicable) + * startTime= test case starting time + * info = short descritpion of the expected result (if applicable) + */ + IMPORT_C void BeginTestCaseReportL( const TDesC& aId, + const TInt aExpected, + const TTime& aStartTime, + const TDesC& aInfo = KAtsLoggerEmpty, + const TDesC& aVersion = KAtsLoggerEmpty ); + + /** + * EndTestCaseL() is called when an individual testcase ends + */ + IMPORT_C void EndTestCaseL(); + + /** + * TestCasePassed() must be called between calls + * to BeginTestCase() and EndTestCase(). This results + * test case to be passed. + */ + IMPORT_C void TestCasePassed(); + + + /** + * TestCaseFailed() must be called between calls + * to BeginTestCase() and EndTestCase(). This results + * test case to be failed. + */ + IMPORT_C void TestCaseFailed(); + + /** + * TestCaseSkipped() must be called between calls + * to BeginTestCase() and EndTestCase(). This results + * test case to be skipped. + */ + IMPORT_C void TestCaseSkipped(); + + /** + * TestCaseNa() must be called between calls + * to BeginTestCase() and EndTestCase(). This results + * test case to be N/A. + */ + IMPORT_C void TestCaseNa(); + + /** + * SetTestCaseResultL() sets the actual result of the test (if applicable), + * this should correspond to the expected result (see BeginTestCase) if + * the test succeeds. + + * Must be called between calls to BeginTestCaseL() and EndTestCaseL(). + */ + IMPORT_C void SetTestCaseResultL(const TInt aResult); + IMPORT_C void SetTestCaseResultL(const TDesC& aResult = KAtsLoggerEmpty); + IMPORT_C void SetTestCaseResultL(TRefByValue aFmt,...); + + /** + * DebugL(), WarningL(), ErrorL() and CommentL() as used to place + * informational messages of appropriate debug level into the test report. + * These functions can be called anywhere between BeginReportL() and EndReportL(). + */ + IMPORT_C void DebugL(const TDesC& aMsg); + IMPORT_C void DebugL(TRefByValue aFmt,...); + + IMPORT_C void WarningL(const TDesC& aMsg); + IMPORT_C void WarningL(TRefByValue aFmt,...); + + IMPORT_C void ErrorL(const TDesC& aMsg); + IMPORT_C void ErrorL(TRefByValue aFmt,...); + + IMPORT_C void CommentL(const TDesC& aMsg); + IMPORT_C void CommentL(TRefByValue aFmt,...); + + /** + * RawLogL() writes to a separate log file. + */ + IMPORT_C TInt RawLogL(const TDesC& aMsg); + IMPORT_C TInt RawLogL(TRefByValue aFmt,...); + + /** + * DebugOutput() writes to RDebug + */ + IMPORT_C void DebugOutput(const TDesC& aMsg); + + /** + * Set this to ETrue if client should use + * full set of reporting methods + */ + IMPORT_C void SetFullReporting(TBool aFlag); + + /** + * Set this to ETrue if XML log should be + * written to the debug port also. + */ + IMPORT_C void SetDebugOutput(TBool aFlag); + + /** + * Set this to ETrue if XML log should have + * indentation. This only adds human readability. + */ + IMPORT_C void SetIndentation(TBool aFlag); + + + public: // Public functions from base classes + // None + + protected: // Protected new functions + /** + * Outputs message closed by the tags. + */ + void TagL(const TDesC& aTag, + const TDesC& aMsg); + + /** + * Adds attribute with value to the message and + * outputs message closed by the tags. + */ + void TagL(const TDesC& aTag, + const TDesC& aMsg, + const TDesC& aAttribute, + const TDesC& aValue); + + /** + * Outputs message closed by the tags. This is used with + * DebugL(), WarningL(), ErrorL() and CommentL(). Time stamp is + * added to the message. + */ + void TimeStampedMessageL(const TDesC& aTag, + const TDesC& aMsg); + + /** + * Opens a tag. + */ + void OpenTagL(const TDesC& aTag); + + + /** + * Opens a tag with attribute and value. + */ + void OpenTagL(const TDesC& aTag, + const TDesC& aAttribute, + const TDesC& aValue); + + /** + * Opens a tag and increases indent level. + */ + void OpenTagIndentL(const TDesC& aTag); + + + /** + * Opens a tag with attribute having value and increases indent level. + */ + void OpenTagIndentL(const TDesC& aTag, + const TDesC& aAttribute, + const TDesC& aValue); + + /** + * Closes a tag; + */ + void CloseTagL(const TDesC& aTag); + + /** + * Closes a tag and descreases indent level. + */ + void CloseTagIndentL(const TDesC& aTag); + + /** + * Outputs line feed. + */ + void LineFeedL(); + + /** + * Writes data to the specified file. + */ + void WriteL(const TDesC& aData, RFile& aFile); + + /** + * Writes data to the XML file. + */ + void WriteL(const TDesC& aData); + + /** + * Encodes XML special chararacters from message + */ + HBufC* EncodeLC(const TDesC& aMsg); + + /** + * Checks whether report stage transition is legal. + */ + TBool IsTransitionLegal(const TReportStage& aNewStage); + + protected: // Protected functions from base classes + // None + + protected: // Protected data + // None + + private: // Private functions + /** + * By default Symbian OS two-phase constructor is private. + */ + void ConstructL( TBool aAfterReboot ); + + /** + * C++ constructor + */ + CAtsLogger(const TDesC& aName); + + /** + * Checks whether directory exist or not + */ + TBool CheckDirectoryL(const TDesC& aDirName, TChar& aDrive); + + /** + * Replaces file if already exist + */ + TInt ReplaceFileL(const TDesC& aFileName); + + /** + * Open existing file if already exist + */ + TInt OpenExistingFileL(const TDesC& aFileName); + + /** + * Formats given date to a format of yyyy-mm-dd hh:mm:ss + */ + HBufC* FormatDateLC(TDateTime aDate); + + /** + * Formats given time to a format of hh:mm:ss + */ + HBufC* FormatTimeLC(TTimeIntervalMicroSeconds aTime); + + /** + * Expands buffer and then writes aBuf into it. + */ + TInt BufferL(CBufBase* aBufBase, TInt& aLength,const TDesC& aBuf); + + /** + * Writes whole buffer to a file. Does not reset buffer. + */ + TInt WriteBufferToFileL(CBufBase* aCBufBase, const TDesC& aFileName); + + /** + * Writes whole buffer to the debug port. Does not reset buffer. + */ + TInt WriteBufferToDebugPortL(CBufBase* aCBufBase); + + protected: // Protected data + // TTestSet data holder class definition and implementation + class TTestSet + { + public: + TTime iStartTime; + }; + + // TCase data holder class definition and implementation + class TTestCase + { + public: + TTestCase() { iResult = NULL; } + ~TTestCase() + { + if (iResult) + { + delete iResult; + iResult = NULL; + } + } + public: + HBufC* iResult; + TPtrC iStatus; + TTime iStartTime; + + }; + + // Data holder for batch information + CAtsLogger::TTestSet iTestSet; + + // Data holder for test case information + CAtsLogger::TTestCase iTestCase; + + // Holds current report stage + CAtsLogger::TReportStage iReportStage; + + // Test case and logger ID + const TFileName iName; + + private: // Private data + // Dynamic buffer for XML data + CBufBase* iXmlBuffer; + + // Current legth of iXmlBuffer + TInt iXmlBufferLength; + + // Indentation level of outputted XML + int iIndentLevel; + + // Handle to file server + RFs iRfs; + + // The name of XML file + TFileName iXmlLogFileName; + + // The name of raw log file + TFileName iRawLogFileName; + + // Flag to indicate that raw log should be done + TBool iRawLog; + + // Flag to indicate that XML log should be done + TBool iXmlLog; + + // Flag to indicate that logger is valid + TBool iValid; + + // Flag to indicate that a line feed has been done + TBool iLineFeedDone; + + // Flag to indicate that BeginTestCase() has been called + // and EndTestCase() hasn't yet been called. + TBool iInTestCase; + + // Flag to indicate that logger is closed + TBool iClosed; + + // Flag to indicate if client should use + // full set of logger methods: + // BeginTestReportL() + // BeginTestSetL(); + // BeginTestCaseL(); + // TestCasePassed(); // or other verdict method + // EndTestCase(); + // EndTestSetL(); + // EndTestReportL(); + TBool iFullReportingMode; + + // Flag to indicate that XML log should be + // written to the debug port also + TBool iDoDebugOutput; + + // Flag to indicate that logger does intendation + // to the XML file + TBool iDoIndentation; + + public: // Friend classes + // None + + protected: // Friend classes + // None + + private: // Friend classes + // None +}; + +#endif// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/api/api_platform/stif_api.metaxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/api/api_platform/stif_api.metaxml Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,27 @@ + + + STIF API + Defines the API, which is used by STIF and its test modules. + c++ + stif + + + + + + + + + + + + + + + + + + no + no + + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/doc/HOWTO_Execute_TEF_test_cases_on_STF.doc Binary file testexecfw/stf/doc/HOWTO_Execute_TEF_test_cases_on_STF.doc has changed diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/doc/STF_Users_Guide.doc Binary file testexecfw/stf/doc/STF_Users_Guide.doc has changed diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample.zip Binary file testexecfw/stf/examples/MigrationExample.zip has changed diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/STF/Bmarm/TestFileStoreU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/STF/Bmarm/TestFileStoreU.DEF Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,3 @@ +EXPORTS + LibEntryL__FR13CTestModuleIf @ 1 NONAME R3UNUSED ; LibEntryL(CTestModuleIf &) + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/STF/Bwins/TestFileStoreU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/STF/Bwins/TestFileStoreU.DEF Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,3 @@ +EXPORTS + ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * __cdecl LibEntryL(class CTestModuleIf &) + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/STF/EABI/TestFileStoreU.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/STF/EABI/TestFileStoreU.def Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,3 @@ +EXPORTS + _Z9LibEntryLR13CTestModuleIf @ 1 NONAME + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/STF/conf/TestFileStore.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/STF/conf/TestFileStore.cfg Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,58 @@ +[Test] +title Case1 (CreateFile, allow error -11) +create TestFileStore foobar +allowerrorcodes -11 +foobar CreateFile c:\testfileserver.test +foobar WriteFile c:\testfileserver.test +delete foobar +[Endtest] + +[Test] +title Case2 (Loop , Print) +create TestFileStore foobar +loop 10000 msec +print Loop test: LOOP_COUNTER . +foobar ReadFile c:\testfileserver.test +endloop +delete foobar +[Endtest] + +[Test] +title Case3 (pause) +create TestFileStore foobar +print Pause 2 seconds. +pause 2000 +delete foobar +[Endtest] + +[Test] +title Case4 (expectedpanic) +create TestFileStore foobar +print set expected panic +expectedpanic 5 +foobar PanicExample USER 5 +delete foobar +[Endtest] + +[Test] +title Case5_1 (OpenFile, event testing) +print This case should be run with Case5_2 parallel. +create TestFileStore foobar +request Event1 +wait Event1 +foobar OpenFile c:\testfileserver.test +release Event1 +delete foobar +[Endtest] + +[Test] +title Case5_2 (CreateFile, event testing) +print This case should be run with Case5_1 parallel. +create TestFileStore foobar +allowerrorcodes -11 +foobar CreateFile c:\testfileserver.test +set Event1 state +unset Event1 +delete foobar +[Endtest] + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/STF/group/Bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/STF/group/Bld.inf Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +PRJ_PLATFORMS +// specify the platforms your component needs to be built for here +// defaults to WINS MARM so you can ignore this if you just build these + + DEFAULT + +PRJ_TESTEXPORTS +// NOTE: If using ARS requirements all export operations should be done under this. +// 'abld test export' + +PRJ_EXPORTS +../conf/TestFileStore.cfg /epoc32/winscw/c/TestFramework/TestFileStore.cfg +TestFramework.ini /epoc32/winscw/c/TestFramework/TestFramework.ini + +// Specify the source file followed by its destination here +// copy will be used to copy the source file to its destination +// If there's no destination then the source file will be copied +// to the same name in \epoc32\include +// Example: +/* +\agnmodel\inc\AGMCOMON.H +*/ + +PRJ_TESTMMPFILES + + +PRJ_MMPFILES +TestFileStore.mmp + + +// Specify the .mmp files required for building the important component +// releasables. +// +// Specify "tidy" if the component you need to build doesn't need to be +// released. Specify "ignore" if the MMP file exists but should be +// ignored. +// Example: +/* +\agnmodel\group\agnmodel.mmp +#if defined(MARM) +\agnmodel\group\agsvexe.mmp +#endif +*/ + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/STF/group/TestFileStore.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/STF/group/TestFileStore.mmp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,76 @@ +/*TYPE TESTCLASS*/ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: MMP file for STIF Test Framework's TestScripter +* testclass test module. +* +*/ + +#include + +TARGET TestFileStore.dll +TARGETTYPE dll +UID 0x1000008D 0x101FB3E3 + +CAPABILITY ALL -TCB +/* Remove comments and replace 0x00000000 with correct vendor id */ +// VENDORID 0x00000000 +/* Remove comments and replace 0x00000000 with correct secure id */ +// SECUREID 0x00000000 + +//TARGETPATH ?target_path +DEFFILE TestFileStore.def + +USERINCLUDE ../inc + +OS_LAYER_SYSTEMINCLUDE + +SOURCEPATH ../src + +SOURCE TestFileStore.cpp +SOURCE TestFileStoreBlocks.cpp + +//RESOURCE resource_file +//RESOURCE resource_file2 + +LIBRARY euser.lib +LIBRARY efsrv.lib +LIBRARY stiftestinterface.lib +LIBRARY stiftestengine.lib + +LANG SC + +/* +START WINS +?wins_specific_information +END + +START MARM +?marm_specific_information +END +*/ +// Other possible keywords: + +// DOCUMENT ?file, that is not compiled, but added to MSVC project workspace (i.e. release notes) +/* +START BITMAP ?target +TARGETPATH ?emulated_path_on_target_machine +HEADER +SOURCE ?color_depth ?source_bitmap +END +*/ +// DEFFILE ?filename +// AIF ?filename + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/STF/group/TestFileStore.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/STF/group/TestFileStore.pkg Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,60 @@ +; +; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +; Installation file for STIF +; + +; Languages +&EN + +; Provide value for uid +#{"STIF"},(0x00000000),1,1,0,TYPE=SA + +; Series60 product id for S60 3.0 +[0x101F7961], 0, 0, 0, {"Series60ProductID"} + +; Localised Vendor name +%{"Nokia"} + +; Unique Vendor name +:"Nokia" + +; Logo +; None + +; Package signature - Optional +; None + +; Start of Package body + +; Condition blocks +; None + +; Options list +; None + +; Install files +"\epoc32\release\armv5\udeb\TestFileStore.dll" - "!:\Sys\Bin\TestFileStore.dll" + +; Embedded SIS +; None + +; End of Package body + +; PKG dependencies +; None + +; PKG capabilities +; None diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/STF/group/TestFramework.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/STF/group/TestFramework.ini Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,218 @@ +# +# This is STIF initialization file +# Comment lines start with '#'-character. +# See STIF TestFramework users guide.doc for instructions + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set following test engine settings: +# - Set Test Reporting mode. TestReportMode's possible values are: +# + 'Summary': Summary of the tested test cases. +# + 'Environment': Hardware and software info. +# + 'TestCases': Test case report. +# + 'FullReport': Set of all above ones. +# + Example 'TestReportMode= Summary TestCases' +# +# - CreateTestReport setting controls report creation mode +# + YES, Test report will created. +# + NO, No Test report. +# +# - File path indicates the base path of the test report. +# - File name indicates the name of the test report. +# +# - File format indicates the type of the test report. +# + TXT, Test report file will be txt type, for example 'TestReport.txt'. +# + HTML, Test report will be html type, for example 'TestReport.html'. +# + XML, Test report will be xml type, for example 'TestReport.xml'. +# Note, that xml format is available only when output is set to FILE. +# +# - File output indicates output source of the test report. +# + FILE, Test report logging to file. +# + RDEBUG, Test report logging to using rdebug. +# +# - File Creation Mode indicates test report overwriting if file exist. +# + OVERWRITE, Overwrites if the Test report file exist. +# + APPEND, Continue logging after the old Test report information if +# report exist. +# - Sets a device reset module's dll name(Reboot). +# + If Nokia specific reset module is not available or it is not correct one +# StifHWResetStub module may use as a template for user specific reset +# module. +# - Sets STIF test measurement disable options. e.g. pluging1 and pluging2 disablation +# DisableMeasurement= stifmeasurementplugin01 stifmeasurementplugin02 +# + +[Engine_Defaults] + +TestReportMode= FullReport # Possible values are: 'Empty', 'Summary', 'Environment', + # 'TestCases' or 'FullReport' + +CreateTestReport= YES # Possible values: YES or NO + +TestReportFilePath= C:\LOGS\TestFramework\ +TestReportFileName= TestReport + +TestReportFormat= TXT # Possible values: TXT, HTML or XML +TestReportOutput= FILE # Possible values: FILE or RDEBUG +TestReportFileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +DeviceResetDllName= StifResetForNokia.dll # e.g. 'StifHWResetStub.dll' for user specific reseting + +DisableMeasurement= stifmeasurementdisablenone # Possible values are: + # 'stifmeasurementdisablenone', 'stifmeasurementdisableall' + # 'stifmeasurementplugin01', 'stifmeasurementplugin02', + # 'stifmeasurementplugin03', 'stifmeasurementplugin04', + # 'stifmeasurementplugin05' or 'stifbappeaprofiler' + +Timeout= 0 # Default timeout value for each test case. In milliseconds +UITestingSupport= YES # Possible values: YES or NO +#SeparateProcesses= YES # Possible values: YES or NO (default: NO) +[End_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Module configurations start +# Modules are added between module tags +# tags. Module name is specified after ModuleName= tag, like +# ModuleName= XXXXXXXXX +# Modules might have initialisation file, specified as +# IniFile= c:\testframework\YYYYYY +# Modules might have several configuration files, like +# TestCaseFile= c:\testframework\NormalCases.txt +# TestCaseFile= c:\testframework\SmokeCases.txt +# TestCaseFile= c:\testframework\ManualCases.txt + +# (TestCaseFile is synonym for old term ConfigFile) + +# Following case specifies demo module settings. Demo module +# does not read any settings from file, so tags +# IniFile and TestCaseFile are not used. +# In the simplest case it is enough to specify only the +# name of the test module when adding new test module + +[New_Module] +ModuleName= testscripter +TestCaseFile= c:\testframework\TestFileStore.cfg +[End_Module] + + +# Load testmoduleXXX, optionally with initialization file and/or test case files +#[New_Module] +#ModuleName= testmodulexxx + +#TestModuleXXX used initialization file +#IniFile= c:\testframework\init.txt + +#TestModuleXXX used configuration file(s) +#TestCaseFile= c:\testframework\testcases1.cfg +#TestCaseFile= c:\testframework\testcases2.cfg +#TestCaseFile= c:\testframework\manualtestcases.cfg + +#[End_Module] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set STIF logging overwrite parameters for Logger. +# Hardware and emulator environment logging path and styles can +# be configured from here to overwrite the Logger's implemented values. +# +# Settings description: +# - Indicates option for creation log directory/directories. If log directory/directories +# is/are not created by user they will make by software. +# + YES, Create log directory/directories if not allready exist. +# + NO, Log directory/directories not created. Only created one is used. +# +# - Overwrite emulator path setting. +# + Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined +# Logger's path 'D:\\LOGS\\Module\\' with those definition the path +# will be 'C:\LOGS\TestFramework\LOGS\Module\' +# +# - Overwrite emulator's logging format. +# + TXT, Log file(s) will be txt type(s), for example 'Module.txt'. +# + HTML, Log file(s) will be html type(s), for example 'Module.html'. +# +# - Overwrited emulator logging output source. +# + FILE, Logging to file(s). +# + RDEBUG, Logging to using rdebug(s). +# +# - Overwrite hardware path setting (Same description as above in emulator path). +# - Overwrite hardware's logging format(Same description as above in emulator format). +# - Overwrite hardware's logging output source(Same description as above in emulator output). +# +# - File Creation Mode indicates file overwriting if file exist. +# + OVERWRITE, Overwrites if file(s) exist. +# + APPEND, Continue logging after the old logging information if file(s) exist. +# +# - Will thread id include to the log filename. +# + YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'. +# + NO, No thread id to log file(s), Example filename 'Module.txt'. +# +# - Will time stamps include the to log file. +# + YES, Time stamp added to each line in log file(s). Time stamp is +# for example'12.Nov.2003 115958 LOGGING INFO' +# + NO, No time stamp(s). +# +# - Will line breaks include to the log file. +# + YES, Each logging event includes line break and next log event is in own line. +# + NO, No line break(s). +# +# - Will event ranking include to the log file. +# + YES, Event ranking number added to each line in log file(s). Ranking number +# depends on environment's tics, for example(includes time stamp also) +# '012 12.Nov.2003 115958 LOGGING INFO' +# + NO, No event ranking. +# +# - Will write log file in unicode format. +# + YES, Log file will be written in unicode format +# + NO, Log will be written as normal, not unicode, file. +# + +[Logger_Defaults] + +#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#' +#NOTE: TestEngine and TestServer logging settings cannot change here + +#CreateLogDirectories= YES # Possible values: YES or NO + +#EmulatorBasePath= C:\LOGS\TestFramework\ +#EmulatorFormat= HTML # Possible values: TXT or HTML +#EmulatorOutput= FILE # Possible values: FILE or RDEBUG + +#HardwareBasePath= D:\LOGS\TestFramework\ +#HardwareFormat= HTML # Possible values: TXT or HTML +#HardwareOutput= FILE # Possible values: FILE or RDEBUG + +#FileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +#ThreadIdToLogFile= YES # Possible values: YES or NO +#WithTimeStamp= YES # Possible values: YES or NO +#WithLineBreak= YES # Possible values: YES or NO +#WithEventRanking= YES # Possible values: YES or NO + +#FileUnicode= YES # Possible values: YES or NO +#AddTestCaseTitle= YES # Possible values: YES or NO +[End_Logger_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set filters to be used by ConsoleUI. +# If you want to use filter with ConsoleUI, simply remove comments +# from section below and provide valid filter entries. +# Each filter line has to start with "filter= " keyword. +# Filter can contain special wildcard characters: +# * which stands for none or any literal; +# ? which stands for single character. +# Filters are not case-sensitive. + +#[Filters] +#filter= *math* +#filter= *radio* +#[End_Filters] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + +# End of file diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/STF/inc/TestFileStore.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/STF/inc/TestFileStore.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,192 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: STIF testclass declaration +* +*/ + +#ifndef TESTFILESTORE_H +#define TESTFILESTORE_H + +// INCLUDES +#include +#include +#include +#include + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def +#define TEST_CLASS_VERSION_MAJOR 0 +#define TEST_CLASS_VERSION_MINOR 0 +#define TEST_CLASS_VERSION_BUILD 0 + +// Logging path +_LIT( KTestFileStoreLogPath, "\\logs\\testframework\\TestFileStore\\" ); +// Log file +_LIT( KTestFileStoreLogFile, "TestFileStore.txt" ); +_LIT( KTestFileStoreLogFileWithTitle, "TestFileStore_[%S].txt" ); + +// FUNCTION PROTOTYPES +//?type ?function_name(?arg_list); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; +class CTestFileStore; + +// DATA TYPES +//enum ?declaration +//typedef ?declaration +//extern ?data_type; + +// CLASS DECLARATION + +/** +* CTestFileStore test class for STIF Test Framework TestScripter. +* ?other_description_lines +* +* @lib ?library +* @since ?Series60_version +*/ +NONSHARABLE_CLASS(CTestFileStore) : public CScriptBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CTestFileStore* NewL( CTestModuleIf& aTestModuleIf ); + + /** + * Destructor. + */ + virtual ~CTestFileStore(); + + public: // New functions + + /** + * ?member_description. + * @since ?Series60_version + * @param ?arg1 ?description + * @return ?description + */ + //?type ?member_function( ?type ?arg1 ); + + public: // Functions from base classes + + /** + * From CScriptBase Runs a script line. + * @since ?Series60_version + * @param aItem Script line containing method name and parameters + * @return Symbian OS error code + */ + virtual TInt RunMethodL( CStifItemParser& aItem ); + + protected: // New functions + + /** + * ?member_description. + * @since ?Series60_version + * @param ?arg1 ?description + * @return ?description + */ + //?type ?member_function( ?type ?arg1 ); + + protected: // Functions from base classes + + /** + * From ?base_class ?member_description + */ + //?type ?member_function(); + + private: + + /** + * C++ default constructor. + */ + CTestFileStore( CTestModuleIf& aTestModuleIf ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + // Prohibit copy constructor if not deriving from CBase. + // ?classname( const ?classname& ); + // Prohibit assigment operator if not deriving from CBase. + // ?classname& operator=( const ?classname& ); + + /** + * Frees all resources allocated from test methods. + * @since ?Series60_version + */ + void Delete(); + + /** + * Test methods are listed below. + */ + + /** + * Example test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt ExampleL( CStifItemParser& aItem ); + + virtual TInt PanicExample(CStifItemParser& aItem); + + virtual TInt TestFileServerCreateFile( CStifItemParser& aItem ); + + virtual TInt TestFileServerWriteFile( CStifItemParser& aItem ); + + virtual TInt TestFileServerReadFile( CStifItemParser& aItem ); + + /** + * Method used to log version of test class + */ + void SendTestClassVersion(); + + //ADD NEW METHOD DEC HERE + //[TestMethods] - Do not remove + + public: // Data + // ?one_line_short_description_of_data + //?data_declaration; + + protected: // Data + // ?one_line_short_description_of_data + //?data_declaration; + + private: // Data + + // ?one_line_short_description_of_data + //?data_declaration; + + // Reserved pointer for future extension + //TAny* iReserved; + + public: // Friend classes + //?friend_class_declaration; + protected: // Friend classes + //?friend_class_declaration; + private: // Friend classes + //?friend_class_declaration; + + }; + +#endif // TESTFILESTORE_H + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/STF/src/TestFileStore.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/STF/src/TestFileStore.cpp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,199 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains testclass implementation. +* +*/ + +// INCLUDE FILES +#include +#include "TestFileStore.h" +#include + +// EXTERNAL DATA STRUCTURES +//extern ?external_data; + +// EXTERNAL FUNCTION PROTOTYPES +//extern ?external_function( ?arg_type,?arg_type ); + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def + +// LOCAL CONSTANTS AND MACROS +//const ?type ?constant_var = ?constant; +//#define ?macro_name ?macro_def + +// MODULE DATA STRUCTURES +//enum ?declaration +//typedef ?declaration + +// LOCAL FUNCTION PROTOTYPES +//?type ?function_name( ?arg_type, ?arg_type ); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; + +// ============================= LOCAL FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// ?function_name ?description. +// ?description +// Returns: ?value_1: ?description +// ?value_n: ?description_line1 +// ?description_line2 +// ----------------------------------------------------------------------------- +// +/* +?type ?function_name( + ?arg_type arg, // ?description + ?arg_type arg) // ?description + { + + ?code // ?comment + + // ?comment + ?code + } +*/ + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CTestFileStore::CTestFileStore +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CTestFileStore::CTestFileStore( + CTestModuleIf& aTestModuleIf ): + CScriptBase( aTestModuleIf ) + { + } + +// ----------------------------------------------------------------------------- +// CTestFileStore::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CTestFileStore::ConstructL() + { + //Read logger settings to check whether test case name is to be + //appended to log file name. + RSettingServer settingServer; + TInt ret = settingServer.Connect(); + if(ret != KErrNone) + { + User::Leave(ret); + } + // Struct to StifLogger settigs. + TLoggerSettings loggerSettings; + // Parse StifLogger defaults from STIF initialization file. + ret = settingServer.GetLoggerSettings(loggerSettings); + if(ret != KErrNone) + { + User::Leave(ret); + } + // Close Setting server session + settingServer.Close(); + + TFileName logFileName; + + if(loggerSettings.iAddTestCaseTitle) + { + TName title; + TestModuleIf().GetTestCaseTitleL(title); + logFileName.Format(KTestFileStoreLogFileWithTitle, &title); + } + else + { + logFileName.Copy(KTestFileStoreLogFile); + } + + iLog = CStifLogger::NewL( KTestFileStoreLogPath, + logFileName, + CStifLogger::ETxt, + CStifLogger::EFile, + EFalse ); + + SendTestClassVersion(); + } + +// ----------------------------------------------------------------------------- +// CTestFileStore::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CTestFileStore* CTestFileStore::NewL( + CTestModuleIf& aTestModuleIf ) + { + CTestFileStore* self = new (ELeave) CTestFileStore( aTestModuleIf ); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + + return self; + + } + +// Destructor +CTestFileStore::~CTestFileStore() + { + + // Delete resources allocated from test methods + Delete(); + + // Delete logger + delete iLog; + + } + +//----------------------------------------------------------------------------- +// CTestFileStore::SendTestClassVersion +// Method used to send version of test class +//----------------------------------------------------------------------------- +// +void CTestFileStore::SendTestClassVersion() + { + TVersion moduleVersion; + moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR; + moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR; + moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD; + + TFileName moduleName; + moduleName = _L("TestFileStore.dll"); + + TBool newVersionOfMethod = ETrue; + TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod); + } + +// ========================== OTHER EXPORTED FUNCTIONS ========================= + +// ----------------------------------------------------------------------------- +// LibEntryL is a polymorphic Dll entry point. +// Returns: CScriptBase: New CScriptBase derived object +// ----------------------------------------------------------------------------- +// +EXPORT_C CScriptBase* LibEntryL( + CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework + { + + return ( CScriptBase* ) CTestFileStore::NewL( aTestModuleIf ); + + } + + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/STF/src/TestFileStoreBlocks.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/STF/src/TestFileStoreBlocks.cpp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,309 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains testclass implementation. +* +*/ + +// [INCLUDE FILES] - do not remove +#include +#include +#include +#include "TestFileStore.h" + +// EXTERNAL DATA STRUCTURES +//extern ?external_data; + +// EXTERNAL FUNCTION PROTOTYPES +//extern ?external_function( ?arg_type,?arg_type ); + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def + +// LOCAL CONSTANTS AND MACROS +//const ?type ?constant_var = ?constant; +//#define ?macro_name ?macro_def + +// MODULE DATA STRUCTURES +//enum ?declaration +//typedef ?declaration + +// LOCAL FUNCTION PROTOTYPES +//?type ?function_name( ?arg_type, ?arg_type ); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; + +// ============================= LOCAL FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// ?function_name ?description. +// ?description +// Returns: ?value_1: ?description +// ?value_n: ?description_line1 +// ?description_line2 +// ----------------------------------------------------------------------------- +// +/* +?type ?function_name( + ?arg_type arg, // ?description + ?arg_type arg) // ?description + { + + ?code // ?comment + + // ?comment + ?code + } +*/ + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CTestFileStore::Delete +// Delete here all resources allocated and opened from test methods. +// Called from destructor. +// ----------------------------------------------------------------------------- +// +void CTestFileStore::Delete() + { + + } + +// ----------------------------------------------------------------------------- +// CTestFileStore::RunMethodL +// Run specified method. Contains also table of test mothods and their names. +// ----------------------------------------------------------------------------- +// +TInt CTestFileStore::RunMethodL( + CStifItemParser& aItem ) + { + + static TStifFunctionInfo const KFunctions[] = + { + // Copy this line for every implemented function. + // First string is the function name used in TestScripter script file. + // Second is the actual implementation member function. + ENTRY( "Example", CTestFileStore::ExampleL ), + ENTRY( "PanicExample", CTestFileStore::PanicExample ), + ENTRY( "CreateFile", CTestFileStore::TestFileServerCreateFile ), + ENTRY( "WriteFile", CTestFileStore::TestFileServerWriteFile ), + ENTRY( "ReadFile", CTestFileStore::TestFileServerReadFile ) + //ADD NEW ENTRY HERE + // [test cases entries] - Do not remove + + }; + + const TInt count = sizeof( KFunctions ) / + sizeof( TStifFunctionInfo ); + + return RunInternalL( KFunctions, count, aItem ); + + } + +// ----------------------------------------------------------------------------- +// CTestFileStore::ExampleL +// Example test method function. +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CTestFileStore::ExampleL( CStifItemParser& aItem ) + { + + // Print to UI + _LIT( KTestFileStore, "TestFileStore" ); + _LIT( KExample, "In Example" ); + TestModuleIf().Printf( 0, KTestFileStore, KExample ); + // Print to log file + iLog->Log( KExample ); + + TInt i = 0; + TPtrC string; + _LIT( KParam, "Param[%i]: %S" ); + while ( aItem.GetNextString ( string ) == KErrNone ) + { + TestModuleIf().Printf( i, KTestFileStore, + KParam, i, &string ); + i++; + } + + return KErrNone; + + } + + +TInt CTestFileStore::TestFileServerCreateFile( CStifItemParser& aItem ) + { + // Print to UI + _LIT( KSTIF_TestFileServer, "STIF_TestFileServer" ); + _LIT( KExample, "Create File" ); + TestModuleIf().Printf( 0, KSTIF_TestFileServer, KExample ); + // Print to log file + iLog->Log( KExample ); + + TInt retValue = KErrNone ; + TInt expErrorCode = 0; + TPtrC filename; + + TInt erro = aItem.GetNextString ( filename ); + if( erro == KErrNone ) + { + iLog->Log( filename ); + RFs fileSession; + TRAP(erro, fileSession.Connect()) + if ( erro != KErrNone) + { + iLog->Log(_L("Failed to connect to the file server")); + retValue = erro; + } + else + { + RFile file; + + CleanupClosePushL(fileSession); + + erro = file.Create( fileSession, filename, EFileRead | EFileWrite ); + if(erro==expErrorCode) + { + iLog->Log(_L("===>Opening file passed with error code %D==="), erro); + } + else + { + iLog->Log(_L("--->Error in opening file expected error code %D error returned %D"), expErrorCode, erro); + } + CleanupStack::PopAndDestroy(&fileSession); + retValue = erro; + } + } + + return retValue; + } + + +TInt CTestFileStore::TestFileServerWriteFile( CStifItemParser& aItem ) + { + // Print to UI + _LIT( KSTIF_TestFileServer, "STIF_TestFileServer" ); + _LIT( KExample, "Open File" ); + TestModuleIf().Printf( 0, KSTIF_TestFileServer, KExample ); + // Print to log file + iLog->Log( KExample ); + + TInt retValue = KErrNone ; + TInt expErrorCode = 0; + TPtrC filename; + + TInt erro = aItem.GetNextString ( filename ); + if( erro == KErrNone ) + { + iLog->Log( filename ); + RFs fileSession; + TRAP(erro, fileSession.Connect()) + if ( erro != KErrNone) + { + iLog->Log(_L("Failed to connect to the file server")); + } + else + { + RFile file; + + CleanupClosePushL(fileSession); + erro = file.Open(fileSession,filename,EFileRead); + if(erro==expErrorCode) + { + iLog->Log(_L("===>Opening file passed with error code %D==="), erro); + } + else + { + iLog->Log(_L("--->Error in opening file expected error code %D error returned %D"), expErrorCode, erro); + } + CleanupStack::PopAndDestroy(&fileSession); + } + retValue = erro; + } + + return retValue; + } + +TInt CTestFileStore::TestFileServerReadFile( CStifItemParser& aItem ) + { + // Print to UI + _LIT( KSTIF_TestFileServer, "STIF_TestFileServer" ); + _LIT( KExample, "Open File" ); + TestModuleIf().Printf( 0, KSTIF_TestFileServer, KExample ); + // Print to log file + iLog->Log( KExample ); + + TInt retValue = KErrNone ; + TInt expErrorCode = 0; + TPtrC filename; + + TInt erro = aItem.GetNextString ( filename ); + if( erro == KErrNone ) + { + iLog->Log( filename ); + RFs fileSession; + TRAP(erro, fileSession.Connect()) + if ( erro != KErrNone) + { + iLog->Log(_L("Failed to connect to the file server")); + } + else + { + RFile file; + + CleanupClosePushL(fileSession); + erro = file.Open(fileSession,filename,EFileRead); + if(erro==expErrorCode) + { + iLog->Log(_L("===>Opening file passed with error code %D==="), erro); + } + else + { + iLog->Log(_L("--->Error in opening file expected error code %D error returned %D"), expErrorCode, erro); + } + CleanupStack::PopAndDestroy(&fileSession); + } + retValue = erro; + } + + return retValue; + } + + +TInt CTestFileStore::PanicExample(CStifItemParser& aItem) + { + _LIT( KSTIF_TestFileServer, "STIF_TestFileServer" ); + _LIT( KFunction, "PanicExample" ); + TestModuleIf().Printf( 0, KSTIF_TestFileServer, KFunction ); + iLog->Log( KFunction ); + TInt expectedPanicCode = 0; + TPtrC expectedPanicString; + TInt err1 = aItem.GetNextString(expectedPanicString); + TInt err2 = aItem.GetNextInt(expectedPanicCode); + if ( err1 != KErrNone || err2 != KErrNone) + { + iLog->Log(_L("Failed to read expected panic code")); + User::Panic(_L("USER-EXEC"), 1); + } + else + { + iLog->Log( _L("Create expected panic number= %D"), expectedPanicCode); + iLog->Log( _L("Create expected panic String= %S"), &expectedPanicString); + User::Panic(expectedPanicString, expectedPanicCode); + } + return KErrNone; + } diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/TEF_BLOCK/data/TestFileServer_TEF.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/TEF_BLOCK/data/TestFileServer_TEF.ini Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,15 @@ +// Sample TestFileServer_TEF.ini +// Your copyright notice + +[fileserver] +name =fileserver + +[MyParamsSection] +FileName = c:\testfileserver.test + +[RepeatSection] +repeatParam = 10 + +[PanicSection] +PanicString = USER +PanicCode = 5 diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/TEF_BLOCK/group/TestFileServer_TEF.driver --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/TEF_BLOCK/group/TestFileServer_TEF.driver Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/TEF_BLOCK/group/TestFileServer_TEF.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/TEF_BLOCK/group/TestFileServer_TEF.iby Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef __TestFileServer_TEF_IBY__ +#define __TestFileServer_TEF_IBY__ + +#include + +file=ABI_DIR\BUILD_DIR\TestFileServer_TEF.exe sys\bin\TestFileServer_TEF.exe +data=EPOCROOT##Epoc32\winscw\c\data\TestFileServer_TEF.ini \data\TestFileServer_TEF.ini +data=EPOCROOT##Epoc32\winscw\c\scripts\TestFileServer_TEF.script \scripts\TestFileServer_TEF.script + +#endif diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/TEF_BLOCK/group/TestFileServer_TEF.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/TEF_BLOCK/group/TestFileServer_TEF.mmp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implements common reset module for STIF +* TestFramework. According to this DLL template can be implemented +* licensee specific reset module. +* +*/ +#include + +TARGET TestFileServer_TEF.exe +TARGETTYPE exe +UID 0x1000007B 0x06B13B52 + +//Please add any change under here +SOURCEPATH ..\src +SOURCE TestFileServer_TEFBlockServer.cpp +SOURCE TestFileServer_TEFBlockController.cpp +SOURCE CTestFileServerWrapper.cpp + + +USERINCLUDE ..\inc + +SYSTEMINCLUDE \epoc32\include +SYSTEMINCLUDE \epoc32\include\test + +OS_LAYER_SYSTEMINCLUDE + +//Please add your system include under here. + +LIBRARY euser.lib +LIBRARY testexecuteutils.lib +LIBRARY testexecutelogclient.lib +LIBRARY efsrv.lib +LIBRARY iniparser.lib + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/TEF_BLOCK/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/TEF_BLOCK/group/bld.inf Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +// BLD.INF +// +// Your copyright notice + +PRJ_EXPORTS + +PRJ_TESTEXPORTS +..\scripts\TestFileServer_TEF.script \epoc32\winscw\c\scripts\TestFileServer_TEF.script +..\data\TestFileServer_TEF.ini \epoc32\winscw\c\data\TestFileServer_TEF.ini +.\TestFileServer_TEF.iby \epoc32\rom\include\TestFileServer_TEF.iby + +PRJ_MMPFILES +// None + +PRJ_TESTMMPFILES +TestFileServer_TEF.mmp \ No newline at end of file diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/TEF_BLOCK/inc/CTestFileServerWrapper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/TEF_BLOCK/inc/CTestFileServerWrapper.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,84 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef __CTESTFILESERVERWRAPPER_H__ +#define __CTESTFILESERVERWRAPPER_H__ + +#include + +class CTestFileServerWrapper : public CDataWrapper + { +public: + // Default Constructor + CTestFileServerWrapper(); + // Default Destructor + ~CTestFileServerWrapper(); + + // Two-Phase Constructor + static CTestFileServerWrapper* NewL(); + + // Command Dispatcher + virtual TBool DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex); + + // Getter for the wrapped object + virtual TAny* GetObject() { return iObject; } + + // Setter for the wrapped object + inline virtual void SetObjectL(TAny* aObject) + { + delete iObject; + iObject = NULL; + iObject = static_cast (aObject); + } + + + // Asynchronous Run + void RunL(CActive* aActive, TInt aIndex); + + inline virtual void DisownObjectL() + { + iObject = NULL; + } + inline virtual TCleanupOperation CleanupOperation() + { + return CleanupOperation; + } + +protected: + void ConstructL(); + +private: + // Testing CTestFileServer::CreateFile + inline void DoCmdCreateFile(const TDesC& aSection); + + // Testing CTestFileServer::ReadFile + inline void DoCmdReadFile(const TDesC& aSection); + + inline void DoCmdPanicExample(const TDesC& aSection); + + static void CleanupOperation(TAny* aAny) + { + CTestFileServerWrapper* myObject = static_cast(aAny); + delete myObject; + } + + +private: + CActiveCallback* iActiveCallback; + TAny* iObject; + }; +#endif // __CTESTFILESERVERWRAPPER_H__ diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/TEF_BLOCK/inc/TestFileServer_TEFBlockController.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/TEF_BLOCK/inc/TestFileServer_TEFBlockController.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#if (!defined __TESTFILESERVER_TEF_BLOCK_CONTROLLER_H__) +#define __TESTFILESERVER_TEF_BLOCK_CONTROLLER_H__ +#include +#include "CTestFileServerWrapper.h" + +class CTestFileServer_TEFBlockController : public CTestBlockController + { +public: + static CTestFileServer_TEFBlockController* NewL(); + // Base class pure virtual override + virtual CDataWrapper* CreateDataL(const TDesC& aData); + +// Please Add/modify your class members +private: + }; + +#endif diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/TEF_BLOCK/inc/TestFileServer_TEFBlockServer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/TEF_BLOCK/inc/TestFileServer_TEFBlockServer.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#if (!defined __TESTFILESERVER_TEF_BLOCK_SERVER_H__) +#define __TESTFILESERVER_TEF_BLOCK_SERVER_H__ +#include +#include "TestFileServer_TEFBlockController.h" + +class CTestFileServer_TEFBlockServer : public CTestServer2 + { +public: + static CTestFileServer_TEFBlockServer* NewL(); + // Base class pure virtual override + virtual CTestBlockController* CreateTestBlock(); + +// Please Add/modify your class members +private: + }; + +#endif diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/TEF_BLOCK/scripts/TestFileServer_TEF.script --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/TEF_BLOCK/scripts/TestFileServer_TEF.script Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,71 @@ +// +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// +// Sample TestFileServer_TEF.script +// Your copyright notice + +LOAD_SUITE TestFileServer_TEF + +START_TESTCASE TEST-CASE1 + START_TEST_BLOCK 100 TestFileServer_TEF c:\data\TestFileServer_TEF.ini + CREATE_OBJECT CTestFileServerWrapper fileserver + COMMAND !Error=-11 fileserver CreateFile MyParamsSection + END_TEST_BLOCK +END_TESTCASE TEST-CASE1 + +START_TESTCASE TEST-CASE2 + START_TEST_BLOCK 100 TestFileServer_TEF c:\data\TestFileServer_TEF.ini + CREATE_OBJECT CTestFileServerWrapper fileserver + //START_REPEAT c:\data\TestFileServer_TEF.ini RepeatSection repeatParam + //PRINT Loop test + COMMAND fileserver ReadFile MyParamsSection + //END_REPEAT + END_TEST_BLOCK +END_TESTCASE TEST-CASE2 + +START_TESTCASE TEST-CASE3 + START_TEST_BLOCK 100 TestFileServer_TEF c:\data\TestFileServer_TEF.ini + CREATE_OBJECT CTestFileServerWrapper fileserver + DELAY 2000 + COMMAND fileserver ReadFile MyParamsSection + END_TEST_BLOCK +END_TESTCASE TEST-CASE3 + + +START_TESTCASE TEST-CASE4 + START_TEST_BLOCK 100 TestFileServer_TEF c:\data\TestFileServer_TEF.ini + CREATE_OBJECT CTestFileServerWrapper fileserver + COMMAND fileserver PanicExample PanicSection + END_TEST_BLOCK !PanicString=USER !PanicCode=5 +END_TESTCASE TEST-CASE4 + + + +CONCURRENT + +START_TESTCASE TEST-SAMPLE-CONCURRENT + START_TEST_BLOCK 100 TestFileServer_TEF c:\data\TestFileServer_TEF.ini + CREATE_OBJECT CTestFileServerWrapper fileserver + COMMAND fileserver ReadFile MyParamsSection + END_TEST_BLOCK + START_TEST_BLOCK 100 TestFileServer_TEF c:\data\TestFileServer_TEF.ini + CREATE_OBJECT CTestFileServerWrapper fileserver + COMMAND !Error=-14 fileserver ReadFile MyParamsSection + END_TEST_BLOCK + START_TEST_BLOCK 100 TestFileServer_TEF c:\data\TestFileServer_TEF.ini + CREATE_OBJECT CTestFileServerWrapper fileserver + COMMAND !Error=-14 fileserver ReadFile MyParamsSection + END_TEST_BLOCK +END_TESTCASE TEST-SAMPLE-CONCURRENT diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/TEF_BLOCK/src/CTestFileServerWrapper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/TEF_BLOCK/src/CTestFileServerWrapper.cpp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,247 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "CTestFileServerWrapper.h" +_LIT(KCreateFile, "CreateFile"); +_LIT(KReadFile, "ReadFile"); +_LIT(KPanicExample, "PanicExample"); +_LIT(KFileName, "FileName"); +_LIT(KPanicString, "PanicString"); +_LIT(KPanicCode, "PanicCode"); + +CTestFileServerWrapper::CTestFileServerWrapper() : + iObject(NULL) + { + } + +CTestFileServerWrapper::~CTestFileServerWrapper() + { + delete iObject; + iObject = NULL; + } + +CTestFileServerWrapper*CTestFileServerWrapper::NewL() + { + CTestFileServerWrapper* ret = new (ELeave) CTestFileServerWrapper(); + CleanupStack::PushL(ret); + ret->ConstructL(); + CleanupStack::Pop(ret); + return ret; + } + +void CTestFileServerWrapper::ConstructL() + { + iActiveCallback = CActiveCallback::NewL(*this); + // TODO : Initialize wrppped object + + } + +void CTestFileServerWrapper::RunL(CActive* aActive, TInt aIndex) + { + TInt err = aActive->iStatus.Int(); + SetAsyncError(aIndex, err); + DecOutstanding(); + } + +TBool CTestFileServerWrapper::DoCommandL(const TTEFFunction& aCommand, + const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/) + { + TBool ret = ETrue; + + if (KCreateFile() == aCommand) + { + // Testing CTestFileServer::CreateFile + DoCmdCreateFile(aSection); + } + else if (KReadFile() == aCommand) + { + // Testing CTestFileServer::ReadFile + DoCmdReadFile(aSection); + } + else if (KPanicExample() == aCommand) + { + DoCmdPanicExample(aSection); + } + else + { + ret = EFalse; + } + return ret; + } + +// Testing CTestFileServer::CreateFile +void CTestFileServerWrapper::DoCmdCreateFile(const TDesC& aSection) + { + INFO_PRINTF1(_L("Running CreateFile()")); + // TODO : Add a method test here + // iObject->CreateFile + TInt err = 0; + TPtrC fileName; + + if (!GetStringFromConfig(aSection, KFileName, fileName)) + { + ERR_PRINTF1(_L("File Name noinline void DoCmdCreateFile(const TTEFSectionName& aSection); specified")); + SetBlockResult(EFail); + } + else + { + INFO_PRINTF2(_L("File to be opened is= %S "),&fileName); + + RFs fileSession; + TRAP(err, fileSession.Connect()) + if (err != KErrNone) + { + ERR_PRINTF1(_L("Failed to connect to the file server")); + SetBlockResult(EFail); + } + else + { + RFile file; + + CleanupClosePushL(fileSession); + err = file.Create(fileSession, fileName, EFileRead | EFileWrite); + if (err == KErrNone) + { + INFO_PRINTF1(_L("===>Opening file passed")); + } + else + { + ERR_PRINTF2(_L("--->Error in opening file error returned %D"), err); + SetError(err); + } + CleanupStack::PopAndDestroy(&fileSession); + } + } + // TODO : Please make changes for checking your test result + //SetBlockResult(EPass); + } + +// Testing CTestFileServer::ReadFile +void CTestFileServerWrapper::DoCmdReadFile(const TDesC& aSection) + { + INFO_PRINTF1(_L("Running ReadFile()")); + // TODO : Add a method test here + // iObject->ReadFile + { + TInt err = 0; + TPtrC fileName; + + INFO_PRINTF1(_L("In test step ReadFile")); + + //Getting the file name from ini file + if (!GetStringFromConfig(aSection, KFileName, fileName)) + { + ERR_PRINTF1(_L("File Name not specified")); + SetBlockResult(EFail); + } + else + { + INFO_PRINTF2(_L("File to be opened is= %S "),&fileName); + } + + if (BlockResult() == EPass) + { + RFs fileSession; + //Connecting to the file server + TRAP(err, fileSession.Connect()) + if (err != KErrNone) + { + ERR_PRINTF1(_L("Failed to connect to the file server")); + SetError(err); + } + else + { + RFile file; + + CleanupClosePushL(fileSession); + //Opening the file + err = file.Open(fileSession, fileName, EFileRead); + if (err != KErrNone) + { + ERR_PRINTF1(_L("Error in Opening file")); + SetError(err); + } + else + { + CleanupClosePushL(file); + TInt fileSize = 0; + err = file.Size(fileSize); + if (err == KErrNone) + { + HBufC8 *data = HBufC8::NewLC(fileSize); + TPtr8 ptr = data->Des(); + // RaiseInstrumentationEventNotificationL(MTestInstrumentation::EPointFilestoreReadFileStart); + err = file.Read(ptr); + // RaiseInstrumentationEventNotificationL(MTestInstrumentation::EPointFilestoreReadFileStop); + if (err != KErrNone) + { + ERR_PRINTF1(_L("Error in reading the file")); + SetError(err); + } + else + { + INFO_PRINTF1(_L("Read File passed with no error code")); + SetBlockResult(EPass); + } + CleanupStack::PopAndDestroy(data); + } + else + { + ERR_PRINTF1(_L("Error in finding size of the file")); + SetError(err); + } + file.Close(); + CleanupStack::PopAndDestroy(&file); + + } + CleanupStack::PopAndDestroy(&fileSession); + } + } + + // TODO : Please make changes for checking your test result + } + SetBlockResult(EPass); + } + +void CTestFileServerWrapper::DoCmdPanicExample(const TDesC& aSection) + { + INFO_PRINTF1(_L("Running DoCmdPanicExample()")); + //Getting the panic name from ini file + TInt panicCode = 0; + TPtrC panicString; + if (!GetStringFromConfig(aSection, KPanicString, panicString)) + { + ERR_PRINTF1(_L("Panic string not specified")); + SetBlockResult(EFail); + } + else + { + INFO_PRINTF2(_L("Get Panic String= %S "),&panicString); + } + if (!GetIntFromConfig(aSection, KPanicCode, panicCode)) + { + ERR_PRINTF1(_L("Panic code not specified")); + SetBlockResult(EFail); + } + else + { + INFO_PRINTF2(_L("Get Panic Code= %d "),panicCode); + } + + User::Panic(panicString, panicCode); + + } diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/TEF_BLOCK/src/TestFileServer_TEFBlockController.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/TEF_BLOCK/src/TestFileServer_TEFBlockController.cpp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "TestFileServer_TEFBlockController.h" + +_LIT(KCTestFileServerWrapper, "CTestFileServerWrapper"); + +CTestFileServer_TEFBlockController* CTestFileServer_TEFBlockController::NewL() +/** + * @return - Instance of the test block controller + */ + { + CTestFileServer_TEFBlockController* block = new (ELeave) CTestFileServer_TEFBlockController(); + return block; + } + + +CDataWrapper* CTestFileServer_TEFBlockController::CreateDataL(const TDesC& aData) + { + CDataWrapper* wrapper = NULL; + if (KCTestFileServerWrapper() == aData) + { + wrapper = CTestFileServerWrapper::NewL(); + } + + return wrapper; + } diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/TEF_BLOCK/src/TestFileServer_TEFBlockServer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/TEF_BLOCK/src/TestFileServer_TEFBlockServer.cpp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,88 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "TestFileServer_TEFBlockServer.h" + +CTestFileServer_TEFBlockServer* CTestFileServer_TEFBlockServer::NewL() + { + CTestFileServer_TEFBlockServer* server = new (ELeave) CTestFileServer_TEFBlockServer(); + CleanupStack::PushL(server); + server->ConstructL(); + CleanupStack::Pop(server); + return server; + } + +CTestBlockController* CTestFileServer_TEFBlockServer::CreateTestBlock() +/** + * @return - Instance of the test block controller + * Called when CTestFileServer_TEFBlockServer initializing. + */ + { + CTestBlockController* controller = NULL; + TRAPD(err, controller = CTestFileServer_TEFBlockController::NewL()); + return controller; + } + +// Secure variants much simpler +// For EKA2, just an E32Main and a MainL() +LOCAL_C void MainL() +/** + * Secure variant + * Much simpler, uses the new Rendezvous() call to sync with the client + */ + { + // Leave the hooks in for platform security +#if (defined __DATA_CAGING__) + RProcess().DataCaging(RProcess::EDataCagingOn); + RProcess().DataCaging(RProcess::ESecureApiOn); +#endif + CActiveScheduler* sched=NULL; + sched=new(ELeave) CActiveScheduler; + CActiveScheduler::Install(sched); + CTestFileServer_TEFBlockServer* server = NULL; + // Create the CTestFileServer_TEFBlockServer derived server + TRAPD(err,server = CTestFileServer_TEFBlockServer::NewL()); + if(!err) + { + // Sync with the client and enter the active scheduler + RProcess::Rendezvous(KErrNone); + sched->Start(); + } + delete server; + delete sched; + } + + + +GLDEF_C TInt E32Main() +/** + * @return - Standard Epoc error code on process exit + * Secure variant only + * Process entry point. Called by client using RProcess API + */ + { + __UHEAP_MARK; + CTrapCleanup* cleanup = CTrapCleanup::New(); + if(cleanup == NULL) + { + return KErrNoMemory; + } + TRAPD(err,MainL()); + delete cleanup; + __UHEAP_MARKEND; + return err; + } diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/TEF_STEP/data/SystestFilestoreSuite.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/TEF_STEP/data/SystestFilestoreSuite.ini Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,16 @@ +[Case1Section] +filename = c:\testfileserver.test + +[Case2Section] +filename = c:\testfileserver.test +repeatParam = 3 + +[Case3Section] +panicString = USER +panicCode = 5 + +[Case4Section] +filename = c:\testfileserver.test + +[Case5Section] +filename = c:\testfileserver.test \ No newline at end of file diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/TEF_STEP/group/TEF_STEP.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/TEF_STEP/group/TEF_STEP.mmp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include + +TARGET TEFSTEPFileStore.exe +TARGETTYPE exe +UID 0 0xEBA805B7 + +SYSTEMINCLUDE \epoc32\include +SYSTEMINCLUDE \epoc32\include\test + +OS_LAYER_SYSTEMINCLUDE + +USERINCLUDE ..\inc + +#ifdef ENABLE_ABIV2_MODE +DEBUGGABLE_UDEBONLY +#endif +SOURCEPATH ..\src +SOURCE SystestFilestoreSuiteServer.cpp TestFSCreateFile.cpp TestFSReadFile.cpp + +LIBRARY euser.lib +LIBRARY testexecuteutils.lib +LIBRARY testexecutelogclient.lib + +LIBRARY efsrv.lib + +SOURCEPATH ..\src +SOURCE TestFSPanicExample.cpp diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/TEF_STEP/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/TEF_STEP/group/bld.inf Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS +..\scripts\SystestFilestoreSuite.script \epoc32\winscw\c\scripts\SystestFilestoreSuite.script +..\data\SystestFilestoreSuite.ini \epoc32\winscw\c\data\SystestFilestoreSuite.ini + +PRJ_MMPFILES +TEF_STEP.mmp diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/TEF_STEP/inc/SystestFilestoreSuiteServer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/TEF_STEP/inc/SystestFilestoreSuiteServer.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#if (!defined __SYSTESTFILESTORE_SERVER_H__) +#define __SYSTESTFILESTORE_SERVER_H__ +#include + + +class CSystestFilestoreSuite : public CTestServer + { +public: + static CSystestFilestoreSuite* NewL(); + // Base class pure virtual override + virtual CTestStep* CreateTestStep(const TDesC& aStepName); + +// Please Add/modify your class members +private: + }; + +#endif diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/TEF_STEP/inc/TestFSCreateFile.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/TEF_STEP/inc/TestFSCreateFile.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#if (!defined __TEST_FS_CREATE_FILE_H__) +#define __TEST_FS_CREATE_FILE_H__ + +// System includes + +// User includes +#include + +// Literal constant for test step name +_LIT(KCreateFile,"CreateFile"); + +class CTestFSCreateFile :public CTestStep +/** +@internalAll +@test +The class implements a test step which creates files or directories. + */ + { +public: + CTestFSCreateFile(); + ~CTestFSCreateFile(); + virtual TVerdict doTestStepL(); + + }; + +#endif /* __TEST_FS_CREATE_FILE_H__ */ diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/TEF_STEP/inc/TestFSPanicExample.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/TEF_STEP/inc/TestFSPanicExample.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef TESTFSPANICEXAMPLE_H_ +#define TESTFSPANICEXAMPLE_H_ +#include + +// Literal constant for test step name +_LIT(KPanicExample,"PanicExample"); + +class CTestFSPanicExample : public CTestStep + { +public: + CTestFSPanicExample(); + ~CTestFSPanicExample(); + virtual TVerdict doTestStepL(); + }; + +#endif /* TESTFSPANICEXAMPLE_H_ */ diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/TEF_STEP/inc/TestFSReadFile.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/TEF_STEP/inc/TestFSReadFile.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#if (!defined __TEST_FS_READ_FILE_H__) +#define __TEST_FS_READ_FILE_H__ + +// User includes +#include + +// Literal constant for test step name +_LIT(KTestFSReadFile,"ReadFile"); + +class CTestFSReadFile :public CTestStep +/** +@internalAll +@test +The class implements a test step which reads data from a file. + */ + { +public: + CTestFSReadFile(); + ~CTestFSReadFile(); + virtual TVerdict doTestStepL(); + }; + +#endif /* __TEST_FS_READ_FILE_H__ */ diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/TEF_STEP/scripts/SystestFilestoreSuite.script --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/TEF_STEP/scripts/SystestFilestoreSuite.script Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,55 @@ +// +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// +// Sample Test Script + +PRINT Run all test Suite Tests + +LOAD_SERVER TEFSTEPFileStore + +START_TESTCASE TestCase-1 +RUN_TEST_STEP !Error=-11 5 TEFSTEPFileStore CreateFile c:\data\SystestFilestoreSuite.ini Case1Section +END_TESTCASE TestCase-1 + + +START_TESTCASE TestCase-2 +START_REPEAT c:\data\SystestFilestoreSuite.ini Case2Section repeatParam +PRINT repeat testing. +RUN_TEST_STEP 1000 TEFSTEPFileStore ReadFile c:\data\SystestFilestoreSuite.ini Case2Section +END_REPEAT +END_TESTCASE TestCase-2 + +START_TESTCASE TestCase-3 +PRINT test Expected Panic. +RUN_TEST_STEP !PanicString=USER !PanicCode=5 1000 TEFSTEPFileStore PanicExample c:\data\SystestFilestoreSuite.ini Case3Section +END_TESTCASE TestCase-3 + +START_TESTCASE TestCase-4 +PRINT test Delay. +DELAY 2000 +RUN_TEST_STEP 1000 TEFSTEPFileStore ReadFile c:\data\SystestFilestoreSuite.ini Case4Section +END_TESTCASE TestCase-4 + + + + +CONCURRENT +START_TESTCASE TestCase-5 +RUN_TEST_STEP 1000 TEFSTEPFileStore ReadFile c:\data\SystestFilestoreSuite.ini Case5Section +RUN_TEST_STEP !Error=-14 1000 TEFSTEPFileStore ReadFile c:\data\SystestFilestoreSuite.ini Case5Section +RUN_TEST_STEP !Error=-14 1000 TEFSTEPFileStore ReadFile c:\data\SystestFilestoreSuite.ini Case5Section +END_TESTCASE TestCase-5 + +PRINT Complete testSuite \ No newline at end of file diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/TEF_STEP/src/SystestFilestoreSuiteServer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/TEF_STEP/src/SystestFilestoreSuiteServer.cpp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,111 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "SystestFilestoreSuiteServer.h" +#include "TestFSCreateFile.h" +#include "TestFSReadFile.h" +#include "TestFSPanicExample.h" + +_LIT(KServerName,"TEFSTEPFileStore");//SystestFilestoreSuite +CSystestFilestoreSuite* CSystestFilestoreSuite::NewL() +/** + * @return - Instance of the test server + * Same code for Secure and non-secure variants + * Called inside the MainL() function to create and start the + * CTestServer derived server. + */ + { + CSystestFilestoreSuite * server = new (ELeave) CSystestFilestoreSuite(); + CleanupStack::PushL(server); + + server->ConstructL(KServerName); + CleanupStack::Pop(server); + return server; + } + +// Secure variants much simpler +// For EKA2, just an E32Main and a MainL() +LOCAL_C void MainL() +/** + * Secure variant + * Much simpler, uses the new Rendezvous() call to sync with the client + */ + { + // Leave the hooks in for platform security +#if (defined __DATA_CAGING__) + RProcess().DataCaging(RProcess::EDataCagingOn); + RProcess().DataCaging(RProcess::ESecureApiOn); +#endif + CActiveScheduler* sched = NULL; + sched = new (ELeave) CActiveScheduler; + CActiveScheduler::Install(sched); + CSystestFilestoreSuite* server = NULL; + // Create the CTestServer derived server + TRAPD(err,server = CSystestFilestoreSuite::NewL()); + if (!err) + { + // Sync with the client and enter the active scheduler + RProcess::Rendezvous(KErrNone); + sched->Start(); + } + delete server; + delete sched; + } + +GLDEF_C TInt E32Main() +/** + * @return - Standard Epoc error code on process exit + * Secure variant only + * Process entry point. Called by client using RProcess API + */ + { + __UHEAP_MARK; + CTrapCleanup* cleanup = CTrapCleanup::New(); + if (cleanup == NULL) + { + return KErrNoMemory; + } + TRAPD(err,MainL()); + delete cleanup; + __UHEAP_MARKEND; + return err; + } + +CTestStep* CSystestFilestoreSuite::CreateTestStep(const TDesC& aStepName) +/** + * @return - A CTestStep derived instance + * Secure and non-secure variants + * Implementation of CTestServer pure virtual + */ + { + CTestStep* testStep = NULL; + + + if (aStepName == KCreateFile) + { + testStep = new CTestFSCreateFile(); + } + else if(aStepName == KTestFSReadFile) + { + testStep = new CTestFSReadFile(); + } + else if(aStepName == KPanicExample) + { + testStep = new CTestFSPanicExample(); + } + + return testStep; + } diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/TEF_STEP/src/TestFSCreateFile.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/TEF_STEP/src/TestFSCreateFile.cpp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,90 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +// User includes +#include "TestFSCreateFile.h" +// Literal constants +_LIT(KFileName, "filename"); + +CTestFSCreateFile::CTestFSCreateFile() +/** + Constructor. + + Sets the test step name. + */ + { + // Call base class method to set up the human readable name for logging + SetTestStepName(KCreateFile); + } + +CTestFSCreateFile::~CTestFSCreateFile() +/** + Destructor + */ + { + } + +TVerdict CTestFSCreateFile::doTestStepL() +/** + This is implementation of the pure virtual function of CTestStep. + It creates files or directories + @return TVerdict - the test result + */ + { + INFO_PRINTF1(_L("In test step CreateFile")); + + if (TestStepResult() == EPass) + { + + // Get file or directory name + TPtrC file; + if (GetStringFromConfig(ConfigSection(), KFileName, file)) + { + INFO_PRINTF2(_L("File name %S"), &file); + } + else + { + ERR_PRINTF1(_L("No File Name")); + SetTestStepResult(EFail); + } + + RFile rf; + RFs fileSession; + CleanupClosePushL(rf); + TRAPD(error, fileSession.Connect()) + if ( error != KErrNone) + { + ERR_PRINTF2(_L("File Session connect error, %d"), error); + SetTestStepResult(EFail); + } + CleanupClosePushL(fileSession); + TInt errCode = rf.Create(fileSession, file, EFileWrite); + CleanupStack::PopAndDestroy(&fileSession); + CleanupStack::PopAndDestroy(&rf); + + + if (KErrNone != errCode) + { + SetTestStepError(errCode); + ERR_PRINTF2(_L("--->Error in Creating file, get result %D"), errCode); + SetTestStepResult(EFail); + } + + } + return TestStepResult(); + } + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/TEF_STEP/src/TestFSPanicExample.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/TEF_STEP/src/TestFSPanicExample.cpp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "TestFSPanicExample.h" + +_LIT(KPanicString, "panicString"); +_LIT(KPanicCode, "panicCode"); + +CTestFSPanicExample::CTestFSPanicExample() + { + // TODO Auto-generated constructor stub + SetTestStepName(KPanicExample); + } + +CTestFSPanicExample::~CTestFSPanicExample() + { + // TODO Auto-generated destructor stub + } + + +TVerdict CTestFSPanicExample::doTestStepL() + { + TInt panicCode = 0; + if (GetIntFromConfig(ConfigSection(), KPanicCode, panicCode)) + { + INFO_PRINTF2(_L("Expected Panic Code= %d"), panicCode); + } + else + { + ERR_PRINTF1(_L("Panic Code not set")); + SetTestStepResult(EFail); + } + // Get file or directory name + TPtrC panicString; + if (GetStringFromConfig(ConfigSection(), KPanicString, panicString)) + { + INFO_PRINTF2(_L("Expected Panic String= %S"), &panicString); + } + else + { + ERR_PRINTF1(_L("Panic String not set")); + SetTestStepResult(EFail); + } + + User::Panic(panicString, panicCode); + return TestStepResult(); + } diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/TEF_STEP/src/TestFSReadFile.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/TEF_STEP/src/TestFSReadFile.cpp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,126 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +// User includes +#include "TestFSReadFile.h" + +// System includes +#include + + +// Literal constants +_LIT(KFileName, "filename"); + +CTestFSReadFile::CTestFSReadFile() +/** +Constructor + */ + { + // Call base class method to set up the human readable name for logging + SetTestStepName(KTestFSReadFile); + } + +CTestFSReadFile::~CTestFSReadFile() +/** +Destructor + */ + { + } + +TVerdict CTestFSReadFile::doTestStepL() +/** +This is implementation of the pure virtual function of CTestStep. +It reads data from a file. +@return TVerdict - the test result + */ + { + TInt err = 0; + TPtrC fileName; + + INFO_PRINTF1(_L("In test step ReadFile")); + + //Getting the file name from ini file + if(!GetStringFromConfig(ConfigSection(), KFileName ,fileName)) + { + ERR_PRINTF1(_L("File Name not specified")); + SetTestStepResult(EFail); + } + else + { + INFO_PRINTF2(_L("File to be opened is= %S "),&fileName); + } + + if(TestStepResult() == EPass) + { + RFs fileSession; + //Connecting to the file server + TRAP(err, fileSession.Connect()) + if ( err != KErrNone) + { + ERR_PRINTF1(_L("Failed to connect to the file server")); + SetTestStepError(err); + } + else + { + RFile file; + + CleanupClosePushL(fileSession); + //Opening the file + err = file.Open(fileSession,fileName,EFileRead); + if ( err != KErrNone) + { + ERR_PRINTF1(_L("Error in Opening file")); + SetTestStepError(err); + } + else + { + CleanupClosePushL(file); + TInt fileSize = 0; + err = file.Size(fileSize); + if(err == KErrNone) + { + HBufC8 *data = HBufC8::NewLC(fileSize); + TPtr8 ptr = data->Des(); + // RaiseInstrumentationEventNotificationL(MTestInstrumentation::EPointFilestoreReadFileStart); + err = file.Read(ptr); + // RaiseInstrumentationEventNotificationL(MTestInstrumentation::EPointFilestoreReadFileStop); + if(err != KErrNone) + { + ERR_PRINTF1(_L("Error in reading the file")); + SetTestStepError(err); + } + else + { + INFO_PRINTF1(_L("Read File passed with no error code")); + SetTestStepResult(EPass); + } + CleanupStack::PopAndDestroy(data); + } + else + { + ERR_PRINTF1(_L("Error in finding size of the file")); + SetTestStepError(err); + } + file.Close(); + CleanupStack::PopAndDestroy(&file); + + } + CleanupStack::PopAndDestroy(&fileSession); + } + } + return TestStepResult(); + } diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/doc/TEF_to_STF_Migration_Guide.doc Binary file testexecfw/stf/examples/MigrationExample/doc/TEF_to_STF_Migration_Guide.doc has changed diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/group/bld.inf Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header of additional functions +* needed for Python support and used in PythonScripter, TestEngine +* and TestCombiner. +* +*/ + +PRJ_PLATFORMS +DEFAULT + +PRJ_MMPFILES + +#include "../FileStore/TEF_BLOCK/group/bld.inf" +#include "../FileStore/TEF_STEP/group/bld.inf" +#include "../FileStore/STF/group/bld.inf" + +PRJ_MMPFILES diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/demomodule/BMARM/DEMOMODULEU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/demomodule/BMARM/DEMOMODULEU.DEF Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,4 @@ +EXPORTS + LibEntryL__Fv @ 1 NONAME R3UNUSED ; LibEntryL(void) + SetRequirements__FRP16CTestModuleParamRUl @ 2 NONAME R3UNUSED ; SetRequirements(CTestModuleParam *&, unsigned long &) + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/demomodule/BWINS/DEMOMODULEU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/demomodule/BWINS/DEMOMODULEU.DEF Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,5 @@ +EXPORTS + ?LibEntryL@@YAPAVCTestModuleBase@@XZ @ 1 NONAME ; class CTestModuleBase * __cdecl LibEntryL(void) + ?SetRequirements@@YAHAAPAVCTestModuleParam@@AAK@Z @ 2 NONAME ; int __cdecl SetRequirements(class CTestModuleParam * &,unsigned long &) + ??1TScriptObject@@UAE@XZ @ 3 NONAME ABSENT ; TScriptObject::~TScriptObject(void) + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/demomodule/eabi/Demomoduleu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/demomodule/eabi/Demomoduleu.def Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,4 @@ +EXPORTS + _Z9LibEntryLv @ 1 NONAME + _Z15SetRequirementsRP16CTestModuleParamRm @ 2 NONAME + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/demomodule/group/Demomodule.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/demomodule/group/Demomodule.mmp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: MMP file for STIF Test Framework's Demomodule. +* +*/ + +#include + +SMPSAFE +TARGET Demomodule.dll +TARGETTYPE dll +DEFFILE Demomodule.def + +CAPABILITY ALL -TCB +VENDORID 0x101FB657 +SECUREID 0x102073DB + +USERINCLUDE ../inc +USERINCLUDE ../../../inc + +OS_LAYER_SYSTEMINCLUDE + +SOURCEPATH ../src + +SOURCE DemoModule.cpp +SOURCE Demomodulecases.cpp + +LIBRARY euser.lib +LIBRARY stiftestinterface.lib +LIBRARY stiftestengine.lib + +// First UID is DLL UID, Second UID is STIF Test Framework UID +UID 0x1000008D 0x101FB3E7 +// End of File + + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/demomodule/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/demomodule/group/bld.inf Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +* Build information for STIF Test Framework's DemoModule. +*/ + +PRJ_PLATFORMS + + DEFAULT + +PRJ_TESTEXPORTS + +PRJ_EXPORTS + +PRJ_TESTMMPFILES + +PRJ_MMPFILES + + Demomodule.mmp + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/demomodule/inc/DemoModule.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/demomodule/inc/DemoModule.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,327 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of DemoModule of +* STIF TestFramework. +* +*/ + +#ifndef DEMOMODULE_H +#define DEMOMODULE_H + +// INCLUDES +#include "StifTestModule.h" +#include + +// CONSTANTS +// None + +// MACROS +// None + +// Logging path +_LIT( KDemoModuleLogPath, "\\logs\\testframework\\DemoModule\\" ); +// Log file +_LIT( KDemoModuleLogFile, "DemoModule.txt" ); +_LIT( KDemoModuleLogFileWithTitle, "DemoModule_[%S].txt" ); + +// Function pointer related internal definitions +#define GETPTR & +#define ENTRY(str,func) {_S(str), GETPTR func,0,0,0} +#define FUNCENTRY(func) {_S(#func), GETPTR func,0,0,0} +#define OOM_ENTRY(str,func,a,b,c) {_S(str), GETPTR func,a,b,c} +#define OOM_FUNCENTRY(func,a,b,c) {_S(#func), GETPTR func,a,b,c} + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +class CDemoModule; + +// DATA TYPES +// None + +// A typedef for function that does the actual testing, +// function is a type +// TInt CDemoModule:: ( TTestResult& aResult ) +typedef TInt (CDemoModule::* TestFunction)(TTestResult&); + +// CLASS DECLARATION + +/** +* An internal structure containing a test case name and +* the pointer to function doing the test +* +* @lib ?library +* @since ?Series60_version +*/ +class TCaseInfoInternal + { + public: + const TText* iCaseName; + TestFunction iMethod; + TBool iIsOOMTest; + TInt iFirstMemoryAllocation; + TInt iLastMemoryAllocation; + }; + +// CLASS DECLARATION + +/** +* A structure containing a test case name and +* the pointer to function doing the test +* +* @lib ?library +* @since ?Series60_version +*/ +class TCaseInfo + { + public: + TPtrC iCaseName; + TestFunction iMethod; + TBool iIsOOMTest; + TInt iFirstMemoryAllocation; + TInt iLastMemoryAllocation; + + TCaseInfo( const TText* a ) : iCaseName( (TText*) a ) + { + }; + + }; + + +// CLASS DECLARATION + +/** +* This a DemoModule class. +* ?other_description_lines +* +* @lib ?library +* @since ?Series60_version +*/ +NONSHARABLE_CLASS(CDemoModule) : public CTestModuleBase + { + public: // Constructors and destructor + + + /** + * Two-phased constructor. + */ + static CDemoModule* NewL(); + + /** + * Destructor. + */ + virtual ~CDemoModule(); + + public: // New functions + // None + + public: // Functions from base classes + + /** + * From CTestModuleBase InitL is used to initialize the + * DemoModule. It is called once for every instance of + * TestModuleDemoModule after its creation. + * @since ?Series60_version + * @param aIniFile Initialization file for the test module (optional) + * @param aFirstTime Flag is true when InitL is executed for first + * created instance of DemoModule. + * @return Symbian OS error code + */ + TInt InitL( TFileName& aIniFile, TBool aFirstTime ); + + /** + * From CTestModuleBase GetTestCasesL is used to inquiry test cases + * from DemoModule. + * @since ?Series60_version + * @param aTestCaseFile Test case file (optional) + * @param aTestCases Array of TestCases returned to test framework + * @return Symbian OS error code + */ + TInt GetTestCasesL( const TFileName& aTestCaseFile, + RPointerArray& aTestCases ); + + /** + * From CTestModuleBase RunTestCaseL is used to run an individual + * test case. + * @since ?Series60_version + * @param aCaseNumber Test case number + * @param aTestCaseFile Test case file (optional) + * @param aResult Test case result returned to test framework (PASS/FAIL) + * @return Symbian OS error code (test case execution error, which is + * not reported in aResult parameter as test case failure). + */ + TInt RunTestCaseL( const TInt aCaseNumber, + const TFileName& aTestCaseFile, + TTestResult& aResult ); + + /** + * From CTestModuleBase; OOMTestQueryL is used to specify is particular + * test case going to be executed using OOM conditions + * @param aTestCaseFile Test case file (optional) + * @param aCaseNumber Test case number (optional) + * @param aFailureType OOM failure type (optional) + * @param aFirstMemFailure The first heap memory allocation failure value (optional) + * @param aLastMemFailure The last heap memory allocation failure value (optional) + * @return TBool + */ + virtual TBool OOMTestQueryL( const TFileName& /* aTestCaseFile */, + const TInt /* aCaseNumber */, + TOOMFailureType& aFailureType, + TInt& /* aFirstMemFailure */, + TInt& /* aLastMemFailure */ ); + + /** + * From CTestModuleBase; OOMTestInitializeL may be used to initialize OOM + * test environment + * @param aTestCaseFile Test case file (optional) + * @param aCaseNumber Test case number (optional) + * @return None + */ + virtual void OOMTestInitializeL( const TFileName& /* aTestCaseFile */, + const TInt /* aCaseNumber */ ); + /** + * From CTestModuleBase; OOMTestFinalizeL may be used to finalize OOM + * test environment + * @param aTestCaseFile Test case file (optional) + * @param aCaseNumber Test case number (optional) + * @return None + */ + virtual void OOMTestFinalizeL( const TFileName& /* aTestCaseFile */, + const TInt /* aCaseNumber */ ); + + /** + * From CTestModuleBase; OOMHandleWarningL + * @param aTestCaseFile Test case file (optional) + * @param aCaseNumber Test case number (optional) + * @param aFailNextValue FailNextValue for OOM test execution (optional) + * @return None + */ + virtual void OOMHandleWarningL( const TFileName& /* aTestCaseFile */, + const TInt /* aCaseNumber */, + TInt& /* aFailNextValue */); + protected: // New functions + // None + + protected: // Functions from base classes + // None + + private: + + /** + * C++ default constructor. + */ + CDemoModule(); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + // Prohibit copy constructor if not deriving from CBase. + // ?classname( const ?classname& ); + // Prohibit assigment operator if not deriving from CBase. + // ?classname& operator=( const ?classname& ); + + /** + * Function returning test case name and pointer to test case function. + * @since ?Series60_version + * @param aCaseNumber test case number + * @return TCaseInfo + */ + const TCaseInfo Case ( const TInt aCaseNumber ) const; + + /** + * Simple math calculation test. + */ + TInt SimpleMathTest( TTestResult& aResult ); + + /** + * Math calculation test. + */ + TInt MathTest( TTestResult& aResult ); + + /** + * Actual Hardcoded test case functions are listed below. + */ + + /** + * Printing test case. + * @since ?Series60_version + * @param aResult Test case result (PASS/FAIL) + * @return Symbian OS error code (test case execution error + * that is not returned as test case result in aResult) + */ + TInt PrintTest( TTestResult& aResult ); + + /** + * Printing loop test case. + * @since ?Series60_version + * @param aResult Test case result (PASS/FAIL) + * @return Symbian OS error code (test case execution error + * that is not returned as test case result in aResult) + */ + TInt LoopTest( TTestResult& aResult ); + + /** + * Test case for heap memory allocation + * @since ?Series60_version + * @param aResult Test case result (PASS/FAIL) + * @return panic or Symbian OS error code (test case execution error + * that is not returned as test case result in aResult) + */ + TInt HeapMemoryAllocation( TTestResult& aResult ); + + public: // Data + // None + + protected: // Data + // None + + private: // Data + // Pointer to test (function) to be executed + TestFunction iMethod; + + // Pointer to logger + CStifLogger * iLog; + + // Normal logger + CStifLogger* iStdLog; + + // Test case logger + CStifLogger* iTCLog; + + // Flag saying if test case title should be added to log file name + TBool iAddTestCaseTitleToLogName; + + // ?one_line_short_description_of_data + //?data_declaration; + + // Reserved pointer for future extension + //TAny* iReserved; + + public: // Friend classes + // None + + protected: // Friend classes + // None + + private: // Friend classes + // None + + }; + +#endif // DEMOMODULE_H + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/demomodule/src/DemoModule.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/demomodule/src/DemoModule.cpp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,595 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file (DemoModule.cpp) contains all test +* framework related parts of this test module. Actual test cases +* are implemented in file DemoModuleCases.cpp. +* +* CTestModuleDemo is an example of test module implementation. This example +* uses hard coded test cases (i.e it does not have any test case +* configuration file). +* +* Example uses function pointers to call test cases. This provides an easy +* method to add new test cases. +* +* See function Cases in file DemoModuleCases.cpp for instructions how to +* add new test cases. It is not necessary to modify this file when adding +* new test cases. +* +* To take this module into use, add following lines to test framework +* initialisation file: +* +* # Demo module +* [New_Module] +* ModuleName= DemoModule +* [End_Module] +* +*/ + +// INCLUDE FILES +#include +#include "DemoModule.h" +#include +#include "SettingServerClient.h" + +// EXTERNAL DATA STRUCTURES +// None + +// EXTERNAL FUNCTION PROTOTYPES +// None + +// CONSTANTS +// None + +// MACROS +// None + +// LOCAL CONSTANTS AND MACROS +// None + +// MODULE DATA STRUCTURES +// None + +// LOCAL FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +// None + +// ==================== LOCAL FUNCTIONS ======================================= + + +// ================= MEMBER FUNCTIONS ========================================= + +/* +------------------------------------------------------------------------------- + + Class: CDemoModule + + Method: CDemoModule + + Description: C++ default constructor can NOT contain any code, that + might leave. + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Approved + +------------------------------------------------------------------------------- +*/ +CDemoModule::CDemoModule() + { + } + +/* +------------------------------------------------------------------------------- + + Class: CDemoModule + + Method: ConstructL + + Description: Symbian 2nd phase constructor that can leave. + + Note: If OOM test case uses STIF Logger, then STIF Logger must be created + with static buffer size parameter (aStaticBufferSize). Otherwise Logger + allocates memory from heap and therefore causes error situations with OOM + testing. For more information about STIF Logger construction, see STIF + Users Guide. + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Approved + +------------------------------------------------------------------------------- +*/ +void CDemoModule::ConstructL() + { + //Read logger settings to check whether test case name is to be + //appended to log file name. + RSettingServer settingServer; + TInt ret = settingServer.Connect(); + if(ret != KErrNone) + { + User::Leave(ret); + } + // Struct to StifLogger settigs. + TLoggerSettings loggerSettings; + // Parse StifLogger defaults from STIF initialization file. + ret = settingServer.GetLoggerSettings(loggerSettings); + if(ret != KErrNone) + { + User::Leave(ret); + } + // Close Setting server session + settingServer.Close(); + iAddTestCaseTitleToLogName = loggerSettings.iAddTestCaseTitle; + + // Constructing static buffer size logger, needed with OOM testing because + // normally logger allocates memory from heap! + iStdLog = CStifLogger::NewL( KDemoModuleLogPath, + KDemoModuleLogFile, + CStifLogger::ETxt, + CStifLogger::EFile, + ETrue, + ETrue, + ETrue, + EFalse, + ETrue, + EFalse, + 100 ); + iLog = iStdLog; + + // Sample how to use logging + _LIT( KLogInfo, "DemoModule logging starts!" ); + iLog->Log( KLogInfo ); + } + +/* +------------------------------------------------------------------------------- + + Class: CTestModuleDemo + + Method: NewL + + Description: Two-phased constructor. Constructs new CTestModuleDemo + instance and returns pointer to it. + + Parameters: None + + Return Values: CTestModuleDemo*: new object. + + Errors/Exceptions: Leaves if memory allocation fails or ConstructL leaves. + + Status: Approved + +------------------------------------------------------------------------------- +*/ +CDemoModule* CDemoModule::NewL() + { + CDemoModule* self = new (ELeave) CDemoModule; + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + + return self; + } + +/* +------------------------------------------------------------------------------- + + Class: CTestModuleDemo + + Method: ~CTestModuleDemo + + Description: Destructor. + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Approved + +------------------------------------------------------------------------------- +*/ +CDemoModule::~CDemoModule() + { + iLog = NULL; + delete iStdLog; + iStdLog = NULL; + delete iTCLog; + iTCLog = NULL; + } + +/* +------------------------------------------------------------------------------- + Class: CTestModuleDemo + + Method: InitL + + Description: Method for test case initialization + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Approved +------------------------------------------------------------------------------- +*/ +TInt CDemoModule::InitL( TFileName& /*aIniFile*/, + TBool /*aFirstTime*/ ) + { + return KErrNone; + + } + +/* +------------------------------------------------------------------------------- + + Class: CTestModuleDemo + + Method: GetTestCases + + Description: GetTestCases is used to inquire test cases + from the test module. Because this test module has hard coded test cases + (i.e cases are not read from file), paramter aConfigFile is not used. + + This function loops through all cases defined in Cases() function and + adds corresponding items to aTestCases array. + + Parameters: const TFileName& : in: Configuration file name. Not used + RPointerArray& aTestCases: out: + Array of TestCases. + + Return Values: KErrNone: No error + + Errors/Exceptions: Function leaves if any memory allocation operation fails + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +TInt CDemoModule::GetTestCasesL( const TFileName& /*aConfig*/, + RPointerArray& aTestCases ) + { + // Loop through all test cases and create new + // TTestCaseInfo items and append items to aTestCase array + for( TInt i = 0; Case(i).iMethod != NULL; i++ ) + { + // Allocate new TTestCaseInfo from heap for a testcase definition. + TTestCaseInfo* newCase = new( ELeave ) TTestCaseInfo(); + + // PushL TTestCaseInfo to CleanupStack. + CleanupStack::PushL( newCase ); + + // Set number for the testcase. + // When the testcase is run, this comes as a parameter to RunTestCaseL. + newCase->iCaseNumber = i; + + // Set title for the test case. This is shown in UI to user. + newCase->iTitle.Copy( Case(i).iCaseName ); + + // Append TTestCaseInfo to the testcase array. After appended + // successfully the TTestCaseInfo object is owned (and freed) + // by the TestServer. + User::LeaveIfError(aTestCases.Append ( newCase ) ); + + // Pop TTestCaseInfo from the CleanupStack. + CleanupStack::Pop( newCase ); + } + + return KErrNone; + + } + +/* +------------------------------------------------------------------------------- + + Class: CTestModuleDemo + + Method: RunTestCase + + Description: Run a specified testcase. + + Function runs a test case specified by test case number. Test case file + parameter is not used. + + If case number is valid, this function runs a test case returned by + function Cases(). + + Parameters: const TInt aCaseNumber: in: Testcase number + const TFileName& : in: Configuration file name. Not used + TTestResult& aResult: out: Testcase result + + Return Values: KErrNone: Testcase ran. + KErrNotFound: Unknown testcase + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +TInt CDemoModule::RunTestCaseL( const TInt aCaseNumber, + const TFileName& /* aConfig */, + TTestResult& aResult ) + { + // Return value + TInt execStatus = KErrNone; + + // Get the pointer to test case function + TCaseInfo tmp = Case ( aCaseNumber ); + + _LIT( KLogInfo, "Starting testcase [%S]" ); + iLog->Log( KLogInfo, &tmp.iCaseName); + + // Check that case number was valid + if ( tmp.iMethod != NULL ) + { + //Open new log file with test case title in file name + if(iAddTestCaseTitleToLogName) + { + //delete iLog; //Close currently opened log + //iLog = NULL; + //Delete test case logger if exists + if(iTCLog) + { + delete iTCLog; + iTCLog = NULL; + } + + TFileName logFileName; + TName title; + TestModuleIf().GetTestCaseTitleL(title); + + logFileName.Format(KDemoModuleLogFileWithTitle, &title); + + iTCLog = CStifLogger::NewL(KDemoModuleLogPath, + logFileName, + CStifLogger::ETxt, + CStifLogger::EFile, + ETrue, + ETrue, + ETrue, + EFalse, + ETrue, + EFalse, + 100); + iLog = iTCLog; + } + + // Valid case was found, call it via function pointer + iMethod = tmp.iMethod; + //execStatus = ( this->*iMethod )( aResult ); + TRAPD(err, execStatus = ( this->*iMethod )( aResult )); + if(iAddTestCaseTitleToLogName) + { + //Restore standard log and destroy test case logger + iLog = iStdLog; + delete iTCLog; //Close currently opened log + iTCLog = NULL; + } + User::LeaveIfError(err); + + } + else + { + // Valid case was not found, return error. + execStatus = KErrNotFound; + } + + // Return case execution status (not the result of the case execution) + return execStatus; + + } + +/* +------------------------------------------------------------------------------- + + Class: CDemoModule + + Method: OOMTestQueryL + + Description: Checks test case information for OOM execution. + + Return Values: TBool + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +TBool CDemoModule::OOMTestQueryL( const TFileName& /* aTestCaseFile */, + const TInt aCaseNumber, + TOOMFailureType& /* aFailureType */, + TInt& aFirstMemFailure, + TInt& aLastMemFailure ) + { + _LIT( KLogInfo, "CDemoModule::OOMTestQueryL" ); + iLog->Log( KLogInfo ); + + aFirstMemFailure = Case( aCaseNumber ).iFirstMemoryAllocation; + aLastMemFailure = Case( aCaseNumber ).iLastMemoryAllocation; + + return Case( aCaseNumber ).iIsOOMTest; + } + +/* +------------------------------------------------------------------------------- + + Class: CDemoModule + + Method: OOMTestInitializeL + + Description: Used to perform the test environment setup for a particular + OOM test case. Test Modules may use the initialization file to read + parameters for Test Module initialization but they can also have their own + configure file or some other routine to initialize themselves. + + NOTE: User may add implementation for OOM test environment initialization. + Usually no implementation is required. + + Return Values: None + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +void CDemoModule::OOMTestInitializeL( const TFileName& /* aTestCaseFile */, + const TInt /* aCaseNumber */ ) + { + _LIT( KLogInfo, "CDemoModule::OOMTestInitializeL" ); + iLog->Log( KLogInfo ); + + } + +/* +------------------------------------------------------------------------------- + + Class: CDemoModule + + Method: OOMHandleWarningL + + Description: Used in OOM testing to provide a way to the derived TestModule + to handle warnings related to non-leaving or TRAPped allocations. + + In some cases the allocation should be skipped, either due to problems in + the OS code or components used by the code being tested, or even inside the + tested components which are implemented this way on purpose (by design), so + it is important to give the tester a way to bypass allocation failures. + + NOTE: User may add implementation for OOM test warning handling. Usually no + implementation is required. + + Return Values: None + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +void CDemoModule::OOMHandleWarningL( const TFileName& /* aTestCaseFile */, + const TInt /* aCaseNumber */, + TInt& /* aFailNextValue */ ) + { + _LIT( KLogInfo, "CDemoModule::OOMHandleWarningL" ); + iLog->Log( KLogInfo ); + + } + +/* +------------------------------------------------------------------------------- + + Class: CDemoModule + + Method: OOMTestFinalizeL + + Description: Used to perform the test environment cleanup for a particular OOM + test case. + + NOTE: User may add implementation for OOM test environment finalization. + Usually no implementation is required. + + Return Values: None + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +void CDemoModule::OOMTestFinalizeL( const TFileName& /* aTestCaseFile */, + const TInt /* aCaseNumber */ ) + { + _LIT( KLogInfo, "CDemoModule::OOMTestFinalizeL" ); + iLog->Log( KLogInfo ); + + } + +// ========================== OTHER EXPORTED FUNCTIONS ========================= + +// ----------------------------------------------------------------------------- +// LibEntryL is a polymorphic Dll entry point +// Returns: CTestModuleBase*: Pointer to Test Module object +// ----------------------------------------------------------------------------- +// +EXPORT_C CTestModuleBase* LibEntryL() + { + return CDemoModule::NewL(); + + } + +// ----------------------------------------------------------------------------- +// SetRequirements handles test module parameters(implements evolution +// version 1 for test module's heap and stack sizes configuring). +// Returns: TInt: Symbian error code. +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt SetRequirements( CTestModuleParam*& /*aTestModuleParam*/, + TUint32& /*aParameterValid*/ ) + { + + /* --------------------------------- NOTE --------------------------------- + USER PANICS occurs in test thread creation when: + 1) "The panic occurs when the value of the stack size is negative." + 2) "The panic occurs if the minimum heap size specified is less + than KMinHeapSize". + KMinHeapSize: "Functions that require a new heap to be allocated will + either panic, or will reset the required heap size to this value if + a smaller heap size is specified". + 3) "The panic occurs if the minimum heap size specified is greater than + the maximum size to which the heap can grow". + Other: + 1) Make sure that your hardware or Symbian OS is supporting given sizes. + e.g. Hardware might support only sizes that are divisible by four. + ------------------------------- NOTE end ------------------------------- */ + + // Normally STIF uses default heap and stack sizes for test thread, see: + // KTestThreadMinHeap, KTestThreadMinHeap and KStackSize. + // If needed heap and stack sizes can be configured here by user. Remove + // comments and define sizes. + +/* + aParameterValid = KStifTestModuleParameterChanged; + + CTestModuleParamVer01* param = CTestModuleParamVer01::NewL(); + // Stack size + param->iTestThreadStackSize= 16384; // 16K stack + // Heap sizes + param->iTestThreadMinHeap = 4096; // 4K heap min + param->iTestThreadMaxHeap = 1048576;// 1M heap max + + aTestModuleParam = param; +*/ + return KErrNone; + + } + + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/demomodule/src/Demomodulecases.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/demomodule/src/Demomodulecases.cpp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,495 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This module contains the implementation of +* CTestModuleDemo class member functions that does the actual +* tests. +* +*/ + +// INCLUDE FILES +#include +#include "DemoModule.h" + +// EXTERNAL DATA STRUCTURES +// None + +// EXTERNAL FUNCTION PROTOTYPES +// None + +// CONSTANTS +// None + +// MACROS +// None + +// LOCAL CONSTANTS AND MACROS +// None + +// MODULE DATA STRUCTURES +// None + +// LOCAL FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +// None + +// ==================== LOCAL FUNCTIONS ======================================= + +// ============================ MEMBER FUNCTIONS =============================== + +/* +------------------------------------------------------------------------------- + + Class: CDemoModule + + Method: Case + + Description: Returns a test case by number. + + This function contains an array of all available test cases + i.e pair of case name and test function. If case specified by parameter + aCaseNumber is found from array, then that item is returned. + + The reason for this rather complicated function is to specify all the + test cases only in one place. It is not necessary to understand how + function pointers to class member functions works when adding new test + cases. See function body for instructions how to add new test case. + + Parameters: const TInt aCaseNumber :in: Test case number + + Return Values: const TCaseInfo Struct containing case name & function + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +const TCaseInfo CDemoModule::Case ( + const TInt aCaseNumber ) const + { + + /* + * To add new test cases, implement new test case function and add new + * line to KCases array specify the name of the case and the function + * doing the test case + * In practice, do following + * + * 1) Make copy of existing test case function and change its name + * and functionality. Note that the function must be added to + * OOMHard.cpp file and to OOMHard.h + * header file. + * + * 2) Add entry to following KCases array either by using: + * + * 2.1: FUNCENTRY or ENTRY macro + * ENTRY macro takes two parameters: test case name and test case + * function name. + * + * FUNCENTRY macro takes only test case function name as a parameter and + * uses that as a test case name and test case function name. + * + * Or + * + * 2.2: OOM_FUNCENTRY or OOM_ENTRY macro. Note that these macros are used + * only with OOM (Out-Of-Memory) testing! + * + * OOM_ENTRY macro takes five parameters: test case name, test case + * function name, TBool which specifies is method supposed to be run using + * OOM conditions, TInt value for first heap memory allocation failure and + * TInt value for last heap memory allocation failure. + * + * OOM_FUNCENTRY macro takes test case function name as a parameter and uses + * that as a test case name, TBool which specifies is method supposed to be + * run using OOM conditions, TInt value for first heap memory allocation + * failure and TInt value for last heap memory allocation failure. + */ + + static TCaseInfoInternal const KCases[] = + { + // To add new test cases, add new items to this array + + // NOTE: When compiled to GCCE, there must be Classname:: + // declaration in front of the method name, e.g. + // CDemoModule::PrintTest. Otherwise the compiler + // gives errors. + + ENTRY( "Loop test", CDemoModule::LoopTest ), + ENTRY( "Simple math test", CDemoModule::SimpleMathTest ), + ENTRY( "Math test", CDemoModule::MathTest ), + ENTRY( "Print test", CDemoModule::PrintTest ), + // Example how to use OOM functionality + OOM_ENTRY( "Heap memory allocation with OOM [ABORT]", CDemoModule::HeapMemoryAllocation, ETrue, 1, 2 ), + ENTRY( "Heap memory allocation (passes)", CDemoModule::HeapMemoryAllocation ) + }; + + // Verify that case number is valid + if( (TUint) aCaseNumber >= sizeof( KCases ) / + sizeof( TCaseInfoInternal ) ) + { + + // Invalid case, construct empty object + TCaseInfo null( (const TText*) L"" ); + null.iMethod = NULL; + null.iIsOOMTest = EFalse; + null.iFirstMemoryAllocation = 0; + null.iLastMemoryAllocation = 0; + return null; + + } + + // Construct TCaseInfo object and return it + TCaseInfo tmp ( KCases[ aCaseNumber ].iCaseName ); + tmp.iMethod = KCases[ aCaseNumber ].iMethod; + tmp.iIsOOMTest = KCases[ aCaseNumber ].iIsOOMTest; + tmp.iFirstMemoryAllocation = KCases[ aCaseNumber ].iFirstMemoryAllocation; + tmp.iLastMemoryAllocation = KCases[ aCaseNumber ].iLastMemoryAllocation; + return tmp; + + } + +/* +------------------------------------------------------------------------------- + + Class: CDemoModule + + Method: SimpleMathTest + + Description: Simple Math testing. + + Parameters: TTestResult& aErrorDescription: out: + Test result and on error case a short description of error + + Return Values: TInt: Always KErrNone to indicate that test was valid + + Errors/Exceptions: None + + Status: Approved + +------------------------------------------------------------------------------- +*/ +TInt CDemoModule::SimpleMathTest( TTestResult& aResult ) + { + /* Test with mathematic calculations and printing */ + _LIT( KDefinion , "RunTestCase"); + _LIT( KData , "Simple Math calculations"); + TestModuleIf().Printf( 0, KDefinion, KData ); + + // Random number. + TReal num = Math::Random(); + // Intermediate result + TReal sqrt = 0; + // Result + TReal result = 0; + + // Take square root of the number + TInt ret = Math::Sqrt( sqrt, num ); + if( ret != KErrNone ) + { + // Return error if Sqrt failed + _LIT( KResult ,"Math::Sqrt failed"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + + // Case was executed but failed + return KErrNone; + } + + // Take power of two from the previous result + ret = Math::Pow( result, sqrt, 2 ); + if( ret != KErrNone ) + { + // Return error if Pow failed + _LIT( KResult ,"Math::Pow failed"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + + // Case was executed but failed + return KErrNone; + } + + // Compare final result to the original value, + // rounded values should usually be same. + TInt32 a1; + TInt32 a2; + TInt r = Math::Int(a1, result); + + if (r != KErrNone ) + { + _LIT( KResult ,"1st conversion failed"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = r; + return KErrNone; + } + + r = Math::Int(a2, num); + if (r != KErrNone ) + { + _LIT( KResult ,"2nd conversion failed"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = r; + return KErrNone; + } + + if( a1 != a2 ) + { + _LIT( KResult ,"Calculation doesn't match"); + // Return error if comparison failed + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + return KErrNone; + } + + + // Test case passed + + // Sets test case result and description(Maximum size is KStifMaxResultDes) + _LIT( KDescription , "Test case passed"); + aResult.SetResult( KErrNone, KDescription ); + //aResult.iResult = KErrNone; + //aResult.iResultDes = KDescription; + + // Case was executed + return KErrNone; + + } + +/* +------------------------------------------------------------------------------- + + Class: CDemoModule + + Method: MathTest + + Description: Print loop test. Actually does not test anything, just + demonstrate how to print. Test is always pased. + + Parameters: TTestResult& aErrorDescription: out: + Test result and on error case a short description of error + + Return Values: TInt: Always KErrNone to indicate that test was valid + + Errors/Exceptions: None + + Status: Approved + +------------------------------------------------------------------------------- +*/ +TInt CDemoModule::LoopTest( TTestResult& aResult ) + { + + /* Simple print and wait loop */ + _LIT( KDefinion ,"State"); + _LIT( KData ,"Looping"); + TestModuleIf().Printf( 0, KDefinion, KData ); + for( TInt i=0; i<10; i++) + { + _LIT( KRunning ,"Running"); + _LIT( KLoop ,"%d"); + TestModuleIf().Printf( 0, KRunning, KLoop, i); + User::After( 1000000 ); + } + _LIT( KData2 ,"Finished"); + TestModuleIf().Printf( 0, KDefinion, KData2 ); + + // Test case passed + + // Sets test case result and description(Maximum size is KStifMaxResultDes) + _LIT( KDescription , "Test case passed"); + aResult.SetResult( KErrNone, KDescription ); + //aResult.iResult = KErrNone; + //aResult.iResultDes = KDescription; + + // Case was executed + return KErrNone; + } + +/* +------------------------------------------------------------------------------- + + Class: CDemoModule + + Method: MathTest + + Description: Math testing. + + Parameters: TTestResult& aErrorDescription: out: + Test result and on error case a short description of error + + Return Values: TInt: Always KErrNone to indicate that test was valid + + Errors/Exceptions: None + + Status: Approved + +------------------------------------------------------------------------------- +*/ +TInt CDemoModule::MathTest( TTestResult& aResult ) + { + /* Test with mathematic calculations and printing */ + _LIT( KDefinion ,"RunTestCase"); + _LIT( KData ,"Math calculations"); + TestModuleIf().Printf( 0, KDefinion, KData ); + // Result + TRealX res; + // Random numbers + TInt rand[6]; + TRealX coef[5]; + TInt i; + TInt j; + for( i=0; i<10; i++ ) + { + for(j=0; j<6; j++) + rand[j] = Math::Random(); + for(j=0; j<5; j++) + coef[j] = rand[j]; + Math::PolyX(res, rand[5], 5, coef ); + + _LIT( KResult ,"Result %d"); + TestModuleIf().Printf( 0, KDefinion, KResult, ( TInt )res); + } + + // Test case passed + + // Sets test case result and description(Maximum size is KStifMaxResultDes) + _LIT( KDescription , "Test case passed"); + aResult.SetResult( KErrNone, KDescription ); + //aResult.iResult = KErrNone; + //aResult.iResultDes = KDescription; + + // Case was executed + return KErrNone; + + } + +/* +------------------------------------------------------------------------------- + + Class: CDemoModule + + Method: PrintTest + + Description: Printing testing. + + Parameters: TTestResult& aErrorDescription: out: + Test result and on error case a short description of error + + Return Values: TInt: Always KErrNone to indicate that test was valid + + Errors/Exceptions: None + + Status: Approved + +------------------------------------------------------------------------------- +*/ +TInt CDemoModule::PrintTest( TTestResult& aResult ) + { + /* Tests printing with high intencity and different priority */ + _LIT( KDefinion ,"CTestModuleDemo::RunTestCase"); + _LIT( KData ,"Heavy print looping"); + TestModuleIf().Printf( 0, KDefinion, KData ); + TInt j; + for( TInt i=0; i<10; i++) + { + + for(j=0; j<2; j++) + { + _LIT( KTmp ,"RunTestCase"); + TBuf<15> tmp; + tmp.Copy( KTmp ); + tmp.AppendNum( j ); + _LIT( KNewData ,"p"); + TestModuleIf().Printf(3, tmp, KNewData ); + } + + for(j=0; j<500; j++) + { + _LIT( KNewDefinion ,"RunTestCase"); + _LIT( KNewData ,"%c"); + TestModuleIf().Printf(1+(Math::Random() % 12), + KNewDefinion, + KNewData, 'a'+(j%('z'-'a')) ); + } + + _LIT( KNewDefinion ,"RunTestCase"); + _LIT( KNewData ,"Running %d"); + TestModuleIf().Printf( 2, KNewDefinion,KNewData, i); + User::After( 1000000 ); + } + + // Test case passed + + // Sets test case result and description(Maximum size is KStifMaxResultDes) + _LIT( KDescription , "Test case passed"); + aResult.SetResult( KErrNone, KDescription ); + //aResult.iResult = KErrNone; + //aResult.iResultDes = KDescription; + + // Case was executed + return KErrNone; + + } + +/* +------------------------------------------------------------------------------- + + Class: CDemoModule + + Method: HeapMemoryAllocation + + Description: Allocates heap descriptor. + + Parameters: TTestResult& aError + + Return Values: TInt + + Errors/Exceptions: Leaves with KErrNoMemory if heap allocation fails + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +TInt CDemoModule::HeapMemoryAllocation( TTestResult& aResult ) + { + _LIT( KLogInfo , "CDemoModule::HeapMemoryAllocation" ); + iLog->Log( KLogInfo ); + + // Allocate heap descriptor + HBufC * buffer = HBufC::New( 10 ); + if( buffer == NULL ) + { + // Allocation failed + _LIT( KNewLogInfo , "buffer was NULL"); + iLog->Log( KNewLogInfo ); + User::Leave( KErrNoMemory ); + } + else + { + // Descriptor creation was ok + _LIT( KNewLogInfo ,"buffer was allocated properly" ); + iLog->Log( KNewLogInfo ); + } + + delete buffer; + + _LIT( KDescription , "Test case passed"); + aResult.SetResult( KErrNone, KDescription ); + return KErrNone; + } + +// ================= OTHER EXPORTED FUNCTIONS ================================= + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/hwresetstub/BMARM/STIFHWRESETSTUBU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/hwresetstub/BMARM/STIFHWRESETSTUBU.DEF Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,4 @@ +EXPORTS + LibEntryL__Fv @ 1 NONAME R3UNUSED ; LibEntryL(void) + NewL__16CStifHWResetStub @ 2 NONAME R3UNUSED ; CStifHWResetStub::NewL(void) + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/hwresetstub/BWINS/STIFHWRESETSTUBU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/hwresetstub/BWINS/STIFHWRESETSTUBU.DEF Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,4 @@ +EXPORTS + ?LibEntryL@@YAPAVCStifHWResetStub@@XZ @ 1 NONAME ; class CStifHWResetStub * __cdecl LibEntryL(void) + ?NewL@CStifHWResetStub@@SAPAV1@XZ @ 2 NONAME ; public: static class CStifHWResetStub * __cdecl CStifHWResetStub::NewL(void) + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/hwresetstub/eabi/StifHWResetStubu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/hwresetstub/eabi/StifHWResetStubu.def Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,4 @@ +EXPORTS + _Z9LibEntryLv @ 1 NONAME + _ZN16CStifHWResetStub4NewLEv @ 2 NONAME + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/hwresetstub/group/StifHWResetStub.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/hwresetstub/group/StifHWResetStub.mmp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: MMP file for STIF Test Framework's StifHWResetStub. +* +*/ + +#include + +SMPSAFE +TARGET StifHWResetStub.dll +TARGETTYPE dll +DEFFILE StifHWResetStub.def + +CAPABILITY ALL -TCB +/* Remove comments and replace 0x00000000 with correct vendor id */ +// VENDORID 0x00000000 +/* Remove comments and replace 0x00000000 with correct secure id */ +// SECUREID 0x00000000 + +LIBRARY euser.lib +LIBRARY stiftestinterface.lib + +USERINCLUDE ../inc +USERINCLUDE ../../../inc + +OS_LAYER_SYSTEMINCLUDE + +SOURCEPATH ../src + +SOURCE StifHWResetStub.cpp + +// First UID is DLL UID, Second UID is STIF Test Framework UID +UID 0x1000008D 0x101FB3E7 +// End of File + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/hwresetstub/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/hwresetstub/group/bld.inf Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +* Build information for STIF Test Framework's StifHWResetStub. +*/ + + +PRJ_PLATFORMS + + DEFAULT + +PRJ_EXPORTS + + +PRJ_TESTEXPORTS + + +PRJ_MMPFILES + + StifHWResetStub.mmp + +PRJ_TESTMMPFILES + + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/hwresetstub/inc/StifHWResetStub.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/hwresetstub/inc/StifHWResetStub.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,130 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of +* CStifHWResetStub of STIF TestFramework. +* +*/ + +#ifndef STIFHWRESETSTUB_H +#define STIFHWRESETSTUB_H + +// INCLUDES +#include +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION +// None + +// DESCRIPTION +// Implements common reset module for STIF TestFramework. According to this DLL +// template can be implemented licensee specific reset module. +NONSHARABLE_CLASS(CStifHWResetStub) + :public CStifHWReset + { + public: // Enumerations + // None + + private: // Enumerations + // None + + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + IMPORT_C static CStifHWResetStub* NewL(); + + /** + * Destructor. + */ + ~CStifHWResetStub(); + + public: // New functions + + /** + * Does reset according to reset type. + */ + TInt DoReset( CTestModuleIf::TRebootType aResetType ); + + public: // Functions from base classes + // None + + protected: // New functions + // None + + protected: // Functions from base classes + // None + + private: + + /** + * C++ default constructor. + */ + CStifHWResetStub(); + + /** + * Symbian OS constructor. + */ + void ConstructL(); + + /** + * Kills process. Example method. + */ + TInt KillProcess(); + + /** + * General reset. Example method. + */ + TInt GeneralReset(); + + public: // Data + // None + + protected: // Data + // None + + private: // Data + + // Logger instance + CStifLogger* iLogger; + + public: // Friend classes + // None + + protected: // Friend classes + // None + + private: // Friend classes + // None + + }; + +#endif // STIFHWRESETSTUB_H + +// End of File \ No newline at end of file diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/hwresetstub/src/StifHWResetStub.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/hwresetstub/src/StifHWResetStub.cpp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,326 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implements common reset module for STIF +* TestFramework. According to this DLL template can be implemented +* licensee specific reset module. +* +*/ + +// INCLUDE FILES +#include "StifHWResetStub.h" + +// EXTERNAL DATA STRUCTURES +// None + +// EXTERNAL FUNCTION PROTOTYPES +// None + +// CONSTANTS +// None + +// MACROS +// None + +// LOCAL CONSTANTS AND MACROS +// None + +// MODULE DATA STRUCTURES +// None + +// LOCAL FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +// None + +// ==================== LOCAL FUNCTIONS ======================================= + +// ================= MEMBER FUNCTIONS ========================================= + +/* +------------------------------------------------------------------------------- + + Class: CStifHWResetStub + + Method: CStifHWResetStub + + Description: Default constructor. + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +CStifHWResetStub::CStifHWResetStub() + { + // None + + } + +/* +------------------------------------------------------------------------------- + + Class: CStifHWResetStub + + Method: ConstructL + + Description: Symbian OS second phase constructor. Nothing to do. + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +void CStifHWResetStub::ConstructL() + { + // Create Logger + iLogger = CStifLogger::NewL( _L( "C:\\logs\\testframework\\testengine\\"), + _L( "StifHWResetStub" ), + CStifLogger::ETxt, + CStifLogger::EFile, + EFalse, // Append + ETrue, + ETrue, + EFalse, + EFalse ); + + } + +/* +------------------------------------------------------------------------------- + + Class: CStifHWResetStub + + Method: NewL + + Description: Two-phased constructor. Constructs new CStifHWResetStub + instance and returns pointer to it. + + Parameters: None + + Return Values: CStifHWResetStub*: new object. + + Errors/Exceptions: Leaves if memory allocation fails or ConstructL leaves. + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +EXPORT_C CStifHWResetStub* CStifHWResetStub::NewL() + { + // Construct new CStifHWResetStub instance. + CStifHWResetStub* self = new ( ELeave ) CStifHWResetStub(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + + return self; + + } + +/* +------------------------------------------------------------------------------- + + Class: CStifHWResetStub + + Method: ~CStifHWResetStub + + Description: Destructor. + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +CStifHWResetStub::~CStifHWResetStub() + { + delete iLogger; + iLogger = NULL; + + } + +/* +------------------------------------------------------------------------------- + + Class: CStifHWResetStub + + Method: DoReset + + Description: Does reset according to reset type. + + Parameters: CTestModuleIf::TRebootType aResetType: in: Reset type + + Return Values: TInt: Symbian OS error + + Errors/Exceptions: Error code returned if reset method returns an error. + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +TInt CStifHWResetStub::DoReset( CTestModuleIf::TRebootType aResetType ) + { + iLogger->Log( _L( "CStifHWResetStub::DoReset(), reset type: %d" ), aResetType ); + TInt ret( KErrNone ); + + switch( aResetType ) + { + case CTestModuleIf::EDefaultReset: + { + ret = KillProcess(); // For an example + break; + } + case CTestModuleIf::EDeviceReset0: + { + ret = KillProcess(); // For an example + break; + } + case CTestModuleIf::EDeviceReset1: + { + ret = KillProcess(); // For an example + break; + } + case CTestModuleIf::EDeviceReset2: + { + ret = GeneralReset(); // Do nothing, for an example + break; + } + case CTestModuleIf::EDeviceReset3: + { + ret = GeneralReset(); // Do nothing, for an example + break; + } + case CTestModuleIf::EDeviceReset4: + { + ret = GeneralReset(); // Do nothing, for an example + break; + } + case CTestModuleIf::EDeviceReset5: + { + ret = GeneralReset(); // Do nothing, for an example + break; + } + default: + { + return KErrArgument; + } + } + + return ret; + + } + +/* +------------------------------------------------------------------------------- + + Class: CStifHWResetStub + + Method: KillProcess + + Description: Kills process + + Parameters: None + + Return Values: TInt: Symbian OS error + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +TInt CStifHWResetStub::KillProcess() + { + iLogger->Log( _L( "KillProcess()" ) ); + // Do process kill if MTC messages not allowed + RProcess thisProcess; + thisProcess.Kill( KErrNone ); + thisProcess.Close(); + + return KErrNone; + + } + +/* +------------------------------------------------------------------------------- + + Class: CStifHWResetStub + + Method: GeneralReset + + Description: General reset for example. + + Parameters: None + + Return Values: TInt: Symbian OS error + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +TInt CStifHWResetStub::GeneralReset() + { + // Lisencee specific reset + iLogger->Log( _L( "GeneralReset()" ) ); + return KErrNone; + + } + +// ================= OTHER EXPORTED FUNCTIONS ================================= + +/* +------------------------------------------------------------------------------- + + Function: LibEntryL + + Description: Polymorphic Dll Entry Point + + Test framework calls this function to obtain new instance of test module + class. + + Parameters: None + + Return Values: CStifHWResetStub* Pointer to CStifHWResetStub instance + + Errors/Exceptions: Leaves if CStifHWResetStub::NewL leaves + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +EXPORT_C CStifHWResetStub* LibEntryL() + { + return CStifHWResetStub::NewL(); + + } + + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/testmeasurementstub/Bmarm/STIFTESTMEASUREMENTSTUBU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/testmeasurementstub/Bmarm/STIFTESTMEASUREMENTSTUBU.DEF Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,3 @@ +EXPORTS + LibEntryL__FRC7TDesC16Q220CSTIFTestMeasurement20TSTIFMeasurementType @ 1 NONAME R3UNUSED ; LibEntryL(TDesC16 const &, CSTIFTestMeasurement::TSTIFMeasurementType) + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/testmeasurementstub/Bwins/STIFTESTMEASUREMENTSTUBU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/testmeasurementstub/Bwins/STIFTESTMEASUREMENTSTUBU.DEF Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,3 @@ +EXPORTS + ?LibEntryL@@YAPAVCSTIFTestMeasurementImplementation@@ABVTDesC16@@W4TSTIFMeasurementType@CSTIFTestMeasurement@@@Z @ 1 NONAME ; class CSTIFTestMeasurementImplementation * __cdecl LibEntryL(class TDesC16 const &,enum CSTIFTestMeasurement::TSTIFMeasurementType) + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/testmeasurementstub/eabi/STIFTestMeasurementStubu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/testmeasurementstub/eabi/STIFTestMeasurementStubu.def Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,3 @@ +EXPORTS + _Z9LibEntryLRK7TDesC16N20CSTIFTestMeasurement20TSTIFMeasurementTypeE @ 1 NONAME + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/testmeasurementstub/group/STIFTestMeasurementStub.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/testmeasurementstub/group/STIFTestMeasurementStub.mmp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: MMP file for STIF Test Framework's TestMeasurement +* stub module. +* +*/ + +#include + +SMPSAFE +TARGET STIFTestMeasurementStub.dll +TARGETTYPE dll +UID 0x1000008D 0x101FB3E7 + + +CAPABILITY ALL -TCB +/* Remove comments and replace 0x00000000 with correct vendor id */ +// VENDORID 0x00000000 +/* Remove comments and replace 0x00000000 with correct secure id */ +// SECUREID 0x00000000 + +//TARGETPATH ?target_path +DEFFILE STIFTestMeasurementStub.def + +USERINCLUDE ../inc + +OS_LAYER_SYSTEMINCLUDE + +SOURCEPATH ../src + +SOURCE STIFTestMeasurementStub.cpp + +//RESOURCE resource_file +//RESOURCE resource_file2 + +LIBRARY euser.lib + +LANG SC + +/* +START WINS +?wins_specific_information +END + +START MARM +?marm_specific_information +END +*/ +// Other possible keywords: + +// DOCUMENT ?file, that is not compiled, but added to MSVC project workspace (i.e. release notes) +/* +START BITMAP ?target +TARGETPATH ?emulated_path_on_target_machine +HEADER +SOURCE ?color_depth ?source_bitmap +END +*/ +// DEFFILE ?filename +// AIF ?filename// End of File + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/testmeasurementstub/group/STIFTestMeasurementStub_DoxyFile.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/testmeasurementstub/group/STIFTestMeasurementStub_DoxyFile.txt Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,237 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# +# + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +PROJECT_NAME = STIFTestMeasurementStub +PROJECT_NUMBER = +OUTPUT_DIRECTORY = w:\STIFTestMeasurementStub\ +CREATE_SUBDIRS = NO +OUTPUT_LANGUAGE = English +USE_WINDOWS_ENCODING = YES +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ABBREVIATE_BRIEF = +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = NO +FULL_PATH_NAMES = NO +STRIP_FROM_PATH = +STRIP_FROM_INC_PATH = +SHORT_NAMES = NO +JAVADOC_AUTOBRIEF = NO +MULTILINE_CPP_IS_BRIEF = NO +DETAILS_AT_TOP = NO +INHERIT_DOCS = YES +DISTRIBUTE_GROUP_DOC = NO +TAB_SIZE = 8 +ALIASES = +OPTIMIZE_OUTPUT_FOR_C = YES +OPTIMIZE_OUTPUT_JAVA = NO +SUBGROUPING = YES +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- +EXTRACT_ALL = YES +EXTRACT_PRIVATE = NO +EXTRACT_STATIC = NO +EXTRACT_LOCAL_CLASSES = NO +EXTRACT_LOCAL_METHODS = NO +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = NO +HIDE_FRIEND_COMPOUNDS = NO +HIDE_IN_BODY_DOCS = NO +INTERNAL_DOCS = YES +CASE_SENSE_NAMES = YES +HIDE_SCOPE_NAMES = NO +SHOW_INCLUDE_FILES = YES +INLINE_INFO = YES +SORT_MEMBER_DOCS = YES +SORT_BRIEF_DOCS = NO +SORT_BY_SCOPE_NAME = NO +GENERATE_TODOLIST = NO +GENERATE_TESTLIST = NO +GENERATE_BUGLIST = NO +GENERATE_DEPRECATEDLIST= YES +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +SHOW_USED_FILES = YES +SHOW_DIRECTORIES = YES +FILE_VERSION_FILTER = +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = NO +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_IF_DOC_ERROR = YES +WARN_NO_PARAMDOC = NO +WARN_FORMAT = "$file:$line: $text" +WARN_LOGFILE = +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = w:\STIFTestMeasurementStub\ +FILE_PATTERNS = *.h \ + *.rh \ + *.hrh +RECURSIVE = YES +EXCLUDE = +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_PATTERNS = +FILTER_SOURCE_FILES = NO +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = NO +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +REFERENCED_BY_RELATION = YES +REFERENCES_RELATION = YES +VERBATIM_HEADERS = YES +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = NO +COLS_IN_ALPHA_INDEX = 5 +IGNORE_PREFIX = +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = NO +HTML_OUTPUT = html +HTML_FILE_EXTENSION = .html +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_ALIGN_MEMBERS = YES +GENERATE_HTMLHELP = YES +CHM_FILE = +HHC_LOCATION = +GENERATE_CHI = NO +BINARY_TOC = YES +TOC_EXPAND = YES +DISABLE_INDEX = YES +ENUM_VALUES_PER_LINE = 4 +GENERATE_TREEVIEW = YES +TREEVIEW_WIDTH = 250 +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = NO +LATEX_OUTPUT = latex +LATEX_CMD_NAME = latex +MAKEINDEX_CMD_NAME = makeindex +COMPACT_LATEX = NO +PAPER_TYPE = a4wide +EXTRA_PACKAGES = +LATEX_HEADER = +PDF_HYPERLINKS = NO +USE_PDFLATEX = NO +LATEX_BATCHMODE = NO +LATEX_HIDE_INDICES = NO +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = YES +RTF_OUTPUT = Doc +COMPACT_RTF = YES +RTF_HYPERLINKS = YES +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = NO +MAN_OUTPUT = man +MAN_EXTENSION = .3 +MAN_LINKS = NO +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = NO +XML_OUTPUT = xml +XML_SCHEMA = +XML_DTD = +XML_PROGRAMLISTING = YES +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- +GENERATE_AUTOGEN_DEF = NO +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- +GENERATE_PERLMOD = NO +PERLMOD_LATEX = NO +PERLMOD_PRETTY = YES +PERLMOD_MAKEVAR_PREFIX = +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = YES +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = NONSHARABLE_CLASS +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- +TAGFILES = +GENERATE_TAGFILE = +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +PERL_PATH = /usr/bin/perl +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = YES +HIDE_UNDOC_RELATIONS = YES +HAVE_DOT = NO +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +GROUP_GRAPHS = YES +UML_LOOK = NO +TEMPLATE_RELATIONS = YES +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +CALL_GRAPH = NO +GRAPHICAL_HIERARCHY = YES +DIRECTORY_GRAPH = YES +DOT_IMAGE_FORMAT = png +DOT_PATH = +DOTFILE_DIRS = +MAX_DOT_GRAPH_WIDTH = 1024 +MAX_DOT_GRAPH_HEIGHT = 1024 +MAX_DOT_GRAPH_DEPTH = 0 +DOT_TRANSPARENT = NO +DOT_MULTI_TARGETS = NO +GENERATE_LEGEND = YES +DOT_CLEANUP = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- +SEARCHENGINE = NO diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/testmeasurementstub/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/testmeasurementstub/group/bld.inf Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +PRJ_PLATFORMS + + DEFAULT + +PRJ_TESTEXPORTS + +PRJ_EXPORTS + +PRJ_TESTMMPFILES + +PRJ_MMPFILES + + STIFTestMeasurementStub.mmp + +// End of File \ No newline at end of file diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/testmeasurementstub/inc/STIFTestMeasurementStub.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/testmeasurementstub/inc/STIFTestMeasurementStub.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,156 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: STIF measurement stub module declaration +* +*/ + +#ifndef STIFTESTMEASUREMENTSTUB_H +#define STIFTESTMEASUREMENTSTUB_H + +// INCLUDES +#include +#include + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def + +// FUNCTION PROTOTYPES +//?type ?function_name(?arg_list); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; + +// DATA TYPES +//enum ?declaration +//typedef ?declaration +//extern ?data_type; + +// CLASS DECLARATION + +/** +* This a CSTIFTestMeasurementStub stub class for Test Measurement Module +* Pluging. +* ?other_description_lines +* +* @lib ?library +* @since ?Series60_version +*/ +NONSHARABLE_CLASS( CSTIFTestMeasurementStub ) : + public CSTIFTestMeasurementImplementation + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CSTIFTestMeasurementStub* NewL( + const TDesC& aConfigurationInfo, + CSTIFTestMeasurement::TSTIFMeasurementType aMeasurementType ); + + /** + * Destructor. + */ + virtual ~CSTIFTestMeasurementStub(); + + public: // New functions + + /** + * ?member_description. + * @since ?Series60_version + * @param ?arg1 ?description + * @return ?description + */ + //?type ?member_function( ?type ?arg1 ); + + public: // Functions from base classes + + /** + * From CSTIFTestMeasurementStub Start + * @since ?Series60_version + * @return Symbian OS error code + */ + virtual TInt Start(); + + /** + * From CSTIFTestMeasurementStub Start + * @since ?Series60_version + * @return Symbian OS error code + */ + virtual TInt Stop(); + + /** + * From CSTIFTestMeasurementStub Start + * @since ?Series60_version + * @return CSTIFTestMeasurement::TSTIFMeasurementType + */ + virtual CSTIFTestMeasurement::TSTIFMeasurementType MeasurementType(); + + protected: // New functions + + /** + * ?member_description. + * @since ?Series60_version + * @param ?arg1 ?description + * @return ?description + */ + //?type ?member_function( ?type ?arg1 ); + + protected: // Functions from base classes + + /** + * From ?base_class ?member_description + */ + //?type ?member_function(); + + private: + + /** + * C++ default constructor. + */ + CSTIFTestMeasurementStub( + CSTIFTestMeasurement::TSTIFMeasurementType aMeasurementType ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL( const TDesC& aConfigurationInfo ); + + public: // Data + // ?one_line_short_description_of_data + //?data_declaration; + + protected: // Data + // ?one_line_short_description_of_data + //?data_declaration; + + private: // Data + + // Test Measurement module type + CSTIFTestMeasurement::TSTIFMeasurementType iMeasurementType; + + public: // Friend classes + //?friend_class_declaration; + protected: // Friend classes + //?friend_class_declaration; + private: // Friend classes + //?friend_class_declaration; + + }; + +#endif // STIFTESTMEASUREMENTSTUB_H + +// End of File \ No newline at end of file diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/testmeasurementstub/src/STIFTestMeasurementStub.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/testmeasurementstub/src/STIFTestMeasurementStub.cpp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,183 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains testmeasurementstub declaration. +* +*/ + +// INCLUDE FILES +#include "STIFTestMeasurementStub.h" + +// EXTERNAL DATA STRUCTURES +//extern ?external_data; + +// EXTERNAL FUNCTION PROTOTYPES +//extern ?external_function( ?arg_type,?arg_type ); + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def + +// LOCAL CONSTANTS AND MACROS +//const ?type ?constant_var = ?constant; +//#define ?macro_name ?macro_def + +// MODULE DATA STRUCTURES +//enum ?declaration +//typedef ?declaration + +// LOCAL FUNCTION PROTOTYPES +//?type ?function_name( ?arg_type, ?arg_type ); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; + +// ============================= LOCAL FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// ?function_name ?description. +// ?description +// Returns: ?value_1: ?description +// ?value_n: ?description_line1 +// ?description_line2 +// ----------------------------------------------------------------------------- +// +/* +?type ?function_name( + ?arg_type arg, // ?description + ?arg_type arg) // ?description + { + + ?code // ?comment + + // ?comment + ?code + } +*/ + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CSTIFTestMeasurementStub::CSTIFTestMeasurementStub +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CSTIFTestMeasurementStub::CSTIFTestMeasurementStub( + CSTIFTestMeasurement::TSTIFMeasurementType aMeasurementType ): + iMeasurementType( aMeasurementType ) + { + + } + +// ----------------------------------------------------------------------------- +// CSTIFTestMeasurementStub::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CSTIFTestMeasurementStub::ConstructL( const TDesC& aConfigurationInfo ) + { + + } + +// ----------------------------------------------------------------------------- +// CSTIFTestMeasurementStub::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CSTIFTestMeasurementStub* CSTIFTestMeasurementStub::NewL( + const TDesC& aConfigurationInfo, + CSTIFTestMeasurement::TSTIFMeasurementType aMeasurementType ) + { + CSTIFTestMeasurementStub* self = new (ELeave) CSTIFTestMeasurementStub( + aMeasurementType ); + + CleanupStack::PushL( self ); + self->ConstructL( aConfigurationInfo ); + CleanupStack::Pop(); + + return self; + + } + +// Destructor +// ----------------------------------------------------------------------------- +// CSTIFTestMeasurementStub::~CSTIFTestMeasurementStub +// Destructor. +// ----------------------------------------------------------------------------- +// +CSTIFTestMeasurementStub::~CSTIFTestMeasurementStub() + { + + } + +// ----------------------------------------------------------------------------- +// CSTIFTestMeasurementStub::Start +// Starts test measurement +// Returns Symbian error code +// ----------------------------------------------------------------------------- +// +TInt CSTIFTestMeasurementStub::Start( ) + { + return KErrNone; + + } + +// ----------------------------------------------------------------------------- +// CSTIFTestMeasurementStub::Stop +// Stops test measurement +// Returns Symbian error code +// ----------------------------------------------------------------------------- +// +TInt CSTIFTestMeasurementStub::Stop( ) + { + return KErrNone; + + } + +// ----------------------------------------------------------------------------- +// CSTIFTestMeasurementStub::MeasurementType +// +// Returns measurement module's type +// ----------------------------------------------------------------------------- +// +CSTIFTestMeasurement::TSTIFMeasurementType CSTIFTestMeasurementStub::MeasurementType( ) + { + return iMeasurementType; + + } + +// ========================== OTHER EXPORTED FUNCTIONS ========================= + +// ----------------------------------------------------------------------------- +// LibEntryL is a polymorphic Dll entry point +// Returns: CSTIFTestMeasurementImplementation*: Pointer to STIF Test +// Measurement Module +// object +// ----------------------------------------------------------------------------- +// +EXPORT_C CSTIFTestMeasurementImplementation* LibEntryL( + const TDesC& aConfigurationInfo, + CSTIFTestMeasurement::TSTIFMeasurementType aMeasurementType ) + { + CSTIFTestMeasurementImplementation* measurement; + measurement = CSTIFTestMeasurementStub::NewL( + aConfigurationInfo, aMeasurementType ); + return measurement; + + } + + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/group/STF_read_me.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/group/STF_read_me.txt Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,36 @@ +STF release Note: + + +How to deploy: +**************** +From the zip: + unzip all the files into your EPOCROOT and replace \epoc32\... repository. + + +What's in this zip : +******************** +--epoc32 + + --data ----> STF configuration files + + --include ----> exported header file + + --release ----> STF binaries of winscw & armv5 + + --rom ----> .iby files for rom build + + --tools ----> sis package of STF, test module templates for test suite developers + + --wins ----> STF configuration files + + --winscw ----> STF configuration files + + +Project wiki page : +******************** +http://wikis.in.nokia.com/TestingSolutions/STFUserWiki + + +Support : +********* +STF-Support@Nokia.com \ No newline at end of file diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/group/TestFramework.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/group/TestFramework.ini Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,217 @@ +# +# This is STIF initialization file +# Comment lines start with '#'-character. +# See STIF TestFramework users guide.doc for instructions + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set following test engine settings: +# - Set Test Reporting mode. TestReportMode's possible values are: +# + 'Summary': Summary of the tested test cases. +# + 'Environment': Hardware and software info. +# + 'TestCases': Test case report. +# + 'FullReport': Set of all above ones. +# + Example 'TestReportMode= Summary TestCases' +# +# - CreateTestReport setting controls report creation mode +# + YES, Test report will created. +# + NO, No Test report. +# +# - File path indicates the base path of the test report. +# - File name indicates the name of the test report. +# +# - File format indicates the type of the test report. +# + TXT, Test report file will be txt type, for example 'TestReport.txt'. +# + HTML, Test report will be html type, for example 'TestReport.html'. +# + XML, Test report will be xml type, for example 'TestReport.xml'. +# Note, that xml format is available only when output is set to FILE. +# +# - File output indicates output source of the test report. +# + FILE, Test report logging to file. +# + RDEBUG, Test report logging to using rdebug. +# +# - File Creation Mode indicates test report overwriting if file exist. +# + OVERWRITE, Overwrites if the Test report file exist. +# + APPEND, Continue logging after the old Test report information if +# report exist. +# - Sets a device reset module's dll name(Reboot). +# + If Nokia specific reset module is not available or it is not correct one +# StifHWResetStub module may use as a template for user specific reset +# module. +# - Sets STIF test measurement disable options. e.g. pluging1 and pluging2 disablation +# DisableMeasurement= stifmeasurementplugin01 stifmeasurementplugin02 +# + +[Engine_Defaults] + +TestReportMode= FullReport # Possible values are: 'Empty', 'Summary', 'Environment', + # 'TestCases' or 'FullReport' + +CreateTestReport= YES # Possible values: YES or NO + +TestReportFilePath= C:\LOGS\TestFramework\ +TestReportFileName= TestReport + +TestReportFormat= TXT # Possible values: TXT, HTML or XML +TestReportOutput= FILE # Possible values: FILE or RDEBUG +TestReportFileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +DeviceResetDllName= StifResetForNokia.dll # e.g. 'StifHWResetStub.dll' for user specific reseting + +DisableMeasurement= stifmeasurementdisablenone # Possible values are: + # 'stifmeasurementdisablenone', 'stifmeasurementdisableall' + # 'stifmeasurementplugin01', 'stifmeasurementplugin02', + # 'stifmeasurementplugin03', 'stifmeasurementplugin04', + # 'stifmeasurementplugin05' or 'stifbappeaprofiler' + +Timeout= 0 # Default timeout value for each test case. In milliseconds +#UITestingSupport= YES # Possible values: YES or NO +#SeparateProcesses= YES # Possible values: YES or NO (default: NO) +[End_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Module configurations start +# Modules are added between module tags +# tags. Module name is specified after ModuleName= tag, like +# ModuleName= XXXXXXXXX +# Modules might have initialisation file, specified as +# IniFile= c:\testframework\YYYYYY +# Modules might have several configuration files, like +# TestCaseFile= c:\testframework\NormalCases.txt +# TestCaseFile= c:\testframework\SmokeCases.txt +# TestCaseFile= c:\testframework\ManualCases.txt + +# (TestCaseFile is synonym for old term ConfigFile) + +# Following case specifies demo module settings. Demo module +# does not read any settings from file, so tags +# IniFile and TestCaseFile are not used. +# In the simplest case it is enough to specify only the +# name of the test module when adding new test module + +[New_Module] +ModuleName= demomodule +[End_Module] + + +# Load testmoduleXXX, optionally with initialization file and/or test case files +#[New_Module] +#ModuleName= testmodulexxx + +#TestModuleXXX used initialization file +#IniFile= c:\testframework\init.txt + +#TestModuleXXX used configuration file(s) +#TestCaseFile= c:\testframework\testcases1.cfg +#TestCaseFile= c:\testframework\testcases2.cfg +#TestCaseFile= c:\testframework\manualtestcases.cfg + +#[End_Module] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set STIF logging overwrite parameters for Logger. +# Hardware and emulator environment logging path and styles can +# be configured from here to overwrite the Logger's implemented values. +# +# Settings description: +# - Indicates option for creation log directory/directories. If log directory/directories +# is/are not created by user they will make by software. +# + YES, Create log directory/directories if not allready exist. +# + NO, Log directory/directories not created. Only created one is used. +# +# - Overwrite emulator path setting. +# + Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined +# Logger's path 'D:\\LOGS\\Module\\' with those definition the path +# will be 'C:\LOGS\TestFramework\LOGS\Module\' +# +# - Overwrite emulator's logging format. +# + TXT, Log file(s) will be txt type(s), for example 'Module.txt'. +# + HTML, Log file(s) will be html type(s), for example 'Module.html'. +# +# - Overwrited emulator logging output source. +# + FILE, Logging to file(s). +# + RDEBUG, Logging to using rdebug(s). +# +# - Overwrite hardware path setting (Same description as above in emulator path). +# - Overwrite hardware's logging format(Same description as above in emulator format). +# - Overwrite hardware's logging output source(Same description as above in emulator output). +# +# - File Creation Mode indicates file overwriting if file exist. +# + OVERWRITE, Overwrites if file(s) exist. +# + APPEND, Continue logging after the old logging information if file(s) exist. +# +# - Will thread id include to the log filename. +# + YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'. +# + NO, No thread id to log file(s), Example filename 'Module.txt'. +# +# - Will time stamps include the to log file. +# + YES, Time stamp added to each line in log file(s). Time stamp is +# for example'12.Nov.2003 115958 LOGGING INFO' +# + NO, No time stamp(s). +# +# - Will line breaks include to the log file. +# + YES, Each logging event includes line break and next log event is in own line. +# + NO, No line break(s). +# +# - Will event ranking include to the log file. +# + YES, Event ranking number added to each line in log file(s). Ranking number +# depends on environment's tics, for example(includes time stamp also) +# '012 12.Nov.2003 115958 LOGGING INFO' +# + NO, No event ranking. +# +# - Will write log file in unicode format. +# + YES, Log file will be written in unicode format +# + NO, Log will be written as normal, not unicode, file. +# + +[Logger_Defaults] + +#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#' +#NOTE: TestEngine and TestServer logging settings cannot change here + +#CreateLogDirectories= YES # Possible values: YES or NO + +#EmulatorBasePath= C:\LOGS\TestFramework\ +#EmulatorFormat= HTML # Possible values: TXT or HTML +#EmulatorOutput= FILE # Possible values: FILE or RDEBUG + +#HardwareBasePath= D:\LOGS\TestFramework\ +#HardwareFormat= HTML # Possible values: TXT or HTML +#HardwareOutput= FILE # Possible values: FILE or RDEBUG + +#FileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +#ThreadIdToLogFile= YES # Possible values: YES or NO +#WithTimeStamp= YES # Possible values: YES or NO +#WithLineBreak= YES # Possible values: YES or NO +#WithEventRanking= YES # Possible values: YES or NO + +#FileUnicode= YES # Possible values: YES or NO +#AddTestCaseTitle= YES # Possible values: YES or NO +[End_Logger_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set filters to be used by ConsoleUI. +# If you want to use filter with ConsoleUI, simply remove comments +# from section below and provide valid filter entries. +# Each filter line has to start with "filter= " keyword. +# Filter can contain special wildcard characters: +# * which stands for none or any literal; +# ? which stands for single character. +# Filters are not case-sensitive. + +#[Filters] +#filter= *math* +#filter= *radio* +#[End_Filters] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + +# End of file diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/group/bld.inf Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +* bld.inf Toplevel build information for STF. +*/ + +#include + + +PRJ_PLATFORMS + + DEFAULT + + +PRJ_EXPORTS + + TestFramework.ini +/wins/c/TestFramework/TestFramework.ini + TestFramework.ini +/winscw/c/TestFramework/TestFramework.ini + TestFramework.ini +/data/z/system/data/TestFramework.ini + + // This is added in order to export iby files automaticly in 5.0 env + ../rom/Stif.iby CORE_IBY_EXPORT_PATH(tools,Stif.iby) + + ../rom/stif_rom.iby CORE_IBY_EXPORT_PATH(tools/rom,stif_rom.iby) + + :zip ../TestModuleTemplates/TestModuleTemplates.zip +/tools/s60rndtools/stf + :zip ../examples/MigrationExample.zip +/tools/s60rndtools/stf + +PRJ_TESTEXPORTS + +PRJ_MMPFILES + +// STF API +#include "../api/api_platform/group/bld.inf" + +// STF framework +#include "../stffw/group/bld.inf" + +// STF extensions +#include "../stfext/group/bld.inf" + +// STF UI +#include "../stfui/group/bld.inf" + +// Examples +#include "../examples/demomodule/group/bld.inf" + + +// End of File + +PRJ_MMPFILES diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/group/package_all.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/group/package_all.bat Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,105 @@ +@rem +@rem Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +@rem All rights reserved. +@rem This component and the accompanying materials are made available +@rem under the terms of "Eclipse Public License v1.0" +@rem which accompanies this distribution, and is available +@rem at the URL "http://www.eclipse.org/legal/epl-v10.html". +@rem +@rem Initial Contributors: +@rem Nokia Corporation - initial contribution. +@rem +@rem Contributors: +@rem +@rem Description: +@rem +@echo off +rem ---remove any old zip files if exists--- +@del *.zip 2>1 + +rem --- prepare zip file name STF_Version_Timestamp.zip +set VER=1.0.0 + +rem Date +set DATE0=%date% +if %DATE0% equ 0 (set DATE0=%date:~-10%) else (set DATE0=%date:~,10%) +rem time +set tsp="%time:~0,1%" +if %tsp%==" " (set TIME0=0%time:~1,1%%time:~3,2%%time:~6,2%)&goto NEXTTASK: +set TIME0=%time:~0,2%%time:~3,2%%time:~6,2% +rem time stamp +:NEXTTASK +set TMST=%DATE0%_%TIME0% + +echo STF Version: %VER% +set ZIPFILE=STF_%VER%_%TMST%.zip +echo Package file name: %ZIPFILE% + +rem ---------BUILD---------- +rem call abld reallyclean +rem call bldmake clean +rem call bldmake bldfiles +rem call abld build + +rem ---------packaging--------- +rem "abld build -what" to get all exported files +call abld build -what > TEMP + +for /f %%l in (TEMP) do ( +@zip %ZIPFILE% %%l +) + +del TEMP + + +rem ---------BUILD STFQTUI---------- +rem pushd %cd% + +rem cd ..\stfui\qtui\StfQtUI +rem call qmake +rem call bldmake bldfiles +rem call abld build + +rem ---------packaging STFQTUI--------- +rem "abld build -what" to get all exported files +rem call abld build -what > TEMP + +rem for /f %%l in (TEMP) do ( +rem @zip ..\..\..\group\%ZIPFILE% %%l +rem ) + +rem del TEMP + +rem popd + +rem ---------packaging MigrationExample--------- +set TEMPLATE_TARGET=\epoc32\tools\s60rndtools\stf\MigrationExample +zip %ZIPFILE% %TEMPLATE_TARGET%\* +zip %ZIPFILE% %TEMPLATE_TARGET%\*\* +zip %ZIPFILE% %TEMPLATE_TARGET%\*\*\* +zip %ZIPFILE% %TEMPLATE_TARGET%\*\*\*\* + +rem --------packaging testmoduletemplates-------- +set TEMPLATE_TARGET=\epoc32\tools\s60rndtools\stf\testmoduletemplates +zip %ZIPFILE% %TEMPLATE_TARGET%\* +zip %ZIPFILE% %TEMPLATE_TARGET%\*\* +zip %ZIPFILE% %TEMPLATE_TARGET%\*\*\* + +rem ---------create and add sis package into zip file-------- +set SIS_TARGET=\epoc32\tools\s60rndtools\stf\sis +md %SIS_TARGET% +rem set KEY_DIR to the real path +rem set KEY_DIR=YOUR_KEY_DIR +copy ..\sis\stf.pkg %SIS_TARGET%\stf.pkg /y +rem copy ..\stfui\qtui\StfQtUI\StfQtUI.pkg %SIS_TARGET%\StfQtUI.pkg /y +rem ----create sis---- +makesis %SIS_TARGET%\stf.pkg %SIS_TARGET%\stf.sis +rem makesis %SIS_TARGET%\StfQtUI.pkg %SIS_TARGET%\StfQtUI.sis +rem ----sign sis------ +rem signsis -s %SIS_TARGET%\stf.sis %SIS_TARGET%\stf.sisx %KEY_DIR%\rd.crt %KEY_DIR%\rd.key +rem signsis -s %SIS_TARGET%\StfQtUI.sis %SIS_TARGET%\StfQtUI.sisx %KEY_DIR%\rd.crt %KEY_DIR%\rd.key +rem -----zip all------ +zip %ZIPFILE% %SIS_TARGET%\* + +rem -----STF_read_me.txt------ +zip %ZIPFILE% STF_read_me.txt \ No newline at end of file diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/inc/STIFConfiguration.mmh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/inc/STIFConfiguration.mmh Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef STIFCONFIGURATION_MMH +#define STIFCONFIGURATION_MMH + +// MMP's header file for macro definitions. + +/** +* STIF's TestEngine and TestServer logs to c:\logs\testframework\testengine +* and c:\logs\testframework\testserver directories. These logging can be changed +* to log RDebug with next macro. If uncommenting this macro STIFTestFramework +* reallyclean and compile is needed (from \STIFTestFramework\group\bld.inf). +*/ +//MACRO FORCE_STIF_INTERNAL_LOGGING_TO_RDEBUG + + +#endif // STIFCONFIGURATION_MMH + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/inc/STIFMeasurement.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/inc/STIFMeasurement.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: StifMeasurement plugin names declaration +* +*/ + +#ifndef STIF_MEASUREMENT_H +#define STIF_MEASUREMENT_H + +// INCLUDES +#include + +// Maximum length of measurement types(see literals below) +const TInt KStifMeasurementTypeLength = 30; + +/** +* Literals for measurement types. +*/ +_LIT( KStifMeasurementEnableAll, "stifmeasurementenableall" ); +_LIT( KStifMeasurementDisableAll, "stifmeasurementdisableall" ); +_LIT( KStifMeasurement01, "stifmeasurementplugin01" ); +_LIT( KStifMeasurement02, "stifmeasurementplugin02" ); +_LIT( KStifMeasurement03, "stifmeasurementplugin03" ); +_LIT( KStifMeasurement04, "stifmeasurementplugin04" ); +_LIT( KStifMeasurement05, "stifmeasurementplugin05" ); +_LIT( KStifMeasurementBappea, "stifbappeaprofiler" ); +// Next is used in testframework.ini file +_LIT( KStifMeasurementDisableNone, "stifmeasurementdisablenone" ); + + +// Measurement module types definition(used in keyword's parameters) +_LIT( KParamMeasurement01, "measurementplugin01" ); +_LIT( KParamMeasurement02, "measurementplugin02" ); +_LIT( KParamMeasurement03, "measurementplugin03" ); +_LIT( KParamMeasurement04, "measurementplugin04" ); +_LIT( KParamMeasurement05, "measurementplugin05" ); +_LIT( KParamMeasurementBappea, "stifbappeaprofiler" ); + +/** +* Enumeration for measurement disable and enable. +*/ +enum TDisableMeasurement + { + EDisableAll = 0xFFFFFFFF, // Disable all measurement, 1111 + EEnableAll = ~EDisableAll, // This allowes all measurements, 0000 + EMeasurement01 = 1<<0, // User specific measurement + EMeasurement02 = 1<<1, // User specific measurement + EMeasurement03 = 1<<2, // User specific measurement + EMeasurement04 = 1<<3, // User specific measurement + EMeasurement05 = 1<<4, // User specific measurement + EBappea = 1<<25, // Disable bappea measurement + }; + +#endif // STIF_MEASUREMENT_H + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/inc/StifKernelTestClass.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/inc/StifKernelTestClass.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,111 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Kernel test class for STIF Test Framework TestScripter +* +*/ + + +#ifndef STIFKERNELTESTCLASS_H +#define STIFKERNELTESTCLASS_H + +// INCLUDES + +#include + + +// CONSTANTS + +// MACROS + +// DATA TYPES + +typedef TBuf8<0x80> TMethodResultDes; +typedef TBuf8<0x20> TMethodName; +typedef TBuf8<0x100> TMethodParams; + + +// FUNCTION PROTOTYPES + +// FORWARD DECLARATIONS + +// CLASS DECLARATION +class TStifRunMethodInfo + { + public: + TStifRunMethodInfo() : + iResult( 0 ) + { + iMethodName.Zero(); + iMethodParams.Zero(); + iMethodResultDes.Zero(); + } + + public: + TMethodName iMethodName; + TMethodParams iMethodParams; + TMethodResultDes iMethodResultDes; + TInt iResult; + + }; + +// CLASS DECLARATION + +/** +* RStifKernelTestClass kernel test class for STIF Test Framework TestScripter. +* ?other_description_lines +* +* @lib ?library +* @since ?Series60_version +*/ +class RStifKernelTestClass : public RBusLogicalChannel + { + public: + // Synchronous operations + enum TStifKernelTCOperation + { + ERunMethod = 1, + }; + + // Version number + enum TStifKernelTCVersion + { + EMajorVersionNumber=1, + EMinorVersionNumber=0, + EBuildVersionNumber=1 + }; + + public: // Interface functions + + // Open + inline TInt Open( const TVersion& aVer, const TDesC& aDriverName ); + + // Return required version + inline TVersion VersionRequired() const; + + // Run specific method + + + inline TInt RunMethod( const TDesC8& aMethodName, + const TDesC8& aParams, + TInt& aResult, + TDes8& aResultDes ); + + }; + +// Include inline function implementations +#include "StifKernelTestClass.inl" + +#endif // STIFKERNELTESTCLASS_H + +// End of File \ No newline at end of file diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/inc/StifKernelTestClass.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/inc/StifKernelTestClass.inl Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef STIFKERNELTESTCLASS_INL +#define STIFKERNELTESTCLASS_INL + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// RStifKernelTestClass::Open +// Open driver. +// ----------------------------------------------------------------------------- +// +TInt RStifKernelTestClass::Open( const TVersion& aVer, const TDesC& aDriverName ) + { + return DoCreate( aDriverName, aVer, KNullUnit, NULL, NULL ); + } + +// ----------------------------------------------------------------------------- +// RStifKernelTestClass::VersionRequired +// Get version info. +// ----------------------------------------------------------------------------- +// +TVersion RStifKernelTestClass::VersionRequired() const + { + return TVersion( EMajorVersionNumber, EMinorVersionNumber, EBuildVersionNumber ); + } + +// ----------------------------------------------------------------------------- +// RStifKernelTestClass::RunMethod +// DoControl call to the kernel side for test case execution +// ----------------------------------------------------------------------------- +// + +TInt RStifKernelTestClass::RunMethod( const TDesC8& aMethodName, + const TDesC8& aMethodParams, + TInt& aResult, + TDes8& aResultDes ) + { + TStifRunMethodInfo methodInfo; + if( ( aMethodName.Length() > methodInfo.iMethodName.MaxLength() ) || + ( aMethodParams.Length() > methodInfo.iMethodParams.MaxLength() ) ) + { + return KErrArgument; + } + methodInfo.iMethodName.Copy( aMethodName ); + methodInfo.iMethodParams.Copy( aMethodParams ); + + TPckg methodInfoPckg( methodInfo ); + TInt ret = DoControl( ERunMethod, ( TAny* )&methodInfoPckg ); + + if( ret != KErrNone ) + { + return ret; + } + + aResult = methodInfo.iResult; + aResultDes.Copy( methodInfo.iMethodResultDes.Left( aResultDes.MaxLength() ) ); + return KErrNone; + } + +#endif // STIFKERNELTESTCLASS_INL + +// End of File \ No newline at end of file diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/inc/StifPython.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/inc/StifPython.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header of additional functions +* needed for Python support and used in PythonScripter, TestEngine +* and TestCombiner. +* +*/ + +#ifndef STIFPYTHON_H +#define STIFPYTHON_H + +// INCLUDES +#include + +// CONSTANTS +_LIT(KPythonScripter, "pythonscripter"); +const TInt KPythonScripterLength = 14; + + +// MACROS +// None + +// DATA TYPES +// None + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION +// None + +#endif // STIFPYTHON_H + +// End of File \ No newline at end of file diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/inc/StifTFw.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/inc/StifTFw.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,190 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the CStifTFw. +* +*/ + +#ifndef STIF_TFW_H +#define STIF_TFW_H + +// INCLUDES +#include +#include +#include +#include +#include + +// CONSTANTS +// None + +// MACROS + +// DATA TYPES + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +class CUIEngineContainer; +class CUIEngineEvent; +class CStifTFwIf; + +// CLASS DECLARATION + +// CStifTFw is the sub class of STIF Test Framework Interface +class CStifTFw + :public CUIIf + { + public: // Enumerations + + protected: // Enumerations + + private: // Enumerations + + public: // Constructors and destructor + /** + * NewL is first phase of two-phased constructor. + */ + static CStifTFw* NewL( CStifTFwIf* aStifTFwIf ); + + /** + * Destructor. + */ + virtual ~CStifTFw(); + + public: + + protected: // Functions that can be called from derived class + + protected: // Functions that the derived class may implement. + + private: + + /** + * Constructor. + */ + CStifTFw( CStifTFwIf* aStifTFwIf ); + + /** + * Second phase constructor. + */ + void ConstructL(); + + /** + * Test case executed. + * + * Returns Symbian OS error code. + */ + IMPORT_C void TestExecuted( CUIEngineContainer* aContainer, + TFullTestResult& aFullTestResult ); + /** + * Progress information from Test case execution. + * + * Returns Symbian OS error code. + */ + IMPORT_C TInt PrintProg ( CUIEngineContainer* aContainer, + TTestProgress& aProgress ); + + /** + * Forward message to ATS. + */ + IMPORT_C TInt RemoteMsg( CUIEngineContainer* aContainer, + const TDesC& /*aMessage*/ ); + + /** + * Forward reboot indication to ATS. + */ + IMPORT_C TInt GoingToReboot( CUIEngineContainer* aContainer, + TRequestStatus& aStatus ); + + /** + * Initialize logger from UI engine. + */ + void InitializeLogger( CStifLogger* aLogger ){ iLogger = aLogger; } + + /** + * Remote ATS call + */ + TInt AtsRemote( CStifTFwIfProt& aReq, CStifTFwIfProt& aResp ); + + /** + * Remote ATS run call + */ + TInt AtsRemoteRun( CStifTFwIfProt& aReq, CStifTFwIfProt& aResp ); + + /** + * Remote ATS test control call + */ + TInt AtsRemoteTestCtl( CStifTFwIfProt& aReq, CStifTFwIfProt& aResp ); + + /** + * Remote ATS event system control call + */ + TInt AtsRemoteEventCtl( CStifTFwIfProt& aReq, CStifTFwIfProt& aResp ); + + /** + * Delete data in class + */ + void DeleteData(); + + /** + * Enumerates test cases from given module and finds test case index by title + */ + TInt GetCaseNumByTitle(TDesC& aModule, TDesC& aTestCaseFile, TDesC& aTitle, TInt& aCaseNum); + + public: // Data + /** + * Logger created by UI engine. + */ + CStifLogger* iLogger; + + protected: // Data + + private: // Data + /** + * Pointer to UI engine. + */ + CUIEngine* iUIEngine; + + /** + * Pointer to CStifTfwIf + */ + CStifTFwIf* iStifTFwIf; + + // Execute test case table + RPointerArray iTestExecutionTable; + + // Remote execute test case table + RPointerArray iTestRemoteExecutionTable; + + // Remote execute test case table + RPointerArray iEventArray; + + // Array of master identifiers that have reserved the slave + RArray iMasterArray; + + public: // Friend classes + // None + + protected: // Friend classes + // None + + private: // Friend classes + friend class CStifTFwIf; + + }; + +#endif // STIF_TFW_H + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/inc/TestModuleInfo.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/inc/TestModuleInfo.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,294 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the +* CTestModuleInfo class. The class was created to keep module names, +* ini files and test case configuration files. +* +*/ + +#ifndef TESTMODULEINFO_H +#define TESTMODULEINFO_H + +// INCLUDES +#include +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION + +// DESCRIPTION +// Class with information about configuration (test case) file. +class CTestCaseFileInfo + :public CBase + { + public: // Enumerations + + private: // Enumerations + + public: // Constructors and destructor + /** + * NewL. + */ + static CTestCaseFileInfo* NewL(TDesC& aCfgFileName, CStifLogger* aLogger); + + /** + * C++ destructor. + */ + virtual ~CTestCaseFileInfo(); + + private: // Constructors and destructor + /** + * C++ constructor. + */ + CTestCaseFileInfo(); + + /** + * By default Symbian OS constructor is private. + */ + void ConstructL(TDesC& aCfgFileName, CStifLogger* aLogger); + + public: // New functions + /** + * Set configuration file as already checked. + */ + IMPORT_C void SetChecked(void); + + /** + * Return if config file has been checked. + */ + TBool IsChecked(void); + + /** + * Get module name. + */ + IMPORT_C TInt GetCfgFileName(TDes& aCfgFileName); + + + + protected: // New functions + + private: // New functions + + public: // Data + + protected: // Data + + private: // Data + //Config file name + HBufC* iCfgFileName; + + //Was checked + TBool iChecked; + + // Logger instance + CStifLogger* iLogger; + + public: // Friend classes + + protected: // Friend classes + + private: // Friend classes + }; + +// DESCRIPTION +// Class with information about test modules. +class CTestModuleInfo + :public CBase + { + public: // Enumerations + + private: // Enumerations + + public: // Constructors and destructor + /** + * NewL. + */ + static CTestModuleInfo* NewL(TDesC& aModuleName, CStifLogger* aLogger); + + /** + * C++ destructor. + */ + virtual ~CTestModuleInfo(); + + private: // Constructors and destructor + /** + * C++ constructor. + */ + CTestModuleInfo(); + + /** + * By default Symbian OS constructor is private. + */ + void ConstructL(TDesC& aModuleName, CStifLogger* aLogger); + + public: // New functions + /** + * Set initialization file name. + */ + IMPORT_C TInt SetIniFile(TDesC& aIniFileName); + + /** + * Add configuration (test case) file name to array. + */ + IMPORT_C TInt AddCfgFile(TDesC& aCfgFileName); + + /** + * Get number of test case files. + */ + IMPORT_C TInt CountCfgFiles(void); + + /** + * Get module name. + */ + IMPORT_C TInt GetModuleName(TDes& aModuleName); + + /** + * Get ini file. + */ + IMPORT_C TInt GetIniFileName(TDes& aIniFileName); + + /** + * Get cfg file. + */ + IMPORT_C TInt GetCfgFileName(TInt aIndex, TDes& aCfgFileName); + + /** + * Get first unchecked config file. + */ + CTestCaseFileInfo* GetUncheckedCfgFile(void); + + protected: // New functions + + private: // New functions + + public: // Data + + protected: // Data + + private: // Data + //Module name + HBufC* iModuleName; + + //Initialization file + HBufC* iIniFileName; + + //Array of cfg files + RPointerArray iCfgFiles; + + // Logger instance + CStifLogger* iLogger; + + public: // Friend classes + + protected: // Friend classes + + private: // Friend classes + }; + +// DESCRIPTION +// Class with list of test modules. +class CTestModuleList + :public CBase + { + public: // Enumerations + + private: // Enumerations + + public: // Constructors and destructor + /** + * NewL. + */ + IMPORT_C static CTestModuleList* NewL(CStifLogger* aLogger); + + /** + * C++ destructor. + */ + IMPORT_C virtual ~CTestModuleList(); + + private: // Constructors and destructor + /** + * C++ constructor. + */ + CTestModuleList(); + + /** + * By default Symbian OS constructor is private. + */ + void ConstructL(CStifLogger* aLogger); + + public: // New functions + /** + * Add test module to list. + */ + IMPORT_C TInt AddTestModule(TDesC& aModuleName); + + /** + * Get number of test modules. + */ + IMPORT_C TInt Count(void); + + /** + * Get module. + */ + IMPORT_C CTestModuleInfo* GetModule(TDesC& aModuleName); + + /** + * Get module. + */ + IMPORT_C CTestModuleInfo* GetModule(TInt aIndex); + + /** + * Get first unchecked test case file (module: testscripter and testcombiner). + */ + IMPORT_C CTestCaseFileInfo* GetUncheckedCfgFile(void); + + protected: // New functions + + private: // New functions + + public: // Data + + protected: // Data + + private: // Data + //Array of test modules + RPointerArray iTestModules; + + // Logger instance + CStifLogger* iLogger; + + public: // Friend classes + + protected: // Friend classes + + private: // Friend classes + }; + +#endif // TESTMODULEINFO_H + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/inc/TestServerModuleIf.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/inc/TestServerModuleIf.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,697 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the CTestExecution. +* +*/ + +#ifndef TEST_SERVER_MODULE_IF_H +#define TEST_SERVER_MODULE_IF_H + + +// INCLUDES +#include +#include +#include +#include +#include +#include +#include "StifTFwIfProt.h" + +// CONSTANTS + +// MACROS + +// DATA TYPES + +// FUNCTION PROTOTYPES +typedef CSTIFTestMeasurementImplementation*( + *CTestMeasurementFactory )( const TDesC&, + CSTIFTestMeasurement::TSTIFMeasurementType ); + +// FORWARD DECLARATIONS +class TEvent; +class CTestModule; +class CTestModuleContainer; +class CPrintQueue; +class CPrintHandler; +class CEventHandler; +class CSndHandler; +class CRcvHandler; +class CErrorPrintHandler; +class CInterferenceHandler; +class CMeasurementHandler; +class CCommandHandler; +class CAsyncEventActive; + +// CLASS DECLARATION + +// DESCRIPTION +// TCmdDef represents remote command +class TCmdDef + { + public: + TStifCommand iCommand; + TParams iParam; + TInt iLen; + TRequestStatus* iStatus; + }; + +// TCommandDef represents command +class TCommandDef + { + public: + TCommand iCommand; + TBuf8 iParamsPckg; + }; + +// DESCRIPTION +// CCommandDef represents command +class CCommandDef : public CBase + { + public: // Enumerations + + private: // Enumerations + + public: // Constructors and destructor + static CCommandDef* NewL(); + ~CCommandDef(); + + private: // Constructors and destructor + CCommandDef(); + void ConstructL(); + + public: // New functions + + public: // Functions from base classes + + protected: // New functions + + protected: // Functions from base classes + + private: + + public: //Data + TCommand iCommand; + TBuf8 iParamsPckg; + + protected: // Data + + private: // Data + + public: // Friend classes + + protected: // Friend classes + + private: // Friend classes + + }; + +// CLASS DECLARATION + +// DESCRIPTION +// TCmdDef represents remote command +class TEventDef + { + public: + enum TEventCmdType + { + EEventCmd, + EEventCmdCancel, + }; + // Added constructor to TEventDef @js + TEventDef():iStatus(NULL){}; + + public: + TEventCmdType iType; + TEventIf iEvent; + TRequestStatus* iStatus; + }; + +// DESCRIPTION +// TTestInterference represents remote command +class TTestInterference + { + public: + enum TOperation + { + EAppend, + ERemove, + }; + public: + TTestInterference(){}; + public: + // Thread id. + TUint iThreadId; + // Is operations append or remove. + TOperation iOperation; + }; + +// DESCRIPTION +// TTestMeasurement contains measurement related information +// transfering between TestInterface and TestServer. +class TTestMeasurement + { + public: + TTestMeasurement(){}; + public: + // Struct for information. + CSTIFTestMeasurement::TStifMeasurementStruct iMeasurementStruct; + + }; + +// DESCRIPTION +// TMeasurementHandling keeps information for measurement module +// dynamic loading, types, etc. +class TMeasurementHandling + { + public: + TMeasurementHandling() : iMeasurement( NULL ), + iMeasurementModulePtr( NULL ){}; + + ~TMeasurementHandling() + { + delete iMeasurement; + delete iMeasurementModulePtr; + // After close test measurement's pointer is not valid anymore. + if ( iMeasurementModule.Handle() ) + { + iMeasurementModule.Close(); + } + }; + public: + RLibrary iMeasurementModule; + CTestMeasurementFactory iMeasurementLibEntry; + CSTIFTestMeasurementImplementation* iMeasurement; + CSTIFTestMeasurement::TSTIFMeasurementType iMeasurementType; + CSTIFTestMeasurementImplementation* iMeasurementModulePtr; + }; + +// CLASS DECLARATION + +// DESCRIPTION +// CTestExecution represents a subsession object in the CTestServer. +// A session may own any number of CTestExecution objects +class CTestExecution + :public CObject + { + + public: // Enumerations + enum TTestState + { + ENotStarted, + EOnGoing, + EFinished, + ECancelled, + }; + + enum TRequestType + { + ERqPrint, + ERqEvent, + ERqSnd, + ERqRcv, + ERqInterference, + ERqMeasurement, + ERqCommand, + }; + + enum TTestThreadFailure + { + ETestThreadOk = 0, + ETestMemLeak = 0x00000001, + ETestRequestLeak = 0x00000002, + ETestHandleLeak = 0x00000004, + }; + + private: // Enumerations + // None + + public: // Constructors and destructor + + /** + * NewL is first phase of two-phased constructor. + */ + static CTestExecution* NewL( CTestModule* aModuleSession, + TInt aCaseNumber, + const TFileName& aConfig + ); + + /** + * Destructor + */ + virtual ~CTestExecution(); + + public: // New functions + + /** + * Close Test Execution + */ + TInt CloseTestExecution( const RMessage2& aMessage ); + + /** + * Run a test case + */ + TInt RunTestCase( const RMessage2& aMessage ); + + /** + * Sets a print notification + */ + TInt NotifyPrint( const RMessage2& aMessage ); + + /** + * Sets a event notification + */ + TInt NotifyEvent( const RMessage2& aMessage ); + + /** + * Sets a RemoteCmd notification + */ + TInt NotifyRemoteCmd( const RMessage2& aMessage ); + + /** + * Reads a RemoteCmd notification + */ + TInt ReadRemoteCmdInfo( const RMessage2& aMessage ); + + /** + * Resumes a paused test case + */ + TInt Resume( const RMessage2& aMessage ); + + /** + * Pauses ongoing test case + */ + TInt Pause( const RMessage2& aMessage ); + + + /** + * Cancels asynchronous request + */ + TInt CancelRequestL( const RMessage2& aMessage ); + + + /** + * Completes a print request. + */ + void DoNotifyPrint(); + + /** + * Completes a interference request. + */ + void DoNotifyInterference(); + + /** + * Completes a measurement request. + */ + TInt DoNotifyMeasurement(); + + /** + * Completes a print request. + */ + void DoErrorPrint(); + + /** + * Enables remote command receiving. + */ + void DoRemoteReceive(); + + /** + * Sends remote commands. + */ + void DoRemoteSend(); + + /** + * Completes a event request. + */ + TInt DoNotifyEvent(); + + /** + * Completes a event cancel request. + */ + void CancelEvent(); + + /** + * Set thread State. + * This function can be called from test execution thread. + */ + void SetThreadState( const TTestState aState ); + + /** + * Completes print request if print queue is empty + */ + void CompletePrintRequestIfQueueEmpty(); + + /** + * Completes print request if print queue is empty + */ + void CleanupEvents(); + + /** + * Completes test execution + */ + void CompleteTestExecution( const TInt aCompletionCode, + const TFullTestResult::TCaseExecutionResult aCaseExecutionType, + const TInt aCaseExecutionCode, + const TInt aCaseResult, + const TDesC& aText ); + + /** + * Unsets all pending state events. + */ + void UnsetStateEvents(); + + /** + * Completes test execution + */ + void CompleteTestExecution( const TInt aCompletionCode ); + + /** + * Current thread state. + */ + TTestState ThreadState(){ return iThreadState; } + + /** + * Cancels test(s) execution in special cases e.g. timeout, exit etc. + */ + TInt CancelTestExecution(); + + /** + * Make sure that any of the test interference thread's won't stay + * to run if test case is crashed of test interference object is not + * deleted. + */ + TInt KillTestinterferenceThread(); + + /** + * Make sure that any of the test measurement process's won't stay + * to run if test case is crashed of test measurement object is not + * deleted. + */ + TInt KillTestMeasurement(); + + /** + * Executes command for ongoing test case. + * Created to allow test case to kill itself. + */ + TInt NotifyCommand(const RMessage2& aMessage); + + /** + * Completes a command request. + * Created to allow test case to kill itself. + */ + TInt DoNotifyCommand(); + + /** + * Cancels command request. + * Created to allow test case to kill itself. + */ + TInt CancelCommandRequest(); + + public: // Functions that are called from test thread + + /** + * Get mutex handles. + */ + TInt EventMutexHandle(){ return iEventMutex.Handle(); }; + TInt SndMutexHandle(){ return iSndMutex.Handle(); }; + TInt RcvMutexHandle(){ return iRcvMutex.Handle(); }; + TInt PrintMutexHandle(){ return iPrintMutex.Handle(); }; + TInt InterferenceMutexHandle(){ return iInterferenceMutex.Handle(); }; + TInt MeasurementMutexHandle(){ return iMeasurementMutex.Handle(); }; + TInt CommandMutexHandle(){ return iCommandMutex.Handle(); }; + + /** + * Get semaphore handles. + */ + TInt EventSemHandle(){ return iEventSem.Handle(); }; + TInt SndSemHandle(){ return iSndSem.Handle(); }; + TInt RcvSemHandle(){ return iRcvSem.Handle(); }; + //TInt ReceiverSemHandle(){ return iReceiverSem.Handle(); }; + TInt PrintSemHandle(){ return iPrintSem.Handle(); }; + TInt InterferenceSemHandle(){ return iInterferenceSem.Handle(); }; + TInt MeasurementSemHandle(){ return iMeasurementSem.Handle(); }; + TInt CommandSemHandle(){ return iCommandSem.Handle(); }; + + /** + * Set execution test thread id. + */ + void SetTestThread( TThreadId aThreadId ){ iTestThreadId = aThreadId; }; + + /** + * Access to "shared" memory. + */ + TFullTestResult& FullResult(){ return iFullResult; }; + TTestProgress& TestProgress(){ return iProgress; }; + TEventDef& EventDef(){ return iEventDef; }; + TCmdDef& SndInfo(){ return iCmdDef; }; + TCmdDef& RcvInfo(){ return iRcvCmdDef; }; + TInt& TestThreadFailure(){ return iTestThreadFailure; }; + TTestInterference& TestInterference(){ return iTestInterference; }; + TTestMeasurement& TestMeasurement(){ return iTestMeasurement; }; + CCommandDef& CommandDef(){ return *iCommandDef; }; + + /** + * Get specific TRequestStatus variable. + */ + TRequestStatus* GetRq( TRequestType aType ); + + /** + * Get mutex handle. + * This mutex meaning is to make sure that test complete and test + * case cancel operations are not executed at the same time. + */ + TInt TestThreadMutexHandle() { return iTestThreadMutex.Handle(); }; + + const TDesC& GetConfigFileName() const { return iConfig; } + public: // Functions from base classes + // None + + protected: // New functions + // None + + protected: // Functions from base classes + // None + + private: + + /** + * C++ default constructor. + */ + CTestExecution(); + + /** + * By default Symbian OS constructor is private. + */ + void ConstructL( CTestModule* aModuleSession, + TInt aCaseNumber, + const TFileName& aConfig ); + + /** + * Cancels print request. + */ + TInt CancelPrintRequest(); + + /** + * Cancels test interference request. + */ + TInt CancelInterferenceRequest(); + + /** + * Cancels test execution request + */ + TInt CancelTestRequest(); + + /** + * Cancel event request. + */ + TInt CancelEventRequest(); + + /** + * Cancel event request. + */ + TInt CancelRemoteCmdRequest(); + + /** + * Writes a print notification to client memory space. + */ + TInt WritePrint( TTestProgress& aProgress ); + + /** + * Complete event TRequestStatus if pending. + */ + void CompleteEvent( TInt aError ); + + /** + * Handle event unsets. + */ + TInt UnsetEvent( TEventIf& aEvent, const RMessage2& aMessage ); + + /** + * Handle event request. + */ + TInt RequestEvent( TEventIf& aEvent ); + + /** + * Wait event request. + */ + TInt WaitEvent( TEventIf& aEvent, TRequestStatus* aStatus ); + + /** + * Handle event releases. + */ + TInt ReleaseEvent( TEventIf& aEvent ); + + /** + * Handle state events. + */ + TInt EventStateChange( TEventIf& aEvent ); + + /** + * Complete request in test thread. + */ + void TestThreadRequestComplete( TRequestStatus* aStatus, TInt aCode ); + + public: // Data + // None + protected: // Data + // None + + private: // Data + + // Pointers to things around + CTestModule* iModuleSession; // Session owning us + CTestModuleContainer* iModuleContainer; // Container used to execute this case + + // Test execution related members + TInt iCaseNumber; // Case to be executed + TPtr iConfig; // Configuration file name + HBufC* iConfigNameBuffer; // HBuffer for configuration file; + RMessage2 iTestExeMessage; // Test execution message + TTestState iThreadState; // Thread state + + // Print related members + RMutex iPrintMutex; // For iPrintSem semaphore handling + RSemaphore iPrintSem; // Synchonize print queue access + CPrintQueue* iPrintQueue; // Print queue + RMessage2 iNotifyPrintMessage; // Print notification message + TBool iPrintNotifyAvailable; // Is print notification available? + + // Event related members + RMessage2 iNotifyEventMessage; // Event nofitication message + TBool iEventNotifyAvailable; // Is event notification available? + RMutex iEventMutex; // For iEventSem semaphore handling + RSemaphore iEventSem; // Signal event request availability + TEventDef iEventDef; + + // Remote command protocol related stuff + RMessage2 iNotifyRemoteCmdMessage;// RemoteCmd notication message + TBool iRemoteSendAvailable; // Is RemoteSend available + RMutex iSndMutex; // For iSndSem semaphore handling + RSemaphore iSndSem; // Signal RemoteCmd request availability + TThreadId iTestThreadId; // Thread id for receiver + RThread iTestThread; + TBool iTestThreadOpen; + TBool iRemoteReceiveAvailable; // Is RemoteReceive available + RMutex iRcvMutex; // For iRcvSem semaphore handling + RSemaphore iRcvSem; // Signal RemoteCmd request availability + //RSemaphore iReceiverSem; // Signal testmodule request availability + RPointerArray iMessageQueue; + + TCmdDef iCmdDef; + TCmdDef iRcvCmdDef; + TTestProgress iProgress; + + + // Result with timestamp information + TFullTestResult iFullResult; + TInt iTestThreadFailure; + + // Event array + RPointerArray iEventArray; + // State event array + RPointerArray iStateEvents; + + // Event handlers + CPrintHandler* iPrintHandler; + CEventHandler* iEventHandler; + CSndHandler* iSndHandler; + CRcvHandler* iRcvHandler; + CInterferenceHandler* iInterferenceHandler; + CMeasurementHandler* iMeasurementHandler; + CCommandHandler* iCommandHandler; + + // Test Interface related members + RMutex iInterferenceMutex; // For iInterferenceMutex semaphore handling + RSemaphore iInterferenceSem; // Synchronize interference queue access + TBool iInterferenceNotifyAvailable; // Is interference notification + //available? + // Test measurement related members + RMutex iMeasurementMutex; // For iMeasurementMutex semaphore handling + RSemaphore iMeasurementSem; // Synchronize measurement queue access + TBool iMeasurementNotifyAvailable; // Is measurement notification + //available? + RMessage2 iNotifyInterferenceMessage; // Interference notification message + + TTestInterference iTestInterference; // Struct for information + // Array for handling test interference thread's kill in + // panic etc. cases + RArray iSTIFTestInterferenceArray; + + RMessage2 iNotifyMeasurementMessage; // Measurement notification message + + // Struct for information + TTestMeasurement iTestMeasurement; + // Array for handling measurement + RPointerArray iMeasurementHandlingArray; + + // This mutex meaning is to make sure that test complete and test + // case cancel operations are not executed at the same time. + RMutex iTestThreadMutex; + + // Command related members + CCommandDef* iCommandDef; // Command definition (content) + RMessage2 iNotifyCommandMessage; // Command nofitication message + TBool iCommandNotifyAvailable; // Is command notification available? + RMutex iCommandMutex; // For iCommandSem semaphore handling + RSemaphore iCommandSem; // Signal command request availability + + // New event system + CAsyncEventActive* iAsyncEventActive; // Active object to handle asynchronous wait. + // Only one asynchronous operation can be handled at a time, + // so if the object is created and is pending, it means + // that operation is ongoing. + // AO after completion closes connection to server and object + // can be deleted and new wait can be handled + + public: // Friend classes + // None + + protected: // Friend classes + // None + + private: // Friend classes + friend class CUnderTaker; + friend class CPrintHandler; + friend class CEventHandler; + friend class CSndHandler; + friend class CRcvHandler; + friend class TEvent; + friend class CInterferenceHandler; + friend class CMeasurementHandler; + friend class CCommandHandler; + }; + +#endif // TEST_SERVER_MODULE_IF_H + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/inc/TestThreadContainer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/inc/TestThreadContainer.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,440 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the CTestServer. +* +*/ + +#ifndef TEST_THREAD_CONTAINER_H +#define TEST_THREAD_CONTAINER_H + + +// INCLUDES +#include +#include +#include +#include +#include +#include "TestServerModuleIf.h" + +// CONSTANTS +const TInt KStifMacroMax = 128; // Maximum description length for + // STIF TF's macro cases +const TInt KStifMacroMaxFile = 50; // Maximum test result description + // length for STIF TF's macro cases +const TInt KStifMacroMaxFunction = 30; // Maximum test result description + // length for STIF TF's macro cases + +typedef TBuf TStifMacroDes; + +// MACROS + +// DATA TYPES + +// FUNCTION PROTOTYPES + +// FORWARD DECLARATIONS +class CUiEnvProxy; + +// CLASS DECLARATION + +// DESCRIPTION +// CTestThreadContainer is a class, which contains the test execution thread +// and interface functions to do operations in that thread context. +class CTestThreadContainer + :public CBase + { + + public: // Enumerations + + private: // Enumerations + enum TPanicReason + { + EUnknownEventCmd, + EInvalidCTestThreadContainer, + ECreateTrapCleanup, + ENullTestThreadContainer, + EReInitializingTestModule, + ETestModuleNotInitialized, + EInvalidTestModuleOperation, + ENullRequest, + EDuplicateFail, + EServerDied, + ENullExecution, + EThreadHandleOpenFail, + }; + + public: // Structured classes + + /** + * For STIF TF's macro information + */ + struct TTestMacro + { + TBool iIndication; + TName iFileDes; + TName iFunctionDes; + TInt iLine; + TInt iReceivedError; + }; + + + public: // Constructors and destructor + + /** + * NewL is first phase of two-phased constructor. + */ + static CTestThreadContainer* NewL( + CTestModuleContainer* aModuleContainer, + TThreadId aServerThreadId ); + + /** + * Destructor of CTestThreadContainer. + */ + virtual ~CTestThreadContainer(); + + + public: // New functions + + /** + * Test case execution thread thread function + */ + static TInt ExecutionThread( TAny* aParams ); + + /** + * UI Test case execution thread thread function + */ + static TInt UIExecutionThread( TAny* aParams ); + + /** + * Returns pointer to test cases + */ + const RPointerArray* TestCases() const; + + /** + * Completes a print request. + * This function is called from test execution thread. + */ + virtual void DoNotifyPrint( const TInt aPriority, + const TStifInfoName& aDes, + const TName& aBuffer + ); + + /** + * Enables remote command receiving. + * This function is called from test execution thread. + */ + virtual void DoRemoteReceive( TStifCommand aRemoteCommand, + TParams aParams, + TInt aLen, + TRequestStatus& aStatus ); + + /** + * Cancel remote command receiving. + * This function is called from test execution thread. + */ + virtual TInt DoRemoteReceiveCancel(); + + /** + * Completes a event request. + * This function is called from test execution thread. + */ + virtual TInt DoNotifyEvent( TEventIf& aEvent, + TRequestStatus* aStatus = NULL ); + + /** + * Cancels pending asynchronous event request. + * This function is called from test execution thread. + */ + virtual void CancelEvent( TEventIf& aEvent, + TRequestStatus* aStatus ); + + /** + * Set exit reason. + */ + virtual void SetExitReason( const CTestModuleIf::TExitReason aExitReason, + const TInt aExitCode ); + + /** + * Set test behavior. + */ + virtual TInt SetBehavior( const CTestModuleIf::TTestBehavior aType, + TAny* aPtr ); + + /** + * Get exit reason. + */ + virtual void ExitReason ( CTestModuleIf::TExitReason& aExitReason, + TInt& aExitCode ); + + /** + * STIF TF's macro. Initialized TTestMacro. + */ + virtual void StifMacroErrorInit(); + + /** + * STIF TF's(TL, T1L, T2L, etc )macro. Saves information for later use. + */ + virtual TInt StifMacroError( TInt aMacroType, + const TText8* aFile, + const char* aFunction, + TInt aLine, + TInt aResult, + TInt aExpected1, + TInt aExpected2, + TInt aExpected3, + TInt aExpected4, + TInt aExpected5 ); + + /** + * With this can be store information about test interference + * thread to client space. + */ + virtual TInt AddInterferenceThread( RThread aSTIFTestInterference ); + + /** + * With this can be remove information about test interference + * thread from client space. + */ + virtual TInt RemoveInterferenceThread( RThread aSTIFTestInterference ); + + /** + * With this can be stored information about test measurement + * to TestServer space. + */ + virtual TInt HandleMeasurementProcess( + CSTIFTestMeasurement::TStifMeasurementStruct aSTIFMeasurementInfo ); + + /** + * Completes a command request. + * This function is called from test execution thread. + */ + virtual void DoNotifyCommand(TCommand aCommand, const TDesC8& aParamsPckg); + + /** + * Obtain title of currently running test case. + */ + virtual void GetTestCaseTitleL(TDes& aTestCaseTitle); + + /** + * Sets thread logger. + */ + void SetThreadLogger( CStifLogger* aThreadLogger ); + + /** + * Gets thread logger. + */ + CStifLogger* GetThreadLogger(); + + /** + * Gets information if testserver supports UI testing. + */ + IMPORT_C TBool UITesting(); + + /** + * Gets UIEnvProxy. + */ + IMPORT_C CUiEnvProxy* GetUiEnvProxy(); + + IMPORT_C TBool SeperateProcesses(); + + public: // Functions from base classes + + protected: // New functions + + private: // New functions + + /** + * Function that initialise module in execution thread context. + */ + TInt InitializeModuleInThread( RLibrary& aModule ); + + /** + * Function that enumerates test cases in execution thread context. + */ + TInt EnumerateInThread(); + + /** + * Function that frees the enumeration data in execution thread context. + */ + void FreeEnumerationDataInThread(); + + /** + * Function that executes test case in execution thread context. + */ + TInt ExecuteTestCaseInThread(); + + + /** + * Complete testcase. + */ + void TestComplete( TInt aCompletionCode ); + + /** + * Delete a test module instance + */ + void DeleteTestModule(); + + /** + * Store TRequestStatus. + */ + void SetEventReq( TEventDef::TEventCmdType aType, + TEventIf& aEvent, + TRequestStatus* aStatus ); + + /** + * Destroys the event queue. + * This function is called from test execution thread. + */ + void DestroyEventQueue(); + + /** + * Error print. + */ + void ErrorPrint( const TInt aPriority, TPtrC aError ); + + /** + * Panicing function for test thread. + */ + static void Panic( TPanicReason aReason ); + + /** + * Check that server is alive. + */ + void IsServerAlive(); + + /** + * Exception handler + */ + static void ExceptionHandler( TExcType ); + + /** + * Modifies aRecFile and aRecFunction lenghts if nesessarily. + */ + void SetMacroInformation( TInt aFileMaxLength, + TInt aFuntionMaxLength, + const TText8* aRecFile, + const char* aRecFunction, + TDes& aFile, + TDes& aFunction ); + /** + * Duplicates mutexes + */ + TInt DuplicateMutexHandles( RThread& aThread ); + + /** + * Executes test case using OOM simulation + */ + TInt ExecuteOOMTestCase( TInt aTestCaseNumber, + TInt aFirst, + TInt aLast, + TInt& aResult, + TTestResult& caseResult ); + /** + * Leak checks for test case + */ + + void LeakChecksForTestCase( TBool aReturnLeakCheckFail, + TInt aThreadHandleCountBeforeTest, + TInt aThreadHandleCountAfterTest, + TInt aRequestCountBeforeTest, + TInt aRequestCountAfterTest ); + + protected: // Functions from base classes + // None + + private: + + /** + * By default Symbian OS constructor is private. + */ + void ConstructL( TThreadId aServerThreadId ); + + /** + * C++ default constructor. + */ + CTestThreadContainer( CTestModuleContainer* aModuleContainer ); + + /** + * Handles to parent. + */ + CTestExecution& TestExecution(); + CTestModuleContainer& ModuleContainer(); + + public: // Data + + protected: // Data + // None + + private: // Data + // Pointers to server + CTestModuleContainer* iModuleContainer; + + // Pointer to test module + CTestModuleBase* iTestModule; + + // Test cases + RPointerArray* iCases; + + // Resource checking + TUint iCheckResourceFlags; + + // Internal if none provoded from testmodule + TRequestStatus iReqStatus; + + // StifLogger used in test module thread + CStifLogger* iThreadLogger; + + // Handles to server + RThread iServerThread; + + // Mutexes, duplicated handles + RMutex iPrintMutex; // For iPrintSem semaphore handling + //RMutex iErrorPrintMutex; // For iErrorPrintSem semaphore handling + RMutex iEventMutex; // For iEventSem semaphore handling + RMutex iSndMutex; // For iSndSem semaphore handling + RMutex iRcvMutex; // For iRcvSem semaphore handling + RMutex iInterferenceMutex; // For iInterferenceSem semaphore handling + RMutex iMeasurementMutex; // For iMeasurementSem semaphore handling + RMutex iCommandMutex; // For iCommandSem semaphore handling + + // Mutex, duplicated handle. This mutex meaning is to make sure that + // test complete and test case cancel operations are not executed at + // the same time. + RMutex iTestThreadMutex; + + // Semaphores, duplicated handles + RSemaphore iPrintSem; // Signal print request availability + RSemaphore iErrorPrintSem; // Signal error request availability + RSemaphore iEventSem; // Signal event request availability + RSemaphore iSndSem; // Signal Send request availability + RSemaphore iRcvSem; // Signal Receive request availability + RSemaphore iInterferenceSem; // Synchronize test interference access + RSemaphore iMeasurementSem; // Synchronize test measurement access + RSemaphore iCommandSem; // Signal command request availability + + // Macro information + TTestMacro iTestMacroInfo; + + public: // Friend classes + + protected: // Friend classes + // None + + private: // Friend classes + friend class CTestThreadContainerRunner; + }; + +#endif // TEST_THREAD_CONTAINER_H + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/inc/version.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/inc/version.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: STIF version declaration +* +*/ + +#ifndef VERSION_H_ +#define VERSION_H_ + +#define STIF_MAJOR_VERSION 1 +#define STIF_MINOR_VERSION 0 +#define STIF_BUILD_VERSION 0 + +#define STIF_REL_DATE "1st Mar 2010" + +#define TO_UNICODE(text) _L(text) + +#endif /*VERSION_H_*/ diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/rom/STIFTestFramework.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/rom/STIFTestFramework.iby Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: STIFTestFramework.iby file specifies needed +* components for ROM image +* +*/ + +#ifndef __STIF_TEST_FRAMEWORK_IBY__ +#define __STIF_TEST_FRAMEWORK_IBY__ + + #include + +#endif +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/rom/Stif.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/rom/Stif.iby Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Stif.iby file specifies needed components for ROM image +* +*/ + +#ifndef __STIF_IBY__ +#define __STIF_IBY__ + +// TEF Test Module +#include +#include +#include +#include + +file=ABI_DIR\BUILD_DIR\stiftestengine.dll SHARED_LIB_DIR\stiftestengine.dll +file=ABI_DIR\BUILD_DIR\stftestenginesrv.exe SHARED_LIB_DIR\stftestenginesrv.exe +file=ABI_DIR\BUILD_DIR\stiftestserver.dll SHARED_LIB_DIR\stiftestserver.dll +file=ABI_DIR\BUILD_DIR\stiftestinterface.dll SHARED_LIB_DIR\stiftestinterface.dll +file=ABI_DIR\BUILD_DIR\testcombiner.dll SHARED_LIB_DIR\testcombiner.dll +file=ABI_DIR\BUILD_DIR\TestServerStarter.exe SHARED_LIB_DIR\TestServerStarter.exe +file=ABI_DIR\BUILD_DIR\demomodule.dll SHARED_LIB_DIR\demomodule.dll +file=ABI_DIR\BUILD_DIR\atslogger.dll SHARED_LIB_DIR\atslogger.dll +file=ABI_DIR\BUILD_DIR\testscripter.dll SHARED_LIB_DIR\testscripter.dll +file=ABI_DIR\BUILD_DIR\stiftfwif.dll SHARED_LIB_DIR\stiftfwif.dll +file=ABI_DIR\BUILD_DIR\suevent.dll SHARED_LIB_DIR\suevent.dll +file=ABI_DIR\BUILD_DIR\stfloggingserver.exe SHARED_LIB_DIR\stfloggingserver.exe +file=ABI_DIR\BUILD_DIR\stf.exe SHARED_LIB_DIR\stf.exe +file=ABI_DIR\BUILD_DIR\stfeventsystemsrv.exe SHARED_LIB_DIR\stfeventsystemsrv.exe +file=ABI_DIR\BUILD_DIR\stfeventsystemclient.dll SHARED_LIB_DIR\stfeventsystemclient.dll +file=ABI_DIR\BUILD_DIR\ConsoleUI.exe SHARED_LIB_DIR\ConsoleUI.exe + +data=\epoc32\data\z\system\data\TestFramework.ini testframework\TestFramework.ini + +// Touchconsoleui is a component that allows to work with touch screen devices in console mode. +// It should be use only swith environments that do not supports S60 graphical user interface +// file=ABI_DIR\BUILD_DIR\TouchConsoleUI.exe SHARED_LIB_DIR\TouchConsoleUI.exe + +#endif +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/rom/Stif_rom.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/rom/Stif_rom.iby Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Stif.iby file specifies needed components for ROM image +* +*/ + +#ifndef __STIF_ROM_IBY__ +#define __STIF_ROM_IBY__ + +#if defined(__S60_) +// For kernel testing support, uncomment the following line +device[VARID]=ABI_DIR\BUILD_DIR\StifKernelTestClassBase.dll SHARED_LIB_DIR\StifKernelTestClassBase.dll +#endif + +#endif +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/sis/stf.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/sis/stf.pkg Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,77 @@ +; +; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: Installation file for STIF UI +; + +; Languages +&EN + +; Package header, uid is the Stf's uid +#{"STF"},(0x2002BC9F),1,0,0 + +; Series60 product id for S60 3.0 +[0x101F7961], 0, 0, 0, {"Series60ProductID"} + +; Localised Vendor name +%{"Nokia"} + +; Unique Vendor name +:"Nokia" + +; Logo +; None + +; Package signature - Optional +; None + +; Start of Package body + +; Condition blocks +; None + +; Options list +; None + +; Install files + + + "\epoc32\release\armv5\urel\stiftestengine.dll"-"!:\Sys\Bin\stiftestengine.dll" + "\epoc32\release\armv5\urel\stftestenginesrv.exe"-"!:\Sys\Bin\stftestenginesrv.exe" + "\epoc32\release\armv5\urel\stiftestserver.dll"-"!:\Sys\Bin\stiftestserver.dll" + "\epoc32\release\armv5\urel\stiftestinterface.dll"-"!:\Sys\Bin\stiftestinterface.dll" + "\epoc32\release\armv5\urel\TestServerStarter.exe"-"!:\Sys\Bin\TestServerStarter.exe" + "\epoc32\release\armv5\urel\demomodule.dll"-"!:\Sys\Bin\demomodule.dll" + "\epoc32\release\armv5\urel\atslogger.dll"-"!:\Sys\Bin\atslogger.dll" + "\epoc32\release\armv5\urel\testscripter.dll"-"!:\Sys\Bin\testscripter.dll" + "\epoc32\release\armv5\urel\testcombiner.dll"-"!:\Sys\Bin\testcombiner.dll" + "\epoc32\release\armv5\urel\stiftfwif.dll"-"!:\Sys\Bin\stiftfwif.dll" + "\epoc32\release\armv5\urel\suevent.dll"-"!:\Sys\Bin\suevent.dll" + "\epoc32\release\armv5\urel\stfloggingserver.exe"-"!:\Sys\Bin\stfloggingserver.exe" + "\epoc32\release\armv5\urel\stf.exe"-"!:\Sys\Bin\stf.exe" + "\epoc32\release\armv5\urel\ConsoleUI.exe"-"!:\Sys\Bin\ConsoleUI.exe" + + "\epoc32\release\armv5\urel\stfeventsystemsrv.exe"-"!:\Sys\Bin\stfeventsystemsrv.exe" + "\epoc32\release\armv5\urel\stfeventsystemclient.dll"-"!:\Sys\Bin\stfeventsystemclient.dll" + "\epoc32\data\z\system\data\TestFramework.ini"-"c:\testframework\TestFramework.ini" + +; Embedded SIS +; None + +; End of Package body + +; PKG dependencies +; None + +; PKG capabilities +; None \ No newline at end of file diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/group/bld.inf Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +* bld.inf Toplevel build information for STF extension. +*/ + + + +// STF TestLib Plugins +#include "../testlibplugins/group/bld.inf" + +// STF Test Modules +#include "../testmodules/group/bld.inf" + + + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testlibplugins/filelibplugin/bwins/stffiletestlibpluginu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testlibplugins/filelibplugin/bwins/stffiletestlibpluginu.def Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,6 @@ +EXPORTS + ?LibEntryL@@YAPAVCStfFileTestLibPlugin@@XZ @ 1 NONAME ; class CStfFileTestLibPlugin * LibEntryL(void) + ?ExecuteCommandL@CStfFileTestLibPlugin@@UAEHABVTDesC16@@@Z @ 2 NONAME ; int CStfFileTestLibPlugin::ExecuteCommandL(class TDesC16 const &) + ?IsCommandSupported@CStfFileTestLibPlugin@@UAEHABVTDesC16@@@Z @ 3 NONAME ; int CStfFileTestLibPlugin::IsCommandSupported(class TDesC16 const &) + + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testlibplugins/filelibplugin/eabi/stffiletestlibpluginu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testlibplugins/filelibplugin/eabi/stffiletestlibpluginu.def Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,7 @@ +EXPORTS + _Z9LibEntryLv @ 1 NONAME + _ZN21CStfFileTestLibPlugin15ExecuteCommandLERK7TDesC16 @ 2 NONAME + _ZN21CStfFileTestLibPlugin18IsCommandSupportedERK7TDesC16 @ 3 NONAME + _ZTI21CStfFileTestLibPlugin @ 4 NONAME ; ## + _ZTV21CStfFileTestLibPlugin @ 5 NONAME ; ## + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testlibplugins/filelibplugin/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testlibplugins/filelibplugin/group/bld.inf Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,23 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS +../inc/stffiletestlibplugin.h +PRJ_MMPFILES +stffiletestlibplugin.mmp diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testlibplugins/filelibplugin/group/stffiletestlibplugin.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testlibplugins/filelibplugin/group/stffiletestlibplugin.mmp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include +SMPSAFE +TARGET stffiletestlibplugin.dll +TARGETTYPE dll +UID 0x1000008d 0x2002BC96 + +USERINCLUDE ..\inc + +OS_LAYER_SYSTEMINCLUDE +SOURCEPATH ..\src + +SOURCE stffiletestlibplugin.cpp + + + + +//EXPORTUNFROZEN +DEFFILE stffiletestlibplugin.def + + +LIBRARY euser.lib +LIBRARY efsrv.lib +CAPABILITY ALL -TCB + + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testlibplugins/filelibplugin/inc/stffiletestlibplugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testlibplugins/filelibplugin/inc/stffiletestlibplugin.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the CAtsLogger +* class. +* +*/ + +#ifndef __STFFILETESTLIB_H__ +#define __STFFILETESTLIB_H__ + +// Include Files + +#include // CBase +#include // TBuf +#include "StfTestLibPluginInterface.h" + + + + + +// Class Definitions + +class CStfFileTestLibPlugin : public CStfTestLibPlugin + { +public: // new functions + + ~CStfFileTestLibPlugin(); + + static CStfFileTestLibPlugin* NewL(); + + +public: + // new functions, example API + virtual TBool IsCommandSupported(const TDesC& aCommand) ; + virtual TInt ExecuteCommandL(const TDesC& aCommandLine); +private: + // new functions + CStfFileTestLibPlugin(); + void ConstructL(); + +private: + // data + + }; + + + +#endif // __STFFILETESTLIB_H__ + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testlibplugins/filelibplugin/sis/StfFileTestLib_EKA2.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testlibplugins/filelibplugin/sis/StfFileTestLib_EKA2.pkg Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,36 @@ +; +; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +; Installation file for StfFileTestLib dll +; +; This is an auto-generated PKG file by Carbide. +; This file uses variables specific to Carbide builds that will not work +; on command-line builds. If you want to use this generated PKG file from the +; command-line tools you will need to modify the variables with the appropriate +; values: $(EPOCROOT), $(PLATFORM), $(TARGET) + +; +; UID is the dll's UID +; +#{"StfFileTestLib DLL"},(0xE887D696),1,0,0 + + +;Localised Vendor name +%{"Vendor-EN"} + +;Unique Vendor name +:"Vendor" + +"$(EPOCROOT)Epoc32\release\$(PLATFORM)\$(TARGET)\StfFileTestLib.dll" -"!:\sys\bin\StfFileTestLib.dll" diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testlibplugins/filelibplugin/src/stffiletestlibplugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testlibplugins/filelibplugin/src/stffiletestlibplugin.cpp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,203 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the CAtsLogger +* class. +* +*/ + +#include "stffiletestlibplugin.h" +#include + +_LIT(KSTFRunUtilsMakeReadWrite,"MakeReadWrite"); +_LIT(KSTFRunUtilsCopyFile,"CopyFile"); +_LIT(KSTFRunUtilsMkDir,"MkDir"); +_LIT(KSTFRunUtilsDeleteFile,"DeleteFile"); +_LIT(KSTFRunUtilsDelete,"Delete"); +_LIT(KSTFRunUtilsDeleteDirectory,"DeleteDirectory"); +EXPORT_C CStfFileTestLibPlugin* LibEntryL() + { + CStfFileTestLibPlugin* self=CStfFileTestLibPlugin::NewL(); + return self; + } + + + +// Member Functions + +CStfFileTestLibPlugin* CStfFileTestLibPlugin::NewL() + { + CStfFileTestLibPlugin* self = new (ELeave) CStfFileTestLibPlugin; + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } +CStfFileTestLibPlugin::~CStfFileTestLibPlugin() + { + + } + + + + +EXPORT_C TBool CStfFileTestLibPlugin::IsCommandSupported(const TDesC& aCommand) + { + TBool result=EFalse; + if(aCommand==KSTFRunUtilsMakeReadWrite) + { + result=ETrue; + } + else if(aCommand==KSTFRunUtilsCopyFile) + { + result=ETrue; + } + else if(aCommand==KSTFRunUtilsMkDir) + { + result=ETrue; + } + else if(aCommand==KSTFRunUtilsDeleteFile) + { + result=ETrue; + } + else if(aCommand==KSTFRunUtilsDelete) + { + result=ETrue; + } + else if(aCommand==KSTFRunUtilsDeleteDirectory) + { + result=ETrue; + } + + return result; + } + +EXPORT_C TInt CStfFileTestLibPlugin::ExecuteCommandL(const TDesC& aCommandLine) + { + TInt err = 0; + _LIT(KDefault, "?:\\default"); + _LIT(KCDrive, "?:\\"); + _LIT(KSTFBackslash, "\\" ); + TBuf<10> defaultPath(KDefault); + defaultPath.Replace(0, 2, _L("c:")); + + TBuf<3> cDrive(KCDrive); + cDrive.Replace(0, 2, _L("c:")); + + RFs fS; + User::LeaveIfError(fS.Connect() ); + CleanupClosePushL(fS); + + TLex lex(aCommandLine); + // lex.NextToken(); + TPtrC token(lex.NextToken()); + if(token.CompareF(KSTFRunUtilsCopyFile) == 0) + { + TPtrC file1=lex.NextToken(); + TPtrC file2=lex.NextToken(); + TParse source, dest; + CFileMan* fMan = CFileMan::NewL(fS); + CleanupStack::PushL(fMan); + User::LeaveIfError(source.Set(file1, &defaultPath, NULL) ); + User::LeaveIfError(dest.Set(file2, &defaultPath, NULL) ); + TPtrC sourcefile=source.FullName(); + TPtrC destfile=dest.FullName(); + err=fMan->Copy(file1, file2, CFileMan::EOverWrite); + User::LeaveIfError(err); + CleanupStack::PopAndDestroy(fMan); + } + else if(token.CompareF(KSTFRunUtilsMkDir) == 0) + { + token.Set(lex.NextToken()); + TParse fileName; + + if (!token.Length()) + User::Leave(KErrPathNotFound); + + TPtrC lastChar(token.Mid(token.Length() - 1)); + if ( lastChar.CompareF(KSTFBackslash) != 0 ) + { + TBuf<64> tempToken(token); + tempToken.Append(KSTFBackslash); + token.Set(tempToken); + } + + User::LeaveIfError( fileName.Set(token, &cDrive, NULL) ); + err=fS.MkDir( fileName.DriveAndPath() ); + User::LeaveIfError( err ); + } + else if(token.CompareF(KSTFRunUtilsDeleteFile) == 0 || + token.CompareF(KSTFRunUtilsDelete) == 0) + { + token.Set(lex.NextToken()); + + CFileMan* fMan = CFileMan::NewL(fS); + CleanupStack::PushL(fMan); + err=fMan->Delete(token); + User::LeaveIfError(err ); + CleanupStack::PopAndDestroy(fMan); + } + else if(token.CompareF(KSTFRunUtilsMakeReadWrite) == 0) + { + token.Set(lex.NextToken()); + TParse fileName; + User::LeaveIfError(fileName.Set(token, &defaultPath, NULL) ); + err = fS.SetAtt(fileName.FullName(),0, KEntryAttReadOnly); + if (err != KErrNone && err != KErrNotFound) + User::Leave(err); + } + //It deletes the specified directory + else if(token.CompareF(KSTFRunUtilsDeleteDirectory) == 0) + { + token.Set(lex.NextToken()); + TParse fileName; + + if (!token.Length()) + User::Leave(KErrPathNotFound); + + TPtrC lastChar(token.Mid(token.Length() - 1)); + if ( lastChar.CompareF(KSTFBackslash) != 0 ) + { + TBuf<64> tempToken(token); + tempToken.Append(KSTFBackslash); + token.Set(tempToken); + } + + CFileMan* fMan = CFileMan::NewL(fS); + CleanupStack::PushL(fMan); + + User::LeaveIfError(fileName.Set(token, &cDrive, NULL) ); + err=fMan->RmDir( fileName.DriveAndPath() ); + User::LeaveIfError(err ); + + CleanupStack::PopAndDestroy(fMan); + } + + fS.Close(); + CleanupStack::Pop(&fS); + return err; + } + +CStfFileTestLibPlugin::CStfFileTestLibPlugin() +// note, CBase initialises all member variables to zero + { + } + +void CStfFileTestLibPlugin::ConstructL() + { + // second phase constructor, anything that may leave must be constructed here + + } + + + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testlibplugins/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testlibplugins/group/bld.inf Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +* bld.inf Toplevel build information for STF testlib plugins. +*/ + +#include "../filelibplugin/group/bld.inf" +#include "../syslibplugin/group/bld.inf" + + + + +PRJ_EXPORTS +../inc/StfTestLibPluginInterface.h \ No newline at end of file diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testlibplugins/inc/StfTestLibPluginInterface.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testlibplugins/inc/StfTestLibPluginInterface.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +/* + * StfTestLibPluginInterface.h + * + * Created on: Nov 10, 2009 + * Author: h112wang + */ + +#ifndef STFTESTLIBPLUGININTERFACE_H_ +#define STFTESTLIBPLUGININTERFACE_H_ + +class CStfTestLibPlugin : public CBase { +public: + + + /** + * Result indicates eiterh plug-in is able to process command + * @param aCommand command to check + */ + virtual TBool IsCommandSupported(const TDesC& aCommand) = 0; + + /** + * Execution of the specified library command + * implementation of , should return ASAP. + * aMessage contan is service specific. + * it will return KErrNone for successfully execution + * otherwise, it will return the error code + * @param aCommandLine command to execute + + */ + virtual TInt ExecuteCommandL(const TDesC& aCommandLine) = 0; + }; + + + + +#endif /* STFTESTLIBPLUGININTERFACE_H_ */ diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testlibplugins/syslibplugin/bwins/stfsystemtestlibplugin.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testlibplugins/syslibplugin/bwins/stfsystemtestlibplugin.def Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,6 @@ +EXPORTS + ?LibEntryL@@YAPAVCstfsystemtestlibplugin@@XZ @ 1 NONAME ; class Cstfsystemtestlibplugin * LibEntryL(void) + ?ExecuteCommandL@Cstfsystemtestlibplugin@@UAEHABVTDesC16@@@Z @ 2 NONAME ; int Cstfsystemtestlibplugin::ExecuteCommandL(class TDesC16 const &) + ?IsCommandSupported@Cstfsystemtestlibplugin@@UAEHABVTDesC16@@@Z @ 3 NONAME ; int Cstfsystemtestlibplugin::IsCommandSupported(class TDesC16 const &) + + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testlibplugins/syslibplugin/eabi/stfsystemtestlibplugin.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testlibplugins/syslibplugin/eabi/stfsystemtestlibplugin.def Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,9 @@ +EXPORTS + _Z9LibEntryLv @ 1 NONAME + _ZN23Cstfsystemtestlibplugin15ExecuteCommandLERK7TDesC16 @ 2 NONAME + _ZN23Cstfsystemtestlibplugin18IsCommandSupportedERK7TDesC16 @ 3 NONAME + _ZTI23Cstfsystemtestlibplugin @ 4 NONAME ; ## + _ZTV23Cstfsystemtestlibplugin @ 5 NONAME ; ## + _ZTI26CTestSecurityInstUIHandler @ 6 NONAME ; ## + _ZTV26CTestSecurityInstUIHandler @ 7 NONAME ; ## + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testlibplugins/syslibplugin/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testlibplugins/syslibplugin/group/bld.inf Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS +..\inc\stfsystemtestlibplugin.h + +PRJ_MMPFILES +stfsystemtestlibplugin.mmp diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testlibplugins/syslibplugin/group/stfsystemtestlibplugin.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testlibplugins/syslibplugin/group/stfsystemtestlibplugin.mmp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: MMP file for STIF Test Framework's remote events module. +* +*/ + + +#include + +SMPSAFE +TARGET stfsystemtestlibplugin.dll +TARGETTYPE dll +UID 0x1000008d 0x2002BC97 + +MW_LAYER_SYSTEMINCLUDE + +USERINCLUDE ..\inc +SYSTEMINCLUDE \epoc32\include +SYSTEMINCLUDE \epoc32\include\swi +SYSTEMINCLUDE \epoc32\include\platform\mw\swi +SOURCEPATH ..\src + +SOURCE stfsystemtestlibplugin.cpp +SOURCE AppInstall.cpp TestSecurityInstUIHandler.cpp + +// In order to use .def files to freeze code you must use one or more DEFFILE lines; +// see the ones commented out below for examples. +// By default, the build tools look for the WINSCW def file in a BWINS directory +// (at the same level as the directory containing the mmp file), +// the GCC ARM def file in a BMARM directory, and the ARMV5 def file in a EABI directory. +// If your .def files are stored in these default locations, you can simply specify the +// .def filename(s) with no path. If you want to store .def files in non-default +// locations, you will need to specify the paths in the DEFFILE statement(s). + +//The following commented out code shows how the build system uses the implicit +// location for defiles. To create the DEF files Choose Project > Freeze Exports from Carbide +// or run 'abld freeze' from the command-line +//#if defined (WINS) +// DEFFILE ..\bwins\stfsystemtestlibplugin.def +//#elif defined (GCC32) +// DEFFILE ..\bmarm\stfsystemtestlibplugin.def +//#else +// DEFFILE ..\eabi\stfsystemtestlibplugin.def +//#endif + +nostrictdef + +LIBRARY euser.lib +LIBRARY sishelper.lib + +CAPABILITY ALL -TCB + +DEFFILE stfsystemtestlibplugin.def +#ifdef ENABLE_ABIV2_MODE +DEBUGGABLE_UDEBONLY +#endif + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testlibplugins/syslibplugin/inc/AppInstall.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testlibplugins/syslibplugin/inc/AppInstall.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the CAtsLogger +* class. +* +*/ + +#if (!defined __TEST_SECURITY_APPINSTALL_H__) +#define __TEST_SECURITY_APPINSTALL_H__ + + +class CAppInstall + +{ +public: + CAppInstall(); + + static TInt Install(const TDesC&); + static TInt Uninstall(const TDesC&); + +protected: + +private: +}; + +#endif // __TEST_SECURITY_APPINSTALL_H__ diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testlibplugins/syslibplugin/inc/TestSecurityInstUIHandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testlibplugins/syslibplugin/inc/TestSecurityInstUIHandler.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,340 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the CAtsLogger +* class. +* +*/ +#include + +/*@{*/ +///Macros +#define KUserNameMaxLength 64 +#define KPassword 64 +/*@}*/ + +enum KMyErrCode + { + KErrNothing, + KErrLanguage, + KErrDrive, + KErrOptions, + KErrAbortInstall, + KErrAbortUnInstall, + KErrLeave, + KErrCannotOverwriteFile, + KErrError + }; + +/** +This represents the User Interface handler for the install engine +The higher code should provide one of these interfaces for the engine +to use for a UI. + +@publishedPartner +@released +*/ +using namespace Swi; + +class CTestSecurityInstUIHandler : public CBase, public Swi::MUiHandler +// This represents the User Interface handler for the install engine +// The higher code should provide one of these interfaces for the engine +// to use for a UI + { + public: + static CTestSecurityInstUIHandler* NewL(); + + ~CTestSecurityInstUIHandler(); + + /** + * Displays a dialog at the beginning of an installation with details about the SISX package + * being installed. This dialog must be shown in TrustedUI mode. + * + * @param aAppInfo Information about the application. + * @param aLogo The logo data in the SISX file. If no logo is present it will be NULL. + * @param aCertificates An array of end entity certificates, one for each chain in the SISX file. + * If the SISX file is unsigned this array will have zero length. + * + * @note Trusted UI + * + * @return ETrue if the user pressed the Yes button to continue the install, + * EFalse if the user pressed the No button, aborting the installation. + */ + TBool DisplayInstallL (const CAppInfo& aAppInfo, + const CApaMaskedBitmap* aLogo, + const RPointerArray & aCertificates); + /** + * Displays a dialog requesting that the user grants these capabilities to the SISX package + * being installed. This dialog must be shown in TrustedUI mode. + * + * @param aAppInfo Information about the application. + * @param aCapabilitySet The capabilities requested by the SISX package. + * + * @note Trusted UI + * + * @return ETrue to continue the installation, or EFalse to abort the installation. + */ + TBool DisplayGrantCapabilitiesL(const CAppInfo& aAppInfo, + const TCapabilitySet& aCapabilitySet); + + /** + * Requests preferred language and dialect information from the UI. + * + * @param aAppInfo Information about the application. + * @param aLanguages Array of languages supported by the SIS file. + * + * @return Must return index in the passed array that corresponds to the user's selected + * preferred language. If out-of-bounds value is returned, the engine will abort + * installation. + */ + TInt DisplayLanguageL(const CAppInfo& aAppInfo, + const RArray& aLanguages); + + /** + * Requests the drive to install the package on, from the UI. + * + * @param aAppInfo Information about the application. + * @param aSize Total size of the files that will be installed on the configurable drive. + * @param aDriveLetters Array of drive letters on which the package can be installed. + * @param aDriveSpaces Array of space free (in bytes) on each of the drives in the aDriveLetters array. + * + * @return An index in the drive array. If the index is out of range the engine will abort + * the installation. + */ + TInt DisplayDriveL(const CAppInfo& aAppInfo, + TInt64 aSize, + const RArray& aDriveLetters, + const RArray& aDriveSpaces); + + /** + * Displays a dialog asking whether we want to upgrade an application present on the device. + * + * @param aAppInfo Information about the application being installed. + * @param aExistingAppInfo Information about the existing application. + * + * @return ETrue if the user pressed the Yes button, + * EFalse if the user pressed the No button. + */ + TBool DisplayUpgradeL(const CAppInfo& aAppInfo, + const CAppInfo& aExistingAppInfo); + + /** + * Displays a dialog box asking which options the user wishes to install. + * + * @param aAppInfo Information about the application. + * @param aOptions An array of option names. + * @param aSelections An array of booleans, corresponding to the aOptions array. + * + * @return ETrue on success, EFalse on error. + */ + TBool DisplayOptionsL(const CAppInfo& aAppInfo, + const RPointerArray& aOptions, + RArray& aSelections); + + /** + * Informs the UI of events occurring during installation. + * + * @param aEvent The event which has occurred. + * @param aValue The value associated with the event if applicable. + * @param aDes A descriptor associated with the event if applicable. + */ + TBool HandleInstallEventL(const CAppInfo& aAppInfo, + TInstallEvent aEvent, + TInt aValue=0, + const TDesC& aDes=KNullDesC); + /** + * Informs the UI of cancellable events occurring during installation. + * + * @param aEvent The event which has occurred. + * @param aCancelHandler This mix-in is used to inform Software Install that the user has + * pressed the cancel button on the dialog. + * @param aValue The value associated with the event if applicable. + * @param aDes A descriptor associated with the event if applicable. + */ + void HandleCancellableInstallEventL(const CAppInfo& aAppInfo, + TInstallCancellableEvent aEvent, + MCancelHandler& aCancelHandler, + TInt aValue=0, + const TDesC& aDes=KNullDesC); + /** + * Displays a dialog indicating that the package is unsigned, or that signature validation has failed. + * + * @param aAppInfo Information about the application. + * @param aSigValidationResult The result of signature validation. + * @param aPkixResult Results of a validation of the PKIX certificate chain. + * Note that is can be NULL, in this case no validation results are available. + * @param aCertificates An array containing information about the certificates in the chain. + * @param aInstallAnyway ETrue if installation is allowed to continue. + * + * @return ETrue to continue the installation, EFalse to abort. + */ + TBool DisplaySecurityWarningL(const CAppInfo& aAppInfo, + Swi::TSignatureValidationResult aSigValidationResult, + RPointerArray& aPkixResults, + RPointerArray& aCertificates, + TBool aInstallAnyway); + + /** + * Displays a dialog indicating that there was an error carrying out online certificate status checking. + * + * @param aMessage The error which occurred during online certificate status checking + * @param aOutcome The outcome of the OCSP check. If no outcome can be given, it will be NULL. + * @param aWarningOnly ETrue if the installation is allowed to continue after a warning, EFalse otherwise. + * + * @return ETrue on success, EFalse on error. + */ + TBool DisplayOcspResultL(const CAppInfo& aAppInfo, + TRevocationDialogMessage aMessage, + RPointerArray& aOutcomes, + RPointerArray& aCertificates, + TBool aWarningOnly); + + /** + * Used to inform the user the installation they are attempting is trying to overwrite + * a file that does not belong to it. Following this message installation is aborted. + * + * @param aAppInfo Information about the application. + * @param aInstalledAppInfo Information about the application that owns the file in question. + * @param aFileName The filename of the file in question + */ + void DisplayCannotOverwriteFileL(const CAppInfo& aAppInfo, + const CAppInfo& aInstalledAppInfo, + const TDesC& aFileName); + + /** + * Displays a dialog at the start of the uninstallation with information about the application + * to be uninstalled. The user may cancel the uninstallation at this stage. This dialog must + * be shown in TrustedUI mode. + * + * @param aAppInfo Information about the application. + * + * @note Trusted UI + * + * @return ETrue to continue the uninstallation, or EFalse to abort the uninstallation. + */ + TBool DisplayUninstallL(const CAppInfo& aAppInfo); + + + /** + * Displays a dialog containing text. This dialog has only a Continue button if aOption is + * EInstFileTextOptionContinue, or Yes and No buttons otherwise. + * + * @param aAppInfo Information about the application. + * @param aOption The type of dialog box to display. + * @param aText The text to display + * + * @return ETrue is the user wants to go forward, EFalse otherwise. + */ + TBool DisplayTextL(const CAppInfo& aAppInfo, + TFileTextOption aOption, + const TDesC& aText); + + /** + * Displays a dialog showing an error message. + * + * @param aAppInfo Information about the application. + * @param aType The error message to display. + * @param aParam An error specific parameter. + */ + void DisplayErrorL(const CAppInfo& aAppInfo, + TErrorDialog aType, + const TDesC& aParam); + + /** + * Displays a dialog indicating that a component which is being uninstalled is a dependency + * of another component installed. + * + * @param aAppInfo Information about the application. + * @param aComponents An array of components which depend on components of the application + * + * @return ETrue to continue the uninstallation, EFalse to abort. + */ + TBool DisplayDependencyBreakL(const CAppInfo& aAppInfo, + const RPointerArray& aComponents); + + /** + * Informs user that the applications are in use during an uninstallation. + * Return ETrue if the user wishes to continue the removal process and + * close the applications anyway + * + * @param aAppNames An array containing the name of the application in use. + * + * @return ETrue if the user wishes to continue with removal. + */ + TBool DisplayApplicationsInUseL(const CAppInfo& aAppInfo, const RPointerArray& aAppNames); + + /** + * Displays a generic question dialog with a Yes/No answer. + * + * @param aAppInfo Information about the application. + * @param aQuestion The question to ask. + * @param aDes A descriptor associated with the question if applicable. + * + * @return ETrue if the user pressed the Yes button, + * EFalse if the user pressed the No button. + */ + TBool DisplayQuestionL(const CAppInfo& aAppInfo, TQuestionDialog aQuestion, const TDesC& aDes=KNullDesC); + + /** + * Used to inform the user of a missing dependency needed to install the + * current package. It is up to the UI implementors and/or the user whether + * or not this warning can be overridden. + * + * @param aAppInfo Info about the current application. + * @param aDependencyName Name of the missing dependency. + * @param aWantedVersionFrom Starting suitable version number of the mising + * dependency. Can be all zeros, meaning it is + * unknown. + * @param aWantedVersionFrom Ending suitable version number of the mising + * dependency. Can be all zeros, meaning it is + * unknown. + * @param aInstalledVersion The installed (unsuitable) version of the + * missing dependency. Can be all zeros, meaning + * the missing dependency is not installed. + * + * @return \e ETrue to continue installation, \e EFalse to abort. + */ + TBool DisplayMissingDependencyL( + const CAppInfo& aAppInfo, + const TDesC& aDependencyName, + TVersion aWantedVersionFrom, + TVersion aWantedVersionTo, + TVersion aInstalledVersion); + + + + + TBool iDispInstall; + TBool iDispGrantCapabilities; + TBool iDispUnInstall; + TInt iDispLanguage; + TInt iDispDialect; + TChar iDispDrive; + TBool iDispUpgrade; + TBool iDispDependencyBreak; + TBool iDispQuestion; + TBool iDispSecurityWarning; + TBool iDispRevocationQuery; + TBool iDispApplicationInUse; + TBool iDispTextDialog; + TInt iDispOptions; + TInt iAppUID; + + KMyErrCode iErrCode; + + private: + CTestSecurityInstUIHandler(); + void ConstructL(); + }; + + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testlibplugins/syslibplugin/inc/stfsystemtestlibplugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testlibplugins/syslibplugin/inc/stfsystemtestlibplugin.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the CAtsLogger +* class. +* +*/ + +// This file defines the API for stfsystemtestlibplugin.dll + +#ifndef __STFSYSTEMTESTLIBPLUGIN_H__ +#define __STFSYSTEMTESTLIBPLUGIN_H__ + +// Include Files + +#include // CBase +#include // TBuf +#include "StfTestLibPluginInterface.h" +// Constants + +const TInt KstfsystemtestlibpluginBufferLength = 15; +typedef TBuf + TstfsystemtestlibpluginExampleString; + +// Class Definitions + +class Cstfsystemtestlibplugin : public CStfTestLibPlugin + { +public: + // new functions + static Cstfsystemtestlibplugin* NewL(); + ~Cstfsystemtestlibplugin(); + +public: + // new functions, example API + virtual TBool IsCommandSupported(const TDesC& aCommand) ; + virtual TInt ExecuteCommandL(const TDesC& aCommandLine); + +private: + // new functions + Cstfsystemtestlibplugin(); + void ConstructL(); + +private: + + }; + +#endif // __STFSYSTEMTESTLIBPLUGIN_H__ + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testlibplugins/syslibplugin/inc/stfsystemtestlibplugin.pan --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testlibplugins/syslibplugin/inc/stfsystemtestlibplugin.pan Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the CAtsLogger +* class. +* +*/ + +#ifndef __STFSYSTEMTESTLIBPLUGIN_PAN__ +#define __STFSYSTEMTESTLIBPLUGIN_PAN__ + +// Data Types + +enum TstfsystemtestlibpluginPanic + { + EstfsystemtestlibpluginNullPointer + }; + +// Function Prototypes + +GLREF_C void Panic(TstfsystemtestlibpluginPanic aPanic); + +#endif // __STFSYSTEMTESTLIBPLUGIN_PAN__ + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testlibplugins/syslibplugin/sis/stfsystemtestlibplugin_EKA2.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testlibplugins/syslibplugin/sis/stfsystemtestlibplugin_EKA2.pkg Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,36 @@ +; +; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +; Installation file for stfsystemtestlibplugin dll +; +; This is an auto-generated PKG file by Carbide. +; This file uses variables specific to Carbide builds that will not work +; on command-line builds. If you want to use this generated PKG file from the +; command-line tools you will need to modify the variables with the appropriate +; values: $(EPOCROOT), $(PLATFORM), $(TARGET) + +; +; UID is the dll's UID +; +#{"stfsystemtestlibplugin DLL"},(0xED788704),1,0,0 + + +;Localised Vendor name +%{"Vendor-EN"} + +;Unique Vendor name +:"Vendor" + +"$(EPOCROOT)Epoc32\release\$(PLATFORM)\$(TARGET)\stfsystemtestlibplugin.dll" -"!:\sys\bin\stfsystemtestlibplugin.dll" diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testlibplugins/syslibplugin/src/AppInstall.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testlibplugins/syslibplugin/src/AppInstall.cpp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the CAtsLogger +* class. +* +*/ +#include +#include +#include + + +// Epoc Includes +#include + + +#include "appinstall.h" +#include "testsecurityinstuihandler.h" + + +CAppInstall::CAppInstall() + { + } + +TInt CAppInstall::Install(const TDesC& aFileName) + { + + TInt error = KErrNone; + + TFileName fileName(aFileName); + + fileName.PtrZ(); + + Swi::CInstallPrefs* iInstallPrefs = Swi::CInstallPrefs::NewL(); + + CTestSecurityInstUIHandler* iUIHandler = CTestSecurityInstUIHandler::NewL(); + + error = Swi::Launcher::Install(*iUIHandler,fileName,*iInstallPrefs); + + delete iUIHandler; + delete iInstallPrefs; + + return error; + + } + +TInt CAppInstall::Uninstall(const TDesC& aUid) + { + + TInt error = KErrNone; + + TLex conv(aUid); + + TUint32 id; + + error = conv.Val(id,EHex); + + if(error!=KErrNone) + { + return error; + } + + TUid uid = TUid::Uid(id); + + + CTestSecurityInstUIHandler* iUIHandler = CTestSecurityInstUIHandler::NewL(); + + error = Swi::Launcher::Uninstall(*iUIHandler, uid); + + delete iUIHandler; + + return error; + + } + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testlibplugins/syslibplugin/src/TestSecurityInstUIHandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testlibplugins/syslibplugin/src/TestSecurityInstUIHandler.cpp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,484 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the CAtsLogger +* class. +* +*/ +#include "TestSecurityInstUIHandler.h" + +/** + * Creates a new Instance of the CTestSecurityInstUIHandler and calls the + * appropriate ConsturctL + * @param None + * @return CTestSecurityInstUIHandler* + * + */ +CTestSecurityInstUIHandler* CTestSecurityInstUIHandler::NewL() + { + CTestSecurityInstUIHandler* self=new(ELeave) CTestSecurityInstUIHandler(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +/** + * Constructor for CTestSecurityInstUIHandler + */ +CTestSecurityInstUIHandler::CTestSecurityInstUIHandler() +: iDispInstall(TRUE), + iDispGrantCapabilities(TRUE), + iDispUnInstall(TRUE), + iDispLanguage(0), + iDispDialect(0), + iDispDrive('C'), + iDispUpgrade(TRUE), + iDispDependencyBreak(TRUE), + iDispQuestion(TRUE), + iDispSecurityWarning(TRUE), + iDispRevocationQuery(TRUE), + iDispApplicationInUse(TRUE), + iDispTextDialog(TRUE), + iDispOptions(0), + iAppUID(0), + iErrCode(KErrNothing) + { + } + +/** + * Second stage constructor for CTestSecurityInstUIHandler + */ +void CTestSecurityInstUIHandler::ConstructL() + { + } + +/** + * Destructor for CTestSecurityInstUIHandler + */ +CTestSecurityInstUIHandler::~CTestSecurityInstUIHandler() + { + iDispInstall = FALSE; + iDispGrantCapabilities = FALSE; + iDispUnInstall = FALSE; + iDispLanguage = 0; + iDispDialect = 0; + iDispDrive = 'C'; + iDispUpgrade = FALSE; + iDispDependencyBreak = FALSE; + iDispQuestion = FALSE; + iDispSecurityWarning = FALSE; + iDispRevocationQuery = FALSE; + iDispApplicationInUse = FALSE; + iDispTextDialog = FALSE; + iDispOptions = 0; + iAppUID = 0; + + iErrCode = KErrNothing; + } + +/** + * Displays a dialog at the beginning of an installation with details about the SISX package + * being installed. This dialog must be shown in TrustedUI mode. + * + * @param aAppInfo Information about the application. + * @param aLogo The logo data in the SISX file. If no logo is present it will be NULL. + * @param aCertificates An array of end entity certificates, one for each chain in the SISX file. + * If the SISX file is unsigned this array will have zero length. + * + * @note Trusted UI + * + * @return ETrue if the user pressed the Yes button to continue the install, + * EFalse if the user pressed the No button, aborting the installation. + */ +TBool CTestSecurityInstUIHandler::DisplayInstallL(const CAppInfo& /*aAppInfo*/, + const CApaMaskedBitmap* /*aLogo*/, + const RPointerArray< CCertificateInfo >& /*aCertificates*/) + { + return iDispInstall; + } + +/** + * Displays a dialog requesting that the user grants these capabilities to the SISX package + * being installed. This dialog must be shown in TrustedUI mode. + * + * @param aAppInfo Information about the application. + * @param aCapabilitySet The capabilities requested by the SISX package. + * + * @note Trusted UI + * + * @return ETrue to continue the installation, or EFalse to abort the installation. + */ +TBool CTestSecurityInstUIHandler::DisplayGrantCapabilitiesL(const CAppInfo& /*aAppInfo*/, + const TCapabilitySet& /*aCapabilitySet*/) + { + return iDispGrantCapabilities; + } + +/** + * Requests preferred language and dialect information from the UI. + * + * @param aAppInfo Information about the application. + * @param aLanguages Array of languages supported by the SIS file. + * + * @return Must return index in the passed array that corresponds to the user's selected + * preferred language. If out-of-bounds value is returned, the engine will abort + * installation. + */ +TInt CTestSecurityInstUIHandler::DisplayLanguageL(const CAppInfo& /*aAppInfo*/, + const RArray& aLanguages) + { + TInt languageCode = iDispLanguage; + TInt index; + + // Return the index value in the array which matches the language code + // obtained from the ini file. + for (index=0; index& aDriveLetters, + const RArray& /*aDriveSpaces*/) + { + TInt index; + TInt driveIndex=0; + for (index=0; index < aDriveLetters.Count(); index++) + { + if (aDriveLetters[index] == iDispDrive) + { + driveIndex = index; + break; + } + } + + if (index == aDriveLetters.Count()) // Out of range error + { + iErrCode = KErrDrive; + driveIndex = index; + } + return driveIndex; + } + +/** + * Displays a dialog asking whether we want to upgrade an application present on the device. + * + * @param aAppInfo Information about the application being installed. + * @param aExistingAppInfo Information about the existing application. + * + * @return ETrue if the user pressed the Yes button, + * EFalse if the user pressed the No button. + */ +TBool CTestSecurityInstUIHandler::DisplayUpgradeL(const CAppInfo& /*aAppInfo*/, + const CAppInfo& /*aExistingAppInfo*/) + { + return iDispUpgrade; + } + +/** + * Displays a dialog box asking which options the user wishes to install. + * + * @param aAppInfo Information about the application. + * @param aOptions An array of option names. + * @param aSelections An array of booleans, corresponding to the aOptions array. + * + * @return ETrue on success, EFalse on error. + */ +TBool CTestSecurityInstUIHandler::DisplayOptionsL(const CAppInfo& /*aAppInfo*/, + const RPointerArray& aOptions, + RArray& aSelections) + { + + TInt index; + TBool setFlag = EFalse; + + for (index=0; index& /*aPkixResults*/, + RPointerArray& /*aCertificates*/, + TBool /*aInstallAnyway*/) + { + return ETrue; + } + +/** + * Displays a dialog indicating that there was an error carrying out online certificate status checking. + * + * @param aMessage The error which occurred during online certificate status checking + * @param aOutcome The outcome of the OCSP check. If no outcome can be given, it will be NULL. + * @param aWarningOnly ETrue if the installation is allowed to continue after a warning, EFalse otherwise. + * + * @return ETrue on success, EFalse on error. + */ +TBool CTestSecurityInstUIHandler::DisplayOcspResultL(const CAppInfo& /*aAppInfo*/, + TRevocationDialogMessage /*aMessage*/, + RPointerArray& /*aOutcomes*/, + RPointerArray& /*aCertificates*/, + TBool aWarningOnly) + { + return aWarningOnly; + } + +/** + * Used to inform the user the installation they are attempting is trying to overwrite + * a file that does not belong to it. Following this message installation is aborted. + * + * @param aAppInfo Information about the application. + * @param aInstalledAppInfo Information about the application that owns the file in question. + * @param aFileName The filename of the file in question + */ +void CTestSecurityInstUIHandler::DisplayCannotOverwriteFileL(const CAppInfo& /*aAppInfo*/, + const CAppInfo& /*aInstalledAppInfo*/, + const TDesC& /*aFileName*/) + { + iErrCode = KErrCannotOverwriteFile; + } + +/** + * Displays a dialog at the start of the uninstallation with information about the application + * to be uninstalled. The user may cancel the uninstallation at this stage. This dialog must + * be shown in TrustedUI mode. + * + * @param aAppInfo Information about the application. + * + * @note Trusted UI + * + * @return ETrue to continue the uninstallation, or EFalse to abort the uninstallation. + */ +TBool CTestSecurityInstUIHandler::DisplayUninstallL(const CAppInfo& /*aAppInfo*/) + { + return iDispUnInstall; + } + +/** + * Displays a dialog containing text. This dialog has only a Continue button if aOption is + * EInstFileTextOptionContinue, or Yes and No buttons otherwise. + * + * @param aAppInfo Information about the application. + * @param aOption The type of dialog box to display. + * @param aText The text to display + * + * @return ETrue if the user wants to go forward, EFalse otherwise. + */ +TBool CTestSecurityInstUIHandler::DisplayTextL(const CAppInfo& /*aAppInfo*/, + TFileTextOption /*aOption*/, + const TDesC& /*aText*/) + { + return iDispTextDialog; + } + +/** + * Displays a dialog showing an error message. + * + * @param aAppInfo Information about the application. + * @param aType The error message to display. + * @param aParam An error specific parameter. + */ +void CTestSecurityInstUIHandler::DisplayErrorL(const CAppInfo& /*aAppInfo*/, + TErrorDialog /*aType*/, + const TDesC& /*aParam*/) + { + iErrCode = KErrError; + } + +/** + * Displays a dialog indicating that a component which is being uninstalled is a dependency + * of another component installed. + * + * @param aAppInfo Information about the application. + * @param aComponents An array of components which depend on components of the application + * + * @return ETrue to continue the uninstallation, EFalse to abort. + */ +TBool CTestSecurityInstUIHandler::DisplayDependencyBreakL(const CAppInfo& /*aAppInfo*/, + const RPointerArray& /*aComponents*/) + { + return iDispDependencyBreak; + } + +/** + * Informs user that the applications are in use during an uninstallation. + * Return ETrue if the user wishes to continue the removal process and + * close the applications anyway + * + * @param aAppNames An array containing the name of the application in use. + * + * @return ETrue if the user wishes to continue with removal. + */ +TBool CTestSecurityInstUIHandler::DisplayApplicationsInUseL(const CAppInfo& /*aAppInfo*/, + const RPointerArray& /*aAppNames*/) + { + return iDispApplicationInUse; + } + +/** + * Displays a generic question dialog with a Yes/No answer. + * + * @param aAppInfo Information about the application. + * @param aQuestion The question to ask. + * @param aDes A descriptor associated with the question if applicable. + * + * @return ETrue if the user pressed the Yes button, + * EFalse if the user pressed the No button. + */ +TBool CTestSecurityInstUIHandler::DisplayQuestionL(const CAppInfo& /*aAppInfo*/, + TQuestionDialog aQuestion, const TDesC& /*aDes=KNullDesC*/) + { + + switch(aQuestion) + { + case EQuestionIncompatible: + break; + default: + break; + } + + return iDispQuestion; + } + +TBool CTestSecurityInstUIHandler::DisplayMissingDependencyL(const CAppInfo& /*aAppInfo*/, + const TDesC& /*aDependencyName*/,TVersion /*aWantedVersionFrom*/, + TVersion /*aWantedVersionTo*/,TVersion /*aInstalledVersion*/) + { + return ETrue; + } + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testlibplugins/syslibplugin/src/stfsystemtestlibplugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testlibplugins/syslibplugin/src/stfsystemtestlibplugin.cpp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,156 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the header file of the CAtsLogger +* class. +* +*/ + +// Include Files + +#include "stfsystemtestlibplugin.h" // Cstfsystemtestlibplugin +#include "stfsystemtestlibplugin.pan" // panic codes +#include "AppInstall.h" +_LIT(KSTFRunProgram,"RUN_PROGRAM"); +_LIT(KSTFKillProgram,"KILL_PROGRAM"); +_LIT(KSTFInstallSIS,"InstallSis"); +_LIT(KSTFUnInstallSIS,"UnInstallSis"); +// Member Functions + +EXPORT_C Cstfsystemtestlibplugin* LibEntryL() + { + Cstfsystemtestlibplugin* self=Cstfsystemtestlibplugin::NewL(); + return self; + } + +Cstfsystemtestlibplugin* Cstfsystemtestlibplugin::NewL() + { + Cstfsystemtestlibplugin* self = new (ELeave) Cstfsystemtestlibplugin; + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +Cstfsystemtestlibplugin::Cstfsystemtestlibplugin() +// note, CBase initialises all member variables to zero + { + } + +void Cstfsystemtestlibplugin::ConstructL() + { + } + +Cstfsystemtestlibplugin::~Cstfsystemtestlibplugin() + { + + } + + + +EXPORT_C TBool Cstfsystemtestlibplugin::IsCommandSupported(const TDesC& aCommand) + { + TBool result=EFalse; + if(aCommand==KSTFRunProgram) + { + result=ETrue; + } + else if(aCommand==KSTFKillProgram) + { + result=ETrue; + } + + else if(aCommand==KSTFInstallSIS) + { + result=ETrue; + } + else if(aCommand==KSTFUnInstallSIS) + { + result=ETrue; + } + + + return result; + } +EXPORT_C TInt Cstfsystemtestlibplugin::ExecuteCommandL(const TDesC& aCommandLine) + { + TInt result=KErrNone; + TLex lex(aCommandLine); + TPtrC token(lex.NextToken()); + if(token.CompareF(KSTFRunProgram) == 0) + { + RProcess process; + TPtrC filename(lex.NextToken()); + TPtrC para(lex.NextToken()); + TInt err=process.Create(filename, para); + if (err == KErrNone) + { + CleanupClosePushL(process); + TRequestStatus status; + process.Rendezvous(status); + if (status == KRequestPending) + { + process.Resume(); + User::WaitForRequest(status); + } + else + { + process.RendezvousCancel(status); + process.Kill(0); + + } + CleanupStack::PopAndDestroy(); + } + else + { + + } + } + else if(token.CompareF(KSTFKillProgram) == 0) + { + + + TBuf<100> execute; + execute.Append(lex.NextToken()); + execute.TrimAll(); + execute.Append(_L("*")); + + TFindProcess processFinder(execute); + + TFullName result; + TInt err=processFinder.Next(result); + if( err == KErrNone) + { + + RProcess processHandle; + User::LeaveIfError(processHandle.Open ( processFinder, EOwnerThread)); + processHandle.Kill(KErrNone); + processHandle.Close(); + } + + + + + } + else if(token.CompareF(KSTFInstallSIS) == 0) + { + TPtrC sisname(lex.NextToken()); + result=CAppInstall::Install(sisname); + } + else if(token.CompareF(KSTFUnInstallSIS) == 0) + { + TPtrC uid(lex.NextToken()); + result=CAppInstall::Uninstall(uid); + } + return result; + } diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/group/bld.inf Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +* bld.inf Toplevel build information for STF test modules. +*/ +//scripter test module +#include "../scriptermod/group/bld.inf" +#if defined(__S60_) + // StifKernelTestClassBase + #include "../kerneltestmod/group/bld.inf" +#endif // __S60_ + +//TEF test module +//#include "../teftestmod/group/bld.inf" + +//Test Combiner test module +#include "../testcombiner/group/bld.inf" + +//TEF Test Module +#include "../teftestmod/group/bld.inf" + + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/kerneltestmod/Bwins/STIFKERNELTESTCLASSBASEU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/kerneltestmod/Bwins/STIFKERNELTESTCLASSBASEU.DEF Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,10 @@ +EXPORTS + ??0DStifKernelTestClassBase@@QAE@PAVDLogicalDevice@@@Z @ 1 NONAME ; DStifKernelTestClassBase::DStifKernelTestClassBase(class DLogicalDevice *) + ??0DStifKernelTestClassBaseDriver@@QAE@ABVTDesC8@@@Z @ 2 NONAME ; DStifKernelTestClassBaseDriver::DStifKernelTestClassBaseDriver(class TDesC8 const &) + ??1DStifKernelTestClassBase@@UAE@XZ @ 3 NONAME ; DStifKernelTestClassBase::~DStifKernelTestClassBase(void) + ??1DStifKernelTestClassBaseDriver@@UAE@XZ @ 4 NONAME ; DStifKernelTestClassBaseDriver::~DStifKernelTestClassBaseDriver(void) + ?GetCaps@DStifKernelTestClassBaseDriver@@UBEXAAVTDes8@@@Z @ 5 NONAME ; void DStifKernelTestClassBaseDriver::GetCaps(class TDes8 &) const + ?HandleMsg@DStifKernelTestClassBase@@UAEXPAVTMessageBase@@@Z @ 6 NONAME ; void DStifKernelTestClassBase::HandleMsg(class TMessageBase *) + ?Install@DStifKernelTestClassBaseDriver@@UAEHXZ @ 7 NONAME ; int DStifKernelTestClassBaseDriver::Install(void) + ?RunInternalL@DStifKernelTestClassBase@@MAEHPBVTStifFunctionInfo@@HABVTDesC8@@1@Z @ 8 NONAME ; int DStifKernelTestClassBase::RunInternalL(class TStifFunctionInfo const *, int, class TDesC8 const &, class TDesC8 const &) + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/kerneltestmod/Bwins/STIFKERNELTESTCLASSBASE_EKA1U.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/kerneltestmod/Bwins/STIFKERNELTESTCLASSBASE_EKA1U.DEF Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,10 @@ +EXPORTS + ??0DStifKernelTestClassBase@@QAE@PAVDLogicalDevice@@@Z @ 1 NONAME ; DStifKernelTestClassBase::DStifKernelTestClassBase(class DLogicalDevice *) + ??0DStifKernelTestClassBaseDriver@@QAE@ABVTDesC16@@@Z @ 2 NONAME ; DStifKernelTestClassBaseDriver::DStifKernelTestClassBaseDriver(class TDesC16 const &) + ??1DStifKernelTestClassBase@@UAE@XZ @ 3 NONAME ; DStifKernelTestClassBase::~DStifKernelTestClassBase(void) + ??1DStifKernelTestClassBaseDriver@@UAE@XZ @ 4 NONAME ; DStifKernelTestClassBaseDriver::~DStifKernelTestClassBaseDriver(void) + ?DoControl@DStifKernelTestClassBase@@EAEHHPAX0@Z @ 5 NONAME ; int DStifKernelTestClassBase::DoControl(int, void *, void *) + ?GetCaps@DStifKernelTestClassBaseDriver@@UBEXAAVTDes8@@@Z @ 6 NONAME ; void DStifKernelTestClassBaseDriver::GetCaps(class TDes8 &) const + ?Install@DStifKernelTestClassBaseDriver@@UAEHXZ @ 7 NONAME ; int DStifKernelTestClassBaseDriver::Install(void) + ?RunInternalL@DStifKernelTestClassBase@@MAEHPBVTStifFunctionInfo@@HABVTDesC16@@1@Z @ 8 NONAME ; int DStifKernelTestClassBase::RunInternalL(class TStifFunctionInfo const *, int, class TDesC16 const &, class TDesC16 const &) + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/kerneltestmod/eabi/StifKernelTestClassBaseu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/kerneltestmod/eabi/StifKernelTestClassBaseu.def Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,18 @@ +EXPORTS + _ZN24DStifKernelTestClassBase12RunInternalLEPK17TStifFunctionInfoiRK6TDesC8S5_ @ 1 NONAME + _ZN24DStifKernelTestClassBase9HandleMsgEP12TMessageBase @ 2 NONAME + _ZN24DStifKernelTestClassBaseC2EP14DLogicalDevice @ 3 NONAME + _ZN24DStifKernelTestClassBaseD0Ev @ 4 NONAME + _ZN24DStifKernelTestClassBaseD1Ev @ 5 NONAME + _ZN24DStifKernelTestClassBaseD2Ev @ 6 NONAME + _ZN30DStifKernelTestClassBaseDriver7InstallEv @ 7 NONAME + _ZN30DStifKernelTestClassBaseDriverC2ERK6TDesC8 @ 8 NONAME + _ZN30DStifKernelTestClassBaseDriverD0Ev @ 9 NONAME + _ZN30DStifKernelTestClassBaseDriverD1Ev @ 10 NONAME + _ZN30DStifKernelTestClassBaseDriverD2Ev @ 11 NONAME + _ZNK30DStifKernelTestClassBaseDriver7GetCapsER5TDes8 @ 12 NONAME + _ZTI24DStifKernelTestClassBase @ 13 NONAME ; ## + _ZTI30DStifKernelTestClassBaseDriver @ 14 NONAME ; ## + _ZTV24DStifKernelTestClassBase @ 15 NONAME ; ## + _ZTV30DStifKernelTestClassBaseDriver @ 16 NONAME ; ## + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/kerneltestmod/group/StifKernelTestClassBase.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/kerneltestmod/group/StifKernelTestClassBase.mmp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: MMP file for STIF Test Framework's Kernel testclass +* base module. +* +*/ + +#include + +SMPSAFE + +#include "kernel/kern_ext.mmh" + +CAPABILITY ALL +VENDORID 0x101FB657 +SECUREID 0x102073DD +EPOCALLOWDLLDATA + + +TARGET StifKernelTestClassBase.dll +TARGETTYPE kdll +UID 0x1000008D 0x101FB3E3 + +DEFFILE StifKernelTestClassBase.def + +USERINCLUDE ../inc +USERINCLUDE ../../../../inc + +OS_LAYER_KERNEL_SYSTEMINCLUDE + +SOURCEPATH ../src + +SOURCE StifKernelTestClassBase.cpp + +LIBRARY ekern.lib + + + +LANG SC + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/kerneltestmod/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/kerneltestmod/group/bld.inf Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include + +// +// TO DO: (mandatory) +// +// Add here a definition for your port (as declared in E32PLAT.PM) +// +// WINSCW added for debugging test programs +PRJ_PLATFORMS + WINSCW ARMV5 + +PRJ_EXPORTS + +PRJ_MMPFILES + StifKernelTestClassBase.mmp + +// End of File \ No newline at end of file diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/kerneltestmod/src/StifKernelTestClassBase.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/kerneltestmod/src/StifKernelTestClassBase.cpp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,295 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains DStifKernelTestClassBaseDriver +* implementation. +* +*/ + +// INCLUDE FILES +#include "StifKernelTestClass.h" +#include "StifKernelTestClassBase.h" + +// EXTERNAL DATA STRUCTURES + +// EXTERNAL FUNCTION PROTOTYPES + +// CONSTANTS + +// MACROS + +// LOCAL CONSTANTS AND MACROS + +// MODULE DATA STRUCTURES + +// LOCAL FUNCTION PROTOTYPES + +// FORWARD DECLARATIONS + +// ============================= LOCAL FUNCTIONS =============================== + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// DStifKernelTestClassBaseDriver::DStifKernelTestClassBaseDriver +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +EXPORT_C DStifKernelTestClassBaseDriver::DStifKernelTestClassBaseDriver( + const TDesC& aName ) + { + + __KTRACE_OPT(KHARDWARE, + Kern::Printf("DStifKernelTestClassBaseDriver::DStifKernelTestClassBaseDriver()")); + + iVersion=TVersion( RStifKernelTestClass::EMajorVersionNumber, + RStifKernelTestClass::EMinorVersionNumber, + RStifKernelTestClass::EBuildVersionNumber ); + + iName.Copy( aName.Left( KMaxName ) ); + + } + +// ----------------------------------------------------------------------------- +// DStifKernelTestClassBaseDriver::Install +// Set name. +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt DStifKernelTestClassBaseDriver::Install() + { + + __KTRACE_OPT(KHARDWARE, + Kern::Printf("DStifKernelTestClassBaseDriver::Install()")); + + + return SetName( &iName ); // Set our name and return error code. + + } + +// ----------------------------------------------------------------------------- +// DStifKernelTestClassBaseDriver::~DStifKernelTestClassBaseDriver +// Destructor. +// ----------------------------------------------------------------------------- +// +EXPORT_C DStifKernelTestClassBaseDriver::~DStifKernelTestClassBaseDriver() + { + + __KTRACE_OPT(KHARDWARE, + Kern::Printf("DStifKernelTestClassBaseDriver::~DStifKernelTestClassBaseDriver()")); + + } + +// ----------------------------------------------------------------------------- +// DStifKernelTestClassBaseDriver::GetCaps +// Returns the drivers capabilities, may be used by LDD +// ----------------------------------------------------------------------------- +// +EXPORT_C void DStifKernelTestClassBaseDriver::GetCaps( TDes8& /* aDes */ ) const + { + + __KTRACE_OPT(KHARDWARE, + Kern::Printf("DStifKernelTestClassBaseDriver::GetCaps()")); + + } + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CStifKernelTestClassBase::CStifKernelTestClassBase +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// + +EXPORT_C DStifKernelTestClassBase::DStifKernelTestClassBase( DLogicalDevice* /* aDevice */ ) + { + // Get pointer to client threads DThread object + iThread=&Kern::CurrentThread(); + + // Open a reference on client thread so it's control block can't dissapear until + // this driver has finished with it + ((DObject*)iThread)->Open(); + + __KTRACE_OPT(KHARDWARE, + Kern::Printf("DStifKernelTestClassBase::DStifKernelTestClassBase()")); + } + + +// ----------------------------------------------------------------------------- +// DStifKernelTestClassBase::~DStifKernelTestClassBase() +// Destructor +// ----------------------------------------------------------------------------- +// + +EXPORT_C DStifKernelTestClassBase::~DStifKernelTestClassBase() + { + + __KTRACE_OPT(KHARDWARE, + Kern::Printf("DStifKernelTestClassBase::~DStifKernelTestClassBase()")); + + // Close our reference on the client thread + Kern::SafeClose((DObject*&)iThread,NULL); + + + Delete(); + } + +// ----------------------------------------------------------------------------- +// CStifKernelTestClassBase::DoControl +// Handle syncronous request, +// ----------------------------------------------------------------------------- +// + +TInt DStifKernelTestClassBase::DoControl( + TInt aFunction, + TAny* a1, + TAny* /* a2 */ ) + { + + __KTRACE_OPT(KHARDWARE, + Kern::Printf("DStifKernelTestClassBase::DoControl()")); + + TInt ret = KErrNone; + switch( aFunction ) + { + case RStifKernelTestClass::ERunMethod: + { + TStifRunMethodInfo methodInfo; + TPckg methodInfoPckg( methodInfo ); + + TInt err = KErrNone; + + ret = Kern::ThreadDesRead( iThread, a1, methodInfoPckg, 0, KChunkShiftBy0 ); + if( ret != KErrNone ) + { + __KTRACE_OPT(KHARDWARE, + Kern::Printf("DStifKernelTestClassBase::DoControl: ThreadDesRead fails! %d", 333)); + return ret; + } + + // TRAP is not supported in EKA2 kernel, so we can't use it. However, it is not even needed + // any longer because kernel test cases cannot leave either. Although RunMethodL's name + // seems to allow leaves (L in the end of the name), it really doesn't! + ret = RunMethodL( methodInfo.iMethodName, methodInfo.iMethodParams ); + + if( err != KErrNone ) + { + methodInfo.iResult = err; + methodInfo.iMethodResultDes.Copy( _L("RunMethodL leave: ") ); + methodInfo.iMethodResultDes.AppendNum( err ); + } + else if( ret != KErrNone ) + { + methodInfo.iResult = ret; + methodInfo.iMethodResultDes.Copy( _L("RunMethodL returned error: ") ); + methodInfo.iMethodResultDes.AppendNum( ret ); + } + else + { + methodInfo.iResult = KErrNone; + } + + ret = Kern::ThreadDesWrite( iThread, a1, methodInfoPckg, 0, 0, &Kern::CurrentThread() ); + + } + break; + default: + ret = KErrNotFound; + } + + return ret; + } + + +// ----------------------------------------------------------------------------- +// void DStifKernelTestClassBase::HandleMsg(TMessageBase* aMsg) +// Processes the DoControl call in EKA2 +// ----------------------------------------------------------------------------- +// + +EXPORT_C void DStifKernelTestClassBase::HandleMsg( TMessageBase* aMsg ) + { + __KTRACE_OPT(KHARDWARE, + Kern::Printf("DStifKernelTestClassBase::HandleMsg")); + + TThreadMessage& m=*(TThreadMessage*)aMsg; + + // Get the id + TInt id=m.iValue; + + if(id == (TInt)ECloseMsg) + { + // Lets close the channel + m.Complete( KErrNone, EFalse ); + return; + } + + if (id == KMaxTInt) + { + // Cancel operations are not needed because we don't use async requests + m.Complete( KErrNone, ETrue ); + return; + } + + if( id > 0 ) + { + // Process the DoControl call + TInt r = DoControl( id, m.Ptr0(), m.Ptr1() ); + m.Complete( r, ETrue ); + return; + } + } + + +// ----------------------------------------------------------------------------- +// DStifKernelTestClassBase::RunInternalL( +// const TStifKernelFunctionInfo* const aFunctions, +// TInt aCount, +// const TDesC& aMethod, +// const TDesC& aParams ) +// +// Executes the test case. In EKA2 this function cannot leave. +// ----------------------------------------------------------------------------- +// + +EXPORT_C TInt DStifKernelTestClassBase::RunInternalL( + const TStifFunctionInfo* const aFunctions, + TInt aCount, + const TDesC& aMethod, + const TDesC& aParams ) + { + + TInt ret = KErrNotFound; + + TInt i = 0; + TName funcName; + + // Search function from table and call it + for ( i = 0; i < aCount; i++ ) + { + funcName = aFunctions[i].iFunctionName; + if ( aMethod == funcName ) + { + ret = ( this->*(aFunctions[i].iMethod) )( aParams ); + break; + } + + } + + return ret; + + } + + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/scriptermod/Bmarm/TESTSCRIPTERU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/scriptermod/Bmarm/TESTSCRIPTERU.DEF Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,3 @@ +EXPORTS + LibEntryL__Fv @ 1 NONAME R3UNUSED ; LibEntryL(void) + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/scriptermod/Bwins/TESTSCRIPTERU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/scriptermod/Bwins/TESTSCRIPTERU.DEF Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,8 @@ +EXPORTS + ?LibEntryL@@YAPAVCTestScripter@@XZ @ 1 NONAME ; class CTestScripter * LibEntryL(void) + ?GetConstantValue@CTestScripter@@QAEHABVTDesC16@@AAVTDes16@@@Z @ 2 NONAME ; int CTestScripter::GetConstantValue(class TDesC16 const &, class TDes16 &) + ?SetResultDescription@CTestScripter@@QAEXABVTDesC16@@@Z @ 3 NONAME ; void CTestScripter::SetResultDescription(class TDesC16 const &) + ?SetLocalValue@CTestScripter@@QAEHABVTDesC16@@0@Z @ 4 NONAME ; int CTestScripter::SetLocalValue(class TDesC16 const &, class TDesC16 const &) + ?GetLocalValue@CTestScripter@@QAEHABVTDesC16@@AAVTDes16@@@Z @ 5 NONAME ; int CTestScripter::GetLocalValue(class TDesC16 const &, class TDes16 &) + ??1TScriptObject@@UAE@XZ @ 6 NONAME ABSENT ; TScriptObject::~TScriptObject(void) + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/scriptermod/eabi/testscripteru.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/scriptermod/eabi/testscripteru.def Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,21 @@ +EXPORTS + _Z9LibEntryLv @ 1 NONAME + _ZTI11CTestRunner @ 2 NONAME ; ## + _ZTI11TTestObject @ 3 NONAME ; ## + _ZTI13CDefinedValue @ 4 NONAME ; ## + _ZTI13CTestContinue @ 5 NONAME ; ## + _ZTI13CTestScripter @ 6 NONAME ; ## + _ZTI15TTestObjectBase @ 7 NONAME ; ## + _ZTI17TTestObjectKernel @ 8 NONAME ; ## + _ZTV11CTestRunner @ 9 NONAME ; ## + _ZTV11TTestObject @ 10 NONAME ; ## + _ZTV13CDefinedValue @ 11 NONAME ; ## + _ZTV13CTestContinue @ 12 NONAME ; ## + _ZTV13CTestScripter @ 13 NONAME ; ## + _ZTV15TTestObjectBase @ 14 NONAME ; ## + _ZTV17TTestObjectKernel @ 15 NONAME ; ## + _ZN13CTestScripter16GetConstantValueERK7TDesC16R6TDes16 @ 16 NONAME + _ZN13CTestScripter20SetResultDescriptionERK7TDesC16 @ 17 NONAME + _ZN13CTestScripter13GetLocalValueERK7TDesC16R6TDes16 @ 18 NONAME + _ZN13CTestScripter13SetLocalValueERK7TDesC16S2_ @ 19 NONAME + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/scriptermod/group/TestScripter.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/scriptermod/group/TestScripter.mmp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: MMP file for STIF Test Framework's TestScripter. +* +*/ + +#include + +SMPSAFE +TARGET testscripter.dll +TARGETTYPE dll + +CAPABILITY ALL -TCB +VENDORID 0x101FB657 +SECUREID 0x102073E2 + +DEFFILE testscripter.def + +LIBRARY euser.lib +LIBRARY stiftestinterface.lib +LIBRARY efsrv.lib +LIBRARY stiftestengine.lib + +USERINCLUDE ../inc +USERINCLUDE ../../../../inc +USERINCLUDE ../../../../stffw/parser/inc +USERINCLUDE ../../../testlibplugins/inc +OS_LAYER_SYSTEMINCLUDE + +SOURCEPATH ../src + +SOURCE TestScripter.cpp +SOURCE TestKeywords.cpp +SOURCE SubTestCaseRunner.cpp +SOURCE TestScripterUtils.cpp + +// ------- Parser ------- + + +// First UID is DLL UID, Second UID is STIF Test Framework UID +UID 0x1000008D 0x101FB3E7// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/scriptermod/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/scriptermod/group/bld.inf Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +* Build information for STIF Test Framework's TestScripter. +*/ + +PRJ_PLATFORMS +// Specify the platforms your component needs to be built for here. +// If not specified all platforms can be built. + + DEFAULT + +PRJ_EXPORTS + +PRJ_TESTEXPORTS + +PRJ_MMPFILES + + TestScripter.mmp + +PRJ_TESTMMPFILES + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/scriptermod/inc/Logging.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/scriptermod/inc/Logging.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,75 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains Logging macros for TestScripter. +* +*/ + +#ifndef LOGGINGDEFS_H +#define LOGGINGDEFS_H + +// INCLUDES +#include +#include + + +// CONSTANTS +const TUint KError = 0x1; +const TUint KInit = 0x2; +const TUint KPrint = 0x4; +const TUint KMessage = 0x10; +const TUint KFunction = 0x20; +const TUint KVerbose = 0x40; +const TUint KAlways = 0xFFFFFFFF; +const TUint KDebugLevel = ( KPrint | KError | KMessage ); + +// MACROS +#define __TRACING_ENABLED + +#ifdef __TRACING_ENABLED + + // Disable conditional expression is constant -warning + #pragma warning( disable : 4127 ) + + // General tracing function + #define __TRACE(level,p) if ( ( (level) & KDebugLevel ) && LOGGER )\ + {LOGGER->Log p;} + + // Direct RDebug::Print + #define __RDEBUG(p) if( KVerbose & KDebugLevel ){ RDebug::Print p ; } + + // Log function name + #define __TRACEFUNC() if( ( KFunction & KDebugLevel ) && LOGGER ){\ + const char* f = __FUNCTION__;\ + TPtrC8 F((const unsigned char*)f);\ + LOGGER->Log(F);} + +#else // __TRACING_ENABLED + // No tracing + #define __TRACE(level,p) + #define __RDEBUG(p) + #define __TRACEFUNC() +#endif // __TRACING_ENABLED + + +// DATA TYPES + +// FUNCTION PROTOTYPES + +// FORWARD DECLARATIONS + +// CLASS DECLARATION + +#endif // LOGGINGDEFS_H + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/scriptermod/inc/SubTestCaseRunner.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/scriptermod/inc/SubTestCaseRunner.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,341 @@ +/* + * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: This file contains the header file of the TestScripter + * module of STIF Test Framework. + * + */ + +#ifndef SUBTESTCASERUNNER_H_ +#define SUBTESTCASERUNNER_H_ + +// INCLUDES +#include +#include +#include "TestScripterUtils.h" + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +class CTestRunner; +class CSlave; +class CRemoteCallsProxy; + +// CLASS DECLARATION +// DESCRIPTION +// CSubTestCaseRunner manages sub test cases execution and retuns +// execution results to CTestRunner +NONSHARABLE_CLASS(CSubTestCaseRunner): public CActive + { +public: + enum TSubTestCaseType { ESTTLocal, ESTTRemote }; + enum TSubTestCaseState { ESTSIdle, ESTSRunning, ESTSPaused }; +public: + /** + * Coinstructor. + */ + CSubTestCaseRunner(); + + /** + * Starts execution of selected test case. + */ + virtual void RunSubTestCaseL( CStartInfo& aStartTestCaseInfo ) = 0; + + /** + * Pauses selected sub test case. + */ + virtual void PauseSubTestCaseL() = 0; + + /** + * Reasume selected sub test case. + */ + virtual void ResumeSubTestCaseL() = 0; + + virtual void CancelSubTestCaseL() = 0; + + + /** + * Gets execution result. + */ + virtual TInt GetRunResult() const = 0; + + /** + * Gets test case execution result.. + */ + virtual const TFullTestResult& GetTestCaseResult() const = 0; + + /** + * Gets executed test case info. + */ + virtual const CStartInfo* GetStartInfo() const = 0; + + /** + * Gets sub test case runner type. + */ + virtual TSubTestCaseType GetType() const = 0; + + TSubTestCaseState GetState() const; +protected: + TSubTestCaseState iState; + }; // class CSubTestCaseRunner + + +// DESCRIPTION +// CSubTestCaseRunner manages sub test cases execution and retuns +// execution results to CTestRunner +NONSHARABLE_CLASS(CLocalSubTestCaseRunner): public CSubTestCaseRunner + { +public: + /** + * Two-phased constructor. + */ + static CLocalSubTestCaseRunner* NewL( CTestRunner* aTestRunner ); + + /** + * Two-phased constructor. + */ + static CLocalSubTestCaseRunner* NewLC( CTestRunner* aTestRunner ); +public: + /** + * Destructor. + */ + ~CLocalSubTestCaseRunner(); + + /** + * Starts execution of selected test case. + */ + void RunSubTestCaseL( CStartInfo& aStartTestCaseInfo ); + + /** + * Pauses selected sub test case. + */ + void PauseSubTestCaseL(); + + /** + * Reasume selected sub test case. + */ + void ResumeSubTestCaseL(); + + void CancelSubTestCaseL(); + + /** + * Gets execution result. + */ + TInt GetRunResult() const; + + /** + * Gets test case execution result.. + */ + const TFullTestResult& GetTestCaseResult() const; + + /** + * Gets executed test case info. + */ + const CStartInfo* GetStartInfo() const; + + /** + * Gets sub test case runner type. + */ + TSubTestCaseType GetType() const; +private: + /** + * Constructor. + */ + CLocalSubTestCaseRunner( CTestRunner* aTestRunner ); + + /** + * Second phase of two-phased constructor. + */ + void ConstructL(); + + /** + * See CActive::RunL() + */ + void RunL(); + + /** + * See CActive::DoCancel() + */ + void DoCancel(); + + /** + * Resets runner internal state to default values. + */ + void Reset(); +private: + // Pointer to test runner which will be notified about test case execution end. + CTestRunner* iTestRunner; + + // Test engine session used to load test module and open RTestCase subsession + RTestEngine iTestEngine; + + // Test case sub session used to run test case + RTestCase iTestCase; + + // Copy of CStartInfo passed as an argument of RunSubTestCaseL call + CStartInfo* iStartInfo; + + // Value of iState.Int() after test case execution + TInt iRunResult; + + // Result of test case execution + TFullTestResult iResult; + + // Descriptor used to retrive result from TestEngine + TFullTestResultPckg iResultPckg; + }; // class CLocalSubTestCaseRunner + + +// DESCRIPTION +// CRemoteSubTestCaseRunner manages sub test cases execution and retuns +// execution results to CTestRunner +NONSHARABLE_CLASS(CRemoteSubTestCaseRunner): public CSubTestCaseRunner + { + private: + enum TCurrentOperation { ECONone, + ECORunSubtestCase, + ECOPauseSubtestCase, + ECOResumeSubtestCase, + ECOCancelSubtestCase }; + public: + /** + * Two-phased constructor. + */ + static CRemoteSubTestCaseRunner* NewL( CTestRunner* aTestRunner, + CSlave* aSlave, CRemoteCallsProxy* aRemoteCallsProxy ); + + /** + * Two-phased constructor. + */ + static CRemoteSubTestCaseRunner* NewLC( CTestRunner* aTestRunner, + CSlave* aSlave, CRemoteCallsProxy* aRemoteCallsProxy ); + public: + /** + * Destructor. + */ + ~CRemoteSubTestCaseRunner(); + + /** + * Starts execution of selected test case. + */ + void RunSubTestCaseL( CStartInfo& aStartTestCaseInfo ); + + /** + * Pauses selected sub test case. + */ + void PauseSubTestCaseL(); + + /** + * Reasume selected sub test case. + */ + void ResumeSubTestCaseL(); + + void CancelSubTestCaseL(); + + /** + * Gets execution result. + */ + TInt GetRunResult() const; + + /** + * Gets test case execution result.. + */ + const TFullTestResult& GetTestCaseResult() const; + + /** + * Gets executed test case info. + */ + const CStartInfo* GetStartInfo() const; + + /** + * Gets sub test case runner type. + */ + TSubTestCaseType GetType() const; + + CSlave* GetSlave(); + + TUint16 GetTestCaseId() const; + + void NotifyTestCaseStartedL( TUint16 aTestCaseId ); + void NotifyTestCaseRunError( const TFullTestResult& aTestCaseResult ); + + void NotifyTestCasePausedL(); + void NotifyTestCaseResumedL(); + void NotifyTestCaseCancelledL(); + + void NotifyTestCaseFinishedL( const TFullTestResult& aTestCaseResult ); + + TBool IsRunSubTestCaseRequestOngoing() const; + private: + /** + * Constructor. + */ + CRemoteSubTestCaseRunner( CTestRunner* aTestRunner, + CSlave* aSlave, CRemoteCallsProxy* aRemoteCallsProxy ); + + /** + * Second phase of two-phased constructor. + */ + void ConstructL(); + + /** + * See CActive::RunL() + */ + void RunL(); + + /** + * See CActive::DoCancel() + */ + void DoCancel(); + + void Reset(); + private: + // Pointer to test runner which will be notified about test case execution end. + CTestRunner* iTestRunner; + CSlave* iSlave; + CRemoteCallsProxy* iRemoteCallsProxy; + + // Copy of CStartInfo passed as an argument of RunSubTestCaseL call + CStartInfo* iStartInfo; + + TUint16 iTestCaseId; + + // Value of iState.Int() after test case execution + TInt iRunResult; + + // Result of test case execution + TFullTestResult iResult; + + TCurrentOperation iCurrentOperation; + TInt iOperationResult; + + TTimeIntervalMicroSeconds32 iOperationTimeout; + RTimer iTimeoutTimer; + + CActiveSchedulerWait* iNestedASLoop; + }; // class CRemoteSubTestCaseRunner + + + +#endif /* SUBTESTCASERUNNER_H_ */ +// EOF diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/scriptermod/inc/TestKeywords.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/scriptermod/inc/TestKeywords.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,187 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains the keywords for the +* TestScripter module. +* +*/ + +#ifndef TESTKEYWORDS_H +#define TESTKEYWORDS_H + +// INCLUDES +#include +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +typedef TPtrC (*KeywordFunc)( TInt aKeyword ); + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION + +// DESCRIPTION +// TestScripter Keyword class +class TTestKeywords + { + public: // Enumerations + // Keyword enum + enum TKeywords + { + ETitle, + ETimeout, + EPriority, + ECreate, + EDelete, + ERequest, + EWait, + ERelease, + ESet, + EUnset, + EPrint, + EAllowNextResult, + EWaitTestClass, + ECreateKernel, + EPause, + ELoop, + EEndLoop, + EOOMIgnoreFailure, + EOOMHeapFailNext, + EOOMHeapSetFail, + EOOMHeapToNormal, + ETestInterference, + EMeasurement, + EAllowErrorCodes, + EBringToForeground, + ESendToBackground, + EPressKey, + ETypeText, + EVar, + ECallSub, + ECreateX, + ESetResultDescription, + ESendPointerEvent, + EUsing, + EExpectedPanic, + ECreateShareObj, + ERestoreShareObj, + EDeleteShareObj, + ERun, + EComplete, + ECancelIfError, + EPauseTest, + EResume, + ECancel, + EAllocate, + EFree, + ERemote, + ESendReceive, + }; + + // run keyword optional arguments + enum TRunOptArgs + { + EExpect, + ETestid, + EIni, + ECategory, + ECaseTimeout, + ECaseTitle, + }; + + // priorities + enum TPriority + { + EPriHigh, + EPriNormal, + EPriLow, + }; + + private: // Enumerations + + public: // Constructors and destructor + + public: // Constructors and destructor + + public: // New functions + + /** + * Returns a string desrciptor corresponding to keyword number. + */ + static TPtrC Keyword( TInt aKeyword ); + + /** + * Returns a string desrciptor corresponding to priority + * enum value. + */ + static TPtrC Priority( TInt aArg ); + + /** + * Returns a keyword enum corresponding to keyword + * string descriptor. + */ + static TInt Parse( TDesC& aKeyword, KeywordFunc aFunc ); + + /** + * Returns a string desrciptor corresponding to run keyword + * optional argument number. + */ + static TPtrC RunOptArg( TInt aArg ); + + /** + * Returns result category description. + */ + static TPtrC ResultCategory( TInt aArg ); + + /** + * Returns result category type. + */ + static TFullTestResult::TCaseExecutionResult + GetResultCategory( TDesC& aCategory ); + + + public: // Functions from base classes + + protected: // New functions + + protected: // Functions from base classes + + private: // New functions + + public: // Data + + protected: // Data + + private: // Data + + public: // Friend classes + + protected: // Friend classes + + private: // Friend classes + + }; + +#endif // TESTKEYWORDS_H + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/scriptermod/inc/TestScripter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/scriptermod/inc/TestScripter.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,1183 @@ +/* + * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: This file contains the header file of the TestScripter + * module of STIF Test Framework. + * + */ + +#ifndef TestScripter_H +#define TestScripter_H + +// INCLUDES +#include + +#include +#include +#include +#include "TestScripterInternal.h" +#include "TestKeywords.h" +#include "StifKernelTestClass.h" +#include "StifTestInterference.h" +#include "STIFMeasurement.h" +#include "StfTestLibPluginInterface.h" +#include "StifTestModule.h" +#include "TestScripterUtils.h" +#include "SubTestCaseRunner.h" + +// CONSTANTS +// Printing priorities +const TInt KPrintPriLow = 10; +const TInt KPrintPriNorm = 30; +const TInt KPrintPriHigh = 50; +// Log dir and file +_LIT( KTestScripterLogDir, "\\Logs\\TestFramework\\TestScripter\\" ); +_LIT( KTestScripterLogFile, "TestScripter.txt" ); +_LIT( KTestScripterLogFileWithTitle, "TestScripter_[%S].txt"); +// Configuration file tags +_LIT( KTestStartTag, "[Test]" ); +_LIT( KTestEndTag, "[Endtest]" ); +// Define tags +_LIT( KDefineStartTag, "[Define]" ); +_LIT( KDefineEndTag, "[Enddefine]" ); +// Data tags +_LIT( KDataStartTag, "[Data]" ); +_LIT( KDataEndTag, "[Enddata]" ); +// Loop counter macro +_LIT( KLoopCounter, "LOOP_COUNTER" ); +// ini flag +_LIT(KFileFlag,"$"); +_LIT(KSectionFlag,"@"); +_LIT(KKeyFlag,"#"); + +// Remote protocol timeout +const TInt KRemoteProtocolTimeout = 30000000; +// Remote protocol Master id +const TUint32 KRemoteProtocolMasterId = 0xdeadbeef; + + +// MACROS +// None + +// DATA TYPES +class CTestRunner; +typedef CScriptBase* (*CInterfaceFactory)(CTestModuleIf& aTestModuleIf); + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +class CTestRunner; +class CTestContinue; +class TTestModule; +class TTestObjectBase; +class TTestObject; +class TTestInterference; +class CStifTestMeasurement; +class TTestMeasurement; +class TSharedTestModule; + +// CLASS DECLARATION + +// DESCRIPTION +// Predefined value entry +class CDefinedValue : public CBase + { +public: + // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CDefinedValue* NewL(TDesC& aName, TDesC& aValue); + + /** + * Destructor. + */ + virtual ~CDefinedValue(); + +public: + // New functions + + /** + * Returns define name. + */ + TDesC& Name(); + + /** + * Returns define value. + */ + TDesC& Value(); + + /** + * Returns new define value. + */ + void SetValueL(TDesC& aValue); + +private: + + /** + * C++ default constructor. + */ + CDefinedValue(); + + /** + * By default Symbian OS constructor is private. + */ + void ConstructL(TDesC& aName, TDesC& aValue); + +private: + // Data + + // Define name + HBufC* iNameBuf; + TPtrC iName; + + // Define value + HBufC* iValueBuf; + TPtrC iValue; + + }; + +// CLASS DECLARATION + +// DESCRIPTION +// CTestScripter contains the Test Module interface of TestScripter +// for STIF Test Framework + +class CTestScripter : public CTestModuleBase + { +public: + // Enumerations + +private: + // Enumerations + +public: + // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CTestScripter* NewL(); + + /** + * Destructor. + */ + ~CTestScripter(); + +public: + // New functions + + /** + * Call specified tst class object. + */ + TInt CallTestClass(const TDesC& aLine); + + /** + * Get pointer to test class object. + */ + TInt GetTestScriptObject(const TDesC& aObjectName); + + /** + * Return runner handle. + */ + CTestRunner& TestRunner() + { + return *iTestRunner; + } + ; + +public: + // Functions from base classes + + /** + * Test module initialization. + */ + TInt InitL(TFileName& aIniFile, TBool aFirstTime); + + /** + * GetTestCasesL is used to inquire testcases. + */ + TInt GetTestCasesL(const TFileName& aConfigFile, RPointerArray< + TTestCaseInfo>& aTestCases); + + /** + * RunTestCase is used to run an individual test case specified + * by aTestCase. + */ + TInt RunTestCaseL(const TInt aCaseNumber, const TFileName& aConfig, + TTestResult& aResult); + + /** + * Internal fuction to get const value defined in + * [Define]...[Enddefine] section of script file + */ + IMPORT_C TInt GetConstantValue(const TDesC& aName, TDes& aValue); + + /** + * Set result description of test case. + */ + IMPORT_C void SetResultDescription(const TDesC& aDescr); + + /** + * Internal fuction to set local value. + */ + IMPORT_C TInt SetLocalValue(const TDesC& aName, const TDesC& aValue); + + /** + * Internal fuction to get local value. + */ + IMPORT_C TInt GetLocalValue(const TDesC& aName, TDes& aValue); + +protected: + // New functions + +protected: + // Functions from base classes + +private: + /** + * C++ default constructor. + */ + CTestScripter(); + + /** + * By default Symbian OS constructor is private. + */ + void ConstructL(); + + /** + * GetTestCaseL gets the specified test case section + * from the onfigfile. + */ + CStifSectionParser* GetTestCaseL(TInt aCaseNumber, + const TFileName& aConfig); + + /** + * RunTestL runs the testcase specified in section. + */ + void RunTestL(); + + /** + * LoadTestModuleL loads test module. + */ + TTestModule* LoadTestModuleL(TDesC& aModule); + + /** + * LoadTestModuleL loads test module. + */ + TTestModule* LoadSharedTestModuleL(TDesC& aModule); + + /** + * CreateObjectL create new object. + */ + void CreateObjectL(TDesC& aModule, TDesC& aObjectId); + + /** + * CreateShareObjectL create new object. + */ + void CreateShareObjectL(TDesC& aModule, TDesC& aObjectId); + + /** + * RestoreShareObjectL create new object. + */ + void RestoreShareObjectL(TDesC& aObjectId); + + /** + * CreateKernelObjectL create new kernel object. + */ + void CreateKernelObjectL(TDesC& aDriver, TDesC& aObjectId); + + /** + * DeleteObjectL deletes object with aObjectId. + */ + TInt DeleteObjectL(TDesC& aObjectId); + + /** + * DeleteGlobalObjectL deletes object with aObjectId. + */ + TInt CTestScripter::DeleteScripterObjectL(TDesC& aObjectId); + + /** + * GetObject returns object corresponding to aObjectId. + */ + TTestObjectBase* GetObject(const TDesC& aObjectId); + + /** + * Read initialization from file. + */ + void ReadInitializationL(const TDesC& aIniFile, RPointerArray< + CDefinedValue>& aDefines); + + /** + * Read sub section from test case file. + */ + CStifSectionParser* GetSubL(const TDesC& aSubName); + + /** + * Updates result of test case. + */ + void UpdateTestCaseResult(const TInt aError, const TDesC& aDescr); + + void Substitute(const TDesC& aSrc, TDes& aDest); + + /** + * Add Test object + */ + void AddTestObjToScripterDictL(TTestObject* aObject); + + /** + * Delete Test object + */ + void DelTestObjFromScripterDict(const TDesC& aObjectId); + + /** + * Get Test object + */ + TTestObject* GetTestObjFromScripterDict(const TDesC& aObjectId) const; + + /** + * Append to TS's result description (if possible due to length) + * limitation provided text in [] brackets. + */ + void AppendTestResultToResultDes(TDes& aResultDescr, const TDesC& aTestCaseResultDescr); + + /** + * Trace memory usage of global objects and output to log. method return the used cells. + */ + TInt TraceGlobalObjectsMemoryUsage(); + +public: + // Data + // Logger + CStifLogger* iLog; + +protected: + // Data + +private: + // Data + // Test case array of running/runned test cases + RPointerArray iTestObjects; + // Array of test modules + RPointerArray iTestModules; + + // Array of test modules + RPointerArray iSharedTestModules; + + // Test case array of global test objects + RPointerArray iGlobalObjects; + + // Test case result of the TestScripter + TTestResult iResult; + + // Sectionparser for the current testcase + CStifSectionParser* iSectionParser; + + // Currently used section parser (changed when executing a function (sub)) + CStifSectionParser* iCurrentParser; + + // It says if we need to call GetLine or GetNextLine for the parser + TBool iCurrentParserReadFirstLine; + + // Stack of parsers for called functions (subs) + RPointerArray iParserStack; + + // Pointer to used testrunner + CTestRunner* iTestRunner; + + // Predefined values are listed here + RPointerArray iDefinedIni; + RPointerArray iDefinedRuntime; + RPointerArray iDefinedLocal; + + // Flag for OOM testing. If true test class's build + // block execution result will ignored. + TBool iOOMIgnoreFailure; + + // Flag which says if heap balance should be checked (affects only + // EKA2 environment). May be set in StifSettings section. + TBool iCheckHeapBalance; + + // Standard logger + CStifLogger* iStdLog; + + // Test case Logger + CStifLogger* iTCLog; + + // Flag which says if test case title should be appended to the + // log file name. This is read from SettingServer + TBool iAddTestCaseTitleToLogName; + + // The running test case's config file name + TFileName iConfig; + + TBuf iCurrentFile; + TBuf iCurrentFileAlias; + + TBuf iCurrentSection; + TBuf iCurrentSectionFileAlias; + + TBuf iCurrentKey; + TBuf iCurrentvalues; + + RArray > iKeys; + RArray > iValues; + RPointerArray *iObjects; + + // Indicates if pass limit in loops was met + TBool iPassLimitNotMet; +public: + // Friend classes + +protected: + // Friend classes + +private: + // Friend classes + friend class CTestRunner; + friend class CTestContinue; + + }; + +// CLASS DECLARATION + +// DESCRIPTION +// CTestRunner parses the TestScripter configuration file and +// runs a testcase. CTestRunner is the friend of CTestScripter +// and uses its private member variables directly. + +class CTestRunner : public CActive + { +public: + // Enumerations + +private: + // Enumerations + enum TRunnerState + { + ERunnerIdle, + ERunnerRunning, + ERunnerCancel, + ERunnerError, + ERunnerPaused, + }; + + enum TInternalStateForSubTestCases + { + EISNotStarted, + EISRuning, + EISWaitingForComplete, + EISEndLoopWaitingForSubTestCases, + EISFinishedWaitingForSubTestCases, + EISFinished, + }; +public: + // Constructors and destructor + /** + * Two-phased constructor. + */ + static CTestRunner* NewL(CTestScripter* aTestScripter); + + /** + * Destructor. + */ + ~CTestRunner(); + +public: + // New functions + /** + * Calls SetActive() from CActive. + */ + void SetRunnerActive(); + + /** + * Get test case result handle. + */ + RArray& TestCaseResults() + { + return iTestCaseResults; + } + ; + +public: + // Functions from base classes + /** + * RunL derived from CActive handles the completed requests. + */ + void RunL(); + + /** + * DoCancel derived from CActive handles the Cancel. + */ + void DoCancel(); + + /** + * RunError derived from CActive handles errors from active handler. + */ + TInt RunError(TInt aError); + + CStifLogger* GetLogger(); + + /** + * Recieves notification about finished sub test case execution. + */ + void SubTestCaseFinishedL( CSubTestCaseRunner* aSubTestCaseRunner ); + + /** + * Recives report from CLoopHelper about result of loop execution + */ + void ReportLoopEndResultL( TInt aPassedIterations ); + + /** + * Releases resources allocated in loop + */ + void ReleaseRemoteResourcesAllocatedInLoopL(); + + /** + * Gets information if there was reported executed sub test case + * which failed. + */ + TBool IsFailedSubTestCaseReported() const; + + /** + * Returns first failed sub test case result. + */ + TFullTestResult GetFailedSubTestCaseResult() const; + + /** + * Returns first failed sub test case info. + */ + const CStartInfo* GetFailedSubTestCaseInfo() const; + + void HandleRemoteReceiveError( TInt aError, const TDesC& aErrorDescription ); +protected: + // New functions + +protected: + // Functions from base classes + +private: + /** + * C++ default constructor. + */ + CTestRunner(CTestScripter* aTestScripter); + + /** + * By default Symbian OS constructor is private. + */ + void ConstructL(); + + /** + * Executes one script line. + */ + TBool ExecuteLineL(TDesC& aKeyword, CStifItemParser* aItem); + + /** + * Executes run script line. + */ + TBool ExecuteRunL( CStifItemParser* aItem ); + + TBool ExecuteCompleteL( CStifItemParser* aItem ); + + /** + * Parses run parameters. + */ + void ParseRunParamsL( CStifItemParser* aItem, CStartInfo& aStartInfo ); + + /** + * Parses optional argument. + */ + void ParseOptArgL( const TDesC& aOptArg, TPtrC& aArg, TPtrC& aVal); + + /** + * Executes method call to object script line. + */ + TBool ExecuteCommandL(TDesC& aObject, CStifItemParser* aItem); + + /** + * Executes method call to object script line. + */ + TBool ExecuteLibL(TDesC& lib, CStifItemParser* aItem); + + /** + * Executes event control script line. + */ + TBool ExecuteEventL(TDesC& aKeyword, CStifItemParser* aItem); + + /** + * Preprocess hardcoded values in test case. + */ + CStifItemParser* PreprocessLineL(TDesC& line); + + /** + * Checks if aWord is defined value. + */ + TInt CheckDefined(TPtrC& aWord); + + /** + * Checks if aWord is a local variable. + */ + TInt CheckDefinedLocals(TPtrC& aWord); + + /** + * Handles 'oomignorefailure' keyword parsing. + */ + void OOMIgnoreFailureL(CStifItemParser* aItem); + + /** + * Handles 'oomheapfailnext' keyword parsing. + */ + void OOMHeapFailNextL(CStifItemParser* aItem); + + /** + * Handles 'oomheapsetfail' keyword parsing. + */ + void OOMHeapSetFailL(CStifItemParser* aItem); + + /** + * Initialize all OOM related variables. + */ + void OOMHeapToNormal(); + + /** + * Handles 'testinterference' keyword parsing. + */ + void TestInterferenceL(CStifItemParser* aItem); + + /** + * Starts test interference. + */ + void StartInterferenceL(TDesC& aName, CStifItemParser* aItem); + + /** + * Stops test interference. + */ + void StopInterferenceL(TDesC& aName); + + /** + * Handles 'measurement' keyword parsing. + */ + void MeasurementL(CStifItemParser* aItem); + + /** + * Starts measurement. + */ + void StartMeasurementL(const TDesC& aType, CStifItemParser* aItem); + + /** + * Stops measurementplugin's measurement. + */ + void StopMeasurementL(const TDesC& aType); + + /** + * Adds new test case result. Used with 'allownextresult' + * and 'allowerrorcodes' keywords. + */ + void AddTestCaseResultL(CStifItemParser* aItem); + + /** Adds new test case panic. Used with 'allowpanic' + */ + void AddTestCasePanicL(CStifItemParser* aItem); + + /** + * Sends key press event to AppUi + */ + TBool PressKeyL(CStifItemParser* aItem); + + /** + * Sends text to AppUi + */ + TBool TypeTextL(CStifItemParser* aItem); + + /** + * Sends pointer event to AppUi + */ + TBool SendPointerEventL(CStifItemParser* aItem); + + /** + * Controls sub test case execution + */ + TBool ControlSubTestCaseL( TTestKeywords::TKeywords aOperation, CStifItemParser* aItem ); + + /** + * Executes loop keyword + */ + TBool ExecuteLoopL( CStifItemParser* aItem ); + + /** + * Executes endloop keyword + */ + TBool ExecuteEndLoopL( CStifItemParser* aItem ); + + TBool ExecuteAllocateL( CStifItemParser* aItem ); + TBool ExecuteFreeL( CStifItemParser* aItem ); + TBool ExecuteRemoteL( CStifItemParser* aItem ); + + /** + * Executes remote run script line. + */ + TBool ExecuteRemoteRunL( CStifItemParser* aItem, CSlave* aSlave, + HBufC *aSetUnsetEvent = NULL, + TInt aCaseNumber = 0 ); + + /** + * Executes remote event control script line. + */ + TBool ExecuteRemoteEventCtlL( CStifItemParser* aItem, + CSlave* aSlave, + TInt aCmd ); + + /** + * Executes asynchronous remote sendreceive control script line. + */ + TBool ExecuteRemoteSendReceiveL( CStifItemParser* aItem, + CSlave* aSlave ); + + /** + * Executes remote unknown control script line. + */ + TBool ExecuteRemoteUnknownL( CStifItemParser* aItem, + CSlave* aSlave, + TDesC& aCommand ); + +public: + // Data + +protected: + // Data + +private: + // Data + // Runner state + TRunnerState iState; + + TInternalStateForSubTestCases iInternalStateForSubTestCases; + + // Backpointer to CTestScripter + CTestScripter* iTestScripter; + + // Allowed test case results + RArray iTestCaseResults; + + // Temporary line buffer + HBufC* iLine; + + // Store for requested events + RPointerArray iEventArray; + + // Pause timer + RTimer iPauseTimer; + + // Pause value for timer + TInt iRemainingTimeValue; + + // Loop times, counter and start position + TInt iLoopTimes; + TInt iLoopCounter; + TInt iLoopStartPos; + TBuf<10> iLoopCounterDes; + + // Loop (timed loop option) + TBool iTimedLoop; + TTime iStartTime; + TTimeIntervalMicroSeconds iExpectedLoopTime; + + // For OOM heap testing, FAILNEXT: count + TInt iHeapFailNext; + // For OOM heap testing, SETFAIL: type and value(rate) + RHeap::TAllocFail iHeapSetFailType; + TInt iHeapSetFailValue; + + // Array for test interference + RPointerArray iTestInterferenceArray; + + // CStifTestMeasurement object + RPointerArray iTestMeasurementArray; + + // Message displayed when leave occurs during script parsing + TBuf<256> iRunErrorMessage; + + // test lib plugins array + RPointerArray iPlugins; + + // test lib pluginnames array + RPointerArray iPluginnames; + + RLibrary iLibrary; + + // Array of executed sub test cases + RPointerArray iSubTestCases; + + // Indicates on which sub test case waits last complete call + HBufC* iTestIdForComplete; + + // Indicates if execution of some sub test case failed + TBool iFailedSubTestCaseReported; + + // Caintains test execution result of first failed sub test case + TFullTestResult iFailedSubTestCaseResult; + + // Caintains information about first failed sub test case + CStartInfo* iFailedSubTestCaseInfo; + + // Indicates if test case executions should be breaked when of the sub test case fails + TBool iCancelIfError; + + // Indicates whether passlimit feature is enabled or not + TBool iPasslimitEnabled; + + // Pass limit for loop + TInt iPasslimit; + + // Loop helper + CLoopHelper* iLoopHelper; + + // Slaves manager + CSlavesManager* iSlavesManager; +public: + // Friend classes + +protected: + // Friend classes + +private: + // Friend classes + + }; + +// CLASS DECLARATION + +// DESCRIPTION +// CTestContinue gets ContinueScript signals from test class +class CTestContinue : public CActive + { +public: + // Enumerations + +private: + // Enumerations + +public: + // Constructors and destructor + /** + * Two-phased constructor. + */ + static CTestContinue* NewL(CTestScripter* aTestScripter, + TTestObject* aObject); + + /** + * Destructor. + */ + ~CTestContinue(); + +public: + // New functions + +public: + // Functions from base classes + /** + * RunL derived from CActive handles the completed requests. + */ + void RunL(); + + /** + * DoCancel derived from CActive handles the Cancel. + */ + void DoCancel(); + + /** + * RunError derived from CActive handles errors from active handler. + */ + TInt RunError(TInt aError); + +protected: + // New functions + +protected: + // Functions from base classes + +private: + /** + * C++ default constructor. + */ + CTestContinue(CTestScripter* aTestScripter, TTestObject* aObject); + + /** + * By default Symbian OS constructor is private. + */ + void ConstructL(); + +public: + //Data + +protected: + // Data + +private: + // Data + // Backpointer to CTestScripter + CTestScripter* iTestScripter; + + // Objectid for this object + TTestObject* iObject; + +public: + // Friend classes + +protected: + // Friend classes + +private: + // Friend classes + + }; + +// CLASS DECLARATION + +// DESCRIPTION +// TTestObjectBase contains test object base information +class TTestObjectBase : public TScriptObject + { +public: + enum TObjectType + { + EObjectNormal, EObjectKernel, + }; + +public: + TTestObjectBase(TObjectType aType); + virtual ~TTestObjectBase(); +public: + TObjectType ObjectType() + { + return iType; + } + ; + + virtual TInt RunMethodL(CStifItemParser& aItem) = 0; + virtual TBool Signal() = 0; + virtual TBool Wait() = 0; + +public: + TInt iAsyncResult; + +protected: + TObjectType iType; + +private: + // TName iName; + + }; + +// CLASS DECLARATION + +// DESCRIPTION +// TTestObject contains test object information +class TTestObject : public TTestObjectBase + { +public: + TTestObject(); + virtual ~TTestObject(); + +public: + TInt RunMethodL(CStifItemParser& aItem); + inline TBool Signal() + { + return (iCount++ < 0); + } + ; + inline TBool Wait() + { + return (--iCount >= 0); + } + ; + +public: + CTestContinue* iContinue; + TName iModule; +private: + TInt iCount; + }; + +// CLASS DECLARATION + +// DESCRIPTION +// TTestObjectKernel contains kernel test object information +class TTestObjectKernel : public TTestObjectBase + { +public: + TTestObjectKernel(); + virtual ~TTestObjectKernel(); + +public: + TInt RunMethodL(CStifItemParser& aItem); + + // Signal and Wait not supported + TBool Signal() + { + return ETrue; + } + ; + TBool Wait() + { + return ETrue; + } + ; + + TName& LddName() + { + return iLddName; + } + RStifKernelTestClass& KernelTestClass() + { + return iTestClass; + } + +private: + RStifKernelTestClass iTestClass; + TName iLddName; + + }; + +// CLASS DECLARATION + +// DESCRIPTION +// TTestModule contains test module information +class TTestModule + { +public: + TTestModule() + { + } + ; + ~TTestModule() + { + iLibrary.Close(); + } + ; + +public: + TName& ModuleName() + { + return iName; + } + +public: + RLibrary iLibrary; + CInterfaceFactory iLibEntry; + +private: + TName iName; + + }; + +// CLASS DECLARATION + +// DESCRIPTION +// TSharedTestModule contains test module information +class TSharedTestModule + { +public: + TSharedTestModule(TTestModule *aTestModule) + { + refCount=1; + iTestModule = aTestModule; + }; + ~TSharedTestModule(){}; + TName& ModuleName() + { + return iTestModule->ModuleName(); + }; + TTestModule* Get() + { + ++refCount; + return iTestModule; + } + void Del() + { + if(--refCount<=0) + { + delete iTestModule; + iTestModule = NULL; + } + }; + + const TInt RefCount(){ return refCount; }; + +private: + TInt refCount; + TTestModule *iTestModule; + }; + +// CLASS DECLARATION + +// DESCRIPTION +// TTestInterference contains test interference object information +class TTestInterference + { +public: + TTestInterference() + { + iInterference = NULL; + } + ; + ~TTestInterference() + { + delete iInterference; + } + ; + +public: + +public: + // "object" name given in test case file. + TName iName; + // MSTIFTestInterference object. + MSTIFTestInterference* iInterference; + +private: + + }; + +// DESCRIPTION +// TTestMeasurement contains test measurement module information +class TTestMeasurement + { +public: + TTestMeasurement() + { + iMeasurement = NULL; + } + ; + ~TTestMeasurement() + { + delete iMeasurement; + } + ; + +public: + +public: + // "object" name given in test case file. + TName iName; + // MSTIFTestInterference object. + CSTIFTestMeasurement* iMeasurement; + +private: + + }; + +#endif // TestScripter_H +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/scriptermod/inc/TestScripterUtils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/scriptermod/inc/TestScripterUtils.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,1080 @@ +/* + * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: This file contains the header file of the TestScripter + * module of STIF Test Framework. + * + */ + +#ifndef TESTSCRIPTERUTILS_H_ +#define TESTSCRIPTERUTILS_H_ + +// INCLUDES +#include +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +typedef TBuf<0x200> TRemoteProtMsg; + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +class CTestRunner; +class CSubTestCaseRunner; +class CRemoteCallTimeoutMonitor; +class CStifTFwIfProt; +class CStifLogger; +class CSlave; +class CRemoteSubTestCaseRunner; + +// DESCRIPTION +// Testcase starting information +NONSHARABLE_CLASS(CStartInfo): public CBase + { + public: // Constructors and destructor + /** + * Two-phased constructor. + */ + static CStartInfo* NewL(); + + /** + * Destructor. + */ + virtual ~CStartInfo(); + + public: // New functions + /** + * Sets module name. + */ + void SetModuleNameL( const TDesC& aModule, TInt aExtLength = 0 ); + + /** + * Sets initialization file name. + */ + void SetIniFileL( const TDesC& aIni ); + + /** + * Sets configuration file name. + */ + void SetConfigL( const TDesC& aConfig ); + + /** + * Sets test identifier. + */ + void SetTestIdL( const TDesC& aTestId ); + + /** + * Sets test case title. + */ + void SetTitleL( const TDesC& aTitle); + + /** + * Sets test case index. + */ + void SetTestCaseNumber( TInt aTestCaseNumber ); + + /** + * Sets test case expected result. + */ + void SetExpectedResult( TInt aExpectedResult ); + + /** + * Sets expected result category. + */ + void SetExpectedResultCategory( TFullTestResult::TCaseExecutionResult aCategory ); + + /** + * Sets timeout value. + */ + void SetTimeout( TInt aTimeout ); + + /** + * Gets test module name. + */ + const TDesC& GetModuleName() const; + + /** + * Gets ini file path. + */ + const TDesC& GetIniFile() const; + + /** + * Gets config file path + */ + const TDesC& GetConfig() const; + + /** + * Gets test case id. + */ + const TDesC& GetTestId() const; + + /** + * Gets test case title. + */ + const TDesC& GetTitle() const; + + /** + * Gets test case title. + */ + TInt GetTestCaseNumber() const; + + /** + * Gets expected result. + */ + TInt GetExpectedResult() const; + + /** + * Gets expected result category. + */ + TFullTestResult::TCaseExecutionResult GetExpectedResultCategory() const; + + /** + * Gets timeout value. + */ + TInt GetTimeout() const; + + /** + * Copy values from other CStartInfo instance. + */ + void CopyL( const CStartInfo& aStartInfo ); + + private: + /** + * C++ default constructor. + */ + CStartInfo(); + + /** + * By default Symbian OS constructor is private. + */ + void ConstructL(); + + private: + // Module name + HBufC* iModule; + + // Ini file path + HBufC* iIniFile; + + // Config file path + HBufC* iConfig; + + // Test id ( used for complete, pausetest, reasume + HBufC* iTestId; + + // Title of the test case + HBufC* iTitle; + + // Test case index + TInt iCaseNum; + + // Test case expected result + TInt iExpectedResult; + + // Test case expected result category + TFullTestResult::TCaseExecutionResult iCategory; + + // Test case timeout value + TInt iTimeout; + }; + +// TestScripter loop helper +NONSHARABLE_CLASS(CLoopHelper): public CActive + { + public: + /** + * Two-phased constructor. + */ + static CLoopHelper* NewL( CTestRunner* aTestRunner ); + public: + /** + * Destrucktor. + */ + ~CLoopHelper(); + + /** + * Should be to indicate loop start. + */ + void LoopStartL(); + + /** + * Should be called to indicate end of iteration and begining of next iteration + */ + void IterationEndStartNextIterationL(); + + /** + * Should be called to indicate loop end + */ + void LoopEndL(); + + /** + * Should be called to register sub test case executed inside loop + */ + void RegisterInLoopSubTestCaseL( CSubTestCaseRunner* aSubTestCaseRunner ); + + /** + * Should be called to unregister sub test case executed inside loop + */ + void UnregisterInLoopSubTestCaseL( CSubTestCaseRunner* aSubTestCaseRunner ); + + /** + * Should be called to register remote event allocated inside loop + */ + void RegisterInLoopSlaveL( CSlave* aSlave ); + + /** + * Should be called to unregister remote event allocated inside loop + */ + void UnregisterInLoopSlaveL( CSlave* aSlave ); + + /** + * Returns array of registered in loop slaves. + */ + RPointerArray& GetRegisteredInLoopSlaves(); + + /** + * Should be called to indicate end of sub test case executed inside loop + */ + void NotifySubTestCaseEndL( CSubTestCaseRunner* aSubTestCaseRunner, TBool aPassed ); + + /** + * Indicates whether loop is in progress or not + */ + TBool LoopInProgress() const; + private: + /** + * Constructor + */ + CLoopHelper( CTestRunner* aTestRunner ); + + /** + * By default Symbian OS constructor is private. + */ + void ConstructL(); + + /** + * See CActive::DoCancel + */ + void DoCancel(); + + /** + * See CActive::Runl + */ + void RunL(); + + /** + * Indicate begining of the loop iteration + */ + void IterationBeginL( TBool aFirstIteration ); + + /** + * Indicate end of the loop iteration + */ + void IterationEndL( TBool aLastIteration ); + private: + // Pointer to CTestRunner + CTestRunner* iTestRunner; + + // Indicates whether loop is in progress + TBool iInProgress; + + // Indicates whether loop iteration is ongoing + TBool iIterationOngoing; + + // Indicates whether current iteration is last iteration + TBool iLoopEnd; + + // Counter of passed iterations + TInt iPassedIterationsCounter; + + // Indicates if current iteration should be count as passed or failed + TBool iPassCurrentIteration; + + // Array of sub test cases executed in loop + RPointerArray iInLoopSubTestCases; + + // Array of remote events allocated inside loop + RPointerArray iInLoopSlaves; + }; + +// TestScripter remote event wrapper +class TEventTS: public TEventIf + { + public: // Constructors and destructor + /** + * C++ default constructor. + */ + TEventTS(); + + /** + * C++ parametric constructor. + */ + TEventTS( TName& aEventName ); + + /** + * C++ destructor. + */ + ~TEventTS(); + + public: // New functions + + /** + * Set request status member. + */ + void SetRequestStatus( TRequestStatus* aStatus ); + + /** + * Set event pending. + */ + void SetEvent( TEventType aEventType ); + + /** + * Wait event. + */ + void WaitEvent( TRequestStatus& aStatus ); + + private: // New functions + /** + * Complete request status member. + */ + void Complete( TInt aError ); + + private: // Data + /** + * Request status. + */ + TRequestStatus* iClientReqStatus; + }; + +// Interface for classes which can handle errors which may occure during remote +// message receive +NONSHARABLE_CLASS( MReceiveErrorHandler ) + { + public: + /** + * Handle error which occured during remote message receive + */ + virtual void HandleRemoteReceiveError( + TInt aError, const TDesC& aErrorDescription ) = 0; + }; + +// Interface for classes which should be notified about remote allocate +// and free requests results +NONSHARABLE_CLASS( MSlaveAllocateFreeMonitor ) + { + public: + /** + * Notify slave is allocated + */ + virtual void NotifySlaveAllocatedL( TUint16 aSlaveId ) = 0; + + /** + * Notify slave is freed + */ + virtual void NotifySlaveFreedL( TUint16 aSlaveId ) = 0; + }; + +// Interface for classes which should be notified about results of remote test +// control requests +NONSHARABLE_CLASS( MRemoteTestCasesMonitor ) + { + public: + /** + * Notify test case has been started. + */ + virtual void NotifyTestCaseStartedL( TUint16 aSlaveId, TUint16 aSlaveTestId ) = 0; + + /** + * Notify test case can't be started. + */ + virtual void NotifyTestCaseRunErrorL( TUint16 aSlaveId, const TFullTestResult& aTestCaseResult ) = 0; + + /** + * Notify execution test case has finished + */ + virtual void NotifyTestCaseFinishedL( TUint16 aSlaveId, TUint16 aSlaveTestId, const TFullTestResult& aTestCaseResult ) = 0; + + /** + * Notify test case has been paused. + */ + virtual void NotifyTestCasePausedL( TUint16 aSlaveId, TUint16 aSlaveTestId ) = 0; + + /** + * Notify test case has been resumed. + */ + virtual void NotifyTestCaseResumedL( TUint16 aSlaveId, TUint16 aSlaveTestId ) = 0; + + /** + * Notify test case has been cancelled. + */ + virtual void NotifyTestCaseCancelledL( TUint16 aSlaveId, TUint16 aSlaveTestId ) = 0; + }; + +// Interface for classes which should be notified about results of remote events +// control requests. +NONSHARABLE_CLASS( MRemoteEventsMonitor ) + { + public: + /** + * Notify remote event has been requested + */ + virtual void NotifyEventRequestedL( TUint16 aSlaveId, + const TDesC& aEventName, + CStifTFwIfProt::TEventStatus aEventStatus, + TEventIf::TEventType aEventType, + TInt aResult ) = 0; + + /** + * Notify remote event state has changed + */ + virtual void NotifyEventStateChangedL( TUint16 aSlaveId, + const TDesC& aEventName, + CStifTFwIfProt::TEventStatus aEventStatus, + TEventIf::TEventType aEventType, + TInt aResult ) = 0; + + /** + * Notify remote event has been released + */ + virtual void NotifyEventReleasedL( TUint16 aSlaveId, + const TDesC& aEventName, TInt aResult ) = 0; + + /** + * Notify remote event has been sucessfully set + */ + virtual void NotifyEventSetCompletedL( TUint16 aSlaveId, + const TDesC& aEventName, TInt aResult ) = 0; + + /** + * Notify remote event has been sucessfully unset + */ + virtual void NotifyEventUnsetCompletedL( TUint16 aSlaveId, + const TDesC& aEventName, TInt aResult ) = 0; + }; + +// Interface for classes which should be notified about results of sendreceive +// and send unknown requests +NONSHARABLE_CLASS( MRemoteSendReceiveMonitor ) + { + public: + /** + * Notify sendreceive request has been started + */ + virtual void NotifySendReceiveStartedL( TUint16 aSlaveId ) = 0; + + /** + * Notify sendreceive request has finished + */ + virtual void NotifySendReceiveResultL( + TUint16 aSlaveId, + CStifTFwIfProt::TRunStatus aRunStatus, + TInt aRunResult ) = 0; + + /** + * Notify send unknown request has finished + */ + virtual void NotifySendUnknownL( TUint16 aSlaveId, TInt aResult ) = 0; + }; + +// This class creates, execute and recive respons for master-slave requests +NONSHARABLE_CLASS( CRemoteCallsProxy ): public CActive + { + public: + /** + * Two phase constructor. + */ + static CRemoteCallsProxy* NewL( CTestModuleIf& aTestModuleIf, CStifLogger* aLogger ); + public: + /** + * Destructor. + */ + ~CRemoteCallsProxy(); + + /** + * Sends slave allocate request. + */ + void AllocateL( TUint32 aMasterId, const TDesC& aType ); + + /** + * Sends slave free request. + */ + void FreeL( TUint32 aMasterId, TUint16 aSlaveId ); + + /** + * Sends sendreceive request. + */ + void SendReceiveL( TUint32 aMasterId, TUint16 aSlaveId, const TDesC& aMessage ); + + /** + * Sends unknown request + */ + void SendUnknownL( TUint32 aMasterId, TUint16 aSlaveId, + const TDesC& aCommand, const TDesC& aMessage ); + + /** + * Sends start test case request. + */ + void RunTestCaseL( TUint32 aMasterId, TUint16 aSlaveId, CStartInfo* aStartInfo ); + + /** + * Sends pause test case request. + */ + void PauseTestCaseL( TUint32 aMasterId, TUint16 aSlaveId, TUint16 aTestId ); + + /** + * Sends resume test case request. + */ + void ResumeTestCaseL( TUint32 aMasterId, TUint16 aSlaveId, TUint16 aTestId ); + + /** + * Sends cancel test case request. + */ + void CancelTestCaseL( TUint32 aMasterId, TUint16 aSlaveId, TUint16 aTestId ); + + /** + * Sends request event request. + */ + void RequestEventL( TUint32 aMasterId, TUint16 aSlaveId, const TDesC& aEventName ); + + /** + * Sends set event request. + */ + void SetEventL( TUint32 aMasterId, TUint16 aSlaveId, const TDesC& aEventName, + TEventIf::TEventType aEventType = TEventIf::EIndication ); + + /** + * Sends unset event request. + */ + void UnsetEventL( TUint32 aMasterId, TUint16 aSlaveId, const TDesC& aEventName ); + + /** + * Sends release event request. + */ + void ReleaseEventL( TUint32 aMasterId, TUint16 aSlaveId, const TDesC& aEventName ); + + /** + * Sets slave allocate/free requests notyfications handler. + */ + void SetSlaveAllocateFreeMonitor( MSlaveAllocateFreeMonitor* aSlaveAllocateFreeMonitor ); + + /** + * Sets remote test case control requests notyfications handler. + */ + void SetRemoteTestCasesMonitor( MRemoteTestCasesMonitor* aRemoteTestCasesMonitor ); + + /** + * Sets remote events control requests notyfications handler. + */ + void SetRemoteEventsMonitor( MRemoteEventsMonitor* aRemoteEventssMonitor ); + + /** + * Sets remote sendreceive request notyfications handler. + */ + void SetRemoteSendReceiveMonitor( MRemoteSendReceiveMonitor* aRemoteSendReceiveMonitor ); + + /** + * Sets remote respones receive error handler. + */ + void SetReceiveErrorHandler( MReceiveErrorHandler* aReceiveErrorHandler ); + + private: + /** + * Constructor. + */ + CRemoteCallsProxy( CTestModuleIf& aTestModuleIf, CStifLogger* aLogger ); + + /** + * Second phase of two phase construction. + */ + void ConstructL(); + + /** + * Cancels remote responses receiving. + */ + void DoCancel(); + + /** + * Handlers remote request respons + */ + void RunL(); + + /** + * Handles errors during remote request response dispatching + */ + TInt RunError( TInt aError ); + + /** + * Starts remote requests respons receiving. + */ + void StartReceivingL(); + + /** + * Dispatches received remote request response. + */ + void DispatchReceivedRemoteMsgL(); + + /** + * Handles slave reserve request response. + */ + void ReceiveResponseReserveL( CStifTFwIfProt* aMsg ); + + /** + * Handles slave release request response. + */ + void ReceiveResponseReleaseL( CStifTFwIfProt* aMsg ); + + /** + * Handles remote test case run request response. + */ + void ReceiveResponseRunL( CStifTFwIfProt* aMsg ); + + /** + * Handles remote test case control request response. + */ + void ReceiveResponseTestCtlL( CStifTFwIfProt* aMsg ); + + /** + * Handles remote event control request response. + */ + void ReceiveResponseEventCtlL( CStifTFwIfProt* aMsg ); + + /** + * Handles remote sendreceive request response. + */ + void ReceiveResponseSendReceiveL( CStifTFwIfProt* aMsg ); + + /** + * Handles remote send unknown request response. + */ + void ReceiveResponseSendUnknownL( CStifTFwIfProt* aMsg ); + private: + // Pointer to STF looger + CStifLogger* iLogger; + + // TestModuleIf used to send master-slave requests + CTestModuleIf& iTestModuleIf; + + // Buffer for remote request response + TRemoteProtMsg iReceivedRemoteMsg; + + // Buffer for error description + TBuf<256> iReceiveErrorDescription; + + // Pointer to slave allocate/free monitor + MSlaveAllocateFreeMonitor* iSlaveAllocateFreeMonitor; + + // Pointer to test case control requests monitor + MRemoteTestCasesMonitor* iRemoteTestCasesMonitor; + + // Pointer to events control requests monitor + MRemoteEventsMonitor* iRemoteEventsMonitor; + + // Pointer to send/receive requests monitor + MRemoteSendReceiveMonitor* iRemoteSendReceiveMonitor; + + // Pointer to receive error handler + MReceiveErrorHandler* iReceiveErrorHandler; + }; + +// This class contains most important informations about allocated slave device +NONSHARABLE_CLASS( CSlave ): public CBase + { + public: + /** + * Two phase constructor. + */ + static CSlave* NewL(); + + /** + * Destructor. + */ + ~CSlave(); + + /** + * Returns slave name. + */ + const TDesC& GetName() const; + + /** + * Sets slave name. + */ + void SetNameL( const TDesC& aName ); + + /** + * Returns slave master's id. + */ + TUint32 GetMasterId() const; + + /** + * Sets slave master's id + */ + void SetMasterId( TUint32 aMasterId ); + + /** + * Returns slave's id. + */ + TUint16 GetSlaveId() const; + + /** + * Sets slave's id. + */ + void SetSlaveId( TUint16 aSlaveId ); + + /** + * Returns true if slave has running remote sub test cases. + */ + TBool HasRunningTestCases() const; + + /** + * Register slave remote sub test case. + */ + void RegisterSubTestCaseL( CRemoteSubTestCaseRunner* aSubTestCase ); + + /** + * Unregister slave remote sub test case. + */ + void UnregisterSubTestCaseL( CRemoteSubTestCaseRunner* aSubTestCase ); + + /** + * Returns list of slave remote sub test cases. + */ + RPointerArray& GetSubTestCases(); + + /** + * Waits until all running slave remote sub test cases finis. + */ + void WaitForSubTestCasesL(); + + /** + * Cancel WaitForSubTestCasesL call. + */ + void CancelWaitForSubTestCases(); + + /** + * Register slave remote event. + */ + void AddEventL( TEventTS* aEvent ); + + /** + * Unregister slave remote event. + */ + void RemoveEventL( TEventTS* aEvent ); + + /** + * Returns selected slave remote event. + */ + TEventTS* GetEvent( const TDesC& aName ); + + RPointerArray& GetEvents(); + private: + /** + * Constructor. + */ + CSlave(); + + /** + * Second phase of two phase construction. + */ + void ConstructL(); + private: + /** + * Slave's name. + */ + HBufC* iName; + + /** + * Slave's master id. + */ + TUint32 iMasterId; + + /** + * Slave's id. + */ + TUint16 iSlaveId; + + /** + * List of slave's remote sub test cases. + */ + RPointerArray iSubTestCases; + + /** + * List of slave's remote events. + */ + RPointerArray iEvents; + + /** + * nested active scheduler loop used to wait for running remote sub + * test cases finis. + */ + CActiveSchedulerWait* iNestedASLoop; + }; + +// Manages slaves and wraps most of the master-slave communication +NONSHARABLE_CLASS( CSlavesManager ): + protected CActive, + private MSlaveAllocateFreeMonitor, + private MRemoteTestCasesMonitor, + private MRemoteEventsMonitor, + private MRemoteSendReceiveMonitor, + private MReceiveErrorHandler + { + private: + /** + * Types of internal CSlavesManager states. + */ + enum TSlavesManagerOperation { + ESMOIdle, + ESMOSlaveAllocate, + ESMOSlaveFree, + ESMOEventRequest, + ESMOEventRelease, + ESMOEventSet, + ESMOEventUnset, + ESMOSendReceiveWaitForStarted, + ESMOSendReceiveWaitForReady, + ESMOSendUnknown, + }; + public: + /** + * Two phase constructor. + */ + static CSlavesManager* NewL( CTestRunner* aTestRunner, CTestModuleIf& aTestModuleIf ); + + /** + * Destructor. + */ + ~CSlavesManager(); + + /** + * Allocates slave device. + */ + void SlaveAllocateL( const TDesC& aName, const TDesC& aType ); + + /** + * Frees slave device. + */ + void SlaveFreeL( const TDesC& aName ); + + /** + * Send remote command. + */ + void SendReceiveL( CSlave* aSlave, const TDesC& aMessage ); + + /** + * Send command not specified in STF master-slave protocol + */ + void SendUnknownL( CSlave* aSlave, const TDesC& aCommand, const TDesC& aMessage ); + + /** + * Returns selected slave device wrapper object. + */ + CSlave* GetSlave( const TDesC& aName ); + + /** + * Returns selected slave device wrapper object. + */ + CSlave* GetSlave( TUint16 aSlaveId ); + + RPointerArray& GetSlaves(); + + /** + * Requests specified event from slave device + */ + void EventRequestL( CSlave* aSlave, TEventTS* aEvent ); + + /** + * Releases selected remote event. + */ + void EventReleaseL( CSlave* aSlave, const TDesC& aEventName ); + + /** + * Sets remote event. + */ + void EventSetL( CSlave* aSlave, const TDesC& aEventName, TEventIf::TEventType aEventType ); + + /** + * Unsets remote event + */ + void EventUnsetL( CSlave* aSlave, const TDesC& aEventName ); + + /** + * Returns CRemoteCallsProxy used in master-slave communication. + */ + CRemoteCallsProxy* GetRemoteCallsProxy(); + + private: + /** + * Constructor. + */ + CSlavesManager( CTestRunner* aTestRunner, CTestModuleIf& aTestModuleIf ); + + /** + * Second phase of two phase construction. + */ + void ConstructL(); + + /** + * Handles operation timeout event. + */ + void RunL(); + + /** + * Cancels operation timeout monitor. + */ + void DoCancel(); + + /** + * Notify slave is allocated + */ + void NotifySlaveAllocatedL( TUint16 aSlaveId ); + + /** + * Notify slave is freed + */ + void NotifySlaveFreedL( TUint16 aSlaveId ); + + /** + * Notify test case has been started. + */ + void NotifyTestCaseStartedL( TUint16 aSlaveId, TUint16 aSlaveTestId ); + + /** + * Notify test case can't be started. + */ + void NotifyTestCaseRunErrorL( TUint16 aSlaveId, + const TFullTestResult& aTestCaseResult ); + + /** + * Notify execution test case has finished + */ + void NotifyTestCaseFinishedL( TUint16 aSlaveId, TUint16 aSlaveTestId, + const TFullTestResult& aTestCaseResult ); + + /** + * Notify test case has been paused. + */ + void NotifyTestCasePausedL( TUint16 aSlaveId, TUint16 aSlaveTestId ); + + /** + * Notify test case has been resumed. + */ + void NotifyTestCaseResumedL( TUint16 aSlaveId, TUint16 aSlaveTestId ); + + /** + * Notify test case has been cancelled. + */ + void NotifyTestCaseCancelledL( TUint16 aSlaveId, TUint16 aSlaveTestId ); + + /** + * Notify remote event has been requested + */ + void NotifyEventRequestedL( TUint16 aSlaveId, + const TDesC& aEventName, + CStifTFwIfProt::TEventStatus aEventStatus, + TEventIf::TEventType aEventType, + TInt aResult ); + + /** + * Notify remote event state has changed + */ + void NotifyEventStateChangedL( TUint16 aSlaveId, + const TDesC& aEventName, + CStifTFwIfProt::TEventStatus aEventStatus, + TEventIf::TEventType aEventType, + TInt aResult ); + + /** + * Notify remote event has been released + */ + void NotifyEventReleasedL( TUint16 aSlaveId, + const TDesC& aEventName, TInt aResult ); + + /** + * Notify remote event has been sucessfully set + */ + void NotifyEventSetCompletedL( TUint16 aSlaveId, + const TDesC& aEventName, TInt aResult ); + + /** + * Notify remote event has been sucessfully unset + */ + void NotifyEventUnsetCompletedL( TUint16 aSlaveId, + const TDesC& aEventName, TInt aResult ); + + /** + * Notify sendreceive request has been started + */ + void NotifySendReceiveStartedL( TUint16 aSlaveId ); + + /** + * Notify sendreceive request has finished + */ + void NotifySendReceiveResultL( + TUint16 aSlaveId, + CStifTFwIfProt::TRunStatus aRunStatus, + TInt aRunResult ); + + /** + * Notify send unknown request has finished + */ + void NotifySendUnknownL( TUint16 aSlaveId, TInt aResult ); + + /** + * Handle error which occured during remote message receive + */ + void HandleRemoteReceiveError( TInt aError, const TDesC& aErrorDescription ); + + private: + // Indicates currently performed operation + TSlavesManagerOperation iOperation; + + // Contains last operation result + TInt iLastOperationResult; + + // Pointer to CTestRunner object + CTestRunner* iTestRunner; + + // TestModuleIf used by CRemoteCallsProxy in master-slave communication + CTestModuleIf& iTestModuleIf; + + // CRemoteCallsProxy used in master-slave communication + CRemoteCallsProxy* iRemoteCallsProxy; + + // Array of allocated slave devices + RPointerArray iSlaves; + + // Temporary field used during slave device allocation + CSlave* iSlaveForAllocate; + + // Temporary field used during event request + TEventTS* iEventForRequest; + + // Operation timeout + TTimeIntervalMicroSeconds32 iOperationTimeout; + + // Operation timeout timer + RTimer iOperationTimeoutTimer; + + // Nested active scheduler loop used to block CSlavesManager methods + // execution until respons for selected request is received + CActiveSchedulerWait* iNestedASLoop; + }; + +#endif /* TESTSCRIPTERUTILS_H_ */ diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/scriptermod/src/SubTestCaseRunner.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/scriptermod/src/SubTestCaseRunner.cpp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,950 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains TestScripter implementation. +* +*/ + +// INCLUDE FILES +#include "SubTestCaseRunner.h" +#include +#include "TestScripter.h" +#include "Logging.h" +// EXTERNAL DATA STRUCTURES +// None + +// EXTERNAL FUNCTION PROTOTYPES +// None + +// CONSTANTS +// None + +// MACROS +#ifdef LOGGER +#undef LOGGER +#endif +#define LOGGER iTestRunner->GetLogger() + +// LOCAL CONSTANTS AND MACROS +// None + +// MODULE DATA STRUCTURES +// None + +// LOCAL FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +// None + +// ==================== LOCAL FUNCTIONS ======================================= + +// ================= MEMBER FUNCTIONS ========================================= + +/* +------------------------------------------------------------------------------- + + Class: CSubTestCaseRunner + + Method: CSubTestCaseRunner + + Description: Constructor + + Constructor. + + Parameters: CTestRunner* aTestRunner : in: Pointer to test runner which + should be notified about test case end + + Return Values: None + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +CSubTestCaseRunner::CSubTestCaseRunner() +:CActive( EPriorityStandard ), iState( ESTSIdle ) + { + } + +CSubTestCaseRunner::TSubTestCaseState CSubTestCaseRunner::GetState() const + { + return iState; + } + + +/* +------------------------------------------------------------------------------- + + Class: CLocalSubTestCaseRunner + + Method: NewLC + + Description: Two-phased constructor. + + Two-phased constructor. + + Parameters: CTestRunner* aTestRunner : in: Pointer to test runner which + should be notified about test case end + + Return Values: Pointer to newly created CLocalSubTestCaseRunner object. + + Errors/Exceptions: Leaves if there is some problem during method execution + + Status: Draft + +------------------------------------------------------------------------------- +*/ +CLocalSubTestCaseRunner* CLocalSubTestCaseRunner::NewLC( CTestRunner* aTestRunner ) + { + CLocalSubTestCaseRunner* self = new(ELeave)CLocalSubTestCaseRunner( aTestRunner ); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + +/* +------------------------------------------------------------------------------- + + Class: CLocalSubTestCaseRunner + + Method: NewL + + Description: Two-phased constructor. + + Two-phased constructor. + + Parameters: CTestRunner* aTestRunner : in: Pointer to test runner which + should be notified about test case end + + Return Values: Pointer to newly created CLocalSubTestCaseRunner object. + + Errors/Exceptions: Leaves if there is some problem during method execution + + Status: Draft + +------------------------------------------------------------------------------- +*/ +CLocalSubTestCaseRunner* CLocalSubTestCaseRunner::NewL( CTestRunner* aTestRunner ) + { + CLocalSubTestCaseRunner* self = NewL( aTestRunner ); + CleanupStack::Pop( self ); + return self; + } + +/* +------------------------------------------------------------------------------- + + Class: CLocalSubTestCaseRunner + + Method: CLocalSubTestCaseRunner + + Description: Destructor + + Destructor + + Parameters: none + + Return Values: none + + Errors/Exceptions: none + + Status: Draft + +------------------------------------------------------------------------------- +*/ +CLocalSubTestCaseRunner::~CLocalSubTestCaseRunner() + { + CancelSubTestCaseL(); + + delete iStartInfo; + iTestCase.Close(); + iTestEngine.Close(); + } + +/* +------------------------------------------------------------------------------- + + Class: CLocalSubTestCaseRunner + + Method: CLocalSubTestCaseRunner + + Description: Constructor + + Constructor. + + Parameters: CTestRunner* aTestRunner : in: Pointer to test runner which + should be notified about test case end + + Return Values: None + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +CLocalSubTestCaseRunner::CLocalSubTestCaseRunner( CTestRunner* aTestRunner ) +:iTestRunner( aTestRunner ), iResultPckg( iResult ) + { + CActiveScheduler::Add( this ); + } + +/* +------------------------------------------------------------------------------- + + Class: CLocalSubTestCaseRunner + + Method: ConstructL + + Description: Second phase of two-phased constructor. + + Second phase of two-phased constructor. + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CLocalSubTestCaseRunner::ConstructL() + { + } + +/* +------------------------------------------------------------------------------- + + Class: CLocalSubTestCaseRunner + + Method: NewL + + Description: Handles test case execution end. + + Handles test case execution end and pass test case execution result to + proper CTestCaseRunner. + + Parameters: None + + Return Values: None + + Errors/Exceptions: Leaves if there is some problem during method execution + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CLocalSubTestCaseRunner::RunL() + { + // Store run result + iRunResult = iStatus.Int(); + + iTestCase.Close(); + iTestEngine.Close(); + + iState = ESTSIdle; + + // Report sub test case result to CTestRunner + iTestRunner->SubTestCaseFinishedL( this ); + } + +/* +------------------------------------------------------------------------------- + + Class: CLocalSubTestCaseRunner + + Method: DoCancel + + Description: Cancels test case execution + + Cancels test case execution + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CLocalSubTestCaseRunner::DoCancel() + { + TInt ret = iTestCase.CancelAsyncRequest( RTestCase::ERunTestCase ); + if ( ret != KErrNone ) + { + // There was some error during sub test case cancel + // Only put message to log. + __TRACE( KMessage, ( _L( "Unexpected error during sub test case testid=%S cancel." ), &iStartInfo->GetTestId() ) ); + } + + iTestCase.Close(); + iTestEngine.Close(); + + // Mart test case as canceled + iResult.iTestResult.SetResult( KErrNone, KNullDesC ); + iResult.iCaseExecutionResultCode = KErrCancel; + iResult.iCaseExecutionResultType = TFullTestResult::ECaseCancelled; + iState = ESTSIdle; + } + +/* +------------------------------------------------------------------------------- + + Class: CLocalSubTestCaseRunner + + Method: RunSubTestCaseL + + Description: Starts test case execution. + + Starts test case execution. + + Parameters: CStartInfo* aStartInfo : in: Pointer to structure which hold + information about test case which should be executed. + + Return Values: None + + Errors/Exceptions: Leaves if there is some problem during method execution + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CLocalSubTestCaseRunner::RunSubTestCaseL( CStartInfo& aStartTestCaseInfo ) + { + // Check if this AO is already running some sub test case + if ( IsActive() ) + { + User::Leave( KErrInUse ); + } + + // Reset runner internal state + Reset(); + + // Copy sub test case startup information + CStartInfo* startInfo = CStartInfo::NewL(); + CleanupStack::PushL( startInfo ); + startInfo->CopyL( aStartTestCaseInfo ); + CleanupStack::Pop( startInfo ); + iStartInfo = startInfo; + + // Connect to TestEngine + TInt ret = iTestEngine.Connect(); + if ( ret != KErrNone ) + { + User::Leave( ret ); + } + + // Initialize TestEngine session + CleanupClosePushL( iTestEngine ); + ret = iTestEngine.LoadConfiguration( KNullDesC() ); + if ( ret != KErrNone ) + { + User::Leave( ret ); + } + + // Load selected test module with specified ini file + ret = iTestEngine.AddTestModule( iStartInfo->GetModuleName(), + iStartInfo->GetIniFile() ); + if ( ret != KErrNone ) + { + User::Leave( ret ); + } + + // Set optional cfg file + if ( iStartInfo->GetConfig() != KNullDesC ) + { + ret = iTestEngine.AddConfigFile( iStartInfo->GetModuleName(), + iStartInfo->GetConfig() ); + if ( ret != KErrNone ) + { + User::Leave( ret ); + } + } + + // Get list of available test cases from test engine + TRequestStatus enumerationRequestStatus; + TCaseCount testCasesCount; + iTestEngine.EnumerateTestCases( testCasesCount, enumerationRequestStatus ); + User::WaitForRequest( enumerationRequestStatus ); + if ( enumerationRequestStatus.Int() != KErrNone ) + { + User::Leave( enumerationRequestStatus.Int() ); + } + + CFixedFlatArray* testCasesList = CFixedFlatArray::NewL( testCasesCount() ); + CleanupStack::PushL( testCasesList ); + + ret = iTestEngine.GetTestCases( *testCasesList ); + if ( ret != KErrNone ) + { + User::Leave( ret ); + } + + // Find requested test case in test cases enumerated from TestEngine + TBool findByTitle = ( iStartInfo->GetTitle() != KNullDesC ); + TTestInfo testInfo; + TBool foundTestCase = EFalse; + if ( findByTitle ) + { + iStartInfo->SetTestCaseNumber( -1 ); + } + for ( TInt i = 0; i < testCasesList->Count(); i++ ) + { + if ( ( findByTitle && ( (*testCasesList)[ i ].iTestCaseInfo.iTitle == iStartInfo->GetTitle() ) ) || + ( (*testCasesList)[ i ].iTestCaseInfo.iCaseNumber == iStartInfo->GetTestCaseNumber() ) ) + { + testInfo = (*testCasesList)[ i ]; + foundTestCase = ETrue; + } + } + + // Store test case title + iStartInfo->SetTitleL( testInfo.iTestCaseInfo.iTitle ); + + // Check if requested test case is availabe or not + if ( !foundTestCase ) + { + User::Leave( KErrNotFound ); + } + + CleanupStack::PopAndDestroy( testCasesList ); + + // Open test case subsession + TTestInfoPckg testInfoPckg( testInfo ); + ret = iTestCase.Open( iTestEngine, testInfoPckg ); + if ( ret != KErrNone ) + { + User::Leave( ret ); + } + + // Run sub test case + CleanupClosePushL( iTestCase ); + iTestCase.RunTestCase( iResultPckg, iStatus ); + SetActive(); + CleanupStack::Pop(); // Remove iTestCase from cleanup stack + CleanupStack::Pop(); // Remove iTestEngine from cleanup stack + iState = ESTSRunning; + } + +/* +------------------------------------------------------------------------------- + + Class: CLocalSubTestCaseRunner + + Method: PauseSubTestCaseL + + Description: Pauses selected sub test case. + + Pauses selected sub test case. + + Parameters: None + + Return Values: None + + Errors/Exceptions: Leaves if sub test case is not running + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CLocalSubTestCaseRunner::PauseSubTestCaseL() + { + // Check if sub test case is running + if ( !IsActive() ) + { + User::Leave( KErrNotReady ); + } + + User::LeaveIfError( iTestCase.Pause() ); + iState = ESTSPaused; + } + +/* +------------------------------------------------------------------------------- + + Class: CLocalSubTestCaseRunner + + Method: ReasumeSubTestCaseL + + Description: Reasume selected sub test case. + + Reasume selected sub test case. + + Parameters: None + + Return Values: None + + Errors/Exceptions: Leaves if sub test case is not running + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CLocalSubTestCaseRunner::ResumeSubTestCaseL() + { + // Check if sub test case is running + if ( !IsActive() ) + { + User::Leave( KErrNotReady ); + } + + User::LeaveIfError( iTestCase.Resume() ); + iState = ESTSRunning; + } + +void CLocalSubTestCaseRunner::CancelSubTestCaseL() + { + Cancel(); + } + + +/* +------------------------------------------------------------------------------- + + Class: CLocalSubTestCaseRunner + + Method: Reset + + Description: Resets sub test case runner internal state. + + Resets sub test case runner internal state. + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CLocalSubTestCaseRunner::Reset() + { + delete iStartInfo; + iStartInfo = NULL; + + iRunResult = KErrNone; + + iResult.iCaseExecutionResultCode = KErrNone; + iResult.iCaseExecutionResultType = TFullTestResult::ECaseOngoing; + iResult.iTestResult.SetResult( KErrNone, KNullDesC ); + + iState = ESTSIdle; + } + +/* +------------------------------------------------------------------------------- + + Class: CLocalSubTestCaseRunner + + Method: GetRunResult + + Description: Returns execution result. + + Returns execution result. + + Parameters: None + + Return Values: Execution result + + Errors/Exceptions: + + Status: Draft + +------------------------------------------------------------------------------- +*/ +TInt CLocalSubTestCaseRunner::GetRunResult() const + { + return iRunResult; + } + +/* +------------------------------------------------------------------------------- + + Class: CLocalSubTestCaseRunner + + Method: GetTestCaseResult + + Description: Returns test case execution result. + + Returns test case execution result. + + Parameters: None + + Return Values: Test case execution result. + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +const TFullTestResult& CLocalSubTestCaseRunner::GetTestCaseResult() const + { + return iResult; + } + +/* +------------------------------------------------------------------------------- + + Class: CLocalSubTestCaseRunner + + Method: GetStartInfo + + Description: Returns informations about started test case. + + Returns informations about started test case. + + Parameters: None + + Return Values: Returns information about started test case. + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +const CStartInfo* CLocalSubTestCaseRunner::GetStartInfo() const + { + return iStartInfo; + } + +CSubTestCaseRunner::TSubTestCaseType CLocalSubTestCaseRunner::GetType() const + { + return ESTTLocal; + } + + + + +CRemoteSubTestCaseRunner* CRemoteSubTestCaseRunner::NewL( CTestRunner* aTestRunner, + CSlave* aSlave, CRemoteCallsProxy* aRemoteCallsProxy ) + { + CRemoteSubTestCaseRunner* self = new(ELeave)CRemoteSubTestCaseRunner( + aTestRunner, aSlave, aRemoteCallsProxy ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +CRemoteSubTestCaseRunner* CRemoteSubTestCaseRunner::NewLC( CTestRunner* aTestRunner, + CSlave* aSlave, CRemoteCallsProxy* aRemoteCallsProxy ) + { + CRemoteSubTestCaseRunner* self = new(ELeave)CRemoteSubTestCaseRunner( + aTestRunner, aSlave, aRemoteCallsProxy ); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + +CRemoteSubTestCaseRunner::~CRemoteSubTestCaseRunner() + { + Cancel(); + + iTimeoutTimer.Close(); + + delete iNestedASLoop; + iNestedASLoop = NULL; + + delete iStartInfo; + iStartInfo = NULL; + + TRAPD( err, iSlave->UnregisterSubTestCaseL( this ) ); + if ( err != KErrNone ) + { + RDebug::Print( _L("Unexpected error during slave subtestcase deregistration %d"), err ); + } + } + +void CRemoteSubTestCaseRunner::RunSubTestCaseL( CStartInfo& aStartTestCaseInfo ) + { + // Check if this AO is already running some sub test case + if ( IsActive() || ( iState != ESTSIdle ) ) + { + User::Leave( KErrInUse ); + } + + // Reset runner internal state + Reset(); + + // Copy sub test case startup information + CStartInfo* startInfo = CStartInfo::NewL(); + CleanupStack::PushL( startInfo ); + startInfo->CopyL( aStartTestCaseInfo ); + CleanupStack::Pop( startInfo ); + iStartInfo = startInfo; + + // Connect to TestEngine + iRemoteCallsProxy->RunTestCaseL( iSlave->GetMasterId(), iSlave->GetSlaveId(), iStartInfo ); + + iCurrentOperation = ECORunSubtestCase; + + iTimeoutTimer.After( iStatus, iOperationTimeout ); + SetActive(); + + iNestedASLoop->Start(); + + User::LeaveIfError( iOperationResult ); + iState = ESTSRunning; + } + +void CRemoteSubTestCaseRunner::PauseSubTestCaseL() + { + // Check if sub test case is running + if ( IsActive() || ( iState != ESTSRunning ) ) + { + User::Leave( KErrNotReady ); + } + + iRemoteCallsProxy->PauseTestCaseL( iSlave->GetMasterId(), iSlave->GetSlaveId(), iTestCaseId ); + + iCurrentOperation = ECOPauseSubtestCase; + + iTimeoutTimer.After( iStatus, iOperationTimeout ); + SetActive(); + + iNestedASLoop->Start(); + + User::LeaveIfError( iOperationResult ); + iState = ESTSPaused; + } + +void CRemoteSubTestCaseRunner::ResumeSubTestCaseL() + { + // Check if sub test case is running + if ( IsActive() || ( iState != ESTSPaused ) ) + { + User::Leave( KErrNotReady ); + } + + iRemoteCallsProxy->ResumeTestCaseL( iSlave->GetMasterId(), iSlave->GetSlaveId(), iTestCaseId ); + + iCurrentOperation = ECOResumeSubtestCase; + + iTimeoutTimer.After( iStatus, iOperationTimeout ); + SetActive(); + + iNestedASLoop->Start(); + + User::LeaveIfError( iOperationResult ); + iState = ESTSRunning; + } + +void CRemoteSubTestCaseRunner::CancelSubTestCaseL() + { + // Check if sub test case is running + if ( IsActive() || ( iState != ESTSIdle ) ) + { + User::Leave( KErrNotReady ); + } + + iRemoteCallsProxy->CancelTestCaseL( iSlave->GetMasterId(), iSlave->GetSlaveId(), iTestCaseId ); + + iCurrentOperation = ECOCancelSubtestCase; + + iTimeoutTimer.After( iStatus, iOperationTimeout ); + SetActive(); + + iNestedASLoop->Start(); + + User::LeaveIfError( iOperationResult ); + + iRunResult = KErrCancel; + // Mart test case as canceled + iResult.iTestResult.SetResult( KErrNone, KNullDesC ); + iResult.iCaseExecutionResultCode = KErrCancel; + iResult.iCaseExecutionResultType = TFullTestResult::ECaseCancelled; + + iState = ESTSIdle; + } + +TInt CRemoteSubTestCaseRunner::GetRunResult() const + { + return iRunResult; + } + +const TFullTestResult& CRemoteSubTestCaseRunner::GetTestCaseResult() const + { + return iResult; + } + +const CStartInfo* CRemoteSubTestCaseRunner::GetStartInfo() const + { + return iStartInfo; + } + +CSubTestCaseRunner::TSubTestCaseType CRemoteSubTestCaseRunner::GetType() const + { + return ESTTRemote; + } + +CRemoteSubTestCaseRunner::CRemoteSubTestCaseRunner( CTestRunner* aTestRunner, + CSlave* aSlave, CRemoteCallsProxy* aRemoteCallsProxy ) +:iTestRunner( aTestRunner ), iSlave( aSlave ), + iRemoteCallsProxy( aRemoteCallsProxy ), iOperationTimeout( 30000000 ) + { + CActiveScheduler::Add( this ); + } + +void CRemoteSubTestCaseRunner::ConstructL() + { + User::LeaveIfError( iTimeoutTimer.CreateLocal() ); + iNestedASLoop = new(ELeave)CActiveSchedulerWait; + iSlave->RegisterSubTestCaseL( this ); + } + +void CRemoteSubTestCaseRunner::RunL() + { + // Test case timeouted. + iCurrentOperation = ECONone; + iOperationResult = KErrTimedOut; + iNestedASLoop->AsyncStop(); + } + +void CRemoteSubTestCaseRunner::DoCancel() + { + if ( GetState() == ESTSRunning ) + { + TRAPD( err, CancelSubTestCaseL() ); + if ( err != KErrNone ) + { + RDebug::Print( _L("Unexpected error during slave subtestcase cancel %d"), err ); + } + } + + iTimeoutTimer.Cancel(); + } + +void CRemoteSubTestCaseRunner::Reset() + { + delete iStartInfo; + iStartInfo = NULL; + iTestCaseId = 0; + iRunResult = 0; + iResult = TFullTestResult(); + } + +CSlave* CRemoteSubTestCaseRunner::GetSlave() + { + return iSlave; + } + +TUint16 CRemoteSubTestCaseRunner::GetTestCaseId() const + { + return iTestCaseId; + } + +void CRemoteSubTestCaseRunner::NotifyTestCaseStartedL( TUint16 aTestCaseId ) + { + if ( !iNestedASLoop->IsStarted() || ( iCurrentOperation != ECORunSubtestCase ) ) + { + User::Leave( KErrNotReady ); + } + + iTestCaseId = aTestCaseId; + + Cancel(); + + iNestedASLoop->AsyncStop(); + iCurrentOperation = ECONone; + iOperationResult = KErrNone; + } + +void CRemoteSubTestCaseRunner::NotifyTestCaseRunError( const TFullTestResult& aTestCaseResult ) + { + if ( !iNestedASLoop->IsStarted() || ( iCurrentOperation != ECORunSubtestCase ) ) + { + User::Leave( KErrNotReady ); + } + + Cancel(); + + iResult = aTestCaseResult; + + iNestedASLoop->AsyncStop(); + iCurrentOperation = ECONone; + iOperationResult = iResult.iCaseExecutionResultCode; + } + +void CRemoteSubTestCaseRunner::NotifyTestCasePausedL() + { + if ( !iNestedASLoop->IsStarted() || ( iCurrentOperation != ECOPauseSubtestCase ) ) + { + User::Leave( KErrNotReady ); + } + + Cancel(); + + iNestedASLoop->AsyncStop(); + iCurrentOperation = ECONone; + iOperationResult = KErrNone; + } + +void CRemoteSubTestCaseRunner::NotifyTestCaseResumedL() + { + if ( !iNestedASLoop->IsStarted() || ( iCurrentOperation != ECOResumeSubtestCase ) ) + { + User::Leave( KErrNotReady ); + } + + Cancel(); + + iNestedASLoop->AsyncStop(); + iCurrentOperation = ECONone; + iOperationResult = KErrNone; + } + +void CRemoteSubTestCaseRunner::NotifyTestCaseCancelledL() + { + if ( !iNestedASLoop->IsStarted() || ( iCurrentOperation != ECOCancelSubtestCase ) ) + { + User::Leave( KErrNotReady ); + } + + Cancel(); + + iNestedASLoop->AsyncStop(); + iCurrentOperation = ECONone; + iOperationResult = KErrNone; + } + +void CRemoteSubTestCaseRunner::NotifyTestCaseFinishedL( const TFullTestResult& aTestCaseResult ) + { + iRunResult = KErrNone; + iResult = aTestCaseResult; + + iState = ESTSIdle; + + // Report sub test case result to CTestRunner + iTestRunner->SubTestCaseFinishedL( this ); + } + +TBool CRemoteSubTestCaseRunner::IsRunSubTestCaseRequestOngoing() const + { + if ( iCurrentOperation == ECORunSubtestCase ) + { + return ETrue; + } + return EFalse; + } + +// EOF diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/scriptermod/src/TestKeywords.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/scriptermod/src/TestKeywords.cpp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,344 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This module contains the implementation of +* TTestKeywords class member functions. +* +*/ + + +// INCLUDE FILES +#include "TestKeywords.h" + +// EXTERNAL DATA STRUCTURES +// None + +// EXTERNAL FUNCTION PROTOTYPES +// None + +// CONSTANTS +// None + +// MACROS +// None + +// LOCAL CONSTANTS AND MACROS +// None + +// MODULE DATA STRUCTURES +// None + +// LOCAL FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +// None + +// ==================== LOCAL FUNCTIONS ======================================= +// None + +// ================= MEMBER FUNCTIONS ========================================= + +/* +------------------------------------------------------------------------------- + + Class: TTestKeywords + + Method: Keyword + + Description: Returns a string desrciptor corresponding to keyword number. + + Parameters: TInt aKeyword: in: keyword index. + + Return Values: TPtrC8: keyword descriptor + + Errors/Exceptions: None + + Status: Approved + +------------------------------------------------------------------------------- +*/ +TPtrC TTestKeywords::Keyword( TInt aKeyword ) + { + static TText* const keywords[] = + { + (TText*)L"title", + (TText*)L"timeout", + (TText*)L"priority", + (TText*)L"create", + (TText*)L"delete", + (TText*)L"request", + (TText*)L"wait", + (TText*)L"release", + (TText*)L"set", + (TText*)L"unset", + (TText*)L"print", + (TText*)L"allownextresult", + (TText*)L"waittestclass", + (TText*)L"createkernel", + (TText*)L"pause", + (TText*)L"loop", + (TText*)L"endloop", + (TText*)L"oomignorefailure", + (TText*)L"oomheapfailnext", + (TText*)L"oomheapsetfail", + (TText*)L"oomheaptonormal", + (TText*)L"testinterference", + (TText*)L"measurement", + (TText*)L"allowerrorcodes", + (TText*)L"bringtoforeground", + (TText*)L"sendtobackground", + (TText*)L"presskey", + (TText*)L"typetext", + (TText*)L"var", + (TText*)L"callsub", + (TText*)L"createx", + (TText*)L"setresultdescription", + (TText*)L"sendpointerevent", + (TText*)L"using", + (TText*)L"expectedpanic", + (TText*)L"createshareobj", + (TText*)L"restoreshareobj", + (TText*)L"deleteshareobj", + (TText*)L"run", + (TText*)L"complete", + (TText*)L"canceliferror", + (TText*)L"pausetest", + (TText*)L"resume", + (TText*)L"cancel", + (TText*)L"allocate", + (TText*)L"free", + (TText*)L"remote", + (TText*)L"sendreceive", + }; + + if( (TUint)aKeyword >= (sizeof( keywords )/sizeof(TText*)) ) + { + TPtrC null; + return null; + } + + TPtrC keyword( keywords[ aKeyword ] ); + return keyword; + + } + +/* +------------------------------------------------------------------------------- + + Class: TTestKeywords + + Method: Priority + + Description: Returns a string desrciptor corresponding to priority + keywords optional argument number. + + Parameters: TInt aArg: in: argument index. + + Return Values: TPtrC8: keyword descriptor + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +TPtrC TTestKeywords::Priority( TInt aArg ) + { + static TText* const priority[] = + { + (TText*)L"high", + (TText*)L"normal", + (TText*)L"low", + }; + + if( aArg >= (TInt)(sizeof( priority )/sizeof(TText*)) ) + { + TPtrC null; + return null; + } + + TPtrC arg( priority[ aArg ] ); + return arg; + + } + +/* +------------------------------------------------------------------------------- + + Class: TTestKeywords + + Method: Parse + + Description: Returns a keyword enum corresponding to keyword + string descriptor. + + Parameters: TPtrC aKeyword: in: keyword descriptor. + KeywordFunc aFunc: in: Function pointer to keyword parser + + Return Values: TInt: keyword index + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +TInt TTestKeywords::Parse( TDesC& aKeyword, KeywordFunc aFunc ) + { + TInt ind; + for( ind = 0; aFunc( ind ).Length() > 0; ind++ ) + { + if( aFunc( ind ) == aKeyword ) + { + return ind; + } + } + return KErrNotFound; + }; + +/* +------------------------------------------------------------------------------- + + Class: TTestKeywords + + Method: RunOptArg + + Description: Returns a string desrciptor corresponding to run keyword + optional argument number. + + Parameters: TRunOptArgs aArg: in: run keyword optional argument index + + Return Values: TPtrC8: argument descriptor + + Errors/Exceptions: None + + Status: Approved + +------------------------------------------------------------------------------- +*/ +TPtrC TTestKeywords::RunOptArg( TInt aArg ) + { + static TText* const runOptArgs[] = + { + (TText*)L"expect", + (TText*)L"testid", + (TText*)L"ini", + (TText*)L"category", + (TText*)L"timeout", + (TText*)L"title", + }; + + if( aArg >= (TInt)(sizeof( runOptArgs )/sizeof(TText*)) ) + { + TPtrC null; + return null; + } + + TPtrC arg( runOptArgs[ aArg ] ); + return arg; + } + +/* +------------------------------------------------------------------------------- + + Class: TTestKeywords + + Method: ResultCategory + + Description: Returns a string desrciptor corresponding to result + category number. + + Parameters: TInt aArg: in: argument index. + + Return Values: TPtrC: keyword descriptor + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +TPtrC TTestKeywords::ResultCategory( TInt aArg ) + { + static TText* const category[] = + { + (TText*)L"ongoing", + (TText*)L"normal", + (TText*)L"cancelled", + (TText*)L"errorfrommodule", + (TText*)L"leave", + (TText*)L"panic", + (TText*)L"exception", + (TText*)L"timeout", + }; + + if( aArg >= (TInt)(sizeof( category )/sizeof(TText*)) ) + { + TPtrC null; + return null; + } + + TPtrC arg( category[ aArg ] ); + return arg; + + } + +/* +------------------------------------------------------------------------------- + + Class: TTestKeywords + + Method: ResultCategory + + Description: Returns a string desrciptor corresponding to event keywords + optional argument number. + + Parameters: TEventOptArgs aArg: in: argument index. + + Return Values: TPtrC8: keyword descriptor + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +TFullTestResult::TCaseExecutionResult TTestKeywords::GetResultCategory( TDesC& aCategory ) + { + + TInt ind; + for( ind = 0; ResultCategory( ind ).Length() > 0; ind++ ) + { + if( ResultCategory( ind ) == aCategory ) + { + switch( ind ) + { + case TFullTestResult::ECaseExecuted: + case TFullTestResult::ECaseLeave: + case TFullTestResult::ECasePanic: + case TFullTestResult::ECaseException: + case TFullTestResult::ECaseTimeout: + return (TFullTestResult::TCaseExecutionResult)ind; + default: + break; + } + } + } + return TFullTestResult::ECaseOngoing; + } + +// ================= OTHER EXPORTED FUNCTIONS ================================= +// None + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/scriptermod/src/TestScripter.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/scriptermod/src/TestScripter.cpp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,7350 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains TestScripter implementation. +* +*/ + +// INCLUDE FILES +#include +#include +#include "TestScripter.h" +#include "TestKeywords.h" +#include "Logging.h" +#include "TestEngineClient.h" +#include "SettingServerClient.h" +#include "TestScripterInternal.h" +#include "SubTestCaseRunner.h" +#include + + +#include + +// EXTERNAL DATA STRUCTURES +// None + +// EXTERNAL FUNCTION PROTOTYPES +// None + +// CONSTANTS +// None + +const TUid KPropertyCat = + { + 0x101FB3DE + }; +const TUint KPropertyKey = 0x00000001; +// MACROS +#ifdef LOGGER +#undef LOGGER +#endif +#define LOGGER iLog + +// LOCAL CONSTANTS AND MACROS +_LIT( KExecute, "Execute"); +// Printing priorities +const TInt KPrintPriExec = 400; + +// MODULE DATA STRUCTURES +// None + +// LOCAL FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +// None + +// ==================== LOCAL FUNCTIONS ======================================= + +/* +------------------------------------------------------------------------------- + + Class: - + + Method: CallBack + + Description: (Function pointer) Called from CScriptBase class. Generic + method for call back operations from Test Script Class to + TestScripter. + + Parameters: CTestScripter* aTestScripter: in: Pointer to TestScripter + TStifTSCallBackType aCallType: in: Call back type + const TDesC& aLine: in Script line + + Return Values: TInt: Symbian error code + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +TInt CallBack( CTestScripter* aTestScripter, + TStifTSCallBackType aCallType, + const TDesC& aLine ) + { + TInt ret( 0 ); + switch( aCallType ) + { + case EStifTSCallClass: + { + ret = aTestScripter->CallTestClass( aLine ); + break; + } + case EStifTSGetObject: + { + ret = aTestScripter->GetTestScriptObject( aLine ); + break; + } + default: + { + ret = KErrArgument; + break; + } + } + + return ret; + + } + +/* +------------------------------------------------------------------------------- + + DESCRIPTION + + This module contains the implementation of CTestScripter class + member functions. + +------------------------------------------------------------------------------- +*/ + +// ================= MEMBER FUNCTIONS ========================================= + +/* +------------------------------------------------------------------------------- + + Class: CTestScripter + + Method: CTestScripter + + Description: Default constructor + + C++ default constructor can NOT contain any code, that + might leave. + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Draft + + ------------------------------------------------------------------------------- + */ +CTestScripter::CTestScripter() : + iObjects(NULL) + { + + } + +/* +------------------------------------------------------------------------------- + + Class: CTestScripter + + Method: ConstructL + + Description: Symbian OS second phase constructor + + Symbian OS default constructor can leave. + + Parameters: None + + Return Values: None + + Errors/Exceptions: None. + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CTestScripter::ConstructL() + { + __TRACE( KPrint, ( _L("New TestScripter") ) ); + iStdLog = CStifLogger::NewL( KTestScripterLogDir, + KTestScripterLogFile ); + iLog = iStdLog; + + iOOMIgnoreFailure = EFalse; // OFF for default + + iCheckHeapBalance = EFalse; // No checking heap balance by default + + //Read logger settings to check whether test case name is to be + //appended to log file name. + RSettingServer settingServer; + TInt ret = settingServer.Connect(); + if(ret != KErrNone) + { + User::Leave(ret); + } + // Struct to StifLogger settigs. + TLoggerSettings loggerSettings; + // Parse StifLogger defaults from STIF initialization file. + ret = settingServer.GetLoggerSettings(loggerSettings); + if(ret != KErrNone) + { + User::Leave(ret); + } + // Close Setting server session + settingServer.Close(); + iAddTestCaseTitleToLogName = loggerSettings.iAddTestCaseTitle; + + // Initialize parser variables + iCurrentParser = NULL; + iCurrentParserReadFirstLine = EFalse; + + TUint ProperKey = RProcess().Id().Id(); + TInt err = RProperty::Define(KPropertyCat, ProperKey, RProperty::EInt); + + iObjects = new (ELeave) RPointerArray ; + err = RProperty::Set(KPropertyCat, ProperKey, (TInt) iObjects); + User::LeaveIfError(err); + } + +/* +------------------------------------------------------------------------------- + + Class: CTestScripter + + Method: NewL + + Description: Two-phased constructor. + + Parameters: None + + Return Values: CTestScripter*: new object + + Errors/Exceptions: Leaves if new or ConstructL leaves. + + Status: Draft + +------------------------------------------------------------------------------- +*/ +CTestScripter* CTestScripter::NewL() + { + + CTestScripter* self = new (ELeave) CTestScripter(); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + + return self; + + } + +/* +------------------------------------------------------------------------------- + + Class: CTestScripter + + Method: ~CTestScripter + + Description: Destructor + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +CTestScripter::~CTestScripter() + { + iTestObjects.ResetAndDestroy(); + iTestModules.ResetAndDestroy(); + iDefinedIni.ResetAndDestroy(); + iDefinedRuntime.ResetAndDestroy(); + iDefinedLocal.ResetAndDestroy(); + iParserStack.ResetAndDestroy(); + iGlobalObjects.ResetAndDestroy(); + iSharedTestModules.ResetAndDestroy(); + iObjects->Reset(); + iTestObjects.Close(); + iTestModules.Close(); + iDefinedIni.Close(); + iGlobalObjects.Close(); + iDefinedRuntime.Close(); + iDefinedLocal.Close(); + iParserStack.Close(); + iObjects->Close(); + iSharedTestModules.Close(); + + iCurrentParser = NULL; + delete iSectionParser; + delete iTestRunner; + delete iObjects; + + iLog = NULL; + delete iStdLog; + iStdLog = NULL; + delete iTCLog; + iTCLog = NULL; + + TUint ProperKey = RProcess().Id().Id(); + TInt err = RProperty::Delete(KPropertyCat, ProperKey); + } + +/* +------------------------------------------------------------------------------- + + Class: CTestScripter + + Method: InitL + + Description: InitL is used to initialize the Test Module. + + Parameters: const TFileName& aIniFile: in: Initialization file + TBool aFirstTime: in: First time flag + + Return Values: Symbian OS error code + + Errors/Exceptions: Leaves if ReadInitializationL leaves + + Status: Draft + +------------------------------------------------------------------------------- +*/ +TInt CTestScripter::InitL( TFileName& aIniFile, + TBool /*aFirstTime*/ ) + { + + __TRACEFUNC(); + + if( aIniFile.Length() > 0 ) + { + // Read initialization from test case file + ReadInitializationL( aIniFile, iDefinedIni ); + } + + return KErrNone; + + } + +/* +------------------------------------------------------------------------------- + + Class: CTestScripter + + Method: GetTestCases + + Description: GetTestCases is used to inquired test cases + + Parameters: const TFileName& aConfigFile: in: Test case file + RPointerArray& aTestCases: out: + Array of TestCases + + Return Values: KErrNone: Success + Symbian OS error code + + Errors/Exceptions: Leaves if CStifParser::SectionL leaves + Leaves if CStifParser::NextSectionL leaves + Leaves if memory allocation fails + + Status: Draft + +------------------------------------------------------------------------------- +*/ +TInt CTestScripter::GetTestCasesL( const TFileName& aConfigFile, + RPointerArray& aTestCases ) + { + __TRACEFUNC(); + + if( aConfigFile.Length() == 0 ) + { + __TRACE( KError, (_L("No test case script file given") ) ); + __RDEBUG( (_L("No test case script file given") ) ); + return KErrNotFound; + } + + CStifParser* parser = NULL; + + // Open test case file + TRAPD( err, + parser = CStifParser::NewL( _L(""), + aConfigFile, + CStifParser::ECStyleComments ) ); + if( err != KErrNone ) + { + __TRACE( KError, (_L("Given test case script file [%S] not found"), + &aConfigFile ) ); + __RDEBUG( (_L("Given test case script file [%S] not found"), + &aConfigFile ) ); + return err; + } + + CleanupStack::PushL( parser ); + CStifSectionParser* section; + TPtrC tmp; + TInt index = 0; + TInt ret = KErrNone; + + // Find first section + section = parser->SectionL( KTestStartTag, KTestEndTag ); + if( section == NULL ) + { + ret = KErrNotFound; + } + else + { + // Parse all sections + while( section ) + { + CleanupStack::PushL( section ); + + // Get title line + if( section->GetLine( TTestKeywords::Keyword( TTestKeywords::ETitle ), + tmp, ENoTag ) != KErrNone ) + { + __TRACE( KError, (_L("Title not given for test case"))); + User::Leave( KErrNotFound ); + } + else + { + if( tmp.Length() > KMaxName ) + { + tmp.Set( tmp.Left( KMaxName ) ); + } + TTestCaseInfo* tc = new ( ELeave ) TTestCaseInfo(); + CleanupStack::PushL( tc ); + __TRACE( KVerbose, (_L("TestCase: %S"), &tmp)); + tc->iTitle.Copy( tmp ); + tc->iCaseNumber = ++index; + + // Get timeout if defined + CStifItemParser* item = section->GetItemLineL( + TTestKeywords::Keyword( TTestKeywords::ETimeout ) ); + if( item ) + { + TInt timeout; // In milliseconds + ret = item->GetInt( + TTestKeywords::Keyword( TTestKeywords::ETimeout ), + timeout ); + if( ret != KErrNone ) + { + __TRACE( KError, (_L("Illegal timeout"))); + User::Leave( ret ); + } + + // Type cast timeout to TInt64 + tc->iTimeout = TInt64( timeout ) * 1000; + __TRACE( KMessage, (_L("Timeout: %i"), tc->iTimeout.Int64() )); + } + + // Get priority if defined + item = section->GetItemLineL( + TTestKeywords::Keyword( TTestKeywords::EPriority ) ); + if( item ) + { + // First try to interpret as integer + ret = item->GetInt( + TTestKeywords::Keyword( TTestKeywords::EPriority ), + tc->iPriority ); + if( ret != KErrNone ) + { + TPtrC priority; + // If priority was not given as integer, it must be + // one of the predefined values + ret = item->GetString( + TTestKeywords::Keyword( TTestKeywords::EPriority ), + priority ); + if( ret != KErrNone ) + { + __TRACE( KError, (_L("Illegal priority"))); + User::Leave( ret ); + } + switch( TTestKeywords::Parse( priority, + TTestKeywords::Priority ) ) + { + case TTestKeywords::EPriHigh: + tc->iPriority = TTestCaseInfo::EPriorityHigh; + break; + case TTestKeywords::EPriNormal: + tc->iPriority = TTestCaseInfo::EPriorityNormal; + break; + case TTestKeywords::EPriLow: + tc->iPriority = TTestCaseInfo::EPriorityLow; + break; + default: + __TRACE( KError, (_L("Illegal priority"))); + User::Leave( KErrArgument ); + } + } + __TRACE( KMessage, (_L("Priority: %i"), tc->iPriority )); + } + + aTestCases.Append(tc); + CleanupStack::Pop( tc ); + } + CleanupStack::PopAndDestroy( section ); + section = parser->NextSectionL( KTestStartTag, KTestEndTag ); + } + } + + CleanupStack::PopAndDestroy( parser ); + + __TRACE( KPrint, ( _L( "Configfile '%S', testcases %d" ), + &aConfigFile, index )); + + return ret; + + } + +/* +------------------------------------------------------------------------------- + + Class: CTestScripter + + Method: GetConstantValue + + Description: Internal fuction to get const value defined in + [Define]...[Enddefine] section of script file + + GetConstantValue gets const value defined in [Define]...[Enddefine] + section of script file + + Parameters: const TDesC& aName: in: constant name + TDes& avalue: out: constant value + + Return Values: KErrNone: Value is returned succesfully. + KErrNotFound: Constant was not found + Any other SymbianOS error + +------------------------------------------------------------------------------- +*/ +EXPORT_C TInt CTestScripter::GetConstantValue( const TDesC& aName, TDes& aValue ) + { + + __TRACEFUNC(); + + TInt count = iDefinedLocal.Count(); + for(TInt i = 0; i < count; i++) + { + if(iDefinedLocal[i]->Name() == aName) + { + aValue.Copy(iDefinedLocal[i]->Value()); + return KErrNone; + } + } + + count = iDefinedIni.Count(); + for( TInt i = 0; i < count; i++ ) + { + if( iDefinedIni[i]->Name() == aName ) + { + aValue.Copy( iDefinedIni[i]->Value() ); + return KErrNone; + } + } + + count = iDefinedRuntime.Count(); + for( TInt i = 0; i < count; i++ ) + { + if( iDefinedRuntime[i]->Name() == aName ) + { + aValue.Copy( iDefinedRuntime[i]->Value() ); + return KErrNone; + } + } + return KErrNotFound; + } + + +/* +------------------------------------------------------------------------------- + + Class: CTestScripter + + Method: RunTestCaseL + + Description: Run a specified testcase. + + RunTestCaseL is used to run an individual test case. + + Parameters: const TInt aCaseNumber: in: Testcase number + const TFileName& aConfig: in: Test case file + TTestResult& aResult: out: test case result + + Return Values: KErrNone: Test case started succesfully. + KErrNotFound: Testcase not found + KErrUnknown: Unknown TestScripter error + Any other SymbianOS error + + Errors/Exceptions: Leaves if GetTestCaseL leaves + Leaves if RunTestL leaves + Leaves if memory allocation fails + + Status: Draft + +------------------------------------------------------------------------------- +*/ +TInt CTestScripter::RunTestCaseL( const TInt aCaseNumber, + const TFileName& aConfig, + TTestResult& aResult ) + { + + // Heap is checked by test server + //__UHEAP_MARK; + + __TRACEFUNC(); + + //Open new log file with test case title in file name + if(iAddTestCaseTitleToLogName) + { + //Delete test case logger if exists + if(iTCLog) + { + delete iTCLog; + iTCLog = NULL; + } + + TFileName logFileName; + TName title; + TestModuleIf().GetTestCaseTitleL(title); + + logFileName.Format(KTestScripterLogFileWithTitle, &title); + iTCLog = CStifLogger::NewL(KTestScripterLogDir, logFileName); + iLog = iTCLog; + } + + __TRACE( KMessage, (_L("\n\n***Testcase started***"))); + + // Remove locally defined variables + iDefinedLocal.ResetAndDestroy(); + // Remove existing function parsers (there shouldn't be any) + iParserStack.ResetAndDestroy(); + + // Keep file name of config file + iConfig = aConfig; + + // Read initialization from test case file + ReadInitializationL( aConfig, iDefinedRuntime ); + + // Get case from test case file + iSectionParser = GetTestCaseL( aCaseNumber, aConfig ); + iCurrentParser = iSectionParser; + iCurrentParserReadFirstLine = EFalse; + + // Check parsing result + if( iSectionParser == NULL ) + { + __TRACE( KError, (_L("***Parsing testcase failed***\n\n"))); + // Delete runtime defines + iDefinedRuntime.ResetAndDestroy(); + //__UHEAP_MARKEND; + return KErrNotFound; + } + + // When option is set in cfg file, on EKA2 env memory leaking is enabled + TInt memCellsBef = 0; //memory in current thread allocated before the test case is run + TInt memCellsAft = 0; //memory in current thread allocated after the test case has run + + memCellsBef = User::Heap().Count(); + __TRACE(KMessage, (_L("Allocated memory cells before the test case: %d"), memCellsBef)); + + __TRACE(KMessage, (_L("Memory usage in global objects before the execution:"))); + TInt beforeGlobalMemCells = TraceGlobalObjectsMemoryUsage(); + + + CActiveScheduler* activeScheduler = + new ( ELeave ) CActiveScheduler(); + CleanupStack::PushL( activeScheduler ); + + if ( CActiveScheduler::Current() == NULL ) + { + CActiveScheduler::Install( activeScheduler ); + } + + // Run the given testcase described in iSectionParser section + RunTestL(); + + iTestObjects.ResetAndDestroy(); + iTestModules.ResetAndDestroy(); + iObjects->Reset(); + + // TestScripter must stop Active Scheduler after test + // object is destroyed. Otherwise if unexpected error occurs + // handling is erronous. + CleanupStack::PopAndDestroy( activeScheduler ); + + // Check for memory leak. + // It is reported in log always, but result of test case is changed only + // when option in cfg file is enabled. + memCellsAft = User::Heap().Count(); + __TRACE(KMessage, (_L("Allocated memory cells after the test case: %d"), memCellsAft)); + + + __TRACE(KMessage, (_L("Memory usage in global objects after the execution:"))); + TInt afterGlobalMemCells = TraceGlobalObjectsMemoryUsage(); + + memCellsAft = memCellsAft - afterGlobalMemCells + beforeGlobalMemCells; + + // if there is a difference report memory leak + if(memCellsAft != memCellsBef) + { + __TRACE(KError, (_L("Memory leak, %d cell(s) is missing"), memCellsAft - memCellsBef)); + if(iCheckHeapBalance) + { + // Memory leaks detection is disabled for UI components testing + if ( !( TestModuleIf().UITesting() ) ) + { + UpdateTestCaseResult(KErrGeneral, _L("Memory leak has occured")); + } + } + } + + // Delete parser and set current parser to NULL + iCurrentParser = NULL; + delete iSectionParser; + iSectionParser = NULL; + + // Erase config file name + iConfig = KNullDesC; + + // Return result + aResult = iResult; + + if( iResult.iResult == KErrNone ) + { + __TRACE( KPrint, (_L("***Testcase PASSED***\n\n"))); + TestModuleIf().Printf( KPrintPriNorm, _L("TestScripter"), + _L("***Testcase PASSED***\n\n")); + } + else + { + __TRACE( KPrint, (_L("***Testcase FAILED***\n\n"))); + TestModuleIf().Printf( KPrintPriNorm, _L("TestScripter"), + _L("***Testcase FAILED***\n\n")); + } + User::After(300000); + // Delete runtime defines + iDefinedRuntime.ResetAndDestroy(); + + //__UHEAP_MARKEND; + + //If log was replaced then restore it + if(iAddTestCaseTitleToLogName) + { + iLog = iStdLog; + delete iTCLog; + iTCLog = NULL; + } + + return KErrNone; + + } + +TInt CTestScripter::TraceGlobalObjectsMemoryUsage() + { + __TRACEFUNC(); + + TInt moduleNumber = iSharedTestModules.Count(); + TInt shareObjNumber = iGlobalObjects.Count(); + __TRACE(KMessage, (_L("There are %d item(s) in shared modules list"),moduleNumber)); + __TRACE(KMessage, (_L("There are %d item(s) in shared objects list"),shareObjNumber)); + + TInt listNumber = 0; + + if(moduleNumber != 0) + { + listNumber++; + __TRACE(KMessage, (_L("Shared module list used 1 cell."))); + __TRACE(KMessage, (_L("There are %d shared module(s), they used %d cells"), moduleNumber , moduleNumber * 2)); + } + + if(shareObjNumber != 0) + { + listNumber++; + __TRACE(KMessage, (_L("Shared object list used 1 cell."))); + __TRACE(KMessage, (_L("There are %d shared object(s), they used %d cells"), shareObjNumber, shareObjNumber * 4)); + } + TInt result = listNumber + moduleNumber * 2 + shareObjNumber * 4; + __TRACE(KMessage, (_L("There are %d cells used by shared objects and their modules."), result)); + + return result; + } + +/* +------------------------------------------------------------------------------- + + Class: CTestScripter + + Method: ReadInitializationL + + Description: Read initialization from file. + + Parameters: const TDesC& aIniFile: in: File that contains initialization + + Return Values: None + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CTestScripter::ReadInitializationL( + const TDesC& aIniFile, + RPointerArray& aDefines ) + { + + CStifParser* parser = NULL; + + // Open file + TRAPD( err, + parser = CStifParser::NewL( _L(""), + aIniFile, + CStifParser::ECStyleComments ) ); + if( ( err == KErrNone ) && parser ) + { + CleanupStack::PushL( parser ); + __TRACE( KMessage, (_L("Read initialization from [%S]"), + &aIniFile ) ); + + CStifSectionParser* section = parser->SectionL( KDefineStartTag, + KDefineEndTag ); + while(section) + { + CleanupStack::PushL( section ); + __TRACE( KMessage, (_L("Read defines")) ); + + TPtrC name; + TPtrC value; + CStifItemParser* item = section->GetItemLineL( _L("") ); + while( item ) + { + CleanupStack::PushL( item ); + + if( item->GetString( _L(""), name ) != KErrNone ) + { + __TRACE( KError, (_L("No define name given")) ); + User::Leave( KErrGeneral ); + } + if( item->Remainder( value ) != KErrNone ) + { + __TRACE( KError, (_L("No define value given")) ); + User::Leave( KErrGeneral ); + } + TInt count = aDefines.Count(); + TInt i = 0; + for( ; i < count; i++ ) + { + if( aDefines[i]->Name() == name ) + { + // Update existing + aDefines[i]->SetValueL( value ); + __TRACE(KMessage, (_L("Update define [%S]: [%S]"), &name, &value)); + break; + } + } + if( i == count) + { + // New define, store it + CDefinedValue* define = CDefinedValue::NewL( name, value ); + CleanupStack::PushL( define ); + User::LeaveIfError( aDefines.Append( define ) ); + CleanupStack::Pop( define ); + } + + CleanupStack::PopAndDestroy( item ); + item = section->GetNextItemLineL(); + } + CleanupStack::PopAndDestroy( section ); + section = parser->NextSectionL(KDefineStartTag, KDefineEndTag); + } + + //Read StifSettings section and find value for CheckHeapBalance. + //(In cfg file in settings section User may also set CapsModifier + // option. This is handled in TestServerClient.cpp in + // RTestServer::GetCapsModifier method). + section = parser->SectionL(KStifSettingsStartTag, KStifSettingsEndTag); + + if(section) + { + CleanupStack::PushL(section); + __TRACE(KMessage, (_L("Read stif settings"))); + + TPtrC value; + CStifItemParser* item = section->GetItemLineL(_L("")); + while(item) + { + CleanupStack::PushL(item); + __TRACE( KMessage, (_L("Got settings line"))); + + if(item->GetString(_L("CheckHeapBalance="), value) == KErrNone) + { + __TRACE(KMessage, (_L("Got CheckHeapBalance item, value=%S"), &value)); + if(value.Compare(_L("off")) == 0) + { + iCheckHeapBalance = EFalse; + } + else if(value.Compare(_L("on")) == 0) + { + iCheckHeapBalance = ETrue; + } + else + { + __TRACE(KError, (_L("Value '%S' for CheckHeapBalance setting is not supported. Aborting"), &value)); + User::Leave(KErrNotSupported); + } + } + CleanupStack::PopAndDestroy(item); + item = section->GetNextItemLineL(); + } + CleanupStack::PopAndDestroy(section); + } + + + + + //Read data section + section = parser->SectionL(KDataStartTag, KDataEndTag); + + if(section) + { + CleanupStack::PushL(section); + __TRACE(KMessage, (_L("Read data section"))); + + + CStifItemParser* item = section->GetItemLineL(_L("")); + + while(item) + { + CleanupStack::PushL(item); + __TRACE( KMessage, (_L("Got data section line"))); + TPtrC inifile; + TPtrC inisection; + if(item->GetString(_L("File"), inifile) == KErrNone) + { + + __TRACE(KMessage, (_L("Got ini file name: %S"), &inifile)); + + iCurrentFile.Zero(); + + + if(inifile.Find(_L("\\"))==KErrNotFound) + { + iCurrentFile.Append(_L("c:\\TestFramework\\")); + } + + iCurrentFile.Append(inifile); + + + + TPtrC alias; + err=item->GetNextString(alias); + __TRACE(KMessage, (_L("Got ini file alias: %S"), &alias)); + + iCurrentFileAlias.Zero(); + if(err==KErrNone) + { + iCurrentFileAlias.Copy(alias); + } + else + { + TParsePtr filespec(iCurrentFile); + iCurrentFileAlias.Copy(filespec.NameAndExt()); + } + + + + } + else if(item->GetString(_L("Section"), inisection) == KErrNone) + { + + __TRACE(KMessage, (_L("Got Section name: %S"), &inisection)); + + iCurrentSection.Zero(); + iCurrentSection.Copy(inisection); + + + TPtrC alias; + TInt err=item->GetNextString(alias); + __TRACE(KMessage, (_L("Got Section alias: %S"), &alias)); + + iCurrentSectionFileAlias.Zero(); + + if(err==KErrNone) + { + iCurrentSectionFileAlias.Copy(alias); + } + else + { + iCurrentSectionFileAlias.Copy(iCurrentSection); + } + + TParsePtr filespec(iCurrentFile); + + CStifParser* parser=CStifParser::NewL(filespec.DriveAndPath(),filespec.NameAndExt()); + + TBuf section; + section.Append(_L("[")); + section.Append(iCurrentSection); + section.Append(_L("]")); + CStifSectionParser* sectionparser=parser->SectionL(section,KNullDesC,1,EFalse); + + CStifItemParser* itemparser=sectionparser->GetItemLineL(KNullDesC); + + while(itemparser) + { + itemparser->SetParsingType(CStifItemParser::EQuoteStyleParsing); + TPtrC temp; + + itemparser->Remainder(temp); + __TRACE(KMessage, (_L("Got item string: %S"), &temp)); + iCurrentKey.Zero(); + iCurrentKey.Append(KFileFlag); + iCurrentKey.Append(iCurrentFileAlias); + iCurrentKey.Append(KSectionFlag); + iCurrentKey.Append(iCurrentSectionFileAlias); + iCurrentKey.Append(KKeyFlag); + + TBuf tempkey; + TBuf tempvalue; + TLex lex(temp); + TChar ch; + while((ch = lex.Get()) != 0 ) + { + while ((ch = lex.Peek()) != '=') + lex.Inc(); + tempkey.Append(lex.MarkedToken()); + lex.Inc(); + lex.Mark(); + break; + } + tempkey.TrimAll(); + iCurrentKey.Append(tempkey); + iKeys.Append(iCurrentKey); + + + tempvalue.Append(lex.Remainder()); + tempvalue.TrimAll(); + + + iCurrentvalues.Zero(); + iCurrentvalues.Copy(tempvalue); + + + + iValues.Append(iCurrentvalues); + delete itemparser; + itemparser=NULL; + itemparser=sectionparser->GetNextItemLineL(); + + } + + + + + delete sectionparser; + delete parser; + + + + + + + + } + CleanupStack::PopAndDestroy(item); + item = section->GetNextItemLineL(); + } + CleanupStack::PopAndDestroy(section); + } + + + + CleanupStack::PopAndDestroy( parser ); + } + } + + +/* +------------------------------------------------------------------------------- + + Class: CTestScripter + + Method: GetTestCaseL + + Description: Get specified test case section from configfile. + + Parameters: const TInt aCaseNumber: in: Test case number + const TFileName& aConfig: in: Configfile name + + Return Values: CStifSectionParser*: pointer to test case section + + Errors/Exceptions: Leaves if CStifParser::NewL leaves + Leaves if CStifParser::SectionL leaves + Leaves if memory allocation fails + + + Status: Draft + +------------------------------------------------------------------------------- +*/ +CStifSectionParser* CTestScripter::GetTestCaseL( const TInt aCaseNumber, + const TFileName& aConfig ) + { + __TRACEFUNC(); + CStifParser* parser = NULL; + + TRAPD( err, + parser = CStifParser::NewL( _L(""), + aConfig, + CStifParser::ECStyleComments ); ); + if( err != KErrNone ) + { + __TRACE( KError, (_L("Test case file [%S] not found"), &aConfig )); + User::Leave( err ); + } + CleanupStack::PushL( parser ); + + CStifSectionParser* section = NULL; + TRAP( err, + section =parser->SectionL( KTestStartTag, KTestEndTag, aCaseNumber );); + if( err != KErrNone ) + { + __TRACE( KError, + (_L("Section [%S/%d] not found"), &aConfig, aCaseNumber )); + User::Leave( err ); + } + + CleanupStack::PopAndDestroy( parser ); + return section; + + } + +/* +------------------------------------------------------------------------------- + + Class: CTestScripter + + Method: GetSubL + + Description: Get specified function (sub) from stored config file. + + Parameters: const TDesC& aSubName: in: function name + + Return Values: CStifSectionParser*: pointer to test function section + + Errors/Exceptions: Leaves if CStifParser::NewL leaves + Leaves if CStifParser::SectionL leaves + Leaves if memory allocation fails + + Status: Draft + +------------------------------------------------------------------------------- +*/ +CStifSectionParser* CTestScripter::GetSubL(const TDesC& aSubName) + { + __TRACE(KMessage, (_L("Searching sub [%S]."), &aSubName)); + // Check if config file is set + if(iConfig.Length() == 0) + { + __TRACE(KError, (_L("Searching sub [%S]. Config file is not set."), &aSubName)); + User::Leave(KErrBadName); + } + + // Create parser + CStifParser* parser = NULL; + CStifSectionParser* section = NULL; + + TRAPD(err, + parser = CStifParser::NewL(_L(""), iConfig, CStifParser::ECStyleComments); + ); + if(err != KErrNone) + { + __TRACE(KError, (_L("Searching sub [%S]. Error [%d] when loading config file [%S]."), &aSubName, err, &iConfig)); + User::Leave(err); + } + CleanupStack::PushL(parser); + + // Set section tags + _LIT(KEndSubTag, "[EndSub]"); + TName startSubTag; + startSubTag.Copy(_L("[Sub ")); + startSubTag.Append(aSubName); + startSubTag.Append(_L("]")); + + // Load section + TRAP(err, + section = parser->SectionL(startSubTag, KEndSubTag, 1); + ); + if(err != KErrNone) + { + __TRACE(KError, (_L("Searching sub [%S]. Searching section %S%S ended with error [%d]."), &aSubName, &startSubTag, &KEndSubTag, err)); + User::Leave(err); + } + if(!section) + { + __TRACE(KError, (_L("Searching sub [%S]. Section %S%S not found."), &aSubName, &startSubTag, &KEndSubTag)); + User::Leave(err); + } + else + { + __TRACE(KMessage, (_L("Searching sub [%S]. Section %S%S found."), &aSubName, &startSubTag, &KEndSubTag)); + } + + CleanupStack::PopAndDestroy(parser); + return section; + } + +/* +------------------------------------------------------------------------------- + + Class: CTestScripter + + Method: RunTestL + + Description: Run a testcase specified by iSectionParser. + + Parameters: None + + Return Values: None. + + Errors/Exceptions: Leaves if CSectionParser::GetItemLineL leaves + Leaves if CTestRunner::NewL leaves + Leaves if memory allocation fails + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CTestScripter::RunTestL() + { + __TRACEFUNC(); + iResult.iResult = KErrNone; + iResult.iResultDes.Zero(); + + // "title" keyword must be in the first line + TPtrC title; + if( iCurrentParser->GetLine( + TTestKeywords::Keyword( TTestKeywords::ETitle ), title, ENoTag ) + != KErrNone ) + { + __TRACE( KError, (_L("title not found from section"))); + User::Leave( KErrNotFound ); + } + iCurrentParserReadFirstLine = ETrue; + + __TRACE( KMessage, (_L("RunTest: %S"), &title )); + + iTestRunner = CTestRunner::NewL( this ); + + TestModuleIf().Printf( KPrintPriNorm, _L("RunTest"), _L("%S"), &title ); + + // Rest of the job is done by test runner + iTestRunner->SetRunnerActive(); + + // Start activeScheduler looping testcase lines + __TRACE( KMessage, (_L("Start CActiveScheduler"))); + CActiveScheduler::Current()->Start(); + + if ( iTestRunner->IsFailedSubTestCaseReported() && !(iPassLimitNotMet) ) + { + TFullTestResult testResult = iTestRunner->GetFailedSubTestCaseResult(); + const CStartInfo* startInfo = iTestRunner->GetFailedSubTestCaseInfo(); + if( testResult.iCaseExecutionResultType == TFullTestResult::ECaseExecuted ) + { + iResult.iResult = testResult.iTestResult.iResult; + } + else + { + iResult.iResult = testResult.iCaseExecutionResultCode; + } + iResult.iResultDes.Format( _L("Sub test case \"%S\" execution failed. "), &startInfo->GetTitle() ); + iResult.iResultDes.AppendFormat( _L("Result [%d], expected result [%d]"), iResult.iResult, startInfo->GetExpectedResult() ); + } + + delete iTestRunner; + iTestRunner = NULL; + __TRACE( KMessage, ( _L("RunTestL: Done"))); + + // Destroy locally defined variables + iDefinedLocal.ResetAndDestroy(); + // Destroy function parsers (there shouldn't be any) + iParserStack.ResetAndDestroy(); + } + +/* +------------------------------------------------------------------------------- + + Class: CTestScripter + + Method: GetTestModuleL + + Description: Load testmodule if not already loaded, otherwise return + description of the loaded testmodule. + + Parameters: TDesC& aModule: in: module name + TDesC& aIniFile: in: ini file name + + Return Values: CTCTestModule*: pointer to testmodules description + + Errors/Exceptions: Leaves if CTCTestModule::NewL leaves + Leaves if RPointerArray::Append fails + + Status: Draft + +------------------------------------------------------------------------------- +*/ +TTestModule* CTestScripter::LoadTestModuleL( TDesC& aModule ) + { + __TRACEFUNC(); + TInt count = iTestModules.Count(); + for( TInt i=0; i < count; i++ ) + { + if( iTestModules[i]->ModuleName() == aModule ) + { + // Found test module, return description + __TRACE( KMessage, + (_L("GetTestModuleL: Use already loaded TestModule (%S)"), + &aModule )); + return iTestModules[i]; + } + } + + __TRACE( KMessage, (_L("GetTestModuleL: Load new TestModule (%S)"), + &aModule )); + TTestModule* module = new (ELeave) TTestModule(); + CleanupStack::PushL( module ); + module->ModuleName() = aModule; + User::LeaveIfError( iTestModules.Append( module ) ); + CleanupStack::Pop( module ); + + TInt ret = module->iLibrary.Load ( aModule ); + + if( ret != KErrNone ) + { + __TRACE( KMessage, (_L("GetTestModuleL: %S loading failed"), + &aModule )); + TestModuleIf().Printf( KMessage, _L("Load dll"), _L("%S failed"), + &aModule ); + + User::Leave( ret ); + } + + // Get pointer to first exported function + module->iLibEntry = (CInterfaceFactory) module->iLibrary.Lookup(1); + return module; + + } + +/* + ------------------------------------------------------------------------------- + + Class: CTestScripter + + Method: LoadSharedTestModuleL + + Description: Load testmodule if not already loaded, otherwise return + description of the loaded testmodule. + + Parameters: TDesC& aModule: in: module name + TDesC& aIniFile: in: ini file name + + Return Values: CTCTestModule*: pointer to testmodules description + + Errors/Exceptions: Leaves if CTCTestModule::NewL leaves + Leaves if RPointerArray::Append fails + + Status: Draft + + ------------------------------------------------------------------------------- + */ + +TTestModule* CTestScripter::LoadSharedTestModuleL(TDesC& aModule) + { + __TRACEFUNC(); + TInt count = iSharedTestModules.Count(); + for (TInt i = 0; i < count; i++) + { + if (iSharedTestModules[i]->ModuleName() == aModule) + { + // Found test module, return description + __TRACE( KMessage, + (_L("GetTestModuleL: Use already loaded TestModule (%S)"), + &aModule )); + return iSharedTestModules[i]->Get(); + } + } + + __TRACE( KMessage, (_L("GetTestModuleL: Load new TestModule (%S)"), + &aModule )); + TTestModule* module = new (ELeave) TTestModule(); + CleanupStack::PushL(module); + module->ModuleName() = aModule; + User::LeaveIfError(iSharedTestModules.Append( + new (ELeave) TSharedTestModule(module))); + CleanupStack::Pop(module); + + TInt ret = module->iLibrary.Load(aModule); + TestModuleIf().iNumberInGlbDict++; + + if (ret != KErrNone) + { + __TRACE( KMessage, (_L("GetTestModuleL: %S loading failed"), + &aModule )); + TestModuleIf().Printf(KMessage, _L("Load dll"), _L("%S failed"), + &aModule); + + User::Leave(ret); + } + + // Get pointer to first exported function + module->iLibEntry = (CInterfaceFactory) module->iLibrary.Lookup(1); + return module; + } + +/* +------------------------------------------------------------------------------- + + Class: CTestScripter + + Method: CreateObjectL + + Description: Load testmodule if not already loaded, otherwise return + description of the loaded testmodule. + + Parameters: TDesC& aModule: in: module name + TDesC& aObjectId: in: object id name + + Return Values: None + + Errors/Exceptions: Leaves on error + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CTestScripter::CreateObjectL( TDesC& aModule, TDesC& aObjectId ) + { + __TRACEFUNC(); + + // Load module and get pointer + TTestModule* module = LoadTestModuleL( aModule ); + TTestObject* object = new (ELeave) TTestObject(); + CleanupStack::PushL( object ); + object->ObjectId() = aObjectId; + object->iModule.Copy(aModule); + User::LeaveIfError( iTestObjects.Append( object ) ); + CleanupStack::Pop( object ); + + // Create object + object->iScript = module->iLibEntry( TestModuleIf() ); + //User::LeaveIfNull ( object->iScript ); + if( object->iScript == NULL ) + { + User::Leave( KErrGeneral ); + } + + // Create continue callback + object->iContinue = CTestContinue::NewL( this, object ); + + // Create function pointer operation to possible + object->iScript->SetScripter( &CallBack, this ); + + TestModuleIf().AddTestObjToCaseDictL(object); + } + +/* +------------------------------------------------------------------------------- + + Class: CTestScripter + + Method: CreateShareObjectL + + Description: Load testmodule if not already loaded, otherwise return + description of the loaded testmodule. + + Parameters: TDesC& aModule: in: module name + TDesC& aObjectId: in: object id name + + Return Values: None + + Errors/Exceptions: Leaves on error + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CTestScripter::CreateShareObjectL( TDesC& aModule, TDesC& aObjectId ) + { + __TRACEFUNC(); + + // Load module and get pointer + TTestModule* module = LoadSharedTestModuleL(aModule); + TTestObject* object = new (ELeave) TTestObject(); + CleanupStack::PushL( object ); + object->ObjectId() = aObjectId; + CleanupStack::Pop( object ); + object->iModule.Copy(aModule); + // Create object + object->iScript = module->iLibEntry( TestModuleIf() ); + //User::LeaveIfNull ( object->iScript ); + if( object->iScript == NULL ) + { + User::Leave( KErrGeneral ); + } + + TestModuleIf().AddTestObjToCaseDictL(object); + AddTestObjToScripterDictL(object); + TestModuleIf().iNumberInGlbDict++; + } + +/* +------------------------------------------------------------------------------- + + Class: CTestScripter + + Method: RestoreShareObjectL + + Description: Load testmodule if not already loaded, otherwise return + description of the loaded testmodule. + + Parameters: TDesC& aModule: in: module name + TDesC& aObjectId: in: object id name + + Return Values: None + + Errors/Exceptions: Leaves on error + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CTestScripter::RestoreShareObjectL( TDesC& aObjectId ) + { + __TRACEFUNC(); + + TTestObject* object = NULL; + object = (TTestObject*)GetTestObjFromScripterDict( aObjectId ); + + if( NULL == object ) + { + User::Leave( KErrGeneral ); + } + + //User::LeaveIfNull ( object->iScript ); + if( object->iScript == NULL ) + { + User::Leave( KErrGeneral ); + } + + TestModuleIf().AddTestObjToCaseDictL(object); + } + +/* +------------------------------------------------------------------------------- + + Class: CTestScripter + + Method: CreateKernelObjectL + + Description: Load testdriver if not already loaded, otherwise return + description of the loaded testdriver. + + Parameters: TDesC& aDriver: in: driver name + TDesC& aObjectId: in: object id name + + Return Values: None + + Errors/Exceptions: Leaves on error + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CTestScripter::CreateKernelObjectL( TDesC& aDriver, TDesC& aObjectId ) + { + + __TRACEFUNC(); + + if( ( aDriver.Length() > KMaxName ) || + ( aObjectId.Length() > KMaxName ) ) + { + __TRACE( KError, (_L("CreateKernelObjectL: Max lenght exceeded") ) ); + User::Leave( KErrArgument ); + } + TInt ret = User::LoadLogicalDevice( aDriver ); + if( ( ret != KErrNone ) && ( ret != KErrAlreadyExists ) ) + { + __TRACE( KError, + (_L("CreateKernelObjectL: User::LoadLogicalDevice failed %d"), + ret ) ); + User::Leave( ret ); + } + + TTestObjectKernel* object = new (ELeave) TTestObjectKernel(); + CleanupStack::PushL( object ); + object->ObjectId() = aObjectId; + object->LddName().Copy( aDriver ); + ret = object->KernelTestClass().Open( + object->KernelTestClass().VersionRequired(), + aDriver ); + if( ret != KErrNone ) + { + __TRACE( KError, + (_L("CreateKernelObjectL: KernelTestClass().Open failed %d"), + ret ) ); + User::Leave( ret ); + } + + User::LeaveIfError( iTestObjects.Append( object ) ); + CleanupStack::Pop( object ); + + } + +/* +------------------------------------------------------------------------------- + + Class: CTestScripter + + Method: GetTestModuleL + + Description: Load testmodule if not already loaded, otherwise return + description of the loaded testmodule. + + Parameters: TDesC& aModule: in: module name + TDesC& aIniFile: in: ini file name + + Return Values: CTCTestModule*: pointer to testmodules description + + Errors/Exceptions: Leaves if CTCTestModule::NewL leaves + Leaves if RPointerArray::Append fails + + Status: Draft + +------------------------------------------------------------------------------- +*/ +TInt CTestScripter::DeleteObjectL( TDesC& aObjectId ) + { + __TRACEFUNC(); + + TestModuleIf().DelTestObjFromCaseDict(aObjectId); + + TInt count = iTestObjects.Count(); + for( TInt i=0; i < count; i++ ) + { + if( iTestObjects[i]->ObjectId() == aObjectId ) + { + TTestObjectBase* object = iTestObjects[i]; + iTestObjects.Remove( i ); + delete object; + return KErrNone; + } + } + + return KErrNone; + } + +/* +------------------------------------------------------------------------------- + + Class: CTestScripter + + Method: DeleteGlobalObjectL + + Description: Delete test object from dictionary + + Parameters: TDesC& aObjectId: in: object name + + Return Values: void + + Errors/Exceptions: Leaves if CTCTestModule::NewL leaves + Leaves if RPointerArray::Append fails + + Status: Draft + +------------------------------------------------------------------------------- +*/ +TInt CTestScripter::DeleteScripterObjectL( TDesC& aObjectId ) + { + __TRACEFUNC(); + + TScriptObject* obj = TestModuleIf().GetTestObjFromCaseDict(aObjectId); + if(obj == NULL) + { + return KErrNotFound; + } + + TestModuleIf().DelTestObjFromCaseDict(aObjectId); + DelTestObjFromScripterDict(aObjectId); + + return KErrNone; + } + +/* +------------------------------------------------------------------------------- + + Class: CTestScripter + + Method: GetTest + + Description: Get test case from testcase array. + + Parameters: TDesC& aTestId: in: TestId for testcase + + Return Values: CTCTestCase*: running/runned testcase + NULL: Testcase with aTestId not running/runned + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +TTestObjectBase* CTestScripter::GetObject( const TDesC& aObjectId ) + { + __TRACEFUNC(); + + TInt count = iTestObjects.Count(); + for( TInt i=0; i < count; i++ ) + { + if( iTestObjects[i]->ObjectId() == aObjectId ) + { + // Found testcase with specified TestId + return iTestObjects[i]; + } + } + + TTestObject* object = NULL; + object = (TTestObject*)TestModuleIf().GetTestObjFromCaseDict( aObjectId ); + + return object; + } + +/* +------------------------------------------------------------------------------- + + Class: CTestScripter + + Method: CallTestClass + + Description: For sub classing operations. + + Parameters: const TDesC& aLine: in: script line + + Return Values: TInt: Symbian error code + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +TInt CTestScripter::CallTestClass( const TDesC& aLine ) + { + CStifItemParser* item = CStifItemParser::NewL( aLine, 0, aLine.Length() ); + CleanupStack::PushL( item ); + + TPtrC objectName; + TInt ret( KErrNone ); + ret = item->GetString( _L( "" ), objectName ); + if( ret != KErrNone ) + { + CleanupStack::PopAndDestroy( item); + return ret; + } + + TTestObjectBase* obj = GetObject( objectName ); + if( obj == NULL ) + { + CleanupStack::PopAndDestroy(item ); + return KErrNotFound; + } + + TRAPD( commandResult, commandResult = obj->RunMethodL( *item ) ); + + CleanupStack::PopAndDestroy(item ); + + return commandResult; + + } + +/* +------------------------------------------------------------------------------- + + Class: CTestScripter + + Method: GetTestScriptObject + + Description: Get object address. + + Parameters: const TDesC& aObjectName: in: object name + + Return Values: TInt: Symbian error code + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +TInt CTestScripter::GetTestScriptObject( const TDesC& aObjectName ) + { + + TTestObjectBase* objBase = GetObject( aObjectName ); + if( ( objBase == NULL ) || + ( objBase->ObjectType() != TTestObjectBase::EObjectNormal ) ) + { + return KErrNotFound; + } + + TTestObject* object = ( TTestObject* )objBase; + + return (TInt) object->iScript; + + } + +/* +------------------------------------------------------------------------------- + + Class: CTestScripter + + Method: UpdateTestCaseResult + + Description: Updates result of test case. If there is already some + description stored, it is put in the [] brackets. + + Parameters: const TInt aResult: in: error code + const TDesC& aDescr: in: description + + Return Values: None + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CTestScripter::UpdateTestCaseResult(const TInt aResult, const TDesC& aDescr) + { + // Create buffer + RBuf buf; + + TInt ret = buf.Create(iResult.iResultDes.Length() + aDescr.Length() + 5); + if(ret != KErrNone) + { + __TRACE(KError, (_L("UpdateResultDescription: descriptor creation failed [%d]"), ret)); + return; + } + CleanupClosePushL(buf); + + // Update result + iResult.iResult = aResult; + if(iResult.iResultDes.Length() > 0) + { + buf.Format(_L("%S [%S]"), &aDescr, &iResult.iResultDes); + } + else + { + buf.Copy(aDescr); + } + + SetResultDescription(buf); + + // Close buffer + CleanupStack::PopAndDestroy(&buf); + } + +/* +------------------------------------------------------------------------------- + + Class: CTestScripter + + Method: SetResultDescription + + Description: Sets result description of test case. + + Parameters: const TDesC& aDescr: in: new description + + Return Values: None + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +EXPORT_C void CTestScripter::SetResultDescription(const TDesC& aDescr) + { + if(aDescr.Length() > KStifMaxResultDes) + { + iResult.iResultDes.Copy(aDescr.Mid(0, KStifMaxResultDes)); + } + else + { + iResult.iResultDes.Copy(aDescr); + } + } + +/* +------------------------------------------------------------------------------- + + Class: CTestScripter + + Method: SetLocalValue + + Description: Internal fuction to set value of local variable defined in script + + Parameters: const TDesC& aName: in: local variable name + const TDesC& avalue: in: local variable value + + Return Values: KErrNone: Value is returned succesfully. + KErrNotFound: Variable was not found + Any other SymbianOS error + +------------------------------------------------------------------------------- +*/ +EXPORT_C TInt CTestScripter::SetLocalValue(const TDesC& aName, const TDesC& aValue) + { + __TRACEFUNC(); + + TInt count = iDefinedLocal.Count(); + for(TInt i = 0; i < count; i++) + { + if(iDefinedLocal[i]->Name() == aName) + { + iDefinedLocal[i]->SetValueL(const_cast(aValue)); + return KErrNone; + } + } + + return KErrNotFound; + } + +/* +------------------------------------------------------------------------------- + + Class: CTestScripter + + Method: GetLocalValue + + Description: Internal fuction to get value of local variable + + Parameters: const TDesC& aName: in: local variable name + const TDesC& avalue: in: local variable value + + Return Values: KErrNone: Value is returned succesfully. + KErrNotFound: Variable was not found + Any other SymbianOS error + +------------------------------------------------------------------------------- +*/ +EXPORT_C TInt CTestScripter::GetLocalValue(const TDesC& aName, TDes& aValue) + { + __TRACEFUNC(); + + TInt count = iDefinedLocal.Count(); + for(TInt i = 0; i < count; i++) + { + if(iDefinedLocal[i]->Name() == aName) + { + aValue.Copy(iDefinedLocal[i]->Value()); + return KErrNone; + } + } + + return KErrNotFound; + } + +TBool CompareTBuf(const TBuf& aLeft,const TBuf& aRight) +{ + return aLeft.Compare(aRight) == 0 ? ETrue : EFalse; + +} + +void CTestScripter::Substitute(const TDesC& aSrc,TDes& aDest) +{ + TIdentityRelation > relation(CompareTBuf); + + + + + + + + + + TInt fileindex=aSrc.Find(KFileFlag); + TInt sectionindex=aSrc.Find(KSectionFlag); + TInt keyindex=aSrc.Find(KKeyFlag); + TBuf srcbuf; + if(fileindex==KErrNotFound&§ionindex==KErrNotFound&&keyindex!=KErrNotFound) + { + srcbuf.Append(KFileFlag); + srcbuf.Append(iCurrentFileAlias); + srcbuf.Append(KSectionFlag); + srcbuf.Append(iCurrentSectionFileAlias); + + srcbuf.Append(aSrc); + + } + else if(fileindex==KErrNotFound&§ionindex!=KErrNotFound&&keyindex!=KErrNotFound) + { + srcbuf.Append(KFileFlag); + srcbuf.Append(iCurrentFileAlias); + + + srcbuf.Append(aSrc); + + } + else + { + srcbuf.Append(aSrc); + } + + + TInt index=iKeys.Find(srcbuf,relation); + if(index==KErrNotFound) + { + + aDest.Append(aSrc); + } + else + { + + aDest.Append(iValues[index]); + } + +} + +/* +------------------------------------------------------------------------------- + + Class: CTestScripter + + Method: AddTestObjToDictL + + Description: Add Test Object to dictionary + + Parameters: TTestObject* aObject: in: test object + + Return Values: None + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CTestScripter::AddTestObjToScripterDictL(TTestObject* aObject) + { + __TRACEFUNC(); + + User::LeaveIfNull( (TAny*)aObject ); + + TInt count = iGlobalObjects.Count(); + for (TInt i = 0; i < count; i++) + { + if (iGlobalObjects[i]->ObjectId() == aObject->ObjectId()) + { + // Found testcase with specified TestId + return; + } + } + + User::LeaveIfError( iGlobalObjects.Append(aObject) ); + } + +/* +------------------------------------------------------------------------------- + + Class: CTestScripter + + Method: DelTestObjFromDict + + Description: delete Test Object from dictionary + + Parameters: const TDesC& aObjectId: in: id + + Return Values: None + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CTestScripter::DelTestObjFromScripterDict(const TDesC& aObjectId) + { + __TRACEFUNC(); + + TInt count = iGlobalObjects.Count(); + for (TInt i = 0; i < count; i++) + { + if (iGlobalObjects[i]->ObjectId() == aObjectId) + { + // Found testcase with specified TestId + TTestObject *object = (TTestObject*) iGlobalObjects[i]; + iGlobalObjects.Remove(i); + TInt count2 = iSharedTestModules.Count(); + for (TInt j = 0; j < count2; j++) + { + if (iSharedTestModules[j]->ModuleName() == object->iModule) + { + delete object; + TestModuleIf().iNumberInGlbDict--; + iSharedTestModules[j]->Del(); + if (iSharedTestModules[j]->RefCount() <= 0) + { + TestModuleIf().iNumberInGlbDict--; + } + delete iSharedTestModules[j]; + iSharedTestModules.Remove(j); + break; + } + } + if(iSharedTestModules.Count() == 0) + { + iSharedTestModules.Reset(); + } + if(iGlobalObjects.Count() == 0) + { + iGlobalObjects.Reset(); + } + return; + } + } + } + +/* +------------------------------------------------------------------------------- + + Class: CTestScripter + + Method: GetTestObjFromDict + + Description: delete Test Object from dictionary + + Parameters: const TDesC& aObjectId: in: id + + Return Values: TTestObject* : pointer to TTestObject + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +TTestObject* CTestScripter::GetTestObjFromScripterDict(const TDesC& aObjectId) const + { + __TRACEFUNC(); + + TInt count = iGlobalObjects.Count(); + for (TInt i = 0; i < count; i++) + { + if (iGlobalObjects[i]->ObjectId() == aObjectId) + { + // Found testcase with specified TestId + return iGlobalObjects[i]; + } + } + + return NULL; + } + +/* +------------------------------------------------------------------------------- + + Class: CTestScripter + + Method: AppendTestResultToResultDes + + Description: Append to TC's result description (if possible due to length) + limitation provided text in [] brackets. + + Parameters: None. + + Return Values: None. + + Errors/Exceptions: None. + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +void CTestScripter::AppendTestResultToResultDes(TDes& aResultDescr, const TDesC& aTestCaseResultDescr) + { + if(aTestCaseResultDescr != KNullDesC) + { + _LIT(KAdditionalInfo, " [%S]"); + TInt len = aResultDescr.Length() + KAdditionalInfo().Length() + aTestCaseResultDescr.Length(); + + if(len > KStifMaxResultDes) + { + len = KStifMaxResultDes - aResultDescr.Length() - KAdditionalInfo().Length(); + if(len > 0) + { + TPtrC descr = aTestCaseResultDescr.Mid(0, len); + aResultDescr.AppendFormat(KAdditionalInfo, &descr); + } + } + else + { + aResultDescr.AppendFormat(KAdditionalInfo, &aTestCaseResultDescr); + } + } + } + +/* +------------------------------------------------------------------------------- + + DESCRIPTION + + This module contains the implementation of CTestRunner class + member functions. CTestRunner is used to execute TestScripter testcase by + CTestScripter. + +------------------------------------------------------------------------------- +*/ +// MACROS +#ifdef LOGGER +#undef LOGGER +#endif +#define LOGGER iTestScripter->iLog + +// ================= MEMBER FUNCTIONS ========================================= + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: CTestRunner + + Description: Default constructor + + C++ default constructor can NOT contain any code, that + might leave. + + Parameters: CTestScripter* aTestScripter: in: Backpointer to CTestScripter + + Return Values: None + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +CTestRunner::CTestRunner( CTestScripter* aTestScripter ): + CActive( CActive::EPriorityHigh ), // Executed with highest priority + iState( ERunnerIdle ), + iInternalStateForSubTestCases( EISNotStarted ), + iTestScripter( aTestScripter ), + iRemainingTimeValue( 0 ) + { + CActiveScheduler::Add( this ); + __TRACEFUNC(); + + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: ConstructL + + Description: Symbian OS second phase constructor + + Symbian OS default constructor can leave. + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CTestRunner::ConstructL() + { + + iPauseTimer.CreateLocal(); + + // Initiaze all OOM related variables to default. + OOMHeapToNormal(); + + iLoopHelper = CLoopHelper::NewL( this ); + + iSlavesManager = CSlavesManager::NewL( this, iTestScripter->TestModuleIf() ); + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: NewL + + Description: Two-phased constructor. + + Parameters: CTestScripter* aTestScripter: in: Backpointer to CTestScripter + + Return Values: CTestRunner*: new object + + Errors/Exceptions: Leaves if new or ConstructL leaves + + Status: Draft + +------------------------------------------------------------------------------- +*/ + +CTestRunner* CTestRunner::NewL( CTestScripter* aTestScripter ) + { + CTestRunner* self = new (ELeave) CTestRunner( aTestScripter ); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + + return self; + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: ~CTestRunner + + Description: Destructor + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Approved + +------------------------------------------------------------------------------- +*/ + +CTestRunner::~CTestRunner() + { + __TRACEFUNC(); + Cancel(); + + iPauseTimer.Close(); + + delete iLine; + iLine = NULL; + + delete iLoopHelper; + iLoopHelper = NULL; + + iSubTestCases.ResetAndDestroy(); + iSubTestCases.Close(); + + delete iTestIdForComplete; + iTestIdForComplete = NULL; + + delete iFailedSubTestCaseInfo; + iFailedSubTestCaseInfo = NULL; + + TInt count = iEventArray.Count(); + TEventIf event( TEventIf::ERelEvent ); + for( TInt i = 0; i < count; i++ ) + { + HBufC* tmp = iEventArray[0]; + event.SetName( iEventArray[0]->Des() ); + iEventArray.Remove(0); + if( iTestScripter != NULL ) + { + iTestScripter->TestModuleIf().Event( event ); + } + delete tmp; + } + + iTestCaseResults.Reset(); + iEventArray.ResetAndDestroy(); + iTestCaseResults.Close(); + iEventArray.Close(); + + delete iSlavesManager; + iSlavesManager = NULL; + + // Reset test case allow result to CTestModuleIf side too. This is + // used in TAL-TA5L macro handling. + if( iTestScripter != NULL ) + { + User::LeaveIfError( + iTestScripter->TestModuleIf().ResetAllowResult() ); + } + + // Stop all remaining interference object + TInt count_inter = iTestInterferenceArray.Count(); + for( TInt a = 0; a < count_inter; a++ ) + { + if( iTestInterferenceArray[a] != NULL ) + { + iTestInterferenceArray[a]->iInterference->Stop(); + } + } + iTestInterferenceArray.ResetAndDestroy(); + iTestInterferenceArray.Close(); + + // Stop all remaining measurement modules + const TInt count_meas = iTestMeasurementArray.Count(); + for( TInt b = 0; b < count_meas; b++ ) + { + if( iTestMeasurementArray[b] != NULL ) + { + iTestMeasurementArray[b]->iMeasurement->Stop(); + } + } + iTestMeasurementArray.ResetAndDestroy(); + iTestMeasurementArray.Close(); + iPlugins.ResetAndDestroy(); + iPlugins.Close(); + iPluginnames.ResetAndDestroy(); + iPluginnames.Close(); + iLibrary.Close(); + + + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: RunL + + Description: Derived from CActive, handles testcase execution. + + Parameters: None. + + Return Values: None. + + Errors/Exceptions: Leaves on error situations. + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CTestRunner::RunL() + { + __TRACEFUNC(); + __TRACE( KMessage, (_L("CTestRunner::RunL: [%d] "), iStatus.Int() )); + + if ( iInternalStateForSubTestCases == EISNotStarted ) + { + iInternalStateForSubTestCases = EISRuning; + } + + // Check if we need to Pause test case again + if( iStatus == KErrNone && iRemainingTimeValue > 0 ) + { + // Maximum time for one RTimer::After request + TInt maximumTime = KMaxTInt / 1000; + + __TRACE( KMessage, (_L("CTestRunner::RunL: Going to reissue After request ") ) ); + __TRACE( KMessage, (_L("CTestRunner::RunL: iRemainingTimeValue = %d"), iRemainingTimeValue ) ); + + if( iRemainingTimeValue < maximumTime ) + { + iPauseTimer.After( iStatus, ( iRemainingTimeValue * 1000 ) ); + iRemainingTimeValue = 0; + } + else + { + iRemainingTimeValue -= maximumTime; + iPauseTimer.After( iStatus, ( maximumTime * 1000 ) ); + } + SetActive(); + } + else + { + TBool continueTask = EFalse; + + User::LeaveIfError( iStatus.Int() ); + + if( ( iTestScripter == NULL ) || + ( iTestScripter->iCurrentParser == NULL ) ) + { + __TRACE( KError, (_L("CTestRunner invalid arguments"))); + User::Leave( KErrGeneral ); + } + + iState = ERunnerIdle; + + // Get next execution line from configuration section + TPtrC line; + // If current parser already has read the first line, then read next line. + // Otherwise read the first line. + if(iTestScripter->iCurrentParserReadFirstLine && iTestScripter->iCurrentParser->GetNextLine(line) == KErrNone + || !iTestScripter->iCurrentParserReadFirstLine && iTestScripter->iCurrentParser->GetLine(KNullDesC, line) == KErrNone) + { + iTestScripter->iCurrentParserReadFirstLine = ETrue; + + // Got new execution line + __TRACE( KMessage, (_L("Executing line [%S]"), &line)); + + CStifItemParser* item = PreprocessLineL( line ); + + CleanupStack::PushL( item ); + + TPtrC keyword; + // Get first word from line, i.e. keyword + User::LeaveIfError( item->GetString( _L(""), keyword ) ); + + __TRACE( KMessage, (_L("CTestRunner execute %S"), &keyword )); + + // Execute script line + continueTask = ExecuteLineL( keyword, item ); + __TRACE( KMessage, (_L("CTestRunner %S executed"), &keyword )); + + if( continueTask ) + { + __TRACE( KMessage, (_L("RunL: continueTask"))); + // Set CTestRunner active again to perform + // next execution line + // from testcase section + SetRunnerActive(); + } + + CleanupStack::PopAndDestroy( item ); + } + else // Stop execution if end of test case + { + __TRACE( KMessage, (_L("Executing line: no more lines from this section"))); + // There is no more lines in current parser, but it needs to be + // checked if the parser is not taken for function (sub). + // If this is true, then we have to get back to the parser which + // has called the function. + TInt lastParserIndex = iTestScripter->iParserStack.Count() - 1; + if(lastParserIndex >= 0) + { + // Delete current (the last one) parser + delete iTestScripter->iParserStack[lastParserIndex]; + iTestScripter->iParserStack.Remove(lastParserIndex); + if(lastParserIndex >= 1) //There is some other parser on the stack + { + iTestScripter->iCurrentParser = iTestScripter->iParserStack[lastParserIndex - 1]; + } + else //The parser stack is empty + { + iTestScripter->iCurrentParser = iTestScripter->iSectionParser; + } + __TRACE(KMessage, (_L("Returning to calling parser stored on section stack"))); + + // Continue with the test case + __TRACE(KMessage, (_L("RunL: continueTask (end of Sub reached)"))); + SetRunnerActive(); + return; + } + // No more execution lines in testcase section + // Check if there are running test cases + if ( iSubTestCases.Count() > 0 ) + { + if ( iInternalStateForSubTestCases != EISFinishedWaitingForSubTestCases ) + { + iInternalStateForSubTestCases = EISFinishedWaitingForSubTestCases; + } + // Continue with the test case + // proper sub test case runner should activate test runner + return; + } + + iInternalStateForSubTestCases = EISFinished; + + + // Release remote resources + RPointerArray& slaves = iSlavesManager->GetSlaves(); + + while ( slaves.Count() > 0 ) + { + slaves[ 0 ]->WaitForSubTestCasesL(); + + RPointerArray& slaveEvents = slaves[ 0 ]->GetEvents(); + for ( TInt k = 0; k < slaveEvents.Count(); k++ ) + { + iSlavesManager->EventReleaseL( slaves[ 0 ], slaveEvents[ k ]->Name() ); + } + slaveEvents.ResetAndDestroy(); + + iSlavesManager->SlaveFreeL( slaves[ 0 ]->GetName() ); + } + + __TRACE( KMessage, + (_L("CTestRunner::RunL: Testcase script done") )); + iTestScripter->TestModuleIf().Printf( KPrintPriLow, + _L("RunL"), _L("Script done")); + + + __TRACE( KMessage, + (_L("RunL: All TestCases done, stop CActiveScheduler"))); + CActiveScheduler::Current()->Stop(); + // Now testcase section is executed, + // so CTestRunner has done its job and stops + } + } + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: DoCancel + + Description: Derived from CActive handles the Cancel + + Parameters: None. + + Return Values: None. + + Errors/Exceptions: None. + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CTestRunner::DoCancel() + { + __TRACEFUNC(); + __TRACE( KMessage, (_L("CTestRunner::DoCancel"))); + iTestScripter->TestModuleIf().Printf( KPrintPriLow, _L("Runner"), _L("DoCancel")); + + iPauseTimer.Cancel(); + + CActiveScheduler::Current()->Stop(); + + iState = ERunnerCancel; + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: RunError + + Description: Derived from CActive handles errors from active handler. + + Parameters: TInt aError: in: error from CActive + + Return Values: KErrNone: success + + Errors/Exceptions: None. + + Status: Draft + +------------------------------------------------------------------------------- +*/ +TInt CTestRunner::RunError( TInt aError ) + { + __TRACEFUNC(); + __TRACE( KMessage, (_L("CTestRunner::RunError %d"), aError)); + + if ( iRunErrorMessage.Length() != 0 ) + { + iTestScripter->TestModuleIf().Printf( KPrintPriLow, _L("Runner"), + _L("RunError : %S"), &iRunErrorMessage ); + iRunErrorMessage = KNullDesC; + } + else + { + iTestScripter->TestModuleIf().Printf( KPrintPriLow, _L("Runner"), + _L("RunError")); + } + + iState = ERunnerError; + + // Return error from here, if none given from execution + if( iTestScripter->iResult.iResult == KErrNone ) + { + iTestScripter->UpdateTestCaseResult(aError, _L("CTestRunner::RunError")); + } + + CActiveScheduler::Current()->Stop(); + + return KErrNone; + + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: GetLogger + + Description: Returns TestScripter logger + + Parameters: None + + Return Values: Pointer to TestScripter logger. + + Errors/Exceptions: None. + + Status: Draft + +------------------------------------------------------------------------------- +*/ +CStifLogger* CTestRunner::GetLogger() + { + return iTestScripter->iLog; + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: PreprocessLineL + + Description: Preprocesses script line + + Parameters: TPtrC& line: in: script line + CStifItemParser*& aItem: out: New CItemParser for script line. + + Return Values: HBufC* pointer if new memory that has been allocated + + Errors/Exceptions: Leaves on error situations. + + Status: Draft + +------------------------------------------------------------------------------- +*/ +CStifItemParser* CTestRunner::PreprocessLineL( TDesC& line ) + { + CStifItemParser* item = NULL; + TPtrC tmp; + TInt len = 0; + TInt ret = 0; + + // Decide how long buffer should be allocated + if( line.Length() < KMaxName/2 ) + { + len = KMaxName; + } + else + { + len = line.Length() + KMaxName; + } + delete iLine; + iLine = 0; + iLine = HBufC::NewL(len); + TPtr parsedLine(iLine->Des()); + len = 0; + + HBufC* sourceLine = line.AllocL(); + CleanupStack::PushL(sourceLine); + + //Check for local variable definitions + item = CStifItemParser::NewL(sourceLine->Des(), 0, sourceLine->Length()); + CleanupStack::PushL(item); + + ret = item->GetString(KNullDesC, tmp); + TBool isVarDefinition = (tmp == TTestKeywords::Keyword(TTestKeywords::EVar)); + + if(!isVarDefinition) + { + while( ret == KErrNone ) + { + len += CheckDefinedLocals(tmp); + if((parsedLine.Length() + tmp.Length() + 1) > parsedLine.MaxLength()) + { + // Allocate bigger buffer + HBufC* tmpBuf = HBufC::NewL(parsedLine.MaxLength() + KMaxName); + CleanupStack::PushL(tmpBuf); + TPtrC ptr(iLine->Des()); + parsedLine.Set(tmpBuf->Des()); + parsedLine.Copy(ptr); + delete iLine; + iLine = tmpBuf; + CleanupStack::Pop(tmpBuf); + } + parsedLine.Append(tmp); + ret = item->GetNextString(tmp); + if(ret == KErrNone) + { + // Add space only if we got new string + parsedLine.Append(_L(" ")); + } + } + CleanupStack::PopAndDestroy(item); + item = NULL; + CleanupStack::PopAndDestroy(sourceLine); + sourceLine = NULL; + + //Prepare data for checking for defines + sourceLine = parsedLine.AllocL(); + CleanupStack::PushL(sourceLine); + parsedLine.Zero(); + + item = CStifItemParser::NewL(sourceLine->Des(), 0, sourceLine->Length()); + CleanupStack::PushL(item); + + ret = item->GetString(KNullDesC, tmp); + } + + //Check for defines + while(ret == KErrNone) + { + if(!isVarDefinition) + { + len += CheckDefined(tmp); + } + + if((parsedLine.Length() + tmp.Length() + 1) > parsedLine.MaxLength()) + { + // Allocate bigger buffer + HBufC* tmpBuf = HBufC::NewL(parsedLine.MaxLength() + KMaxName); + CleanupStack::PushL(tmpBuf); + TPtrC ptr(iLine->Des()); + parsedLine.Set(tmpBuf->Des()); + parsedLine.Copy(ptr); + delete iLine; + iLine = tmpBuf; + CleanupStack::Pop(tmpBuf); + } + parsedLine.Append(tmp); + ret = item->GetNextString(tmp); + if( ret == KErrNone ) + { + // Add space only if we got new string + parsedLine.Append(_L(" ")); + } + } + + //Cleaning... + CleanupStack::PopAndDestroy(item); + item = NULL; + CleanupStack::PopAndDestroy(sourceLine); + sourceLine = NULL; + + __TRACE(KMessage, (_L("Preprocessed line [%S]"), &parsedLine)); + item = CStifItemParser::NewL( parsedLine, 0, parsedLine.Length() ); + + return item; + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: CheckDefined + + Description: Check if aWord is some defined word + + Parameters: TPtrC& aWord: inout: Parsed word, defined or original returned + + Return Values: TInt: length diference between new and old word + + Errors/Exceptions: None. + + Status: Draft + +------------------------------------------------------------------------------- +*/ +TInt CTestRunner::CheckDefined( TPtrC& aWord ) + { + + TInt len = 0; + TInt i = 0; + + // KLoopCounter word changing to current loop count value. + if( aWord == KLoopCounter ) + { + iLoopCounterDes.Zero(); + iLoopCounterDes.AppendNum( iLoopCounter ); + len = iLoopCounterDes.Length() - aWord.Length(); + aWord.Set( iLoopCounterDes ); + return len; + } + + // First, check values defined in test case file + TInt count = iTestScripter->iDefinedRuntime.Count(); + for( i = 0; i < count; i++ ) + { + if( iTestScripter->iDefinedRuntime[i]->Name() == aWord ) + { + len = iTestScripter->iDefinedRuntime[i]->Value().Length() - aWord.Length(); + aWord.Set( iTestScripter->iDefinedRuntime[i]->Value() ); + return len; + } + } + + // Second, check values defined in test module initialization file + count = iTestScripter->iDefinedIni.Count(); + for( i = 0; i < count; i++ ) + { + if( iTestScripter->iDefinedIni[i]->Name() == aWord ) + { + len = iTestScripter->iDefinedIni[i]->Value().Length() - aWord.Length(); + aWord.Set( iTestScripter->iDefinedIni[i]->Value() ); + return len; + } + } + + return len; + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: CheckDefinedLocals + + Description: Check if aWord is a local variable + + Parameters: TPtrC& aWord: inout: Parsed word, defined or original returned + + Return Values: TInt: length diference between new and old word + + Errors/Exceptions: None. + + Status: Draft + +------------------------------------------------------------------------------- +*/ +TInt CTestRunner::CheckDefinedLocals( TPtrC& aWord ) + { + + TInt len = 0; + TInt i = 0; + + TInt count = iTestScripter->iDefinedLocal.Count(); + for(i = 0; i < count; i++) + { + if(iTestScripter->iDefinedLocal[i]->Name() == aWord) + { + len = iTestScripter->iDefinedLocal[i]->Value().Length() - aWord.Length(); + aWord.Set(iTestScripter->iDefinedLocal[i]->Value()); + return len; + } + } + + return len; + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: ExecuteLineL + + Description: Executes script line + + Parameters: TDesC& aKeyword: in: keyword string + CStifItemParser* aItem: in: script line + + Return Values: ETrue: continue script file execution + EFalse: stop script file execution + + Errors/Exceptions: Leaves on error situations. + + Status: Approved + +------------------------------------------------------------------------------- +*/ +TBool CTestRunner::ExecuteLineL( TDesC& aKeyword, + CStifItemParser* aItem ) + { + _LIT( KErrMsgDeleteNoParam, "Delete: Name of object is not defined" ); + _LIT( KErrMsgDeleteObjNotFound, "Delete: Can't delete object %S. Object does not exists." ); + _LIT( KErrMsgPauseTimeoutNotDefined, "Pause: No timeout value given or value has invalid format" ); + _LIT( KErrMsgPauseTimeoutNotPositive, "Pause: Timeout value can't be <0" ); + _LIT( KErrMsgCreateTestModeleNotDefined, "Create: Name of test module is not defined" ); + _LIT( KErrMsgCreateObjectIdNotDefined, "Create: Name of test module object is not defined" ); + _LIT( KErrMsgCreateKernelDriverNotDefined, "CreateKernel: Kernel driver name is not defined" ); + _LIT( KErrMsgCreateKernelObjectNameNotDefined, "CreateKernel: Kernel driver object name is not defined" ); + _LIT( KErrMsgCreateKernelFailed, "CreateKernel: Can't creeate kernel driver %S" ); + _LIT( KErrMsgWaitTestClassNameNotDefined, "WaitTestClass: Test class object name is not defined" ); + _LIT( KErrMsgWaitTestClassObjNotFound, "WaitTestClass: Test class object %S does not exists" ); + _LIT( KErrMsgBringToForegroundNotSupported, "BringToForeground: BringToForeground is not supported in non s60 environment" ); + _LIT( KErrMsgSendToBackgroundNotSupported, "SendToBackground: SendToBackground is not supported in non s60 environment" ); + _LIT( KErrMsgPressKeyNotSupported, "PressKey: PressKey is not supported in non s60 environment. Check if .cfg file name contains ui_ prefix and UITestingSupport= YES entry is defined in TestFrameworkd.ini" ); + _LIT( KErrMsgTypeTextNotSupported, "TypeText: TypeText is not supported in non s60 environment. Check if .cfg file name contains ui_ prefix and UITestingSupport= YES entry is defined in TestFrameworkd.ini" ); + _LIT( KErrMsgSendPointerEventNotSupported, "SendPointerEvent: SendPointerEvent is not supported in non s60 environment. Check if .cfg file name contains ui_ prefix and UITestingSupport= YES entry is defined in TestFrameworkd.ini" ); + _LIT( KErrVarNameError, "Variable: Could not get variable name"); + _LIT( KErrVarValueError, "Variable: Value too long"); + _LIT( KErrSubNameError, "Sub: Could not get name of Sub to be called"); + _LIT( KErrSubGetError, "Sub: Could not get Sub section"); + + TPtrC temp; + RBuf buf; + buf.Create(512); + CleanupClosePushL(buf); + buf.Append(aKeyword); + buf.Append(_L(" ")); + while(aItem->GetNextString(temp)==KErrNone) + { + + + RBuf tempbuf; + tempbuf.Create(512); + iTestScripter->Substitute(temp,tempbuf); + buf.Append(tempbuf); + + buf.Append(_L(" ")); + tempbuf.Close(); + } + + delete aItem; + aItem=NULL; + + temp.Set((TUint16 *)buf.Ptr(),buf.Length()); + aItem=CStifItemParser::NewL(temp,0,temp.Length()); + + aItem->GetString(KNullDesC,temp); + + + iRunErrorMessage = KNullDesC; + TBool continueTask = ETrue; + + TInt key = TTestKeywords::Parse( aKeyword, TTestKeywords::Keyword ); + + switch( key ) + { + // Test case execution control cases + case TTestKeywords::ECreate: + case TTestKeywords::ECreateX: + case TTestKeywords::ECreateShareObj: + { + TPtrC tmp; + TName module; + + // Testmodule name + TInt ret = aItem->GetNextString( tmp ); + + if ( ret != KErrNone ) + { + iRunErrorMessage = KErrMsgCreateTestModeleNotDefined; + User::Leave( KErrArgument ); + } + TParse p; + p.Set( tmp, NULL, NULL ); + // Check if exists in module name + if( p.ExtPresent() ) + { + module.Copy( tmp ); + } + else + { + // No extension in module name, add it here + _LIT( KDllExtension, ".dll"); + module.Copy( tmp ); + module.Append( KDllExtension ); + } + + // objectid + ret = aItem->GetNextString( tmp ); + + if ( ret != KErrNone ) + { + iRunErrorMessage = KErrMsgCreateObjectIdNotDefined; + User::Leave( KErrArgument ); + } + + __TRACE( KMessage, (_L("%S %S"), &aKeyword, &tmp)); + iTestScripter->TestModuleIf().Printf( KPrintPriLow, _L("Runner"), + _L("%S %S"), &aKeyword, &tmp); + + if( TTestKeywords::ECreateShareObj == key ) + { + iTestScripter->CreateShareObjectL( module, tmp ); + } + else + { + iTestScripter->CreateObjectL( module, tmp ); + } + } + break; + case TTestKeywords::ERestoreShareObj: + { + TPtrC tmp; + + // objectid + TInt ret = aItem->GetNextString( tmp ); + + if ( ret != KErrNone ) + { + iRunErrorMessage = KErrMsgCreateObjectIdNotDefined; + User::Leave( KErrArgument ); + } + + __TRACE( KMessage, (_L("%S %S"), &aKeyword, &tmp)); + iTestScripter->TestModuleIf().Printf( KPrintPriLow, _L("Runner"), + _L("%S %S"), &aKeyword, &tmp); + + + iTestScripter->RestoreShareObjectL( tmp ); + } + break; + case TTestKeywords::ECreateKernel: + { + TPtrC obj; + TPtrC driver; + + // Testdriver name + TInt ret = aItem->GetNextString( driver ); + if ( ret != KErrNone ) + { + iRunErrorMessage = KErrMsgCreateKernelDriverNotDefined; + User::Leave( ret ); + } + + // objectid + ret = aItem->GetNextString( obj ); + if ( ret != KErrNone ) + { + iRunErrorMessage = KErrMsgCreateKernelObjectNameNotDefined; + User::Leave( ret ); + } + + __TRACE( KMessage, (_L("%S %S"), &aKeyword, &obj)); + iTestScripter->TestModuleIf().Printf( KPrintPriLow, _L("Runner"), + _L("%S %S"), &aKeyword, &obj); + TInt leaveErr = KErrNone; + TRAP( leaveErr, iTestScripter->CreateKernelObjectL( driver, obj )); + if ( leaveErr != KErrNone ) + { + iRunErrorMessage.Format( KErrMsgCreateKernelFailed, &driver ); + User::Leave( leaveErr ); + } + } + break; + case TTestKeywords::EDelete: + { + TPtrC tmp; + // objectid + TInt ret = aItem->GetNextString( tmp ); + if ( ret != KErrNone ) + { + iRunErrorMessage = KErrMsgDeleteNoParam; + User::Leave( ret ); + } + + __TRACE( KMessage, (_L("%S %S"), &aKeyword, &tmp)); + iTestScripter->TestModuleIf().Printf( KPrintPriLow, _L("Runner"), + _L("%S %S"), &aKeyword, &tmp); + + ret = iTestScripter->DeleteObjectL( tmp ); + if ( ret != KErrNone ) + { + iRunErrorMessage.Format( KErrMsgDeleteObjNotFound, &tmp ); + User::Leave( ret ); + } + } + break; + case TTestKeywords::EDeleteShareObj: + { + TPtrC tmp; + // objectid + TInt ret = aItem->GetNextString( tmp ); + if ( ret != KErrNone ) + { + iRunErrorMessage = KErrMsgDeleteNoParam; + User::Leave( ret ); + } + + __TRACE( KMessage, (_L("%S %S"), &aKeyword, &tmp)); + iTestScripter->TestModuleIf().Printf( KPrintPriLow, _L("Runner"), + _L("%S %S"), &aKeyword, &tmp); + + ret = iTestScripter->DeleteScripterObjectL( tmp ); + if(ret) + { + iRunErrorMessage.Format( KErrMsgDeleteObjNotFound, &tmp ); + User::Leave( ret ); + } + } + break; + case TTestKeywords::ERun: + continueTask = ExecuteRunL( aItem ); + break; + case TTestKeywords::ECancelIfError: + iCancelIfError = ETrue; + break; + case TTestKeywords::EComplete: + continueTask = ExecuteCompleteL( aItem ); + break; + case TTestKeywords::EPauseTest: + continueTask = ControlSubTestCaseL( TTestKeywords::EPauseTest, aItem ); + break; + case TTestKeywords::EResume: + continueTask = ControlSubTestCaseL( TTestKeywords::EResume, aItem ); + break; + case TTestKeywords::ECancel: + continueTask = ControlSubTestCaseL( TTestKeywords::ECancel, aItem ); + break; + case TTestKeywords::ERequest: + case TTestKeywords::EWait: + case TTestKeywords::ERelease: + case TTestKeywords::ESet: + case TTestKeywords::EUnset: + continueTask = ExecuteEventL( aKeyword, aItem ); + break; + case TTestKeywords::EPrint: + { + __TRACE( KMessage, (_L("%S"), &aKeyword)); + iTestScripter->TestModuleIf().Printf( KPrintPriLow, _L("Runner"), + _L("%S"), &aKeyword ); + + RBuf buf; + buf.CreateL(1024); + CleanupClosePushL(buf); + + TPtrC tmp; + + while( aItem->GetNextString( tmp ) == KErrNone ) + { + if( buf.Length() + tmp.Length() >= buf.MaxLength() ) + { + buf.ReAllocL(buf.MaxLength() + tmp.Length() * 10); + } + buf.Append( tmp ); + buf.Append( _L(" ") ); + } + + iTestScripter->TestModuleIf().Printf( KPrintPriNorm, + _L("Test"), + _L("%S"), &buf); + RDebug::Print( _L("Print : Test : %S"), &buf ); + CleanupStack::PopAndDestroy(&buf); + } + break; + case TTestKeywords::EAllowNextResult: + { + AddTestCaseResultL( aItem ); + } + break; + case TTestKeywords::EExpectedPanic: + { + AddTestCasePanicL( aItem ); + } + break; + case TTestKeywords::EWaitTestClass: + { + // Just stop script running, continue event is signaled + // from test class with specified object name + TPtrC objectName; + // Get Object name + TInt ret = aItem->GetNextString( objectName ); + if ( ret != KErrNone ) + { + iRunErrorMessage = KErrMsgWaitTestClassNameNotDefined; + User::Leave( ret ); + } + TTestObjectBase* obj = iTestScripter->GetObject ( objectName ); + //User::LeaveIfNull( obj ); + if( obj == NULL ) + { + iRunErrorMessage.Format( KErrMsgWaitTestClassObjNotFound, &objectName ); + User::Leave( KErrGeneral ); + } + continueTask = obj->Wait(); + + if( continueTask ) + { + // If OOM testing is ongoing ignore result check(given by user) + if( !iTestScripter->iOOMIgnoreFailure ) + { + if( iTestCaseResults.Count() == 0 ) + { + // KErrNone is the default result expected + // if nothing else is given + User::LeaveIfError( iTestCaseResults.Append( + KErrNone ) ); + } + + if( iTestCaseResults.Find( obj->iAsyncResult ) < 0 ) + { + __TRACE( KError, ( _L("Command for [%S] failed (%d)"), + &objectName, obj->iAsyncResult )); + iTestScripter->UpdateTestCaseResult(obj->iAsyncResult, _L("CTestRunner::ExecuteLineL: asynchronous method returned error")); + // Stops execution from CTestRunner::RunError + User::Leave( KErrGeneral ); + } + } + else + { + __TRACE( KMessage, ( + _L( "OOM test: 'oomignorefailure' is ON, test case result will reset" ) ) ); + } + + iTestCaseResults.Reset(); + // Reset test case allow result to CTestModuleIf side too. This is + // used in TAL-TA5L macro handling. + User::LeaveIfError( + iTestScripter->TestModuleIf().ResetAllowResult() ); + } + + } + break; + case TTestKeywords::EPause: + { + // Maximum time for one RTimer::After request + TInt maximumTime = KMaxTInt / 1000; + // Set iRemainingTimeValue to zero + iRemainingTimeValue = 0; + + TInt timeout; + // Read valid results to timeout + if( aItem->GetNextInt( timeout ) != KErrNone ) + { + __TRACE( KError, (_L("CTestRunner::ExecuteLineL: No timeout value given for pause"))); + iRunErrorMessage = KErrMsgPauseTimeoutNotDefined; + User::Leave( KErrArgument ); + } + + // Test case file parsing was success + + __TRACE( KMessage, (_L("CTestRunner::ExecuteLineL: Pause for %d milliseconds"), timeout)); + + if( timeout < 0 ) + { + __TRACE( KError, (_L("CTestRunner::ExecuteLineL: Given pause value < 0"))); + iRunErrorMessage = KErrMsgPauseTimeoutNotPositive; + User::Leave( KErrArgument ); + } + else + { + // Check is pause value suitable for RTimer::After + if( timeout < maximumTime ) + { + iPauseTimer.After( iStatus, ( timeout * 1000 ) ); + } + else + { + // Given pause value after multiplication with 1000 is + // larger than KMaxTInt, so we need to split it and + // re-request After with remaining value from RunL + + iRemainingTimeValue = timeout - maximumTime; + iPauseTimer.After( iStatus, maximumTime * 1000 ); + } + + SetActive(); + + // Stop execution after paused for given timeout + continueTask = EFalse; + } + } + break; + case TTestKeywords::EAllocate: + continueTask = ExecuteAllocateL( aItem ); + break; + case TTestKeywords::EFree: + continueTask = ExecuteFreeL( aItem ); + break; + case TTestKeywords::ERemote: + continueTask = ExecuteRemoteL( aItem ); + break; + case TTestKeywords::ELoop: + continueTask = ExecuteLoopL( aItem ); + break; + case TTestKeywords::EEndLoop: + continueTask = ExecuteEndLoopL( aItem ); + break; + case TTestKeywords::ETimeout: + case TTestKeywords::EPriority: + // not used here + break; + case TTestKeywords::EOOMIgnoreFailure: + { + OOMIgnoreFailureL( aItem ); // Handle parsing + break; + } + case TTestKeywords::EOOMHeapFailNext: + { + OOMHeapFailNextL( aItem ); // Handle parsing + break; + } + case TTestKeywords::EOOMHeapSetFail: + { + OOMHeapSetFailL( aItem ); // Handle parsing + break; + } + case TTestKeywords::EOOMHeapToNormal: + { + // Initialize all OOM related variables back to default. + OOMHeapToNormal(); + __TRACE( KMessage, ( + _L( "'oomheaptonormal' called, OOM initialization or ending OOM test") ) ); + break; + } + case TTestKeywords::ETestInterference: + { + TestInterferenceL( aItem ); // Handle parsing + break; + } + case TTestKeywords::EMeasurement: + { + MeasurementL( aItem ); // Handle parsing + break; + } + case TTestKeywords::EAllowErrorCodes: + { + // Check is KErrNone already appended to iTestCaseResults array. + if( iTestCaseResults.Find( KErrNone ) < 0 ) + { + // 'allowerrorcodes' keyword sets KErrNone as a default + User::LeaveIfError( iTestCaseResults.Append( KErrNone ) ); + // Set test case allow result to CTestModuleIf side too. This + // is used in TAL-TA5L macro handling. + User::LeaveIfError( + iTestScripter->TestModuleIf().SetAllowResult( KErrNone ) ); + } + + // Set user given specific error code to be allowed. + AddTestCaseResultL( aItem ); + } + break; + + case TTestKeywords::EBringToForeground: + { + if ( iTestScripter->TestModuleIf().UITesting() == true ) + { + iTestScripter->TestModuleIf().GetUiEnvProxy()->BringToForeground(); + } + else + { + __TRACE( KError, (_L("ExecuteLineL: Can't execute bringtoforeground in non s60 environment. Check if .cfg file name contains ui_ prefix and UITestingSupport= YES entry is defined in TestFrameworkd.ini"))); + iRunErrorMessage = KErrMsgBringToForegroundNotSupported; + User::Leave( KErrNotSupported ); + } + } + break; + case TTestKeywords::ESendToBackground: + { + if ( iTestScripter->TestModuleIf().UITesting() == true ) + { + iTestScripter->TestModuleIf().GetUiEnvProxy()->SendToBackground(); + } + else + { + __TRACE( KError, (_L("ExecuteLineL: Can't execute sendtobackground in non s60 environment. Check if .cfg file name contains ui_ prefix and UITestingSupport= YES entry is defined in TestFrameworkd.ini"))); + iRunErrorMessage = KErrMsgSendToBackgroundNotSupported; + User::Leave( KErrNotSupported ); + } + } + break; + case TTestKeywords::EPressKey: + { + if ( iTestScripter->TestModuleIf().UITesting() == true ) + { + continueTask = PressKeyL( aItem ); + } + else + { + __TRACE( KError, (_L("ExecuteLineL: Can't execute presskey in non s60 environment. Check if .cfg file name contains ui_ prefix and UITestingSupport= YES entry is defined in TestFrameworkd.ini"))); + iRunErrorMessage = KErrMsgPressKeyNotSupported; + User::Leave( KErrNotSupported ); + } + + // Check if it was global or local presskey + if ( !continueTask ) + { + // Stop execution after key is pressed and wait until it is handled + SetActive(); + } + } + break; + case TTestKeywords::ETypeText: + { + if ( iTestScripter->TestModuleIf().UITesting() == true ) + { + continueTask = TypeTextL( aItem ); + } + else + { + __TRACE( KError, (_L("ExecuteLineL: Can't execute typetext in non s60 environment. Check if .cfg file name contains ui_ prefix and UITestingSupport= YES entry is defined in TestFrameworkd.ini"))); + iRunErrorMessage = KErrMsgTypeTextNotSupported; + User::Leave( KErrNotSupported ); + } + + // Check if it was global or local typetext + if ( !continueTask ) + { + // Stop execution after key is pressed and wait until it is handled + SetActive(); + } + } + break; + case TTestKeywords::EVar: + { + TName name; + TName buf; + TPtrC tmp; + + //Get variable name + if(aItem->GetNextString(tmp) == KErrNone) + { + name.Copy(tmp); + } + else + { + //Error when getting variable name + __TRACE(KError, (_L("ExecuteLineL: Could not read variable name"))); + iRunErrorMessage = KErrVarNameError; + User::Leave(KErrArgument); + } + + //Get value for variable + while(aItem->GetNextString(tmp) == KErrNone) + { + if(buf.Length() + tmp.Length() >= buf.MaxLength()) + { + //Error when getting variable name + __TRACE(KError, (_L("ExecuteLineL: Variable value too long"))); + iRunErrorMessage = KErrVarValueError; + User::Leave(KErrArgument); + } + buf.Append(tmp); + buf.Append(_L(" ")); + } + //Remove last space + if(buf.Length() > 0) + { + buf.SetLength(buf.Length() - 1); + } + + //Store local variable + TInt count = iTestScripter->iDefinedLocal.Count(); + TInt i; + for(i = 0; i < count; i++) + { + if(iTestScripter->iDefinedLocal[i]->Name() == name) + { + // Update existing + iTestScripter->iDefinedLocal[i]->SetValueL(buf); + __TRACE(KMessage, (_L("Update local variable [%S]: [%S]"), &name, &buf)); + break; + } + } + if(i == count) + { + // New define, store it + CDefinedValue* define = CDefinedValue::NewL(name, buf); + CleanupStack::PushL(define); + User::LeaveIfError(iTestScripter->iDefinedLocal.Append(define)); + CleanupStack::Pop(define); + __TRACE(KMessage, (_L("Add local variable [%S]: [%S]"), &name, &buf)); + } + } + break; + case TTestKeywords::ECallSub: + { + // Get sub name + TPtrC subName; + + //Get sub name + TInt err = aItem->GetNextString(subName); + if(err != KErrNone) + { + //Error when getting sub name + __TRACE(KError, (_L("ExecuteLineL: Could not read sub name [%d]"), err)); + iRunErrorMessage = KErrSubNameError; + User::Leave(KErrArgument); + } + + // Load section + CStifSectionParser* subSection = NULL; + TRAP(err, + subSection = iTestScripter->GetSubL(subName); + ); + if((err != KErrNone) || (!subSection)) + { + //Error when getting sub name + if(err == KErrNone) + { + err = KErrArgument; + } + __TRACE(KError, (_L("ExecuteLineL: Could not get section for sub [%d]"), err)); + iRunErrorMessage = KErrSubGetError; + User::Leave(err); + } + + // Handle new section parser + CleanupStack::PushL(subSection); + iTestScripter->iParserStack.AppendL(subSection); + __TRACE(KMessage, (_L("ExecuteLineL: Section for sub [%S] appended to section stack"), &subName)); + CleanupStack::Pop(subSection); + iTestScripter->iCurrentParser = subSection; + iTestScripter->iCurrentParserReadFirstLine = EFalse; //Change it to false, becaue subSection is a new parser and it has nothing read + } + break; + case TTestKeywords::ESetResultDescription: + { + __TRACE(KMessage, (_L("%S"), &aKeyword)); + iTestScripter->TestModuleIf().Printf(KPrintPriLow, _L("Runner"), _L("%S"), &aKeyword); + + TName buf; + TPtrC tmp; + + while(aItem->GetNextString(tmp) == KErrNone) + { + if(buf.Length() + tmp.Length() >= buf.MaxLength()) + { + break; + } + if(buf.Length() > 0) + { + buf.Append(_L(" ")); + } + buf.Append(tmp); + } + + iTestScripter->SetResultDescription(buf); + RDebug::Print( _L("SetDescription to [%S]"), &buf ); + } + break; + case TTestKeywords::ESendPointerEvent: + { + if ( iTestScripter->TestModuleIf().UITesting() == true ) + { + continueTask = SendPointerEventL( aItem ); + } + else + { + __TRACE( KError, (_L("ExecuteLineL: Can't execute sendpointerevent in non s60 environment. Check if .cfg file name contains ui_ prefix and UITestingSupport= YES entry is defined in TestFrameworkd.ini"))); + iRunErrorMessage = KErrMsgSendPointerEventNotSupported; + User::Leave( KErrNotSupported ); + } + + // Check if it was global or local sendpointerevent + if ( !continueTask ) + { + // Stop execution after pointer event is send and wait until it is handled + SetActive(); + } + } + break; + case TTestKeywords::EUsing: + { + TInt err; + TPtrC dll; + err=aItem->GetNextString(dll); + err=iLibrary.Load(dll); + + User::LeaveIfError(err); + TLibraryFunction LibEntryL=iLibrary.Lookup(1); + iPlugins.Append((CStfTestLibPlugin*)LibEntryL()); + TPtrC temp; + err=aItem->GetNextString(temp); + HBufC* alias=HBufC::NewL(temp.Length()); + alias->Des().Copy(temp); + iPluginnames.Append(alias); + + break; + } + default: + { + if(ExecuteLibL(aKeyword, aItem)) + { + + } + else + { + continueTask = ExecuteCommandL( aKeyword, aItem ); + } + } + break; + } + + __TRACE( KMessage, (_L("ExecuteLineL: TestCase line executed"))); + CleanupStack::PopAndDestroy(&buf); + return continueTask; + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: ExecuteRunL + + Description: Executes run line + + Parameters: CStifItemParser* aItem: in: script line + + Return Values: ETrue: continue script file execution + EFalse: stop script file execution + + Errors/Exceptions: Leaves on error situations. + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +TBool CTestRunner::ExecuteRunL( CStifItemParser* aItem ) + { + _LIT( KErrMsgCaseRunError, "Run : %S[case=%d] run error" ); + __TRACE( KMessage, (_L("Run"))); + iTestScripter->TestModuleIf().Printf( KPrintPriExec, KExecute, _L("Run")); + + CStartInfo* startInfo = CStartInfo::NewL(); + CleanupStack::PushL( startInfo ); + + ParseRunParamsL( aItem, *startInfo ); + + // Start new case with configurations parsed above + + iRunErrorMessage.Format( KErrMsgCaseRunError, &startInfo->GetModuleName(), startInfo->GetTestCaseNumber() ); + + CSubTestCaseRunner* subTestCaseRunner = CLocalSubTestCaseRunner::NewLC( this ); + + __TRACE( KMessage, ( _L( "Executing sub test case: module=%S cfg=%S tcnum=%d id=%S" ), + &startInfo->GetModuleName(), &startInfo->GetConfig(), + startInfo->GetTestCaseNumber(), &startInfo->GetTestId()) ); + + RDebug::Print( _L( "Executing sub test case: module=%S cfg=%S tcnum=%d id=%S" ), + &startInfo->GetModuleName(), &startInfo->GetConfig(), + startInfo->GetTestCaseNumber(), &startInfo->GetTestId() ); + + subTestCaseRunner->RunSubTestCaseL( *startInfo ); + iSubTestCases.AppendL( subTestCaseRunner ); + if ( iLoopHelper->LoopInProgress() ) + { + iLoopHelper->RegisterInLoopSubTestCaseL( subTestCaseRunner ); + } + + CleanupStack::Pop( subTestCaseRunner ); + + iRunErrorMessage = KNullDesC; + + CleanupStack::PopAndDestroy( startInfo ); + + return ETrue; + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: ExecuteCompleteL + + Description: Executes complete line + + Parameters: CStifItemParser* aItem: in: script line + + Return Values: ETrue: continue script file execution + EFalse: stop script file execution + + Errors/Exceptions: Leaves on error situations. + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +TBool CTestRunner::ExecuteCompleteL( CStifItemParser* aItem ) + { + _LIT( KErrMsgTestIdNotDefined, "%S : testid is not defined" ); + TPtrC testId; + + TInt ret = KErrNone; + + TPtrC keywordStr = TTestKeywords::Keyword( TTestKeywords::EComplete ); + + // Parse testid + ret = aItem->GetNextString( testId ); + if( ret != KErrNone ) + { + iRunErrorMessage.Format( KErrMsgTestIdNotDefined, &keywordStr ); + User::Leave( ret ); + } + + for ( TInt i = 0; i < iSubTestCases.Count(); i++ ) + { + if ( iSubTestCases[ i ]->GetStartInfo()->GetTestId() == testId ) + { + delete iTestIdForComplete; + iTestIdForComplete = testId.AllocL(); + iInternalStateForSubTestCases = EISWaitingForComplete; + return EFalse; + } + } + + return ETrue; + } + + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: ParseRunParamsL + + Description: Parses run parameters + + Parameters: CStifItemParser* aItem: in: script line + CStartInfo& aStartInfo: out: Parsed information + + Return Values: None + + Errors/Exceptions: Leaves on error situations. + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CTestRunner::ParseRunParamsL( CStifItemParser* aItem, + CStartInfo& aStartInfo ) + { + _LIT( KErrMsgRunTestmoduleNameNotDefined, "Run : Testmodule name is not defined " ); + _LIT( KErrMsgRunCfgFileNotDefined, "Run : Testmodule configuration file is not defined" ); + _LIT( KErrMsgRunTestcaseNumberNotDefined, "Run : Testcase number is not defined or has invalid value" ); + _LIT( KErrMsgRunCfgFileNameToLong, "Run : TestScripter test case file(config)'s name is too long. Current length[%d], allowed max length[%d]. Cannot continue" ); + _LIT( KErrMsgRunInvalidExpectValue, "Run : Invalid expected result value" ); + _LIT( KErrMsgRunUnknownOrIllegalCategory, "Run : Unknown or illegal result category" ); + _LIT( KErrMsgRunInvalidTimeoutValue, "Run: Invalid testcase timeout value" ); + _LIT( KErrMsgRunUnknowOrIllegalKeyword, "Run: Unknown or illegal keyword %S" ); + + TPtrC tmp; + TInt ret = KErrNone; + + // Get mandatory run arguments + // Testmodule name + ret = aItem->GetNextString( tmp ); + if ( ret != KErrNone ) + { + iRunErrorMessage = KErrMsgRunTestmoduleNameNotDefined; + User::Leave( ret ); + } + + aStartInfo.SetModuleNameL( tmp ); + __TRACE( KMessage, (_L("module: %S"), &aStartInfo.GetModuleName() )); + + // Configuration file + ret = aItem->GetNextString( tmp ); + if ( ret != KErrNone ) + { + iRunErrorMessage = KErrMsgRunCfgFileNotDefined; + User::Leave( ret ); + } + + TFileName cfgFileName( tmp ); + TStifUtil::CorrectFilePathL( cfgFileName ); + aStartInfo.SetConfigL( cfgFileName ); + + __TRACE( KMessage, (_L("config: %S"), &aStartInfo.GetConfig() )); + + // Check is TestScripter + if( aStartInfo.GetModuleName().Find( KTestScripterName ) != KErrNotFound ) + { + // TestScripter name is format: 'testscripter_testcasefilename' + + TParse parse; + parse.Set( aStartInfo.GetConfig(), NULL, NULL ); + + // Maximum length of TestScripter's name(Max limitation from + // CTestModuleController creation) + TInt maximumLength = KMaxName - ( KTestScripterNameLength + 1 ); + + TFileName testScripterAndTestCaseFile; // InitL() takes TFileName + testScripterAndTestCaseFile.Copy( KTestScripterName ); + testScripterAndTestCaseFile.Append( _L( "_" ) ); + if( parse.Name().Length() < maximumLength ) + { + testScripterAndTestCaseFile.Append( parse.Name() ); + } + else + { + __TRACE( KInit, ( CStifLogger::ERed, + _L( "TestScripter test case file(config)'s name is too long. Current length[%d], allowed max length[%d]. Cannot continue" ), + parse.Name().Length(), maximumLength ) ); + iRunErrorMessage.Format( KErrMsgRunCfgFileNameToLong, parse.Name().Length(), maximumLength ); + User::Leave( KErrArgument ); + } + aStartInfo.SetModuleNameL( testScripterAndTestCaseFile ); + } + + // Testcase number + TInt testCaseNumber; + ret = aItem->GetInt( tmp, testCaseNumber ); + if ( ret != KErrNone ) + { + iRunErrorMessage = KErrMsgRunTestcaseNumberNotDefined; + User::Leave( ret ); + } + aStartInfo.SetTestCaseNumber( testCaseNumber ); + + __TRACE( KMessage, (_L("testcasenum: %d"), testCaseNumber ) ); + + // Set mode of item parser to be able to read titles with spaces inside + aItem->SetParsingType(CStifItemParser::EQuoteStyleParsing); + + // Get optional run arguments + while( aItem->GetNextString( tmp ) == KErrNone ) + { + TPtrC val; + TPtrC arg; + ParseOptArgL( tmp, arg, val ); + CheckDefined( val ); + + // Parse optional argument + switch( TTestKeywords::Parse( arg, TTestKeywords::RunOptArg ) ) + { + case TTestKeywords::EExpect: + { + TLex ptr( val ); + TInt expectedResult; + ret = ptr.Val( expectedResult ); + if ( ret != KErrNone ) + { + iRunErrorMessage = KErrMsgRunInvalidExpectValue; + User::Leave( ret ); + } + aStartInfo.SetExpectedResult( expectedResult ); + __TRACE( KMessage, (_L("expect=%d"), expectedResult )); + } + break; + case TTestKeywords::ETestid: + { + aStartInfo.SetTestIdL( val ); + __TRACE( KMessage, (_L("TestId=%S"), &val)); + } + break; + case TTestKeywords::EIni: + { + __TRACE( KMessage, (_L("ini=%S"), &val)); + TFileName iniFileName( val ); + TStifUtil::CorrectFilePathL( iniFileName ); + aStartInfo.SetIniFileL( iniFileName ); + } + break; + case TTestKeywords::ECategory: + { + __TRACE( KMessage, (_L("category=%S"), &val)); + aStartInfo.SetExpectedResultCategory( TTestKeywords::GetResultCategory( val ) ); + if( aStartInfo.GetExpectedResultCategory() == TFullTestResult::ECaseOngoing ) + { + __TRACE( KError, (_L("Unknown or illegal result category"))); + //Unknown or illegal category + iRunErrorMessage = KErrMsgRunUnknownOrIllegalCategory; + User::Leave( KErrGeneral ); + } + } + break; + case TTestKeywords::ECaseTimeout: + { + TInt timeout; + TLex ptr( val ); + ret = ptr.Val( timeout ); + if ( ret != KErrNone ) + { + iRunErrorMessage = KErrMsgRunInvalidTimeoutValue; + User::Leave( ret ); + } + aStartInfo.SetTimeout( timeout ); + __TRACE( KMessage, (_L("timeout=%d"), timeout ) ); + } + break; + case TTestKeywords::ECaseTitle: + { + __TRACE( KMessage, (_L("case title=%S"), &val)); + aStartInfo.SetTitleL(val); + break; + } + default: + { + __TRACE( KError, (_L("Unknown or illegal keyword"))); + //Unknown or illegal keyword + iRunErrorMessage.Format( KErrMsgRunUnknowOrIllegalKeyword, &arg ); + User::Leave( KErrGeneral ); + } + } + } + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: ParseOptArgL + + Description: Parses optional argument + + Parameters: const TDesC& aOptArg: in: + argument-value pair (format arg=value) + TPtrC& aArg: out: parsed argument + TPtrC& aVal: out: parsed value + + Return Values: None + + Errors/Exceptions: Leaves if parsing fails. + + Status: Approved + +------------------------------------------------------------------------------- +*/ +void CTestRunner::ParseOptArgL( const TDesC& aOptArg, TPtrC& aArg, TPtrC& aVal) + { + _LIT( KErrMsgUnknownOrIllegalKeyword, "Unknown or illegal argument %S" ); + _LIT( KErrMsgValueNotDefined, "Value of optional argument %S is not defined" ); + TInt length = aOptArg.Length(); + for( TInt i=0; i < length; i++) + { + // find the '=' sign + if( aOptArg[i] == '=' ) + { + if( i+1 >= length ) + { + __TRACE( KError, + (_L("Illegal optional argument(%S), no value"), + &aOptArg )); + TPtrC tmp = aOptArg.Left( i ); + iRunErrorMessage.Format( KErrMsgValueNotDefined, &tmp ); + User::Leave( KErrArgument ); + } + aArg.Set( aOptArg.Left( i ) ); + aVal.Set( aOptArg.Mid( i+1 ) ); + __TRACE( KMessage, ( _L( "arg '%S', val '%S'" ), + &aArg, &aVal )); + return; + } + } + __TRACE( KError, (_L("Illegal optional argument(%S)"), &aOptArg )); + iRunErrorMessage.Format( KErrMsgUnknownOrIllegalKeyword, &aOptArg ); + User::Leave( KErrArgument ); + + } + +TBool CompareTDesC(const TDesC8& aLeft,const TDesC8& aRight) +{ + return aLeft.Compare(aRight) == 0 ? ETrue : EFalse; + +} + + + +/** +* Executes method call to object script line. +*/ +TBool CTestRunner::ExecuteLibL( TDesC& lib, + CStifItemParser* aItem ) +{ + TBool result=EFalse; + TIdentityRelation relation(CompareTDesC); + TInt count=iPluginnames.Count(); + TInt index; + for( index=0;indexDes(); + if(tempptr==lib) + { + TPtrC partcommand; + TBuf<300> commandline; + TBuf<100> command; + result=ETrue; + TInt i=0; + while(aItem->GetNextString(partcommand)==KErrNone) + { + if(i==0) + { + command.Append(partcommand); + } + commandline.Append(partcommand); + commandline.Append(_L(" ")); + i++; + } + commandline.TrimAll(); + if(iPlugins[index]->IsCommandSupported(command)) + + { + iPlugins[index]->ExecuteCommandL(commandline); + } + break; + } + } + return result; +} +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: PressKeyL + + Description: Send key press event to AppUi + + Parameters: CStifItemParser* aItem: in: script line + + Return Values: None + + Errors/Exceptions: Leaves on error situations. + + Status: Draft + +------------------------------------------------------------------------------- +*/ +TBool CTestRunner::PressKeyL( CStifItemParser* aItem ) + { + _LIT( KErrMsgSendKeyEventInvalidParameterValue, "PressKey: Invalid parameter %s value " ); + _LIT( KErrMsgSendKeyEventInvalidParameter, "PressKey: Invalid parameter %s" ); + + _LIT( KKeyCodeParameter, "keycode=" ); + _LIT( KKeyScanCodeParameter, "keyscancode=" ); + _LIT( KModifierParameter, "modifier=" ); + _LIT( KRepeatsParameter, "repeats=" ); + + _LIT( KModeGlobal, "global" ); + _LIT( KModeLocal, "local" ); + + TBool globalMode = EFalse; + TUint keyCode = 0; + TInt keyScanCode = 0; + TUint keyModifiers = 0; + TInt keyRepeats = 0; + + TPtrC parameter; + + CUiEnvProxy* uiEnvProxy = iTestScripter->TestModuleIf().GetUiEnvProxy(); + + while( aItem->GetNextString( parameter ) == KErrNone ) + { + if ( parameter.Find( KKeyCodeParameter ) == 0 ) + { + TPtrC parameterValue = parameter.Right( parameter.Length() - KKeyCodeParameter().Length() ); + TLex parameterValueParser( parameterValue ); + if ( parameterValueParser.Val( keyCode ) != KErrNone ) + { + if ( uiEnvProxy->ParseKeyCode( parameterValue, keyCode ) != KErrNone ) + { + __TRACE( KError, (_L("SendKeyEvent: Invalid parameter value"))); + TBuf<128> errMsg; + errMsg.Format( KErrMsgSendKeyEventInvalidParameterValue, &KKeyCodeParameter() ); + iRunErrorMessage = errMsg; + User::Leave( KErrArgument ); + } + } + } + else if ( parameter.Find( KKeyScanCodeParameter ) == 0 ) + { + TPtrC parameterValue = parameter.Right( parameter.Length() - KKeyScanCodeParameter().Length() ); + TLex parameterValueParser( parameterValue ); + if ( parameterValueParser.Val( keyScanCode ) != KErrNone ) + { + if ( uiEnvProxy->ParseKeyScanCode( parameterValue, keyScanCode ) != KErrNone ) + { + __TRACE( KError, (_L("SendKeyEvent: Invalid parameter value"))); + TBuf<128> errMsg; + errMsg.Format( KErrMsgSendKeyEventInvalidParameterValue, &KKeyCodeParameter() ); + iRunErrorMessage = errMsg; + User::Leave( KErrArgument ); + } + } + } + else if ( parameter.Find( KModifierParameter ) == 0 ) + { + TPtrC parameterValue = parameter.Right( parameter.Length() - KModifierParameter().Length() ); + TLex parameterValueParser( parameterValue ); + if ( parameterValueParser.Val( keyModifiers ) != KErrNone ) + { + if ( uiEnvProxy->ParseModifier( parameterValue, keyModifiers ) != KErrNone ) + { + __TRACE( KError, (_L("SendKeyEvent: Invalid parameter value"))); + TBuf<128> errMsg; + errMsg.Format( KErrMsgSendKeyEventInvalidParameterValue, &KModifierParameter() ); + iRunErrorMessage = errMsg; + User::Leave( KErrArgument ); + } + } + } + else if ( parameter.Find( KRepeatsParameter ) == 0 ) + { + TPtrC parameterValue = parameter.Right( parameter.Length() - KRepeatsParameter().Length() ); + TLex parameterValueParser( parameterValue ); + if ( parameterValueParser.Val( keyRepeats ) != KErrNone ) + { + __TRACE( KError, (_L("SendKeyEvent: Invalid parameter value"))); + TBuf<128> errMsg; + errMsg.Format( KErrMsgSendKeyEventInvalidParameterValue, &KRepeatsParameter() ); + iRunErrorMessage = errMsg; + User::Leave( KErrArgument ); + } + } + else if ( parameter == KModeGlobal ) + { + globalMode = ETrue; + } + else if ( parameter == KModeLocal ) + { + globalMode = EFalse; + } + else if ( uiEnvProxy->ParseKeyCode( parameter, keyCode ) == KErrNone ) + { + } + else if ( parameter.Length() == 1 ) + { + keyCode = parameter[ 0 ]; + } + else + { + __TRACE( KError, (_L("PressKey: Invalid parameter"))); + TBuf<128> errMsg; + errMsg.Format( KErrMsgSendKeyEventInvalidParameter, ¶meter ); + iRunErrorMessage = errMsg; + User::Leave( KErrArgument ); + } + } + + if ( globalMode ) + { + uiEnvProxy->PressKeyL( keyCode, keyScanCode, keyModifiers, keyRepeats ); + } + else + { + uiEnvProxy->PressKeyL( &iStatus, keyCode, keyScanCode, keyModifiers, keyRepeats ); + } + + return globalMode; + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: TypeTextL + + Description: Sends text to AppUi + + Parameters: CStifItemParser* aItem: in: script line + + Return Values: None + + Errors/Exceptions: Leaves on error situations. + + Status: Draft + +------------------------------------------------------------------------------- +*/ +TBool CTestRunner::TypeTextL( CStifItemParser* aItem ) + { + _LIT( KErrMsgTypeTextInvalidParameter, "TypeText: Invalid parameter %S" ); + _LIT( KErrMsgTypeTextNotEnoughParameters, "TypeText: Not enough parameters" ); + + TBool globalMode = EFalse; + + TPtrC command; + TPtrC text; + aItem->SetParsingType( CStifItemParser::EQuoteStyleParsing ); + + // Read first parameter + TInt ret = aItem->GetNextString( command ); + + if ( ret != KErrNone ) + { + __TRACE( KError, (_L("TypeText: Not enough parameters"))); + iRunErrorMessage = KErrMsgTypeTextNotEnoughParameters; + User::Leave( ret ); + } + + // Read second parameter + ret = aItem->GetNextString( text ); + + // Check if second can be read. if yes then check if first parameters is + // 'global' parameter + if ( ret != KErrNone ) + { + // normal type text + text.Set( command ); + iTestScripter->TestModuleIf().GetUiEnvProxy()->TypeTextL( &iStatus, text ); + globalMode = EFalse; + } + else if ( command == _L("global") ) + { + iTestScripter->TestModuleIf().GetUiEnvProxy()->TypeTextL( text ); + globalMode = ETrue; + } + else + { + __TRACE( KError, (_L("TypeText: Invalid parameter"))); + TBuf<128> errMsg; + errMsg.Format( KErrMsgTypeTextInvalidParameter, &command ); + iRunErrorMessage = errMsg; + User::Leave( KErrNotSupported ); + } + + return globalMode; + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: SendPointerEventL + + Description: Send key press event to AppUi + + Parameters: CStifItemParser* aItem: in: script line + + Return Values: None + + Errors/Exceptions: Leaves on error situations. + + Status: Draft + +------------------------------------------------------------------------------- +*/ +TBool CTestRunner::SendPointerEventL( CStifItemParser* aItem ) + { + // Error messages + _LIT( KErrMsgNotEnoughParameters, "SendPointerEvent: Not enough parameters" ); + _LIT( KErrMsgPointerEventTypeNotDefined, "SendPointerEvent: Pointer event type not defined" ); + _LIT( KErrMsgInvalidUnknownPointerEventType, "SendPointerEvent: Invalid/Unknown pointer event type %S" ); + _LIT( KErrMsgPositionXNotDefined, "SendPointerEvent: x co-ordinate is not defined" ); + _LIT( KErrMsgPositionYNotDefined, "SendPointerEvent: y co-ordinate is not defined" ); + _LIT( KErrMsgPositionXInvalidValue, "SendPointerEvent: Invalid value of x co-ordinate" ); + _LIT( KErrMsgPositionYInvalidValue, "SendPointerEvent: Invalid value of y co-ordinate" ); + + // Parameters keywords + _LIT( KModeGlobal, "global" ); + _LIT( KModeLocal, "local" ); + + TBool globalMode = EFalse; + TUint eventType = 0; + TPoint position( 0, 0 ); + TPoint parentPosition( 0, 0 ); + + TPtrC parameter; + + CUiEnvProxy* uiEnvProxy = iTestScripter->TestModuleIf().GetUiEnvProxy(); + + // Get first parameter + if ( aItem->GetNextString( parameter ) != KErrNone ) + { + __TRACE( KError, (_L("SendPointerEvent: Not enough parameters"))); + iRunErrorMessage = KErrMsgNotEnoughParameters; + User::Leave( KErrArgument ); + } + else + { + TBool modeSelected = EFalse; + // Check if global/local mode is defined + if ( parameter == KModeLocal ) + { + globalMode = false; + modeSelected = ETrue; + } + else if ( parameter == KModeGlobal ) + { + globalMode = true; + modeSelected = ETrue; + } + + if ( modeSelected ) + { + // First parameter was mode so we need get next parameter which should + // contain event type + if ( aItem->GetNextString( parameter ) != KErrNone ) + { + __TRACE( KError, (_L("SendPointerEvent: Pointer event type not defined"))); + iRunErrorMessage = KErrMsgPointerEventTypeNotDefined; + User::Leave( KErrArgument ); + } + } + } + + // Parse event type + if ( uiEnvProxy->ParsePointerEventType( parameter, eventType ) != KErrNone ) + { + __TRACE( KError, (_L("PressKey: Invalid/Unknown pointer event type %S"), ¶meter )); + iRunErrorMessage.Format( KErrMsgInvalidUnknownPointerEventType, ¶meter ); + User::Leave( KErrArgument ); + } + + if ( aItem->GetNextString( parameter ) != KErrNone ) + { + __TRACE( KError, (_L("SendPointerEvent: x co-ordinate is not defined"))); + iRunErrorMessage = KErrMsgPositionXNotDefined; + User::Leave( KErrArgument ); + } + + TLex parameterParser( parameter ); + if ( parameterParser.Val( position.iX ) != KErrNone ) + { + __TRACE( KError, (_L("SendPointerEvent: Invalid value of x co-ordinate"))); + iRunErrorMessage = KErrMsgPositionXInvalidValue; + User::Leave( KErrArgument ); + } + + if ( aItem->GetNextString( parameter ) != KErrNone ) + { + __TRACE( KError, (_L("SendPointerEvent: y co-ordinate is not defined"))); + iRunErrorMessage = KErrMsgPositionYNotDefined; + User::Leave( KErrArgument ); + } + + parameterParser.Assign( parameter ); + if ( parameterParser.Val( position.iY ) != KErrNone ) + { + __TRACE( KError, (_L("SendPointerEvent: Invalid value of y co-ordinate"))); + iRunErrorMessage = KErrMsgPositionYInvalidValue; + User::Leave( KErrArgument ); + } + + // Send pointer event + if ( globalMode ) + { + uiEnvProxy->SendPointerEventL( eventType, position ); + } + else + { + uiEnvProxy->SendPointerEventL( &iStatus, eventType, position ); + } + + return globalMode; + } + + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: ExecuteEventL + + Description: Executes event command script line + + Parameters: TDesC& aKeyword: in: keyword string + CStifItemParser* aItem: in: script line + + Return Values: ETrue: continue script file execution + EFalse: stop script file execution + + Errors/Exceptions: Leaves on error situations. + + Status: Draft + +------------------------------------------------------------------------------- +*/ +TBool CTestRunner::ExecuteEventL( TDesC& aKeyword, + CStifItemParser* aItem ) + { + _LIT( KErrMsgEventNameNotDefined, "%S : Event name not defined" ); + _LIT( KErrMsgUnknowKeyword, "Unknow keyword %S" ); + + TInt ret = KErrNone; + TInt key = TTestKeywords::Parse( aKeyword, TTestKeywords::Keyword ); + TBool continueTask = ETrue; + + TPtrC eventName; + // read eventname + ret = aItem->GetNextString( eventName ); + if ( ret != KErrNone ) + { + iRunErrorMessage.Format( KErrMsgEventNameNotDefined, &aKeyword ); + User::Leave( ret ); + } + + TEventIf event; + event.SetName( eventName ); + + __TRACE( KMessage, (_L("%S %S"), &aKeyword, &eventName)); + iTestScripter->TestModuleIf().Printf( KPrintPriLow, _L("Event"), + _L("%S %S"), &aKeyword, &eventName); + + switch( key ) + { + case TTestKeywords::ERequest: + { + HBufC* eName = eventName.AllocLC(); + User::LeaveIfError( iEventArray.Append( eName ) ); + CleanupStack::Pop( eName ); + event.SetType( TEventIf::EReqEvent ); + ret = iTestScripter->TestModuleIf().Event( event ); + } + break; + case TTestKeywords::EWait: + { + event.SetType( TEventIf::EWaitEvent ); + iTestScripter->TestModuleIf().Event( event, iStatus ); + SetActive(); + continueTask = EFalse; + } + break; + case TTestKeywords::ERelease: + { + event.SetType( TEventIf::ERelEvent ); + ret = iTestScripter->TestModuleIf().Event( event ); + if( ret == KErrNone ) + { + TPtrC eName; + TInt count = iEventArray.Count(); + for( TInt i = 0; i < count; i++ ) + { + eName.Set( iEventArray[i]->Des() ); + if( eName == eventName ) + { + HBufC* tmp = iEventArray[i]; + iEventArray.Remove(i); + delete tmp; + break; + } + } + } + } + break; + case TTestKeywords::ESet: + { + event.SetType( TEventIf::ESetEvent ); + + TPtrC tmp; + // Get optional set argument + if( aItem->GetNextString( tmp ) == KErrNone ) + { + // Parse optional set argument + if( tmp == _L("state") ) + { + __TRACE( KMessage, (_L("State event"))); + event.SetEventType( TEventIf::EState ); + } + else + { + __TRACE( KError, + (_L("Unknown argument for set %S"), + &tmp)); + } + } + + ret = iTestScripter->TestModuleIf().Event( event ); + } + break; + case TTestKeywords::EUnset: + { + event.SetType( TEventIf::EUnsetEvent ); + event.SetEventType( TEventIf::EState ); + ret = iTestScripter->TestModuleIf().Event( event ); + } + break; + default: + __TRACE( KError, (_L("Unknown keyword %S"), &aKeyword)); + iRunErrorMessage.Format( KErrMsgUnknowKeyword, &aKeyword ); + User::Leave( KErrGeneral ); + break; + } + if( ret != KErrNone ) + { + TName resultDescr; + resultDescr.Format(_L("Event %S returned error: %d"), &aKeyword, ret); + iTestScripter->UpdateTestCaseResult(ret, resultDescr); + // Stops execution from CTestRunner::RunError + User::Leave( KErrGeneral ); + } + + return continueTask; + + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: ExecuteCommandL + + Description: Executes script line + + Parameters: TDesC& aObject: in: object name + CStifItemParser* aItem: in: script line + + Return Values: ETrue: continue script file execution + EFalse: stop script file execution + + Errors/Exceptions: Leaves on error situations. + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +TBool CTestRunner::ExecuteCommandL( TDesC& aObject, CStifItemParser* aItem) + { + _LIT( KErrMsgUnknownObjOrKeyword, "Unknow keyword/object %S" ); + + + TTestObjectBase* obj = iTestScripter->GetObject ( aObject ); + if( obj == NULL ) + { + iRunErrorMessage.Format( KErrMsgUnknownObjOrKeyword, &aObject ); + User::Leave( KErrGeneral ); + } + + if( iTestCaseResults.Count() == 0 ) + { + // KErrNone is the default result expected if nothing else is given + User::LeaveIfError( iTestCaseResults.Append( KErrNone ) ); + } + + // OOM heap testing with FAILNEXT + if( iHeapFailNext > 0 ) + { + __TRACE( KPrint, ( + _L( "OOM FAILNEXT is used with count value: %d " ), + iHeapFailNext) ); + User::__DbgSetAllocFail( RHeap::EUser, RHeap::EFailNext, iHeapFailNext ); + } + // OOM heap testing with SETFAIL + if( iHeapSetFailValue > 0 ) + { + __TRACE( KPrint, ( + _L("OOM SETFAIL is used with type:[%d] and value(rate):[%d]"), + iHeapSetFailType, iHeapSetFailValue ) ); + User::__DbgSetAllocFail( RHeap::EUser, iHeapSetFailType, iHeapSetFailValue ); + } + + TInt commandResult = KErrNone; + TRAP( commandResult, commandResult = obj->RunMethodL( *aItem ) ); + + + // Reset OOM macro immediately(Otherwise other allocations + // will be blocked) + User::__DbgSetAllocFail( RHeap::EUser, RHeap::ENone, 1 ); + + // OOM test class's build block handling + if( iTestScripter->iOOMIgnoreFailure ) + { + __TRACE( KPrint, ( + _L( "----------< OOM related test information >----------" ) ) ); + if( iHeapFailNext > 0 ) + { + __TRACE( KPrint, ( + _L( "'oomignorefailure' is:[ON] and 'failnextvalue' count is:[%d]" ), + iHeapFailNext ) ); + } + if( iHeapSetFailValue > 0 ) + { + __TRACE( KPrint, ( + _L( "'oomignorefailure' is:[ON], 'setfailtype' type is:[%d] and value is:[%d]" ), + iHeapSetFailType, iHeapSetFailValue ) ); + } + __TRACE( KPrint, ( + _L( "Test class build block execution with result:[%d]" ), + commandResult ) ); + __TRACE( KPrint, ( + _L( "----------------------------------------------------" ) ) ); + + // Continue testing, despite the memory error situations + iTestCaseResults.Reset(); + return ETrue; // Continue script executions + } + + // Normal test class's build block handling + if( iTestCaseResults.Find( commandResult ) < 0 ) + { + __TRACE( KError, ( _L("Command for [%S] failed (%d)"), + &aObject, commandResult )); + + // Added more logging for this special case + if( commandResult == KErrNone ) + { + __TRACE( KError, (_L("Test fails with result KErrGeneral, because execution result was KErrNone and expected results given with 'allownextresult' were Symbian's error codes (<0)"))); + } + + iTestScripter->UpdateTestCaseResult(commandResult, _L("CTestRunner::ExecuteCommandL returned error")); + + // Stops execution from CTestRunner::RunError + User::Leave( KErrGeneral ); + } + + iTestCaseResults.Reset(); + // Reset test case allow result to CTestModuleIf side too. This is + // used in TAL-TA5L macro handling. + User::LeaveIfError( + iTestScripter->TestModuleIf().ResetAllowResult() ); + + return ETrue; + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: SetRunnerActive + + Description: Set CTestRunner active and complete. + + Parameters: None. + + Return Values: None. + + Errors/Exceptions: None. + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CTestRunner::SetRunnerActive() + { + __TRACEFUNC(); + // Update state + iState = ERunnerRunning; + + iStatus = KRequestPending; + TRequestStatus* rs = &iStatus; + SetActive(); + User::RequestComplete( rs, KErrNone ); + + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: OOMIgnoreFailure + + Description: Handles 'oomignorefailure' keyword parsing. + + Parameters: CStifItemParser* aItem: in: Item object for parsing. + + Return Values: None. + + Errors/Exceptions: None. + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +void CTestRunner::OOMIgnoreFailureL( CStifItemParser* aItem ) + { + _LIT( KerrMsgOOMIgnoreFailureUnknownArgument, "OOMIgnoreFailure : Invalid argument %S" ); + _LIT( KerrMsgOOMIgnoreFailureNoArgument, "OOMIgnoreFailure : Parameter not defined" ); + + __TRACEFUNC(); + + TPtrC tmp; + // Get result + if( aItem->GetNextString( tmp ) == KErrNone ) + { + if( tmp == _L("ON") || tmp == _L("on") ) + { + __TRACE( KMessage, (_L("OOM related 'oomignorefailure': ON"))); + iTestScripter->iOOMIgnoreFailure = ETrue; + } + else if( tmp == _L("OFF") || tmp == _L("off") ) + { + __TRACE( KMessage, (_L("OOM related 'oomignorefailure': OFF"))); + iTestScripter->iOOMIgnoreFailure = EFalse; + } + else + { + __TRACE( KError, + (_L("Unknown argument for 'oomignorefailure': [%S]"), + &tmp)); + iRunErrorMessage.Format( KerrMsgOOMIgnoreFailureUnknownArgument, &tmp ); + User::Leave( KErrArgument ); + } + } + else + { + __TRACE( KError, ( _L( "Unknown argument for 'oomignorefailure'" ) ) ); + iRunErrorMessage = KerrMsgOOMIgnoreFailureNoArgument; + User::Leave( KErrArgument ); + } + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: OOMHeapFailNext + + Description: Handles 'oomheapfailnext' keyword parsing. + + Parameters: CStifItemParser* aItem: in: Item object for parsing. + + Return Values: None. + + Errors/Exceptions: None. + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +void CTestRunner::OOMHeapFailNextL( CStifItemParser* aItem ) + { + _LIT( KErrMsgHeapFailNextNoArgument, "HeapFailNext : Parameters is not defined or has invalid value" ); + _LIT( KErrMsgHeapFailNextInvalidValue, "HeapFailNext : Argument value can't be <0" ); + __TRACEFUNC(); + + TInt heapfailNext( 0 ); + // If LOOP_COUNTER is used the GetNextInt returns a correct + // value(Because of the LOOP_COUNTER implementation). + if( aItem->GetNextInt( heapfailNext ) == KErrNone ) + { + if( heapfailNext < 0 ) + { + __TRACE( KError, ( _L( "Argument value must be >0" ) ) ); + iRunErrorMessage = KErrMsgHeapFailNextInvalidValue; + User::Leave( KErrArgument ); + } + // OOM heap's FAILNEXT range is from 1 to n + iHeapFailNext = heapfailNext + 1; + __TRACE( KMessage, ( _L( "'oomheapfailnext' count value(rate): %d" ), + iHeapFailNext ) ); + } + else + { + __TRACE( KError, ( _L( "Unknown argument for 'oomheapfailnext'" ) ) ); + iRunErrorMessage = KErrMsgHeapFailNextNoArgument; + User::Leave( KErrArgument ); + } + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: OOMHeapSetFail + + Description: Handles 'oomheapsetfail' keyword parsing. + + Parameters: CStifItemParser* aItem: in: Item object for parsing. + + Return Values: None. + + Errors/Exceptions: None. + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +void CTestRunner::OOMHeapSetFailL( CStifItemParser* aItem ) + { + _LIT( KErrMsgOOMHeapSetFailTypeNotDefined, "OOMHeapSetFail : Parameter type is not defined" ); + _LIT( KErrMsgOOMHeapSetFailRateNotDefined, "OOMHeapSetFail : Parameter rate is not defined" ); + _LIT( KErrMsgOOMHeapSetFailTypeInvalidValue, "OOMHeapSetFail : Parameter type has invalid value" ); + _LIT( KErrMsgOOMHeapSetFailRateInvalidValue, "OOMHeapSetFail : Parameter rate can't be <0" ); + __TRACEFUNC(); + + _LIT( KRandom, "random"); + _LIT( KTrueRandom, "truerandom"); + _LIT( KDeterministic, "deterministic"); + _LIT( KNone, "none"); + _LIT( KFailNext, "failnext"); + + TPtrC type; + TInt value( 0 ); + + // NOTE: If error in type or value parsing => return without changing + // iHeapSetFailType or iHeapSetFailValue variables. + + // Get type + if( aItem->GetNextString( type ) != KErrNone ) + { + __TRACE( KError, ( + _L( "Unknown argument for 'oomheapsetfail' type" ) ) ); + iRunErrorMessage = KErrMsgOOMHeapSetFailTypeNotDefined; + User::Leave( KErrArgument ); + } + // Get value(rate) + if( aItem->GetNextInt( value ) != KErrNone ) + { + if(type == KNone) + { + value = 0; + } + else + { + __TRACE( KError, (_L( "Unknown argument for 'oomheapsetfail' value(rate)" ) ) ); + iRunErrorMessage = KErrMsgOOMHeapSetFailRateNotDefined; + User::Leave( KErrArgument ); + } + } + + // All parsing operations are passed, get type and value + + // Get type + if(type == KRandom) + { + __TRACE( KMessage, (_L("'oomheapsetfail' type: random"))); + iHeapSetFailType = RHeap::ERandom; + } + else if(type == KTrueRandom) + { + __TRACE( KMessage, (_L("'oomheapsetfail' type: truerandom"))); + iHeapSetFailType = RHeap::ETrueRandom; + } + else if(type == KDeterministic) + { + __TRACE( KMessage, (_L("'oomheapsetfail' type: deterministic"))); + iHeapSetFailType = RHeap::EDeterministic; + } + else if(type == KNone) + { + __TRACE( KMessage, (_L("'oomheapsetfail' type: none"))); + iHeapSetFailType = RHeap::ENone; + } + else if(type == KFailNext) + { + __TRACE( KMessage, (_L("'oomheapsetfail' type: failnext"))); + iHeapSetFailType = RHeap::EFailNext; + } + else + { + __TRACE( KError, + ( _L( "Unknown argument for 'oomheapsetfail' type: [%S]" ), + &type ) ); + iRunErrorMessage = KErrMsgOOMHeapSetFailTypeInvalidValue; + User::Leave( KErrArgument ); + } + + if( value < 0 ) + { + __TRACE( KError, _L( "'oomheapsetfail' value(rate) can't be <0" ) ); + iRunErrorMessage = KErrMsgOOMHeapSetFailRateInvalidValue; + User::Leave( KErrArgument ); + } + // Get value + // OOM heap's SETFAIL range is from 1 to n + iHeapSetFailValue = value + 1; + __TRACE(KMessage, (_L( "'oomheapsetfail' value(rate): [%d]" ), iHeapSetFailValue)); + + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: OOMHeapToNormal + + Description: Initialize all OOM related variables. + + Parameters: None. + + Return Values: None. + + Errors/Exceptions: None. + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +void CTestRunner::OOMHeapToNormal() + { + __TRACEFUNC(); + + if( iTestScripter ) + { + // This should initialize also + iTestScripter->iOOMIgnoreFailure = EFalse; + } + + iHeapFailNext = 0; + iHeapSetFailType = RHeap::ENone; + iHeapSetFailValue = 0; + + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: TestInterference + + Description: Starts test interference. + + Parameters: CStifItemParser* aItem: in: Item object for parsing. + + Return Values: None. + + Errors/Exceptions: None. + + Status: Approved + +------------------------------------------------------------------------------- +*/ +void CTestRunner::TestInterferenceL( CStifItemParser* aItem ) + { + _LIT( KErrMsgTestInterferenceNameNotDefined, "TestInterference : Parameter name is not defined" ); + _LIT( KErrMsgTestInterferenceCommandNotDefined, "TestInterference : Parameter command is not defined" ); + _LIT( KErrMsgTestInterferenceCommandInvalidValue, "TestInterference : Parameter command has invalid value" ); + __TRACEFUNC(); + TPtrC name; + TPtrC command; + + // Get name + if( aItem->GetNextString( name ) != KErrNone ) + { + __TRACE( KError, ( + _L( "Unknown argument for 'testinterference' name" ) ) ); + iRunErrorMessage = KErrMsgTestInterferenceNameNotDefined; + User::Leave( KErrArgument ); // Error in parsing => Leave + } + // Get command + if( aItem->GetNextString( command ) != KErrNone ) + { + __TRACE( KError, ( + _L( "Unknown argument for 'testinterference' command" ) ) ); + iRunErrorMessage = KErrMsgTestInterferenceCommandNotDefined; + User::Leave( KErrArgument ); // Error in parsing => Leave + } + + if( command == _L( "start" ) ) + { + __TRACE( KMessage, ( _L( "'testinterference' called, starts test interference") ) ); + StartInterferenceL( name, aItem ); + } + else if( command == _L( "stop" ) ) + { + __TRACE( KMessage, ( _L( "'testinterference' called, stops and releases test interference") ) ); + StopInterferenceL( name ); + } + else + { + __TRACE( KError, ( + _L( "Unknown command for 'testinterference'[%S]" ), &command ) ); + iRunErrorMessage = KErrMsgTestInterferenceCommandInvalidValue; + User::Leave( KErrArgument ); // Error in parsing => Leave + } + + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: StartInterference + + Description: + + Parameters: CStifItemParser* aItem: in: Item object for parsing. + + Return Values: None. + + Errors/Exceptions: None. + + Status: Approved + +------------------------------------------------------------------------------- +*/ +void CTestRunner::StartInterferenceL( TDesC& aName, CStifItemParser* aItem ) + { + _LIT( KErrMsgStartInterferenceCategoryNotDefined, "TestInterference : Parameter category is not defined" ); + _LIT( KErrMsgStartInterferenceCategoryInvalidValue, "TestInterference : Parameter category has invalid value" ); + _LIT( KErrMsgStartInterferenceTypeNotDefined, "TestInterference : Parameter type is not defined" ); + _LIT( KErrMsgStartInterferenceTypeInvalidValue, "TestInterference : Parameter type has invalid value" ); + _LIT( KErrMsgStartInterferenceIdleNotDefined, "TestInterference : Parameter idle is not defined or has invalid value" ); + _LIT( KErrMsgStartInterferenceIdleInvalidValue, "TestInterference : Parameter idle has invalid value" ); + _LIT( KErrMsgStartInterferenceActiveNotDefined, "TestInterference : Parameter active is not defined or has invalid value" ); + _LIT( KErrMsgStartInterferenceActiveInvalidValue, "TestInterference : Parameter active has invalid value" ); + + __TRACEFUNC(); + TPtrC category; + TPtrC type; + TInt idle( 0 ); + TInt active( 0 ); + TInt priority( 0 ); + + // Get category + if( aItem->GetNextString( category ) != KErrNone ) + { + __TRACE( KError, ( + _L( "Unknown argument for 'testinterference' category" ) ) ); + iRunErrorMessage = KErrMsgStartInterferenceCategoryNotDefined; + User::Leave( KErrArgument ); // Error in parsing => Leave + } + // Get type + if( aItem->GetNextString( type ) != KErrNone ) + { + __TRACE( KError, ( + _L( "Unknown argument for 'testinterference' type" ) ) ); + iRunErrorMessage = KErrMsgStartInterferenceTypeNotDefined; + User::Leave( KErrArgument ); // Error in parsing => Leave + } + + TPtrC timeStr; + TReal time; + // Get idle time + if( aItem->GetNextString( timeStr ) != KErrNone ) + { + __TRACE( KError, ( + _L( "Unknown argument for 'testinterference' idle" ) ) ); + iRunErrorMessage = KErrMsgStartInterferenceIdleNotDefined; + User::Leave( KErrArgument ); // Error in parsing => Leave + } + if ( TLex( timeStr ).Val( time, '.' ) != KErrNone ) + { + __TRACE( KError, ( + _L( "Unknown argument for 'testinterference' idle" ) ) ); + iRunErrorMessage = KErrMsgStartInterferenceIdleNotDefined; + User::Leave( KErrArgument ); // Error in parsing => Leave + } + // Convert idle time from milli to micro seconds + idle = time * 1000.0; + + if( idle < 0 ) + { + __TRACE( KError, ( + _L( "Argument 'testinterference' idle can't be <0" ) ) ); + iRunErrorMessage = KErrMsgStartInterferenceIdleInvalidValue; + User::Leave( KErrArgument ); + } + // Get active time + if( aItem->GetNextString( timeStr ) != KErrNone ) + { + __TRACE( KError, ( + _L( "Unknown argument for 'testinterference' active" ) ) ); + iRunErrorMessage = KErrMsgStartInterferenceActiveNotDefined; + User::Leave( KErrArgument ); // Error in parsing => Leave + } + if ( TLex( timeStr ).Val( time, '.' ) != KErrNone ) + { + __TRACE( KError, ( + _L( "Unknown argument for 'testinterference' idle" ) ) ); + iRunErrorMessage = KErrMsgStartInterferenceIdleNotDefined; + User::Leave( KErrArgument ); // Error in parsing => Leave + } + + // Convert active time from milli to micro seconds + active = time * 1000.0; + + if( active < 0 ) + { + __TRACE( KError, ( + _L( "Argument 'testinterference' active can't be <0" ) ) ); + iRunErrorMessage = KErrMsgStartInterferenceActiveInvalidValue; + User::Leave( KErrArgument ); + } + + // Get priority + if( aItem->GetNextInt( priority ) != KErrNone ) + { + // Log information only do not return. Priority value is optional. + __TRACE( KInit, ( + _L( "Unknown argument for 'testinterference' priority or value not given, default priority will be used" ) ) ); + } + + MSTIFTestInterference* interference = NULL; + + // Get category + if( category == _L("activeobject") ) + { + interference = MSTIFTestInterference::NewL( iTestScripter, + MSTIFTestInterference::EActiveObject ); + } + else if( category == _L("thread") ) + { + interference = MSTIFTestInterference::NewL( iTestScripter, + MSTIFTestInterference::EThread ); + } + else + { + __TRACE( KError, ( + _L( "Unknown argument for 'testinterference' category[%S]" ), &category ) ); + iRunErrorMessage = KErrMsgStartInterferenceCategoryInvalidValue; + User::Leave( KErrArgument ); // Error in parsing => Leave + } + + // Create object that include test interference information and append this + // to array. + TTestInterference* object = new (ELeave) TTestInterference(); + object->iName = aName; + object->iInterference = interference; + + // Array for handling test interference between different objects + TInt ret = iTestInterferenceArray.Append( object ); + if( ret != KErrNone ) + { + delete object; + __TRACE( KError, ( + _L( "CTestRunner::StartInterference: iTestInterferenceArray.Append fails:[%d]" ), ret ) ); + User::Leave( ret ); + } + + // Set priority if user given + if( priority != 0 ) + { + interference->SetPriority( priority ); + } + + // Get type + if( type == _L("cpuload") ) + { + interference->StartL( MSTIFTestInterference::ECpuLoadMicroSeconds, idle , active ); + } + else if( type == _L("filesystemreadc") ) + { + interference->StartL( MSTIFTestInterference::EFileSystemReadCMicroSeconds, idle , active ); + } + else if( type == _L("filesystemreadd") ) + { + interference->StartL( MSTIFTestInterference::EFileSystemReadDMicroSeconds, idle , active ); + } + else if( type == _L("filesystemreade") ) + { + interference->StartL( MSTIFTestInterference::EFileSystemReadEMicroSeconds, idle , active ); + } + else if( type == _L("filesystemreadz") ) + { + interference->StartL( MSTIFTestInterference::EFileSystemReadZMicroSeconds, idle , active ); + } + else if( type == _L("filesystemwritec") ) + { + interference->StartL( MSTIFTestInterference::EFileSystemWriteCMicroSeconds, idle , active ); + } + else if( type == _L("filesystemwrited") ) + { + interference->StartL( MSTIFTestInterference::EFileSystemWriteDMicroSeconds, idle , active ); + } + else if( type == _L("filesystemwritee") ) + { + interference->StartL( MSTIFTestInterference::EFileSystemWriteEMicroSeconds, idle , active ); + } + else if( type == _L("filesystemfillandemptyc") ) + { + interference->StartL( MSTIFTestInterference::EFileSystemFillAndEmptyCMicroSeconds, idle , active ); + } + else if( type == _L("filesystemfillandemptyd") ) + { + interference->StartL( MSTIFTestInterference::EFileSystemFillAndEmptyDMicroSeconds, idle , active ); + } + else if( type == _L("filesystemfillandemptye") ) + { + interference->StartL( MSTIFTestInterference::EFileSystemFillAndEmptyEMicroSeconds, idle , active ); + } + else + { + __TRACE( KError, ( + _L( "Unknown argument for 'testinterference' type[%S]" ), &type ) ); + iRunErrorMessage = KErrMsgStartInterferenceTypeInvalidValue; + User::Leave( KErrArgument ); // Error in parsing => Leave + } + + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: StopInterference + + Description: Stops test interference. + + Parameters: TDesC& aName: in: Indicates right test interference object. + + Return Values: None. + + Errors/Exceptions: None. + + Status: Approved + +------------------------------------------------------------------------------- +*/ +void CTestRunner::StopInterferenceL( TDesC& aName ) + { + _LIT( KErrMsgStopInterference, "TestInterference : testinterference %S was not start" ); + __TRACEFUNC(); + + TInt count = iTestInterferenceArray.Count(); + for( TInt i = 0; i < count; i++ ) + { + if( iTestInterferenceArray[i]->iName == aName ) + { + // Found test module, return description + iTestInterferenceArray[i]->iInterference->Stop(); + // Delete data + delete iTestInterferenceArray[i]; + // Remove pointer to deleted data(Append()) + iTestInterferenceArray.Remove( i ); + // iTestMeasurementArray can contain only one type of measurement + // so we can break when type is removed. + return; + } + } + __TRACE( KError, ( + _L( "'testinterference' type[%S] was not start" ), &aName ) ); + iRunErrorMessage.Format( KErrMsgStopInterference, &aName ); + User::Leave( KErrArgument ); // Error in parsing => Leave + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: MeasurementL + + Description: Starts test measurement. + + Parameters: CStifItemParser* aItem: in: Item object for parsing. + + Return Values: None. + + Errors/Exceptions: Leaves if StartBappeaMeasurementL() fails. + Leaves if StopBappeaMeasurementL() fails. + + Status: Approved + +------------------------------------------------------------------------------- +*/ +void CTestRunner::MeasurementL( CStifItemParser* aItem ) + { + _LIT( KErrMsgMeasurementCommandNotDefined, "TestMeasurement : Parameter command is not defined" ); + _LIT( KErrMsgMeasurementTypeNotDefined, "TestMeasurement : Parameter type is not defined" ); + _LIT( KErrMsgMeasurementUnknownType, "TestMeasurement : Unknown measurement type %S" ); + _LIT( KErrMsgMeasurementUnknownCommand, "TestMeasurement : Unknown command %S" ); + __TRACEFUNC(); + TPtrC type; + TPtrC command; + + // Get command + if( aItem->GetNextString( command ) != KErrNone ) + { + __TRACE( KError, ( + _L( "Unknown argument for 'measurement' command" ) ) ); + iRunErrorMessage = KErrMsgMeasurementCommandNotDefined; + User::Leave( KErrArgument ); // Error in parsing => Leave + } + // Get name + if( aItem->GetNextString( type ) != KErrNone ) + { + __TRACE( KError, ( + _L( "Unknown argument for 'measurement' type" ) ) ); + iRunErrorMessage = KErrMsgMeasurementTypeNotDefined; + User::Leave( KErrArgument ); // Error in parsing => Leave + } + + // Verify measurement type + if( !( type == KParamMeasurement01 || + type == KParamMeasurement02 || + type == KParamMeasurement03 || + type == KParamMeasurement04 || + type == KParamMeasurement05 || + type == KParamMeasurementBappea ) ) + + { + __TRACE( KError, ( + _L( "Unknown measurement type:[%S]" ), &type ) ); + iRunErrorMessage.Format( KErrMsgMeasurementUnknownType, &type ); + User::Leave( KErrArgument ); // Error in types => Leave + } + + // Verify command + if( command == _L( "start" ) ) + { + // START measurement's process + __TRACE( KMessage, ( _L( "Start 'measurement' with '%S'"), &type ) ); + StartMeasurementL( type, aItem ); + } + else if( command == _L( "stop" ) ) + { + // STOP measurement's process + __TRACE( KMessage, ( _L( "'Stop 'measurement' with '%S'"), &type ) ); + StopMeasurementL( type ); + } + else + { + __TRACE( KError, ( + _L( "Unknown command for 'measurement' command:[%S] or type:[%S]" ), &command, &type ) ); + iRunErrorMessage.Format( KErrMsgMeasurementUnknownCommand, &command ); + User::Leave( KErrArgument ); // Error in commands => Leave + } + + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: StartMeasurementL + + Description: Start measurement + + Parameters: const TDesC& aType: in: Plugin type. + CStifItemParser* aItem: in: Item object for parsing. + + Return Values: None. + + Errors/Exceptions: Leaves is measurement operation fails. + + Status: Approved + +------------------------------------------------------------------------------- +*/ +void CTestRunner::StartMeasurementL( const TDesC& aType, + CStifItemParser* aItem ) + { + _LIT( KErrMsgMeasurementUnknownPlugin, "Measurement : Unknown measurement plugin %S" ); + _LIT( KErrMsgMeasurementStartFail, "Measurement : Measurement start fails" ); + __TRACEFUNC(); + + CSTIFTestMeasurement* testMeasurement = NULL; + + // Get Measurement configuration info + TPtrC configurationInfo( KNullDesC() ); + if( aItem->Remainder( configurationInfo ) != KErrNone ) + { + __TRACE( KInit, ( + _L( "Using default path and file name for measurement configure" ) ) ); + } + + if( aType == KParamMeasurement01 ) + { + testMeasurement = CSTIFTestMeasurement::NewL( + iTestScripter, + CSTIFTestMeasurement::KStifMeasurementPlugin01, + configurationInfo ); + } + else if( aType == KParamMeasurement02 ) + { + testMeasurement = CSTIFTestMeasurement::NewL( + iTestScripter, + CSTIFTestMeasurement::KStifMeasurementPlugin02, + configurationInfo ); + } + else if( aType == KParamMeasurement03 ) + { + testMeasurement = CSTIFTestMeasurement::NewL( + iTestScripter, + CSTIFTestMeasurement::KStifMeasurementPlugin03, + configurationInfo ); + } + else if( aType == KParamMeasurement04 ) + { + testMeasurement = CSTIFTestMeasurement::NewL( + iTestScripter, + CSTIFTestMeasurement::KStifMeasurementPlugin04, + configurationInfo ); + } + else if( aType == KParamMeasurement05 ) + { + testMeasurement = CSTIFTestMeasurement::NewL( + iTestScripter, + CSTIFTestMeasurement::KStifMeasurementPlugin05, + configurationInfo ); + } + else if( aType == KParamMeasurementBappea ) + { + testMeasurement = CSTIFTestMeasurement::NewL( + iTestScripter, + CSTIFTestMeasurement::KStifMeasurementBappeaProfiler, + configurationInfo ); + } + else + { + __TRACE( KError, ( _L( "Unknown plugin[%S] for 'measurement'" ), &aType ) ); + iRunErrorMessage.Format( KErrMsgMeasurementUnknownPlugin, &aType ); + User::Leave( KErrArgument ); + } + + // Start test measurement + TInt start_ret( KErrNone ); + start_ret = testMeasurement->Start(); + if( start_ret != KErrNone ) + { + delete testMeasurement; + //CleanupStack::PopAndDestroy( setting_buf ); + __TRACE( KError, ( + _L( "CTestRunner::StartMeasurementL(): Measurement Start() fails:[%d]" ), start_ret ) ); + iRunErrorMessage = KErrMsgMeasurementStartFail; + User::Leave( start_ret ); + } + + TTestMeasurement* object = new (ELeave) TTestMeasurement(); + object->iName = aType; + object->iMeasurement = testMeasurement; + + // Array for handling test measurement between different objects + TInt ret = iTestMeasurementArray.Append( object ); + if( ret != KErrNone ) + { + delete object; + __TRACE( KError, ( + _L( "CTestRunner::StartMeasurementL(): iTestMeasurementArray.Append fails:[%d]" ), ret ) ); + User::Leave( ret ); + } + + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: StopMeasurementL + + Description: Stops test measurement. + + Parameters: None. + + Return Values: None. + + Errors/Exceptions: None. + + Status: Approved + +------------------------------------------------------------------------------- +*/ +void CTestRunner::StopMeasurementL( const TDesC& aType ) + { + _LIT( KErrMsgMeasurementNotStarted, "Measurement : Measurement %S was not start" ); + __TRACEFUNC(); + + TInt count = iTestMeasurementArray.Count(); + for( TInt i = 0; i < count; i++ ) + { + if( iTestMeasurementArray[i]->iName == aType ) + { + // Found measurement module, stop + iTestMeasurementArray[i]->iMeasurement->Stop(); + // Delete data + delete iTestMeasurementArray[i]; + // Remove pointer to deleted data(Append()) + iTestMeasurementArray.Remove( i ); + // iTestMeasurementArray can contain only one type of measurement + // so we can break when type is removed. + return; + } + } + + __TRACE( KError, ( + _L( "CTestRunner::StopMeasurementL(): Measurement %S was not start" ), &aType ) ); + iRunErrorMessage.Format( KErrMsgMeasurementNotStarted, &aType ); + User::Leave( KErrArgument ); + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: AddTestCaseResultL + + Description: Adds new test case result. Used with 'allownextresult' + and 'allowerrorcodes' keywords. + + Parameters: CStifItemParser* aItem: in: Item object for parsing. + + Return Values: None. + + Errors/Exceptions: Leaves if iTestCaseResults.Append fails. + Leaves if aItem->GetNextInt() fails. + + Status: Approved + +------------------------------------------------------------------------------- +*/ +void CTestRunner::AddTestCaseResultL( CStifItemParser* aItem ) + { + _LIT( KErrMsgAllowNextResultInvalidValue, "No expected result value given or value has invalid format" ); + TInt result; + + TPtrC codeBuf; + TBool found = EFalse; + while( aItem->GetNextString( codeBuf ) == KErrNone ) + { + TLex codeParser( codeBuf ); + if ( codeParser.Val( result ) != KErrNone ) + { + __TRACE( KError, (_L("ExecuteLineL: No expected result value given"))); + iRunErrorMessage = KErrMsgAllowNextResultInvalidValue; + User::Leave( KErrArgument ); + } + else + { + User::LeaveIfError( iTestCaseResults.Append( result ) ); + // Set test case allow result to CTestModuleIf side too. This is + // used in TAL-TA5L macro handling. + User::LeaveIfError( + iTestScripter->TestModuleIf().SetAllowResult( result ) ); + found = ETrue; + } + } + + if ( !found ) + { + __TRACE( KError, (_L("ExecuteLineL: No expected result value given"))); + iRunErrorMessage = KErrMsgAllowNextResultInvalidValue; + User::Leave( KErrArgument ); + } + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: AddTestCasePanicL + + Description: Adds new test case result. Used with 'allowpanic' + and 'allowerrorcodes' keywords. + + Parameters: CStifItemParser* aItem: in: Item object for parsing. + + Return Values: None. + + Errors/Exceptions: Leaves if iTestCaseResults.Append fails. + Leaves if aItem->GetNextInt() fails. + + Status: Approved + +------------------------------------------------------------------------------- +*/ + +void CTestRunner::AddTestCasePanicL( CStifItemParser* aItem ) + { + _LIT( KErrMsgAllowNextPanicInvalidValue, "No expected panic value given or value has invalid format" ); + TInt panic; + + TPtrC codeBuf; + while( aItem->GetNextString( codeBuf ) == KErrNone ) + { + TLex codeParser( codeBuf ); + if ( codeParser.Val( panic ) != KErrNone ) + { + __TRACE( KError, (_L("ExecuteLineL: No expected panic value given"))); + iRunErrorMessage = KErrMsgAllowNextPanicInvalidValue; + User::Leave( KErrArgument ); + } + else + { + //do not add panic result to allowed result of case. + //User::LeaveIfError( iTestCaseResults.Append( panic ) ); + // Set test case allow result to CTestModuleIf side too. This is + // used in TAL-TA5L macro handling. + iTestScripter->TestModuleIf().SetExitReason( CTestModuleIf::EPanic, panic ); + break; + } + } + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: SubTestCaseFinishedL + + Description: Recieves and handles notification about finished sub test + \ case execution. + + Parameters: CSubTestCaseRunner* aSubTestCaseRunner: in: sub test case + runner used to run test case. + + Return Values: None + + Errors/Exceptions: Leaves on error situations. + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +void CTestRunner::SubTestCaseFinishedL( CSubTestCaseRunner* aSubTestCaseRunner ) + { + if ( iInternalStateForSubTestCases == EISFinished ) + { + if ( aSubTestCaseRunner->GetTestCaseResult().iCaseExecutionResultCode == KErrCancel ) + { + // Test was canceled. Do nothing. + return; + } + else + { + User::Leave( KErrGeneral ); + } + } + + TInt index = iSubTestCases.Find( aSubTestCaseRunner ); + if ( index < 0 ) + { + // Debug info + return; + } + + CSubTestCaseRunner* subTestCaseRunner = iSubTestCases[ index ]; + iSubTestCases.Remove( index ); + CleanupStack::PushL( subTestCaseRunner ); + + TInt runResult = subTestCaseRunner->GetRunResult(); + TFullTestResult testCaseResult = subTestCaseRunner->GetTestCaseResult(); + const CStartInfo* startInfo = subTestCaseRunner->GetStartInfo(); + + __TRACE( KMessage, ( _L( "Sub test case execution finished: module=%S cfg=%S tcnum=%d id=%S" ), + &startInfo->GetModuleName(), &startInfo->GetConfig(), + startInfo->GetTestCaseNumber(), &startInfo->GetTestId()) ); + + __TRACE( KMessage, ( _L( "Sub test case execution result: execution_result=%d, test_result=%d, des=%S" ), + testCaseResult.iCaseExecutionResultCode, testCaseResult.iTestResult.iResult, + &testCaseResult.iTestResult.iResultDes ) ); + + RDebug::Print( _L( "Sub test case execution finished: module=%S cfg=%S tcnum=%d id=%S" ), + &startInfo->GetModuleName(), &startInfo->GetConfig(), + startInfo->GetTestCaseNumber(), &startInfo->GetTestId() ); + + RDebug::Print( _L( "Sub test case execution result: execution_result=%d, test_result=%d, des=%S" ), + testCaseResult.iCaseExecutionResultCode, testCaseResult.iTestResult.iResult, + &testCaseResult.iTestResult.iResultDes ); + + // Check expected execution result type + TBool reportFailedSubTestCase = EFalse; + if( testCaseResult.iCaseExecutionResultType != startInfo->GetExpectedResultCategory() ) + { + reportFailedSubTestCase = true; + } + else + { + if( startInfo->GetExpectedResultCategory() == TFullTestResult::ECaseExecuted ) + { + if ( startInfo->GetExpectedResult() != testCaseResult.iTestResult.iResult ) + { + reportFailedSubTestCase = true; + } + } + else + { + if ( startInfo->GetExpectedResult() != testCaseResult.iCaseExecutionResultCode ) + { + reportFailedSubTestCase = true; + } + } + } + + if ( reportFailedSubTestCase ) + { + // Only remember first failed sub test case + if ( iFailedSubTestCaseReported == EFalse ) + { + // If passlimit is enabled and loop is in progress ignore sub test case fail. + // Fail will be reported only if passlimit is not met. + // It is done in ReportLoopEndResultL + if ( !( iLoopHelper->LoopInProgress() && iPasslimitEnabled ) || iCancelIfError ) + { + iFailedSubTestCaseReported = true; + iFailedSubTestCaseResult = testCaseResult; + iFailedSubTestCaseInfo = CStartInfo::NewL(); + iFailedSubTestCaseInfo->CopyL( *startInfo ); + } + } + } + + switch( iInternalStateForSubTestCases ) + { + case EISRuning: + // Do noting + if ( iLoopHelper->LoopInProgress() ) + { + iLoopHelper->NotifySubTestCaseEndL( subTestCaseRunner, !reportFailedSubTestCase ); + } + break; + case EISWaitingForComplete: + if ( iLoopHelper->LoopInProgress() ) + { + iLoopHelper->NotifySubTestCaseEndL( subTestCaseRunner, !reportFailedSubTestCase ); + } + // Do noting + if ( subTestCaseRunner->GetStartInfo()->GetTestId() == *iTestIdForComplete ) + { + delete iTestIdForComplete; + iTestIdForComplete = NULL; + SetRunnerActive(); // Continue test case execution after complete + iInternalStateForSubTestCases = EISRuning; + } + break; + case EISFinishedWaitingForSubTestCases: + if ( iSubTestCases.Count() <= 0 ) + { + SetRunnerActive(); + } + break; + default: + break; + } + + CleanupStack::PopAndDestroy( subTestCaseRunner ); + + if ( iCancelIfError && iFailedSubTestCaseReported ) + { + // Make sure that DoCancel will be executed + if ( !IsActive() ) + { + SetRunnerActive(); + } + // Stop Test Case execution + Cancel(); + } + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: ReportLoopEndResultL + + Description: Recives report from CLoopHelper about result of loop execution + + Parameters: TInt aPassedIterations: in: number of passed loop iterations + + Return Values: None + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +void CTestRunner::ReportLoopEndResultL( TInt aPassedIterations ) + { + //If passlimit was given and number of passed test is less then expected, stop execution of scripter's test case + if( iPasslimitEnabled && ( aPassedIterations < iPasslimit ) ) + { + __TRACE( KMessage, ( _L( "Loop has failed (passlimit). Finishing with KErrCompletion." ) ) ); + iTestScripter->iPassLimitNotMet = ETrue; + iTestScripter->iResult.iResult = KErrCompletion; + iTestScripter->iResult.iResultDes = _L("Loop has not reached passlimit requirement."); + Cancel(); + } + else if( iPasslimitEnabled && ( aPassedIterations >= iPasslimit ) ) + { + __TRACE( KMessage, ( _L( "Loop has passed (passlimit)" ) ) ); + } + + iPasslimit = 0; + iPasslimitEnabled = EFalse; + } + +void CTestRunner::ReleaseRemoteResourcesAllocatedInLoopL() + { + RPointerArray& inLoopSlaves = iLoopHelper->GetRegisteredInLoopSlaves(); + + for ( TInt i = 0; i < inLoopSlaves.Count(); i++ ) + { + inLoopSlaves[ i ]->WaitForSubTestCasesL(); + + RPointerArray& slaveEvents = inLoopSlaves[ i ]->GetEvents(); + for ( TInt k = 0; k < slaveEvents.Count(); k++ ) + { + iSlavesManager->EventReleaseL( inLoopSlaves[ i ], slaveEvents[ k ]->Name() ); + } + slaveEvents.ResetAndDestroy(); + + iSlavesManager->SlaveFreeL( inLoopSlaves[ i ]->GetName() ); + } + + inLoopSlaves.Reset(); + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: IsFailedSubTestCaseReported + + Description: Gets information if there was reported executed sub test + case which failed. + + Parameters: None + + Return Values: ETrue: test case was reported + EFalse: test case was not reported + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +TBool CTestRunner::IsFailedSubTestCaseReported() const + { + return iFailedSubTestCaseReported; + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: GetFailedSubTestCaseResult + + Description: Returns first failed sub test case result. + + Parameters: None + + Return Values: First failed sub test case result. + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +TFullTestResult CTestRunner::GetFailedSubTestCaseResult() const + { + return iFailedSubTestCaseResult; + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: GetFailedSubTestCaseInfo + + Description: Returns first failed sub test case info. + + Parameters: None + + Return Values: First failed sub test case info. + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +const CStartInfo* CTestRunner::GetFailedSubTestCaseInfo() const + { + return iFailedSubTestCaseInfo; + } + +void CTestRunner::HandleRemoteReceiveError( TInt aError, const TDesC& aErrorDescription ) + { + iTestScripter->UpdateTestCaseResult( aError, aErrorDescription ); + CActiveScheduler::Current()->Stop(); + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: ControlSubTestCaseL + + Description: Controls sub test case execution + + Parameters: Sub test case id + + Return Values: ETrue: continue script file execution + EFalse: stop script file execution + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +TBool CTestRunner::ControlSubTestCaseL( TTestKeywords::TKeywords aOperation, CStifItemParser* aItem ) + { + _LIT( KErrMsgInvalidTestId, "testid is not specified or it has invalid value" ); + _LIT( KErrMsgUnknownCall, "Unknown operation call on sub test case" ); + + TPtrC subTestId; + TInt ret = aItem->GetNextString( subTestId ); + if ( ret != KErrNone ) + { + iRunErrorMessage = KErrMsgInvalidTestId; + User::Leave( KErrArgument ); + } + + TInt subTestCasesCount = iSubTestCases.Count(); + for ( TInt i = 0; i < subTestCasesCount; i++ ) + { + if ( iSubTestCases[ i ]->GetStartInfo()->GetTestId() == subTestId ) + { + switch ( aOperation ) + { + case TTestKeywords::EPauseTest: + { + __TRACE( KMessage, ( _L( "Pause sub test case testid=%S" ), &subTestId ) ); + iSubTestCases[ i ]->PauseSubTestCaseL(); + } + break; + case TTestKeywords::EResume: + { + __TRACE( KMessage, ( _L( "Reasume sub test case testid=%S" ), &subTestId ) ); + iSubTestCases[ i ]->ResumeSubTestCaseL(); + } + break; + case TTestKeywords::ECancel: + { + __TRACE( KMessage, ( _L( "Cancel sub test case testid=%S" ), &subTestId ) ); + CSubTestCaseRunner* subTestCaseRunner = iSubTestCases[ i ]; + subTestCaseRunner->CancelSubTestCaseL(); + if ( subTestCaseRunner->GetType() == CSubTestCaseRunner::ESTTRemote ) + { + CRemoteSubTestCaseRunner* remoteSubTestCaseRunner = + (CRemoteSubTestCaseRunner*)subTestCaseRunner; + CSlave* slave = remoteSubTestCaseRunner->GetSlave(); + slave->UnregisterSubTestCaseL( remoteSubTestCaseRunner ); + } + if ( iLoopHelper->LoopInProgress() ) + { + iLoopHelper->UnregisterInLoopSubTestCaseL( subTestCaseRunner ); + } + delete iSubTestCases[ i ]; + iSubTestCases.Remove( i ); + } + break; + default: + { + iRunErrorMessage = KErrMsgUnknownCall; + User::Leave( KErrArgument ); + } + break; + } + + return true; + } + } + + __TRACE( KMessage, ( _L( "Sub test case testid=%S not found" ), &subTestId ) ); + RDebug::Print( _L( "Sub test case testid=%S not found" ), &subTestId ); + + return true; + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: ExecuteLoopL + + Description: Executes loop keyword + + Parameters: CStifItemParser* aItem: in: script line + + Return Values: None + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +TBool CTestRunner::ExecuteLoopL( CStifItemParser* aItem ) + { + _LIT( KErrMsgLoopNested, "Loop: Nested loop are not supported" ); + _LIT( KErrMsgLoopNoParam, "Loop: No loop iterations count given or value has invalid format" ); + _LIT( KErrMsgLoopInvalidParam, "Loop: Loop count must be >0" ); + _LIT( KErrMsgLoopUnknownUnexpectedOption, "Loop: Unknown or unexpected loop option"); + _LIT( KErrMsgLoopPasslimitInvalidValue, "Loop: No passlimit value given for loop or value has invalid format" ); + _LIT( KErrMsgLoopPasslimitNotInRange, "Loop: Passlimit value is lower than 0 or higher than loop count" ); + + if( iLoopTimes > 0 ) + { + __TRACE( KError, (_L("ExecuteLineL: Nested loop are not supported"))); + iRunErrorMessage = KErrMsgLoopNested; + User::Leave( KErrNotSupported ); + } + + iLoopTimes = 0; + iLoopCounter = 0; + iTimedLoop = EFalse; + + if( aItem->GetNextInt( iLoopTimes ) != KErrNone ) + { + __TRACE( KError, (_L("ExecuteLineL: No loop count value given for loop"))); + iRunErrorMessage = KErrMsgLoopNoParam; + User::Leave( KErrArgument ); + } + + if( iLoopTimes < 1 ) + { + __TRACE( KError, (_L("ExecuteLineL: Loop count must be >0"))); + iRunErrorMessage = KErrMsgLoopInvalidParam; + User::Leave( KErrArgument ); + } + + __TRACE( KMessage, (_L("ExecuteLineL: Loop for %d times" ), iLoopTimes ) ); + + //Check loop options + TPtrC option; + TInt ret = aItem->GetNextString(option); + if(ret == KErrNone) + { + if(option.Compare(_L("msec")) == 0) //time loop option + { + iTimedLoop = ETrue; + iStartTime.HomeTime(); + iExpectedLoopTime = TInt64(iLoopTimes) * TInt64(1000); //convert to micro seconds + __TRACE(KMessage, (_L("ExecuteLineL: Timed loop for %d msec" ), iLoopTimes)); + + ret = aItem->GetNextString(option); //Get next option + } + } + + if(ret == KErrNone) + { + if(option.Compare(_L("passlimit")) == 0) //passlimit option + { + iPasslimit = 0; + if( aItem->GetNextInt( iPasslimit ) != KErrNone ) + { + __TRACE( KError, ( _L( "ExecuteLoopL: No passlimit value given for loop." ) ) ); + iRunErrorMessage = KErrMsgLoopPasslimitInvalidValue; + User::Leave( KErrArgument ); + } + __TRACE( KMessage, ( _L( "ExecuteLoopL: Passlimit set on %d" ), iPasslimit ) ); + //Check if passlimit has valid value + if(iPasslimit < 0 || (iPasslimit > iLoopTimes && !iTimedLoop)) + { + __TRACE( KError, ( _L( "ExecuteLoopL: Passlimit value is lower than 0 or higher than loop count." ) ) ); + iRunErrorMessage = KErrMsgLoopPasslimitNotInRange; + User::Leave( KErrArgument ); + } + iPasslimitEnabled = ETrue; + + ret = aItem->GetNextString(option); //Get next option + } + } + + if(ret == KErrNone) + { + __TRACE( KError, (_L("ExecuteLineL: Unknown or unexpected loop option [%S]"), &option)); + iRunErrorMessage = KErrMsgLoopUnknownUnexpectedOption; + User::Leave( KErrNotSupported ); + } + + iLoopStartPos = iTestScripter->iCurrentParser->GetPosition(); + + iLoopHelper->LoopStartL(); + + return ETrue; + } + +/* +------------------------------------------------------------------------------- + + Class: CTestRunner + + Method: ExecuteEndLoopL + + Description: Executes endloop keyword + + Parameters: CStifItemParser* aItem: in: script line + + Return Values: None + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +TBool CTestRunner::ExecuteEndLoopL( CStifItemParser* /*aItem*/ ) + { + _LIT( KErrMsgEndLoopNotOpened, "Endloop: Can't execute endloop. No opened loop exists" ); + + if( iLoopTimes == 0 ) + { + __TRACE( KError, (_L("ExecuteLineL: Can't execute endloop. No opened loop exists"))); + iRunErrorMessage = KErrMsgEndLoopNotOpened; + User::Leave( KErrNotFound ); + } + + iLoopCounter++; + __TRACE( KMessage, + (_L("ExecuteLineL: Loop executed for %d times" ), + iLoopCounter ) ); + + TTime currTime; + currTime.HomeTime(); + + if(((!iTimedLoop) && (iLoopCounter < iLoopTimes)) //Normal loop + || + iTimedLoop && (currTime.MicroSecondsFrom(iStartTime) < iExpectedLoopTime)) //Timed loop + { + // Go to beginning of the loop + User::LeaveIfError( + iTestScripter->iCurrentParser->SetPosition( iLoopStartPos )); + iLoopHelper->IterationEndStartNextIterationL(); + } + else + { + // End looping + iLoopCounter = 0; + iLoopTimes = 0; + iLoopStartPos = 0; + + iLoopHelper->LoopEndL(); + } + + // iLoopHelper will activate runner in proper moment + return EFalse; + } + +TBool CTestRunner::ExecuteAllocateL( CStifItemParser* aItem ) + { + _LIT( KErrMsgAllocateSlaveTypeNotDefined, "Allocate : Slave type was not given for allocate" ); + _LIT( KErrMsgAllocateSlaveNameNotDefined, "Allocate : Slave name is not defined" ); + _LIT( KErrMsgAllocateSlaveAlreadyAllocated, "Allocate : Slave with name %S already allocated" ); + __TRACE( KMessage, (_L("Allocate"))); + + TPtrC type; + TPtrC name; + // Get slave type + TInt ret = aItem->GetNextString( type ); + if( ret != KErrNone ) + { + __TRACE( KError, (_L("Slave type was not given for allocate"))); + iRunErrorMessage = KErrMsgAllocateSlaveTypeNotDefined; + User::Leave( KErrArgument ); + } + + // Get slave name + ret = aItem->GetNextString( name ); + if( ret != KErrNone ) + { + __TRACE( KError, (_L("Slave name was not given for allocate"))); + iRunErrorMessage = KErrMsgAllocateSlaveNameNotDefined; + User::Leave( KErrArgument ); + } + + iTestScripter->TestModuleIf().Printf( KPrintPriExec, KExecute, + _L("Allocate %S"), &name ); + + __TRACE( KMessage, (_L("Allocate %S [name: %S]"), &type, &name)); + + if( iSlavesManager->GetSlave( name ) ) + { + __TRACE( KError, (_L("Slave with name %S already allocated"), + &name ) ); + iRunErrorMessage.Format( KErrMsgAllocateSlaveAlreadyAllocated, &name ); + User::Leave( KErrAlreadyExists ); + } + + iSlavesManager->SlaveAllocateL( name, type ); + + if ( iLoopHelper->LoopInProgress() ) + { + CSlave* slave = iSlavesManager->GetSlave( name ); + iLoopHelper->RegisterInLoopSlaveL( slave ); + } + + return ETrue; + } + +TBool CTestRunner::ExecuteFreeL( CStifItemParser* aItem ) + { + _LIT( KErrMsgFreeSlaveNameNotDefined, "Free : Slave name is not defined" ); + _LIT( KErrMsgFreeSlaveNotFound, "Free : Slave %S not found" ); + __TRACE( KMessage, (_L("Free"))); + + TPtrC name; + // Get slave name + TInt ret = aItem->GetNextString( name ); + if( ret != KErrNone ) + { + __TRACE( KError, (_L("Slave name was not given for free"))); + iRunErrorMessage = KErrMsgFreeSlaveNameNotDefined; + User::Leave( KErrArgument ); + } + + iTestScripter->TestModuleIf().Printf( KPrintPriExec, KExecute, + _L("Free %S"), &name ); + + __TRACE( KMessage, (_L("Free %S"), &name ) ); + + CSlave* slave = iSlavesManager->GetSlave( name ); + if( slave == NULL ) + { + __TRACE( KError, (_L("Slave %S not found"), &name )); + iRunErrorMessage.Format( KErrMsgFreeSlaveNotFound, &name ); + User::Leave( KErrNotFound ); + } + + if ( iLoopHelper->LoopInProgress() ) + { + iLoopHelper->UnregisterInLoopSlaveL( slave ); + } + + if ( slave->HasRunningTestCases() ) + { + slave->WaitForSubTestCasesL(); + } + + iSlavesManager->SlaveFreeL( name ); + + return ETrue; + } + +TBool CTestRunner::ExecuteRemoteL( CStifItemParser* aItem ) + { + _LIT( KErrMsgRemoteSlaveNameNotDefined, "Remote : Slave name is not defined" ); + _LIT( KErrMsgRemoteSlaveNotFound, "Remore : Slave %S not found" ); + _LIT( KErrMsgRemoteCommandNotDefined, "Slave command name was not given for remote" ); + + TPtrC name; + TPtrC command; + + // Get slave name + TInt ret = aItem->GetNextString( name ); + if( ret != KErrNone ) + { + __TRACE( KError, (_L("Slave name was not given for remote"))); + iRunErrorMessage = KErrMsgRemoteSlaveNameNotDefined; + User::Leave( KErrArgument ); + } + + __TRACE( KMessage, (_L("Remote command to %S"), &name)); + + CSlave* slave = iSlavesManager->GetSlave( name ); + if( slave == NULL ) + { + __TRACE( KError, (_L("Slave %S not found"), &name )); + iRunErrorMessage.Format( KErrMsgRemoteSlaveNotFound, &name ); + User::Leave( KErrArgument ); + } + + // Get remote command name + ret = aItem->GetNextString( command ); + if( ret != KErrNone ) + { + __TRACE( KError, (_L("Slave command name was not given for remote"))); + iRunErrorMessage = KErrMsgRemoteCommandNotDefined; + User::Leave( KErrArgument ); + } + + iTestScripter->TestModuleIf().Printf( KPrintPriExec, KExecute, + _L("remote %S %S"), &name, &command ); + + __TRACE( KPrint, (_L("remote %S %S"), &name, &command ) ); + + // Parse command name + TInt key = TTestKeywords::Parse( command, TTestKeywords::Keyword ); + TBool continueTask = ETrue; + + switch( key ) + { + // Test case starting + case TTestKeywords::ERun: + continueTask = ExecuteRemoteRunL( aItem, slave ); + break; + + // Event control cases + case TTestKeywords::ERequest: + case TTestKeywords::EWait: + case TTestKeywords::ERelease: + case TTestKeywords::ESet: + case TTestKeywords::EUnset: + continueTask = ExecuteRemoteEventCtlL( aItem, slave, key ); + break; + // asynchronous 'sendreceive' + case TTestKeywords::ESendReceive: + continueTask = ExecuteRemoteSendReceiveL( aItem, slave ); + break; + + default: + // Some unknown remote command, forward as such + continueTask = ExecuteRemoteUnknownL( aItem, slave, command ); + break; + } + + return continueTask; + } + + +TBool CTestRunner::ExecuteRemoteRunL( CStifItemParser* aItem, CSlave* aSlave, + HBufC *aSetUnsetEvent, + TInt aCaseNumber ) + { + CStartInfo* startInfo = CStartInfo::NewL(); + CleanupStack::PushL( startInfo ); + //if aSetUnsetEvent is given, then get start info from this argument + if( aSetUnsetEvent != NULL ) + { + TBuf<10> tmpModuleName; + tmpModuleName.Copy( _L( "suevent" ) ); + startInfo->SetModuleNameL( tmpModuleName ); + startInfo->SetConfigL( *aSetUnsetEvent ); + startInfo->SetTestCaseNumber( aCaseNumber ); + } + else + { + ParseRunParamsL( aItem, *startInfo ); + } + + CRemoteSubTestCaseRunner* remoteSubTestCase = CRemoteSubTestCaseRunner::NewL( + this, + aSlave, + iSlavesManager->GetRemoteCallsProxy() ); + CleanupStack::PushL( remoteSubTestCase ); + + __TRACE( KMessage, ( _L( "Executing sub test case: module=%S cfg=%S tcnum=%d id=%S" ), + &startInfo->GetModuleName(), &startInfo->GetConfig(), + startInfo->GetTestCaseNumber(), &startInfo->GetTestId()) ); + + RDebug::Print( _L( "Executing sub test case: module=%S cfg=%S tcnum=%d id=%S" ), + &startInfo->GetModuleName(), &startInfo->GetConfig(), + startInfo->GetTestCaseNumber(), &startInfo->GetTestId() ); + + remoteSubTestCase->RunSubTestCaseL( *startInfo ); + iSubTestCases.AppendL( remoteSubTestCase ); + if ( iLoopHelper->LoopInProgress() ) + { + iLoopHelper->RegisterInLoopSubTestCaseL( remoteSubTestCase ); + } + + CleanupStack::Pop( remoteSubTestCase ); + + iRunErrorMessage = KNullDesC; + + CleanupStack::PopAndDestroy( startInfo ); + + return ETrue; + } + +TBool CTestRunner::ExecuteRemoteEventCtlL( CStifItemParser* aItem, + CSlave* aSlave, + TInt aCmd ) + { + TPtrC eventName; + // Get event name + TInt ret = aItem->GetNextString( eventName ); + if( ret != KErrNone ) + { + __TRACE( KError, (_L("Event name was not given for remote"))); + User::Leave( KErrArgument ); + } + + TBool continueTask = ETrue; + switch( aCmd ) + { + // Event control cases + case TTestKeywords::ERequest: + { + TEventTS* event = aSlave->GetEvent( eventName ); + if( event != NULL ) + { + __TRACE( KError, (_L("Event %S already requested"), + &eventName ) ); + User::Leave( KErrNotFound ); + } + event = new( ELeave ) TEventTS( (TName&)eventName ); + CleanupStack::PushL( event ); + iSlavesManager->EventRequestL( aSlave, event ); + aSlave->AddEventL( event ); + CleanupStack::Pop( event ); + } + break; + case TTestKeywords::ERelease: + { + TEventTS* event = aSlave->GetEvent( eventName ); + if( event == NULL ) + { + __TRACE( KError, (_L("Event not found %S"), + &eventName ) ); + User::Leave( KErrNotFound ); + } + + aSlave->RemoveEventL( event ); + delete event; + // Release event + iSlavesManager->EventReleaseL( aSlave, eventName ); + } + break; + case TTestKeywords::EWait: + { + TEventTS* event = aSlave->GetEvent( eventName ); + if( event == NULL ) + { + __TRACE( KError, (_L("Waited event %S not requested"), + &eventName ) ); + User::Leave( KErrNotFound ); + } + + iState = ERunnerRunning; + SetActive(); + event->WaitEvent( iStatus ); + // Execution continue if waited event is set or after it is set + continueTask = EFalse; + } + break; + case TTestKeywords::ESet: + { + TPtrC optParam; + ret = aItem->GetNextString( optParam ); + TEventIf::TEventType eventType = TEventIf::EIndication; + if( ret == KErrNone ) + { + if ( optParam != _L("state") ) + { + __TRACE( KError, (_L("Invalid optional argument"))); + User::Leave( KErrArgument ); + } + eventType = TEventIf::EState; + } + iSlavesManager->EventSetL( aSlave, eventName, eventType ); + } + break; + case TTestKeywords::EUnset: + { + iSlavesManager->EventUnsetL( aSlave, eventName ); + } + break; + default: + // Should never come here + User::Leave( KErrGeneral ); + } + + return continueTask; + } + +TBool CTestRunner::ExecuteRemoteSendReceiveL( CStifItemParser* aItem, + CSlave* aSlave ) + { + TPtrC message; + aItem->Remainder( message ); + + iSlavesManager->SendReceiveL( aSlave, message ); + return ETrue; + } + +TBool CTestRunner::ExecuteRemoteUnknownL( CStifItemParser* aItem, + CSlave* aSlave, + TDesC& aCommand ) + { + TPtrC message; + aItem->Remainder( message ); + + iSlavesManager->SendUnknownL( aSlave, aCommand, message ); + return ETrue; + } + +/* +------------------------------------------------------------------------------- + + DESCRIPTION + + This module contains the implementation of CTestContinue class + member functions. CTestContinue handles ContinueScript calls from + TestScripter. + +------------------------------------------------------------------------------- +*/ +// MACROS +#ifdef LOGGER +#undef LOGGER +#endif +#define LOGGER iTestScripter->iLog + +// ================= MEMBER FUNCTIONS ========================================= + +/* +------------------------------------------------------------------------------- + + Class: CTestContinue + + Method: CTestContinue + + Description: Default constructor + + Parameters: CTestRunner* aTestRunner: in: Backpointer to CTestRunner + + Return Values: None + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +CTestContinue::CTestContinue( CTestScripter* aTestScripter, + TTestObject* aObject ): + // Executed with lowest priority, must be lower than CTesRunner priority + CActive( CActive::EPriorityLow ), + iTestScripter( aTestScripter ), + iObject( aObject ) + { + CActiveScheduler::Add( this ); + __TRACEFUNC(); + + } + +/* +------------------------------------------------------------------------------- + + Class: CTestContinue + + Method: ConstructL + + Description: Symbian OS second phase constructor + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CTestContinue::ConstructL() + { + + iObject->iScript->EnableSignal( iStatus ); + SetActive(); + + } + +/* +------------------------------------------------------------------------------- + + Class: CTestContinue + + Method: NewL + + Description: Two-phased constructor. + + Parameters: CTestRunner* aTestRunner: in: Backpointer to CTestRunner + + Return Values: CTestContinue*: new object + + Errors/Exceptions: Leaves if new or ConstructL leaves + + Status: Draft + +------------------------------------------------------------------------------- +*/ + +CTestContinue* CTestContinue::NewL( CTestScripter* aTestScripter, + TTestObject* aObject ) + { + CTestContinue* self = + new (ELeave) CTestContinue( aTestScripter, aObject ); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + + return self; + } + +/* +------------------------------------------------------------------------------- + + Class: CTestContinue + + Method: ~CTestContinue + + Description: Destructor + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ + +CTestContinue::~CTestContinue() + { + __TRACEFUNC(); + Cancel(); + + } + +/* +------------------------------------------------------------------------------- + + Class: CTestContinue + + Method: RunL + + Description: Derived from CActive, handles testcase execution. + + Parameters: None. + + Return Values: None. + + Errors/Exceptions: Leaves on error situations. + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CTestContinue::RunL() + { + + __TRACEFUNC(); + __TRACE( KMessage, (_L("CTestContinue::RunL: [%d] "), iStatus.Int() )); + + if( iObject->Signal() ) + { + // If OOM testing is ongoing ignore result check(given by user). + if( !iTestScripter->iOOMIgnoreFailure ) + { + // Erronous case RunError will called and test handling continue + // from there. + if( iTestScripter->TestRunner().TestCaseResults().Count() == 0 ) + { + // KErrNone is the default result expected + // if nothing else is given + User::LeaveIfError( iTestScripter->TestRunner(). + TestCaseResults().Append( KErrNone ) ); + } + + if( iTestScripter->TestRunner().TestCaseResults(). + Find( iStatus.Int() ) < 0 ) + { + __TRACE( KError, ( _L("Command for [%S] failed (%d)"), + &iObject->ObjectId(), iStatus.Int() )); + + + if( iStatus.Int() == KErrNone ) + { + User::Leave( KErrGeneral ); + } + else + { + User::Leave( iStatus.Int() ); + } + } + } + else + { + __TRACE( KMessage, ( + _L( "OOM test: 'oomignorefailure' is ON, signal result[%d] ignored" ), + iStatus.Int() )); + } + + iTestScripter->TestRunner().TestCaseResults().Reset(); + + __TRACE( KMessage, (_L("CTestContinue::RunL: Set runner active "))); + iTestScripter->iTestRunner->SetRunnerActive(); + } + else + { + // Signal called from test side but 'waittestclass' not yet processed + iObject->iAsyncResult = iStatus.Int(); + } + + iObject->iScript->EnableSignal( iStatus ); + SetActive(); + + } + +/* +------------------------------------------------------------------------------- + + Class: CTestContinue + + Method: DoCancel + + Description: Derived from CActive handles the Cancel + + Parameters: None. + + Return Values: None. + + Errors/Exceptions: None. + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CTestContinue::DoCancel() + { + + __TRACEFUNC(); + __TRACE( KMessage, (_L("CTestContinue::DoCancel"))); + + iObject->iScript->CancelSignal(); + + } + +/* +------------------------------------------------------------------------------- + + Class: CTestContinue + + Method: RunError + + Description: Derived from CActive handles the Cancel + + Parameters: None. + + Return Values: None. + + Errors/Exceptions: None. + + Status: Draft + +------------------------------------------------------------------------------- +*/ +TInt CTestContinue::RunError( TInt aError ) + { + + // Return error from here, if none given from execution + if( iTestScripter->iResult.iResult == KErrNone ) + { + iTestScripter->UpdateTestCaseResult(aError, _L("CTestContinue::RunError")); + } + CActiveScheduler::Current()->Stop(); + + return KErrNone; + + } + +/* +------------------------------------------------------------------------------- + + DESCRIPTION + + This module contains the implementation of CDefinedValue class + member functions. +------------------------------------------------------------------------------- +*/ + +// ================= MEMBER FUNCTIONS ========================================= +/* +------------------------------------------------------------------------------- + + Class: CDefinedValue + + Method: CDefinedValue + + Description: Default constructor + + C++ default constructor can NOT contain any code, that + might leave. + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +CDefinedValue::CDefinedValue() + { + } + +/* +------------------------------------------------------------------------------- + + Class: CDefinedValue + + Method: ConstructL + + Description: Symbian OS second phase constructor + + Symbian OS default constructor can leave. + + Parameters: TDesC& aName: in: Define name + TDesC& aValue: in: Define value + + Return Values: None + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CDefinedValue::ConstructL( TDesC& aName, TDesC& aValue ) + { + + iNameBuf = aName.AllocLC(); + iName.Set( iNameBuf->Des() ); + iValueBuf = aValue.AllocLC(); + iValue.Set( iValueBuf->Des() ); + CleanupStack::Pop( iValueBuf ); + CleanupStack::Pop( iNameBuf ); + + } + +/* +------------------------------------------------------------------------------- + + Class: CDefinedValue + + Method: NewL + + Description: Two-phased constructor. + + Parameters: TDesC& aName: in: Define name + TDesC& aValue: in: Define value + + Return Values: CDefinedValue*: new object + + Errors/Exceptions: Leaves if new or ConstructL leaves. + + Status: Draft + +------------------------------------------------------------------------------- +*/ +CDefinedValue* CDefinedValue::NewL( TDesC& aName, TDesC& aValue ) + { + + CDefinedValue* self = new (ELeave) CDefinedValue(); + + CleanupStack::PushL( self ); + self->ConstructL( aName, aValue ); + CleanupStack::Pop(); + + return self; + + } + +/* +------------------------------------------------------------------------------- + + Class: CDefinedValue + + Method: ~CDefinedValue + + Description: Destructor + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +CDefinedValue::~CDefinedValue() + { + + delete iValueBuf; + delete iNameBuf; + + } + +/* +------------------------------------------------------------------------------- + + Class: CDefinedValue + + Method: SetValueL + + Description: Set new define value + + Parameters: TDesC& aValue: in: Define value + + Return Values: None + + Errors/Exceptions: Leaves on error. + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CDefinedValue::SetValueL( TDesC& aValue ) + { + delete iValueBuf; + iValueBuf = 0; + iValueBuf = aValue.AllocLC(); + iValue.Set( iValueBuf->Des() ); + CleanupStack::Pop( iValueBuf ); + + } + + +/* +------------------------------------------------------------------------------- + + Class: CDefinedValue + + Method: Name + + Description: Returns define name. + + Parameters: None + + Return Values: TDesC: Define name + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +TDesC& CDefinedValue::Name() + { + return iName; + } + +/* +------------------------------------------------------------------------------- + + Class: CDefinedValue + + Method: Value + + Description: Returns define value. + + Parameters: None + + Return Values: TDesC: Define value + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +TDesC& CDefinedValue::Value() + { + return iValue; + } + + +/* +------------------------------------------------------------------------------- + + DESCRIPTION + + This module contains the implementation of TTestObjectBase class + member functions. +------------------------------------------------------------------------------- +*/ + +// ================= MEMBER FUNCTIONS ========================================= +/* +------------------------------------------------------------------------------- + + Class: TTestObjectBase + + Method: TTestObjectBase + + Description: Constructor + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +TTestObjectBase::TTestObjectBase( TObjectType aType ) : + iAsyncResult( KErrNone ), + iType( aType ) + { + + RDebug::Print( _L("TTestObjectBase::TTestObjectBase") ); + iName.Zero(); + + } + + /* +------------------------------------------------------------------------------- + + Class: TTestObjectBase + + Method: ~TTestObjectBase + + Description: Destructor + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +TTestObjectBase::~TTestObjectBase() + { + + RDebug::Print( _L("TTestObjectBase::~TTestObjectBase") ); + + } + +/* +------------------------------------------------------------------------------- + + DESCRIPTION + + This module contains the implementation of TTestObject class + member functions. +------------------------------------------------------------------------------- +*/ +// ================= MEMBER FUNCTIONS ========================================= + +/* +------------------------------------------------------------------------------- + + Class: TTestObject + + Method: TTestObject + + Description: Constructor + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +TTestObject::TTestObject() : + TTestObjectBase( EObjectNormal ), + iContinue(0), + iCount(0) + { + iScript = 0; + RDebug::Print( _L("TTestObject::TTestObject") ); + + } + +/* +------------------------------------------------------------------------------- + + Class: TTestObject + + Method: ~TTestObject + + Description: Destructor + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +TTestObject::~TTestObject() + { + + RDebug::Print( _L("TTestObject::~TTestObject") ); + delete iContinue; + iContinue = 0; + + } + +/* +------------------------------------------------------------------------------- + + Class: TTestObject + + Method: RunMethodL + + Description: Run specified method from testclass. + + Parameters: CStifItemParser* aItem: in: itemparser + + Return Values: Symbian OS error code + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +TInt TTestObject::RunMethodL( CStifItemParser& aItem ) + { + + return iScript->RunMethodL( aItem ); + + } + +/* +------------------------------------------------------------------------------- + + DESCRIPTION + + This module contains the implementation of TTestObjectKernel class + member functions. +------------------------------------------------------------------------------- +*/ +// ================= MEMBER FUNCTIONS ========================================= + + +/* +------------------------------------------------------------------------------- + + Class: TTestObjectKernel + + Method: TTestObjectKernel + + Description: Constructor + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +TTestObjectKernel::TTestObjectKernel() : + TTestObjectBase( EObjectKernel ) + { + + RDebug::Print( _L("TTestObjectKernel::TTestObjectKernel") ); + + } + +/* +------------------------------------------------------------------------------- + + Class: TTestObjectKernel + + Method: ~TTestObjectKernel + + Description: Destructor + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +TTestObjectKernel::~TTestObjectKernel() + { + + RDebug::Print( _L("TTestObjectKernel::~TTestObjectKernel") ); + + iTestClass.Close(); + User::FreeLogicalDevice( iLddName ); + + } + +/* +------------------------------------------------------------------------------- + + Class: TTestObjectKernel + + Method: RunMethodL + + Description: Run specified method from kernel testclass. + + Parameters: CStifItemParser& aItem: in: itemparser + + Return Values: Symbian OS error code + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +TInt TTestObjectKernel::RunMethodL( CStifItemParser& aItem ) + { + + TPtrC method; + TPtrC params; + + User::LeaveIfError( aItem.GetNextString( method ) ); + aItem.Remainder( params ); + + TInt result; + TMethodResultDes resultDes; + + // Need to change descriptors from 16bit to 8bit for EKA2 kernel + // because STIF Parser doesn't support 8bit parsing + HBufC8 * myBuf1 = HBufC8::NewL( method.Length() ); + TPtr8 met8 = myBuf1->Des(); + met8.Copy( method ); + + HBufC8 * myBuf2 = HBufC8::NewL( params.Length() ); + TPtr8 par8 = myBuf2->Des(); + par8.Copy( params ); + + TInt ret = iTestClass.RunMethod( met8, par8, result, resultDes ); + + delete myBuf1; + delete myBuf2; + + if( ret != KErrNone ) + { + return ret; + } + + return result; + + }; + + +// ================= OTHER EXPORTED FUNCTIONS ================================= + +/* +------------------------------------------------------------------------------- + + Function: LibEntryL + + Description: Polymorphic Dll Entry Point + + Parameters: None. + + Return Values: CTestScripter*: pointer to new CTestScripter + + Errors/Exceptions: Leaves if NewL leaves. + + Status: Draft + +------------------------------------------------------------------------------- +*/ + +EXPORT_C CTestScripter* LibEntryL() + { + return CTestScripter::NewL(); + + } + + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/scriptermod/src/TestScripterInternal.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/scriptermod/src/TestScripterInternal.cpp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,390 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains TestScripterImp implementation. +* +*/ + +// INCLUDE FILES +#include +#include +#include "TestScripterInternal.h" +#include "TestScripter.h" +// EXTERNAL DATA STRUCTURES +//extern ?external_data; + +// EXTERNAL FUNCTION PROTOTYPES +//extern ?external_function( ?arg_type,?arg_type ); + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def + +// LOCAL CONSTANTS AND MACROS +//const ?type ?constant_var = ?constant; +//#define ?macro_name ?macro_def + +// MODULE DATA STRUCTURES +//enum ?declaration +//typedef ?declaration + +// LOCAL FUNCTION PROTOTYPES +//?type ?function_name( ?arg_type, ?arg_type ); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; + +// ============================= LOCAL FUNCTIONS =============================== + +// None + + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CScriptBase::CScriptBase +// Constructor. +// ----------------------------------------------------------------------------- +// +EXPORT_C CScriptBase::CScriptBase( CTestModuleIf& aTestModuleIf ): + iTestModuleIf( aTestModuleIf ) + { + // Handles multible 'waittestclass' given in test configure file. + iSignalErrors.Reset(); + + } + + +// ----------------------------------------------------------------------------- +// CScriptBase::TestModuleIf +// Get reference to TestModuleIf API. +// ----------------------------------------------------------------------------- +// +EXPORT_C CTestModuleIf& CScriptBase::TestModuleIf() + { + + return iTestModuleIf; + + } + +// ----------------------------------------------------------------------------- +// CScriptBase::Signal +// Signal TestScripter to continue from waittestclass. +// ----------------------------------------------------------------------------- +// +EXPORT_C void CScriptBase::Signal( TInt aError ) + { + + if( iStatus ) + { + User::RequestComplete( iStatus, aError ); + } + else + { + // Handles multible 'waittestclass' given in test configure file. + // There is active object in CTestRunner also and it has higher + // priority than CTestContinue(It must be higher that e.g. + // 'allownextresult' is gotten right from configure file). That why we + // have to use this array and take signal "count" to the array for + // later handling. + iSignalErrors.Append( aError ); + } + + } + +// ----------------------------------------------------------------------------- +// CScriptBase::CallTestClass +// Called from test class. TestScripter forwards +// operations to other test class object. +// aLine: in: +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CScriptBase::CallTestClass( const TDesC& aLine ) + { + + if( iFunc ) + { + return iFunc( iTestScripter, EStifTSCallClass, aLine ); + } + + return KErrNotSupported; + + }; + +// ----------------------------------------------------------------------------- +// CScriptBase::GetTestObject +// Get test class object address. +// ----------------------------------------------------------------------------- +// +EXPORT_C CScriptBase* CScriptBase::GetTestObject( const TDesC& aObjectName ) + { + + if( iFunc ) + { + TInt ret = iFunc( iTestScripter, EStifTSGetObject, aObjectName ); + if( ret > 0 ) + { + return( CScriptBase* )ret; + } + } + + return NULL; + }; + +// ----------------------------------------------------------------------------- +// CScriptBase::EnableSignal +// Enable Signal(). +// ----------------------------------------------------------------------------- +// +EXPORT_C void CScriptBase::EnableSignal( TRequestStatus& aStatus ) + { + + aStatus = KRequestPending; + iStatus = &aStatus; + + // Handles multible 'waittestclass' given in test configure file. + if( iSignalErrors.Count() > 0 ) + { + // Complete signal and remove it from array. + TInt error = iSignalErrors[0]; + iSignalErrors.Remove( 0 ); + User::RequestComplete( iStatus, error ); + } + + } + +// ----------------------------------------------------------------------------- +// CScriptBase::CancelSignal +// Cancel Signal(). +// ----------------------------------------------------------------------------- +// +EXPORT_C void CScriptBase::CancelSignal() + { + if(iStatus!=NULL) + { + User::RequestComplete( iStatus, KErrCancel ); + } + } + +// ----------------------------------------------------------------------------- +// CScriptBase::SetScripter +// Set scripter callback. +// ----------------------------------------------------------------------------- +// +EXPORT_C void CScriptBase::SetScripter( CallBackFunc aFunc, CTestScripter* aTestScripter ) + { + + iTestScripter = aTestScripter; + iFunc = aFunc; + + } + +// ----------------------------------------------------------------------------- +// CScriptBase::RunInternalL +// Run specified method from test class. +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CScriptBase::RunInternalL ( + TStifFunctionInfo const aFunctions[], + TInt aCount, + CStifItemParser& aItem ) + { + + TInt ret = KErrNotFound; + + TPtrC command; + User::LeaveIfError ( aItem.GetNextString( command ) ); + TInt i = 0; + TName funcName; + + // Search function from table and call it + for ( i = 0; i < aCount; i++ ) + { + funcName = aFunctions[i].iFunctionName; + if ( command == funcName ) + { + if( iLog ) + { + iLog->Log(_L("Calling [%S]"), &command ); + } + ret = ( this->*(aFunctions[i].iMethod) )( aItem ); + + break; + } + + } + + if( i == aCount ) + { + iLog->Log( _L("[%S] not found"), &command ); + } + + return ret; + + } + +// ----------------------------------------------------------------------------- +// CScriptBase::GetConstantValue +// Internal fuction to get const value defined in +// [Define]...[Enddefine] section of script file +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CScriptBase::GetConstantValue( const TDesC& aName, TDes& aValue ) + { + return iTestScripter->GetConstantValue( aName, aValue ); + } + + +// ----------------------------------------------------------------------------- +// CScriptBase::GetConstantValue +// Internal fuction to get const value defined in +// [Define]...[Enddefine] section of script file +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CScriptBase::GetConstantValue( const TDesC& aName, TInt& aValue ) + { + TInt ret = KErrNone; + TBuf<32> valStr; + ret = iTestScripter->GetConstantValue( aName, valStr ); + if ( ret != KErrNone ) + { + return ret; + } + + TLex converter( valStr ); + ret = converter.Val( aValue ); + + return ret; + } + +// ----------------------------------------------------------------------------- +// CScriptBase::GetConstantValue +// Internal fuction to get const value defined in +// [Define]...[Enddefine] section of script file +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CScriptBase::GetConstantValue( const TDesC& aName, TReal& aValue ) + { + TInt ret = KErrNone; + TBuf<32> valStr; + ret = iTestScripter->GetConstantValue( aName, valStr ); + if ( ret != KErrNone ) + { + return ret; + } + + TLex converter( valStr ); + ret = converter.Val( aValue ); + + return ret; + } + +// ----------------------------------------------------------------------------- +// CScriptBase::SetResultDescription +// Result description can be set from within the test class method +// ----------------------------------------------------------------------------- +// +EXPORT_C void CScriptBase::SetResultDescription(const TDesC& aDescription) + { + iTestScripter->SetResultDescription(aDescription); + } + +// ----------------------------------------------------------------------------- +// CScriptBase::SetLocalValue +// Internal fuction to set local value +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CScriptBase::SetLocalValue(const TDesC& aName, const TDesC& aValue) + { + return iTestScripter->SetLocalValue(aName, aValue); + } + +// ----------------------------------------------------------------------------- +// CScriptBase::SetLocalValue +// Internal fuction to set local value +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CScriptBase::SetLocalValue(const TDesC& aName, const TInt aValue) + { + TBuf<20> buf; + buf.Format(_L("%d"), aValue); + return iTestScripter->SetLocalValue(aName, buf); + } + +// ----------------------------------------------------------------------------- +// CScriptBase::SetLocalValue +// Internal fuction to set local value +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CScriptBase::SetLocalValue(const TDesC& aName, const TReal aValue ) + { + TBuf<50> buf; + buf.Format(_L("%g"), aValue); + return iTestScripter->SetLocalValue(aName, buf); + } + +// ----------------------------------------------------------------------------- +// CScriptBase::GetLocalValue +// Internal fuction to get local value +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CScriptBase::GetLocalValue(const TDesC& aName, TDes& aValue) + { + return iTestScripter->GetLocalValue(aName, aValue); + } + +// ----------------------------------------------------------------------------- +// CScriptBase::GetLocalValue +// Internal fuction to get local value +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CScriptBase::GetLocalValue(const TDesC& aName, TInt& aValue) + { + TInt ret = KErrNone; + TBuf<50> valStr; + ret = iTestScripter->GetLocalValue(aName, valStr); + if(ret != KErrNone) + { + return ret; + } + + TLex converter(valStr); + ret = converter.Val(aValue); + + return ret; + } + +// ----------------------------------------------------------------------------- +// CScriptBase::GetLocalValue +// Internal fuction to get local value +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CScriptBase::GetLocalValue(const TDesC& aName, TReal& aValue ) + { + TInt ret = KErrNone; + TBuf<50> valStr; + ret = iTestScripter->GetLocalValue(aName, valStr); + if(ret != KErrNone) + { + return ret; + } + + TLex converter(valStr); + ret = converter.Val(aValue); + + return ret; + } + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/scriptermod/src/TestScripterUtils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/scriptermod/src/TestScripterUtils.cpp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,3078 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file contains TestScripter implementation. +* +*/ + +// INCLUDE FILES +#include "TestScripterUtils.h" +#include +#include "TestScripter.h" +#include "Logging.h" + +// EXTERNAL DATA STRUCTURES +// None + +// EXTERNAL FUNCTION PROTOTYPES +// None + +// CONSTANTS +// None + +// MACROS +// None + +// LOCAL CONSTANTS AND MACROS +// None + +// MODULE DATA STRUCTURES +// None + +// LOCAL FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +// None + +// ==================== LOCAL FUNCTIONS ======================================= + +// ================= MEMBER FUNCTIONS ========================================= + +/* +------------------------------------------------------------------------------- + + Class: CStartInfo + + Method: CStartInfo + + Description: Default constructor + + C++ default constructor can NOT contain any code, that + might leave. + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +CStartInfo::CStartInfo(): +iCategory( TFullTestResult::ECaseExecuted ) + { + } + +/* +------------------------------------------------------------------------------- + + Class: CStartInfo + + Method: ConstructL + + Description: Symbian OS second phase constructor + + Symbian OS default constructor can leave. + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CStartInfo::ConstructL() + { + iModule = HBufC::NewL( 0 ); + iIniFile = HBufC::NewL( 0 ); + iConfig = HBufC::NewL( 0 ); + iTestId = HBufC::NewL( 0 ); + iTitle = HBufC::NewL( 0 ); + } + +/* +------------------------------------------------------------------------------- + + Class: CStartInfo + + Method: NewL + + Description: Two-phased constructor. + + Parameters: None + + Return Values: CStartInfo*: new object + + Errors/Exceptions: Leaves if new or ConstructL leaves. + + Status: Draft + +------------------------------------------------------------------------------- +*/ +CStartInfo* CStartInfo::NewL() + { + CStartInfo* self = new (ELeave) CStartInfo(); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + + return self; + + } + +/* +------------------------------------------------------------------------------- + + Class: CStartInfo + + Method: ~CStartInfo + + Description: Destructor + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +CStartInfo::~CStartInfo() + { + delete iModule; + delete iIniFile; + delete iConfig; + delete iTestId; + delete iTitle; + } + +/* +------------------------------------------------------------------------------- + + Class: CStartInfo + + Method: SetModuleNameL + + Description: Set module name. + + Parameters: TDesC& aModule: in: Module name + TInt aExtLength: in: Extra length reserved for buffer + + Return Values: None + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ + void CStartInfo::SetModuleNameL( const TDesC& aModule, TInt aExtLength ) + { + HBufC* module = HBufC::NewL( aModule.Length() + aExtLength ); + CleanupStack::PushL( module ); + TPtr modulePtr( module->Des() ); + modulePtr.Append( aModule ); + + // Remove optional '.DLL' from file name + modulePtr.LowerCase(); + TParse parse; + parse.Set( *module, NULL, NULL ); + + if ( parse.Ext() == _L(".dll") ) + { + const TInt len = parse.Ext().Length(); + modulePtr.Delete ( modulePtr.Length() - len, len ); + } + CleanupStack::Pop( module ); + delete iModule; + iModule = module; + }; + +/* +------------------------------------------------------------------------------- + + Class: CStartInfo + + Method: SetIniFileL + + Description: Set initialization file name name. + + Parameters: TDesC& aIni: in: Initialization file name + + Return Values: None + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +void CStartInfo::SetIniFileL( const TDesC& aIni ) + { + HBufC* inifile = aIni.AllocL(); + delete iIniFile; + iIniFile = inifile; + }; + +/* +------------------------------------------------------------------------------- + + Class: CStartInfo + + Method: SetConfigL + + Description: Set configuration file name name. + + Parameters: TDesC& aConfig: in: Configuration file name + + Return Values: None + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +void CStartInfo::SetConfigL( const TDesC& aConfig ) + { + HBufC* config = aConfig.AllocL(); + delete iConfig; + iConfig = config; + }; + +/* +------------------------------------------------------------------------------- + + Class: CStartInfo + + Method: SetTestIdL + + Description: Set test identifier. + + Parameters: TDesC& aTestId: in: test identifier + + Return Values: None + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +void CStartInfo::SetTestIdL( const TDesC& aTestId ) + { + HBufC* testId = aTestId.AllocL(); + delete iTestId; + iTestId = testId; + }; + +/* +------------------------------------------------------------------------------- + + Class: CStartInfo + + Method: SetTitleL + + Description: Set title. + + Parameters: TDesC& aTitle: in: Test case title + + Return Values: None + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +void CStartInfo::SetTitleL( const TDesC& aTitle) + { + HBufC* title = aTitle.AllocL(); + delete iTitle; + iTitle = title; + } + +/* +------------------------------------------------------------------------------- + + Class: CStartInfo + + Method: SetTestCaseNumber + + Description: Sets test case index. + + Parameters: TInt aTestCaseNumber: in: Test case index + + Return Values: None + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +void CStartInfo::SetTestCaseNumber( TInt aTestCaseNumber ) + { + iCaseNum = aTestCaseNumber; + } + +/* +------------------------------------------------------------------------------- + + Class: CStartInfo + + Method: SetExpectedResult + + Description: Sets test case expected result + + Parameters: TInt aExpectedResult: in: Test case expected result + + Return Values: None + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +void CStartInfo::SetExpectedResult( TInt aExpectedResult ) + { + iExpectedResult = aExpectedResult; + } + +/* +------------------------------------------------------------------------------- + + Class: CStartInfo + + Method: SetExpectedResultCategory + + Description: Sets test case expected result category + + Parameters: TFullTestResult::TCaseExecutionResult aCategory: in: Test case expected result category + + Return Values: None + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +void CStartInfo::SetExpectedResultCategory( TFullTestResult::TCaseExecutionResult aCategory ) + { + iCategory = aCategory; + } + +/* +------------------------------------------------------------------------------- + + Class: CStartInfo + + Method: SetTimeout + + Description: Sets test case timeout value + + Parameters: TInt aTimeout: in: Test case timeout value + + Return Values: None + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +void CStartInfo::SetTimeout( TInt aTimeout ) + { + iTimeout = aTimeout; + } + +/* +------------------------------------------------------------------------------- + + Class: CStartInfo + + Method: GetModuleName + + Description: Gets test module name. + + Parameters: None + + Return Values: Test module name + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +const TDesC& CStartInfo::GetModuleName() const + { + return *iModule; + } + +/* +------------------------------------------------------------------------------- + + Class: CStartInfo + + Method: GetIniFile + + Description: Gets ini file path + + Parameters: None + + Return Values: Ini file path + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +const TDesC& CStartInfo::GetIniFile() const + { + return *iIniFile; + } + +/* +------------------------------------------------------------------------------- + + Class: CStartInfo + + Method: GetConfig + + Description: Gets config file path + + Parameters: None + + Return Values: Config file path + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +const TDesC& CStartInfo::GetConfig() const + { + return *iConfig; + } + +/* +------------------------------------------------------------------------------- + + Class: CStartInfo + + Method: GetTestId + + Description: Gets test case id + + Parameters: None + + Return Values: Test case id + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +const TDesC& CStartInfo::GetTestId() const + { + return *iTestId; + } + +/* +------------------------------------------------------------------------------- + + Class: CStartInfo + + Method: GetTitle + + Description: Gets test case title + + Parameters: None + + Return Values: Test case title + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +const TDesC& CStartInfo::GetTitle() const + { + return *iTitle; + } + +/* +------------------------------------------------------------------------------- + + Class: CStartInfo + + Method: GetTestCaseNumber + + Description: Gets test case index + + Parameters: None + + Return Values: Test case index + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +TInt CStartInfo::GetTestCaseNumber() const + { + return iCaseNum; + } + +/* +------------------------------------------------------------------------------- + + Class: CStartInfo + + Method: GetExpectedResult + + Description: Gets test case expected result + + Parameters: None + + Return Values: Test case expected result + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +TInt CStartInfo::GetExpectedResult() const + { + return iExpectedResult; + } + +/* +------------------------------------------------------------------------------- + + Class: CStartInfo + + Method: GetExpectedResultCategory + + Description: Gets test case expected result category + + Parameters: None + + Return Values: Test case expected result category + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +TFullTestResult::TCaseExecutionResult CStartInfo::GetExpectedResultCategory() const + { + return iCategory; + } + +/* +------------------------------------------------------------------------------- + + Class: CStartInfo + + Method: GetTimeout + + Description: Gets test case timeout value + + Parameters: None + + Return Values: Test case timeout value + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +TInt CStartInfo::GetTimeout() const + { + return iTimeout; + } + +/* +------------------------------------------------------------------------------- + + Class: CStartInfo + + Method: CopyL + + Description: Copy values from other CStartInfo instance. + + Parameters: const CStartInfo& aStartInfo: in: CStartInfo instance + + Return Values: None + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +void CStartInfo::CopyL( const CStartInfo& aStartInfo ) + { + SetConfigL( aStartInfo.GetConfig() ); + SetExpectedResult( aStartInfo.GetExpectedResult() ); + SetExpectedResultCategory( aStartInfo.GetExpectedResultCategory() ); + SetIniFileL( aStartInfo.GetIniFile() ); + SetModuleNameL( aStartInfo.GetModuleName() ); + SetTestCaseNumber( aStartInfo.GetTestCaseNumber() ); + SetTestIdL( aStartInfo.GetTestId() ); + SetTimeout( aStartInfo.GetTimeout() ); + SetTitleL( aStartInfo.GetTitle() ); + } + + +/* +------------------------------------------------------------------------------- + + Class: CLoopHelper + + Method: NewL + + Description: Two-phased constructor. + + Parameters: CTestRunner* aTestRunner: in: Pointer to CTestRunner + + Return Values: CLoopHelper*: new object + + Errors/Exceptions: Leaves if new or ConstructL leaves. + + Status: Draft + +------------------------------------------------------------------------------- +*/ +CLoopHelper* CLoopHelper::NewL( CTestRunner* aTestRunner ) + { + CLoopHelper* self = new(ELeave)CLoopHelper( aTestRunner ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +/* +------------------------------------------------------------------------------- + + Class: CLoopHelper + + Method: ~CLoopHelper + + Description: Destructor. + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +CLoopHelper::~CLoopHelper() + { + Cancel(); + iInLoopSubTestCases.Reset(); + iInLoopSubTestCases.Close(); + } + +/* +------------------------------------------------------------------------------- + + Class: CLoopHelper + + Method: CLoopHelper + + Description: Constructor. + + Parameters: CTestRunner* aTestRunner: in: Pointer to CTestRunner + + Return Values: None + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +CLoopHelper::CLoopHelper( CTestRunner* aTestRunner ) +:CActive( EPriorityStandard ), iTestRunner( aTestRunner ) + { + } + +/* +------------------------------------------------------------------------------- + + Class: CLoopHelper + + Method: ConstructL + + Description: Two-phased constructor. + + Parameters: None + + Return Values: None + + Errors/Exceptions: Leaves if new or ConstructL leaves. + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CLoopHelper::ConstructL() + { + CActiveScheduler::Add( this ); + } + +/* +------------------------------------------------------------------------------- + + Class: CLoopHelper + + Method: LoopStartL + + Description: Should be to indicate loop start. + + Parameters: None + + Return Values: None + + Errors/Exceptions: Leaves if new or ConstructL leaves. + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CLoopHelper::LoopStartL() + { + IterationBeginL( ETrue ); + } + +/* +------------------------------------------------------------------------------- + + Class: CLoopHelper + + Method: IterationEndStartNextIterationL + + Description: Should be called to indicate end of iteration and begining of next iteration + + Parameters: None + + Return Values: None + + Errors/Exceptions: Leaves if new or ConstructL leaves. + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CLoopHelper::IterationEndStartNextIterationL() + { + IterationEndL( EFalse ); + } + +/* +------------------------------------------------------------------------------- + + Class: CLoopHelper + + Method: LoopEndL + + Description: Should be called to indicate loop end + + Parameters: None + + Return Values: None + + Errors/Exceptions: Leaves if new or ConstructL leaves. + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CLoopHelper::LoopEndL() + { + IterationEndL( ETrue ); + } + +/* +------------------------------------------------------------------------------- + + Class: CLoopHelper + + Method: IterationBeginL + + Description: Indicate begining of the loop iteration + + Parameters: TBool aFirstIteration: in: Indicates if it is first iteration + + Return Values: None + + Errors/Exceptions: Leaves if new or ConstructL leaves. + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CLoopHelper::IterationBeginL( TBool aFirstIteration ) + { + // Check if it is first iteration. If yes then reset CLoopHelper state + if ( aFirstIteration ) + { + if ( iInProgress ) + { + User::Leave( KErrInUse ); + } + iPassedIterationsCounter = 0; + iInProgress = ETrue; + iLoopEnd = EFalse; + } + + // Check for invalid calls order + if ( iIterationOngoing ) + { + User::Leave( KErrInUse ); + } + iIterationOngoing = ETrue; + iPassCurrentIteration = ETrue; + } + +/* +------------------------------------------------------------------------------- + + Class: CLoopHelper + + Method: IterationEndL + + Description: Indicate end of the loop iteration + + Parameters: TBool aLastIteration: in: Indicates if it is last iteration + + Return Values: None + + Errors/Exceptions: Leaves if new or ConstructL leaves. + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CLoopHelper::IterationEndL( TBool aLastIteration ) + { + // Perform tests to check if methods were called in proper order + if ( IsActive() ) + { + User::Leave( KErrInUse ); + } + + if ( !( iInProgress && iIterationOngoing ) ) + { + User::Leave( KErrNotReady ); + } + + if ( aLastIteration ) + { + iLoopEnd = ETrue; + } + + // It is end of loop iteration. Wait for all sub test cases executed inside loop + // to finish its execution. + iStatus = KRequestPending; + SetActive(); + if ( iInLoopSubTestCases.Count() == 0 ) + { + // All sub test cases executed inside loop are already finished. + // Schedule activation of CTestRunner to continue script execution after endloop keyword + // ( it is done in CLoopHelper::RunL ) + TRequestStatus* status = &iStatus; + User::RequestComplete( status, KErrNone ); + } + } + +/* +------------------------------------------------------------------------------- + + Class: CLoopHelper + + Method: RegisterInLoopSubTestCaseL + + Description: Should be called to register sub test case executed inside loop + + Parameters: CSubTestCaseRunner* aSubTestCaseRunner: in: Sub test case runner + to be registered + + Return Values: None + + Errors/Exceptions: Leaves if new or ConstructL leaves. + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CLoopHelper::RegisterInLoopSubTestCaseL( CSubTestCaseRunner* aSubTestCaseRunner ) + { + // Check if loop iteration is ongoing + if ( !( iInProgress && iIterationOngoing ) ) + { + User::Leave( KErrNotReady ); + } + + iInLoopSubTestCases.AppendL( aSubTestCaseRunner ); + } + +void CLoopHelper::UnregisterInLoopSubTestCaseL( CSubTestCaseRunner* aSubTestCaseRunner ) + { + // Check if loop iteration is ongoing + if ( !( iInProgress && iIterationOngoing ) ) + { + User::Leave( KErrNotReady ); + } + + TInt idx = iInLoopSubTestCases.Find( aSubTestCaseRunner ); + if ( idx >= 0 ) + { + iInLoopSubTestCases.Remove( idx ); + } + } + +void CLoopHelper::RegisterInLoopSlaveL( CSlave* aSlave ) + { + // Check if loop iteration is ongoing + if ( !( iInProgress && iIterationOngoing ) ) + { + User::Leave( KErrNotReady ); + } + + iInLoopSlaves.AppendL( aSlave ); + } + +void CLoopHelper::UnregisterInLoopSlaveL( CSlave* aSlave ) + { + // Check if loop iteration is ongoing + if ( !( iInProgress && iIterationOngoing ) ) + { + User::Leave( KErrNotReady ); + } + TInt idx = iInLoopSlaves.Find( aSlave ); + if ( idx >= 0 ) + { + iInLoopSlaves.Remove( idx ); + } + } + +RPointerArray& CLoopHelper::GetRegisteredInLoopSlaves() + { + return iInLoopSlaves; + } + +/* +------------------------------------------------------------------------------- + + Class: CLoopHelper + + Method: NotifySubTestCaseEndL + + Description: Should be called to indicate end of sub test case executed inside loop + + Parameters: CSubTestCaseRunner* aSubTestCaseRunner: in: Sub test case which ended + TBool aPassed: in: Indicates if test case passed or not + + Return Values: None + + Errors/Exceptions: Leaves if new or ConstructL leaves. + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CLoopHelper::NotifySubTestCaseEndL( CSubTestCaseRunner* aSubTestCaseRunner, TBool aPassed ) + { + // Check if execution of the loop is ongoing + if ( !iInProgress ) + { + User::Leave( KErrNotReady ); + } + + // Check if selected sub test case was executed inside loop + TInt idx = iInLoopSubTestCases.Find( aSubTestCaseRunner ); + if ( idx >= 0 ) + { + iInLoopSubTestCases.Remove( idx ); + if ( !aPassed ) + { + iPassCurrentIteration = EFalse; + } + + // Check if there are other ont finished sub test cases executed inside loop + if ( iInLoopSubTestCases.Count() == 0 ) + { + // Check if CLoopHelper is active. + if ( IsActive() ) + { + // CLoopHelper is active. It means that IterationEndL method was called + // and CTestRunner currently waiting for sub test end before executing next + // iteration of the loop. Since all sub test cases executed inside lopp are + // already finished we can activate CTestRunner ( it is done in CLoopHelper::RunL ) + TRequestStatus* status = &iStatus; + User::RequestComplete( status, KErrNone ); + } + } + } + } + +/* +------------------------------------------------------------------------------- + + Class: CLoopHelper + + Method: LoopInProgress + + Description: Indicates if loop execution is in progress + + Parameters: None + + Return Values: True if loop is in progress. + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +TBool CLoopHelper::LoopInProgress() const + { + return iInProgress; + } + +/* +------------------------------------------------------------------------------- + + Class: CLoopHelper + + Method: DoCancel + + Description: See CActive::DoCancel + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CLoopHelper::DoCancel() + { + TRequestStatus* status = &iStatus; + User::RequestComplete( status, KErrCancel ); + } + +/* +------------------------------------------------------------------------------- + + Class: CLoopHelper + + Method: RunL + + Description: See CActive::RunL + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +void CLoopHelper::RunL() + { + // Iteration has ended and all sub test cases executed inside loop has ended. + User::LeaveIfError( iStatus.Int() ); + iIterationOngoing = EFalse; + + if ( iPassCurrentIteration ) + { + iPassedIterationsCounter++; + } + + // Activate CTestRunner to continue test case execution + iTestRunner->SetRunnerActive(); + + if ( iLoopEnd ) + { + iTestRunner->ReleaseRemoteResourcesAllocatedInLoopL(); + // It was last iteration. Report loop result to CTestRunner + iTestRunner->ReportLoopEndResultL( iPassedIterationsCounter ); + // Reset CLoopHelper state + iLoopEnd = EFalse; + iInProgress = EFalse; + } + else + { + // Begin next loop iteration + IterationBeginL( EFalse ); + } + } + +/* +------------------------------------------------------------------------------- + + Class: CSlaveInfo + + Method: GetEvent + + Description: Returns event with given name. + + Parameters: TDesC& aEventName: in; Event name + + Return Values: TEventTc: Event structure + + Errors/Exceptions: None + + Status: Draft + +------------------------------------------------------------------------------- +*/ +//TEventTc* CSlaveInfo::GetEvent( TDesC& aEventName ) +// { +// +// TInt count = iEvents.Count(); +// for( TInt i = 0; i < count; i++ ) +// { +// if( iEvents[i]->Name() == aEventName ) +// { +// return iEvents[i]; +// } +// } +// return NULL; +// +// } + +#ifdef LOGGER +#undef LOGGER +#endif + +#define LOGGER iLogger + +/* +------------------------------------------------------------------------------- + + Class: TEventTS + + Method: TEventTS + + Description: Default constructor + + C++ default constructor can NOT contain any code, that + might leave. + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +TEventTS::TEventTS() +:iClientReqStatus( NULL ) + { + } + +/* +------------------------------------------------------------------------------- + + Class: TEventTS + + Method: TEventTS + + Description: Parametric constructor + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +TEventTS::TEventTS( TName& aEventName ) +:iClientReqStatus( NULL ) + { + SetName( aEventName ); + SetType( EReqEvent ); + } + +/* +------------------------------------------------------------------------------- + + Class: TEventTS + + Method: ~TEventTS + + Description: Destructor + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +TEventTS::~TEventTS() + { + Complete( KErrNone ); + } +/* +------------------------------------------------------------------------------- + + Class: TEventTS + + Method: SetRequestStatus + + Description: Set request status member. + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +void TEventTS::SetRequestStatus( TRequestStatus* aStatus ) + { + iClientReqStatus = aStatus; + *iClientReqStatus = KRequestPending; + } + +/* +------------------------------------------------------------------------------- + + Class: TEventTS + + Method: Complete + + Description: Complete request status member. + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +void TEventTS::Complete( TInt aError ) + { + if( iClientReqStatus ) + { + User::RequestComplete( iClientReqStatus, aError ); + } + } + +/* +------------------------------------------------------------------------------- + + Class: TEventTS + + Method: SetEvent + + Description: Set event pending. + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +void TEventTS::SetEvent( TEventType aEventType ) + { + SetEventType( aEventType ); + if( iClientReqStatus ) + { + Complete( KErrNone ); + if( EventType() == EState ) + { + SetType( ESetEvent ) ; + } + } + else + { + SetType( ESetEvent ) ; + } + } + +/* +------------------------------------------------------------------------------- + + Class: TEventTS + + Method: WaitEvent + + Description: Wait event. + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +void TEventTS::WaitEvent( TRequestStatus& aStatus ) + { + SetRequestStatus( &aStatus ); + if( Type() == ESetEvent ) + { + Complete( KErrNone ); + if( EventType() == EIndication ) + { + SetType( EReqEvent ); + } + } + } + +CRemoteCallsProxy* CRemoteCallsProxy::NewL( CTestModuleIf& aTestModuleIf, CStifLogger* aLogger ) + { + CRemoteCallsProxy* self = new(ELeave)CRemoteCallsProxy( aTestModuleIf, aLogger ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +CRemoteCallsProxy::~CRemoteCallsProxy() + { + Cancel(); + + iLogger = NULL; + iSlaveAllocateFreeMonitor = NULL; + iRemoteTestCasesMonitor = NULL; + iRemoteEventsMonitor = NULL; + iRemoteSendReceiveMonitor = NULL; + iReceiveErrorHandler = NULL; + } + +CRemoteCallsProxy::CRemoteCallsProxy( CTestModuleIf& aTestModuleIf, CStifLogger* aLogger ) +: CActive( EPriorityNormal ), iLogger( aLogger ), iTestModuleIf( aTestModuleIf ) + { + CActiveScheduler::Add( this ); + } + +void CRemoteCallsProxy::ConstructL() + { + StartReceivingL(); + } + +void CRemoteCallsProxy::DoCancel() + { + iTestModuleIf.RemoteReceiveCancel(); + } + +void CRemoteCallsProxy::RunL() + { + RDebug::Print( _L("[STIF Master received response] %S"), &iReceivedRemoteMsg ); + + DispatchReceivedRemoteMsgL(); + StartReceivingL(); + } + +TInt CRemoteCallsProxy::RunError( TInt aError ) + { + if ( iReceiveErrorHandler != NULL ) + { + iReceiveErrorHandler->HandleRemoteReceiveError( aError, iReceiveErrorDescription ); + return KErrNone; + } + return aError; + } + +void CRemoteCallsProxy::AllocateL( TUint32 aMasterId, const TDesC& aType ) + { + CStifTFwIfProt* remoteRequest = CStifTFwIfProt::NewL(); + CleanupStack::PushL( remoteRequest ); + + remoteRequest->CreateL(); + // Reserve message + User::LeaveIfError( + remoteRequest->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgReserve ) ); + // Srcid. i.e. master id + User::LeaveIfError( + remoteRequest->AppendId( aMasterId ) ); + // DstId, broacast id + User::LeaveIfError( + remoteRequest->AppendId( 0 ) ); + // Slave type + User::LeaveIfError( + remoteRequest->Append( aType ) ); + + RDebug::Print( _L("[STIF Master sending request] %S"), &remoteRequest->Message() ); + + User::LeaveIfError( + iTestModuleIf.RemoteSend( remoteRequest->Message() ) ); + + CleanupStack::PopAndDestroy( remoteRequest ); + } + +void CRemoteCallsProxy::FreeL( TUint32 aMasterId, TUint16 aSlaveId ) + { + CStifTFwIfProt* remoteRequest = CStifTFwIfProt::NewL(); + CleanupStack::PushL( remoteRequest ); + + remoteRequest->CreateL(); + + // Release message + User::LeaveIfError( + remoteRequest->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgRelease ) ); + // Srcid. i.e. master id + User::LeaveIfError( + remoteRequest->AppendId( aMasterId ) ); + // DstId is device broadcast + User::LeaveIfError( + remoteRequest->AppendId( SETID( aSlaveId, 0 ) ) ); + + RDebug::Print( _L("[STIF Master sending request] %S"), &remoteRequest->Message() ); + + User::LeaveIfError( + iTestModuleIf.RemoteSend( remoteRequest->Message() ) ); + + CleanupStack::PopAndDestroy( remoteRequest ); + } + +void CRemoteCallsProxy::SendReceiveL( TUint32 aMasterId, TUint16 aSlaveId, const TDesC& aMessage ) + { + CStifTFwIfProt* remoteRequest = CStifTFwIfProt::NewL(); + CleanupStack::PushL( remoteRequest ); + + remoteRequest->CreateL(); + // Remote message + User::LeaveIfError( + remoteRequest->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgRemote ) ); + // Srcid. i.e. master id + User::LeaveIfError( remoteRequest->AppendId( aMasterId ) ); + // DstId, i.e.slave device id + User::LeaveIfError( remoteRequest->AppendId( SETID( aSlaveId, 0 ) ) ); + // Run command + User::LeaveIfError( remoteRequest->Append( + CStifTFwIfProt::CmdType, CStifTFwIfProt::ECmdSendReceive ) ); + // asynchronous sendreceive's parameters + if ( aMessage != KNullDesC ) + { + // Append parameters + User::LeaveIfError( remoteRequest->Append( aMessage ) ); + } + + RDebug::Print( _L("[STIF Master sending request] %S"), &remoteRequest->Message() ); + User::LeaveIfError( + iTestModuleIf.RemoteSend( remoteRequest->Message() ) ); + + CleanupStack::PopAndDestroy( remoteRequest ); + } + +void CRemoteCallsProxy::SendUnknownL( TUint32 aMasterId, TUint16 aSlaveId, + const TDesC& aCommand, const TDesC& aMessage ) + { + CStifTFwIfProt* remoteRequest = CStifTFwIfProt::NewL(); + CleanupStack::PushL( remoteRequest ); + + remoteRequest->CreateL(); + // Remote message + User::LeaveIfError( + remoteRequest->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgRemote ) ); + // Srcid. i.e. master id + User::LeaveIfError( remoteRequest->AppendId( aMasterId ) ); + // DstId, i.e.slave device id + User::LeaveIfError( remoteRequest->AppendId( SETID( aSlaveId, 0 ) ) ); + + // Append command name + User::LeaveIfError( remoteRequest->Append( aCommand ) ); + + if ( aMessage != KNullDesC ) + { + // Append parameters + User::LeaveIfError( remoteRequest->Append( aMessage ) ); + } + + RDebug::Print( _L("[STIF Master sending request] %S"), &remoteRequest->Message() ); + + User::LeaveIfError( + iTestModuleIf.RemoteSend( remoteRequest->Message() ) ); + + CleanupStack::PopAndDestroy( remoteRequest ); + } + + +void CRemoteCallsProxy::RunTestCaseL( TUint32 aMasterId, TUint16 aSlaveId, CStartInfo* aStartInfo ) + { + CStifTFwIfProt* remoteRequest = CStifTFwIfProt::NewL(); + CleanupStack::PushL( remoteRequest ); + remoteRequest->CreateL(); + + // Remote message + User::LeaveIfError( + remoteRequest->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgRemote ) ); + // Srcid. i.e. master id + User::LeaveIfError( remoteRequest->AppendId( aMasterId ) ); + // DstId is device broadcast + User::LeaveIfError( + remoteRequest->AppendId( SETID( aSlaveId, 0 ) ) ); + // Run command + User::LeaveIfError( + remoteRequest->Append( CStifTFwIfProt::CmdType, CStifTFwIfProt::ECmdRun ) ); + // Run parameters + User::LeaveIfError( + remoteRequest->Append( CStifTFwIfProt::RunParams, + CStifTFwIfProt::ERunModule, + aStartInfo->GetModuleName() ) ); + User::LeaveIfError( + remoteRequest->Append( CStifTFwIfProt::RunParams, + CStifTFwIfProt::ERunTestcasenum, + aStartInfo->GetTestCaseNumber() )); + if( aStartInfo->GetIniFile().Length() > 0 ) + { + // Initialization file + __TRACE( KMessage, (_L("ini: %S"), &aStartInfo->GetIniFile() )); + User::LeaveIfError( + remoteRequest->Append( CStifTFwIfProt::RunParams, + CStifTFwIfProt::ERunInifile, + aStartInfo->GetIniFile() ) ); + } + if( aStartInfo->GetConfig().Length() > 0 ) + { + // Initialization file + __TRACE( KMessage, (_L("config: %S"), &aStartInfo->GetConfig() )); + User::LeaveIfError( + remoteRequest->Append( CStifTFwIfProt::RunParams, + CStifTFwIfProt::ERunTestcasefile, + aStartInfo->GetConfig() )); + } + //Title (must be given between quotation marks in case of any spaces inside + if( aStartInfo->GetTitle().Length() > 0 ) + { + __TRACE(KMessage, (_L("title: %S"), &aStartInfo->GetTitle() ) ); + TName title; + title.Format(_L("\"title=%S\""), &aStartInfo->GetTitle() ); + User::LeaveIfError( remoteRequest->Append( title ) ); + } + + RDebug::Print( _L("[STIF Master sending request] %S"), &remoteRequest->Message() ); + + User::LeaveIfError( + iTestModuleIf.RemoteSend( remoteRequest->Message() ) ); + + CleanupStack::PopAndDestroy( remoteRequest ); + } + +void CRemoteCallsProxy::PauseTestCaseL( TUint32 aMasterId, TUint16 aSlaveId, TUint16 aTestId ) + { + CStifTFwIfProt* remoteRequest = CStifTFwIfProt::NewL(); + CleanupStack::PushL( remoteRequest ); + remoteRequest->CreateL(); + // Remote message + User::LeaveIfError( + remoteRequest->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgRemote ) ); + // Srcid. i.e. master id + User::LeaveIfError( + remoteRequest->AppendId( aMasterId ) ); + // DstId, i.e.slave id + User::LeaveIfError( + remoteRequest->AppendId( SETID( aSlaveId, aTestId ) ) ); + + // Pause command + User::LeaveIfError( + remoteRequest->Append( CStifTFwIfProt::CmdType, CStifTFwIfProt::ECmdPause ) ); + + RDebug::Print( _L("[STIF Master sending request] %S"), &remoteRequest->Message() ); + + User::LeaveIfError( + iTestModuleIf.RemoteSend( remoteRequest->Message() ) ); + + CleanupStack::PopAndDestroy( remoteRequest ); + } + +void CRemoteCallsProxy::ResumeTestCaseL( TUint32 aMasterId, TUint16 aSlaveId, TUint16 aTestId ) + { + CStifTFwIfProt* remoteRequest = CStifTFwIfProt::NewL(); + CleanupStack::PushL( remoteRequest ); + remoteRequest->CreateL(); + // Remote message + User::LeaveIfError( + remoteRequest->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgRemote ) ); + // Srcid. i.e. master id + User::LeaveIfError( + remoteRequest->AppendId( aMasterId )); + // DstId, i.e.slave id + User::LeaveIfError( + remoteRequest->AppendId( SETID( aSlaveId, aTestId ) ) ); + + // Resume command + User::LeaveIfError( + remoteRequest->Append( CStifTFwIfProt::CmdType, CStifTFwIfProt::ECmdResume )); + + RDebug::Print( _L("[STIF Master sending request] %S"), &remoteRequest->Message() ); + + User::LeaveIfError( + iTestModuleIf.RemoteSend( remoteRequest->Message() ) ); + + CleanupStack::PopAndDestroy( remoteRequest ); + } + +void CRemoteCallsProxy::CancelTestCaseL( TUint32 aMasterId, TUint16 aSlaveId, TUint16 aTestId ) + { + CStifTFwIfProt* remoteRequest = CStifTFwIfProt::NewL(); + CleanupStack::PushL( remoteRequest ); + remoteRequest->CreateL(); + // Remote message + User::LeaveIfError( + remoteRequest->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgRemote ) ); + // Srcid. i.e. master id + User::LeaveIfError( + remoteRequest->AppendId( aMasterId )); + // DstId, i.e.slave id + User::LeaveIfError( + remoteRequest->AppendId( SETID( aSlaveId, aTestId ) ) ); + + // Cancel command + User::LeaveIfError( + remoteRequest->Append( CStifTFwIfProt::CmdType, CStifTFwIfProt::ECmdCancel )); + + RDebug::Print( _L("[STIF Master sending request] %S"), &remoteRequest->Message() ); + + User::LeaveIfError( + iTestModuleIf.RemoteSend( remoteRequest->Message() ) ); + + CleanupStack::PopAndDestroy( remoteRequest ); + } + +void CRemoteCallsProxy::RequestEventL( TUint32 aMasterId, TUint16 aSlaveId, const TDesC& aEventName ) + { + CStifTFwIfProt* remoteRequest = CStifTFwIfProt::NewL(); + CleanupStack::PushL( remoteRequest ); + + remoteRequest->CreateL(); + // Remote message + User::LeaveIfError( + remoteRequest->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgRemote )); + // Srcid. i.e. master id + User::LeaveIfError( remoteRequest->AppendId( aMasterId ) ); + // DstId, i.e.slave device id + User::LeaveIfError( remoteRequest->AppendId( SETID( aSlaveId, 0 ) ) ); + + // Request event + User::LeaveIfError( + remoteRequest->Append( CStifTFwIfProt::CmdType, CStifTFwIfProt::ECmdRequest )); + + // Event name + User::LeaveIfError( remoteRequest->Append( aEventName ) ); + + RDebug::Print( _L("[STIF Master sending request] %S"), &remoteRequest->Message() ); + + User::LeaveIfError( + iTestModuleIf.RemoteSend( remoteRequest->Message() ) ); + + CleanupStack::PopAndDestroy( remoteRequest ); + } + +void CRemoteCallsProxy::SetEventL( TUint32 aMasterId, TUint16 aSlaveId, const TDesC& aEventName, + TEventIf::TEventType aEventType ) + { + CStifTFwIfProt* remoteRequest = CStifTFwIfProt::NewL(); + CleanupStack::PushL( remoteRequest ); + + remoteRequest->CreateL(); + // Remote message + User::LeaveIfError( + remoteRequest->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgRemote )); + // Srcid. i.e. master id + User::LeaveIfError( remoteRequest->AppendId( aMasterId ) ); + // DstId, i.e.slave device id + User::LeaveIfError( remoteRequest->AppendId( SETID( aSlaveId, 0 ) ) ); + + // Set event + User::LeaveIfError( + remoteRequest->Append( CStifTFwIfProt::CmdType, CStifTFwIfProt::ECmdSetEvent ) ); + + // Event name + User::LeaveIfError( remoteRequest->Append( aEventName ) ); + + if ( aEventType == TEventIf::EState ) + { + // State event + User::LeaveIfError( remoteRequest->Append( remoteRequest->EventType( aEventType ) ) ); + } + + RDebug::Print( _L("[STIF Master sending request] %S"), &remoteRequest->Message() ); + + User::LeaveIfError( + iTestModuleIf.RemoteSend( remoteRequest->Message() ) ); + + CleanupStack::PopAndDestroy( remoteRequest ); + } + +void CRemoteCallsProxy::UnsetEventL( TUint32 aMasterId, TUint16 aSlaveId, const TDesC& aEventName ) + { + CStifTFwIfProt* remoteRequest = CStifTFwIfProt::NewL(); + CleanupStack::PushL( remoteRequest ); + + remoteRequest->CreateL(); + // Remote message + User::LeaveIfError( + remoteRequest->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgRemote )); + // Srcid. i.e. master id + User::LeaveIfError( remoteRequest->AppendId( aMasterId ) ); + // DstId, i.e.slave device id + User::LeaveIfError( remoteRequest->AppendId( SETID( aSlaveId, 0 ) ) ); + + // Set event + User::LeaveIfError( + remoteRequest->Append( CStifTFwIfProt::CmdType, CStifTFwIfProt::ECmdUnsetEvent ) ); + + // Event name + User::LeaveIfError( remoteRequest->Append( aEventName ) ); + + RDebug::Print( _L("[STIF Master sending request] %S"), &remoteRequest->Message() ); + + User::LeaveIfError( + iTestModuleIf.RemoteSend( remoteRequest->Message() ) ); + + CleanupStack::PopAndDestroy( remoteRequest ); + } + +void CRemoteCallsProxy::ReleaseEventL( TUint32 aMasterId, TUint16 aSlaveId, const TDesC& aEventName ) + { + CStifTFwIfProt* remoteRequest = CStifTFwIfProt::NewL(); + CleanupStack::PushL( remoteRequest ); + + remoteRequest->CreateL(); + // Remote message + User::LeaveIfError( + remoteRequest->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgRemote )); + // Srcid. i.e. master id + User::LeaveIfError( remoteRequest->AppendId( aMasterId ) ); + // DstId, i.e.slave device id + User::LeaveIfError( remoteRequest->AppendId( SETID( aSlaveId, 0 ) ) ); + + // Release event + User::LeaveIfError( + remoteRequest->Append( CStifTFwIfProt::CmdType, CStifTFwIfProt::ECmdRelease )); + + // Event name + User::LeaveIfError( remoteRequest->Append( aEventName ) ); + + RDebug::Print( _L("[STIF Master sending request] %S"), &remoteRequest->Message() ); + + User::LeaveIfError( + iTestModuleIf.RemoteSend( remoteRequest->Message() ) ); + + CleanupStack::PopAndDestroy( remoteRequest ); + } + +void CRemoteCallsProxy::SetSlaveAllocateFreeMonitor( MSlaveAllocateFreeMonitor* aSlaveAllocateFreeMonitor ) + { + iSlaveAllocateFreeMonitor = aSlaveAllocateFreeMonitor; + } + +void CRemoteCallsProxy::SetRemoteTestCasesMonitor( MRemoteTestCasesMonitor* aRemoteTestCasesMonitor ) + { + iRemoteTestCasesMonitor = aRemoteTestCasesMonitor; + } + +void CRemoteCallsProxy::SetRemoteEventsMonitor( MRemoteEventsMonitor* aRemoteEventsMonitor ) + { + iRemoteEventsMonitor = aRemoteEventsMonitor; + } + +void CRemoteCallsProxy::SetRemoteSendReceiveMonitor( MRemoteSendReceiveMonitor* aRemoteSendReceiveMonitor ) + { + iRemoteSendReceiveMonitor = aRemoteSendReceiveMonitor; + } + +void CRemoteCallsProxy::SetReceiveErrorHandler( MReceiveErrorHandler* aReceiveErrorHandler ) + { + iReceiveErrorHandler = aReceiveErrorHandler; + } + +void CRemoteCallsProxy::StartReceivingL() + { + iTestModuleIf.RemoteReceive( iReceivedRemoteMsg, iStatus ); + SetActive(); + } + +void CRemoteCallsProxy::DispatchReceivedRemoteMsgL() + { + _LIT( KErrMsg, "Error during slave respons handling"); + + iReceiveErrorDescription = KErrMsg; + + CStifTFwIfProt* msg = CStifTFwIfProt::NewL(); + CleanupStack::PushL( msg ); + TRAPD( err, msg->SetL( iReceivedRemoteMsg ); ); + if( err != KErrNone ) + { + __TRACE( KError, (_L("Response parsing failed"))); + User::Leave( err ); + } + + // Check protocol identifiers + if( ( msg->SrcDevId() == 0 ) || + ( msg->DstDevId() == 0 ) || + ( msg->DstTestId() == 0 ) ) + { + __TRACE( KError, (_L("Illegal deviceid received"))); + User::Leave( KErrGeneral ); + } + + // This is master, cannot receive anything else but responses + if( msg->iMsgType != CStifTFwIfProt::EMsgResponse ) + { + __TRACE( KError, (_L("Illegal message received %d"), + msg->iMsgType )); + User::Leave( KErrGeneral ); + } + + switch( msg->iRespType ) + { + case CStifTFwIfProt::EMsgReserve: + { + ReceiveResponseReserveL( msg ); + } + break; + case CStifTFwIfProt::EMsgRelease: + { + ReceiveResponseReleaseL( msg ); + } + break; + case CStifTFwIfProt::EMsgRemote: + { + __TRACE( KMessage, (_L("ReceiveResponse Remote"))); + switch( msg->iCmdType ) + { + case CStifTFwIfProt::ECmdRun: + ReceiveResponseRunL( msg ); + break; + case CStifTFwIfProt::ECmdPause: + case CStifTFwIfProt::ECmdResume: + case CStifTFwIfProt::ECmdCancel: + ReceiveResponseTestCtlL( msg ); + break; + case CStifTFwIfProt::ECmdRequest: + case CStifTFwIfProt::ECmdRelease: + case CStifTFwIfProt::ECmdSetEvent: + case CStifTFwIfProt::ECmdUnsetEvent: + ReceiveResponseEventCtlL( msg ); + break; + case CStifTFwIfProt::ECmdSendReceive: + ReceiveResponseSendReceiveL( msg ); + break; + default: + ReceiveResponseSendUnknownL( msg ); + break; + } + } + break; + default: + User::Leave( KErrGeneral ); + } + + CleanupStack::PopAndDestroy( msg ); + iReceiveErrorDescription = KNullDesC; + } + +void CRemoteCallsProxy::ReceiveResponseReserveL( CStifTFwIfProt* aMsg ) + { + _LIT( KErrMsg, "Error during slave allocate respons handling"); + __TRACE( KMessage, (_L("ReceiveResponse Reserve"))); + + // Check protocol Src test id + if( aMsg->SrcTestId() != 0 ) + { + __TRACE( KError, (_L("Illegal deviceid received"))); + User::Leave( KErrGeneral ); + } + + if( aMsg->iResult != KErrNone ) + { + __TRACE( KError, (_L("Response with error %d"), aMsg->iResult )); + User::Leave( aMsg->iResult ); + } + + iReceiveErrorDescription = KErrMsg; + iSlaveAllocateFreeMonitor->NotifySlaveAllocatedL( aMsg->SrcDevId() ); + iReceiveErrorDescription = KNullDesC; + __TRACE( KMessage, (_L("Slave allocated succesfully, continue execution"))); + } + +void CRemoteCallsProxy::ReceiveResponseReleaseL( CStifTFwIfProt* aMsg ) + { + _LIT( KErrMsg, "Error during slave release respons handling"); + __TRACE( KMessage, (_L("ReceiveResponse Release"))); + + // Check protocol Src test id + if( aMsg->SrcTestId() != 0 ) + { + __TRACE( KError, (_L("Illegal deviceid received"))); + User::Leave( KErrGeneral ); + } + + if( aMsg->iResult != KErrNone ) + { + __TRACE( KError, (_L("Response with error %d"), aMsg->iResult )); + User::Leave( aMsg->iResult ); + } + + iReceiveErrorDescription = KErrMsg; + iSlaveAllocateFreeMonitor->NotifySlaveFreedL( aMsg->SrcDevId() ); + iReceiveErrorDescription = KNullDesC; + __TRACE( KMessage, (_L("Slave freed succesfully, continue execution"))); + } + +void CRemoteCallsProxy::ReceiveResponseRunL( CStifTFwIfProt* aMsg ) + { + _LIT( KErrMsgRun, "Error during remote sub test casse run respons handling"); + + + TPtrC tmp = CStifTFwIfProt::RunStatus( aMsg->iRunStatus ); + __TRACE( KMessage, (_L("ReceiveResponse Remote Run %S"), &tmp )); + + + if ( iRemoteTestCasesMonitor == NULL ) + { + return; + } + + switch( aMsg->iRunStatus ) + { + case CStifTFwIfProt::ERunStarted: + { + iReceiveErrorDescription = KErrMsgRun; + iRemoteTestCasesMonitor->NotifyTestCaseStartedL( aMsg->SrcDevId(), aMsg->SrcTestId() ); + iReceiveErrorDescription = KNullDesC; + } + break; + case CStifTFwIfProt::ERunError: + case CStifTFwIfProt::ERunReady: + { + TFullTestResult testCaseResult; + switch( aMsg->iResultCategory ) + { + case CStifTFwIfProt::EResultNormal: + testCaseResult.iCaseExecutionResultType = + TFullTestResult::ECaseExecuted; + testCaseResult.iTestResult.iResult = aMsg->iResult; + testCaseResult.iCaseExecutionResultCode = 0; + break; + case CStifTFwIfProt::EResultPanic: + testCaseResult.iCaseExecutionResultType = + TFullTestResult::ECasePanic; + testCaseResult.iTestResult.iResult = KErrGeneral; + testCaseResult.iCaseExecutionResultCode = aMsg->iResult; + break; + case CStifTFwIfProt::EResultException: + testCaseResult.iCaseExecutionResultType = + TFullTestResult::ECaseException; + testCaseResult.iTestResult.iResult = KErrGeneral; + testCaseResult.iCaseExecutionResultCode = aMsg->iResult; + break; + case CStifTFwIfProt::EResultTimeout: + testCaseResult.iCaseExecutionResultType = + TFullTestResult::ECaseTimeout; + testCaseResult.iTestResult.iResult = KErrGeneral; + testCaseResult.iCaseExecutionResultCode = aMsg->iResult; + break; + case CStifTFwIfProt::EResultLeave: + testCaseResult.iCaseExecutionResultType = + TFullTestResult::ECaseLeave; + testCaseResult.iTestResult.iResult = KErrGeneral; + testCaseResult.iCaseExecutionResultCode = aMsg->iResult; + break; + default: + User::Leave( KErrGeneral ); + } + + iReceiveErrorDescription = KErrMsgRun; + if ( aMsg->iRunStatus == CStifTFwIfProt::ERunError ) + { + iRemoteTestCasesMonitor->NotifyTestCaseRunErrorL( aMsg->SrcDevId(), testCaseResult ); + } + else + { + iRemoteTestCasesMonitor->NotifyTestCaseFinishedL( aMsg->SrcDevId(), aMsg->SrcTestId(), testCaseResult ); + } + iReceiveErrorDescription = KNullDesC; + } + break; + default: + // Should never come here + User::Leave( KErrGeneral ); + } + } + +void CRemoteCallsProxy::ReceiveResponseTestCtlL( CStifTFwIfProt* aMsg ) + { + _LIT( KErrMsgPause, "Error during remote sub test casse pause respons handling"); + _LIT( KErrMsgResume, "Error during remote sub test casse resume respons handling"); + _LIT( KErrMsgCancel, "Error during remote sub test casse cancel respons handling"); + + if( aMsg->iResult != KErrNone ) + { + __TRACE( KError, (_L("Response with error %d"), aMsg->iResult )); + User::Leave( aMsg->iResult ); + } + + switch( aMsg->iCmdType ) + { + case CStifTFwIfProt::ECmdPause: + { + __TRACE( KMessage, (_L("ReceiveResponse Remote Pause"))); + iReceiveErrorDescription = KErrMsgPause; + iRemoteTestCasesMonitor->NotifyTestCasePausedL( aMsg->SrcDevId(), aMsg->SrcTestId() ); + iReceiveErrorDescription = KNullDesC; + } + break; + case CStifTFwIfProt::ECmdResume: + { + __TRACE( KMessage, (_L("ReceiveResponse Remote Resume"))); + iReceiveErrorDescription = KErrMsgResume; + iRemoteTestCasesMonitor->NotifyTestCaseResumedL( aMsg->SrcDevId(), aMsg->SrcTestId() ); + iReceiveErrorDescription = KNullDesC; + } + break; + case CStifTFwIfProt::ECmdCancel: + __TRACE( KMessage, (_L("ReceiveResponse Remote Cancel"))); + iReceiveErrorDescription = KErrMsgCancel; + iRemoteTestCasesMonitor->NotifyTestCaseCancelledL( aMsg->SrcDevId(), aMsg->SrcTestId() ); + iReceiveErrorDescription = KNullDesC; + break; + default: + // Should never come here + User::Leave( KErrGeneral ); + } + } + +void CRemoteCallsProxy::ReceiveResponseEventCtlL( CStifTFwIfProt* aMsg ) + { + _LIT( KErrMsgRequest, "Error during remote event request respons handling"); + _LIT( KErrMsgStateChanged, "Error during remote event state change respons handling"); + _LIT( KErrMsgSet, "Error during remote event set respons handling"); + _LIT( KErrMsgUnset, "Error during remote event unset respons handling"); + _LIT( KErrMsgRelease, "Error during remote event release respons handling"); + + if ( iRemoteEventsMonitor == NULL ) + { + return; + } + + switch( aMsg->iCmdType ) + { + case CStifTFwIfProt::ECmdRequest: + { + if ( ( aMsg->iEventStatus == CStifTFwIfProt::EEventSet ) || + ( aMsg->iEventStatus == CStifTFwIfProt::EEventUnset ) ) + { + iReceiveErrorDescription = KErrMsgStateChanged; + iRemoteEventsMonitor->NotifyEventStateChangedL( + aMsg->SrcDevId(), + aMsg->iEventName, + aMsg->iEventStatus, + aMsg->iEventType, + aMsg->iResult + ); + iReceiveErrorDescription = KNullDesC; + } + else + { + iReceiveErrorDescription = KErrMsgRequest; + iRemoteEventsMonitor->NotifyEventRequestedL( + aMsg->SrcDevId(), + aMsg->iEventName, + aMsg->iEventStatus, + aMsg->iEventType, + aMsg->iResult + ); + iReceiveErrorDescription = KNullDesC; + } + } + break; + case CStifTFwIfProt::ECmdRelease: + { + iReceiveErrorDescription = KErrMsgRelease; + iRemoteEventsMonitor->NotifyEventReleasedL( + aMsg->SrcDevId(), + aMsg->iEventName, + aMsg->iResult + ); + iReceiveErrorDescription = KNullDesC; + } + break; + case CStifTFwIfProt::ECmdSetEvent: + { + iReceiveErrorDescription = KErrMsgSet; + iRemoteEventsMonitor->NotifyEventSetCompletedL( + aMsg->SrcDevId(), + aMsg->iEventName, + aMsg->iResult + ); + iReceiveErrorDescription = KNullDesC; + } + break; + case CStifTFwIfProt::ECmdUnsetEvent: + { + iReceiveErrorDescription = KErrMsgUnset; + iRemoteEventsMonitor->NotifyEventUnsetCompletedL( + aMsg->SrcDevId(), + aMsg->iEventName, + aMsg->iResult + ); + iReceiveErrorDescription = KNullDesC; + } + break; + default: + // Should never come here + User::Leave( KErrGeneral ); + } + + } + +void CRemoteCallsProxy::ReceiveResponseSendReceiveL( CStifTFwIfProt* aMsg ) + { + _LIT( KErrMsgStarted, "Error during remote sendreceive started respons handling"); + _LIT( KErrMsgResult, "Error during remote sendreceive result respons handling"); + + if ( iRemoteSendReceiveMonitor == NULL ) + { + return; + } + + switch( aMsg->iRunStatus ) + { + case CStifTFwIfProt::ERunStarted: + { + iReceiveErrorDescription = KErrMsgStarted; + iRemoteSendReceiveMonitor->NotifySendReceiveStartedL( aMsg->SrcDevId() ); + iReceiveErrorDescription = KNullDesC; + break; + } + case CStifTFwIfProt::ERunError: + case CStifTFwIfProt::ERunReady: + { + iReceiveErrorDescription = KErrMsgResult; + iRemoteSendReceiveMonitor->NotifySendReceiveResultL( + aMsg->SrcDevId(), + aMsg->iRunStatus, + aMsg->iResult ); + iReceiveErrorDescription = KNullDesC; + break; + } + default: + { + // Should never come here + User::Leave( KErrGeneral ); + } + } + } + +void CRemoteCallsProxy::ReceiveResponseSendUnknownL( CStifTFwIfProt* aMsg ) + { + _LIT( KErrMsg, "Error during remote send unknown respons handling"); + + if ( iRemoteSendReceiveMonitor == NULL ) + { + return; + } + + iReceiveErrorDescription = KErrMsg; + iRemoteSendReceiveMonitor->NotifySendUnknownL( aMsg->SrcDevId(), aMsg->iResult ); + iReceiveErrorDescription = KNullDesC; + } + +CSlave* CSlave::NewL() + { + CSlave* self = new(ELeave)CSlave; + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +CSlave::~CSlave() + { + iSubTestCases.Reset(); // CSlave does not own sub test cases objects + iSubTestCases.Close(); + + iEvents.ResetAndDestroy(); + iEvents.Close(); + + delete iNestedASLoop; + iNestedASLoop = NULL; + + delete iName; + iName = NULL; + } + +CSlave::CSlave() + { + } + +void CSlave::ConstructL() + { + iName = HBufC::NewL( 0 ); + iNestedASLoop = new(ELeave)CActiveSchedulerWait; + } + +const TDesC& CSlave::GetName() const + { + return *iName; + } + +void CSlave::SetNameL( const TDesC& aName ) + { + HBufC* tmp = aName.AllocL(); + delete iName; + iName = tmp; + } + +TUint32 CSlave::GetMasterId() const + { + return iMasterId; + } + +void CSlave::SetMasterId( TUint32 aMasterId ) + { + iMasterId = aMasterId; + } + +TUint16 CSlave::GetSlaveId() const + { + return iSlaveId; + } + +TBool CSlave::HasRunningTestCases() const + { + if ( iSubTestCases.Count() > 0 ) + { + return ETrue; + } + return EFalse; + } + +void CSlave::RegisterSubTestCaseL( CRemoteSubTestCaseRunner* aSubTestCase ) + { + iSubTestCases.AppendL( aSubTestCase ); + } + +void CSlave::UnregisterSubTestCaseL( CRemoteSubTestCaseRunner* aSubTestCase ) + { + TInt idx = iSubTestCases.Find( aSubTestCase ); + if ( idx >= 0 ) + { + iSubTestCases.Remove( idx ); + } + else + { + User::Leave( KErrNotFound ); + } + if ( ( !HasRunningTestCases() ) && iNestedASLoop->IsStarted() ) + { + iNestedASLoop->AsyncStop(); + } + } + +RPointerArray& CSlave::GetSubTestCases() + { + return iSubTestCases; + } + +void CSlave::WaitForSubTestCasesL() + { + if ( iNestedASLoop->IsStarted() ) + { + User::Leave( KErrInUse ); + } + + if ( !HasRunningTestCases() ) + { + return; + } + + iNestedASLoop->Start(); + } + +void CSlave::CancelWaitForSubTestCases() + { + iNestedASLoop->AsyncStop(); + } + +void CSlave::AddEventL( TEventTS* aEvent ) + { + iEvents.AppendL( aEvent ); + } + +void CSlave::RemoveEventL( TEventTS* aEvent ) + { + TInt idx = iEvents.Find( aEvent ); + if ( idx >= 0 ) + { + iEvents.Remove( idx ); + } + else + { + User::Leave( KErrNotFound ); + } + } + +TEventTS* CSlave::GetEvent( const TDesC& aName ) + { + for ( TInt i = 0; i < iEvents.Count(); i++ ) + { + if ( iEvents[ i ]->Name() == aName ) + { + return iEvents[ i ]; + } + } + + return NULL; + } + +RPointerArray& CSlave::GetEvents() + { + return iEvents; + } + +#ifdef LOGGER +#undef LOGGER +#endif + +#define LOGGER iTestRunner->GetLogger() + +void CSlave::SetSlaveId( TUint16 aSlaveId ) + { + iSlaveId = aSlaveId; + } + +CSlavesManager* CSlavesManager::NewL( CTestRunner* aTestRunner, CTestModuleIf& aTestModuleIf ) + { + CSlavesManager* self = new(ELeave)CSlavesManager( aTestRunner, aTestModuleIf ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +CSlavesManager::~CSlavesManager() + { + Cancel(); + iOperationTimeoutTimer.Close(); + + iRemoteCallsProxy->Cancel(); + + delete iSlaveForAllocate; + iSlaveForAllocate = NULL; + + iSlaves.ResetAndDestroy(); + iSlaves.Close(); + + delete iNestedASLoop; + iNestedASLoop = NULL; + + delete iRemoteCallsProxy; + iRemoteCallsProxy = NULL; + } + +CSlavesManager::CSlavesManager( CTestRunner* aTestRunner, CTestModuleIf& aTestModuleIf ) +:CActive( EPriorityNormal ), iTestRunner( aTestRunner ), + iTestModuleIf( aTestModuleIf ), iOperationTimeout( 30000000 ) + { + CActiveScheduler::Add( this ); + } + +void CSlavesManager::ConstructL() + { + iOperationTimeoutTimer.CreateLocal(); + iRemoteCallsProxy = CRemoteCallsProxy::NewL( iTestModuleIf, LOGGER ); + iNestedASLoop = new(ELeave)CActiveSchedulerWait; + + iRemoteCallsProxy->SetReceiveErrorHandler( this ); + iRemoteCallsProxy->SetSlaveAllocateFreeMonitor( this ); + iRemoteCallsProxy->SetRemoteTestCasesMonitor( this ); + iRemoteCallsProxy->SetRemoteEventsMonitor( this ); + iRemoteCallsProxy->SetRemoteSendReceiveMonitor( this ); + } + +void CSlavesManager::SlaveAllocateL( const TDesC& aName, const TDesC& aType ) + { + if ( iOperation != ESMOIdle ) + { + User::Leave( KErrInUse ); + } + if ( GetSlave( aName ) != NULL ) + { + User::Leave( KErrAlreadyExists ); + } + + delete iSlaveForAllocate; + iSlaveForAllocate = NULL; + + CSlave* slaveForAllocate = CSlave::NewL(); + CleanupStack::PushL( slaveForAllocate ); + slaveForAllocate->SetNameL( aName ); + slaveForAllocate->SetMasterId( KRemoteProtocolMasterId ); + + iRemoteCallsProxy->AllocateL( KRemoteProtocolMasterId, aType ); + CleanupStack::Pop( slaveForAllocate ); + iSlaveForAllocate = slaveForAllocate; + iOperation = ESMOSlaveAllocate; + iLastOperationResult = KErrNone; + + iOperationTimeoutTimer.After( iStatus, iOperationTimeout ); + SetActive(); + iNestedASLoop->Start(); + + User::LeaveIfError( iLastOperationResult ); + } + +void CSlavesManager::SlaveFreeL( const TDesC& aName ) + { + if ( iOperation != ESMOIdle ) + { + User::Leave( KErrInUse ); + } + CSlave* slave = GetSlave( aName ); + + if ( slave == NULL ) + { + User::Leave( KErrNotFound ); + } + + if ( slave->HasRunningTestCases() ) + { + + } + + iSlaves.Remove( iSlaves.Find( slave ) ); + + TUint32 masterId = slave->GetMasterId(); + TUint16 slaveId = slave->GetSlaveId(); + + delete slave; + + iRemoteCallsProxy->FreeL( masterId, slaveId ); + iOperation = ESMOSlaveFree; + iLastOperationResult = KErrNone; + + iOperationTimeoutTimer.After( iStatus, iOperationTimeout ); + SetActive(); + iNestedASLoop->Start(); + + User::LeaveIfError( iLastOperationResult ); + } + +void CSlavesManager::SendReceiveL( CSlave* aSlave, const TDesC& aMessage ) + { + if ( iOperation != ESMOIdle ) + { + User::Leave( KErrInUse ); + } + + iRemoteCallsProxy->SendReceiveL( aSlave->GetMasterId(), + aSlave->GetSlaveId(), aMessage ); + iOperation = ESMOSendReceiveWaitForStarted; + + iOperationTimeoutTimer.After( iStatus, iOperationTimeout ); + SetActive(); + iNestedASLoop->Start(); + + User::LeaveIfError( iLastOperationResult ); + } + +void CSlavesManager::SendUnknownL( CSlave* aSlave, const TDesC& aCommand, const TDesC& aMessage ) + { + if ( iOperation != ESMOIdle ) + { + User::Leave( KErrInUse ); + } + + iRemoteCallsProxy->SendUnknownL( aSlave->GetMasterId(), + aSlave->GetSlaveId(), aCommand, aMessage ); + iOperation = ESMOSendUnknown; + + iOperationTimeoutTimer.After( iStatus, iOperationTimeout ); + SetActive(); + iNestedASLoop->Start(); + + User::LeaveIfError( iLastOperationResult ); + } + +CSlave* CSlavesManager::GetSlave( const TDesC& aName ) + { + for ( TInt i = 0; i < iSlaves.Count(); i++ ) + { + if ( iSlaves[ i ]->GetName() == aName ) + { + return iSlaves[ i ]; + } + } + return NULL; + } + +CSlave* CSlavesManager::GetSlave( TUint16 aSlaveId ) + { + for ( TInt i = 0; i < iSlaves.Count(); i++ ) + { + if ( iSlaves[ i ]->GetSlaveId() == aSlaveId ) + { + return iSlaves[ i ]; + } + } + return NULL; + } + +RPointerArray& CSlavesManager::GetSlaves() + { + return iSlaves; + } + +CRemoteCallsProxy* CSlavesManager::GetRemoteCallsProxy() + { + return iRemoteCallsProxy; + } + +void CSlavesManager::EventRequestL( CSlave* aSlave, TEventTS* aEvent ) + { + if ( iOperation != ESMOIdle ) + { + User::Leave( KErrInUse ); + } + + iEventForRequest = aEvent; + + iRemoteCallsProxy->RequestEventL( aSlave->GetMasterId(), + aSlave->GetSlaveId(), iEventForRequest->Name() ); + iOperation = ESMOEventRequest; + iLastOperationResult = KErrNone; + + iOperationTimeoutTimer.After( iStatus, iOperationTimeout ); + SetActive(); + iNestedASLoop->Start(); + + iEventForRequest = NULL; + + User::LeaveIfError( iLastOperationResult ); + } + +void CSlavesManager::EventReleaseL( CSlave* aSlave, const TDesC& aEventName ) + { + if ( iOperation != ESMOIdle ) + { + User::Leave( KErrInUse ); + } + + iRemoteCallsProxy->ReleaseEventL( aSlave->GetMasterId(), + aSlave->GetSlaveId(), aEventName ); + iOperation = ESMOEventRelease; + + iOperationTimeoutTimer.After( iStatus, iOperationTimeout ); + SetActive(); + iNestedASLoop->Start(); + + User::LeaveIfError( iLastOperationResult ); + } + +void CSlavesManager::EventSetL( CSlave* aSlave, const TDesC& aEventName, TEventIf::TEventType aEventType ) + { + if ( iOperation != ESMOIdle ) + { + User::Leave( KErrInUse ); + } + + iRemoteCallsProxy->SetEventL( aSlave->GetMasterId(), + aSlave->GetSlaveId(), aEventName, aEventType ); + iOperation = ESMOEventSet; + + iOperationTimeoutTimer.After( iStatus, iOperationTimeout ); + SetActive(); + iNestedASLoop->Start(); + + User::LeaveIfError( iLastOperationResult ); + } + +void CSlavesManager::EventUnsetL( CSlave* aSlave, const TDesC& aEventName ) + { + if ( iOperation != ESMOIdle ) + { + User::Leave( KErrInUse ); + } + + iRemoteCallsProxy->UnsetEventL( aSlave->GetMasterId(), + aSlave->GetSlaveId(), aEventName ); + iOperation = ESMOEventUnset; + + iOperationTimeoutTimer.After( iStatus, iOperationTimeout ); + SetActive(); + iNestedASLoop->Start(); + + User::LeaveIfError( iLastOperationResult ); + } + +void CSlavesManager::NotifySlaveAllocatedL( TUint16 aSlaveId ) + { + Cancel(); // Stop operation timeout monitor + + if( iOperation != ESMOSlaveAllocate ) + { + iLastOperationResult = KErrNotReady; + delete iSlaveForAllocate; + iSlaveForAllocate = NULL; + User::Leave( KErrNotReady ); + } + else + { + iSlaveForAllocate->SetSlaveId( aSlaveId ); + iSlaves.AppendL( iSlaveForAllocate ); + iSlaveForAllocate = NULL; + iLastOperationResult = KErrNone; + } + + iOperation = ESMOIdle; + iNestedASLoop->AsyncStop(); + } + +void CSlavesManager::NotifySlaveFreedL( TUint16 /*aSlaveId*/ ) + { + Cancel(); // Stop operation timeout monitor + + if( iOperation != ESMOSlaveFree ) + { + User::Leave( KErrNotReady ); + } + + iLastOperationResult = KErrNone; + + iOperation = ESMOIdle; + iNestedASLoop->AsyncStop(); + } + +void CSlavesManager::NotifyTestCaseStartedL( TUint16 aSlaveId, TUint16 aSlaveTestId ) + { + for ( TInt i = 0; i < iSlaves.Count(); i++ ) + { + if ( iSlaves[ i ]->GetSlaveId() == aSlaveId ) + { + RPointerArray& remoteTestCases = + iSlaves[ i ]->GetSubTestCases(); + for ( TInt k = 0; k < remoteTestCases.Count(); k++ ) + { + if ( remoteTestCases[ k ]->IsRunSubTestCaseRequestOngoing() ) + { + remoteTestCases[ k ]->NotifyTestCaseStartedL( aSlaveTestId ); + // There should be only one test case which waits for + // run test case request response + return; + } + } + } + } + + // There is no test case which waits for run request response + User::Leave( KErrNotFound ); + } + +void CSlavesManager::NotifyTestCaseRunErrorL( TUint16 aSlaveId, const TFullTestResult& aTestCaseResult ) + { + for ( TInt i = 0; i < iSlaves.Count(); i++ ) + { + if ( iSlaves[ i ]->GetSlaveId() == aSlaveId ) + { + RPointerArray& remoteTestCases = + iSlaves[ i ]->GetSubTestCases(); + for ( TInt k = 0; k < remoteTestCases.Count(); k++ ) + { + if ( remoteTestCases[ k ]->IsRunSubTestCaseRequestOngoing() ) + { + remoteTestCases[ k ]->NotifyTestCaseRunError( aTestCaseResult ); + // There should be only one test case which waits for + // run test case request response + return; + } + } + } + } + + // There is no test case which waits for run request response + User::Leave( KErrNotFound ); + } + +void CSlavesManager::NotifyTestCaseFinishedL( TUint16 aSlaveId, TUint16 aSlaveTestId, const TFullTestResult& aTestCaseResult ) + { + for ( TInt i = 0; i < iSlaves.Count(); i++ ) + { + if ( iSlaves[ i ]->GetSlaveId() == aSlaveId ) + { + RPointerArray& remoteTestCases = + iSlaves[ i ]->GetSubTestCases(); + for ( TInt k = 0; k < remoteTestCases.Count(); k++ ) + { + if ( remoteTestCases[ k ]->GetTestCaseId() == aSlaveTestId ) + { + remoteTestCases[ k ]->NotifyTestCaseFinishedL( aTestCaseResult ); + // There should be only one test case which waits for + // run test case request response + return; + } + } + } + } + // There is no test case which waits for run request response + User::Leave( KErrNotFound ); + } + +void CSlavesManager::NotifyTestCasePausedL( TUint16 aSlaveId, TUint16 aSlaveTestId ) + { + for ( TInt i = 0; i < iSlaves.Count(); i++ ) + { + if ( iSlaves[ i ]->GetSlaveId() == aSlaveId ) + { + RPointerArray& remoteTestCases = + iSlaves[ i ]->GetSubTestCases(); + for ( TInt k = 0; k < remoteTestCases.Count(); k++ ) + { + if ( remoteTestCases[ k ]->GetTestCaseId() == aSlaveTestId ) + { + remoteTestCases[ k ]->NotifyTestCasePausedL(); + // There should be only one test case which waits for + // run test case request response + return; + } + } + } + } + // There is no test case which waits for run request response + User::Leave( KErrNotFound ); + } + +void CSlavesManager::NotifyTestCaseResumedL( TUint16 aSlaveId, TUint16 aSlaveTestId ) + { + for ( TInt i = 0; i < iSlaves.Count(); i++ ) + { + if ( iSlaves[ i ]->GetSlaveId() == aSlaveId ) + { + RPointerArray& remoteTestCases = + iSlaves[ i ]->GetSubTestCases(); + for ( TInt k = 0; k < remoteTestCases.Count(); k++ ) + { + if ( remoteTestCases[ k ]->GetTestCaseId() == aSlaveTestId ) + { + remoteTestCases[ k ]->NotifyTestCaseResumedL(); + // There should be only one test case which waits for + // run test case request response + return; + } + } + } + } + // There is no test case which waits for run request response + User::Leave( KErrNotFound ); + } + +void CSlavesManager::NotifyTestCaseCancelledL( TUint16 aSlaveId, TUint16 aSlaveTestId ) + { + for ( TInt i = 0; i < iSlaves.Count(); i++ ) + { + if ( iSlaves[ i ]->GetSlaveId() == aSlaveId ) + { + RPointerArray& remoteTestCases = + iSlaves[ i ]->GetSubTestCases(); + for ( TInt k = 0; k < remoteTestCases.Count(); k++ ) + { + if ( remoteTestCases[ k ]->GetTestCaseId() == aSlaveTestId ) + { + remoteTestCases[ k ]->NotifyTestCaseCancelledL(); + // There should be only one test case which waits for + // run test case request response + return; + } + } + } + } + // There is no test case which waits for run request response + User::Leave( KErrNotFound ); + } + +void CSlavesManager::NotifyEventRequestedL( TUint16 /*aSlaveId*/, + const TDesC& aEventName, + CStifTFwIfProt::TEventStatus aEventStatus, + TEventIf::TEventType /*aEventType*/, + TInt aResult ) + { + if ( iOperation != ESMOEventRequest ) + { + User::Leave( KErrNotReady ); + } + + Cancel(); // Stop operation timeout monitor + + iLastOperationResult = KErrNone; + switch( aEventStatus ) + { + case CStifTFwIfProt::EEventActive: + __TRACE( KMessage, (_L("Event %S active"), &aEventName )); + break; + case CStifTFwIfProt::EEventError: + __TRACE( KMessage, (_L("Event %S error %d"), &aEventName, aResult )); + iLastOperationResult = aResult; + break; + default: + User::Leave( KErrGeneral ); + } + + iOperation = ESMOIdle; + iNestedASLoop->AsyncStop(); + } + +void CSlavesManager::NotifyEventStateChangedL( TUint16 aSlaveId, + const TDesC& aEventName, + CStifTFwIfProt::TEventStatus aEventStatus, + TEventIf::TEventType aEventType, + TInt aResult ) + { + switch( aEventStatus ) + { + case CStifTFwIfProt::EEventSet: + { + __TRACE( KMessage, (_L("Event %S set"), &aEventName )); + // Set event + CSlave* slave = GetSlave( aSlaveId ); + if ( slave != NULL ) + { + TEventTS* event = slave->GetEvent( aEventName ); + if ( event != NULL ) + { + event->SetEvent( aEventType ); + } + else + { + User::Leave( KErrNotFound ); + } + } + else + { + User::Leave( KErrNotFound ); + } + } + break; + case CStifTFwIfProt::EEventUnset: + { + __TRACE( KMessage, (_L("Event %S set"), &aEventName )); + // Set event + CSlave* slave = GetSlave( aSlaveId ); + if ( slave != NULL ) + { + TEventTS* event = slave->GetEvent( aEventName ); + if ( event != NULL ) + { + event->SetType( TEventIf::EUnsetEvent ); + } + else + { + User::Leave( KErrNotFound ); + } + } + else + { + User::Leave( KErrNotFound ); + } + } + break; + case CStifTFwIfProt::EEventError: + { + __TRACE( KMessage, (_L("Event %S error %d"), &aEventName, aResult )); + User::Leave( aResult ); + } + break; + default: + { + User::Leave( KErrGeneral ); + } + } + } + +void CSlavesManager::NotifyEventReleasedL( TUint16 /*aSlaveId*/, + const TDesC& /*aEventName*/, TInt aResult ) + { + if ( iOperation != ESMOEventRelease ) + { + User::Leave( KErrNotReady ); + } + + Cancel(); // Stop operation timeout monitor + + iOperation = ESMOIdle; + iLastOperationResult = aResult; + iNestedASLoop->AsyncStop(); + } + +void CSlavesManager::NotifyEventSetCompletedL( TUint16 /*aSlaveId*/, + const TDesC& /*aEventName*/, TInt aResult ) + { + if ( iOperation != ESMOEventSet ) + { + User::Leave( KErrNotReady ); + } + + Cancel(); // Stop operation timeout monitor + + iOperation = ESMOIdle; + iLastOperationResult = aResult; + iNestedASLoop->AsyncStop(); + } + +void CSlavesManager::NotifyEventUnsetCompletedL( TUint16 /*aSlaveId*/, + const TDesC& /*aEventName*/, TInt aResult ) + { + if ( iOperation != ESMOEventUnset ) + { + User::Leave( KErrNotReady ); + } + + Cancel(); // Stop operation timeout monitor + + iOperation = ESMOIdle; + iLastOperationResult = aResult; + iNestedASLoop->AsyncStop(); + } + + +void CSlavesManager::NotifySendReceiveStartedL( TUint16 /*aSlaveId*/ ) + { + if ( iOperation != ESMOSendReceiveWaitForStarted ) + { + User::Leave( KErrNotReady ); + } + + Cancel(); // Stop operation timeout monitor + + iOperation = ESMOSendReceiveWaitForReady; + } + +void CSlavesManager::NotifySendReceiveResultL( + TUint16 /*aSlaveId*/, + CStifTFwIfProt::TRunStatus /*aRunStatus*/, + TInt aRunResult ) + { + if ( ( iOperation != ESMOSendReceiveWaitForStarted ) && + ( iOperation != ESMOSendReceiveWaitForReady ) ) + { + User::Leave( KErrNotReady ); + } + + iLastOperationResult = aRunResult; + + if ( iOperation == ESMOSendReceiveWaitForStarted ) + { + Cancel(); // Stop operation timeout monitor + } + + iOperation = ESMOIdle; + iNestedASLoop->AsyncStop(); + } + +void CSlavesManager::NotifySendUnknownL( TUint16 aSlaveId, TInt aResult ) + { + if ( iOperation != ESMOSendUnknown ) + { + User::Leave( KErrNotReady ); + } + + Cancel(); // Stop operation timeout monitor + + CSlave* slave = GetSlave( aSlaveId ); + if( slave == NULL ) + { + User::Leave( KErrNotFound ); + } + + iOperation = ESMOIdle; + iLastOperationResult = aResult; + iNestedASLoop->AsyncStop(); + } + +void CSlavesManager::HandleRemoteReceiveError( TInt aError, const TDesC& aErrorDescription ) + { + iTestRunner->HandleRemoteReceiveError( aError, aErrorDescription ); + } + +void CSlavesManager::RunL() + { + // Last operation timeouted + if ( iOperation == ESMOSlaveAllocate ) + { + delete iSlaveForAllocate; + iSlaveForAllocate = NULL; + } + + iLastOperationResult = KErrTimedOut; + iOperation = ESMOIdle; + iNestedASLoop->AsyncStop(); + } + +void CSlavesManager::DoCancel() + { + iOperationTimeoutTimer.Cancel(); + } + +// EOF diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/group/bld.inf Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,37 @@ +// +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +// File Logger +#include "../testexecmdw/filelogger/group/bld.inf" + +// Ini File Parser +#include "../testexecmdw/inifileparser/group/bld.inf" + +//TEF Test Module Framework +#include "../teftestmodulefw/group/bld.inf" + +// TEF Wrapper Utility +#include "../tefwrapper/group/bld.inf" + +PRJ_EXPORTS + +PRJ_MMPFILES + +PRJ_TESTMMPFILES + +PRJ_TESTEXPORTS + +//End of File \ No newline at end of file diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/group/bld.inf Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,42 @@ +// +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#include "testexecute.cfg" + +#include "../wrapperutils/group/bld.inf" +#include "../logger/group/bld.inf" +#include "../pipslogger/group/bld.inf" +#include "../utils/group/bld.inf" +#include "../teftestmodule/group/bld.inf" +#include "../tefunit/group/bld.inf" +#include "../tefutilities/group/bld.inf" +// #include "../test/regressiontest/group/bld.inf" + +PRJ_EXPORTS +..\Group\teftestmodulefw.iby \epoc32\rom\include\teftestmodulefw.iby +..\Group\testexecute.ini \epoc32\winscw\c\system\data\testexecute.ini +..\Group\testexecute.ini \epoc32\data\z\system\data\testexecute.ini + +PRJ_MMPFILES + +PRJ_TESTMMPFILES + +PRJ_TESTEXPORTS + + +#if !(defined TEF_LITE_VERSION) +#include "../workshop/demoipsuite/group/bld.inf" +#endif diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/group/release.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/group/release.txt Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,5 @@ +NOTESRC_RELEASER +Nokia Corporation. + +NOTESRC_RELEASE_REASON +tef release. diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/group/tef.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/group/tef.mrp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,27 @@ +# +# Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +component ana_testfw_testexecfw_tef +source /src/tools/ana/testfw/testexecfw/tef +exports /src/tools/ana/testfw/testexecfw/tef/group +binary /src/tools/ana/testfw/testexecfw/tef/group all +notes_source /src/tools/ana/testfw/testexecfw/tef/group/release.txt + + +# == IPR section auto-inserted from distribution.policy files == +ipr T + +# == end auto-inserted section == diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/group/tef.tdf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/group/tef.tdf Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,181 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/group/teftestmodulefw.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/group/teftestmodulefw.iby Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,40 @@ +// +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + + +#ifndef __TEFTESTMODULEFW_IBY__ +#define __TEFTESTMODULEFW_IBY__ + +#ifndef TEF_LITE +#define TEF_LITE +#endif + +#include +#include +#include +#include +#include + + +file=ABI_DIR\BUILD_DIR\TEFTestModule.dll SHARED_LIB_DIR\TEFTestModule.dll +file=ABI_DIR\BUILD_DIR\TEFTestModuleLite.dll SHARED_LIB_DIR\TEFTestModuleLite.dll + +// Below files are duplicated with testexecute.iby(TEF v1). They are commented out temporarily +// If TEF v1 is removed from MCL, the two files should be added in rom. + +//file=ABI_DIR\BUILD_DIR\testexecuteutils.dll SHARED_LIB_DIR\testexecuteutils.dll +//data=\epoc32\data\z\system\data\testexecute.ini system\data\testexecute.ini +#endif \ No newline at end of file diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/group/testexecute.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/group/testexecute.cfg Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,33 @@ +// +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Conditional includes for All capabilities and TEF LITE +// + +// Uncomment these lines for an All Capability build +//#if !defined (TEF_ALL_CAP) +//#define TEF_ALL_CAP +//#endif + +//Uncomment these lines for a TEF LITE build +//#if !defined (TEF_LITE_VERSION) +//#define TEF_LITE_VERSION +//MACRO TEF_LITE +//#endif + +// Uncomment these lines to make the logger session available by all threads within a process +//#if !defined (TEF_SHARE_AUTO_VERSION) +//#define TEF_SHARE_AUTO_VERSION +//MACRO TEF_SHARE_AUTO +//#endif diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/group/testexecute.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/group/testexecute.ini Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,15 @@ +[TestExecute] +HTML = ${SYSDRIVE}\logs\testexecute\ +XML = ${SYSDRIVE}\logs\testexecute\ +LogLevel = FULL +//DefaultScriptDir = z:\sampletest\ +JustInTimeDebug = 0 +LogMode = HTML +LogChannel = File +output_port = 0 +RemotePanicDetection = OFF +EnableIniAccessLog = ON +EnableTestsCountLog = ON +SystemStarter = OFF +DefaultSysDrive = SYSDRIVE +WaitForLoggingTime = 0 diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/group/testexecutelite.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/group/testexecutelite.cfg Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,21 @@ +// +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#if !defined (TEF_LITE_VERSION) +#define TEF_LITE_VERSION +MACRO TEF_LITE +#endif + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/logger/bmarm/testexecutelogclientu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/logger/bmarm/testexecutelogclientu.def Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,10 @@ +EXPORTS + Write__19RTestExecuteLogServRC7TDesC16 @ 1 NONAME R3UNUSED ; RTestExecuteLogServ::Write(TDesC16 const &) + CreateLog__19RTestExecuteLogServRC7TDesC16Q219RTestExecuteLogServ8TLogMode @ 2 NONAME R3UNUSED ; RTestExecuteLogServ::CreateLog(TDesC16 const &, RTestExecuteLogServ::TLogMode) + LogExtra__19RTestExecuteLogServPCUciiGt11TRefByValue1ZC7TDesC16PPSc @ 3 NONAME ; RTestExecuteLogServ::LogExtra(unsigned char const *, int, int, TRefByValue, signed char **) + LogExtra__19RTestExecuteLogServPCUciiGt11TRefByValue1ZC7TDesC16e @ 4 NONAME ; RTestExecuteLogServ::LogExtra(unsigned char const *, int, int, TRefByValue,...) + WriteFormat__19RTestExecuteLogServGt11TRefByValue1ZC6TDesC8e @ 5 NONAME ; RTestExecuteLogServ::WriteFormat(TRefByValue,...) + WriteFormat__19RTestExecuteLogServGt11TRefByValue1ZC7TDesC16e @ 6 NONAME ; RTestExecuteLogServ::WriteFormat(TRefByValue,...) + Write__19RTestExecuteLogServRC6TDesC8 @ 7 NONAME R3UNUSED ; RTestExecuteLogServ::Write(TDesC8 const &) + Connect__19RTestExecuteLogServ @ 8 NONAME R3UNUSED ; RTestExecuteLogServ::Connect(void) + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/logger/bwins/testexecutelogclientu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/logger/bwins/testexecutelogclientu.def Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,13 @@ +EXPORTS + ?Connect@RTestExecuteLogServ@@QAEHXZ @ 1 NONAME ; int RTestExecuteLogServ::Connect(void) + ?CreateLog@RTestExecuteLogServ@@QAEHABVTDesC16@@W4TLogMode@1@@Z @ 2 NONAME ; int RTestExecuteLogServ::CreateLog(class TDesC16 const &, enum RTestExecuteLogServ::TLogMode) + ?LogExtra@RTestExecuteLogServ@@QAAXPBEHHV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 3 NONAME ; void RTestExecuteLogServ::LogExtra(unsigned char const *, int, int, class TRefByValue, ...) + ?LogExtra@RTestExecuteLogServ@@QAEXPBEHHV?$TRefByValue@$$CBVTDesC16@@@@QAPAC@Z @ 4 NONAME ; void RTestExecuteLogServ::LogExtra(unsigned char const *, int, int, class TRefByValue, signed char * * const) + ?Write@RTestExecuteLogServ@@QAEXABVTDesC16@@@Z @ 5 NONAME ; void RTestExecuteLogServ::Write(class TDesC16 const &) + ?Write@RTestExecuteLogServ@@QAEXABVTDesC8@@@Z @ 6 NONAME ; void RTestExecuteLogServ::Write(class TDesC8 const &) + ?WriteFormat@RTestExecuteLogServ@@QAAXV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 7 NONAME ; void RTestExecuteLogServ::WriteFormat(class TRefByValue, ...) + ?WriteFormat@RTestExecuteLogServ@@QAAXV?$TRefByValue@$$CBVTDesC8@@@@ZZ @ 8 NONAME ; void RTestExecuteLogServ::WriteFormat(class TRefByValue, ...) + ?WriteFormat@RTestExecuteLogServ@@QAEXV?$TRefByValue@$$CBVTDesC16@@@@QAPAC@Z @ 9 NONAME ; void RTestExecuteLogServ::WriteFormat(class TRefByValue, signed char * * const) + ?WriteFormat@RTestExecuteLogServ@@QAEXV?$TRefByValue@$$CBVTDesC8@@@@QAPAC@Z @ 10 NONAME ; void RTestExecuteLogServ::WriteFormat(class TRefByValue, signed char * * const) + ?SetLogLevel@RTestExecuteLogServ@@QAEXW4TLogSeverity@@@Z @ 11 NONAME ; void RTestExecuteLogServ::SetLogLevel(enum TLogSeverity) + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/logger/bwins/testexecutelogengineu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/logger/bwins/testexecutelogengineu.def Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,3 @@ +EXPORTS + ?NewServer@@YAHXZ @ 1 NONAME ; int __cdecl NewServer(void) + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/logger/eabi/testexecutelogclientu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/logger/eabi/testexecutelogclientu.def Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,13 @@ +EXPORTS + _ZN19RTestExecuteLogServ11WriteFormatE11TRefByValueIK6TDesC8Ez @ 1 NONAME + _ZN19RTestExecuteLogServ11WriteFormatE11TRefByValueIK7TDesC16Ez @ 2 NONAME + _ZN19RTestExecuteLogServ5WriteERK6TDesC8 @ 3 NONAME + _ZN19RTestExecuteLogServ5WriteERK7TDesC16 @ 4 NONAME + _ZN19RTestExecuteLogServ7ConnectEv @ 5 NONAME + _ZN19RTestExecuteLogServ8LogExtraEPKhii11TRefByValueIK7TDesC16ESt9__va_list @ 6 NONAME + _ZN19RTestExecuteLogServ8LogExtraEPKhii11TRefByValueIK7TDesC16Ez @ 7 NONAME + _ZN19RTestExecuteLogServ9CreateLogERK7TDesC16NS_8TLogModeE @ 8 NONAME + _ZN19RTestExecuteLogServ11WriteFormatE11TRefByValueIK6TDesC8ESt9__va_list @ 9 NONAME + _ZN19RTestExecuteLogServ11WriteFormatE11TRefByValueIK7TDesC16ESt9__va_list @ 10 NONAME + _ZN19RTestExecuteLogServ11SetLogLevelE12TLogSeverity @ 11 NONAME + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/logger/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/logger/group/bld.inf Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,25 @@ +// +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +PRJ_EXPORTS +..\inc\testexecutelog.h \epoc32\include\test\testexecutelog.h +..\group\testexecutelogger.iby \epoc32\rom\include\testexecutelogger.iby +PRJ_MMPFILES +testexecutelogengine.mmp +testexecutelogclient.mmp +PRJ_TESTMMPFILES +//..\test\group\testexecuteloggertest.mmp + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/logger/group/testexecutelogclient.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/logger/group/testexecutelogclient.mmp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Using relative paths for sourcepath and user includes +* +*/ + +#include + +SMPSAFE + +#include "../../Group/testexecute.cfg" +//Unpaged +TARGET testexecutelogclient.dll + +CAPABILITY All +TARGETTYPE dll +UID 0x1000008d 0x101F778B +VENDORID 0x70000001 + +//CAPABILITY ReadSystemData WriteSystemData ReadUserData WriteUserData PhoneNetwork //LocalNetwork + +APP_LAYER_SYSTEMINCLUDE + +SOURCEPATH ../src +SOURCE client.cpp + +USERINCLUDE ../src + +LIBRARY euser.lib + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/logger/group/testexecutelogengine.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/logger/group/testexecutelogengine.mmp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* testexecutelogserver.mmp +* Using relative paths for sourcepath and user includes +* Unpaged +* +*/ + +#include + +SMPSAFE + +TARGET testexecutelogengine.exe +CAPABILITY All -Tcb +TARGETTYPE exe +UID 0x100039CE 0x10281ADF +VENDORID 0x70000001 + + +APP_LAYER_SYSTEMINCLUDE + +//CAPABILITY + +SOURCEPATH ../src +SOURCE server.Cpp +SOURCE main.cpp + +USERINCLUDE ../src + +LIBRARY euser.lib +LIBRARY efsrv.lib diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/logger/group/testexecutelogger.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/logger/group/testexecutelogger.iby Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,24 @@ +// +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#ifndef __TESTEXECUTE_LOGGER_IBY__ +#define __TESTEXECUTE_LOGGER_IBY__ + + +file=ABI_DIR\BUILD_DIR\testexecutelogclient.dll SHARED_LIB_DIR\testexecutelogclient.dll +file=ABI_DIR\BUILD_DIR\testexecutelogengine.exe SHARED_LIB_DIR\testexecutelogengine.exe + +#endif diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/logger/inc/testexecutelog.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/logger/inc/testexecutelog.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,117 @@ +/* +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +/** + @file TestExecuteLog.h +*/ + +#if !(defined __TESTEXECUTE_LOG_H__) +#define __TESTEXECUTE_LOG_H__ + +#include +#include + +_LIT8(KTEFOverflowMessage8, "\t..Message Truncated"); +_LIT16(KTEFOverflowMessage16, "\t..Message Truncated"); +const TInt overflowMessageLen = 21; // Size of the truncation message. To be changed if the text above is changed + +/** + @internalComponent + @test + * Derived class implementation of TDes16Overflow class + * Implements the base class pure virtual Overflow() to handle descriptor overflow + * during AppendFormatList() operations on TDes16 objects + */ +class TTEFDes16Overflow : public TDes16Overflow + { + inline virtual void Overflow(TDes16& aDes) + { + TInt actualMessageLen = aDes.Length(); + TInt maxLengthOfDes = aDes.MaxLength(); + + TInt midPosForEdit = maxLengthOfDes - overflowMessageLen; + if (actualMessageLen <= midPosForEdit) + { + aDes.Append(KTEFOverflowMessage16()); + } + else + { + aDes.SetLength(midPosForEdit + overflowMessageLen); + aDes.Replace(midPosForEdit, overflowMessageLen, KTEFOverflowMessage16()); + } + } + }; + +/** + @internalComponent + @test + * Derived class implementation of TDes8Overflow class + * Implements the base class pure virtual Overflow() to handle descriptor overflow + * during AppendFormatList() operations on TDes8 objects + */ +class TTEFDes8Overflow : public TDes8Overflow + { + inline virtual void Overflow(TDes8& aDes) + { + TInt actualMessageLen = aDes.Length(); + TInt maxLengthOfDes = aDes.MaxLength(); + + TInt midPosForEdit = maxLengthOfDes - overflowMessageLen; + if (actualMessageLen <= midPosForEdit) + { + aDes.Append(KTEFOverflowMessage8()); + } + else + { + aDes.SetLength(midPosForEdit + overflowMessageLen); + aDes.Replace(midPosForEdit, overflowMessageLen, KTEFOverflowMessage8()); + } + } + }; + +class RTestExecuteLogServ : public RSessionBase +/** +@internalComponent +@test +*/ + { +public: + enum TLogMode{ELogModeAppend,ELogModeOverWrite}; + // Logging level + enum TLogCommand{ECreateLog,EWriteLog}; + + IMPORT_C TInt Connect(); + IMPORT_C TInt CreateLog(const TDesC& aLogFilePath,TLogMode aMode); + IMPORT_C void LogExtra(const TText8* aFile, TInt aLine, TInt aSeverity,TRefByValue aFmt,...); + IMPORT_C void Write(const TDesC& aLogBuffer); + IMPORT_C void WriteFormat(TRefByValue aFmt,...); + IMPORT_C void Write(const TDesC8& aLogBuffer); + IMPORT_C void WriteFormat(TRefByValue aFmt,...); + IMPORT_C void LogExtra(const TText8* aFile, TInt aLine, TInt aSeverity,TRefByValue aFmt, VA_LIST aList); + IMPORT_C void WriteFormat(TRefByValue aFmt, VA_LIST aList); + IMPORT_C void WriteFormat(TRefByValue aFmt, VA_LIST aList); + IMPORT_C void SetLogLevel(TLogSeverity aSeverity); +private: + void WriteL(const TDesC& aLogBuffer); + void WriteL(TDes8& aLogBuffer); + void GetCPPModuleName(TDes& aModuleName, const TText8* aCPPFileName); + void AddTime(TDes8& aTime); + TLogSeverity iLogLevel; + }; +#endif diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/logger/src/client.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/logger/src/client.cpp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,409 @@ +/* +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Source file for the client api +* +*/ + + + +/** + @file Client.cpp +*/ +#include + + +const TInt KMaxFilename = 50; +const TInt KLowMemBufLength = 128; + +// EKA1 requires DLL entry point + + +EXPORT_C TInt RTestExecuteLogServ::Connect() +/** + * @return int - Standard error codes + * EKA2 all variants and EKA1 target. + * Server is an exe + */ + { + TVersion version(KTestExecuteLoggerMajorVersion,KTestExecuteLoggerMinorVersion,KTestExecuteLoggerBuildVersion); + // Assume the server is already running and attempt to create a session + TInt err = CreateSession(KTestExecuteLogServerName,version,8); + if(err == KErrNotFound) + { + // Server not running + // Construct the server binary name + _LIT(KEmpty,""); + // EKA2 is simple + // No path required + TBuf<32> serverFile; + serverFile.Copy(KTestExecuteLogServerName); + _LIT(KExe,".exe"); + serverFile.Append(KExe); + RProcess server; + err = server.Create(serverFile,KEmpty); + if(err != KErrNone) + return err; + // Synchronise with the server + TRequestStatus reqStatus; + server.Rendezvous(reqStatus); + server.Resume(); + // Server will call the reciprocal static synchronise call + User::WaitForRequest(reqStatus); + server.Close(); + if(reqStatus.Int() != KErrNone) + return reqStatus.Int(); + // Create the root server session + err = CreateSession(KTestExecuteLogServerName,version,8); + } + +#ifdef TEF_SHARE_AUTO + // Makes the session shared among all threads in the process + if( err == KErrNone ) + { + err = ShareAuto(); + } +#endif + + return err; + } + +/////// +EXPORT_C TInt RTestExecuteLogServ::CreateLog(const TDesC& aLogFilePath, TLogMode aMode) +/** + * @param aLogFilePath - Full path and filename of the log file + * @param aMode - Overwrite or Append + * Makes synchronous call to the log server to create a log session + */ + { + if(aLogFilePath.Length() > KMaxTestExecuteLogFilePath) + return KErrTooBig; + + iLogLevel = TLogSeverity(ESevrAll); + TIpcArgs args; + args.Set(0,&aLogFilePath); + args.Set(1,aMode); + return SendReceive(ECreateLog,args); + + } + +EXPORT_C void RTestExecuteLogServ::LogExtra(const TText8* aFile, TInt aLine, TInt aSeverity,TRefByValue aFmt,...) +/** + * @param aFile - Source file name + * @param aLine - Source file line number + * @param aSeverity - ERR, WARN, INFO + * @param aFmt - UNICODE format string + */ + { + if (aSeverity>iLogLevel) + { + return; + } + // Set up a Variable argument list and call private method + VA_LIST aList; + VA_START(aList, aFmt); + LogExtra(aFile, aLine, aSeverity, aFmt, aList); + VA_END(aList); + } + +EXPORT_C void RTestExecuteLogServ::WriteFormat(TRefByValue aFmt,...) +/** + * @param aFmt - UNICODE format string + */ + { + // Set up a Variable argument list and call private method + VA_LIST aList; + VA_START(aList, aFmt); + WriteFormat(aFmt, aList); + VA_END(aList); + } + + +EXPORT_C void RTestExecuteLogServ::Write(const TDesC& aLogBuffer) +/** + * @param aLogBuffer - Pre-formatted UNICODE buffer + */ + { + // Just call private method + // Ignore errors. Could put in ASSERT + TRAP_IGNORE(WriteL(aLogBuffer)); + } + + +EXPORT_C void RTestExecuteLogServ::WriteFormat(TRefByValue aFmt,...) +/** + * @param aFmt - Narrow format string + */ + { + // Set up a Variable argument list and call private method + VA_LIST aList; + VA_START(aList, aFmt); + WriteFormat(aFmt, aList); + VA_END(aList); + } + + +EXPORT_C void RTestExecuteLogServ::Write(const TDesC8& aLogBuffer) +/** + * @param aLogBuffer - Pre-formatted Narrow buffer + */ + { + // Create a larger buffer for adding terminators + // Could do more formatting but just allow for CRLF plus time stamp for the time being + HBufC8* buffer = HBufC8::New(aLogBuffer.Length()+20); + if(buffer) + { + TPtr8 ptr(buffer->Des()); + AddTime(ptr); + ptr.Append(aLogBuffer); + // Ignore error for the time being. Could do an ASSERT + TRAP_IGNORE(WriteL(ptr)); + delete buffer; + } + } + +void RTestExecuteLogServ::AddTime(TDes8& aLogBuffer) + { + TTime now; + now.UniversalTime(); + TDateTime dateTime = now.DateTime(); + _LIT8(KFormat,"%02d:%02d:%02d:%03d "); + // add the current time + aLogBuffer.AppendFormat(KFormat,dateTime.Hour(),dateTime.Minute(),dateTime.Second(),(dateTime.MicroSecond()/1000)); + } + +EXPORT_C void RTestExecuteLogServ::LogExtra(const TText8* aFile, TInt aLine, TInt aSeverity,TRefByValue aFmt, VA_LIST aList) +/** + * @param aFile - Source file name + * @param aLine - Source file line number + * @param aSeverity - ERR, WARN, INFO + * @param aFmt - UNICODE format string + * @param aList - Variable argument list + * + * Format a log output line + */ + { + if (aSeverity>iLogLevel) + { + return; + } + // Create a filename string + TBuf16 fileName; + GetCPPModuleName(fileName, aFile); + // Create a buffer for formatting + HBufC* buffer = HBufC::New(KMaxTestExecuteLogLineLength*2); + if (buffer) + { + TPtr ptr(buffer->Des()); + _LIT(KErr,"ERROR - "); + _LIT(KHigh,"HIGH - "); + _LIT(KWarn,"WARN - "); + _LIT(KMedium,"MEDIUM - "); + _LIT(KInfo,"INFO - "); + _LIT(KLow,"LOW - "); + _LIT(KFormat," %d %S %d "); + if(aSeverity == ESevrErr) + ptr.Append(KErr); + else if(aSeverity == ESevrHigh) + ptr.Append(KHigh); + else if(aSeverity == ESevrWarn) + ptr.Append(KWarn); + else if(aSeverity == ESevrMedium) + ptr.Append(KMedium); + else if (aSeverity == ESevrInfo) + ptr.Append(KInfo); + else if(aSeverity == ESevrLow) + ptr.Append(KLow); + else //if(aSeverity == ESevrAll) + ptr.Append(KInfo); + // Add the thread id + ptr.AppendFormat(KFormat,(TInt)RThread().Id(),&fileName, aLine); + TTEFDes16Overflow des16OverflowObject; + ptr.AppendFormatList(aFmt, aList, &des16OverflowObject); + + + TRAP_IGNORE(WriteL(ptr)); + delete buffer; + } + else + { + _LIT(KWarn,"WARN - "); + TBuf8 noMemory; + AddTime(noMemory); + noMemory.Append(KWarn); + noMemory.AppendFormat(_L8(" %d "), (TInt)RThread().Id()); + noMemory.Append(fileName); + noMemory.AppendFormat(_L8(" %d %S"), aLine, &KLoggerNotEnoughMemory8()); + TRAP_IGNORE(WriteL(noMemory)); + } + } + +EXPORT_C void RTestExecuteLogServ::WriteFormat(TRefByValue aFmt, VA_LIST aList) +/** + * @param aFmt - UNICODE format string + * @param aList - Variable argument list + */ + { + HBufC* buffer = HBufC::New(KMaxTestExecuteLogLineLength*2); + if (buffer) + { + TPtr ptr(buffer->Des()); + TTEFDes16Overflow des16OverflowObject; + ptr.AppendFormatList(aFmt, aList, &des16OverflowObject); + + TRAP_IGNORE(WriteL(ptr)); + delete buffer; + } + else + { + TRAP_IGNORE(WriteL((TDes8&)KLoggerNotEnoughMemory8())); + } + } + +EXPORT_C void RTestExecuteLogServ::WriteFormat(TRefByValue aFmt, VA_LIST aList) +/** + * @param aFmt - UNICODE format string + * @param aList - Variable argument list + */ + { + HBufC8* buffer = HBufC8::New(KMaxTestExecuteLogLineLength*2); + if (buffer) + { + TPtr8 ptr(buffer->Des()); + AddTime(ptr); + TTEFDes8Overflow des8OverflowObject; + ptr.AppendFormatList(aFmt, aList, &des8OverflowObject); + + TRAP_IGNORE(WriteL(ptr)); + delete buffer; + } + else + { + TRAP_IGNORE(WriteL((TDes8&)KLoggerNotEnoughMemory8())); + } + } + +void RTestExecuteLogServ::WriteL(const TDesC& aLogBuffer) +/** + * @param aLogBuffer - UNICODE buffer + */ + { + HBufC8* buffer = NULL; + TRAPD(err, buffer=HBufC8::NewL(aLogBuffer.Length()+20)); + if (KErrNoMemory == err) + { + _LIT8(KWarn,"WARN - "); + TInt startPos = 13; // The place change "INFO" to "WARN" + TInt endPos = 7; + TInt wordCount = 5; // The message before the actual log info + TBuf8 buffer; + AddTime(buffer); + TLex lex(aLogBuffer); + lex.Mark(); + for (TInt i=0; iDes()); + AddTime(ptr); + ptr.Append(aLogBuffer); + WriteL(ptr); + + CleanupStack::PopAndDestroy(buffer); + } + } + +void RTestExecuteLogServ::WriteL(TDes8& aLogBuffer) +/** + * @param aLogBuffer - pre-formatted narrow buffer + * + * Synchronous write to the server + */ + { + _LIT8(KEnd,"\r\n"); + // Check to see if there's room to add CRLF + if(aLogBuffer.Length()+2 > aLogBuffer.MaxLength()) + { + HBufC8* buffer = NULL; + TRAPD(err, buffer=HBufC8::NewL(aLogBuffer.Length()+2)); + if (KErrNoMemory == err) + { + aLogBuffer.Replace(aLogBuffer.Length()-2, 2, KEnd); + TIpcArgs args; + args.Set(0,&aLogBuffer); + args.Set(1,aLogBuffer.Length()); + User::LeaveIfError(SendReceive(EWriteLog,args)); + } + else + { + CleanupStack::PushL(buffer); + TPtr8 ptr(buffer->Des()); + ptr.Copy(aLogBuffer); + ptr.Append(KEnd); + TIpcArgs args; + args.Set(0,&ptr); + args.Set(1,ptr.Length()); + User::LeaveIfError(SendReceive(EWriteLog,args)); + CleanupStack::PopAndDestroy(buffer); + } + } + else + { + aLogBuffer.Append(KEnd); + TIpcArgs args; + args.Set(0,&aLogBuffer); + args.Set(1,aLogBuffer.Length()); + User::LeaveIfError(SendReceive(EWriteLog,args)); + } + } + +void RTestExecuteLogServ::GetCPPModuleName(TDes& aModuleName, const TText8* aCPPFileName) +/** + * @return aModuleName - Filename in descriptor + * @param aCppFileName - Filename + * Borrowed from scheduletest + */ + { + TPtrC8 fileNamePtrC8(aCPPFileName); + // We do our own filename munging here; TParse can't help us since that's + // expressly for EPOC filepaths and here we've got whatever the build system is + // At present Win32 and Unix directory delimiters are supported + TInt lastDelimiter = Max(fileNamePtrC8.LocateReverse('\\'), fileNamePtrC8.LocateReverse('/')); + if(lastDelimiter >= 0 && lastDelimiter < fileNamePtrC8.Length() - 1) + { + // Found a delimiter which isn't trailing; update the ptr to start at the next char + TInt fileNameLen = Min(KMaxFilename, fileNamePtrC8.Length() - (lastDelimiter + 1)); + fileNamePtrC8.Set(aCPPFileName + lastDelimiter + 1, fileNameLen); + } + else + { + // Didn't find a delimiter; take as much of the right-end of the name as fits + fileNamePtrC8.Set(aCPPFileName + Max(0, fileNamePtrC8.Length() - KMaxFilename), Min(fileNamePtrC8.Length(), KMaxFilename)); + } + aModuleName.Copy(fileNamePtrC8); + } + +EXPORT_C void RTestExecuteLogServ::SetLogLevel(TLogSeverity aSeverity) + { + iLogLevel = aSeverity; + } diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/logger/src/main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/logger/src/main.cpp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Server entry points +* EKA1 & EKA2 +* EKA1 & WINS is a DLL. All others are exe's +* +*/ + + + +/** + @file Main.cpp +*/ +#include +#include "server.h" + +// Emulator EKA1 is the only DLL case + +// EKA2 all variats & EKA1 target only +// E32Main calls MainL() +LOCAL_C void MainL() +/** + * Secure variant + * Much simpler, uses the new Rendezvous() call to sync with the client + */ + { + // Leave Platform security hooks in place +#if (defined __DATA_CAGING__) + RProcess().DataCaging(RProcess::EDataCagingOn); + RProcess().SecureApi(RProcess::ESecureApiOn); +#endif + CActiveScheduler* sched=NULL; + sched=new(ELeave) CActiveScheduler; + CActiveScheduler::Install(sched); + CLogServer* server = NULL; + // Create the sever + TRAPD(err,server = CLogServer::NewL()); + if(!err) + { + // Client Synchronisation different for EKA1 and EKA2 + // EKA2 really simple. Client blocks on reciprocal Rendezvous call + RProcess::Rendezvous(KErrNone); + // Go into the Active scheduler + sched->Start(); + // Free the server class + delete server; + } + delete sched; + } + +GLDEF_C TInt E32Main() +/** + * @return - Standard Epoc error code on process exit + * Process entry point. Called by client using RProcess API + */ + { + __UHEAP_MARK; + CTrapCleanup* cleanup = CTrapCleanup::New(); + if(cleanup == NULL) + { + return KErrNoMemory; + } + TRAP_IGNORE(MainL()); + delete cleanup; + __UHEAP_MARKEND; + return KErrNone; + } diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/logger/src/server.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/logger/src/server.cpp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,373 @@ +/* +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Main log server engine. +* Process log requests from multiple clients simultaneously. +* +*/ + + + +/** + @file server.cpp +*/ +#include "server.h" + +const TInt KLowMemBufLength = 128; + +CLogServer* CLogServer::NewL() +/** + * @return - Instance of the log server + */ + { + CLogServer * server = new (ELeave) CLogServer(); + CleanupStack::PushL(server); + server->ConstructL(); + // CServer base class call + server->StartL(KTestExecuteLogServerName); + CleanupStack::Pop(server); + return server; + } + +void CLogServer::ConstructL() +/** + * Second phase construction + */ + { + User::LeaveIfError(Fs().Connect()); + } + + +CLogServer::CLogServer() : CServer2(EPriorityStandard,ESharableSessions) +/** + * Constructor + */ + { + } + +CLogServer::~CLogServer() +/** + * Destructor + */ + { + // Close the array of control structures + LogControl().Close(); + Fs().Close(); + } + + +CSession2* CLogServer::NewSessionL(const TVersion& /*aVersion*/,const RMessage2& /*aMessage*/) const +/** + * @param RMessage - RMessage for the session open + */ + { + // Just create the session + CLogSession* session = new (ELeave) CLogSession(); + return session; + } + +void CLogServer::ControlComplete(CLogFileControl& aControl) +/** + * @param aControl - Logfile control class reference + * + * Checks to see if this control session can be removed + */ + { + // Check session count and the data buffers on the queue + if(aControl.SessionCount() || !aControl.QueueEmpty()) + return; + + // There are no subsessions mapped to the logfile control class and + // no data buffers on its write queue + // Loop through the server's control array and remove it then delete it + TInt i; + for(i=0;iRemoveSession(); + CLogServer* p=(CLogServer*) Server(); + // Shuts Down the server if this is the last open session + p->ControlComplete(*iControl); + } + +void CLogSession::ServiceL(const RMessage2& aMessage) +/** + * @param aMessage - Function and data for the session + */ + { + switch(aMessage.Function()) + { + // API CreateLog() call + case RTestExecuteLogServ::ECreateLog : + { + // Sanity check to make sure it's not been called multiple times + if(iControl) + { + aMessage.Complete(KErrInUse); + break; + } + // Get the filepath + // size policed on the client side + TBuf logFilePath; + // Read it + aMessage.ReadL(0,logFilePath); + // Get the log mode in the second argument + RTestExecuteLogServ::TLogMode logMode; + logMode = (RTestExecuteLogServ::TLogMode)aMessage.Int1(); + // Get a pointer to the parent server + CLogServer* server=(CLogServer*) Server(); + // For compare's convert the whole path to lower case + logFilePath.LowerCase(); + // Get rid of leading and trailing spaces. + logFilePath.Trim(); + // Loop the through the server's logfile control class list + // to see if there's a match. + TInt i; + for(i=0;iLogControl().Count();i++) + { + if(server->LogControl()[i]->LogFile() == logFilePath) + // This file's already in open so we don't have to open it + break; + } + TInt err = KErrNone; + // Check the count + if(i < server->LogControl().Count()) + // Map this session to an existing logfile control class in the list + iControl = server->LogControl()[i]; + else + { + // Create a new logfile control class + // creates/opens the logfile + TRAP(err,iControl = CLogFileControl::NewL(*server,logFilePath,logMode)); + if(!err) + // Append it to the logfile control class list + server->LogControl().Append(iControl); + } + if(!err) + // Increment its session count + iControl->AddSession(); + aMessage.Complete(err); + } + break; + // One of the API write calls + case RTestExecuteLogServ::EWriteLog : + { + // Sanity check + if(!iControl) + { + aMessage.Complete(KErrNotFound); + break; + } + // Data can be any size + // Get the length from second argument + TInt bufferLength = aMessage.Int1(); + // Get a heap buffer of the right size + HBufC8* buffer = NULL; + TRAPD(err, buffer = HBufC8::NewL(bufferLength)); + if (KErrNoMemory == err) + { + // If the buffer length is bigger than 128 and allocation failed, try to allocate + // 128 bytes and set it the low memory information. + if (bufferLength > KLowMemBufLength) + { + HBufC8* buf = HBufC8::NewL(KLowMemBufLength); + CleanupStack::PushL(buf); + TPtr8 ptr = buf->Des(); + ptr.Copy(KLoggerNotEnoughMemory8); + CLogBuffer* logBuffer = new (ELeave) CLogBuffer(*buf); + CleanupStack::Pop(buf); + iControl->AddLogBuffer(*logBuffer); + } + } + else + { + CleanupStack::PushL(buffer); + TPtr8 ptr(buffer->Des()); + // read the data + aMessage.ReadL(0,ptr); + // Get a buffer control class contructed with the heap data + // takes ownership + CLogBuffer* logBuffer = new (ELeave) CLogBuffer(*buffer); + CleanupStack::Pop(buffer); + // Add it to the logfile control class buffer queue + iControl->AddLogBuffer(*logBuffer); + } + if(!iControl->IsActive()) + // AO is idle, kick into life + iControl->Kick(); + aMessage.Complete(KErrNone); + } + break; + + default: + break; + } + } + +/////// + +CLogFileControl* CLogFileControl::NewL(CLogServer& aParent, const TDesC& aLogFilePath,RTestExecuteLogServ::TLogMode aMode) +/** + * @param aParent - Server reference for callback + * @param aLogFilePath - Full path and filename of the logfile + * @param aMode - Overwrite or Append + * + * First phase construction for logfile control class + */ + { + CLogFileControl* self = new (ELeave) CLogFileControl(aParent,aLogFilePath); + self->ConstructL(aMode); + return self; + } + +CLogFileControl::CLogFileControl(CLogServer& aParent,const TDesC& aLogFilePath) : + iParent(aParent), + iLogFileName(aLogFilePath), + iTransmitted(EFalse) +/** + * @param aParent - Server reference for callback + * @param aLogFilePath - Full path and filename of the logfile + * + * Constructor - Safe initialisation + */ + { + iQueue.SetOffset(CLogBuffer::LinkOffset()); + } + +void CLogFileControl::ConstructL(RTestExecuteLogServ::TLogMode aMode) +/** + * @param aMode - Overwrite or Append + * + * Second phase construction - Create or open the logfile + */ + { + if(aMode == RTestExecuteLogServ::ELogModeOverWrite) + // In overwrite mode replace + User::LeaveIfError(iLogFile.Replace(iParent.Fs(),iLogFileName,EFileWrite|EFileShareAny)); + else + { + // For append try open then replace + TInt err = iLogFile.Open(iParent.Fs(),iLogFileName,EFileWrite|EFileShareAny); + if(err != KErrNone) + // Bomb out if replace fails + User::LeaveIfError(iLogFile.Replace(iParent.Fs(),iLogFileName,EFileWrite|EFileShareAny)); + else + { + // Open worked. Position at EOF + TInt pos; + User::LeaveIfError(iLogFile.Seek(ESeekEnd,pos)); + } + } + } + +CLogFileControl::~CLogFileControl() +/** + * Destructor + * The server maintains a list of these classes and will not destruct one if there + * is data on its queue + * Destructor just closes the file handle. + */ + { + iLogFile.Close(); + } + +void CLogFileControl::RunL() +/** + * Main File writing pump + * Called on write completion or Kick() by the session that accepts the data + */ + { +#if (defined _DEBUG) + _LIT(KPanic,"LogEng RunL()"); +#endif + __ASSERT_DEBUG(iStatus.Int() == KErrNone,User::Panic(KPanic,iStatus.Int())); + // Check to see if this is the result of write completion + if(iTransmitted) + { + // Write completed + // Remove the buffer at the head of the queue and free it + CLogBuffer* buffer = iQueue.First(); + iQueue.Remove(*buffer); + delete buffer; + } + // Check to see if there's more on the queue + if(!iQueue.IsEmpty()) + { + // There is so write the head of the queue + CLogBuffer* buffer = iQueue.First(); + SetActive(); + // Set the flag to say we've transmitted + iTransmitted = ETrue; + iLogFile.Write(buffer->Buf(),iStatus); + iLogFile.Flush(); + } + else + { + // Nothing on the queue + iTransmitted = EFalse; + // Call into the server to check if this resource can be freed + iParent.ControlComplete(*this); + } + } + +/////// +CLogBuffer::CLogBuffer(HBufC8& aLogBuffer) : iLogBuffer(aLogBuffer) +/** + * @param aLogBuffer - Heap descriptor. This class takes ownership + * Constructor + */ + { + } + +CLogBuffer::~CLogBuffer() +/** + * Destructor + * This class owns a heap buffer so just free it + */ + { + delete &iLogBuffer; + } diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/logger/src/server.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/logger/src/server.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,115 @@ +/* +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +/** + @file Server.h +*/ + +#if (!defined __TESTEXECUTE_LOG_SERVER_H__) +#define __TESTEXECUTE_LOG_SERVER_H__ +#include +#include +#include + +class CActiveBase : public CActive + { +public: + inline TRequestStatus& Status(); + inline void SetActive(); + inline void Kick(); + inline void Prime(); + inline void Complete(TInt aCode); + inline virtual ~CActiveBase(); +protected: + inline CActiveBase(); + }; + +class CLogBuffer : public CBase + { +public: + CLogBuffer(HBufC8& aBuffer); + ~CLogBuffer(); + inline const TDesC8& Buf(); + inline static TInt LinkOffset(); +private: + TSglQueLink iLink; + HBufC8& iLogBuffer; + }; + +class CLogServer; +class CLogFileControl : public CActiveBase + { +public: + static CLogFileControl* NewL(CLogServer& aParent, const TDesC& aLogFilePath,RTestExecuteLogServ::TLogMode aMode); + ~CLogFileControl(); + void RunL(); + inline void AddLogBuffer(CLogBuffer& aBuffer); + inline const TDesC& LogFile(); + inline void DoCancel(); + inline void AddSession(); + inline void RemoveSession(); + inline TInt SessionCount() const; + inline TBool QueueEmpty() const; + +private: + void ConstructL(RTestExecuteLogServ::TLogMode aMode); + CLogFileControl(CLogServer& aParent, const TDesC& aLogFilePath); +private: + CLogServer& iParent; + TBuf iLogFileName; + RFile iLogFile; + TSglQue iQueue; + TInt iSessionCount; + TBool iTransmitted; + }; + +class CLogServer : public CServer2 + { +public: + static CLogServer* NewL(); + ~CLogServer(); + void ControlComplete(CLogFileControl& aControl); + + inline RPointerArray& LogControl(); + inline RFs& Fs(); + + CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const; + void SessionClosed(); +private: + CLogServer(); + void ConstructL(); +private: + RFs iFs; + RPointerArray iControl; + }; + +class CLogSession : public CSession2 + { +public: + inline const CLogServer& LogServer() const; + CLogSession(); + ~CLogSession(); + void ServiceL(const RMessage2& aMessage); +private: + CLogFileControl* iControl; + }; + +#include "Server.inl" + +#endif diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/logger/src/server.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/logger/src/server.inl Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,89 @@ +/* +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +inline TRequestStatus& CActiveBase::Status() + {return iStatus;} + +inline void CActiveBase::SetActive() + { + if(!IsActive()) + CActive::SetActive(); + } + +inline void CActiveBase::Kick() + { + Prime(); + Complete(KErrNone); + } + +inline void CActiveBase::Prime() + { + iStatus = KRequestPending; + if(!IsActive()) + CActive::SetActive(); + } + +inline void CActiveBase::Complete(TInt aCode) + { + TRequestStatus* status = &iStatus; + User::RequestComplete(status,aCode); + } + +inline CActiveBase::CActiveBase() : CActive(EPriorityStandard) + {CActiveScheduler::Add(this);} + +inline CActiveBase::~CActiveBase() + {} + +/////// +inline const TDesC& CLogFileControl::LogFile() + {return iLogFileName;} + +inline void CLogFileControl::DoCancel() + {} + +inline void CLogFileControl::AddSession() + {iSessionCount++;} + +inline void CLogFileControl::RemoveSession() + {iSessionCount--;} + +inline TInt CLogFileControl::SessionCount() const + {return iSessionCount;} + +inline TBool CLogFileControl::QueueEmpty() const + {return iQueue.IsEmpty();} + +inline void CLogFileControl::AddLogBuffer(CLogBuffer& aBuffer) + {iQueue.AddLast(aBuffer);} + +/////// +inline RPointerArray& CLogServer::LogControl() + {return iControl;} + +inline RFs& CLogServer::Fs() + {return iFs;} + +/////// +inline const TDesC8& CLogBuffer::Buf() + {return iLogBuffer;} + +inline TInt CLogBuffer::LinkOffset() + {return _FOFF(CLogBuffer,iLink);} diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/logger/test/group/testexecuteloggertest.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/logger/test/group/testexecuteloggertest.mmp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Using relative paths for sourcepath and user includes +* +*/ + +SMPSAFE + +TARGET testexecuteloggertest.exe +TARGETTYPE exe +UID 0x100039CE 0x101F778D +VENDORID 0x70000001 + +SOURCEPATH ../src +SOURCE testexecuteloggertest.cpp + +SYSTEMINCLUDE /epoc32/include +SYSTEMINCLUDE /epoc32/include/test + +LIBRARY euser.lib +LIBRARY efsrv.lib +LIBRARY testexecutelogclient.lib diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/logger/test/src/testexecuteloggertest.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/logger/test/src/testexecuteloggertest.cpp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,129 @@ +/* +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Demonstration use of the TestExecute standalone logger client API +* +*/ + + + +/** + @file TestExecuteLoggerTest.cpp +*/ +#include +#include +#include + +_LIT(KLogFile1,"?:\\TestExecuteLoggerTest.txt"); + +_LIT(K16BitText,"This is a short line of 16 Bit Text"); +_LIT8(K8BitText,"This is a short line of 8 Bit Text"); + +_LIT(K16BitFormatText,"This is a short line of 16 Bit Format Text int = %d string = %S"); +_LIT8(K8BitFormatText,"This is a short line of 8 Bit Format Text int = %d string = %S"); +_LIT(K16BitString,"The String16"); +_LIT8(K8BitString,"The String8"); + +LOCAL_C void MainL() + { + TDriveName defaultSysDrive(KTEFLegacySysDrive); + + RFs fileServer; + TVersionName version(fileServer.Version().Name()); + + if (fileServer.Version().iMajor >= 2 && + fileServer.Version().iBuild >= 1100) + { + RLibrary pluginLibrary; + TInt pluginErr = pluginLibrary.Load(KTEFWrapperPluginDll); + if (pluginErr == KErrNone) + { + TLibraryFunction newl; + newl = pluginLibrary.Lookup(2); + CWrapperUtilsPlugin* plugin = (CWrapperUtilsPlugin*)newl(); + TDriveUnit driveUnit(plugin->GetSystemDrive()); + defaultSysDrive.Copy(driveUnit.Name()); + delete plugin; + pluginLibrary.Close(); + } + } + + TFileName logFile1(KLogFile1); + logFile1.Replace(0, 2, defaultSysDrive); + + _LIT(KTitle,"TestExecute Standalone Logger Test Code"); + CConsoleBase* console = Console::NewL(KTitle,TSize(KConsFullScreen,KConsFullScreen)); + CleanupStack::PushL(console); + + _LIT(KMessage1,"Connect() To Logger and Close() immediately\r\n"); + console->Printf(KMessage1); + RTestExecuteLogServ logger; + User::LeaveIfError(logger.Connect()); + logger.Close(); + + _LIT(KMessage2,"Immediate re-Connect() To Logger and Close() immediately\r\n"); + console->Printf(KMessage2); + User::LeaveIfError(logger.Connect()); + logger.Close(); + + _LIT(KMessage3,"Immediate re-Connect() To Logger CreateLog() and Close() immediately\r\n"); + console->Printf(KMessage3); + User::LeaveIfError(logger.Connect()); + User::LeaveIfError(logger.CreateLog(logFile1,RTestExecuteLogServ::ELogModeOverWrite)); + logger.Close(); + + // OS needs time to shutdown the server + // No delay means we get server terminated from the OS + User::After(1000000); + + _LIT(KMessage4,"Connect() To Logger CreateLog() %S Call API's\r\n"); + console->Printf(KMessage4,&logFile1); + User::LeaveIfError(logger.Connect()); + User::LeaveIfError(logger.CreateLog(logFile1,RTestExecuteLogServ::ELogModeOverWrite)); + TBuf<20> buf16(K16BitString); + TBuf8<20> buf8(K8BitString); + logger.Write(K16BitText); + logger.Write(K8BitText); + logger.WriteFormat(K16BitFormatText,16,&buf16); + logger.WriteFormat(K8BitFormatText,8,&buf8); + logger.LogExtra(((TText8*)__FILE__), __LINE__,ESevrInfo,K16BitFormatText,1,&buf16); + + _LIT(KMessage5,"ALL API's Called - Call Close(),\r\nHit Any Key\r\n"); + console->Printf(KMessage5); + console->Getch(); + logger.Close(); + + CleanupStack::PopAndDestroy(console); + + } + +// Entry point for all Epoc32 executables +// See PSP Chapter 2 Getting Started +GLDEF_C TInt E32Main() + { + // Heap balance checking + // See PSP Chapter 6 Error Handling + __UHEAP_MARK; + CTrapCleanup* cleanup = CTrapCleanup::New(); + if(cleanup == NULL) + { + return KErrNoMemory; + } + TRAPD(err,MainL()); + _LIT(KPanic,"LoggerTest"); + __ASSERT_ALWAYS(!err, User::Panic(KPanic,err)); + delete cleanup; + __UHEAP_MARKEND; + return KErrNone; + } diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/pipslogger/bwins/testexecutepipslogclientu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/pipslogger/bwins/testexecutepipslogclientu.def Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,14 @@ +EXPORTS + ??4RTestExecutePIPSLogServ@@QAEAAV0@ABV0@@Z @ 1 NONAME ABSENT ; class RTestExecutePIPSLogServ & RTestExecutePIPSLogServ::operator=(class RTestExecutePIPSLogServ const &) + ?Connect@RTestExecutePIPSLogServ@@QAEHXZ @ 2 NONAME ; int RTestExecutePIPSLogServ::Connect(void) + ?CreateLog@RTestExecutePIPSLogServ@@QAEHABVTDesC16@@@Z @ 3 NONAME ; int RTestExecutePIPSLogServ::CreateLog(class TDesC16 const &) + ?LogExtra@RTestExecutePIPSLogServ@@QAAXPBEHHV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 4 NONAME ; void RTestExecutePIPSLogServ::LogExtra(unsigned char const *, int, int, class TRefByValue, ...) + ?LogExtra@RTestExecutePIPSLogServ@@QAEXPBEHHV?$TRefByValue@$$CBVTDesC16@@@@QAPAC@Z @ 5 NONAME ; void RTestExecutePIPSLogServ::LogExtra(unsigned char const *, int, int, class TRefByValue, signed char * * const) + ?SetLogLevel@RTestExecutePIPSLogServ@@QAEXW4TLogSeverity@@@Z @ 6 NONAME ; void RTestExecutePIPSLogServ::SetLogLevel(enum TLogSeverity) + ?Write@RTestExecutePIPSLogServ@@QAEXABVTDesC16@@@Z @ 7 NONAME ; void RTestExecutePIPSLogServ::Write(class TDesC16 const &) + ?Write@RTestExecutePIPSLogServ@@QAEXABVTDesC8@@@Z @ 8 NONAME ; void RTestExecutePIPSLogServ::Write(class TDesC8 const &) + ?WriteFormat@RTestExecutePIPSLogServ@@QAAXV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 9 NONAME ; void RTestExecutePIPSLogServ::WriteFormat(class TRefByValue, ...) + ?WriteFormat@RTestExecutePIPSLogServ@@QAAXV?$TRefByValue@$$CBVTDesC8@@@@ZZ @ 10 NONAME ; void RTestExecutePIPSLogServ::WriteFormat(class TRefByValue, ...) + ?WriteFormat@RTestExecutePIPSLogServ@@QAEXV?$TRefByValue@$$CBVTDesC16@@@@QAPAC@Z @ 11 NONAME ; void RTestExecutePIPSLogServ::WriteFormat(class TRefByValue, signed char * * const) + ?WriteFormat@RTestExecutePIPSLogServ@@QAEXV?$TRefByValue@$$CBVTDesC8@@@@QAPAC@Z @ 12 NONAME ; void RTestExecutePIPSLogServ::WriteFormat(class TRefByValue, signed char * * const) + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/pipslogger/eabi/testexecutepipslogclientu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/pipslogger/eabi/testexecutepipslogclientu.def Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,14 @@ +EXPORTS + _ZN23RTestExecutePIPSLogServ11SetLogLevelE12TLogSeverity @ 1 NONAME + _ZN23RTestExecutePIPSLogServ11WriteFormatE11TRefByValueIK6TDesC8ESt9__va_list @ 2 NONAME + _ZN23RTestExecutePIPSLogServ11WriteFormatE11TRefByValueIK6TDesC8Ez @ 3 NONAME + _ZN23RTestExecutePIPSLogServ11WriteFormatE11TRefByValueIK7TDesC16ESt9__va_list @ 4 NONAME + _ZN23RTestExecutePIPSLogServ11WriteFormatE11TRefByValueIK7TDesC16Ez @ 5 NONAME + _ZN23RTestExecutePIPSLogServ5WriteERK6TDesC8 @ 6 NONAME + _ZN23RTestExecutePIPSLogServ5WriteERK7TDesC16 @ 7 NONAME + _ZN23RTestExecutePIPSLogServ7ConnectEv @ 8 NONAME + _ZN23RTestExecutePIPSLogServ8LogExtraEPKhii11TRefByValueIK7TDesC16ESt9__va_list @ 9 NONAME + _ZN23RTestExecutePIPSLogServ8LogExtraEPKhii11TRefByValueIK7TDesC16Ez @ 10 NONAME + _ZN23RTestExecutePIPSLogServ9CreateLogERK7TDesC16 @ 11 NONAME + _ZN23RTestExecutePIPSLogServaSERKS_ @ 12 NONAME ABSENT + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/pipslogger/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/pipslogger/group/bld.inf Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,29 @@ +// +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +PRJ_EXPORTS +..\inc\testexecutepipslog.h \epoc32\include\test\testexecutepipslog.h +..\group\testexecutepipslogger.iby \epoc32\rom\include\testexecutepipslogger.iby +..\group\testexecutepipsloggerclient.iby \epoc32\rom\include\testexecutepipsloggerclient.iby + +PRJ_MMPFILES +testexecutepipslogclient.mmp +testexecutepipslogengine.mmp + + +PRJ_TESTMMPFILES +//..\test\group\testexecutepipsloggertest.mmp + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/pipslogger/group/testexecutepipslogclient.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/pipslogger/group/testexecutepipslogclient.mmp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Using relative paths for sourcepath and user includes +* +*/ +#include + +SMPSAFE + +#include "../../group/testexecute.cfg" + +OS_LAYER_SYSTEMINCLUDE + +TARGET testexecutepipslogclient.dll + +CAPABILITY All +TARGETTYPE dll +UID 0x1000008d 0x10210D4D +VENDORID 0x70000001 + +SOURCEPATH ../src +SOURCE client.cpp + +USERINCLUDE ../src + +LIBRARY euser.lib diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/pipslogger/group/testexecutepipslogengine.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/pipslogger/group/testexecutepipslogengine.mmp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* testexecutepipslogserver.mmp +* Using relative paths for sourcepath and user includes +* +*/ +#include + +SMPSAFE + +TARGET testexecutepipslogengine.exe +CAPABILITY All -Tcb +TARGETTYPE exe +UID 0x100039CE 0x10210D4C +VENDORID 0x70000001 + +OS_LAYER_SYSTEMINCLUDE +OS_LAYER_LIBC_SYSTEMINCLUDE + +SOURCEPATH ../src +SOURCE server.cpp +SOURCE main.cpp + +USERINCLUDE ../src + +LIBRARY euser.lib +LIBRARY efsrv.lib + +LIBRARY libc.lib +STATICLIBRARY libcrt0.lib diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/pipslogger/group/testexecutepipslogger.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/pipslogger/group/testexecutepipslogger.iby Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,23 @@ +// +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#ifndef __TESTEXECUTEPIPS_LOGGER_IBY__ +#define __TESTEXECUTEPIPS_LOGGER_IBY__ + + +file=ABI_DIR\BUILD_DIR\testexecutepipslogengine.exe SHARED_LIB_DIR\testexecutepipslogengine.exe + +#endif diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/pipslogger/group/testexecutepipsloggerclient.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/pipslogger/group/testexecutepipsloggerclient.iby Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,24 @@ +// +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#ifndef __TESTEXECUTEPIPS_LOGGER_CLIENT_IBY__ +#define __TESTEXECUTEPIPS_LOGGER_CLIENT_IBY__ + + +file=ABI_DIR\BUILD_DIR\testexecutepipslogclient.dll SHARED_LIB_DIR\testexecutepipslogclient.dll + + +#endif diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/pipslogger/inc/testexecutepipslog.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/pipslogger/inc/testexecutepipslog.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,118 @@ +/* +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +/** + @file TestExecuteLog.h +*/ + +#if !(defined __TESTEXECUTE_PIPS_LOG_H__) +#define __TESTEXECUTE_PIPS_LOG_H__ + +#include +#include + +_LIT8(KTEFOverflowMessagePIPS8, "\t..Message Truncated"); +_LIT16(KTEFOverflowMessagePIPS16, "\t..Message Truncated"); +//const TInt overflowMessageLen1 = 21; // Size of the truncation message. To be changed if the text above is changed + +/** + @internalComponent + @test + * Derived class implementation of TDes16Overflow class + * Implements the base class pure virtual Overflow() to handle descriptor overflow + * during AppendFormatList() operations on TDes16 objects + */ +class TTEFDes16OverflowPIPS : public TDes16Overflow + { + inline virtual void Overflow(TDes16& aDes) + { + TInt actualMessageLen = aDes.Length(); + TInt maxLengthOfDes = aDes.MaxLength(); + + TInt midPosForEdit = maxLengthOfDes - KTEFOverflowMessagePIPS16().Length(); + if (actualMessageLen <= midPosForEdit) + { + aDes.Append(KTEFOverflowMessagePIPS16()); + } + else + { + aDes.SetLength(midPosForEdit + KTEFOverflowMessagePIPS16().Length()); + aDes.Replace(midPosForEdit, KTEFOverflowMessagePIPS16().Length(), KTEFOverflowMessagePIPS16()); + } + } + }; + +/** + @internalComponent + @test + * Derived class implementation of TDes8Overflow class + * Implements the base class pure virtual Overflow() to handle descriptor overflow + * during AppendFormatList() operations on TDes8 objects + */ +class TTEFDes8OverflowPIPS : public TDes8Overflow + { + inline virtual void Overflow(TDes8& aDes) + { + TInt actualMessageLen = aDes.Length(); + TInt maxLengthOfDes = aDes.MaxLength(); + + TInt midPosForEdit = maxLengthOfDes - KTEFOverflowMessagePIPS8().Length(); + if (actualMessageLen <= midPosForEdit) + { + aDes.Append(KTEFOverflowMessagePIPS8()); + } + else + { + aDes.SetLength(midPosForEdit + KTEFOverflowMessagePIPS8().Length()); + aDes.Replace(midPosForEdit, KTEFOverflowMessagePIPS8().Length(), KTEFOverflowMessagePIPS8()); + } + } + }; + +class RTestExecutePIPSLogServ : public RSessionBase +/** +@internalComponent +@test +*/ + { +public: + enum TLogMode{ELogModeAppend,ELogModeOverWrite}; + // Logging level + enum TLogCommand{/*ECreateLog,*/EWriteLog}; + + IMPORT_C TInt Connect(); + IMPORT_C TInt CreateLog(const TDesC& aLogFilePath); + IMPORT_C void LogExtra(const TText8* aFile, TInt aLine, TInt aSeverity,TRefByValue aFmt,...); + IMPORT_C void Write(const TDesC& aLogBuffer); + IMPORT_C void WriteFormat(TRefByValue aFmt,...); + IMPORT_C void Write(const TDesC8& aLogBuffer); + IMPORT_C void WriteFormat(TRefByValue aFmt,...); + IMPORT_C void LogExtra(const TText8* aFile, TInt aLine, TInt aSeverity,TRefByValue aFmt, VA_LIST aList); + IMPORT_C void WriteFormat(TRefByValue aFmt, VA_LIST aList); + IMPORT_C void WriteFormat(TRefByValue aFmt, VA_LIST aList); + IMPORT_C void SetLogLevel(TLogSeverity aSeverity); +private: + void WriteL(const TDesC& aLogBuffer); + void WriteL(TDes8& aLogBuffer); + void GetCPPModuleName(TDes& aModuleName, const TText8* aCPPFileName); + void AddTime(TDes8& aTime); + TLogSeverity iLogLevel; + TBufC iLogFilename; + }; +#endif diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/pipslogger/src/client.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/pipslogger/src/client.cpp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,366 @@ +/* +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Source file for the client api +* +*/ + + + +/** + @file Client.cpp +*/ +#include + +const TInt KMaxFilename = 50; +// EKA1 requires DLL entry point +EXPORT_C TInt RTestExecutePIPSLogServ::Connect() +/** + * @return int - Standard error codes + * EKA2 all variants and EKA1 target. + * Server is an exe + */ + { + TVersion version(KTestExecuteLoggerMajorVersion,KTestExecuteLoggerMinorVersion,KTestExecuteLoggerBuildVersion); + // Assume the server is already running and attempt to create a session + TInt err = CreateSession(KTestExecutePIPSLogServerName,version,8); + if(err == KErrNotFound) + { + // Server not running + // Construct the server binary name + _LIT(KEmpty,""); + // EKA2 is simple + // No path required + TBuf<32> serverFile; + serverFile.Copy(KTestExecutePIPSLogServerName); + _LIT(KExe,".exe"); + serverFile.Append(KExe); + RProcess server; + err = server.Create(serverFile,KEmpty); + if(err != KErrNone) + return err; + // Synchronise with the server + TRequestStatus reqStatus; + server.Rendezvous(reqStatus); + server.Resume(); + // Server will call the reciprocal static synchronise call + User::WaitForRequest(reqStatus); + server.Close(); + if(reqStatus.Int() != KErrNone) + return reqStatus.Int(); + // Create the root server session + err = CreateSession(KTestExecutePIPSLogServerName,version,8); + } + +#ifdef TEF_SHARE_AUTO + // Makes the session shared among all threads in the process + if( err == KErrNone ) + { + err = ShareAuto(); + } +#endif + + return err; + } + +EXPORT_C TInt RTestExecutePIPSLogServ::CreateLog(const TDesC& aLogFilePath) +/** + * @param aLogFilePath - Full path and filename of the log file + * @param aMode - Overwrite or Append + * Makes synchronous call to the log server to create a log session + */ + { + iLogFilename = aLogFilePath; + return KErrNone; + + } + +EXPORT_C void RTestExecutePIPSLogServ::LogExtra(const TText8* aFile, TInt aLine, TInt aSeverity,TRefByValue aFmt,...) +/** + * @param aFile - Source file name + * @param aLine - Source file line number + * @param aSeverity - ERR, WARN, INFO + * @param aFmt - UNICODE format string + */ + { + if (aSeverity>iLogLevel) + { + return; + } + // Set up a Variable argument list and call private method + VA_LIST aList; + VA_START(aList, aFmt); + LogExtra(aFile, aLine, aSeverity, aFmt, aList); + VA_END(aList); + } + +EXPORT_C void RTestExecutePIPSLogServ::WriteFormat(TRefByValue aFmt,...) +/** + * @param aFmt - UNICODE format string + */ + { + // Set up a Variable argument list and call private method + VA_LIST aList; + VA_START(aList, aFmt); + WriteFormat(aFmt, aList); + VA_END(aList); + } + + +EXPORT_C void RTestExecutePIPSLogServ::Write(const TDesC& aLogBuffer) +/** + * @param aLogBuffer - Pre-formatted UNICODE buffer + */ + { + // Just call private method + // Ignore errors. Could put in ASSERT + TRAP_IGNORE(WriteL(aLogBuffer)); + } + + +EXPORT_C void RTestExecutePIPSLogServ::WriteFormat(TRefByValue aFmt,...) +/** + * @param aFmt - Narrow format string + */ + { + // Set up a Variable argument list and call private method + VA_LIST aList; + VA_START(aList, aFmt); + WriteFormat(aFmt, aList); + VA_END(aList); + } + + +EXPORT_C void RTestExecutePIPSLogServ::Write(const TDesC8& aLogBuffer) +/** + * @param aLogBuffer - Pre-formatted Narrow buffer + */ + { + // Create a larger buffer for adding terminators + // Could do more formatting but just allow for CRLF plus time stamp for the time being + HBufC8* buffer = HBufC8::New(aLogBuffer.Length()+20); + if(buffer) + { + TPtr8 ptr(buffer->Des()); + AddTime(ptr); + ptr.Append(aLogBuffer); + // Ignore error for the time being. Could do an ASSERT + TRAP_IGNORE(WriteL(ptr)); + delete buffer; + } + } + +void RTestExecutePIPSLogServ::AddTime(TDes8& aLogBuffer) +/** + * @param aLogBuffer - the line to be decorated + * decorate the output with current time + */ + + { + TTime now; + now.UniversalTime(); + TDateTime dateTime = now.DateTime(); + _LIT8(KFormat,"%02d:%02d:%02d:%03d "); + // add the current time + aLogBuffer.AppendFormat(KFormat,dateTime.Hour(),dateTime.Minute(),dateTime.Second(),(dateTime.MicroSecond()/1000)); + } + +EXPORT_C void RTestExecutePIPSLogServ::LogExtra(const TText8* aFile, TInt aLine, TInt aSeverity,TRefByValue aFmt, VA_LIST aList) +/** + * @param aFile - Source file name + * @param aLine - Source file line number + * @param aSeverity - ERR, WARN, INFO + * @param aFmt - UNICODE format string + * @param aList - Variable argument list + * + * Format a log output line + */ + { + if (aSeverity>iLogLevel) + { + return; + } + // Create a filename string + TBuf16 fileName; + GetCPPModuleName(fileName, aFile); + // Create a buffer for formatting + HBufC* buffer = HBufC::New(KMaxTestExecuteLogLineLength*2); + if (buffer) + { + TPtr ptr(buffer->Des()); + _LIT(KErr,"ERROR - "); + _LIT(KHigh,"HIGH - "); + _LIT(KWarn,"WARN - "); + _LIT(KMedium,"MEDIUM - "); + _LIT(KInfo,"INFO - "); + _LIT(KLow,"LOW - "); + _LIT(KFormat," %d %S %d "); + if(aSeverity == ESevrErr) + ptr.Append(KErr); + else if(aSeverity == ESevrHigh) + ptr.Append(KHigh); + else if(aSeverity == ESevrWarn) + ptr.Append(KWarn); + else if(aSeverity == ESevrMedium) + ptr.Append(KMedium); + else if (aSeverity == ESevrInfo) + ptr.Append(KInfo); + else if(aSeverity == ESevrLow) + ptr.Append(KLow); + else //if(aSeverity == ESevrAll) + ptr.Append(KInfo); + // Add the thread id + ptr.AppendFormat(KFormat,(TInt)RThread().Id(),&fileName, aLine); + TTEFDes16OverflowPIPS des16OverflowObject; + ptr.AppendFormatList(aFmt, aList, &des16OverflowObject); + + + TRAP_IGNORE(WriteL(ptr)); + delete buffer; + } + } + +EXPORT_C void RTestExecutePIPSLogServ::WriteFormat(TRefByValue aFmt, VA_LIST aList) +/** + * @param aFmt - UNICODE format string + * @param aList - Variable argument list + */ + { + HBufC* buffer = HBufC::New(KMaxTestExecuteLogLineLength*2); + if (buffer) + { + TPtr ptr(buffer->Des()); + TTEFDes16OverflowPIPS des16OverflowObject; + ptr.AppendFormatList(aFmt, aList, &des16OverflowObject); + + TRAP_IGNORE(WriteL(ptr)); + delete buffer; + } + } + +EXPORT_C void RTestExecutePIPSLogServ::WriteFormat(TRefByValue aFmt, VA_LIST aList) +/** + * @param aFmt - UNICODE format string + * @param aList - Variable argument list + */ + { + HBufC8* buffer = HBufC8::New(KMaxTestExecuteLogLineLength*2); + if (buffer) + { + TPtr8 ptr(buffer->Des()); + AddTime(ptr); + TTEFDes8OverflowPIPS des8OverflowObject; + ptr.AppendFormatList(aFmt, aList, &des8OverflowObject); + + TRAP_IGNORE(WriteL(ptr)); + delete buffer; + } + } + +void RTestExecutePIPSLogServ::WriteL(const TDesC& aLogBuffer) +/** + * @param aLogBuffer - UNICODE buffer + */ + { + HBufC8* buffer = HBufC8::NewLC(aLogBuffer.Length()+20); + TPtr8 ptr(buffer->Des()); + AddTime(ptr); + ptr.Append(aLogBuffer); + WriteL(ptr); + + CleanupStack::PopAndDestroy(buffer); + } + +void RTestExecutePIPSLogServ::WriteL(TDes8& aLogBuffer) +/** + * @param aLogBuffer - pre-formatted narrow buffer + * + * Synchronous write to the server + */ + { + //try to make a buf out of pipeName... + + HBufC8* bufferFile = HBufC8::NewL(iLogFilename.Length()); + TPtr8 ptrFile(bufferFile->Des()); + ptrFile.Append(iLogFilename); + + _LIT8(KEnd,"\r\n"); + + TInt retValue = 0 ; + // Check to see if there's room to add CRLF + if(aLogBuffer.Length()+2 > aLogBuffer.MaxLength()) + { + HBufC8* buffer = HBufC8::NewLC(aLogBuffer.Length()+2); + TPtr8 ptr(buffer->Des()); + ptr.Copy(aLogBuffer); + ptr.Append(KEnd); + TIpcArgs args; + args.Set(0,&ptr); + args.Set(1,ptr.Length()); + args.Set(2,&ptrFile); + args.Set(3,iLogFilename.Length()); + + //User::LeaveIfError(SendReceive(EWriteLog,args)); + retValue = SendReceive(EWriteLog,args) ; + CleanupStack::PopAndDestroy(buffer); + } + else + { + aLogBuffer.Append(KEnd); + TIpcArgs args; + args.Set(0,&aLogBuffer); + args.Set(1,aLogBuffer.Length()); + args.Set(2,&ptrFile); + args.Set(3,iLogFilename.Length()); + //User::LeaveIfError(SendReceive(EWriteLog,args)); + retValue = SendReceive(EWriteLog,args) ; + } + delete bufferFile; + User::LeaveIfError(retValue) ; + } + +void RTestExecutePIPSLogServ::GetCPPModuleName(TDes& aModuleName, const TText8* aCPPFileName) +/** + * @return aModuleName - Filename in descriptor + * @param aCppFileName - Filename + * Borrowed from scheduletest + */ + { + TPtrC8 fileNamePtrC8(aCPPFileName); + // We do our own filename munging here; TParse can't help us since that's + // expressly for EPOC filepaths and here we've got whatever the build system is + // At present Win32 and Unix directory delimiters are supported + TInt lastDelimiter = Max(fileNamePtrC8.LocateReverse('\\'), fileNamePtrC8.LocateReverse('/')); + if(lastDelimiter >= 0 && lastDelimiter < fileNamePtrC8.Length() - 1) + { + // Found a delimiter which isn't trailing; update the ptr to start at the next char + TInt fileNameLen = Min(KMaxFilename, fileNamePtrC8.Length() - (lastDelimiter + 1)); + fileNamePtrC8.Set(aCPPFileName + lastDelimiter + 1, fileNameLen); + } + else + { + // Didn't find a delimiter; take as much of the right-end of the name as fits + fileNamePtrC8.Set(aCPPFileName + Max(0, fileNamePtrC8.Length() - KMaxFilename), Min(fileNamePtrC8.Length(), KMaxFilename)); + } + aModuleName.Copy(fileNamePtrC8); + } + +EXPORT_C void RTestExecutePIPSLogServ::SetLogLevel(TLogSeverity aSeverity) +/** + * @return void + * @param aSeverity - severity of the logs + */ + { + iLogLevel = aSeverity; + } diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/pipslogger/src/main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/pipslogger/src/main.cpp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,84 @@ +/* +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Server entry points +* EKA1 & EKA2 +* EKA1 & WINS is a DLL. All others are exe's +* +*/ + + + +/** + @file Main.cpp +*/ +#include +#include "server.h" + +// Emulator EKA1 is the only DLL case +// EKA2 all variats & EKA1 target only +// E32Main calls MainL() +LOCAL_C void MainL() +/** + * Secure variant + * Much simpler, uses the new Rendezvous() call to sync with the client + */ + { + // Leave Platform security hooks in place +#if (defined __DATA_CAGING__) + RProcess().DataCaging(RProcess::EDataCagingOn); + RProcess().SecureApi(RProcess::ESecureApiOn); +#endif + CActiveScheduler* sched=NULL; + sched=new(ELeave) CActiveScheduler; + CActiveScheduler::Install(sched); + CLogServer* server = NULL; + // Create the sever + TRAPD(err,server = CLogServer::NewL()); + if(!err) + { + // Client Synchronisation different for EKA1 and EKA2 + // EKA2 really simple. Client blocks on reciprocal Rendezvous call + RProcess::Rendezvous(KErrNone); + // Go into the Active scheduler + sched->Start(); + // Free the server class + delete server; + } + sched->Stop() ; + delete sched; + } + +//GLDEF_C TInt E32Main() +//this being an OE application we shall use +// the OE provided main signature +int main(int,char**,char* ) +/** + * @return - Standard Epoc error code on process exit + * Process entry point. Called by client using RProcess API + */ + { + __UHEAP_MARK; + CTrapCleanup* cleanup = CTrapCleanup::New(); + if(cleanup == NULL) + { + return KErrNoMemory; + } + TRAP_IGNORE(MainL()); + delete cleanup; + __UHEAP_MARKEND; + return KErrNone; + } + + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/pipslogger/src/server.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/pipslogger/src/server.cpp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,207 @@ +/* +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Main log server engine. +* Process log requests from multiple clients simultaneously. +* +*/ + + + +/** + @file server.cpp +*/ +#include "server.h" +#include +#include + +CLogServer* CLogServer::NewL() +/** + * @return - Instance of the log server + */ + { + CLogServer * server = new (ELeave) CLogServer(); + CleanupStack::PushL(server); + server->ConstructL(); + // CServer base class call + server->StartL(KTestExecutePIPSLogServerName); + CleanupStack::Pop(server); + return server; + } + +void CLogServer::ConstructL() +/** + * Second phase construction + */ + { + } + + +CLogServer::CLogServer() : CServer2(EPriorityStandard,ESharableSessions) +/** + * Constructor + */ + { + } + +CLogServer::~CLogServer() +/** + * Destructor + */ + { + // Close the array of control structures + LogControl().Close(); + //Fs().Close(); + } + + +CSession2* CLogServer::NewSessionL(const TVersion& /*aVersion*/,const RMessage2& /*aMessage*/) const +/** + * @param RMessage - RMessage for the session open + */ + { + // Just create the session + CLogSession* session = new (ELeave) CLogSession(); + return session; + } + +void CLogServer::ControlComplete(CLogSession& aControl) +/** + * @param aControl - Logfile control class reference + * + * Checks to see if this control session can be removed + */ + { + if(aControl.SessionCount()) + return; + + // There are no subsessions mapped to the logfile control class and + // no data buffers on its write queue + // Loop through the server's control array and remove it then delete it + TInt i; + for(i=0;iControlComplete(*this); + } + +void CLogSession::ServiceL(const RMessage2& aMessage) +/** + * @param aMessage - Function and data for the session + */ + { + switch(aMessage.Function()) + { +// case RTestExecutePIPSLogServ::ECreateLog : +// {} + // One of the API write calls + case RTestExecutePIPSLogServ::EWriteLog : + { + // Data can be any size + // Get the length from second argument + TInt bufferLength = aMessage.Int1(); + // Get a heap buffer of the right size + HBufC8* buffer = HBufC8::NewLC(bufferLength); + TPtr8 ptr(buffer->Des()); + // read the data + aMessage.ReadL(0,ptr); + // Get a buffer control class contructed with the heap data + // takes ownership + //CLogBuffer* logBuffer = new (ELeave) CLogBuffer(*buffer); + CleanupStack::Pop(buffer); + //get the name of the pipe we want to dump the logs to + TInt pipeNameLen = aMessage.Int3(); + // Get a heap buffer of the right size + HBufC8* pipebuffer = HBufC8::NewLC(pipeNameLen); + TPtr8 pipePtr(pipebuffer->Des()); + // read the data + aMessage.ReadL(2,pipePtr); + // Get a buffer control class contructed with the heap data + // takes ownership + CleanupStack::Pop(pipebuffer); + + if((iFileDes == -1) || (!iPipeName ) || (iPipeName->CompareF(pipePtr)) ) + { + iPipeName = new TPtr8(pipePtr) ; + //iPipeName.Set(pipePtr) ; + + char arr[KMaxPath]; + int var; + for (var = 0; var < pipePtr.Length(); ++var) { + arr[var]=pipePtr[var]; + } + arr[var]='\0'; + + iFileDes = open( arr, O_WRONLY); + } + + const char *printsomething = (const char *)ptr.Ptr() ; + // incases when the pipe name given was empty / incorrect + // or unavailable for some reason, the open is expected + // to return -1, and then we do nothing + if(iFileDes != -1 ) + { + write(iFileDes , printsomething, bufferLength) ; + aMessage.Complete(KErrNone); + } + else + { + aMessage.Complete(KErrNotFound); + } + // apparently closing the pipe is an issue with named pipes + // so let be for now + //close(aFileDes); + } + break; + + default: + break; + } + } + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/pipslogger/src/server.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/pipslogger/src/server.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +/** + @file Server.h +*/ + +#if (!defined __TESTEXECUTE_PIPS_LOG_SERVER_H__) +#define __TESTEXECUTE_PIPS_LOG_SERVER_H__ +#include +#include +#include + +class CLogSession ; +class CLogServer : public CServer2 + { +public: + static CLogServer* NewL(); + ~CLogServer(); + void ControlComplete(CLogSession& aControl); + + inline RPointerArray& LogControl(); + + CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const; + void SessionClosed(); +private: + CLogServer(); + void ConstructL(); +private: + RPointerArray iControl; + }; + +class CLogSession : public CSession2 + { +public: + inline const CLogServer& LogServer() const; + CLogSession(); + ~CLogSession(); + + void ServiceL(const RMessage2& aMessage); + + inline void AddSession(); + inline void RemoveSession(); + inline TInt SessionCount() const; + +private: + int iFileDes ; + TPtr8* iPipeName; + TInt iSessionCount; + }; + +#include "Server.inl" + +#endif diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/pipslogger/src/server.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/pipslogger/src/server.inl Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +inline void CLogSession::AddSession() + {iSessionCount++;} + +inline void CLogSession::RemoveSession() + {iSessionCount--;} + +inline TInt CLogSession::SessionCount() const + {return iSessionCount;} + +/////// +inline RPointerArray& CLogServer::LogControl() + {return iControl;} + + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/pipslogger/test/group/testexecutepipsloggertest.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/pipslogger/test/group/testexecutepipsloggertest.mmp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Using relative paths for sourcepath and user includes +* +*/ + +SMPSAFE + +TARGET testexecutepipsloggertest.exe +TARGETTYPE exe +UID 0x100039CE 0x101F778D +VENDORID 0x70000001 + +SOURCEPATH ../src +SOURCE testexecutepipsloggertest.cpp + +SYSTEMINCLUDE /epoc32/include +SYSTEMINCLUDE /epoc32/include/test +SYSTEMINCLUDE /epoc32/include/stdapis + +LIBRARY euser.lib +LIBRARY testexecutepipslogclient.lib +LIBRARY libc.lib +STATICLIBRARY libcrt0.lib \ No newline at end of file diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/pipslogger/test/src/testexecutepipsloggertest.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/pipslogger/test/src/testexecutepipsloggertest.cpp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,138 @@ +/* +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Demonstration use of the TestExecute standalone PIPS logger client API +* +*/ + + + +/** + @file TestExecutePIPSLoggerTest.cpp +*/ + +#include +#include +#include +#include +#include +#include + +_LIT(KLogFile1,"c:/pipe_no1"); +_LIT(K16BitText,"This is a short line of 16 Bit Text"); +_LIT8(K8BitText,"This is a short line of 8 Bit Text"); +_LIT(K16BitFormatText,"This is a short line of 16 Bit Format Text int = %d string = %S"); +_LIT8(K8BitFormatText,"This is a short line of 8 Bit Format Text int = %d string = %S"); +_LIT(K16BitString,"The String16"); +_LIT8(K8BitString,"The String8"); + +#define HALF_DUPLEX "c:/pipe_no1" +#define MAX_BUF_SIZE 255 + +void MainL() + { + + /* Create the named - pipe */ + int ret_val = mkfifo(HALF_DUPLEX, S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH); + + if ((ret_val == -1) && (errno != EEXIST)) { + perror("Error creating the named pipe"); + return ; + //exit (1); + } + + int pipe = open(HALF_DUPLEX, O_RDONLY | O_NONBLOCK); + + _LIT(KTitle,"TestExecute Standalone Logger Test Code"); + CConsoleBase* console = Console::NewL(KTitle,TSize(KConsFullScreen,KConsFullScreen)); + CleanupStack::PushL(console); + + _LIT(KMessage1,"Connect() To Logger and Close() immediately\r\n"); + console->Printf(KMessage1); + RTestExecutePIPSLogServ logger; + User::LeaveIfError(logger.Connect()); + logger.Close(); + + _LIT(KMessage2,"Immediate re-Connect() To Logger and Close() immediately\r\n"); + console->Printf(KMessage2); + User::LeaveIfError(logger.Connect()); + logger.Close(); + + _LIT(KMessage3,"Immediate re-Connect() To Logger CreateLog() and Close() immediately\r\n"); + console->Printf(KMessage3); + User::LeaveIfError(logger.Connect()); + User::LeaveIfError(logger.CreateLog(KLogFile1)); + logger.Close(); + + // OS needs time to shutdown the server + // No delay means we get server terminated from the OS + User::After(1000000); + + _LIT(KMessage4,"Connect() To Logger CreateLog() %S Call API's\r\n"); + TBuf<80> logFile(KLogFile1); + console->Printf(KMessage4,&logFile); + User::LeaveIfError(logger.Connect()); + User::LeaveIfError(logger.CreateLog(KLogFile1)); + TBuf<20> buf16(K16BitString); + TBuf8<20> buf8(K8BitString); + logger.Write(K16BitText); + logger.Write(K8BitText); + logger.WriteFormat(K16BitFormatText,16,&buf16); + logger.WriteFormat(K8BitFormatText,8,&buf8); + logger.LogExtra(((TText8*)__FILE__), __LINE__,ESevrInfo,K16BitFormatText,1,&buf16); + + _LIT(KMessage5,"ALL API's Called - Call Close(),\r\n"); + console->Printf(KMessage5); + //console->Getch(); + logger.Close(); + + //try an empty pipe + _LIT(KLogFileEmpty,""); + _LIT(KMessageEmp,"Connect() To Logger CreateLog() %S Call API's\r\n"); + TBuf<80> logFiley(KLogFileEmpty); + console->Printf(KMessageEmp,&logFiley); + User::LeaveIfError(logger.Connect()); + User::LeaveIfError(logger.CreateLog(KLogFileEmpty)); + logger.Write(K16BitText); + logger.Write(K8BitText); + logger.WriteFormat(K16BitFormatText,16,&buf16); + logger.WriteFormat(K8BitFormatText,8,&buf8); + logger.LogExtra(((TText8*)__FILE__), __LINE__,ESevrInfo,K16BitFormatText,1,&buf16); + console->Printf(KMessage5); + console->Getch(); + logger.Close(); + + CleanupStack::PopAndDestroy(console); + + } + +// Entry point for all Epoc32 executables +// See PSP Chapter 2 Getting Started +int main(int,char**,char* ) + { + // Heap balance checking + // See PSP Chapter 6 Error Handling + __UHEAP_MARK; + CTrapCleanup* cleanup = CTrapCleanup::New(); + if(cleanup == NULL) + { + return KErrNoMemory; + } + TRAPD(err,MainL()); + _LIT(KPanic,"PIPSLoggerTest"); + __ASSERT_ALWAYS(!err, User::Panic(KPanic,err)); + delete cleanup; + __UHEAP_MARKEND; + return KErrNone; + } diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/teftestmodule/Bmarm/TEFTestModuleU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/teftestmodule/Bmarm/TEFTestModuleU.DEF Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,4 @@ +EXPORTS + LibEntryL__Fv @ 1 NONAME R3UNUSED ; LibEntryL(void) + SetRequirements__FRP16CTestModuleParamRUl @ 2 NONAME R3UNUSED ; SetRequirements(CTestModuleParam *&, unsigned long &) + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/teftestmodule/Bwins/TEFTestModuleU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/teftestmodule/Bwins/TEFTestModuleU.DEF Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,5 @@ +EXPORTS + ?LibEntryL@@YAPAVCTestModuleBase@@XZ @ 1 NONAME ; class CTestModuleBase * __cdecl LibEntryL(void) + ?SetRequirements@@YAHAAPAVCTestModuleParam@@AAK@Z @ 2 NONAME ; int __cdecl SetRequirements(class CTestModuleParam * &,unsigned long &) + ??1TScriptObject@@UAE@XZ @ 3 NONAME ABSENT ; TScriptObject::~TScriptObject(void) + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/teftestmodule/eabi/TEFTestModuleu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/teftestmodule/eabi/TEFTestModuleu.def Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,20 @@ +EXPORTS + _Z9LibEntryLv @ 1 NONAME + _Z15SetRequirementsRP16CTestModuleParamRm @ 2 NONAME + _ZTI10CTaskTimer @ 3 NONAME + _ZTI12CSyncControl @ 4 NONAME + _ZTI12CTestWatcher @ 5 NONAME + _ZTI13CScriptMaster @ 6 NONAME + _ZTI14CClientControl @ 7 NONAME + _ZTI14CScriptControl @ 8 NONAME + _ZTI15CProgramControl @ 9 NONAME + _ZTI16CTaskControlBase @ 10 NONAME + _ZTV10CTaskTimer @ 11 NONAME + _ZTV12CSyncControl @ 12 NONAME + _ZTV12CTestWatcher @ 13 NONAME + _ZTV13CScriptMaster @ 14 NONAME + _ZTV14CClientControl @ 15 NONAME + _ZTV14CScriptControl @ 16 NONAME + _ZTV15CProgramControl @ 17 NONAME + _ZTV16CTaskControlBase @ 18 NONAME + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/teftestmodule/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/teftestmodule/group/bld.inf Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,61 @@ +// +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +PRJ_PLATFORMS +// specify the platforms your component needs to be built for here +// defaults to WINS MARM so you can ignore this if you just build these + + DEFAULT + +PRJ_TESTEXPORTS +// NOTE: If using ARS requirements all export operations should be done under this. +// 'abld test export' + +PRJ_EXPORTS +// Specify the source file followed by its destination here +// copy will be used to copy the source file to its destination +// If there's no destination then the source file will be copied +// to the same name in \epoc32\include +// Example: +/* +\agnmodel\inc\AGMCOMON.H +*/ + +PRJ_TESTMMPFILES + + teftestmodule.mmp + teftestmodulelite.mmp + +PRJ_MMPFILES + + teftestmodule_nrm.mmp + teftestmodulelite_nrm.mmp + +// Specify the .mmp files required for building the important component +// releasables. +// +// Specify "tidy" if the component you need to build doesn't need to be +// released. Specify "ignore" if the MMP file exists but should be +// ignored. +// Example: +/* +\agnmodel\group\agnmodel.mmp +#if defined(MARM) +\agnmodel\group\agsvexe.mmp +#endif +*/ + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/teftestmodule/group/teftestmodule.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/teftestmodule/group/teftestmodule.mmp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,91 @@ +/* +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: MMP file for STIF Test Framework's Normal test module. +* +*/ + +#include + +SMPSAFE +TARGET TEFTestModule.dll +TARGETTYPE dll +#ifndef _USE_EWSD_ +EPOCALLOWDLLDATA +#endif +UID 0x1000008D 0x101FB3E7 + +CAPABILITY ALL -TCB +/* Remove comments and replace 0x00000000 with correct vendor id */ +// VENDORID 0x00000000 +/* Remove comments and replace 0x00000000 with correct secure id */ +// SECUREID 0x00000000 + + +DEFFILE TEFTestModule.def +//TARGETPATH ?target_path + +USERINCLUDE ../inc +USERINCLUDE ../../utils/inc + +APP_LAYER_SYSTEMINCLUDE + +SOURCEPATH ../src + +SOURCE teftestmodule.cpp +SOURCE scriptengine.cpp +SOURCE testwatcher.cpp + +LIBRARY euser.lib +LIBRARY StifTestInterface.lib +LIBRARY StifTestEngine.lib +LIBRARY testexecuteutils.lib +LIBRARY efsrv.lib +LIBRARY testexecutelogclient.lib +LIBRARY testexecutepipslogclient.lib +LIBRARY iniparser.lib + +#if !defined(TEF_LITE_VERSION) +LIBRARY apparc.lib +LIBRARY apgrfx.lib +LIBRARY domaincli.lib +LIBRARY ws32.lib +#endif + +LANG SC + +/* +START WINS +?wins_specific_information +END + +START MARM +?marm_specific_information +END +*/ +// Other possible keywords: + +// DOCUMENT ?file, that is not compiled, but added to MSVC project workspace (i.e. release notes) +/* +START BITMAP ?target +TARGETPATH ?emulated_path_on_target_machine +HEADER +SOURCEPATH ?source_path +SOURCE ?color_depth ?source_bitmap +END +*/ +// AIF ?filename + + + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/teftestmodule/group/teftestmodule.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/teftestmodule/group/teftestmodule.pkg Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,63 @@ +; +; Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +; Installation file for STIF +; + + + + +; Languages +&EN + +; Provide value for uid +#{"STIF"},(0x00000000),1,1,0,TYPE=SA + +; Series60 product id for S60 3.0 +[0x101F7961], 0, 0, 0, {"Series60ProductID"} + +; Localised Vendor name +%{"Nokia"} + +; Unique Vendor name +:"Nokia" + +; Logo +; None + +; Package signature - Optional +; None + +; Start of Package body + +; Condition blocks +; None + +; Options list +; None + +; Install files +"\epoc32\release\armv5\udeb\TEFTestModule.dll" - "!:\Sys\Bin\TEFTestModule.dll" + +; Embedded SIS +; None + +; End of Package body + +; PKG dependencies +; None + +; PKG capabilities +; None diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/teftestmodule/group/teftestmodule_doxyfile.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/teftestmodule/group/teftestmodule_doxyfile.txt Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,240 @@ +# +# Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# +# + + +# Doxyfile 1.4.1 + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +PROJECT_NAME = TEFTestModule +PROJECT_NUMBER = +OUTPUT_DIRECTORY = V:\workspace\TEFTestModule\ +CREATE_SUBDIRS = NO +OUTPUT_LANGUAGE = English +USE_WINDOWS_ENCODING = YES +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ABBREVIATE_BRIEF = +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = NO +FULL_PATH_NAMES = NO +STRIP_FROM_PATH = +STRIP_FROM_INC_PATH = +SHORT_NAMES = NO +JAVADOC_AUTOBRIEF = NO +MULTILINE_CPP_IS_BRIEF = NO +DETAILS_AT_TOP = NO +INHERIT_DOCS = YES +DISTRIBUTE_GROUP_DOC = NO +TAB_SIZE = 8 +ALIASES = +OPTIMIZE_OUTPUT_FOR_C = YES +OPTIMIZE_OUTPUT_JAVA = NO +SUBGROUPING = YES +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- +EXTRACT_ALL = YES +EXTRACT_PRIVATE = NO +EXTRACT_STATIC = NO +EXTRACT_LOCAL_CLASSES = NO +EXTRACT_LOCAL_METHODS = NO +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = NO +HIDE_FRIEND_COMPOUNDS = NO +HIDE_IN_BODY_DOCS = NO +INTERNAL_DOCS = YES +CASE_SENSE_NAMES = YES +HIDE_SCOPE_NAMES = NO +SHOW_INCLUDE_FILES = YES +INLINE_INFO = YES +SORT_MEMBER_DOCS = YES +SORT_BRIEF_DOCS = NO +SORT_BY_SCOPE_NAME = NO +GENERATE_TODOLIST = NO +GENERATE_TESTLIST = NO +GENERATE_BUGLIST = NO +GENERATE_DEPRECATEDLIST= YES +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +SHOW_USED_FILES = YES +SHOW_DIRECTORIES = YES +FILE_VERSION_FILTER = +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = NO +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_IF_DOC_ERROR = YES +WARN_NO_PARAMDOC = NO +WARN_FORMAT = "$file:$line: $text" +WARN_LOGFILE = +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = V:\workspace\TEFTestModule\ +FILE_PATTERNS = *.h \ + *.rh \ + *.hrh +RECURSIVE = YES +EXCLUDE = +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_PATTERNS = +FILTER_SOURCE_FILES = NO +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = NO +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +REFERENCED_BY_RELATION = YES +REFERENCES_RELATION = YES +VERBATIM_HEADERS = YES +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = NO +COLS_IN_ALPHA_INDEX = 5 +IGNORE_PREFIX = +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = NO +HTML_OUTPUT = html +HTML_FILE_EXTENSION = .html +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_ALIGN_MEMBERS = YES +GENERATE_HTMLHELP = YES +CHM_FILE = +HHC_LOCATION = +GENERATE_CHI = NO +BINARY_TOC = YES +TOC_EXPAND = YES +DISABLE_INDEX = YES +ENUM_VALUES_PER_LINE = 4 +GENERATE_TREEVIEW = YES +TREEVIEW_WIDTH = 250 +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = NO +LATEX_OUTPUT = latex +LATEX_CMD_NAME = latex +MAKEINDEX_CMD_NAME = makeindex +COMPACT_LATEX = NO +PAPER_TYPE = a4wide +EXTRA_PACKAGES = +LATEX_HEADER = +PDF_HYPERLINKS = NO +USE_PDFLATEX = NO +LATEX_BATCHMODE = NO +LATEX_HIDE_INDICES = NO +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = YES +RTF_OUTPUT = Doc +COMPACT_RTF = YES +RTF_HYPERLINKS = YES +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = NO +MAN_OUTPUT = man +MAN_EXTENSION = .3 +MAN_LINKS = NO +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = NO +XML_OUTPUT = xml +XML_SCHEMA = +XML_DTD = +XML_PROGRAMLISTING = YES +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- +GENERATE_AUTOGEN_DEF = NO +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- +GENERATE_PERLMOD = NO +PERLMOD_LATEX = NO +PERLMOD_PRETTY = YES +PERLMOD_MAKEVAR_PREFIX = +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = YES +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = NONSHARABLE_CLASS +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- +TAGFILES = +GENERATE_TAGFILE = +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +PERL_PATH = /usr/bin/perl +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = YES +HIDE_UNDOC_RELATIONS = YES +HAVE_DOT = NO +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +GROUP_GRAPHS = YES +UML_LOOK = NO +TEMPLATE_RELATIONS = YES +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +CALL_GRAPH = NO +GRAPHICAL_HIERARCHY = YES +DIRECTORY_GRAPH = YES +DOT_IMAGE_FORMAT = png +DOT_PATH = +DOTFILE_DIRS = +MAX_DOT_GRAPH_WIDTH = 1024 +MAX_DOT_GRAPH_HEIGHT = 1024 +MAX_DOT_GRAPH_DEPTH = 0 +DOT_TRANSPARENT = NO +DOT_MULTI_TARGETS = NO +GENERATE_LEGEND = YES +DOT_CLEANUP = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- +SEARCHENGINE = NO diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/teftestmodule/group/teftestmodule_nrm.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/teftestmodule/group/teftestmodule_nrm.mmp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,91 @@ +/* +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: MMP file for STIF Test Framework's Normal test module. +* +*/ + +#include + +SMPSAFE +TARGET TEFTestModule.dll +TARGETTYPE dll +#ifndef _USE_EWSD_ +EPOCALLOWDLLDATA +#endif +UID 0x1000008D 0x101FB3E7 + +CAPABILITY ALL -TCB +/* Remove comments and replace 0x00000000 with correct vendor id */ +// VENDORID 0x00000000 +/* Remove comments and replace 0x00000000 with correct secure id */ +// SECUREID 0x00000000 + + +DEFFILE TEFTestModule.def +//TARGETPATH ?target_path + +USERINCLUDE ../inc +USERINCLUDE ../../utils/inc + +APP_LAYER_SYSTEMINCLUDE + +SOURCEPATH ../src + +SOURCE teftestmodule.cpp +SOURCE scriptengine.cpp +SOURCE testwatcher.cpp + +LIBRARY euser.lib +LIBRARY StifTestInterface.lib +LIBRARY StifTestEngine.lib +LIBRARY testexecuteutils.lib +LIBRARY efsrv.lib +LIBRARY testexecutelogclient.lib +LIBRARY testexecutepipslogclient.lib +LIBRARY iniparser.lib + +#if !defined(TEF_LITE_VERSION) +LIBRARY apparc.lib +LIBRARY apgrfx.lib +LIBRARY domaincli.lib +LIBRARY ws32.lib +#endif + +LANG SC + +/* +START WINS +?wins_specific_information +END + +START MARM +?marm_specific_information +END +*/ +// Other possible keywords: + +// DOCUMENT ?file, that is not compiled, but added to MSVC project workspace (i.e. release notes) +/* +START BITMAP ?target +TARGETPATH ?emulated_path_on_target_machine +HEADER +SOURCEPATH ?source_path +SOURCE ?color_depth ?source_bitmap +END +*/ +// AIF ?filename + + + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/teftestmodule/group/teftestmodulelite.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/teftestmodule/group/teftestmodulelite.mmp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,92 @@ +/* +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: MMP file for STIF Test Framework's Normal test module. +* +*/ + +#include "../../Group/testexecutelite.cfg" +#include + +SMPSAFE +TARGET TEFTestModuleLite.dll +TARGETTYPE dll +#ifndef _USE_EWSD_ +EPOCALLOWDLLDATA +#endif +UID 0x1000008D 0x101FB3E7 + +CAPABILITY ALL -TCB +/* Remove comments and replace 0x00000000 with correct vendor id */ +// VENDORID 0x00000000 +/* Remove comments and replace 0x00000000 with correct secure id */ +// SECUREID 0x00000000 + + +DEFFILE TEFTestModule.def +//TARGETPATH ?target_path + +USERINCLUDE ../inc +USERINCLUDE ../../utils/inc + +APP_LAYER_SYSTEMINCLUDE + +SOURCEPATH ../src + +SOURCE teftestmodule.cpp +SOURCE scriptengine.cpp +SOURCE testwatcher.cpp + +LIBRARY euser.lib +LIBRARY StifTestInterface.lib +LIBRARY StifTestEngine.lib +LIBRARY testexecuteutils.lib +LIBRARY efsrv.lib +LIBRARY testexecutelogclient.lib +LIBRARY testexecutepipslogclient.lib +LIBRARY iniparser.lib + +#if !defined(TEF_LITE_VERSION) +LIBRARY apparc.lib +LIBRARY apgrfx.lib +LIBRARY domaincli.lib +LIBRARY ws32.lib +#endif + +LANG SC + +/* +START WINS +?wins_specific_information +END + +START MARM +?marm_specific_information +END +*/ +// Other possible keywords: + +// DOCUMENT ?file, that is not compiled, but added to MSVC project workspace (i.e. release notes) +/* +START BITMAP ?target +TARGETPATH ?emulated_path_on_target_machine +HEADER +SOURCEPATH ?source_path +SOURCE ?color_depth ?source_bitmap +END +*/ +// AIF ?filename + + + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/teftestmodule/group/teftestmodulelite_nrm.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/teftestmodule/group/teftestmodulelite_nrm.mmp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,92 @@ +/* +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: MMP file for STIF Test Framework's Normal test module. +* +*/ + +#include "../../Group/testexecutelite.cfg" +#include + +SMPSAFE +TARGET TEFTestModuleLite.dll +TARGETTYPE dll +#ifndef _USE_EWSD_ +EPOCALLOWDLLDATA +#endif +UID 0x1000008D 0x101FB3E7 + +CAPABILITY ALL -TCB +/* Remove comments and replace 0x00000000 with correct vendor id */ +// VENDORID 0x00000000 +/* Remove comments and replace 0x00000000 with correct secure id */ +// SECUREID 0x00000000 + + +DEFFILE TEFTestModule.def +//TARGETPATH ?target_path + +USERINCLUDE ../inc +USERINCLUDE ../../utils/inc + +APP_LAYER_SYSTEMINCLUDE + +SOURCEPATH ../src + +SOURCE teftestmodule.cpp +SOURCE scriptengine.cpp +SOURCE testwatcher.cpp + +LIBRARY euser.lib +LIBRARY StifTestInterface.lib +LIBRARY StifTestEngine.lib +LIBRARY testexecuteutils.lib +LIBRARY efsrv.lib +LIBRARY testexecutelogclient.lib +LIBRARY testexecutepipslogclient.lib +LIBRARY iniparser.lib + +#if !defined(TEF_LITE_VERSION) +LIBRARY apparc.lib +LIBRARY apgrfx.lib +LIBRARY domaincli.lib +LIBRARY ws32.lib +#endif + +LANG SC + +/* +START WINS +?wins_specific_information +END + +START MARM +?marm_specific_information +END +*/ +// Other possible keywords: + +// DOCUMENT ?file, that is not compiled, but added to MSVC project workspace (i.e. release notes) +/* +START BITMAP ?target +TARGETPATH ?emulated_path_on_target_machine +HEADER +SOURCEPATH ?source_path +SOURCE ?color_depth ?source_bitmap +END +*/ +// AIF ?filename + + + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/teftestmodule/inc/logging.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/teftestmodule/inc/logging.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef LOGGINGDEFS_H +#define LOGGINGDEFS_H + +// INCLUDES +#include +#include + +// CONSTANTS +const TUint KError = 0x1; +const TUint KInit = 0x2; +const TUint KVerbose = 0x4; +const TUint KAlways = 0xFFFFFFFF; +const TUint KDebugLevel = ( KInit | KError ); + +// MACROS +#define __TRACING_ENABLED + +// Define USE_LOGGER to use logger for logging +#define USE_LOGGER + +#ifdef __TRACING_ENABLED + + // Disable conditional expression is constant -warning + #pragma warning( disable : 4127 ) + + // Using logger + #if defined (USE_LOGGER) + #define __TRACE(level,p) if ( (level) & KDebugLevel) { LOGGER->Log p; } + #else + #define __TRACE(level,p); + #endif + + #define __RDEBUG(x) if( KVerbose & KDebugLevel){ RDebug::Print x ; } + +#else + // No tracing + #define __TRACE(level,p); + + #define __RDEBUG(x) + +#endif + +// DATA TYPES + +// FUNCTION PROTOTYPES + +// FORWARD DECLARATIONS + +// CLASS DECLARATION + +#endif // LOGGINGDEFS_H + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/teftestmodule/inc/scriptengine.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/teftestmodule/inc/scriptengine.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,477 @@ +/* +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +/** + @file ScriptEngine.h +*/ + +#if !(defined __SCRIPT_ENGINE_H__) +#define __SCRIPT_ENGINE_H__ + +#include +#include +#include "testexecutestepbase.h" +#include +#if !(defined TEF_LITE) +#include +#include +#endif +#include +#include +#include +#include "tefconst.h" +#include "blockitems.h" + +#define SUB_PROC_TYPE RProcess + +/** + * Define flogger based class that can also be used to log to console + */ +class RConsoleLogger + { +public: + RConsoleLogger(CConsoleBase& aConsole) : iConsole(aConsole) {}; + inline CConsoleBase& Console() const; +private: + CConsoleBase& iConsole; + }; + +class CActiveBase; +class MChildCompletion + { +public: + virtual void ChildCompletion(TInt aError) = 0; + }; + +class RScriptTestServ : public RTestServ + { +friend class RScriptTestSession; +public: + inline RScriptTestServ(); + TInt Connect(const TDesC& aServerName,TBool aSharedData = EFalse); + inline TBool SharedData() const; + inline TInt SessionCount() const; +private: + inline void AddSession(); + inline void RemoveSession(); +private: + TBool iSharedData; + TBool iSessionCount; + }; + +class RScriptTestSession : public RTestSession + { +public: + TInt Open(RScriptTestServ& aServ, const TBool aIsTestStep, const TDesC& aStepName = KNull ); + inline void Close(); +protected: + RScriptTestServ* iServ; +private: + }; + +class CActiveBase : public CActive + { +public: + inline void Kick(); + inline virtual ~CActiveBase(); +protected: + inline void Prime(); + inline void Complete(TInt aErr); + inline CActiveBase(); + }; + +class CScriptActive : public CActiveBase, public MChildCompletion + { +public: + inline virtual ~CScriptActive(); + inline virtual void ChildCompletion(TInt aErr); +protected: + inline CScriptActive(); + }; + + +class MTaskCompletion + { +public: + virtual void TaskCompletion(TInt aErr, const TDesC& aPanicString, TInt aScriptLineNumber,const TDesC& aCommand,TBool aTaskCanComplete,TTEFItemArray* aItemArray=NULL) = 0; + }; + +class TRange + { +public : + enum EState + { + EStateNotUsed, + EStateInUse, + EStateUsed, + }; + + TRange(TPtrC aStartTestCase,TPtrC aEndTestCase ): + iStartTestCase (aStartTestCase), + iEndTestCase (aEndTestCase ), + iState (EStateNotUsed) + {}; + + //some utility methods + static TBool CompareTRangeEnd(const TRange& aRng1, const TRange& aRng2) ; + static TBool CompareTRangeStartCase(const TRange& aRng1, const TRange& aRng2) ; + static TInt CompareTRangeStartOrder(const TRange& aRng1, const TRange& aRng2) ; + +public : + TPtrC iStartTestCase ; + TPtrC iEndTestCase ; + EState iState ; + + }; + +enum ESelectiveTesting + { + iInclusive =0 , + iExclusive + }; + +class TSelectiveTestingOptions + { +public : + TSelectiveTestingOptions(RArray& aSelectiveCaseRange,ESelectiveTesting& aSelectiveTestingType ) + :iSelectiveCaseRange(aSelectiveCaseRange), + iSelectiveTestingType(aSelectiveTestingType) + {}; + + //some utility methods... + static TBool CompareTPtrC(const TPtrC& aPtrC1, const TPtrC& aPtrC2); + static TInt CompareTPtrCOrder(const TPtrC& aPtrC1, const TPtrC& aPtrC2) ; + + TSelectiveTestingOptions::~TSelectiveTestingOptions() + {iSelectiveCaseRange.Close();}; + + +public : + RArray iSelectiveCaseRange; + ESelectiveTesting iSelectiveTestingType; + }; + +class CScriptMaster : public CScriptActive + { +public: + CScriptMaster(const TDesC& aScriptFilePath, CTestExecuteLogger& aLogger, RConsoleLogger& aConsoleLogger, const TDriveName& aSysDrive, const TDriveName& aTestSysDrive, TSelectiveTestingOptions* aSelTestingOptions = NULL ); + virtual ~CScriptMaster(); + void RunL(); + inline void DoCancel(); +private: + inline CTestExecuteLogger& Logger() const; + inline RConsoleLogger& ConsoleLogger() const; +private: + enum TState{EInit,ERunning}; + TState iState; + TPtrC iScriptFilePath; + CTestExecuteLogger& iLogger; + RConsoleLogger& iConsoleLogger; + TBool iLoop; + TBool iStartLooping; + TDriveName iDefaultSysDrive; + TDriveName iTestSysDrive; + TSelectiveTestingOptions* iSelTestingOptions; + }; + +class CSyncControl; +class CScriptControl : public CScriptActive, public MTaskCompletion + { +public: + CScriptControl(MChildCompletion& aCompletion,const TDesC& aScriptFilePath,CTestExecuteLogger& aLogger,RConsoleLogger& aConsoleLogger,TBool aStartLooping,TBool aLoop, const TDriveName& aSysDrive, const TDriveName& aTestSysDrive, TSelectiveTestingOptions* aSelTestingOptions = NULL); + virtual ~CScriptControl(); + virtual void TaskCompletion(TInt aErr, const TDesC& aPanicString, TInt aScriptLineNumber, const TDesC& aCommand, TBool aTaskCanComplete, TTEFItemArray* aItemArray = NULL); + void RunL(); + inline void DoCancel(); +private: + void PrintFromScriptLine() const; + void LogTestCaseMarkerL(); + TVerdict HasTestCasePassedL(TPtrC TestCaseMarker); + void PrintCurrentScriptLine() const; + void SetPrefix(); + TBool GetNextScriptLine(TPtrC& aScriptLine); + TBool GetLoopScriptLine(TPtrC& aScriptLine); + void CreateScriptDataFromScriptFileL(); + void CreateServerFromScriptLineL(); + TBool GetServerIndexFromScriptLine(TInt& aIndex); + void RunUtilsFromScriptLineL() const; + void GetScriptFileFromScriptLine(); + void RunCedFromScriptLineL(); + void StartTimerFromScriptLine(); + void LogResult(TVerdict aResult, const TDesC& aPanicString, TInt aScriptLineNumber, const TDesC& aCommand); + inline CTestExecuteLogger& Logger() const; + inline RConsoleLogger& ConsoleLogger() const; + void PrintScriptEngineError(TInt aErr) const; + TBool CheckValidScriptLine() const; + TBool CheckCommentedCommands() const; + void FindValueL(CIniData* aConfigData, TPtrC aConfigSection, TPtrC aSharedData, TInt& aSharedDataNum); + void FindValueL(CIniData* aConfigData, TPtrC aConfigSection, TPtrC aSharedData, TPtrC& aSharedDataName); + void CreateSharedObjectsFromScriptLineL(); + void ParseTestBlockL( TTEFItemArray& aItemArray ); + void MakeAbsoluteFilePathsL(TPtrC16& aScriptLineString); + void ConvertRelativeToAbsoluteL(TDes& aCommandString); + TInt RunError(TInt aError); + void ExpandVariables(TDes& aCommandString); + TBool ProceedTestCase() ; + void ProcessEndCase(); + // Fix defect 118337 + TBool ParseTestBlockHeader(); + // End defect 118337 +private: + enum TState{ + EInit, + ERunning, + EClosing, + ERunCedPending, + ERunCed, + ERunScriptPending, + ERunScript, + EDelayPending, + EPausePending, + EPause, + EEndTestCasePending, + ERunEndTestCase, + ERunStartSyncTestCase, + EPrefixPending, + ERunPrefix, + EDelay, + EIdling, + EWaitCompletions, + ETestCaseIgnore + }; + TPtrC iScriptFile; + RTimer iTimer; + TState iState; + HBufC* iScriptData; + TLex iScriptLex; + MChildCompletion& iParent; + TPtrC iCurrentScriptLine; + TBuf iScriptLinePrefix; + TBuf iPrefixedCurrentScriptLine; + TBool iConcurrent; + TBool iCanComplete; + TBool iBreakOnError; + TInt iAsyncTasksOutstanding; + RPointerArray iServers; + TInt iCurrentScriptLineNumber; + CTestExecuteLogger& iLogger; + RConsoleLogger& iConsoleLogger; + TPtrC iChildScriptFile; + RFs iFS; + RFile iResultFile; + TBool iScriptLinePrefixSet; + TLex iTempStoreLoop; + TLex iStoreLoop; + TBool iStartLooping; + TInt iLoopCounter; + TBool iCheckVar; + TInt iRepeatParam; + TBool iLoop; + CTEFSharedData* iSharedDataArray[KTEFMaxSharedArraySize]; + TInt iSharedDataNum; + TBool iIsSharedData; + CSyncControl* iSyncControl; + // Fix defect 119337. Change static TBool value to TInt value + // This value shows the nested count when call RUN_SCRIPT in loop + static TInt iNestedNumRunScriptInLoop; + // End defect 119337 + TBuf iTestCaseID; + TBuf iAlteredScriptLine; + TDriveName iDefaultSysDrive; + TDriveName iTestSysDrive; + TSelectiveTestingOptions* iSelTestingOptions; + TBool iSelectOne; + TInt iRangeRefCounter; + TInt iTestCaseCounter; + TPtrC iTestCaseIDToIgnore ; +public: + static TInt commentedCommandsCount; + static TInt iRunScriptFailCount; + }; + +class MTaskTimerCompletion + { +public: + virtual void TaskTimerCompletion() =0; + }; + +class CTaskTimer : public CTimer + { +public: + static CTaskTimer* NewL(MTaskTimerCompletion& aCompletion); + ~CTaskTimer(); + void RunL(); + void Timeout(TInt aSeconds); +private: + CTaskTimer(MTaskTimerCompletion& aCompletion); + void RunTimeout(); + inline void ConstructL(); +private: + MTaskTimerCompletion& iParent; + TInt iTimesAfter; + TInt iSecondsRemaining; + }; + +const TInt KDefaultTimeoutSeconds = 120; +const TInt KDefaultDelayMilliseconds = 5000; +const TInt KTEFStatusDelay = 2000; + + +class CTaskControlBase : public CActiveBase , public MTaskTimerCompletion + { +public: + inline void SetTaskComplete(TBool aTaskCanComplete); +protected: + CTaskControlBase(const TDesC& aCommand, MTaskCompletion& aCompletion,TInt aScriptLineNumber, CTestExecuteLogger& aLogger); + virtual ~CTaskControlBase(); + inline const CTestExecuteLogger& Logger() const; +private: +protected: + TBuf iCommandLine; + MTaskCompletion& iParent; + TInt iScriptLineNumber; + CTestExecuteLogger& iLogger; + CTaskTimer* iTaskTimer; + TInt iTaskTimeout; + TBuf iTaskExitCategory; + TBool iTaskCanComplete; +private: + }; + +class CClientControl : public CTaskControlBase + { +public: + CClientControl( RScriptTestServ& aTestServ, + const TDesC& aStepCommand, + MTaskCompletion& aCompletion, + TInt aScriptLineNumber, + CTestExecuteLogger& aLogger, + TInt aLoopIndex, + const TDesC& aTestCaseID, + TPtrC& aScriptFilePath, + const TDriveName& aSysDrive, + const TDriveName& aTestSysDrive); + + static CClientControl* NewL( RScriptTestServ& aTestServ, + const TDesC& aCommand, + MTaskCompletion& aCompletion, + TInt aScriptLineNumber, + CTestExecuteLogger& aLogger, + TInt aLoopIndex, + const TDesC& aTestCaseID, + const TDesC& aEndBlockCommand, + TPtrC& aScriptFilePath, + const TTEFItemArray& aBlockArray, + const TDriveName& aSysDrive, + const TDriveName& aTestSysDrive); + + virtual void TaskTimerCompletion(); + virtual ~CClientControl(); + void RunL(); + inline void DoCancel(); +private: + void GetStepParamsFromStepCommand(); + void ConstructL( const TDesC& aEndBlockCommand, const TTEFItemArray& aBlockArray ); + TTEFItemArray* CreateBlockArrayLC(); + TInt RunError(TInt aError); + void TestStepComplete(); + +private: + enum TState + { + EInit = 0, + ERunning, + EServerRetry + }; + + TPtrC iEndBlockCommand; + TState iState; + RScriptTestServ& iServ; + TBuf iStepArgs; + TPtrC iStepName; + RScriptTestSession iSession; + RTimer iTimer; + TInt iRetryCount; + TPtrC iTaskHeapSize; + TBool iOOMRequestSet; + TBuf iSetUpParamValue; + TInt iLoopIndex; + TBuf iTestCaseID; + HBufC8* iBlockArrayPkg; + TPtr8 iBlockArrayPtr; + TPtrC iScriptFilePath; + TDriveName iDefaultSysDrive; + TDriveName iTestSysDrive; + }; + +class CProgramControl : public CTaskControlBase + { +public: + virtual void TaskTimerCompletion(); + CProgramControl(const TDesC& aCommand,MTaskCompletion& aCompletion,TInt aScriptLineNumber, CTestExecuteLogger& aLogger, TBool aWSProgRun=EFalse); + ~CProgramControl(); + void RunL(); + inline void DoCancel(); +private: + void GetProgramArgsFromCommand(); + void RunProgramL(); + #if !defined TEF_LITE + bool IsWindowServerAvailable(void) const; + #endif +private: + SUB_PROC_TYPE iProgram; + TPtrC iProgramArgs; + TBool iProgRenamed; + enum TState{EInit,ERunning}; + TState iState; + TBool iWSProgRun; + #if !defined TEF_LITE + RThread iProgramWS; // Specific for EKA2 with a Window Server available + RApaLsSession iApaLsSess; + RWsSession iWs; + #endif + }; + +#if !defined TEF_LITE +inline bool CProgramControl::IsWindowServerAvailable(void) const +{ + return (0 != iWs.WsHandle()); +} +#endif +class CSyncControl : public CBase + { +public: + CSyncControl(); + ~CSyncControl(); + + static CSyncControl* NewL(); + static CSyncControl* NewLC(); + + void SetResultL( TVerdict aError ); + TBool TestCaseContinueL(); + +private: + void ConstructL(); + + CTEFSharedData* iSharedTEFStatus; + CTEFSharedData* iSharedTEFResult; + }; + +#include "ScriptEngine.inl" +#endif diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/teftestmodule/inc/scriptengine.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/teftestmodule/inc/scriptengine.inl Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,156 @@ +/* +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +inline CConsoleBase& RConsoleLogger::Console() const + {return iConsole;} + +/////// + +inline RScriptTestServ::RScriptTestServ() : iSharedData(EFalse), iSessionCount(0) + {} + +inline TBool RScriptTestServ::SharedData() const + {return iSharedData;} + +inline TInt RScriptTestServ::SessionCount() const + {return iSessionCount;} + +inline void RScriptTestServ::AddSession() + {iSessionCount++;} + +inline void RScriptTestServ::RemoveSession() + {iSessionCount--;} + +/////// + +inline void RScriptTestSession::Close() + { + iServ->RemoveSession(); + RTestSession::Close(); + } + +/////// + +inline CActiveBase::CActiveBase() : CActive(EPriorityStandard) + {CActiveScheduler::Add(this);} + +/** + * Abstract class methods for priming, kicking and completing active objects. + */ +inline void CActiveBase::Kick() +/** + * Self Kick an active object into its RunL() + */ + { + Prime(); + Complete(KErrNone); + } + +inline void CActiveBase::Prime() +/** + * Self Prime an Active Object for completion + */ + { + iStatus = KRequestPending; + if(!IsActive()) + SetActive(); + } + +inline void CActiveBase::Complete(TInt aErr) +/** + * @param aErr - Error code to complete the Active Object + * + * Self Complete an Active Object + */ + { + TRequestStatus* status = &iStatus; + User::RequestComplete(status,aErr); + } + + +inline CActiveBase::~CActiveBase() + {} + +/////// +inline void CScriptActive::ChildCompletion(TInt aErr) +/** + * @param aErr - Error code to complete the Active Object + * @param aChild - Child object whose work is done + * Callback from the child. + * Self complete. + */ + { + Complete(aErr); + } + +inline CScriptActive::~CScriptActive() + {} + +inline CScriptActive::CScriptActive() + {} + +/////// + +inline CTestExecuteLogger& CScriptMaster::Logger() const + {return iLogger;} + +inline RConsoleLogger& CScriptMaster::ConsoleLogger() const + {return iConsoleLogger;} + +inline void CScriptMaster::DoCancel() + {} + +/////// +inline CTestExecuteLogger& CScriptControl::Logger() const + {return iLogger;} + +inline RConsoleLogger& CScriptControl::ConsoleLogger() const + {return iConsoleLogger;} + +inline void CScriptControl::DoCancel() + {} + +/////// + +inline void CTaskTimer::ConstructL() + {CTimer::ConstructL();} + +/////// + +inline const CTestExecuteLogger& CTaskControlBase::Logger() const + {return iLogger;} + +inline void CTaskControlBase::SetTaskComplete(TBool aTaskCanComplete) + { + iTaskCanComplete = aTaskCanComplete; + } + +/////// + +void CClientControl::DoCancel() + {} + +/////// + +void CProgramControl::DoCancel() + {} + +/////// + diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/teftestmodule/inc/teftestmodule.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/teftestmodule/inc/teftestmodule.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,353 @@ +/* +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef TEFTESTMODULE_H +#define TEFTESTMODULE_H + +// INCLUDES +#include "stiftestmodule.h" +#include +#include + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def +#define TEST_MODULE_VERSION_MAJOR 0 +#define TEST_MODULE_VERSION_MINOR 0 +#define TEST_MODULE_VERSION_BUILD 0 + +// Logging path +_LIT( KTEFTestModuleLogPath, "\\logs\\testframework\\TEFTestModule\\" ); +// Log file +_LIT( KTEFTestModuleLogFile, "TEFTestModule.txt" ); +_LIT( KTEFTestModuleLogFileWithTitle, "TEFTestModule_[%S].txt" ); + +typedef TBuf<200> TScriptName; +typedef TBuf<200> TTcsName; + +// DATA TYPES +//enum ?declaration +//typedef ?declaration +//extern ?data_type; + +// FUNCTION PROTOTYPES +//?type ?function_name(?arg_list); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; + +// CLASS DECLARATION + +/** +* This a TEFTestModule class. +* ?other_description_lines +* +* @lib ?library +* @since ?Series60_version +*/ +NONSHARABLE_CLASS(CTEFTestModule) : public CTestModuleBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CTEFTestModule* NewL(); + + /** + * Destructor. + */ + virtual ~CTEFTestModule(); + + public: // New functions + + /** + * ?member_description. + * @since ?Series60_version + * @param ?arg1 ?description + * @return ?description + */ + //?type ?member_function( ?type ?arg1 ); + + public: // Functions from base classes + + /** + * From CTestModuleBase InitL is used to initialize the TEFTestModule. + * It is called once for every instance of TEFTestModule after + * its creation. + * @since ?Series60_version + * @param aIniFile Initialization file for the test module (optional) + * @param aFirstTime Flag is true when InitL is executed for first + * created instance of TEFTestModule. + * @return Symbian OS error code + */ + TInt InitL( TFileName& aIniFile, TBool aFirstTime ); + + /** + * From CTestModuleBase GetTestCasesL is used to inquiry test cases + * from TEFTestModule. + * @since ?Series60_version + * @param aTestCaseFile Test case file (optional) + * @param aTestCases Array of TestCases returned to test framework + * @return Symbian OS error code + */ + TInt GetTestCasesL( const TFileName& aTestCaseFile, + RPointerArray& aTestCases ); + + /** + * From CTestModuleBase RunTestCaseL is used to run an individual + * test case. + * @since ?Series60_version + * @param aCaseNumber Test case number + * @param aTestCaseFile Test case file (optional) + * @param aResult Test case result returned to test framework (PASS/FAIL) + * @return Symbian OS error code (test case execution error, which is + * not reported in aResult parameter as test case failure). + */ + TInt RunTestCaseL( const TInt aCaseNumber, + const TFileName& aTestCaseFile, + TTestResult& aResult ); + + /** + * From CTestModuleBase; OOMTestQueryL is used to specify is particular + * test case going to be executed using OOM conditions + * @param aTestCaseFile Test case file (optional) + * @param aCaseNumber Test case number (optional) + * @param aFailureType OOM failure type (optional) + * @param aFirstMemFailure The first heap memory allocation failure value (optional) + * @param aLastMemFailure The last heap memory allocation failure value (optional) + * @return TBool + */ + virtual TBool OOMTestQueryL( const TFileName& /* aTestCaseFile */, + const TInt /* aCaseNumber */, + TOOMFailureType& /* aFailureType */, + TInt& /* aFirstMemFailure */, + TInt& /* aLastMemFailure */ ); + + /** + * From CTestModuleBase; User may add implementation for OOM test + * environment initialization. Usually no implementation is required. + * @param aTestCaseFile Test case file (optional) + * @param aCaseNumber Test case number (optional) + * @return None + */ + virtual void OOMTestInitializeL( const TFileName& /* aTestCaseFile */, + const TInt /* aCaseNumber */ ); + + /** + * From CTestModuleBase; OOMHandleWarningL. User may add implementation + * for OOM test warning handling. Usually no implementation is required. + * @param aTestCaseFile Test case file (optional) + * @param aCaseNumber Test case number (optional) + * @param aFailNextValue FailNextValue for OOM test execution (optional) + * @return None + */ + virtual void OOMHandleWarningL( const TFileName& /* aTestCaseFile */, + const TInt /* aCaseNumber */, + TInt& /* aFailNextValue */); + + /** + * From CTestModuleBase; OOMTestFinalizeL may be used to finalize OOM + * test environment. Usually no implementation is required. + * @param aTestCaseFile Test case file (optional) + * @param aCaseNumber Test case number (optional) + * @return None + */ + virtual void OOMTestFinalizeL( const TFileName& /* aTestCaseFile */, + const TInt /* aCaseNumber */ ); + + /** + * Method used to log version of test module + */ + void SendTestModuleVersion(); + + /** + * Get stack size set by user, in TestFramework.ini + */ + static TInt ParseStackSizeL(TInt& aStackSize); + + + protected: // New functions + + /** + * ?member_description. + * @since ?Series60_version + * @param ?arg1 ?description + * @return ?description + */ + //?type ?member_function( ?type ?arg1 ); + + protected: // Functions from base classes + + /** + * From ?base_class ?member_description + */ + //?type ?member_function(); + + private: + + /** + * C++ default constructor. + */ + CTEFTestModule(); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + /** + * Read the Cfg File data into a heap buffer + * And populate the arrays of selective test case IDs and + * Ranges to be used by the state machine + * NOTE: we do not support nested cfgs... + */ + void CreateTitleLoggerL(void); + + /** + * Check for logger settings and delete title logger. + */ + void DeleteTitleLogger(void); + + // Prohibit copy constructor if not deriving from CBase. + // ?classname( const ?classname& ); + // Prohibit assigment operator if not deriving from CBase. + // ?classname& operator=( const ?classname& ); + + /** + * Load and wait to start, only used under Non-Lite version. + */ + + #if !(defined TEF_LITE) + void StartSystemL(void); + #endif + + + /** + * Initialization. + */ + void TEFInitialize(void); + + /** + * Parse configuration file to get config information and script list. + */ + TInt ParseTEFTestCfgFileL(const TFileName& aConfigFile, RPointerArray& aTestCases); + + /** + * Execute sigle script. + */ + TInt RunScriptL(CActiveScheduler* aScheduler, const TScriptName& aScriptFilePath, const TTcsName& aTcsData); + + /** + * Read Testexecute.ini to get configuration, otherwise use a default config. + */ + void CreateCfgDataFromFileL(TPtrC& aCfgFilePath, RArray& aSelectiveCaseRange, TDesC*& aSelTestCfgFileData); + + /** + * Get elements from configuration file. + */ + void DistinguishElement(const TPtrC& aElement, RArray& aSelectiveCaseRange); + + + /** + * Parse TcsData from configration file to select test case flag. Get cases Included or Excluded. + */ + void ParseTcsDataForSelectiveTestingOptions( const TTcsName& aTcsData, + CTestExecuteIniData& aParseTestExecuteIni, + RArray& aSelectiveCaseRange, + TDesC*& aSelTestCfgFileData ); + + + /** + * Add script full name(c:/xx/xxx.script) to iScriptFileNames, add cases based on script. + */ + TInt MatchScriptsToCasesL(const TScriptName& aSscriptFile, TInt aScriptCount, RPointerArray& aTestCases); + + + public: // Data + // ?one_line_short_description_of_data + //?data_declaration; + + protected: // Data + // ?one_line_short_description_of_data + //?data_declaration; + + private: // Data + // ?one_line_short_description_of_data + //?data_declaration; + + CStifLogger * iLog; + + // Standard logger + CStifLogger *iStdLog; + + // Logger for currently running test case + CStifLogger *iTCLog; + + // Flag saying if test case title should be added to log file name + TBool iAddTestCaseTitleToLogName; + + // Flag saying if test module version was already sent + TBool iVersionLogged; + + // Reserved pointer for future extension + //TAny* iReserved; + + //For iCfg_tcs + enum TCfgTcs + { + EInclude, + EExclude, + EOFF + }; + + //For Tcs in configration file + TCfgTcs iCfg_tcs; + + //For Debug in configration file + TBool iCfg_Debug; + + //For SeparateLog in configration file + TBool iCfg_SeparateLog; + + //For Pipe in configration file + TName iCfg_Pipe; + + //Store script full name(with path), such as c:/xxxx/xxxx.script + //This array's sequence is same as test cases. + RPointerArray iArray_ScriptFilePaths; + + //Store TcsData in configration file, TcsData is paired with Script. + RPointerArray iArray_Cfg_TcsData; + + //System drive name + TDriveName iDefaultSysDrive; + + public: // Friend classes + //?friend_class_declaration; + protected: // Friend classes + //?friend_class_declaration; + private: // Friend classes + //?friend_class_declaration; + + }; + +#endif // TEFTESTMODULE_H + +// End of File diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/teftestmodule/inc/testwatcher.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/teftestmodule/inc/testwatcher.h Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +/** + @file TestWatcher.h +*/ + +#if !(defined __TEST_WATCHER_H__) +#define __TEST_WATCHER_H__ + +#include +#include + +///////// +// Remote Panic Detection +//////// +class TThreadPanicDetails + { +public: + TThreadPanicDetails(TName aThreadName, TInt aReason, TExitCategoryName aCategory, TTime aTime); + TName iThreadName; + TInt iReason; + TExitCategoryName iCategory; + TTime iTime; + }; + +/** Provides access to shared data between the threads. Because of the nature of construction + * it is too complicated to generate mutexes, and as such you MUST NOT + * use this class inside TestWatcher whilst the UndertakerWatcher thread is running. + * Kill it before you access this data, and construct the object before that thread + * is running. YHBW. + */ +class CSharedData : public CBase + { +public: + RPointerArray iPanicDetails; + }; + +class CTestWatcher : public CBase + { +public: + CTestWatcher(); + ~CTestWatcher(); + void ConstructL(); + void StartL(); + void Stop(); + static CTestWatcher* NewL(); + CSharedData* iSharedData; +private: + RThread iWorker; + }; + +#endif diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/teftestmodule/src/scriptengine.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/teftestmodule/src/scriptengine.cpp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,4076 @@ +/* +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Design Overview: +* The diagram below shows the Script Engine classes and their parent child +* hierarchy. All classes have a CActive base, and apart from CTaskTimer, all classes +* have their own state machine. Apart from CScriptMaster, all classes have a reference +* to a Mixin/Interface completion call of its parent, which it calls when the object +* needs to notify the parent of an event. +* CScriptMaster (derived CActive) +* CScriptControl (derived CActiveBase - Can go recursive) +* CProgramControl (derived CTaskControlBase) CClientControl ( derived CTaskControlBase maps to n x test steps) +* CTaskTimer CTaskTimer (derived CTimer) +* state transition tables for CScriptMaster, CScriptControl & CClientControl +* CActiveBase: +* Derives CActive. +* Contains code for priming, triggering and completing AO's +* Implements the pure abstract MChildCompletion::ChildCompletion() method +* CTaskControlBase: +* Derives CActiveBase. +* Abstract class. Base for CClientControl and CProgramControl. +* CScriptMaster: +* Derives CActiveBase. +* Master control active object with simple state machine. +* Instantiates the top level CScriptControl object and triggers its state machine. +* CScriptContol: +* Derives CActiveBase. +* Main script interpreter state machine. Creates one or more CClientControl and/or +* CProgramControl objects. +* In CONCURRENT mode, it can create as many instances as there are RUN_TEST_STEP and/or +* RUN_PROGRAM calls. +* Creates root sessions with the xxxtest servers using the RTestServ::Connect() client call. +* In the case of non-nested scripts, the parent object is CScriptMaster. +* When scripts are nested and it goes recursive, the parent object could be another +* CScriptControl. +* Implements the MTaskCompletion pure abstract class for callbacks from +* CClientControl or CProgramControl objects +* Calls back into its parent object when the script is complete and all async commands have +* completed. +* CClientControl: +* Derives CTaskControlBase. +* Test Step Controler. Instantiated by CScriptControl when a RUN_TEST_STEP line is interpreted +* Creates and kicks off a CTaskTimer object set to the timeout value for the test step. +* Opens a test step using the RTestSession::Open() client call. +* Executes a test step using the RTestSession::RunTestStep() client call. +* This method issues the client RTestSession::AbortTestStep() call and +* the RunL() state machine handles the completion from the test server. +* Implements the MTaskTimerCompletion pure abstract class for callbacks from the +* CTaskTimer class. +* Calls back into its parent CScriptControl object when a test step completes. +* CProgramControl +* Derives CTaskControlBase +* Kicks off an executable in its own process and handles process completion asynchronously +* CTaskTimer: +* Derives CTimer. +* Calls back into its parent object if the timer expires. +* EPOC include +* +*/ + + + +/** + @file scriptengine.cpp +*/ + +//#include +#if !(defined TEF_LITE) +#include +#include +#endif + +// User include +#include +#include "scriptengine.h" + +// Fix defect 119337, initialize the integer to zero +GLDEF_D TInt CScriptControl::iNestedNumRunScriptInLoop=0; +// End defect 119337 + +/** + * @param aPtrC1 - Instance of TPtrC to compare + * @param aPtrC2 - Instance of TPtrC to compare + * Function to implement the comparison algo for RArray::Find to work with + */ +TBool TSelectiveTestingOptions::CompareTPtrC(const TPtrC& aPtrC1, const TPtrC& aPtrC2) + { + TInt ret =aPtrC1.CompareF(aPtrC2); + return (ret==0) ? ETrue : EFalse; + } + +/** + * @param aRng1 - Instance of TRange to compare + * @param aRng2 - Instance of TRange to compare + * Function to implement the comparison algo for RArray::Find to work with. + * TRange::iStartTestCase determines the match + */ +TBool TRange::CompareTRangeStartCase(const TRange& aRng1, const TRange& aRng2) + { + TInt ret =aRng2.iStartTestCase.CompareF(aRng1.iStartTestCase); + return (ret==0) ? ETrue : EFalse; + } + +/** + * @param aRng1 - Instance of TRange to compare + * @param aRng2 - Instance of TRange to compare + * Function to implement the comparison algo for RArray::Find to work with. + * TRange::iEndTestCase determines the match + */ +TBool TRange::CompareTRangeEnd(const TRange& aRng1, const TRange& aRng2) + { + TInt ret =aRng2.iEndTestCase.CompareF(aRng1.iEndTestCase); + return (ret==0) ? ETrue : EFalse; + } + +/** + * @param aRng1 - Instance of TRange to compare + * @param aRng2 - Instance of TRange to compare + * Function to implement the comparison algo for RArray::Sort to work with. + * TRange::iStartTestCase is used as the sort key + */ +TInt TRange::CompareTRangeStartOrder(const TRange& aRng1, const TRange& aRng2) + { + return aRng1.iStartTestCase.CompareF( aRng2.iStartTestCase); + } + +/** + * @param aPtrC1 - Instance of TPtrC to compare + * @param aPtrC2 - Instance of TPtrC to compare + * Function to implement the comparison algo for RArray::Sort to work with. + */ +TInt TSelectiveTestingOptions::CompareTPtrCOrder(const TPtrC& aPtrC1, const TPtrC& aPtrC2) + { + return aPtrC1.CompareF(aPtrC2); + } + +/** + * @param aServ - Instance of the test server handle + * @param aStepName - Test step name + * Wrapper around the RTestServ class. Performs counting on test step sessions + */ +TInt RScriptTestSession::Open(RScriptTestServ& aServ, const TBool aIsTestStep, const TDesC& aStepName ) + { + if(aServ.SharedData() && aServ.SessionCount()) + return KErrInUse; + TInt ret = KErrNone; + + if( aIsTestStep ) + { + ret = RTestSession::Open(aServ, aStepName, aServ.SharedData()); + } + else + { + ret = RTestSession::Open(aServ, aServ.SharedData()); + } + if(ret) + return ret; + aServ.AddSession(); + iServ = &aServ; + return KErrNone; + } + +/** + * @param aScriptFilePath - The full path and filename of a script command file. + * @param aLogger - Reference to a logger interface object that contains HTML & XML log client sessions. + * @param aConsole - Reference to console object for printing script line during test execution + * @param aSysDrive - Default System drive letter + * @param aTestSysDrive - Default System drive letter overwritten through testexecute.ini + * Constructor + */ +CScriptMaster::CScriptMaster(const TDesC& aScriptFilePath, CTestExecuteLogger& aLogger, RConsoleLogger& aConsole, const TDriveName& aSysDrive, const TDriveName& aTestSysDrive, TSelectiveTestingOptions* aSelTestingOptions ) : + iState(EInit), iScriptFilePath(aScriptFilePath), iLogger(aLogger), iConsoleLogger(aConsole), iDefaultSysDrive(aSysDrive), iTestSysDrive(aTestSysDrive), iSelTestingOptions(aSelTestingOptions) + { + } + +/** + * Destructor + */ +CScriptMaster::~CScriptMaster() + { + } + +/** + * Pure virtual implementation. + * The Top level state machine Kick'd() into by MainL() + * Picks up the completion from a CScriptControl instance then exits the scheduler + */ +void CScriptMaster::RunL() + { + switch (iState) + { + case EInit : + { + // Create the master CScriptControl instance. + CScriptControl* scriptControl = new (ELeave) CScriptControl(*this,iScriptFilePath,Logger(),ConsoleLogger(),iStartLooping,iLoop,iDefaultSysDrive,iTestSysDrive,iSelTestingOptions); + iState = ERunning; + // Set our AO up ready for completion + Prime(); + // Kick the CScriptControl state machine + scriptControl->Kick(); + } + break; + case ERunning : + { + // All child AO's have completed and been deleted so it's safe to exit. + CActiveScheduler::Stop(); + } + break; + default: + break; + } + } + +/** + * @param aCompletion - Callback into the parent object. + * @param aScriptFilePath - The full path and filename of a script file + * @param aLogger - Reference to a logger instance + * @param aConsole - Reference to console object for printing script line during test execution + * @param aStartLooping - Initiate the looping + * @param aLoop - Check for nesting of loops + * @param aSysDrive - Default System drive letter + * @param aTestSysDrive - System drive letter overwritten from testexecute.ini + * Constructor + */ +CScriptControl::CScriptControl(MChildCompletion& aCompletion, const TDesC& aScriptFilePath, CTestExecuteLogger& aLogger, RConsoleLogger& aConsole, TBool aStartLooping, TBool aLoop, const TDriveName& aSysDrive, const TDriveName& aTestSysDrive, TSelectiveTestingOptions* aSelTestingOptions): + iScriptFile(aScriptFilePath), + iState(EInit), + iParent(aCompletion), + iConcurrent(EFalse), + iCanComplete(ETrue), + iBreakOnError(EFalse), + iAsyncTasksOutstanding(0), + iCurrentScriptLineNumber(0), + iLogger(aLogger), + iConsoleLogger(aConsole), + iScriptLinePrefixSet(EFalse), + iStartLooping(aStartLooping), + iLoop(aLoop), + iSharedDataNum(KTEFZeroValue), + iIsSharedData(EFalse), + iSyncControl(NULL), + iTestCaseID(KTEFTestCaseDefault), + iDefaultSysDrive(aSysDrive), + iTestSysDrive(aTestSysDrive), + iSelTestingOptions(aSelTestingOptions), + iSelectOne(EFalse), + iRangeRefCounter(0), + iTestCaseCounter(0) + { + } + +/** + * Destructor + */ +CScriptControl::~CScriptControl() + { + iTimer.Cancel(); + iTimer.Close(); + // We read the complete script into the heap for parsing so: + delete iScriptData; + for (TInt index = 0; index < iSharedDataNum; index++) + { + delete iSharedDataArray[index]; + } + // Instance has an array of pointers to RTestServer objects. + // Loop through deleting and closing + TInt i = 0; + TInt count = iServers.Count(); + for(i=0;iClose(); + delete iServers[0]; + iServers.Remove(0); + } + iServers.Close(); + if( iSyncControl ) + { + delete iSyncControl; + } + } + +/** + * @param aError - Integer error value returned by the active object while leaving + * @return TInt - System-wide error codes + * Error Handler for active object + */ +TInt CScriptControl::RunError(TInt aError) + { + if (aError == KErrNoMemory) + { + ERR_PRINTF1(_L("Insufficient memory available to perform further operation.\n\tPlease increase the maximum heap size from the testexecute.mmp and try running the test again. Exiting test script...")); + } + else + { + ERR_PRINTF2(_L("Test execution failed with error %d. Terminating tests.."), aError); + } + iParent.ChildCompletion(KErrNone); + delete this; + return KErrNone; + } + +/** + * Implementation of pure virtual + * The main script interpreter state machine. + * Kick'd() into by CScriptMaster or, in the case of nested scripts, another CScriptControl + * instance. + * Picks up the completions from CClientControls and/or, in the case of nested scripts, + * another CScriptControl instance. + */ +void CScriptControl::RunL() + { + switch (iState) + { + case EInit : + // First state after Kick() from parent + { + // Standard log output goes to flogger + // Result log goes to a propietary file in c:\logs\testexecute + User::LeaveIfError(iTimer.CreateLocal()); + TRAPD(err,CreateScriptDataFromScriptFileL()); + if(err) + { + // If we can't open the script file then log the fact and gracefully exit + // the state machine. + TBuf buf(iScriptFile); + _LIT(KScriptFileError,"Failed Script File Open %S"); + ERR_PRINTF2(KScriptFileError,&buf); + iState = EClosing; + //condition used for checking failure in testexecute.cpp + commentedCommandsCount=-1; + iRunScriptFailCount++; + Kick(); + break; + } + + // Script file reading state next + iState = ERunning; + // Kick ourselves into the next state + Kick(); + } + break; + + case ERunning : + // Always in this state whilst we're reading lines from script file data member + { + TPtrC scriptLine; + if(!iStartLooping) + { + if(!GetNextScriptLine(scriptLine)) + { + // End of the script file + // Check see if there are any async requests outstanding + // In concurrent mode there are very likely to be + if(iAsyncTasksOutstanding == 0) + { + // No requests outstanding so call into the parent + iParent.ChildCompletion(KErrNone); + delete this; + } + else + { + // Requests outstanding + // Next time we're completed we'll be in the closing state + iState = EClosing; + iCanComplete =ETrue; + // Prime ourselves for completion + Prime(); + } + break; + } + } + //Get the script lines which are to be looped + else if(!GetLoopScriptLine(scriptLine)) + { + // End of the script file + // Check see if there are any async requests outstanding + // In concurrent mode there are very likely to be + if(iAsyncTasksOutstanding == 0) + { + // No requests outstanding so call into the parent + iParent.ChildCompletion(KErrNone); + delete this; + } + else + { + // Requests outstanding + // Next time we're completed we'll be in the closing state + iState = EClosing; + iCanComplete =ETrue; + // Prime ourselves for completion + Prime(); + } + break; + } + + iCurrentScriptLine.Set(scriptLine); + + TBool commentedCommand = CheckCommentedCommands(); + if(commentedCommand) + { + iCanComplete = EFalse; + Kick(); + break; + } + + if (iScriptLinePrefixSet ) + { + TLex lookahead(iCurrentScriptLine); + + TPtrC firstCommand(lookahead.NextToken()); + + if (firstCommand.CompareF(KTEFRemovePrefixCommand) != 0) + { + // If we aren't the Remove_Prefix command, prefix the current line... + iPrefixedCurrentScriptLine = iScriptLinePrefix; + iPrefixedCurrentScriptLine.Append(scriptLine); + iCurrentScriptLine.Set(iPrefixedCurrentScriptLine); + } + } + + TRAPD(err, MakeAbsoluteFilePathsL(iCurrentScriptLine)); + PrintCurrentScriptLine(); + + TLex lex(iCurrentScriptLine); + + TPtrC token(lex.NextToken()); + + if (err == KTEFErrInvalidRelPath) + { + _LIT(KTEFErrInvalidRelPathText,"Invalid relative path provided in the script file. Skipping the script line from execution.."); + ERR_PRINTF1(KTEFErrInvalidRelPathText); + + if (token.CompareF(KTEFRunTestStepCommand) == 0 || + token.CompareF(KTEFRunPanicStepCommand) == 0 || + token.CompareF(KTEFRunTestStepResultCommand) == 0 || + token.CompareF(KTEFRunPanicStepResultCommand) == 0) + { + TExitCategoryName blankPanicString; //Not a Panic + LogResult(EIgnore, blankPanicString, iCurrentScriptLineNumber, iCurrentScriptLine); + } + iCanComplete = EFalse; + Kick(); + break; + } + + if(err == KErrTooBig) + { + _LIT(KTEFErrTooBigArguments, "One or more arguments for the command exceeded allowed limit for length. Skipping test.."); + ERR_PRINTF1(KTEFErrTooBigArguments); + + if (token.CompareF(KTEFRunTestStepCommand) == 0 || + token.CompareF(KTEFRunPanicStepCommand) == 0 || + token.CompareF(KTEFRunTestStepResultCommand) == 0 || + token.CompareF(KTEFRunPanicStepResultCommand) == 0) + { + TExitCategoryName blankPanicString; //Not a Panic + LogResult(EIgnore, blankPanicString, iCurrentScriptLineNumber, iCurrentScriptLine); + } + iCanComplete = EFalse; + Kick(); + break; + } + + // Main parser + if(token.CompareF(KTEFLoadSuiteCommand) == 0 || token.CompareF(KTEFLoadServerCommand) == 0) + { + TRAPD(err,CreateServerFromScriptLineL()); + + // Create a TLogField structure array + // Size of array equals to number of fields to be displayed for the command + TExtraLogField logField[2]; + + // The first member of the structure stores the field name + // The second one holds the value for the particular field + _LIT(KSuiteName, "SUITE_NAME"); + logField[0].iLogFieldName.Copy(KSuiteName); + logField[0].iLogFieldValue.Copy(lex.NextToken()); + + logField[1].iLogFieldName.Copy(KTEFResultString); + if(err != KErrNone) + { + logField[1].iLogFieldValue.Copy(KTEFResultFail); + if( KErrNotFound == err ) + { + _LIT(KServerNotFound,"Failed to create server, either the server or one of its dependancies could not be found."); + ERR_PRINTF1(KServerNotFound); + } + else + { + _LIT(KServerCreateError,"Failed to Create Server Err = %d"); + ERR_PRINTF2(KServerCreateError,err); + } + } + else + { + logField[1].iLogFieldValue.Copy(KTEFResultPass); + } + + // Call the Logger().LogToXml routine which handles XML logging for individual commands + // Takes in the command name, number of fields and the struture array + Logger().LogToXml(((TText8*)__FILE__), __LINE__, RFileFlogger::ESevrMedium, token, 2, logField); + iCanComplete = EFalse; + Kick(); + } + else if(token.CompareF(KTEFStartTestBlock)==0) + { + // Parse the START_TEST_BLOCK command line + TInt index = 0; + TBool taskCanComplete = ETrue; + TBool concurrent = iConcurrent; + // Make sure the server is loaded + if(!GetServerIndexFromScriptLine(index)) + { + // Not loaded. Skip the line, but ensure its logged as a failure. + TExitCategoryName blankPanicString; //Not a Panic + LogResult(EIgnore, blankPanicString, iCurrentScriptLineNumber, iCurrentScriptLine); + + iCanComplete = EFalse; + Kick(); + break; + } + + TBuf startBlockLine = iCurrentScriptLine; + + // Parse the test block of commands + TTEFItemArray* itemArray = new (ELeave) TTEFItemArray(1); + CleanupStack::PushL( itemArray ); + TRAPD( err, ParseTestBlockL(*itemArray) ); + + if( KErrNone == err ) + { + if(!iConcurrent) + { + // If we're not in concurrent mode then child objects can complete us + taskCanComplete = ETrue; + // Prime ready for completion + Prime(); + } + else + { + // In concurrent mode children can't complete us as we kick() ourselves. + taskCanComplete = EFalse; + Kick(); + } + // Create the test block controler object + TInt loopIndex = -1; + if (iLoop) + { + loopIndex = iLoopCounter + 1; + } + + CClientControl* blockController = CClientControl::NewL( *iServers[index], + startBlockLine, + *this, + iCurrentScriptLineNumber, + Logger(), + loopIndex, + iTestCaseID, + iCurrentScriptLine, + iScriptFile, + *itemArray, + iDefaultSysDrive, + iTestSysDrive); + + blockController->SetTaskComplete(taskCanComplete); + iAsyncTasksOutstanding++; + // Kick() the test step object into its state machine + blockController->Kick(); + } + else + { + iCanComplete = EFalse; + Kick(); + } + + iConcurrent = concurrent; + CleanupStack::PopAndDestroy( itemArray ); + } + else if(token.CompareF(KTEFEndTestBlock)==0) + { + // If this is called then there is a missing START_TEST_BLOCK command + TExitCategoryName blankPanicString; + LogResult(EIgnore, blankPanicString, iCurrentScriptLineNumber, iCurrentScriptLine); + iCanComplete = EFalse; + Kick(); + } + else if(token.CompareF(KTEFStartRepeat)==0) + { + TPtrC iniFile(lex.NextToken()); + TPtrC iniSection(lex.NextToken()); + TPtrC tempRepeatParam=lex.NextToken(); + CIniData* configData = NULL; + TInt err = 0; + if(iniFile.Length()) + { + TRAP(err,configData = CIniData::NewL(iniFile)); + } + if(err != KErrNone) + { + _LIT(KTEFIniFileNotFound,"Ini file not found.. Looping Ignored"); + ERR_PRINTF1(KTEFIniFileNotFound); + Kick(); + break; + } + iRepeatParam=0; + CleanupStack::PushL(configData); + if(configData) + { + //For Syntax Error continue ignoring looping + if (!configData->FindVar(iniSection, tempRepeatParam, iRepeatParam)) + { + _LIT(KIniFailMessage,"The input data is not found in the ini specified"); + INFO_PRINTF1(KIniFailMessage); + CleanupStack::PopAndDestroy(configData); + Kick(); + break; + } + } + + CleanupStack::PopAndDestroy(configData); + TExtraLogField logField[1]; + _LIT(KIterations,"ITERATIONS"); + logField[0].iLogFieldName.Copy(KIterations); + logField[0].iLogFieldValue.Copy(KNull); + logField[0].iLogFieldValue.AppendNum(iRepeatParam); + Logger().LogToXml(((TText8*)__FILE__), __LINE__, RFileFlogger::ESevrMedium, token, 1, logField); + + if(tempRepeatParam.Compare(KNull)==0) + { + _LIT(KRepeatKeyNotFound,"Repeat Parameter Key Not Found"); + INFO_PRINTF1(KRepeatKeyNotFound); + Kick(); + break; + } + //Nesting of Control Logic is Not supported + if(iLoop) + { + _LIT(KNestingNotAllowed,"Nesting of START_REPEAT is not supported.. Looping Ignored"); + WARN_PRINTF1(KNestingNotAllowed); + iLoop=EFalse; + Kick(); + break; + } + //Looping is not to be started with Concurrent mode + if(iConcurrent) + { + _LIT(KConcurrentNotAllowed,"No concurrent Execution is Allowed in Looping"); + INFO_PRINTF1(KConcurrentNotAllowed); + Kick(); + break; + } + + iLoopCounter=0; + //For Invalid Parameter continue ignoring looping + if(iRepeatParam<1) + { + _LIT(KInvalidRepeatParam,"The repeat Parameter is invalid"); + INFO_PRINTF1(KInvalidRepeatParam); + Kick(); + break; + } + iLoop=ETrue; + iCheckVar=EFalse; + Kick(); + } + else if(token.CompareF(KTEFEndRepeat)==0) + { + if(!iLoop) + { + _LIT(KLoopNotInitiated,"The Looping is Not Initiated"); + INFO_PRINTF1(KLoopNotInitiated); + Logger().LogToXml(((TText8*)__FILE__), __LINE__, RFileFlogger::ESevrMedium, token); + Kick(); + break; + } + + iLoopCounter++; + if(iLoopCounter==iRepeatParam) + { + Logger().LogToXml(((TText8*)__FILE__), __LINE__, RFileFlogger::ESevrMedium, token); + iStartLooping=EFalse; + iLoop=EFalse; + } + else + { + iStartLooping=ETrue; + //Looping needs to be started in CONSECUTIVE mode + if(iConcurrent) + { + iConcurrent=EFalse; + } + } + Kick(); + } + else if(token.CompareF(KTEFRunTestStepCommand) == 0 || + token.CompareF(KTEFRunPanicStepCommand) == 0 || + token.CompareF(KTEFRunTestStepResultCommand) == 0 || + token.CompareF(KTEFRunPanicStepResultCommand) == 0 + ) + { + if(!CheckValidScriptLine()) + { + // Not a Valid Script Line + + TExitCategoryName blankPanicString; //Not a Panic + LogResult(EIgnore, blankPanicString, iCurrentScriptLineNumber, iCurrentScriptLine); + // End of defect 037066 + + iCanComplete = EFalse; + Kick(); + break; + } + + TInt index; + TBool taskCanComplete = ETrue; + TBool concurrent = iConcurrent; + // Make sure the server is loaded + if(!GetServerIndexFromScriptLine(index)) + { + // Not loaded. Skip the line, but ensure its logged as a failure. + + // Start of defect 037066 + TExitCategoryName blankPanicString; //Not a Panic + LogResult(EIgnore, blankPanicString, iCurrentScriptLineNumber, iCurrentScriptLine); + // End of defect 037066 + + iCanComplete = EFalse; + Kick(); + break; + } + + if(!iConcurrent) + { + // If we're not in concurrent mode then child objects can complete us + taskCanComplete = ETrue; + // Prime ready for completion + Prime(); + } + else + { + // In concurrent mode children can't complete us as we kick() ourselves. + taskCanComplete = EFalse; + Kick(); + } + iConcurrent = concurrent; + // Create the test step controler object + TInt loopIndex = -1; + if (iLoop) + { + loopIndex = iLoopCounter + 1; + } + CClientControl* stepController = new (ELeave) CClientControl(*iServers[index],iCurrentScriptLine,*this,iCurrentScriptLineNumber,Logger(), loopIndex, iTestCaseID, iScriptFile, iDefaultSysDrive, iTestSysDrive); + stepController->SetTaskComplete(taskCanComplete); + iAsyncTasksOutstanding++; + // Kick() the test step object into its state machine + stepController->Kick(); + } + else if(token.CompareF(KTEFRunProgramCommand) == 0) + { + TBool taskCanComplete = ETrue; + if(!iConcurrent) + { + // If we're not in concurrent mode then child objects can complete us + taskCanComplete = ETrue; + // Prime ready for completion + Prime(); + } + else + { + // In concurrent mode children can't complete us as we kick() ourselves. + taskCanComplete = EFalse; + Kick(); + } + // Create the test step controller object + CProgramControl* programController = new (ELeave) CProgramControl(iCurrentScriptLine,*this,iCurrentScriptLineNumber,Logger()); + programController->SetTaskComplete(taskCanComplete); + iAsyncTasksOutstanding++; + // Kick() the test step object into its state machine + programController->Kick(); + } + else if(token.CompareF(KTEFRunWSProgramCommand) == 0) + { + TBool taskCanComplete = ETrue; + if(!iConcurrent) + { + // If we're not in concurrent mode then child objects can complete us + taskCanComplete = ETrue; + // Prime ready for completion + Prime(); + } + else + { + // In concurrent mode children can't complete us as we kick() ourselves. + taskCanComplete = EFalse; + Kick(); + } + // Create the test step controller object + CProgramControl* programController = new (ELeave) CProgramControl(iCurrentScriptLine,*this,iCurrentScriptLineNumber,Logger(),ETrue); + iAsyncTasksOutstanding++; + programController->SetTaskComplete(taskCanComplete); + // Kick() the test step object into its state machine + programController->Kick(); + } + else if(token.CompareF(KTEFConcurrentCommand) == 0) + { + // Go into concurrent mode + // Whilst we're in concurrent mode we always kick() ourselves + // around the state engine + iConcurrent = ETrue; + // Call the Logger()'s LogToXml routine to handle XML logging + // Takes in just the command name without any field + Logger().LogToXml(((TText8*)__FILE__), __LINE__, RFileFlogger::ESevrMedium, KTEFConcurrentCommand); + iCanComplete = EFalse; + Kick(); + } + else if(token.CompareF(KTEFConsecutiveCommand) == 0) + { + // If we go into consecutive mode we have to make sure there are no + // requests outstanding.Set the state accordingly + iConcurrent = EFalse; + + // Call the Logger()'s LogToXml routine to handle XML logging + // Takes in just the command name without any field + Logger().LogToXml(((TText8*)__FILE__), __LINE__, RFileFlogger::ESevrMedium, KTEFConsecutiveCommand); + if(iAsyncTasksOutstanding) + { + iCanComplete = ETrue; + iState = EWaitCompletions; + Prime(); + } + else + { + iCanComplete = EFalse; + iState = ERunning; + Kick(); + } + } + else if(token.CompareF(KTEFRunUtilsCommand) == 0) + { + // All utils complete synchronously + TRAPD(err,RunUtilsFromScriptLineL()); + + // Create a TLogField structure array + // Size of array equals to number of fields to be displayed for the command + TExtraLogField logField[2]; + + // The first member of the structure stores the field name + // The second one holds the value for the particular field + _LIT(KCommand,"COMMAND"); + logField[0].iLogFieldName.Copy(KCommand); + logField[0].iLogFieldValue.Copy(lex.NextToken()); + + logField[1].iLogFieldName.Copy(KTEFResultString); + if (err == KErrNone) + { + logField[1].iLogFieldValue.Copy(KTEFResultPass); + } + else + { + logField[1].iLogFieldValue.Copy(KTEFResultFail); + } + + // Call the Logger().LogToXml routine which handles XML logging for individual commands + // Takes in the command name, number of fields and the struture array + Logger().LogToXml(((TText8*)__FILE__), __LINE__, RFileFlogger::ESevrMedium, KTEFRunUtilsCommand, 2, logField); + + if(err != KErrNone) + { + _LIT(KRunUtilsError,"RUN_UTILS ret = %d"); + INFO_PRINTF2(KRunUtilsError,err); + } + iCanComplete = EFalse; + Kick(); + } + else if(token.CompareF(KTEFPrintCommand) == 0) + { + PrintFromScriptLine(); + iCanComplete = EFalse; + Kick(); + } + else if (token.CompareF(KTEFPrefixCommand) == 0) + { + + if(iAsyncTasksOutstanding) + // Don't run Prefix until all outstanding requests have completed + { + iState = EPrefixPending; + iCanComplete = ETrue; + Prime(); + } + else + { + // Ok to run PREFIX - Kick the stated machine so it's run next time in the RunL() + iState = ERunPrefix; + iCanComplete = EFalse; + Kick(); + } + + } + else if (token.CompareF(KTEFRemovePrefixCommand) == 0) + { + iScriptLinePrefixSet = EFalse; + iCanComplete = EFalse; + Kick(); + } + else if (token.CompareF(KTEFStartTestCaseCommand) == 0) + { + if(ProceedTestCase()) + { + LogTestCaseMarkerL(); + iCanComplete = EFalse; + Kick(); + } + else + { + iState = ETestCaseIgnore; + iCanComplete = EFalse; + Kick(); + } + } + else if (token.CompareF(KTEFEndTestCaseCommand) == 0) + { + ProcessEndCase(); + if(iAsyncTasksOutstanding) + // Don't run END_TESTCASE until all outstanding requests have completed + { + iState = EEndTestCasePending; + iCanComplete = ETrue; + Prime(); + } + else + { + // Ok to run END_TESTCASE - Kick the stated machine so it's run next time in the RunL() + iState = ERunEndTestCase; + iCanComplete = EFalse; + Kick(); + } + } + else if (token.CompareF(KTEFStartSyncTestCaseCommand) == 0) + { + if(ProceedTestCase()) + { + // Start Synchronised Test Case + // Check to see if the Sync Data has been created + // If not then create it + if( iSyncControl == NULL ) + { + iSyncControl = CSyncControl::NewL(); + } + LogTestCaseMarkerL(); + iState = ERunStartSyncTestCase; + iCanComplete = EFalse; + Kick(); + } + else + { + //go into some sleep state until you + //encounter an end test case for this... + iState = ETestCaseIgnore; + iCanComplete = EFalse; + Kick(); + } + } + else if (token.CompareF(KTEFEndSyncTestCaseCommand) == 0) + { + ProcessEndCase(); + // End Synchronised Test Case + if(iAsyncTasksOutstanding) + // Don't run END_SYNCHRONISED_TESTCASE until all outstanding requests have completed + { + iState = EEndTestCasePending; + iCanComplete = ETrue; + Prime(); + } + else + { + // Ok to run END_SYNCHRONISED_TESTCASE - Kick the stated machine so it's run next time in the RunL() + iState = ERunEndTestCase; + iCanComplete = EFalse; + Kick(); + } + } + else if(token.CompareF(KTEFRunScriptCommand) == 0) + { + // Create a TLogField structure array + // Size of array equals to number of fields to be displayed for the command + TExtraLogField logField[1]; + + // The first member of the structure stores the field name + // The second one holds the value for the particular field + _LIT(KScriptName,"SCRIPT_NAME"); + logField[0].iLogFieldName.Copy(KScriptName); + logField[0].iLogFieldValue.Copy(lex.NextToken()); + + // Call the Logger().LogToXml routine which handles XML logging for individual commands + // Takes in the command name, number of fields and the struture array + Logger().LogToXml(((TText8*)__FILE__), __LINE__, RFileFlogger::ESevrHigh, KTEFRunScriptCommand, 1, logField); + if(iAsyncTasksOutstanding) + { + // Don't recursively process a new script until this one's async + // requests are completed + iState = ERunScriptPending; + iCanComplete = ETrue; + Prime(); + } + else + { + // Ok to process the script recursively + iState = ERunScript; + iCanComplete = EFalse; + Kick(); + } + } + else if(token.CompareF(KTEFCedCommand) == 0) + // Run the CED comms database editor + { + if(iAsyncTasksOutstanding) + // Don't run CED until all outstanding requests have completed + { + iState = ERunCedPending; + iCanComplete = ETrue; + Prime(); + } + else + { + // Ok to run CED - Kick the stated machine so it's run next time in the RunL() + iState = ERunCed; + iCanComplete = EFalse; + Kick(); + } + } + else if(token.CompareF(KTEFDelayCommand) == 0) + // Delay n milliseconds + { + if(iAsyncTasksOutstanding) + // Don't delay until all outstanding requests have completed + { + iState = EDelayPending; + iCanComplete = ETrue; + Prime(); + } + else + { + // Ok to delay + iState = EDelay; + iCanComplete = EFalse; + Kick(); + } + } + // Script can exit on error + // Flag is checked on async task completion + else if(token.CompareF(KTEFBreakErrorOnCommand) == 0) + { + // Set the flag and process next line + iCanComplete = EFalse; + iBreakOnError = ETrue; + + // Call the Logger()'s LogToXml routine to handle XML logging + // Takes in just the command name without any field + Logger().LogToXml(((TText8*)__FILE__), __LINE__, RFileFlogger::ESevrMedium, KTEFBreakErrorOnCommand); + Kick(); + } + else if(token.CompareF(KTEFBreakErrorOffCommand) == 0) + { + // Reset the flag and process next line + iCanComplete = EFalse; + iBreakOnError = EFalse; + + // Call the Logger()'s LogToXml routine to handle XML logging + // Takes in just the command name without any field + Logger().LogToXml(((TText8*)__FILE__), __LINE__, RFileFlogger::ESevrMedium, KTEFBreakErrorOffCommand); + Kick(); + } + // We only implement the pause command if JustInTime debugging is switched on + else if(token.CompareF(KTEFPauseCommand) == 0 && User::JustInTime()) + { + // Create a TLogField structure array + // Size of array equals to number of fields to be displayed for the command + TExtraLogField logField[1]; + + // The first member of the structure stores the field name + // The second one holds the value for the particular field + _LIT(KDelay,"DELAY"); + logField[0].iLogFieldName.Copy(KDelay); + logField[0].iLogFieldValue.Copy(lex.NextToken()); + + // Call the Logger().LogToXml routine which handles XML logging for individual commands + // Takes in the command name, number of fields and the struture array + Logger().LogToXml(((TText8*)__FILE__), __LINE__, RFileFlogger::ESevrLow, KTEFPauseCommand, 1, logField); + + if(iAsyncTasksOutstanding) + // Don't pause until all outstanding requests have completed + { + iState = EPausePending; + iCanComplete = ETrue; + Prime(); + } + else + { + // Ok to Pause + iState = EPause; + iCanComplete = EFalse; + Kick(); + } + } + // Handles the shared comand and also creates the shared object + // on reading user inputs from ini file + else if(token.CompareF(KTEFSharedDataCommand) == 0) + { + if (iIsSharedData) + { + WARN_PRINTF1(KTEFSharedDataCommandRepeated); + } + else + { + TRAPD(err,CreateSharedObjectsFromScriptLineL()); + if (err != KErrNone) + { + ERR_PRINTF1(KTEFErrInCreatingSharedObjects); + } + } + iCanComplete = EFalse; + Kick(); + } + else + { + // Command not implemented or a comment line + // Code implemented for defect 047340 + TBuf bufWarning; + if(token.Length()) + { + TInt firstChar = iCurrentScriptLine[0]; + if(firstChar != '\r' && firstChar != '\n' && firstChar != '#' && firstChar != '/' && token.CompareF(KTEFPauseCommand) != 0) + { + _LIT(KUnrecognised,"Unrecognised Command - %S"); + if(token.Length() < bufWarning.MaxLength()) + { + bufWarning.Copy(token); + WARN_PRINTF2(KUnrecognised,&bufWarning); + } + else + { + _LIT(KLineTooLong,"Command line too long"); + bufWarning.Copy(KLineTooLong); + WARN_PRINTF2(KUnrecognised,&bufWarning); + } + } + } + iCanComplete = EFalse; + Kick(); + } + } + break; + + case EClosing : + // Script has been processed + // Pick up the completions + { + if(iAsyncTasksOutstanding == 0) + { + // Script finished + // Call into the parent + iParent.ChildCompletion(KErrNone); + delete this; + } + else + { + // More requests to complete + iCanComplete = ETrue; + Prime(); + } + } + break; + + case ERunScriptPending : + case EWaitCompletions : + case ERunCedPending : + case EDelayPending : + case EPausePending : + case EEndTestCasePending : + case EPrefixPending: + // We go into this state if we're waiting for RUN_TEST_STEP's + // to complete before we execute another command + { + if(iAsyncTasksOutstanding == 0) + { + // All steps complete + // Set up the next state and kick() the state machine + if(iState == ERunScriptPending) + iState = ERunScript; + else if(iState == EWaitCompletions) + iState = ERunning; + else if(iState == ERunCedPending) + iState = ERunCed; + else if(iState == EDelayPending) + iState = EDelay; + else if(iState == EPausePending) + iState = EPause; + else if(iState == EEndTestCasePending) + iState = ERunEndTestCase; + else if(iState == EPrefixPending) + iState = ERunPrefix; + // Safe to Kick() the state machine again + iCanComplete = EFalse; + Kick(); + } + else + { + // More requests outstanding + iCanComplete = ETrue; + Prime(); + } + } + break; + + case ERunScript : + // Recursively instantiate the CScriptControl class + { + GetScriptFileFromScriptLine(); + CScriptControl* scriptControl = new (ELeave) CScriptControl(*this,iChildScriptFile,Logger(),ConsoleLogger(),iStartLooping,iLoop,iDefaultSysDrive,iTestSysDrive,iSelTestingOptions); + // Kick the nested CScriptControl state machine + scriptControl->Kick(); + // Put our instance in the idling state, Prime()'d ready for clild-parent + // completion by the nested one. + iState = EIdling; + iCanComplete = ETrue; + Prime(); + } + break; + + case ERunCed : + // Slightly tricky one + // WIN32 & Non-secure means we execute CED synchronously + { + SetActive(); + TRAPD(err,RunCedFromScriptLineL()); + if(!err) + // Expect completion asynchronously + // We're set for completion so just set the state + iState = EIdling; + else + { + _LIT(KCedError,"CED Error = %d"); + ERR_PRINTF2(KCedError,err); + // A CED error so kick the state machine + iState = ERunning; + Kick(); + } + } + break; + + case EDelay : + { + // Kick the timer and wait for completion + SetActive(); + StartTimerFromScriptLine(); + iState = EIdling; + } + break; + + case ERunEndTestCase : + { + LogTestCaseMarkerL(); + iState = ERunning; + iCanComplete = EFalse; + Kick(); + } + break; + + case ERunStartSyncTestCase : + { + // Check to see if the test case is ready to continue + SetActive(); + iTimer.After( iStatus, KTEFStatusDelay*1000 ); + TBool syncContinue = iSyncControl->TestCaseContinueL(); + if( syncContinue ) + { + iState = EIdling; + } + } + break; + case ERunPrefix : + { + SetPrefix(); + iState = ERunning; + iCanComplete = EFalse; + Kick(); + } + break; + + case EIdling : + { + // Woken up due to either: + // A child CScriptControl instance completing OR + // the delay timer has completed. + iState = ERunning; + iCanComplete = EFalse; + Kick(); + } + break; + + case EPause : + { + _LIT(KPaused,"PAUSED - Hit Any Key to Continue\n"); + ConsoleLogger().Console().Printf(KPaused); + ConsoleLogger().Console().Getch(); + iState = ERunning; + iCanComplete = EFalse; + Kick(); + } + //Start of defect 115942 + break; + //End of defect 115942 + + case ETestCaseIgnore: + { + TPtrC scriptLine; + //do we want to while till we come to end of test case? + while(GetNextScriptLine(scriptLine)) + { + TLex lex(scriptLine); + TPtrC token(lex.NextToken()); + if((token.CompareF(KTEFEndTestCaseCommand) == 0) + || (token.CompareF(KTEFEndSyncTestCaseCommand) == 0)) //we found an end test case one + { + TPtrC testCID(lex.NextToken()); + //to support nested test cases + if(iTestCaseIDToIgnore.CompareF(testCID) == 0) + { + //in any case...go back to running and re-evaluate our position at + iState = ERunning; + iTestCaseIDToIgnore.Set(KTEFNull); + iCanComplete = EFalse; + iCurrentScriptLine.Set(scriptLine); + //before going back to running re-evaluate the + //state of selective testing + ProcessEndCase() ; + Kick(); + break; + } + } + } + break; + } + + default: + break; + } + } + +/** + * Implement the PRINT command + * Print the string(s) following the PRINT command to the log file + */ +void CScriptControl::PrintFromScriptLine() const + { + TLex lex(iCurrentScriptLine); + lex.NextToken(); + TBuf buf; + buf.Copy(lex.Remainder()); + + _LIT(KCommentString, " //"); + + TInt offset = buf.Find(KCommentString); + if (offset != KErrNotFound) + { + buf.SetLength(offset); + } + + _LIT(KS,"%S"); + INFO_PRINTF2(KS,&buf); + } + +/** + * Implement the PREFIX command + * Stores the prefix for command line prefixing + */ +void CScriptControl::SetPrefix() + { + TLex lex(iCurrentScriptLine); + // Bypass the PREFIX command + lex.NextToken(); + + // Get rid of any leading spaces + while(!lex.Eos()) + { + TChar peek = lex.Peek(); + if(peek == ' ') + { + lex.Inc(); + } + else + break; + } + + // Chop off the carriage return and insert a space + // If there is a preceding comment line, get rid of that. + + iScriptLinePrefix.Copy(lex.Remainder()); + + _LIT(KCarriageReturn, "\r\n"); + _LIT(KCommentString, " //"); + + TInt offset = iScriptLinePrefix.Find(KCommentString); + if (offset != KErrNotFound) + { + iScriptLinePrefix.SetLength(offset); + } + else + { + offset = iScriptLinePrefix.Find(KCarriageReturn); + + if (offset != KErrNotFound) + { + iScriptLinePrefix.SetLength(offset); + } + } + + _LIT(KTEFSpace, " "); + iScriptLinePrefix.Append(KTEFSpace); + + iScriptLinePrefixSet = ETrue; + + } + +/** + * Function to evaluate the situation of selective testing + * Returns whether the testcase on the current script line + * should be run. + */ +TBool CScriptControl::ProceedTestCase() + { + + //if selective testing is not on, dont bother + if(iSelTestingOptions == NULL) + return ETrue; + iTestCaseCounter++; + if(iTestCaseCounter > 1) //if this is nested, let it run unconditionally + return ETrue; + // the remaining continues only if selective testing is on + // AND we have a non-null, and hopefully valid instance of + // iSelTestingOptions + TLex lex(iCurrentScriptLine); + TPtrC token(lex.NextToken()); + TPtrC testCaseID(lex.NextToken()); + //evaluating class state variables... + //check range + TIdentityRelation crackID(TSelectiveTestingOptions::CompareTPtrC); + TIdentityRelation rangeComprtr(TRange::CompareTRangeStartCase); + TRange dummy(testCaseID,testCaseID); + for ( TInt index=0; indexiSelectiveCaseRange.Count(); ++index ) + { + if ( testCaseID.CompareF(iSelTestingOptions->iSelectiveCaseRange[index].iStartTestCase) == 0 ) + { + iSelTestingOptions->iSelectiveCaseRange[index].iState=TRange::EStateInUse; + ++iRangeRefCounter;//number of ranges now in operation + } + } + + + TBool runCase = ETrue ; //run everything by def + if( iSelTestingOptions->iSelectiveTestingType == iInclusive ) + { + //so selective testing is on and also its inclusive... + runCase = (iRangeRefCounter>0) || iSelectOne ; + } + else if(iSelTestingOptions->iSelectiveTestingType == iExclusive) + { + //so selective testing is on and also its exclusive... + runCase = (iRangeRefCounter<=0) && !iSelectOne ; + } + if(!runCase)//if the test case is to be selectively skipped, log it... + { + //use this one to log unexecuted cases... + Logger().LogTestCaseResult(iScriptFile, iCurrentScriptLineNumber, RFileFlogger::ESevrInfo, token, testCaseID,ESkippedSelectively); + } + if(runCase == EFalse) + { + iTestCaseIDToIgnore.Set(testCaseID) ; + } + + return runCase ; + } + +/** + * Function to evaluate the state variables + * at the end of test case + */ +void CScriptControl::ProcessEndCase() + { + if(iSelTestingOptions==NULL) //selective testing is not on + return; // dont bother + iTestCaseCounter--; + if(iTestCaseCounter<0) //in case we encountered unmatched end cases + iTestCaseCounter=0; + TLex lex(iCurrentScriptLine); + TPtrC token(lex.NextToken()); + TPtrC testCaseID(lex.NextToken()); + //check if this is ending a range + TRange dummy(testCaseID,testCaseID); + TIdentityRelation crackIDRangeend(TRange::CompareTRangeEnd); + for ( TInt index=0; indexiSelectiveCaseRange.Count(); ++index ) + { + if ( testCaseID.CompareF(iSelTestingOptions->iSelectiveCaseRange[index].iEndTestCase) == 0 ) + { + if ( iSelTestingOptions->iSelectiveCaseRange[index].iState == TRange::EStateInUse ) + { + iSelTestingOptions->iSelectiveCaseRange[index].iState=TRange::EStateUsed; + --iRangeRefCounter; + } + else + { + // Error condition. An end test case has been matched to a range that has not processed the start test case + // Either the start test case does not exist or the start test case comes after the end test case in the script + //or maybe do nothing + + } + } + } + + + //always reset the onetime test case thing + iSelectOne = EFalse; + } + +/** + * Implement START_TESTCASE/ END_TESTCASE commands + * Write a testcase marker to the logfile + */ +void CScriptControl::LogTestCaseMarkerL() + { + TLex lex(iCurrentScriptLine); + TPtrC token(lex.NextToken()); + TVerdict TestCaseResult(EFail); + + TPtrC TestCaseMarker(lex.NextToken()); + + if (token.CompareF(KTEFStartTestCaseCommand) == 0 || token.CompareF(KTEFStartSyncTestCaseCommand) == 0) + { + // Call the interface routine for logging in HTML & XML format + Logger().LogTestCaseResult(iScriptFile, iCurrentScriptLineNumber, RFileFlogger::ESevrHigh, token, TestCaseMarker); + iTestCaseID.Copy(TestCaseMarker); + } + else + { + // Its an END_TESTCASE. + // Need to identify whether all preceding test steps in the file + // passed (back to a *matching* START_TESTCASE). + TestCaseResult = HasTestCasePassedL(TestCaseMarker); + + // Special case for KTEFEndSyncTestCaseCommand where the result in + // the shared data area needs to be updated so STAT can retrieve it later. + if( token.CompareF(KTEFEndSyncTestCaseCommand) == 0 ) + { + // Check to see if the Sync Data has been created + if( iSyncControl != NULL ) + { + // Update the TEFResult shared data value + iSyncControl->SetResultL( TestCaseResult ); + } + else + { + User::Leave( KErrNotReady ); + } + } + // Call the interface routine for logging in HTML & XML format + Logger().LogTestCaseResult(iScriptFile, iCurrentScriptLineNumber, RFileFlogger::ESevrHigh, token, TestCaseMarker, TestCaseResult); + iTestCaseID.Copy(KTEFTestCaseDefault); + } + } + +/** + * + * Implement TestCase pass checking + */ +TVerdict CScriptControl::HasTestCasePassedL(TPtrC aTestCaseMarker) + { + // Looks from the top of the file for the equivalent Start_TestCase + // when it finds it it checks that all the steps to the bottom of + // the file (the current position) + + // Create a Cinidata object to parse through the testexecute.ini + // To retrieve the path where the log is to be placed + + CTestExecuteIniData* parseTestExecuteIni = NULL; + TBuf resultFilePath; + + TRAPD(err,parseTestExecuteIni = CTestExecuteIniData::NewL(iDefaultSysDrive)); + if (err == KErrNone) + { + CleanupStack::PushL(parseTestExecuteIni); + parseTestExecuteIni->ExtractValuesFromIni(); + parseTestExecuteIni->GetKeyValueFromIni(KTEFHtmlKey, resultFilePath); + } + else + { + resultFilePath.Copy(KTestExecuteLogPath); + resultFilePath.Replace(0, 2, iDefaultSysDrive); + } + + TBuf resultFileName(resultFilePath); + // loading the simplified test result in case of out-of-memory + resultFileName.Append(KTEFTestExecuteResultSimplifiedSummaryFile); + if (parseTestExecuteIni != NULL) + { + CleanupStack::PopAndDestroy(parseTestExecuteIni); + } + + // Open the result summary file + RFs fS; + User::LeaveIfError(fS.Connect()); + CleanupClosePushL(fS); + + RFile logFile; + User::LeaveIfError(logFile.Open(fS,resultFileName, EFileWrite | EFileRead | EFileShareAny)); + CleanupClosePushL(logFile); + TInt fileSize; + // Read the complete result summary file onto the heap + // It wont be that large + User::LeaveIfError(logFile.Size(fileSize)); + HBufC* resultData = HBufC::NewLC(fileSize); + HBufC8* resultData8 = HBufC8::NewLC(fileSize); + TPtr8 ptrData8(resultData8->Des()); + User::LeaveIfError(logFile.Read(ptrData8)); + TPtr ptrData(resultData->Des()); + ptrData.Copy(ptrData8); + CleanupStack::PopAndDestroy(resultData8); + + TBool foundMarker(EFalse); + TBool foundNonPassResult(EFalse); + TInt duplicatesCounter(0); + + TLex lex(ptrData); + while (!lex.Eos()) + { + // Find the ***Result keywords + TPtrC commandName( lex.NextToken() ); + if( commandName.CompareF(KTEFStartTestCaseCommand) == 0 || + commandName.CompareF(KTEFStartSyncTestCaseCommand) == 0 ) + { + if (lex.NextToken() == aTestCaseMarker) + { + // Increment the counter to identify that the test case id is duplicated + duplicatesCounter++; + if (duplicatesCounter == 2) + { + // If the test case id is duplicated for more than once, + // issue a warning in the log file, mentioning duplicate of test case id + _LIT(KWarnDuplicateTCID, "Test Case ID : %S re-used"); + WARN_PRINTF2(KWarnDuplicateTCID, &aTestCaseMarker); + } + + // When a matching test case id is found, the found marker is set to ETrue + foundMarker = ETrue; + // Initialise the foundNonPassResult to EFalse, on entry into each test case result in the log + foundNonPassResult = EFalse; + continue; + } + continue; + } + else if (foundMarker && commandName == KTEFResultTag) + { + // If the START_TESTCASE is found and a RESULT tag is found in the test result file, + // Extract the result value set for every test step called within + // and check to see if there are any non-pas results + _LIT(KTEFEquals,"="); + if (lex.NextToken() != KTEFEquals) + continue; + TPtrC result(lex.NextToken()); + if(result != KTEFResultPass) + { + // Set the foundNonPassResult to ETrue indicating the test case to fail + foundNonPassResult = ETrue; + } + } + } + + CleanupStack::PopAndDestroy(resultData); + CleanupStack::Pop(&logFile); + logFile.Close(); + CleanupStack::Pop(&fS); + fS.Close(); + + if (foundMarker) + { + if (foundNonPassResult) + { + return EFail; + } + else + { + return EPass; + } + } + else + { + return EInconclusive; + } + } + +/** + * Implement the DELAY command + */ +void CScriptControl::StartTimerFromScriptLine() + { + TLex lex(iCurrentScriptLine); + lex.NextToken(); + TLex delayLex(lex.NextToken()); + TInt delay; + // Read the delay in milliseconds + TInt err = delayLex.Val(delay); + if(err) + // Set the default + delay = KDefaultDelayMilliseconds; + iTimer.After(iStatus,delay*1000); + } + +/** + * Secure - same for Target and Wins + */ +void CScriptControl::RunCedFromScriptLineL() + { + TLex lex(iCurrentScriptLine); + // Skip CED + lex.NextToken(); + TPtrC cedCommandLine(lex.Remainder()); + iCurrentScriptLine.Set(cedCommandLine); + RProcess process; + User::LeaveIfError(process.Create(_L("ced.exe"),iCurrentScriptLine)); + process.Rendezvous(iStatus); + // Run CED asynchronously + process.Resume(); + process.Close(); + } + +/** + * Set up the path of a script file for a child CScriptControl object + */ +void CScriptControl::GetScriptFileFromScriptLine() + { + TLex lex(iCurrentScriptLine); + lex.NextToken(); + iChildScriptFile.Set(lex.NextToken()); + } + +/** + * @param aUtilsCommand - Command string for the utilities command + * Implement basic commands: + * NB: Always requires the full path + * Logic borrowed from Scheduletest + * Always complete synchronously + * + * CopyFile + * MKDir + * MakeReadWrite + * Delete + * DeleteDirectory + */ +void CScriptControl::RunUtilsFromScriptLineL() const + { + _LIT(KDefault, "?:\\default"); + _LIT(KCDrive, "?:\\"); + _LIT(KTEFBackslash, "\\" ); + + TBuf<10> defaultPath(KDefault); + defaultPath.Replace(0, 2, iTestSysDrive); + + TBuf<3> cDrive(KCDrive); + cDrive.Replace(0, 2, iTestSysDrive); + + RFs fS; + User::LeaveIfError(fS.Connect() ); + CleanupClosePushL(fS); + + TLex lex(iCurrentScriptLine); + lex.NextToken(); + TPtrC token(lex.NextToken()); + if(token.CompareF(KTEFRunUtilsCopyFile) == 0) + { + TPtrC file1=lex.NextToken(); + TPtrC file2=lex.NextToken(); + TParse source, dest; + CFileMan* fMan = CFileMan::NewL(fS); + CleanupStack::PushL(fMan); + User::LeaveIfError(source.Set(file1, &defaultPath, NULL) ); + User::LeaveIfError(dest.Set(file2, &defaultPath, NULL) ); + User::LeaveIfError(fMan->Copy(source.FullName(), dest.FullName(), CFileMan::EOverWrite) ); + CleanupStack::PopAndDestroy(fMan); + } + else if(token.CompareF(KTEFRunUtilsMkDir) == 0) + { + token.Set(lex.NextToken()); + TParse fileName; + + if (!token.Length()) + User::Leave(KErrPathNotFound); + + TPtrC lastChar(token.Mid(token.Length() - 1)); + if ( lastChar.CompareF(KTEFBackslash) != 0 ) + { + TBuf<64> tempToken(token); + tempToken.Append(KTEFBackslash); + token.Set(tempToken); + } + + User::LeaveIfError( fileName.Set(token, &cDrive, NULL) ); + User::LeaveIfError( fS.MkDir( fileName.DriveAndPath() ) ); + } + else if(token.CompareF(KTEFRunUtilsDeleteFile) == 0 || + token.CompareF(KTEFRunUtilsDelete) == 0) + { + token.Set(lex.NextToken()); + // defect047128 - Code change for handling wildcard deletes + CFileMan* fMan = CFileMan::NewL(fS); + CleanupStack::PushL(fMan); + User::LeaveIfError(fMan->Delete(token) ); + CleanupStack::PopAndDestroy(fMan); + } + else if(token.CompareF(KTEFRunUtilsMakeReadWrite) == 0) + { + token.Set(lex.NextToken()); + TParse fileName; + User::LeaveIfError(fileName.Set(token, &defaultPath, NULL) ); + TInt err = fS.SetAtt(fileName.FullName(),0, KEntryAttReadOnly); + if (err != KErrNone && err != KErrNotFound) + User::Leave(err); + } + //It deletes the specified directory + else if(token.CompareF(KTEFDeleteDirectory) == 0) + { + token.Set(lex.NextToken()); + TParse fileName; + + if (!token.Length()) + User::Leave(KErrPathNotFound); + + TPtrC lastChar(token.Mid(token.Length() - 1)); + if ( lastChar.CompareF(KTEFBackslash) != 0 ) + { + TBuf<64> tempToken(token); + tempToken.Append(KTEFBackslash); + token.Set(tempToken); + } + + CFileMan* fMan = CFileMan::NewL(fS); + CleanupStack::PushL(fMan); + + User::LeaveIfError(fileName.Set(token, &cDrive, NULL) ); + User::LeaveIfError( fMan->RmDir( fileName.DriveAndPath() ) ); + + CleanupStack::PopAndDestroy(fMan); + } + + fS.Close(); + CleanupStack::Pop(&fS); + } + +/** + * Read the Script File data into a heap buffer + * We could read the file line by line but that would be cumbersome, and unless there + * is a heap size problem, this is tidier. + */ +void CScriptControl::CreateScriptDataFromScriptFileL() + { + RFs fS; + User::LeaveIfError(fS.Connect()); + CleanupClosePushL(fS); + RFile scriptFile; + User::LeaveIfError(scriptFile.Open(fS,iScriptFile,EFileRead | EFileShareAny)); + CleanupClosePushL(scriptFile); + TInt fileSize; + User::LeaveIfError(scriptFile.Size(fileSize)); + // Create a 16bit heap buffer + iScriptData = HBufC::NewL(fileSize); + HBufC8* narrowData = HBufC8::NewL(fileSize); + CleanupStack::PushL(narrowData); + TPtr8 narrowPtr=narrowData->Des(); + // Read the file into an 8bit heap buffer + User::LeaveIfError(scriptFile.Read(narrowPtr)); + TPtr widePtr(iScriptData->Des()); + // Copy it to the 16bit buffer + widePtr.Copy(narrowData->Des()); + CleanupStack::PopAndDestroy(narrowData); + CleanupStack::Pop(2); + scriptFile.Close(); + fS.Close(); + // Set up the instance token parser + iScriptLex = iScriptData->Des(); + } + +/** + * Extracts the human readable server name from the current script line then + * calls Client RTestServ Interface to make a connection to the server. + */ +void CScriptControl::CreateServerFromScriptLineL() + { + TLex lex(iCurrentScriptLine); + lex.NextToken(); + TInt i=0; + TInt count = iServers.Count(); + TPtrC serverName(lex.NextToken()); + + // We loop through to see if the server has already been created + for(i=0;iServerName() == serverName) + // Server already exists in our array + break; + } + if(i == count) + { + // Create a new RTestServ pointer and add it to the list + RScriptTestServ* serv = new (ELeave) RScriptTestServ; + // Connect using the client API + TInt err; + if(lex.NextToken().CompareF(KTEFLoadSuiteSharedData) == 0) + { + err = serv->Connect(serverName,ETrue); + } + else + err = serv->Connect(serverName,EFalse); + if(err) + { + // Don't add the server to the array if we fail to connect. + delete serv; + // Caller TRAP's + User::Leave(err); + } + iServers.Append(serv); + } + } + +/** + * @param aIndex - Return the index of the RTestServ instance - If found + * @return - EFalse if server not found. ETrue if server found. + * + */ +TBool CScriptControl::GetServerIndexFromScriptLine(TInt& aIndex) + { + TLex lex(iCurrentScriptLine); + TLex lexTimeout; + _LIT(KErrInvalidArgumentSet,"The arguments are not provided in proper format.\ + Unable to retrieve the details of the server from the command line"); + + TPtrC command(lex.NextToken()); + if(command.CompareF(KTEFRunTestStepResultCommand) == 0) + { + lex.NextToken(); + lex.SkipSpace(); + lex.Mark(); + } + + else if(command.CompareF(KTEFRunPanicStepResultCommand) == 0) + { + lex.NextToken(); + TPtrC panicString(lex.NextToken()); + // Check to see if the panic string contains open quotes and close quotes + // If the panic string token contains open quote, it is understood that the panic string contains spaces + // So, look for close quote in the subsequent tokens. If not found, return boolean false as return value + if(panicString.Left(1).Compare(KTEFOpenQuotes) == 0 && panicString.Right(1).Compare(KTEFOpenQuotes) != 0) + { + TBool validCommandLine(EFalse); + while(!lex.Eos() && !validCommandLine) + { + panicString.Set(lex.NextToken()); + if(panicString.Right(1).Compare(KTEFOpenQuotes) == 0) + validCommandLine = ETrue; + } + if (!validCommandLine) + { + ERR_PRINTF1(KErrInvalidArgumentSet); + return EFalse; + } + } + lex.SkipSpace(); + lex.Mark(); + } + else if(command.CompareF(KTEFRunTestStepCommand) == 0 || + command.CompareF(KTEFStartTestBlock) == 0) + { + TInt firstChar; + TPtrC commandStr; + TBool panicStringComplete(ETrue); + while(!lex.Eos()) + { + lex.SkipSpace(); + lex.Mark(); + + TPtrC token = lex.NextToken(); + if( token.Length()>0 ) + { + commandStr.Set( token ); + firstChar = commandStr[0]; + // 33 is the ascii value for "!". Used here for confirming switches + if (firstChar != KTEFAsciiExclamation && panicStringComplete) + { + break; + } + // Check to see if !PanicString TEF parameter contains panic string with spaces + // If so, see if they are enclosed within a open & close braces + if(commandStr.Length() > 14 && + commandStr.Mid(0,14).Compare(_L("!PanicString=\"")) == 0) + panicStringComplete = EFalse; + if(!panicStringComplete && commandStr.Right(1).Compare(KTEFOpenQuotes) == 0) + panicStringComplete = ETrue; + } + } + if (!panicStringComplete) + { + ERR_PRINTF1(KErrInvalidArgumentSet); + return EFalse; + } + } + + // We need to skip the timeout if it's there. + if( command.CompareF(KTEFRunTestStepCommand) == 0 || + command.CompareF(KTEFStartTestBlock) == 0) + lexTimeout=lex.MarkedToken(); + else + lexTimeout=lex.NextToken(); + TInt timeout; + TPtrC serverName; + if(lexTimeout.Val(timeout) != KErrNone) + // No timeout so use the second token + serverName.Set(lex.MarkedToken()); + else + // Timeout value there + serverName.Set(lex.NextToken()); + TInt i=0; + // Loop through the installed servers + TInt count = iServers.Count(); + for(i=0;iServerName() == serverName) + // Found server installed + break; + } + // Return found or not found + if(i == count) + return EFalse; + else + { + aIndex = i; + if (iServers[i]->SharedData()) + { + iConcurrent = EFalse; + } + return ETrue; + } + } + +/** + * * @return - ETrue if the scriptline is valid, else retuens EFalse + */ +TBool CScriptControl::CheckValidScriptLine() const + { + TLex lex(iCurrentScriptLine); + TPtrC command(lex.NextToken()); + TBool panicCodeSet(EFalse); + TBool panicStringSet(EFalse); + TBool heapValueSet(EFalse); + TBool validScript(ETrue); + TBool oomRequestSet(EFalse); + TBool setupOptionSet(EFalse); + + if(command.CompareF(KTEFRunTestStepCommand) == 0) + { + TInt firstChar; + TPtrC commandStr; + while(!lex.Eos()) + { + lex.SkipSpace(); + commandStr.Set(lex.NextToken()); + firstChar = commandStr[0]; + // 33 is the ascii value for "!". Used here for confirming switches + if (firstChar == KTEFAsciiExclamation) + { + if (commandStr.Length() >= KTEFMinErrorParamLength && commandStr.Mid(0,KTEFMinErrorParamLength).CompareF(KTEFError) == 0) + { + if(command.CompareF(KTEFRunTestStepCommand) == 0) + command.Set(KTEFRunErrorStepResultCommand); + else + validScript = EFalse; + } + else if (commandStr.Length() >= KTEFMinSetupParamLength && commandStr.Mid(0,KTEFMinSetupParamLength).CompareF(KTEFSetUpParam) == 0) + { + if(command.CompareF(KTEFRunTestStepCommand) == 0 && !setupOptionSet) + setupOptionSet = ETrue; + else + validScript = EFalse; + } + else if (commandStr.Length() > KTEFMinResultParamLength && commandStr.Mid(0,KTEFMinResultParamLength).CompareF(KTEFResult) == 0 && commandStr.Mid(KTEFMinResultParamLength).Length() <= KTEFMaxVerdictLength) + { + if (command.CompareF(KTEFRunTestStepCommand) == 0) + command.Set(KTEFRunTestStepResultCommand); + else + validScript = EFalse; + } + else if (commandStr.Length() >= KTEFMinPanicCodeParamLength && commandStr.Mid(0,KTEFMinPanicCodeParamLength).CompareF(KTEFPanicCode) == 0) + { + if ((command.CompareF(KTEFRunTestStepCommand) == 0 || command.CompareF(KTEFRunPanicStepResultCommand) == 0) && !panicCodeSet) + { + command.Set(KTEFRunPanicStepResultCommand); + panicCodeSet=ETrue; + } + else + validScript = EFalse; + } + else if (commandStr.Length() >= KTEFMinPanicStringParamLength && commandStr.Mid(0,KTEFMinPanicStringParamLength).CompareF(KTEFPanicString) == 0) + { + if ((command.CompareF(KTEFRunTestStepCommand) == 0 || command.CompareF(KTEFRunPanicStepResultCommand) == 0) && !panicStringSet) + { + command.Set(KTEFRunPanicStepResultCommand); + panicStringSet = ETrue; + } + else + validScript = EFalse; + } + else + { + if (commandStr.Length() >= KTEFMinHeapParamLength && commandStr.Mid(0,KTEFMinHeapParamLength).CompareF(KTEFHeap) == 0 && !heapValueSet) + heapValueSet = ETrue; + else if (commandStr.Length() >= KTEFMinOomParamLength && commandStr.Mid(0,KTEFMinOomParamLength).CompareF(KTEFOom) == 0 && !oomRequestSet) + oomRequestSet = ETrue; + else + validScript = EFalse; + } + } + else + break; + } + } + return validScript; + } + +/** + * Return the next line in the script file + * @param aScriptLine - return line in the script file minus CRLF + * @return - True if line found, false for end of file. + */ +TBool CScriptControl::GetNextScriptLine(TPtrC& aScriptLine) + { + if(iScriptLex.Eos()) + { + // Fix defect 1193337, check the value is zero or not. If zero, this should be no nested run script + if((0 == iNestedNumRunScriptInLoop) && iLoop) + // End defect 119337 + { + _LIT(KEndRepeatNotFound,"The END_REPEAT command is not found"); + INFO_PRINTF1(KEndRepeatNotFound); + } + + // Fix defect 119337, check if this is still in loop and this run script command is nested + // decrease one shows that the nested number is decreased + else if (iNestedNumRunScriptInLoop > 0 && iLoop) + { + --iNestedNumRunScriptInLoop; + } + // End defect 119337 + + return EFalse; + } + // Mark the current script line to return + iScriptLex.Mark(); + if(iLoop && !iCheckVar) + { + iStoreLoop.Assign(iScriptLex.RemainderFromMark()); + iTempStoreLoop.Assign(iScriptLex.RemainderFromMark()); + iCheckVar=ETrue; + } + // Place the lex marker for the next read + while(!iScriptLex.Eos()) + { + TChar peek = iScriptLex.Peek(); + if(peek == '\n') + { + iScriptLex.Inc(); + iCurrentScriptLineNumber++; + break; + } + else + iScriptLex.Inc(); + } + aScriptLine.Set(iScriptLex.MarkedToken()); + if(aScriptLine.FindF(KTEFRunScriptCommand)!=KErrNotFound && iLoop) + { + // Fix defect 119337, add this integer shows a nested run script added. + ++iNestedNumRunScriptInLoop; + // End Fix defect 119337 + } + if(aScriptLine.Length() || !iScriptLex.Eos()) + return ETrue; + else + return EFalse; + } + +/** + * Return the next line from script file which is to be looped + * @param aScriptLine - return line in the script file which is under loop minus CRLF + * @return -True if line is found else return false + * + * If RUN_SCRIPT command has been encountered return the line from GetNextScriptLine Function + */ +TBool CScriptControl::GetLoopScriptLine(TPtrC& aScriptLine) + { + // Fix defect 119337, check if the run script is nested + if (0 != iNestedNumRunScriptInLoop) + // End defect 119337 + return(GetNextScriptLine(aScriptLine)); + if(iStoreLoop.Eos()) + return EFalse; + iStoreLoop.Mark(); + while(!iStoreLoop.Eos()) + { + TChar peek = iStoreLoop.Peek(); + if(peek == '\n') + { + iStoreLoop.Inc(); + break; + } + else + iStoreLoop.Inc(); + } + aScriptLine.Set(iStoreLoop.MarkedToken()); + if(aScriptLine.Find(KTEFEndRepeat)!=KErrNotFound) + { + iStoreLoop.Assign(iTempStoreLoop); + } + if(aScriptLine.FindF(KTEFRunScriptCommand)!=KErrNotFound) + { + // Fix defect 119337, add this integer shows a nested run script added. + ++iNestedNumRunScriptInLoop; + // End defect 119337 + } + if(aScriptLine.Length() || !iStoreLoop.Eos()) + return ETrue; + else + return EFalse; + } + +/** + * @param aErr - The completion code + * @param aPanicString - Descriptor reference containing the panic string if a test were to panic + * @param aScriptLineNumber - Script line number used for printing result into log file + * @param aCommand - Command name also used for printing result into log file + * Called by a CClientControl or CProgramControl child object + */ +void CScriptControl::TaskCompletion(TInt aErr, const TDesC& aPanicString, TInt aScriptLineNumber,const TDesC& aCommand,TBool aTaskCanComplete,TTEFItemArray* aItemArray) + { + if(aItemArray) + { + TVerdict err = Logger().LogBlock( aItemArray, aScriptLineNumber ); + + // If no error was set on the server side (ie. a panic) then set + // it here with the post processing result + if( EPass == aErr && aPanicString.Length() == 0 ) + { + aErr = err; + } + } + // Log the test step result to the output file + LogResult((TVerdict)aErr, aPanicString, aScriptLineNumber, aCommand); + + if(aErr != KErrNone && aErr != KErrNotSupported && iBreakOnError) + // Put this instance of the script engine into the closing state as we've + // encountered the BREAK_ERROR_ON command. + // KErrNotSupported is considered a benign error + { + iState = EClosing; + } + iAsyncTasksOutstanding--; + // Check the flag first then trigger our own RunL() + if(aTaskCanComplete || iCanComplete) + Complete(aErr); + } + +/** + * Print the current script line to the console + */ +void CScriptControl::PrintCurrentScriptLine() const + { + // Check we don't overflow + TBuf output; + if((iCurrentScriptLine.Length() + iScriptFile.Length() + 4 ) > output.MaxLength()) + { + output.Copy(iAlteredScriptLine); + Logger().PrintCurrentScriptLine(output); + return; + } + // Copy the script filename. Handy for recursion + output.Copy(iScriptFile); + output.Append(KTEFSpace); + // Append the script file line + output.Append(iCurrentScriptLine); + // Write to console + ConsoleLogger().Console().Printf(KTEFStringFormat,&output); + + Logger().PrintCurrentScriptLine(output); + } + +/** + * Checks for commented commands and increments a counter for logging + */ +TBool CScriptControl::CheckCommentedCommands() const + { + if(!iCurrentScriptLine.Length()) + return ETrue; + + TLex lex(iCurrentScriptLine); + TPtrC token(lex.NextToken()); + if (!token.Length()) + return ETrue; + + TInt firstChar = iCurrentScriptLine[0]; + if(firstChar == '/') + { + TInt findRunTestStep; + TInt findRunPanicStep; + TInt findRunScript; + TInt findRunProgram; + TInt findRunWSProgram; + TInt findStartTestBlock; + findRunTestStep=iCurrentScriptLine.Find(KTEFRunTestStepCommand); + findRunScript=iCurrentScriptLine.Find(KTEFRunScriptCommand); + findRunPanicStep=iCurrentScriptLine.Find(KTEFRunPanicStepCommand); + findRunProgram=iCurrentScriptLine.Find(KTEFRunProgramCommand); + findRunWSProgram=iCurrentScriptLine.Find(KTEFRunWSProgramCommand); + findStartTestBlock=iCurrentScriptLine.Find(KTEFStartTestBlock); + if(findRunTestStep>0 || findRunScript>0 || findRunPanicStep>0 || findRunProgram>0 || findRunWSProgram>0 || findStartTestBlock>0 && !iStartLooping) + { + commentedCommandsCount++; + } + } + if(firstChar == '\r' || firstChar == '\n' || firstChar == '#' || firstChar == '/') + return ETrue; + return EFalse; + } + +/** + * @param aResult - Test Step result + * @param aPanicString - Descriptor containing the panic string if test were to panic + * @param aScriptLineNumber - The line in the script file + * @param aCommand - Command name whose result is set for logging + * Log a RUN_TEST_STEP, RUN_PANIC_STEP or RUN_PROGRAM result to file + */ +void CScriptControl::LogResult(TVerdict aResult, const TDesC& aPanicString, TInt aScriptLineNumber,const TDesC& aCommand) + { + // Call the Logger()'s LogResult() routine to manipulate results of RUN_TEST_STEP command/variants + // Also controls the fields for logging both HTML & XML logging + Logger().LogResult(aResult, aPanicString, aScriptLineNumber, aCommand, iScriptFile, RFileFlogger::ESevrHigh); + } + +/** + * Constructor + * @param RTestServ - Reference to a root RTestServer instance + * @param aCommand - Reference to a RUN_TEST_STEP script line + * @param MTaskCompletion - Reference to the parent completion interface + * @param aScriptLineNumber - The line in script file + * @param aLogger - Reference to the Logger class + * @param aLoopIndex - TInt reference that provides the loop index for the test. The value is 0 if not in loop. + * @param aTestCaseID - Descriptor containing the test case id, if test run is within a test case + * @param aScriptFilePath - The path of the script file being executed + * @param aSysDrive - Default system drive letter + * @param aTestSysDrive - System drive letter overwritten from testexecute.ini + */ +CClientControl::CClientControl(RScriptTestServ& aServ,const TDesC& aCommand, MTaskCompletion& aCompletion, TInt aScriptLineNumber, CTestExecuteLogger& aLogger, TInt aLoopIndex, const TDesC& aTestCaseID, TPtrC& aScriptFilePath, const TDriveName& aSysDrive, const TDriveName& aTestSysDrive) +: CTaskControlBase(aCommand,aCompletion,aScriptLineNumber,aLogger) +, iServ(aServ) +, iRetryCount(0) +, iLoopIndex(aLoopIndex) +, iTestCaseID(aTestCaseID) +, iBlockArrayPkg(NULL) +, iBlockArrayPtr(STATIC_CAST(TUint8*,NULL), 0) +, iScriptFilePath(aScriptFilePath) +, iDefaultSysDrive(aSysDrive) +, iTestSysDrive(aTestSysDrive) + { + // Extract the parameters to the test step and store them in the class + GetStepParamsFromStepCommand(); + } + +CClientControl* CClientControl::NewL( RScriptTestServ& aTestServ, + const TDesC& aCommand, + MTaskCompletion& aCompletion, + TInt aScriptLineNumber, + CTestExecuteLogger& aLogger, + TInt aLoopIndex, + const TDesC& aTestCaseID, + const TDesC& aEndBlockCommand, + TPtrC& aScriptFilePath, + const TTEFItemArray& aBlockArray, + const TDriveName& aSysDrive, + const TDriveName& aTestSysDrive) + { + CClientControl* self = new (ELeave) CClientControl( aTestServ, + aCommand, + aCompletion, + aScriptLineNumber, + aLogger, + aLoopIndex, + aTestCaseID, + aScriptFilePath, + aSysDrive, + aTestSysDrive); + CleanupStack::PushL(self); + self->ConstructL(aEndBlockCommand, aBlockArray); + CleanupStack::Pop(); + return self; + } + +void CClientControl::ConstructL( const TDesC& aEndBlockCommand, const TTEFItemArray& aBlockArray ) + { + iEndBlockCommand.Set( aEndBlockCommand ); + TTEFItemPkgBuf itemPckgBuf; + TInt count = aBlockArray.Count(); + iBlockArrayPkg = HBufC8::NewL( count * itemPckgBuf.Size() ); + iBlockArrayPtr.Set( iBlockArrayPkg->Des() ); + for( TInt i=0; iDes()); + TInt count = blockArrayPtr.Size()/itemPckgBuf.Size(); + TTEFItemArray* itemArray = new (ELeave) TTEFItemArray( count ); + CleanupStack::PushL( itemArray ); + + TInt pos = 0; + for( TInt i=0; iAppendL( itemPckgBuf() ); + } + + return itemArray; + } + +/** + * Destructor + */ +CClientControl::~CClientControl() + { + iTimer.Cancel(); + iTimer.Close(); + + if( iBlockArrayPkg ) + { + delete iBlockArrayPkg; + iBlockArrayPkg = NULL; + } + } +const TInt KDisableTimer = -1; + +/** + * Test step has done. log the test result. + */ +void CClientControl::TestStepComplete() + { + iSession.Close(); + if(iBlockArrayPkg) + { + TTEFItemArray *itemArray = CreateBlockArrayLC(); + iParent.TaskCompletion(iStatus.Int(), iTaskExitCategory, iScriptLineNumber, iEndBlockCommand, iTaskCanComplete, itemArray); + CleanupStack::PopAndDestroy(itemArray); + } + else + { + iParent.TaskCompletion(iStatus.Int(), iTaskExitCategory, iScriptLineNumber, iCommandLine, iTaskCanComplete); + } + } + +/** + * Pure virtual + * Test step handling state machine + * Kick'd() into by the parent CScriptControl object. Constructed in the EInit state + */ +void CClientControl::RunL() + { + switch(iState) + { + case EInit : + User::LeaveIfError(iTimer.CreateLocal()); + if(iBlockArrayPkg) + { + User::LeaveIfError(iSession.Open(iServ, EFalse)); + } + else + { + User::LeaveIfError(iSession.Open(iServ, ETrue, iStepName)); + } + // Whilst testing concurrent mode, the OS occasionally completes with + // KErrServerBusy or KErrInUse. + + // clean up retry counter. case ERetry will using. + iRetryCount = 0; + case EServerRetry : + { + SetActive(); + + // Set the heap size for creating the thread heap size + iTaskExitCategory.Copy(iTaskHeapSize); + + TBuf<5> checkOOMArgsBuf; + + // Check if the step args has the OOM arguments already + // A minimum 5 chars expected to check this : "OOM=0" or "OOM=1" + if (iStepArgs.Length() >=5) + { + // Extract the first 5 chars from the start of step args string + checkOOMArgsBuf.Copy(iStepArgs.Mid(0,5)); + } + + _LIT(KOOMOne,"OOM=1"); + _LIT(KOOMZero,"OOM=0"); + + // Set the OOM argument after checking for existence of OOM param already + if ((checkOOMArgsBuf.CompareF(KOOMOne) != KErrNone) && (checkOOMArgsBuf.CompareF(KOOMZero) != KErrNone)) + { + // Insert the OOM arguments to the start of iStepArgs string + if (iOOMRequestSet) // Set OOM=1 if !OOM is used in the RUN_TEST_STEP command + iStepArgs.Insert(0,_L("OOM=1 ")); + else + iStepArgs.Insert(0,_L("OOM=0 ")); + } + + TBuf checkSetUpArgsBuf; + + // Check if the step args has the Setup arguments already + // A min of 13 chars expected to check this : "OOM=0 !Setup=" or "OOM=1 !Setup=" + if (iStepArgs.Length() >=13) + { + // Extract 7 chars after skipping the OOM arguments "OOM=0 " or "OOM=1 " + checkSetUpArgsBuf.Copy(iStepArgs.Mid(6,7)); + } + + // Set the !Setup argument after checking for existence !Setup param already + if (checkSetUpArgsBuf.CompareF(KTEFSetUpParam) != KErrNone) + { + // Retain the !Setup value from RUN_TEST_STEP command, if available + if (iSetUpParamValue.Length() == KTEFZeroValue) + { + // If !Setup is not used in RUN_TEST_STEP, set the !Setup to TTestSetupState::ESetupNone (0) + iSetUpParamValue.Copy(KTEFSetUpParam); + iSetUpParamValue.AppendNum(TTestSetupState(ESetupNone)); + } + + // Append a space and also include the loop index + iSetUpParamValue.Append(KTEFSpace); + // The loop index is 0 if the test is not in loop; loop index, otherwise + iSetUpParamValue.AppendNum(iLoopIndex); + iSetUpParamValue.Append(KTEFSpace); + + // Append the TestCaseID along with the Setup params + iSetUpParamValue.Append(iTestCaseID); + iSetUpParamValue.Append(KTEFSpace); + + // Insert the !Setup arguments after the OOM arguments within the iStepArgs + iStepArgs.Insert(6, iSetUpParamValue); + } + + // Call the async client API to run the test step + if(iBlockArrayPkg) + { + iSession.RunTestBlock(iStepArgs,iTaskExitCategory,iBlockArrayPtr,iStatus); + } + else + { + iSession.RunTestStep(iStepArgs,iTaskExitCategory,iStatus); + } + // Start a timer and provide it with our callback MTaskCompletion + iState = ERunning; + // Only start the timer if the disable value is not set + if(iTaskTimeout != KDisableTimer) + { + iTaskTimer = CTaskTimer::NewL(*this); + iTaskTimer->Timeout(iTaskTimeout); + } + } + break; + + case ERunning : + { + // We have been completed but we need to find out the source + // If the timer expires it Aborts the server test step which results in + // the RunTestStep call completing with KErrAbort. + // When the timer expires it calls us back and we delete it then NULL it. + if(iTaskTimer) + { + // The timer did not expire + iTaskTimer->Cancel(); + delete iTaskTimer; + iTaskTimer = NULL; + } + const TInt KRetry10Microseconds = 100000; + const TInt KMaxRetryCount = 20; + if(iStatus.Int() == KErrInUse && iRetryCount < KMaxRetryCount) + { + // OS (not the server) has rejected the call. + // Timed retry + // Noticed this one after panic's in shared data mode + iState = EServerRetry; + // Keep increasing the timeout + iRetryCount++; + SetActive(); + iLogger.LogExtra((TText8*)__FILE__,__LINE__,ESevrInfo, + _L("Error Message :: The Task Is Retrying ")); + iTimer.After(iStatus,KRetry10Microseconds * iRetryCount); + } + else if(iStatus.Int() == KErrServerBusy) + { + // tempt to do test again when test server return busy. + iState = EServerRetry; + iRetryCount++; + if(iRetryCount < KMaxRetryCount) + { + iState = EServerRetry; + SetActive(); + iLogger.LogExtra((TText8*)__FILE__,__LINE__,ESevrInfo, + _L("Error Message : Server return -16 = KErrServerBusy : Retrying %d"),iRetryCount); + iTimer.After(iStatus,KRetry10Microseconds ); + } + else//server alwayse busy. stop test. + { + iLogger.LogExtra((TText8*)__FILE__,__LINE__,ESevrErr, + _L("Error Message : Server Busy Retrying %d times. Test Teminated!"),iRetryCount); + iParent.TaskCompletion(iStatus.Int(),iTaskExitCategory,iScriptLineNumber,iCommandLine,iTaskCanComplete); + + iSession.Close(); + delete this; + } + } + else + { + // see testserverbase.cpp::void SytemWideErrToTefErr(TInt &aErr). converting thi value. + //Check the status, if the status is KErrTestExecuteInUse + //then log the information and change it back to + if(iStatus.Int() == KErrTestExecuteInUse) + { + //Convert the status back to KErrInUse + iStatus=KErrInUse; + } + else if(iStatus.Int() == KErrTestExecuteServerBusy) + { + //this is not server really busy! we should change the server side iStatus back to -16 + //Convert the status back to KErrServerBusy + iStatus = KErrServerBusy; + } + // Step completion + TestStepComplete(); + delete this; + } + } + break; + + default: + break; + } + } + +/** + * @param aError - TInt value representing error returned due to processing request from RunL() + * Handles the leave from RunL() and cleans up the allocated objects + * Also returns KErrNone upon sucessful handling of leave + */ +TInt CClientControl::RunError(TInt aError) + { + if(iBlockArrayPkg) + { + TTEFItemArray* itemArray = CreateBlockArrayLC(); + iParent.TaskCompletion(aError,iTaskExitCategory,iScriptLineNumber,iEndBlockCommand,iTaskCanComplete,itemArray); + CleanupStack::PopAndDestroy( itemArray ); + } + else + { + iParent.TaskCompletion(aError,iTaskExitCategory,iScriptLineNumber,iCommandLine,iTaskCanComplete); + } + delete this; + return KErrNone; + } + +/** + * Extract and save the timeout, step name and test step arguments + */ +void CClientControl::GetStepParamsFromStepCommand() + { + TLex scriptLineLex(iCommandLine); + TPtrC command(scriptLineLex.NextToken()); + if(command.CompareF(KTEFRunTestStepResultCommand) == 0) + scriptLineLex.NextToken(); + else if(command.CompareF(KTEFRunPanicStepResultCommand) == 0) + { + scriptLineLex.NextToken(); + TPtrC panicString(scriptLineLex.NextToken()); + if(panicString.Left(1).Compare(KTEFOpenQuotes) == 0 && panicString.Right(1).Compare(KTEFOpenQuotes) != 0) + { + TBool validCommandLine(EFalse); + while(!scriptLineLex.Eos() && !validCommandLine) + { + panicString.Set(scriptLineLex.NextToken()); + if(panicString.Right(1).Compare(KTEFOpenQuotes) == 0) + validCommandLine = ETrue; + } + } + } + else if(command.CompareF(KTEFRunTestStepCommand) == 0 || + command.CompareF(KTEFStartTestBlock) == 0 ) + { + TInt firstChar; + TPtrC commandStr; + TBool panicStringComplete(ETrue); + while(!scriptLineLex.Eos()) + { + scriptLineLex.SkipSpace(); + scriptLineLex.Mark(); + + TPtrC token = scriptLineLex.NextToken(); + if( token.Length()>0 ) + { + commandStr.Set( token ); + firstChar = commandStr[0]; + // 33 is the ascii value for "!". Used here for confirming switches + if (firstChar != KTEFAsciiExclamation && panicStringComplete) + { + break; + } + if(commandStr.Length() > 14 && + commandStr.Mid(0,14).Compare(_L("!PanicString=\"")) == 0) + panicStringComplete = EFalse; + if(!panicStringComplete && commandStr.Right(1).Compare(KTEFOpenQuotes) == 0) + panicStringComplete = ETrue; + if (commandStr.Length() >= KTEFMinHeapParamLength && commandStr.Mid(0,KTEFMinHeapParamLength).CompareF(KTEFHeap) == 0) + iTaskHeapSize.Set(commandStr.Mid(KTEFMinHeapParamLength)); + else if (commandStr.Length() >= KTEFMinSetupParamLength && commandStr.Mid(0,KTEFMinSetupParamLength).CompareF(KTEFSetUpParam) == 0) + iSetUpParamValue.Copy(commandStr); + else if (commandStr.Length() >= KTEFMinOomParamLength && commandStr.Mid(0,KTEFMinOomParamLength).CompareF(KTEFOom) == 0) + { + // Out of memory cannot be supported for UREL builds due to UHEAP macros + // not being supported in UREL builds + #if defined(_DEBUG) + iOOMRequestSet = ETrue; + #else + iOOMRequestSet = EFalse; + iLogger.LogExtra((TText8*)__FILE__,__LINE__,ESevrWarn, + _L("Out of Memory Testing is not supported for UREL builds")); + #endif + } + } + } + } + + TLex timeoutLex; + if( command.CompareF(KTEFRunTestStepCommand) == 0 || + command.CompareF(KTEFStartTestBlock) == 0) + timeoutLex = scriptLineLex.MarkedToken(); + else + timeoutLex = scriptLineLex.NextToken(); + TInt err = timeoutLex.Val(iTaskTimeout); + if(err) + { + // No timeout specified + iTaskTimeout = KDefaultTimeoutSeconds; + iStepName.Set(scriptLineLex.NextToken()); + } + else + { + scriptLineLex.NextToken(); + if( command.CompareF(KTEFRunTestStepCommand) == 0 || + command.CompareF(KTEFRunTestStepResultCommand) == 0 || + command.CompareF(KTEFRunPanicStepResultCommand) == 0 || + command.CompareF(KTEFRunPanicStepCommand) == 0|| + command.CompareF(KTEFRunErrorStepResultCommand) == 0) + { + // Save the step name + iStepName.Set(scriptLineLex.NextToken()); + } + } + // The rest is sent to the server + scriptLineLex.SkipSpace(); + iStepArgs.Copy(iScriptFilePath.Mid(0,2)); + iStepArgs.Append(KTEFSpace); + iStepArgs.Append(iDefaultSysDrive); + iStepArgs.Append(KTEFSpace); + iStepArgs.Append(iTestSysDrive); + iStepArgs.Append(KTEFSpace); + iStepArgs.Append(scriptLineLex.Remainder()); + } + +/** + * Callback from a CTaskTimer object + * Abort the test step, NULL the timer so we know that a timeout has caused test step completion + */ +void CClientControl::TaskTimerCompletion() + { + delete iTaskTimer; + iTaskTimer = NULL; + iSession.AbortTestStep(); + } + +/** + * Constructor + * @param aCompletion - Reference to a callback method in the CClientControl parent object + */ +CTaskTimer::CTaskTimer(MTaskTimerCompletion& aCompletion) : CTimer(EPriorityUserInput), iParent(aCompletion) + { + CActiveScheduler::Add(this); + } + +/** + * Iterate till the timer has expired and callback into the parent + */ +void CTaskTimer::RunL() + { + if (iTimesAfter > 0 || iSecondsRemaining > 0) + { + RunTimeout(); // Function call implementing the After() routines + } + else + { + iParent.TaskTimerCompletion(); // Call the completion routine for the timeout + } + } + +/** + * Implements a timeout based using CTimer::After() + * Modified for handling huge timeout values + * @param aSeconds - Timeout value in seconds + */ + void CTaskTimer::Timeout(TInt aSeconds) + { + iTimesAfter = aSeconds/60; // Convert the aSeconds to equivalent minutes + iSecondsRemaining = (aSeconds - (iTimesAfter*60)); // Remainder of seconds after converting to equivalent minutes + RunTimeout(); + } + +/** + * Implements the After() routines for the timeout value specified + * The call is initiated from Timeout() & is iterated from the RunL() + */ +void CTaskTimer::RunTimeout() + { + if (iTimesAfter > 0) + { + After(60*1000000); // Call After() for every minute until iTimesAfter is >0 + iTimesAfter--; + } + else if (iSecondsRemaining > 0) + { + After(iSecondsRemaining*1000000); // Call After() for remainder of microsec + iSecondsRemaining = 0; + } + } + +/** + * Destructor + */ +CTaskTimer::~CTaskTimer() + { + } + +/* + * @param aCompletion - Reference to a callback method in a CTaskControlBase parent object + * Two phase contruction + */ +CTaskTimer* CTaskTimer::NewL(MTaskTimerCompletion& aCompletion) + { + CTaskTimer* taskTimer = new(ELeave) CTaskTimer(aCompletion); + CleanupStack::PushL(taskTimer); + // We have to call the base class second phase constructor + taskTimer->ConstructL(); + CleanupStack::Pop(taskTimer); + return taskTimer; + } + +/** + * @param aCommand - Command for the derived class + * @param aCompletion - Reference to the parent class callback method + * @param aScriptLineNumber - The script file line number of this command + * @param aLogger - Reference to a Flogger derived session + * Constructor - Just initialise the abstract class data + */ +CTaskControlBase::CTaskControlBase(const TDesC& aCommand, MTaskCompletion& aCompletion,TInt aScriptLineNumber, CTestExecuteLogger& aLogger) : + iCommandLine(aCommand), + iParent(aCompletion), + iScriptLineNumber(aScriptLineNumber), + iLogger(aLogger), + iTaskTimer(NULL) + { + } + +/** + * Destructor + */ +CTaskControlBase::~CTaskControlBase() + { + } + +/** + * @param aCommand - Command line for the program (Store in base class) + * @param aCompletion - Reference to the parent class callback method (Store in base class) + * @param aScriptLineNumber - The script file line number of this command (Store in base class) + * @param aLogger - Reference to a Flogger derived session (Store in base class) + * @param aWSProgRun - Boolean value used for identifying window server programs + */ +CProgramControl::CProgramControl(const TDesC& aCommand,MTaskCompletion& aCompletion,TInt aScriptLineNumber, CTestExecuteLogger& aLogger, TBool aWSProgRun) : CTaskControlBase(aCommand,aCompletion,aScriptLineNumber,aLogger), + iState(EInit) + { + // Extract the program arguments from the command line + GetProgramArgsFromCommand(); + + // Try to connect to the window server (if available) + iWSProgRun = aWSProgRun; + #if !defined TEF_LITE + if( iWSProgRun ) + { + iWs.Connect(); + } + #else + // Always set to false if TEF_LITE is set + //iWSProgRun = EFalse; + #endif + } + +/** + * Destructor + */ +CProgramControl::~CProgramControl() + { + #if !defined TEF_LITE + if( iWSProgRun ) + { + iWs.Close(); + } + #endif + } + +/** + * Simple State machine. + * Kick()'d into by parent object. + * Runs an executable in its own process. + */ +void CProgramControl::RunL() + { + switch(iState) + { + case EInit : + { + TRAPD(err,RunProgramL()); + if(err != KErrNone) + { + // Special case where the executable has already completed + if( err == KErrCompletion ) + { + // Reset the error code + err = KErrNone; + } + // Failed so complete immediately + iParent.TaskCompletion(err,iTaskExitCategory,iScriptLineNumber,iCommandLine,iTaskCanComplete); + delete this; + } + else + { + SetActive(); + iState = ERunning; + // Only start the timer if the disable value is not set + if(iTaskTimeout != KDisableTimer) + { + iTaskTimer = CTaskTimer::NewL(*this); + iTaskTimer->Timeout(iTaskTimeout); + } + if (iProgRenamed == 1) + { + iLogger.LogExtra((TText8*)__FILE__,__LINE__,ESevrInfo, + _L(".EXE not found - .APP run instead")); + } + + } + } + break; + + case ERunning : + { + if(iTaskTimer) + { + // The timer did not expire + iTaskTimer->Cancel(); + delete iTaskTimer; + iTaskTimer = NULL; + } + // Set up the panic string if the program panicked + if( !iWSProgRun ) + { + if(iProgram.ExitType() == EExitPanic) + { + iTaskExitCategory.Copy(KPanicEquals); + iTaskExitCategory.Append(iProgram.ExitCategory()); + } + else if (iProgram.ExitType() == EExitPending) + { + iProgram.Kill(KErrAbort); + iLogger.LogExtra((TText8*)__FILE__,__LINE__,ESevrWarn, + _L("Program has been killed as the timeout is achieved.")); + } + iProgram.Close(); + } + #if !defined TEF_LITE + else + { + if(iProgramWS.ExitType() == EExitPanic) + { + iTaskExitCategory.Copy(KPanicEquals); + iTaskExitCategory.Append(iProgramWS.ExitCategory()); + } + + // Close the application + TInt prev = 0; + TInt winGid = iWs.FindWindowGroupIdentifier(prev, iProgramWS.Id()); + TApaTask task(iWs); + task.SetWgId(winGid); + if( task.Exists() ) + { + task.KillTask(); + } + iProgramWS.Close(); + } + #endif + + // Complete to the parent object. + iParent.TaskCompletion(iStatus.Int(),iTaskExitCategory,iScriptLineNumber,iCommandLine,iTaskCanComplete); + delete this; + } + break; + + default: + break; + } + } + +/** + * Retrieve the program arguments from the script line. + */ +void CProgramControl::GetProgramArgsFromCommand() + { + TLex scriptLineLex(iCommandLine); + // Skip the RUN_PROGRAM command + scriptLineLex.NextToken(); + TLex lex(scriptLineLex); + // Get the timer if it's been included + TLex timeoutLex(lex.NextToken()); + TInt err = timeoutLex.Val(iTaskTimeout); + if(err) + // No timeout specified + iTaskTimeout = KDefaultTimeoutSeconds; + else + // Skip the timeout value + scriptLineLex.NextToken(); + scriptLineLex.SkipSpace(); + // Use the rest + iProgramArgs.Set(scriptLineLex.Remainder()); + } + +/** + * Task timer expired + */ +void CProgramControl::TaskTimerCompletion() + { + delete iTaskTimer; + iTaskTimer = NULL; + if( !iWSProgRun ) + { + iProgram.RendezvousCancel(iStatus); + } + #if !defined TEF_LITE + else + { + iProgramWS.RendezvousCancel(iStatus); + } + #endif + // We ORPHAN the process + // Our RunL() gets called immediately + // Kill requires KillAnyProcess capability + // ups the stakes as regards CAPABILITY + } + +/** + * Processes RUN_PROGRAM command arguments and starts the program + */ +void CProgramControl::RunProgramL() + { + TLex lex(iProgramArgs); + // Get program name. + lex.Mark(); + lex.NextToken(); +#if !defined TEF_LITE + // Set up the program arguments + TBuf programArgs(lex.Remainder()); + programArgs.Trim(); + iProgramArgs.Set(programArgs); + + if( !iWSProgRun ) + { + // Create the Process + User::LeaveIfError(iProgram.Create(lex.MarkedToken(),iProgramArgs)); + } + else + { + if( !IsWindowServerAvailable() ) + { + User::Leave(KErrNotSupported); + } + + // Launch the application using RApaLsSession + // This will only work if there is a window server available. + // It allows TechView apps to be launched + CApaCommandLine *cmd=CApaCommandLine::NewLC(); + cmd->SetExecutableNameL(lex.MarkedToken()); + + // Set the program arguments + cmd->SetDocumentNameL( iProgramArgs ); + cmd->SetCommandL(EApaCommandRun); + + User::LeaveIfError( iApaLsSess.Connect() ); + // startup + TThreadId thread; + User::LeaveIfError( iApaLsSess.StartApp(*cmd, thread) ); + TInt ret = iProgramWS.Open(thread); + if( ret != KErrNone ) + { + if( ret == KErrNotFound ) + { + // If the thread can not be found then it has already completed + // Leave with a relavent error + User::Leave(KErrCompletion); + } + User::Leave(ret); + } + + //cleanup + iApaLsSess.Close(); + CleanupStack::PopAndDestroy(); + } +#else +/** + * Kick off an exe in its own pocess + * completes asynchronously + */ + + if (iWSProgRun) //TEF lite doesn't support RUN_WS_PROGRAM. + { + iLogger.LogExtra((TText8*)__FILE__,__LINE__,ESevrErr, + _L("Error Message :: TEF lite doesn't support RUN_WS_PROGRAM.")); + User::Leave(EFail); + } + + // Set up the program arguments + TPtrC commandLine(lex.Remainder()); + iProgramArgs.Set(commandLine); + // Create the Process + User::LeaveIfError(iProgram.Create(lex.MarkedToken(),iProgramArgs)); + +#endif + if( !iWSProgRun ) + { + iProgram.Rendezvous(iStatus); + iProgram.Resume(); + } + #if !defined TEF_LITE + else + { + iProgramWS.Rendezvous(iStatus); + } + #endif + } + +/** + * @param aServerName - Test server to connect to + * @param aSharedData - Flag for shared data mode session with test server + * Connect to the test server + * EKA2 version requires a just in time debug flag for the test server process + * This is read from the command line. + * Base class connect acts on this. + */ +TInt RScriptTestServ::Connect(const TDesC& aServerName,TBool aSharedData) + { + iSharedData = aSharedData; + // Parse the command line for -d + TBuf commandLine; + if(User::CommandLineLength() > commandLine.MaxLength()) + User::Leave(KErrTooBig); + User::CommandLine(commandLine); + TLex flagLex(commandLine); + // Default to false + TBool aJustInTime(EFalse); + while(!flagLex.Eos()) + { + TPtrC token(flagLex.NextToken()); + if(token == KTestExecuteCommandLineFlagDebugMode) + { + aJustInTime = ETrue; + break; + } + } + return RTestServ::Connect(aServerName,aJustInTime); + + } + +/** + * Copies the integer value read from ini file to the reference integer passed to the function + * @param aConfigData - Pointer to CIniData object used for reading data from ini file + * @param aConfigSection - Descriptor value describing the section name within an ini file for reading + * @param aSharedData - KeyName within a section where the input data is available in ini file + * @param aSharedDataNum - Reference integer variable for collecting the value at the keyname specified + * @Leave system wide errors + */ +void CScriptControl::FindValueL(CIniData* aConfigData, TPtrC aConfigSection, TPtrC aSharedData, TInt& aSharedDataNum) + { + aConfigData->FindVar(aConfigSection, aSharedData, aSharedDataNum); + if (aSharedDataNum == 0) + { + User::Leave(KErrGeneral); + } + } + +/** + * Copies the descriptor value read from ini file to the reference descriptor passed to the function + * @param aConfigData - Pointer to CIniData object used for reading data from ini file + * @param aConfigSection - Descriptor value describing the section name within an ini file for reading + * @param aSharedData - KeyName within a section where the input data is available in ini file + * @param aSharedDataName - Reference descriptor variable for collecting the value at the keyname specified + * @Leave system wide errors + */ +void CScriptControl::FindValueL(CIniData* aConfigData, TPtrC aConfigSection, TPtrC aSharedData, TPtrC& aSharedDataName) + { + User::LeaveIfError(aConfigData->FindVar(aConfigSection, aSharedData, aSharedDataName)); + TPtrC blankString(KNull); + if (aSharedDataName.CompareF(blankString) == 0) + { + User::Leave(KErrGeneral); + } + } + +/** + * Creates one or more shared objects based on the inputs provided in ini file + * @Leave system wide errors + */ +void CScriptControl::CreateSharedObjectsFromScriptLineL() + { + CIniData* configData = NULL; + TInt err = 0; + TInt sharedDataCount = 0; + TPtrC sharedDataName; + + // Sets the boolean to ETrue + // Avoids SHARED_DATA command being called more than once + iIsSharedData = ETrue; + + //It copies the current line from the script to TLex object + TLex shareLex(iCurrentScriptLine); + + //reads the next word + shareLex.NextToken(); + + TPtrC configFile(shareLex.NextToken()); + + TPtrC configSection(shareLex.NextToken()); + + if(configFile.Length()) + { + // Create instance of CIniData for reading ini input + TRAP(err,configData = CIniData::NewL(configFile)); + } + if(err != KErrNone) + { + ERR_PRINTF1(KTEFErrorReadingIni); + User::Leave(err); + } + if(configData) + { + CleanupStack::PushL(configData); + TPtrC sharedDataNumberKey(KTEFSharedDataNum); + // Read the ini file for number of shared objects to be created + // Store the value into variable sharedDataCount + TRAP(err,FindValueL(configData,configSection,sharedDataNumberKey,sharedDataCount)); + if (err != KErrNone) + { + ERR_PRINTF1(KTEFErrNumberOfShareNotInIni); + } + else + { + // If ini input is available for number of shared data + // Run a loop to read individual shared objects name + for (TInt i=1; i<=sharedDataCount; i++) + { + TBuf<20> keyName(KTEFSharedName); + + keyName.AppendNum(i); + + keyName.ZeroTerminate(); + + TPtrC sharedDataNameKey(keyName); + + sharedDataName.Set(KNull); + + // Read ini file for i th object name + TRAP(err,FindValueL(configData,configSection,sharedDataNameKey,sharedDataName)); + if (err != KErrNone) + { + ERR_PRINTF2(KTEFErrShareNameNotInIni,i); + } + else + { + // Number of shared data is limited to the value set in the constant KTEFMaxSharedArraySize + // The constant is defined in ScriptEngine.h which can be extended from there + if (iSharedDataNum < KTEFMaxSharedArraySize) + { + // If ini input is available for i th object name + // Creating template class object for sharing the object + CTestSharedData* sharedObject = NULL; + + CTEFSharedData* sharedData1 = NULL; + TRAP(err,sharedData1 = CTEFSharedData::NewL(sharedObject, KTEFSharedDataSize, sharedDataName)); + if (err != KErrNone) + { + User::Leave(err); + } + else + { + sharedData1->EnterCriticalSection(); + sharedObject->Construct(); + sharedData1->ExitCriticalSection(); + // Adding the template object to an array + iSharedDataArray[iSharedDataNum] = sharedData1; + // Counting the number of objects created + // destructor can destroy the objects based on this count + iSharedDataNum++; + } + } + else + { + WARN_PRINTF1(KTEFMaxNumberOfSharedObjectsReached); + } + } + } + } + // Cleanup CInidata object + CleanupStack::PopAndDestroy(configData); + } + } + +/** + * Parses the test block header + * @Return ETrue if pass ok else EFalse + */ +// Fix defect 118337, check the configuration file exists or not, and set the flag. +TBool CScriptControl::ParseTestBlockHeader() + { + TLex lex(iCurrentScriptLine); + TPtrC token = lex.NextToken(); + TInt paraCount = 1; + const TInt KLeastBlockHeaderParaCount = 4; + _LIT(KLegacySysDrive, "C:"); + _LIT(KDefaultIniFilePath, "\\System\\Data\\"); + + while (!lex.Eos()) + { + token.Set(lex.NextToken()); + lex.SkipSpace(); + ++paraCount; + } + + if (paraCount < KLeastBlockHeaderParaCount) + { + _LIT(KBadError, "Bad error syntax!"); + ERR_PRINTF1(KBadError); + return EFalse; + } + + TFileName defaultIniFilePath(KLegacySysDrive); + defaultIniFilePath.Append(KDefaultIniFilePath); + + iFS.Connect(); + TFindFile fileFind(iFS); + TInt ret = fileFind.FindByDir(token, defaultIniFilePath); + iFS.Close(); + if (KErrNotFound == ret) + { + _LIT(KFileNotFound, "Configuration File %S Not Found!"); + ERR_PRINTF2(KFileNotFound, &token); + return EFalse; + } + return ETrue; + } +// End defect 118337 + +/** + * Parses the test block and populates the iBlockArray + * @Leave system wide errors + */ +void CScriptControl::ParseTestBlockL( TTEFItemArray& aItemArray ) + { + // Iterate through the commands contained within the test block + // and append them to the itemArray. + TPtrC startBlockScriptLine = iCurrentScriptLine; + TInt startBlockLineNumber = iCurrentScriptLineNumber; + + TBool parseResult = ParseTestBlockHeader(); + + FOREVER + { + TTEFBlockItem blockItem; + + // Read in the next script line + TBool scriptLineRes = EFalse; + if( !iStartLooping ) + { + scriptLineRes = GetNextScriptLine(iCurrentScriptLine); + } + else + { + scriptLineRes = GetLoopScriptLine(iCurrentScriptLine); + } + + if( !scriptLineRes ) + { + _LIT( KTEFEoF, "Unexpectedly hit the end of the file" ); + ERR_PRINTF1( KTEFEoF ); + TExitCategoryName blankPanicString; + LogResult(EFail, blankPanicString, startBlockLineNumber, startBlockScriptLine); + User::Leave( KErrEof ); + } + + // Strip off any trailling comment + TInt offset = iCurrentScriptLine.Find(KTEFComment); + if( offset != KErrNotFound ) + { + iCurrentScriptLine.Set( iCurrentScriptLine.Mid(0, offset) ); + } + + TLex lex(iCurrentScriptLine); + TPtrC token(lex.NextToken()); + + // Populate the blockItem with the data required for each command + + // CREATE_OBJECT + if( 0 == token.CompareF(KTEFCreateObject) ) + { + blockItem.iItemType = ETEFCreateObject; + blockItem.iObjectType = lex.NextToken().Left(KTEFMaxNameLength); + blockItem.iSection = lex.NextToken().Left(KTEFMaxNameLength); + } + // RESTORE_OBJECT + else if( 0 == token.CompareF(KTEFRestoreObject) ) + { + blockItem.iItemType = ETEFRestoreObject; + blockItem.iObjectType = lex.NextToken().Left(KTEFMaxNameLength); + blockItem.iSection = lex.NextToken().Left(KTEFMaxNameLength); + } + // COMMAND [Error TEFParameter] [section] + else if( 0 == token.CompareF(KTEFCommand) ) + { + blockItem.iItemType = ETEFCommand; + TPtrC param = lex.NextToken().Left(KTEFMaxNameLength); + + if( param.Length() > 0 ) + { + while( param[0] == KTEFAsciiExclamation ) + { + // This is a TEF Error Parameter + // Extract the type of TEF parameter being read in + if( param.Length() >= KTEFError().Length() && + 0 == param.Mid(0,KTEFError().Length()).CompareF(KTEFError) ) + { + TInt start = KTEFError().Length(); + TInt length = param.Length()-start; + TLex errorCodeLex( param.Mid(start, + length )); + + TInt errorCode = 0; + if( errorCodeLex.Val(errorCode) == KErrNone ) + { + blockItem.iExpectedError = errorCode; + } + else + { + _LIT(KBadError,"Bad error syntax."); + ERR_PRINTF1(KBadError); + blockItem.iError = KErrNotSupported; + } + } + else if( param.Length() >= KTEFAsyncError().Length() && + 0 == param.Mid(0,KTEFAsyncError().Length()).CompareF(KTEFAsyncError)) + { + TInt start = KTEFAsyncError().Length(); + TInt length = param.Length()-start; + TLex errorCodeLex( param.Mid(start, + length )); + + TInt errorCode = 0; + if( errorCodeLex.Val(errorCode) == KErrNone ) + { + blockItem.iExpectedAsyncError = errorCode; + } + else + { + _LIT(KBadError,"Bad error syntax."); + ERR_PRINTF1(KBadError); + blockItem.iAsyncError = KErrNotSupported; + } + } + else + { + // Unknown TEFParameter + _LIT(KUnknownTEFParam,"Unknown Test Block TEFParameter."); + ERR_PRINTF1(KUnknownTEFParam); + TExitCategoryName blankPanicString; + LogResult(EFail, blankPanicString, startBlockLineNumber, startBlockScriptLine); + User::Leave(KErrNotSupported); + } + + // Read the next token + param.Set( lex.NextToken().Left(KTEFMaxNameLength) ); + } + } + + // Read in the object section name, function name and optional data section + blockItem.iCommand.iObject = param; + blockItem.iCommand.iFunction = lex.NextToken().Left(KTEFMaxNameLength); + blockItem.iSection = lex.NextToken().Left(KTEFMaxNameLength); + } + // STORE
+ else if( 0 == token.CompareF(KTEFStore) ) + { + blockItem.iItemType = ETEFStore; + blockItem.iSection = lex.NextToken().Left(KTEFMaxNameLength); + } + // OUTSTANDING + else if( 0 == token.CompareF(KTEFOutstanding) ) + { + blockItem.iItemType = ETEFOutstanding; + TLex pollLex( lex.NextToken().Left(KTEFMaxNameLength) ); + TInt poll = 0; + blockItem.iTime = (KErrNone==pollLex.Val(poll)?poll:0); + blockItem.iSection = lex.NextToken().Left(KTEFMaxNameLength); + } + // DELAY