# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1284526302 -10800 # Node ID 9397a16b6eb854ee90c119bec5e173be29458270 # Parent 6edeef394eb7a0b0c98e453ca7eb748094d29e02 Revision: 201035 diff -r 6edeef394eb7 -r 9397a16b6eb8 layers.sysdef.xml --- a/layers.sysdef.xml Fri Sep 03 07:55:01 2010 +0300 +++ b/layers.sysdef.xml Wed Sep 15 07:51:42 2010 +0300 @@ -13,13 +13,5 @@ - - - - - - - - - \ No newline at end of file + diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/group/bld.inf --- a/symbianunittestfw/group/bld.inf Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -/* -* 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: Symbian Unit Testing framework -* -*/ - -#include "../symbianunittestfw_pub/group/bld.inf" -#include "../sutfw/group/bld.inf" - -PRJ_EXPORTS - - ../rom/sut.iby CORE_IBY_EXPORT_PATH(tools/rom,sut.iby) diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/rom/sut.iby --- a/symbianunittestfw/rom/sut.iby Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -// 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: -// An iby file for symbianunittest -// -// - -#ifndef __SUT_IBY__ -#define __SUT_IBY__ - - -// symbianunittest framework -file=ABI_DIR\BUILD_DIR\symbianunittestfw.dll sys\bin\symbianunittestfw.dll -// for kernel side testing -extension[VARID]==ABI_DIR\BUILD_DIR\symbianunittestldd.dll sys\bin\symbianunittestldd.dll - -// symbianunittest console ui -file=ABI_DIR\BUILD_DIR\symbianunittest.exe sys\bin\symbianunittest.exe - -// unit test example -//file=ABI_DIR\BUILD_DIR\ut_racecar.dll sys\bin\ut_racecar.dll - -#endif __SUT_IBY__ - diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/group/bld.inf --- a/symbianunittestfw/sutfw/group/bld.inf Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -/* -* 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: Symbian Unit Testing framework -* -*/ - -#include "../sutfwcore/group/bld.inf" -#include "../sutfwui/sutfwconsoleui/group/bld.inf" -#include "../sutfwexamples/group/bld.inf" - - -PRJ_EXPORTS -../inc/symbianunittestversion.h OS_LAYER_PLATFORM_EXPORT_PATH(sutinternal/symbianunittestversion.h) -../inc/symbianunittestrunner.h OS_LAYER_PLATFORM_EXPORT_PATH(sutinternal/symbianunittestrunner.h) -../inc/symbianunittestuicallback.h OS_LAYER_PLATFORM_EXPORT_PATH(sutinternal/symbianunittestuicallback.h) -../inc/symbianunittestobserver.h OS_LAYER_PLATFORM_EXPORT_PATH(sutinternal/symbianunittestobserver.h) \ No newline at end of file diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/inc/symbianunittestobserver.h --- a/symbianunittestfw/sutfw/inc/symbianunittestobserver.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -/* -* 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 SYMBIANUNITTESTOBSERVER_H -#define SYMBIANUNITTESTOBSERVER_H - -// INCLUDES -#include - -// CLASS DECLARATION -class MSymbianUnitTestObserver - { - public: // New functions - - virtual void TestPass(const TDesC& aTestCaseName) = 0; - virtual void TestFailed(const TDesC& aTestCaseName, const TDesC8& aErrMsg) = 0; - }; - -#endif // SYMBIANUNITTESTOBSERVER_H - diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/inc/symbianunittestrunner.h --- a/symbianunittestfw/sutfw/inc/symbianunittestrunner.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,94 +0,0 @@ -/* -* 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 SYMBIANUNITTESTRUNNER_H -#define SYMBIANUNITTESTRUNNER_H - -// INCLUDES -#include "symbianunittestobserver.h" -#include -#include -#include - -// FORWARD DECLARATIONS -class MSymbianUnitTestInterface; -class CSymbianUnitTestResult; -class MSymbianUnitTestUiCallBack; - -const TInt KSymbianUnitTestDefaultTimeout = 30; - -// CLASS DECLARATION -class CSymbianUnitTestRunner : public CBase, public MSymbianUnitTestObserver - { - public: // Constructors and destructor - - IMPORT_C static CSymbianUnitTestRunner* NewLC( - MSymbianUnitTestUiCallBack& aUiCallBack ); - - IMPORT_C static CSymbianUnitTestRunner* NewL( - MSymbianUnitTestUiCallBack& aUiCallBack ); - - IMPORT_C ~CSymbianUnitTestRunner(); - - public: // From MSymbianUnitTestObserver - - void TestPass(const TDesC& aTestCaseName); - void TestFailed(const TDesC& aTestCaseName, const TDesC8& aErrMsg); - - public: // New functions - - IMPORT_C TInt TestCount(); - - IMPORT_C void ExecuteTestsL( - const MDesCArray& aTestDllNames, - TBool aMemoryAllocationFailureSimulation, - const TDesC& aOutputFileName, - const TDesC& aOutputFormat, - const CDesCArray& aTestCaseNames, - TInt aTimeout = KSymbianUnitTestDefaultTimeout ); - - IMPORT_C TInt FailedTestCount(); - - IMPORT_C void TestCaseNamesL(const TDesC& aTestDllName, CDesCArray& aTestCaseNames); - - IMPORT_C TInt TestCountL(const MDesCArray& aTestDllNames, const MDesCArray& aTestCaseNames); - - private: // Constructors - - CSymbianUnitTestRunner( MSymbianUnitTestUiCallBack& aUiCallBack ); - void ConstructL(); - - private: // New functions - - static void DeleteTest( TAny* aTest ); - void ExecuteDllTestsL(const TDesC& aTestDllName, MSymbianUnitTestInterface::TFailureSimulation aFailureSimulation, - const CDesCArray& aTestCaseNames, - TInt aTimeout); - void ExecuteLddTestsL(const TDesC& aTestLddName, const CDesCArray& aTestCaseNames, - TInt aTimeout); - - void GetDllTestCaseNamesL(const TDesC& aTestDllName, CDesCArray& aTestCaseNames); - void GetLddTestCaseNamesL(const TDesC& aTestDllName, CDesCArray& aTestCaseNames); - - private: // Data - - MSymbianUnitTestUiCallBack& iUiCallBack; - CSymbianUnitTestResult* iResult; - TInt iTestCount; - }; - -#endif // SYMBIANUNITTESTRUNNER_H diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/inc/symbianunittestuicallback.h --- a/symbianunittestfw/sutfw/inc/symbianunittestuicallback.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -/* -* 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 SYMBIANUNITTESTUICALLBACK_H -#define SYMBIANUNITTESTUICALLBACK_H - -// INCLUDES -#include - -// CLASS DECLARATION -class MSymbianUnitTestUiCallBack - { - public: // New functions - - virtual void InfoMsg( const TDesC& aMessage ) = 0; - virtual void InfoMsg( const TDesC& aFormat, const TDesC& aMessage ) = 0; - //virtual void IncrementExecutedTestsCount() = 0; - virtual void TestPass(const TDesC& aTestCaseName) = 0; - virtual void TestFailed(const TDesC& aTestCaseName, const TDesC8& aErrMsg) = 0; - }; - -#endif // SYMBIANUNITTESTUICALLBACK_H diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/inc/symbianunittestversion.h --- a/symbianunittestfw/sutfw/inc/symbianunittestversion.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -/* -* 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 SYMBIANUNITTESTVERSION_H -#define SYMBIANUNITTESTVERSION_H - -#define SUT_MAJOR_VERSION 1 -#define SUT_MINOR_VERSION 2 -#define SUT_BUILD_VERSION 3 - -#endif /*SYNBIANUNITTESTVERSION_H*/ diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sis/symbianunittest.pkg --- a/symbianunittestfw/sutfw/sis/symbianunittest.pkg Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -; -; 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 the License "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: -; -; Languages -&EN - -; standard SIS file header -#{"SymbianUnitTest"},(0x20022E75),1,0,0 - -;Localised Vendor name -%{"Nokia"} - -;Unique Vendor name -:"Nokia" - -;Supports Series 60 v 3.0 - -;Files to install -"\epoc32\release\armv5\urel\symbianunittest.exe" -"!:\sys\bin\symbianunittest.exe" -"\epoc32\release\armv5\urel\symbianunittestfw.dll" -"!:\sys\bin\symbianunittestfw.dll" -"\epoc32\release\armv5\urel\symbianunittestldd.dll" -"!:\sys\bin\symbianunittestldd.dll" -"\epoc32\release\armv5\urel\ut_racecar.dll" -"!:\sys\bin\ut_racecar.dll" -"\epoc32\release\armv5\urel\ut_racecar.ldd" -"!:\sys\bin\ut_racecar.ldd" -"\epoc32\release\armv5\urel\ut_sutfwframework.dll" -"!:\sys\bin\ut_sutfwframework.dll" -"\epoc32\release\armv5\urel\ut_symbianunittestconsoleui.dll" -"!:\sys\bin\ut_symbianunittestconsoleui.dll" - -;required for application to be covered by backup/restore facility diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/BWINS/symbianunittestfwU.DEF --- a/symbianunittestfw/sutfw/sutfwcore/BWINS/symbianunittestfwU.DEF Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -EXPORTS - ?RecordNoLeaveFromStatementL@CSymbianUnitTest@@IAEXABVTDesC8@@H0@Z @ 1 NONAME ; void CSymbianUnitTest::RecordNoLeaveFromStatementL(class TDesC8 const &, int, class TDesC8 const &) - ??0CSymbianUnitTest@@IAE@XZ @ 2 NONAME ; CSymbianUnitTest::CSymbianUnitTest(void) - ?ConstructL@CSymbianUnitTest@@IAEXABVTDesC8@@@Z @ 3 NONAME ; void CSymbianUnitTest::ConstructL(class TDesC8 const &) - ?AddL@CSymbianUnitTestSuite@@QAEXPAVMSymbianUnitTestInterface@@@Z @ 4 NONAME ; void CSymbianUnitTestSuite::AddL(class MSymbianUnitTestInterface *) - ??1CSymbianUnitTest@@UAE@XZ @ 5 NONAME ; CSymbianUnitTest::~CSymbianUnitTest(void) - ?SetupL@CSymbianUnitTest@@UAEXXZ @ 6 NONAME ; void CSymbianUnitTest::SetupL(void) - ?AssertionFailedL@CSymbianUnitTest@@IAEXABVTDesC8@@H0@Z @ 7 NONAME ; void CSymbianUnitTest::AssertionFailedL(class TDesC8 const &, int, class TDesC8 const &) - ?TestCount@CSymbianUnitTestRunner@@QAEHXZ @ 8 NONAME ; int CSymbianUnitTestRunner::TestCount(void) - ?ExecuteTestsL@CSymbianUnitTestRunner@@QAEXABVMDesC16Array@@HABVTDesC16@@1ABVCDesC16Array@@H@Z @ 9 NONAME ; void CSymbianUnitTestRunner::ExecuteTestsL(class MDesC16Array const &, int, class TDesC16 const &, class TDesC16 const &, class CDesC16Array const &, int) - ?AssertEqualsL@CSymbianUnitTest@@IAEXHHHABVTDesC8@@@Z @ 10 NONAME ; void CSymbianUnitTest::AssertEqualsL(int, int, int, class TDesC8 const &) - ?AssertEqualsL@CSymbianUnitTest@@IAEXABVTDesC16@@0HABVTDesC8@@@Z @ 11 NONAME ; void CSymbianUnitTest::AssertEqualsL(class TDesC16 const &, class TDesC16 const &, int, class TDesC8 const &) - ?Name@CSymbianUnitTestSuite@@UBEABVTDesC16@@XZ @ 12 NONAME ; class TDesC16 const & CSymbianUnitTestSuite::Name(void) const - ?Teardown@CSymbianUnitTest@@UAEXXZ @ 13 NONAME ; void CSymbianUnitTest::Teardown(void) - ?AssertLeaveL@CSymbianUnitTest@@IAEXABVTDesC8@@HHH0@Z @ 14 NONAME ; void CSymbianUnitTest::AssertLeaveL(class TDesC8 const &, int, int, int, class TDesC8 const &) - ?AssertEqualsL@CSymbianUnitTest@@IAEXABVTDesC8@@0H0@Z @ 15 NONAME ; void CSymbianUnitTest::AssertEqualsL(class TDesC8 const &, class TDesC8 const &, int, class TDesC8 const &) - ?Name@CSymbianUnitTest@@UBEABVTDesC16@@XZ @ 16 NONAME ; class TDesC16 const & CSymbianUnitTest::Name(void) const - ?ExecuteL@CSymbianUnitTest@@UAEXAAVMSymbianUnitTestObserver@@AAVCSymbianUnitTestResult@@W4TFailureSimulation@MSymbianUnitTestInterface@@ABVCDesC16Array@@H@Z @ 17 NONAME ; void CSymbianUnitTest::ExecuteL(class MSymbianUnitTestObserver &, class CSymbianUnitTestResult &, enum MSymbianUnitTestInterface::TFailureSimulation, class CDesC16Array const &, int) - ?NewL@CSymbianUnitTestSuite@@SAPAV1@ABVTDesC16@@@Z @ 18 NONAME ; class CSymbianUnitTestSuite * CSymbianUnitTestSuite::NewL(class TDesC16 const &) - ??1CSymbianUnitTestSuite@@UAE@XZ @ 19 NONAME ; CSymbianUnitTestSuite::~CSymbianUnitTestSuite(void) - ?NewLC@CSymbianUnitTestSuite@@SAPAV1@ABVTDesC16@@@Z @ 20 NONAME ; class CSymbianUnitTestSuite * CSymbianUnitTestSuite::NewLC(class TDesC16 const &) - ?NewLC@CSymbianUnitTestRunner@@SAPAV1@AAVMSymbianUnitTestUiCallBack@@@Z @ 21 NONAME ; class CSymbianUnitTestRunner * CSymbianUnitTestRunner::NewLC(class MSymbianUnitTestUiCallBack &) - ??1CSymbianUnitTestRunner@@UAE@XZ @ 22 NONAME ; CSymbianUnitTestRunner::~CSymbianUnitTestRunner(void) - ?ExecuteL@CSymbianUnitTestSuite@@UAEXAAVMSymbianUnitTestObserver@@AAVCSymbianUnitTestResult@@W4TFailureSimulation@MSymbianUnitTestInterface@@ABVCDesC16Array@@H@Z @ 23 NONAME ; void CSymbianUnitTestSuite::ExecuteL(class MSymbianUnitTestObserver &, class CSymbianUnitTestResult &, enum MSymbianUnitTestInterface::TFailureSimulation, class CDesC16Array const &, int) - ?IsMemoryAllocationFailureSimulationUsed@CSymbianUnitTest@@IBEHXZ @ 24 NONAME ; int CSymbianUnitTest::IsMemoryAllocationFailureSimulationUsed(void) const - ?FailedTestCount@CSymbianUnitTestRunner@@QAEHXZ @ 25 NONAME ; int CSymbianUnitTestRunner::FailedTestCount(void) - ?TestCaseCount@CSymbianUnitTestSuite@@UAEHXZ @ 26 NONAME ; int CSymbianUnitTestSuite::TestCaseCount(void) - ?NewL@CSymbianUnitTestRunner@@SAPAV1@AAVMSymbianUnitTestUiCallBack@@@Z @ 27 NONAME ; class CSymbianUnitTestRunner * CSymbianUnitTestRunner::NewL(class MSymbianUnitTestUiCallBack &) - ?AddTestCaseL@CSymbianUnitTest@@IAEXABVTDesC16@@P81@AEXXZ11@Z @ 28 NONAME ; void CSymbianUnitTest::AddTestCaseL(class TDesC16 const &, void (*)(void), void (*)(void), void (*)(void)) - ?TestCaseCount@CSymbianUnitTest@@UAEHXZ @ 29 NONAME ; int CSymbianUnitTest::TestCaseCount(void) - ?ConstructL@CSymbianUnitTestSuite@@IAEXABVTDesC16@@@Z @ 30 NONAME ; void CSymbianUnitTestSuite::ConstructL(class TDesC16 const &) - ??0CSymbianUnitTestSuite@@IAE@XZ @ 31 NONAME ; CSymbianUnitTestSuite::CSymbianUnitTestSuite(void) - ?AssertEqualsL@CSymbianUnitTest@@IAEXABVTDesC8@@0H00@Z @ 32 NONAME ; void CSymbianUnitTest::AssertEqualsL(class TDesC8 const &, class TDesC8 const &, int, class TDesC8 const &, class TDesC8 const &) - ?AssertEqualsL@CSymbianUnitTest@@IAEXABVTDesC16@@0HABVTDesC8@@1@Z @ 33 NONAME ; void CSymbianUnitTest::AssertEqualsL(class TDesC16 const &, class TDesC16 const &, int, class TDesC8 const &, class TDesC8 const &) - ?AssertEqualsL@CSymbianUnitTest@@IAEXHHHABVTDesC8@@0@Z @ 34 NONAME ; void CSymbianUnitTest::AssertEqualsL(int, int, int, class TDesC8 const &, class TDesC8 const &) - ?TestCaseNamesL@CSymbianUnitTestSuite@@UAEXAAVCDesC16Array@@@Z @ 35 NONAME ; void CSymbianUnitTestSuite::TestCaseNamesL(class CDesC16Array &) - ?TestCaseNamesL@CSymbianUnitTest@@UAEXAAVCDesC16Array@@@Z @ 36 NONAME ; void CSymbianUnitTest::TestCaseNamesL(class CDesC16Array &) - ?TestCaseNamesL@CSymbianUnitTestRunner@@QAEXABVTDesC16@@AAVCDesC16Array@@@Z @ 37 NONAME ; void CSymbianUnitTestRunner::TestCaseNamesL(class TDesC16 const &, class CDesC16Array &) - ?TestCountL@CSymbianUnitTestRunner@@QAEHABVMDesC16Array@@0@Z @ 38 NONAME ; int CSymbianUnitTestRunner::TestCountL(class MDesC16Array const &, class MDesC16Array const &) - diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/EABI/symbianunittestfwU.DEF --- a/symbianunittestfw/sutfw/sutfwcore/EABI/symbianunittestfwU.DEF Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,84 +0,0 @@ -EXPORTS - _ZN16CSymbianUnitTest10ConstructLERK6TDesC8 @ 1 NONAME - _ZN16CSymbianUnitTest12AddTestCaseLERK7TDesC16MS_FvvES4_S4_ @ 2 NONAME - _ZN16CSymbianUnitTest12AssertLeaveLERK6TDesC8iiiS2_ @ 3 NONAME - _ZN16CSymbianUnitTest13AssertEqualsLERK6TDesC8S2_iS2_ @ 4 NONAME - _ZN16CSymbianUnitTest13AssertEqualsLERK7TDesC16S2_iRK6TDesC8 @ 5 NONAME - _ZN16CSymbianUnitTest13AssertEqualsLEiiiRK6TDesC8 @ 6 NONAME - _ZN16CSymbianUnitTest13TestCaseCountEv @ 7 NONAME - _ZN16CSymbianUnitTest16AssertionFailedLERK6TDesC8iS2_ @ 8 NONAME - _ZN16CSymbianUnitTest27RecordNoLeaveFromStatementLERK6TDesC8iS2_ @ 9 NONAME - _ZN16CSymbianUnitTest6SetupLEv @ 10 NONAME - _ZN16CSymbianUnitTest8ExecuteLER24MSymbianUnitTestObserverR22CSymbianUnitTestResultN25MSymbianUnitTestInterface18TFailureSimulationERK12CDesC16Arrayi @ 11 NONAME - _ZN16CSymbianUnitTest8TeardownEv @ 12 NONAME - _ZN16CSymbianUnitTestC1Ev @ 13 NONAME - _ZN16CSymbianUnitTestC2Ev @ 14 NONAME - _ZN16CSymbianUnitTestD0Ev @ 15 NONAME - _ZN16CSymbianUnitTestD1Ev @ 16 NONAME - _ZN16CSymbianUnitTestD2Ev @ 17 NONAME - _ZN21CSymbianUnitTestSuite13TestCaseCountEv @ 18 NONAME - _ZN21CSymbianUnitTestSuite4AddLEP25MSymbianUnitTestInterface @ 19 NONAME - _ZN21CSymbianUnitTestSuite4NewLERK7TDesC16 @ 20 NONAME - _ZN21CSymbianUnitTestSuite5NewLCERK7TDesC16 @ 21 NONAME - _ZN21CSymbianUnitTestSuite8ExecuteLER24MSymbianUnitTestObserverR22CSymbianUnitTestResultN25MSymbianUnitTestInterface18TFailureSimulationERK12CDesC16Arrayi @ 22 NONAME - _ZN21CSymbianUnitTestSuiteD0Ev @ 23 NONAME - _ZN21CSymbianUnitTestSuiteD1Ev @ 24 NONAME - _ZN21CSymbianUnitTestSuiteD2Ev @ 25 NONAME - _ZN22CSymbianUnitTestRunner13ExecuteTestsLERK12MDesC16ArrayiRK7TDesC16S5_RK12CDesC16Arrayi @ 26 NONAME - _ZN22CSymbianUnitTestRunner15FailedTestCountEv @ 27 NONAME - _ZN22CSymbianUnitTestRunner4NewLER26MSymbianUnitTestUiCallBack @ 28 NONAME - _ZN22CSymbianUnitTestRunner5NewLCER26MSymbianUnitTestUiCallBack @ 29 NONAME - _ZN22CSymbianUnitTestRunner9TestCountEv @ 30 NONAME - _ZN22CSymbianUnitTestRunnerD0Ev @ 31 NONAME - _ZN22CSymbianUnitTestRunnerD1Ev @ 32 NONAME - _ZN22CSymbianUnitTestRunnerD2Ev @ 33 NONAME - _ZNK16CSymbianUnitTest39IsMemoryAllocationFailureSimulationUsedEv @ 34 NONAME - _ZNK16CSymbianUnitTest4NameEv @ 35 NONAME - _ZNK21CSymbianUnitTestSuite4NameEv @ 36 NONAME - _ZTI16CSymbianUnitTest @ 37 NONAME - _ZTI21CSymbianUnitTestSuite @ 38 NONAME - _ZTI22CSymbianUnitTestResult @ 39 NONAME - _ZTI22CSymbianUnitTestRunner @ 40 NONAME - _ZTI23CSymbianUnitTestFailure @ 41 NONAME - _ZTI27CSymbianUnitTestOutputAsXml @ 42 NONAME - _ZTI28CSymbianUnitTestOutputAsHtml @ 43 NONAME - _ZTI28CSymbianUnitTestOutputAsText @ 44 NONAME - _ZTI31CSymbianUnitTestOutputFormatter @ 45 NONAME - _ZTI32CSymbianUnitTestFileOutputWriter @ 46 NONAME - _ZTIN16CSymbianUnitTest20CSymbianUnitTestCaseE @ 47 NONAME - _ZTV16CSymbianUnitTest @ 48 NONAME - _ZTV21CSymbianUnitTestSuite @ 49 NONAME - _ZTV22CSymbianUnitTestResult @ 50 NONAME - _ZTV22CSymbianUnitTestRunner @ 51 NONAME - _ZTV23CSymbianUnitTestFailure @ 52 NONAME - _ZTV27CSymbianUnitTestOutputAsXml @ 53 NONAME - _ZTV28CSymbianUnitTestOutputAsHtml @ 54 NONAME - _ZTV28CSymbianUnitTestOutputAsText @ 55 NONAME - _ZTV31CSymbianUnitTestOutputFormatter @ 56 NONAME - _ZTV32CSymbianUnitTestFileOutputWriter @ 57 NONAME - _ZTVN16CSymbianUnitTest20CSymbianUnitTestCaseE @ 58 NONAME - _ZThn4_N16CSymbianUnitTest13TestCaseCountEv @ 59 NONAME - _ZThn4_N16CSymbianUnitTest8ExecuteLER24MSymbianUnitTestObserverR22CSymbianUnitTestResultN25MSymbianUnitTestInterface18TFailureSimulationERK12CDesC16Arrayi @ 60 NONAME - _ZThn4_N16CSymbianUnitTestD0Ev @ 61 NONAME - _ZThn4_N16CSymbianUnitTestD1Ev @ 62 NONAME - _ZThn4_N21CSymbianUnitTestSuite13TestCaseCountEv @ 63 NONAME - _ZThn4_N21CSymbianUnitTestSuite8ExecuteLER24MSymbianUnitTestObserverR22CSymbianUnitTestResultN25MSymbianUnitTestInterface18TFailureSimulationERK12CDesC16Arrayi @ 64 NONAME - _ZThn4_N21CSymbianUnitTestSuiteD0Ev @ 65 NONAME - _ZThn4_N21CSymbianUnitTestSuiteD1Ev @ 66 NONAME - _ZThn4_NK16CSymbianUnitTest4NameEv @ 67 NONAME - _ZThn4_NK21CSymbianUnitTestSuite4NameEv @ 68 NONAME - _ZN16CSymbianUnitTest13AssertEqualsLERK6TDesC8S2_iS2_S2_ @ 69 NONAME - _ZN16CSymbianUnitTest13AssertEqualsLERK7TDesC16S2_iRK6TDesC8S5_ @ 70 NONAME - _ZN16CSymbianUnitTest13AssertEqualsLEiiiRK6TDesC8S2_ @ 71 NONAME - _ZN21CSymbianUnitTestSuite10ConstructLERK7TDesC16 @ 72 NONAME - _ZN21CSymbianUnitTestSuiteC1Ev @ 73 NONAME - _ZN21CSymbianUnitTestSuiteC2Ev @ 74 NONAME - _ZN16CSymbianUnitTest14TestCaseNamesLER12CDesC16Array @ 75 NONAME - _ZN21CSymbianUnitTestSuite14TestCaseNamesLER12CDesC16Array @ 76 NONAME - _ZN22CSymbianUnitTestRunner14TestCaseNamesLERK7TDesC16R12CDesC16Array @ 77 NONAME - _ZTI22CSymbianUnitTestLddCtl @ 78 NONAME - _ZTV22CSymbianUnitTestLddCtl @ 79 NONAME - _ZThn4_N16CSymbianUnitTest14TestCaseNamesLER12CDesC16Array @ 80 NONAME - _ZThn4_N21CSymbianUnitTestSuite14TestCaseNamesLER12CDesC16Array @ 81 NONAME - _ZN22CSymbianUnitTestRunner10TestCountLERK12MDesC16ArrayS2_ @ 82 NONAME - diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/group/SUTFlags.cfg --- a/symbianunittestfw/sutfw/sutfwcore/group/SUTFlags.cfg Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ - -// Set this flag to enable logging. -// (create log folder c:\logs\sut manually in the device) -#define __ENABLE_LOGGING__ - -// Set this flag to enable debug level logging. it is disabled by default. -#define __ENABLE_LOGGING_DEBUG__ - diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/group/bld.inf --- a/symbianunittestfw/sutfw/sutfwcore/group/bld.inf Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -/* -* 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: Symbian Unit Testing framework -* -*/ - -#include "../sutfwframework/tsrc/group/bld.inf" -#include "../sutfwkernel/group/bld.inf" -PRJ_EXPORTS -SUTFlags.cfg OS_LAYER_PLATFORM_EXPORT_PATH(SUTFlags.cfg) - -PRJ_MMPFILES -symbianunittestfw.mmp diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/group/symbianunittestfw.mmp --- a/symbianunittestfw/sutfw/sutfwcore/group/symbianunittestfw.mmp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -/* -* 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 symbianunittestfw.dll -TARGETTYPE dll -UID 0x1000008d 0x20022E74 - -// Framework -SOURCEPATH ../sutfwframework/src -SOURCE symbianunittest.cpp -SOURCE symbianunittestsuite.cpp -SOURCE symbianunittestfailure.cpp -SOURCE symbianunittestresult.cpp - - -// Output -SOURCEPATH ../sutfwoutput/src -SOURCE symbianunittestfileoutputwriter.cpp -SOURCE symbianunittestoutputformatter.cpp -SOURCE symbianunittestoutputashtml.cpp -SOURCE symbianunittestoutputastext.cpp -SOURCE symbianunittestoutputasxml.cpp -SOURCE symbianunittestoutputfactory.cpp - -// Test runner -SOURCEPATH ../sutfwtestrunner/src -SOURCE symbianunittestrunner.cpp - -// Kernel -SOURCEPATH ../sutfwkernel/src -SOURCE symbianunittestlddctl.cpp - -USERINCLUDE ../sutfwframework/inc -USERINCLUDE ../sutfwoutput/inc -USERINCLUDE ../sutfwkernel/inc -USERINCLUDE ../../inc - -OS_LAYER_SYSTEMINCLUDE_SYMBIAN - -LIBRARY euser.lib -LIBRARY charconv.lib -LIBRARY efsrv.lib -LIBRARY bafl.lib - -#if defined(__ENABLE_LOGGING__) -LIBRARY flogger.lib -#endif - -VENDORID 0x101FB657 - -CAPABILITY ALL -TCB diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwframework/inc/sutlogger.h --- a/symbianunittestfw/sutfw/sutfwcore/sutfwframework/inc/sutlogger.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* -* 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 SUT_LOG_DEF__ -#define SUT_LOG_DEF__ - -#include - -#ifdef __ENABLE_LOGGING__ - -#include -_LIT(KLogFolder, "sut"); -_LIT(KLogFile, "sut_log.txt"); - -#define SUT_LOG_START(a1) {RFileLogger::Write(KLogFolder, KLogFile, EFileLoggingModeOverwrite, a1);} -#define SUT_LOG_INFO(a1) {RFileLogger::Write(KLogFolder, KLogFile, EFileLoggingModeAppend, a1);} -#define SUT_LOG_FORMAT(a1, a2) {RFileLogger::WriteFormat(KLogFolder, KLogFile, EFileLoggingModeAppend, a1, (a2));} -#define SUT_LOG_FORMAT2(a1, a2, a3) {RFileLogger::WriteFormat(KLogFolder, KLogFile, EFileLoggingModeAppend, a1, (a2), (a3));} -#define SUT_LOG_FORMAT3(a1, a2, a3, a4) {RFileLogger::WriteFormat(KLogFolder, KLogFile, EFileLoggingModeAppend, a1, (a2), (a3), (a4));} - - -#ifdef __ENABLE_LOGGING_DEBUG__ -#define SUT_LOG_DEBUG(a1) {_LIT(temp, a1); RFileLogger::Write(KLogFolder, KLogFile, EFileLoggingModeAppend, temp);} -#define SUT_LOG_DEBUGF(a1, a2) {RFileLogger::WriteFormat(KLogFolder, KLogFile, EFileLoggingModeAppend, a1, (a2));} -#else -#define SUT_LOG_DEBUG(a1) -#define SUT_LOG_DEBUGF(a1, a2) -#endif // __ENABLE_LOGGING_DEBUG__ - -#else -// NO LOGGING - -#define SUT_LOG_START(a1) -#define SUT_LOG_INFO(a1) -#define SUT_LOG_FORMAT(a1, a2) -#define SUT_LOG_FORMAT2(a1, a2, a3) -#define SUT_LOG_FORMAT3(a1, a2, a3, a4) -#define SUT_LOG_DEBUG(a1) -#define SUT_LOG_DEBUGF(a1, a2) - -#endif // __ENABLE_LOGGING__ - -#endif // SUT_LOG_DEF__ diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwframework/inc/symbianunittestfailure.h --- a/symbianunittestfw/sutfw/sutfwcore/sutfwframework/inc/symbianunittestfailure.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -/* -* 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 SYMBIANUNITTESTFAILURE_H -#define SYMBIANUNITTESTFAILURE_H - -// INCLUDES -#include - -// FORWARD DECLARATIONS -class MSymbianUnitTestInterface; - -// CLASS DECLARATION -class CSymbianUnitTestFailure : public CBase - { - public: // Constructors and destructor - - static CSymbianUnitTestFailure* NewL( - const TDesC& aTestName, - const TDesC8& aFailureMessage, - TInt aLineNumber, - const TDesC8& aFileName ); - - static CSymbianUnitTestFailure* NewLC( - const TDesC& aTestName, - const TDesC8& aFailureMessage, - TInt aLineNumber, - const TDesC8& aFileName ); - - ~CSymbianUnitTestFailure(); - - public: // New functions - - const TDesC8& TestName(); - const TDesC8& FailureMessage(); - TInt LineNumber(); - const TDesC8& FileName(); - - private: // Constructors - - CSymbianUnitTestFailure( TInt aLineNumber ); - - void ConstructL( - const TDesC& aTestName, - const TDesC8& aFailureMessage, - const TDesC8& aFileName ); - - private: // Data - - TInt iLineNumber; - HBufC8* iTestName; - HBufC8* iFailureMessage; - HBufC8* iFileName; - }; - -#endif // SYMBIANUNITTESTFAILURE_H diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwframework/inc/symbianunittestresult.h --- a/symbianunittestfw/sutfw/sutfwcore/sutfwframework/inc/symbianunittestresult.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,121 +0,0 @@ -/* -* 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 SYMBIANUNITTESTRESULT_H -#define SYMBIANUNITTESTRESULT_H - -// INCLUDES -#include -#include -#include - -// FORWARD DECLARATIONS -class CSymbianUnitTestFailure; - -// CLASS DECLARATION -class CSymbianUnitTestResult : public CBase - { - public: // Constructors and destructor - - static CSymbianUnitTestResult* NewLC(); - static CSymbianUnitTestResult* NewL(); - ~CSymbianUnitTestResult(); - - public: // New functions - - TInt TestCount() const; - - TInt PassedTestCount() const; - - RPointerArray< CSymbianUnitTestFailure >& Failures(); - - void StartTestL( const TDesC& aTestName ); - void EndTestL(); - - TBool CurrentResult(); - - void AddSetupErrorL( - TInt aError ); - - void AddLeaveFromTestL( - TInt aLeaveCode, - TInt aAllocFailureRate ); - - void AddMemoryLeakInfoL( - TInt aLeakedMemory, - TInt aAllocFailureRate ); - - void AddResourceLeakInfoL( - TInt aLeakedResource, - TInt aAllocFailureRate ); - - void AddRequestLeakInfoL( - TInt aLeakedRequest, - TInt aAllocFailureRate ); - - void AddPanicInfoL( - const TExitCategoryName& aPanicCategory, - TInt aPanicReason, - TInt aAllocFailureRate ); - - TInt AddAssertFailure( - const TDesC8& aFailureMessage, - TInt aLineNumber, - const TDesC8& aFileName ); - - void AddTimeOutErrorL( - TInt aTimeOut); - - const CDesCArray& TestCaseNames() const; - - private: // Constructors - - CSymbianUnitTestResult(); - void ConstructL(); - - private: // New functions - - void AddAssertFailureL( - const TDesC8& aFailureMessage, - TInt aLineNumber, - const TDesC8& aFileName ); - - TInt AddFailure( - const TDesC8& aFailureText, - TInt aAllocFailureRate ); - - void AddFailureL( - const TDesC8& aFailureText, - TInt aAllocFailureRate ); - - private: // Data - - RHeap& iOriginalHeap; - RPointerArray< CSymbianUnitTestFailure > iFailures; - TInt iTestCount; - HBufC* iCurrentTestName; - TTime iTime; - TBool iCurrentResult; - CDesCArray * iTestCaseNames; - - private: // Test - - SYMBIAN_UNIT_TEST_CLASS( UT_CSymbianUnitTestResult ) - }; - -#endif // SYMBIANUNITTESTRESULT_H - - diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwframework/src/symbianunittest.cpp --- a/symbianunittestfw/sutfw/sutfwcore/sutfwframework/src/symbianunittest.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,777 +0,0 @@ -/* -* 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 "symbianunittestresult.h" -#include "symbianunittestobserver.h" -#include "symbianunittestfailure.h" -#include "sutlogger.h" -#include -#include -#include -#include - -// Assertion failure message formats: -_LIT8( KIntsNotEqualFormat, "Asserted: expected=%d, actual=%d" ); -_LIT8( KDesCsNotEqualFormat, "Asserted: expected='%S', actual='%S'" ); -_LIT8( KAssertLeaveFormat1, "'%S' expected to leave: expected=%d, actual=%d" ); -_LIT8( KAssertLeaveFormat2, "'%S' expected to leave but did not leave" ); - -const TInt KMaxSizeOfTwoIntsAsText = 80; -const TInt KErrSymbianUnitTestAssertionFailed = -99999999; -_LIT( KTestThreadName, "SymbianUnitTestThread" ); -const TInt KTestThreadMaxHeapSize = 0x400000; // 4 MB -_LIT8( KDoubleColon8, "::" ); -_LIT( KDoubleColon16, "::" ); - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -EXPORT_C void CSymbianUnitTest::ConstructL( const TDesC8& aName ) - { - TInt doubleColonPos( aName.FindF( KDoubleColon8 ) ); - TPtrC8 classNamePtr( aName ); - if ( doubleColonPos > 0 ) - { - classNamePtr.Set( aName.Left( doubleColonPos ) ); - } - - iName = CnvUtfConverter::ConvertToUnicodeFromUtf8L( classNamePtr ); - - SUT_LOG_FORMAT(_L("enter CSymbianUnitTest::ConstructL -- aName : [%S]"), iName ); - - // unify the same name for armv5 & winscw. - // on winscw, the function name is abc, - // on armv5, the function name is void abc. - // unify to abc. - TChar chSpace( ' ' ); - TChar chTab( '\t' ); - TChar chAsterisk( '*' ); - TChar chAnd( '&' ); - TBuf<100> strTmp( *iName ); - strTmp.Trim(); - TInt pos; - - // "char * & abc" => abc - pos = strTmp.LocateReverse( chAnd ); - if( KErrNotFound != pos ) - { - TPtrC ptr = strTmp.Right( strTmp.Length() - pos - 1 ); - strTmp = ptr; - strTmp.Trim(); - } - // "void * abc" => abc - pos = strTmp.LocateReverse( chAsterisk ); - if( KErrNotFound != pos ) - { - TPtrC ptr = strTmp.Right( strTmp.Length() - pos - 1 ); - strTmp = ptr; - strTmp.Trim(); - } - // "void abc" - pos = strTmp.LocateReverse( chSpace ); - if( KErrNotFound != pos ) - { - TPtrC ptr = strTmp.Right( strTmp.Length() - pos - 1 ); - strTmp = ptr; - strTmp.Trim(); - } - // "void abc" - pos = strTmp.LocateReverse( chTab ); - if( KErrNotFound != pos ) - { - TPtrC ptr = strTmp.Right( strTmp.Length() - pos - 1 ); - strTmp = ptr; - strTmp.Trim(); - } - - *iName = strTmp; - - SUT_LOG_FORMAT(_L("exit CSymbianUnitTest::ConstructL -- aName : [%S]"), iName ); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -EXPORT_C CSymbianUnitTest::CSymbianUnitTest() - : iAllocFailureType( RHeap::ENone ), - iAllocFailureRate( 0 ) - { - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -EXPORT_C CSymbianUnitTest::~CSymbianUnitTest() - { - delete iName; - iTestCases.ResetAndDestroy(); - } - -// ----------------------------------------------------------------------------- -// From MSymbianUnitTestInterface -// ----------------------------------------------------------------------------- -// -EXPORT_C void CSymbianUnitTest::ExecuteL( - MSymbianUnitTestObserver& aObserver, - CSymbianUnitTestResult& aResult, - MSymbianUnitTestInterface::TFailureSimulation aFailureSimulation, - const CDesCArray& aTestCaseNames, - TInt aTimeout ) - { - if ( aFailureSimulation == EMemAllocFailureSimulation ) - { - iAllocFailureType = RHeap::EDeterministic; - } - else - { - iAllocFailureType = RHeap::ENone; - } - SUT_LOG_FORMAT(_L("start testing, total test cases[%d]"), iTestCases.Count()); - //print the test cases name in the log - for ( TInt i = iTestCases.Count() -1; i >=0 ; i-- ) - { - CSymbianUnitTestCase& testCase = *( iTestCases[ i ] ); - //check the specified test case list if any - if ( aTestCaseNames.Count() > 0 ) - { - TInt index=0; - TInt ret = aTestCaseNames.Find(testCase.Name(), index ); - if (ret != 0) - { - //the case isn't in the specified test case names, skip it - SUT_LOG_FORMAT(_L("skip test case[%S]"), &testCase.Name()); - delete iTestCases[i]; - iTestCases.Remove(i); - continue; - } - } - SUT_LOG_FORMAT(_L("TestCase[%S]"), &testCase.Name()); - } - - for ( TInt i = 0; i < iTestCases.Count(); i++ ) - { - CSymbianUnitTestCase& testCase = *( iTestCases[ i ] ); - - aResult.StartTestL( testCase.Name() ); - ExecuteTestCaseInThreadL( testCase, aResult, aTimeout ); - aResult.EndTestL(); - - if (aResult.CurrentResult()) - { - aObserver.TestPass(iCurrentTestCase->Name()); - } - else - { - CSymbianUnitTestFailure* failure = aResult.Failures()[ - aResult.Failures().Count()-1]; - aObserver.TestFailed(iCurrentTestCase->Name(), failure->FailureMessage()); - } - } - SUT_LOG_FORMAT(_L("testing finished, total passed test cases[%d]"), aResult.PassedTestCount()); - } - -// ----------------------------------------------------------------------------- -// From MSymbianUnitTestInterface -// ----------------------------------------------------------------------------- -// -EXPORT_C TInt CSymbianUnitTest::TestCaseCount() - { - return iTestCases.Count(); - } - -// ----------------------------------------------------------------------------- -// From MSymbianUnitTestInterface -// ----------------------------------------------------------------------------- -// -EXPORT_C const TDesC& CSymbianUnitTest::Name() const - { - if ( iName ) - { - return *iName; - } - return KNullDesC; - } - -// ----------------------------------------------------------------------------- -// From MSymbianUnitTestInterface -// ----------------------------------------------------------------------------- -// -EXPORT_C void CSymbianUnitTest::TestCaseNamesL(CDesCArray& aTestCaseNames) - { - for ( TInt i = iTestCases.Count() -1; i >=0 ; i-- ) - { - CSymbianUnitTestCase& testCase = *( iTestCases[ i ] ); - aTestCaseNames.AppendL(testCase.Name()); - } - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -EXPORT_C void CSymbianUnitTest::SetupL() - { - // The default implementation is no operation - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -EXPORT_C void CSymbianUnitTest::Teardown() - { - // The default implementation is no operation - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -EXPORT_C TBool CSymbianUnitTest::IsMemoryAllocationFailureSimulationUsed() const - { - return ( iAllocFailureType == RHeap::EDeterministic ); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -EXPORT_C void CSymbianUnitTest::AddTestCaseL( - const TDesC& aName, - FunctionPtr aSetupFunction, - FunctionPtr aTestFunction, - FunctionPtr aTeardownFunction ) - { - const TInt KTestCaseNameLength = - Name().Length() + KDoubleColon16().Length() + aName.Length(); - HBufC* name = HBufC::NewLC( KTestCaseNameLength ); - name->Des().Append( Name() ); - name->Des().Append( KDoubleColon16 ); - name->Des().Append( aName ); - CSymbianUnitTestCase* testCase = - CSymbianUnitTestCase::NewL( - *name, aSetupFunction, aTestFunction, aTeardownFunction ); - CleanupStack::PopAndDestroy( name ); - CleanupStack::PushL( testCase ); - iTestCases.AppendL( testCase ); - CleanupStack::Pop( testCase ); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -EXPORT_C void CSymbianUnitTest::AssertEqualsL( - TInt aExpectedValue, - TInt aActualValue, - TInt aLineNumber, - const TDesC8& aFileName ) - { - if ( aExpectedValue != aActualValue ) - { - StopAllocFailureSimulation(); - HBufC8* msg = HBufC8::NewLC( - KIntsNotEqualFormat().Size() + KMaxSizeOfTwoIntsAsText ); - msg->Des().Format( KIntsNotEqualFormat, aExpectedValue, aActualValue ); - AssertionFailedL( *msg, aLineNumber, aFileName ); - } - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -EXPORT_C void CSymbianUnitTest::AssertEqualsL( - const TDesC8& aExpectedValue, - const TDesC8& aActualValue, - TInt aLineNumber, - const TDesC8& aFileName ) - { - if ( aExpectedValue.Compare( aActualValue ) != 0 ) - { - StopAllocFailureSimulation(); - TInt size = - KDesCsNotEqualFormat().Size() + - aExpectedValue.Size() + - aActualValue.Size(); - HBufC8 *msg = HBufC8::NewLC( size ); - msg->Des().Format( KDesCsNotEqualFormat, - &aExpectedValue, - &aActualValue ); - AssertionFailedL( *msg, aLineNumber, aFileName ); - } - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -EXPORT_C void CSymbianUnitTest::AssertEqualsL( - const TDesC16& aExpectedValue, - const TDesC16& aActualValue, - TInt aLineNumber, - const TDesC8& aFileName ) - { - if ( aExpectedValue.Compare( aActualValue ) != 0 ) - { - StopAllocFailureSimulation(); - HBufC8* msg = NotEqualsMessageLC( aExpectedValue, aActualValue ); - AssertionFailedL( *msg, aLineNumber, aFileName ); - } - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -EXPORT_C void CSymbianUnitTest::AssertLeaveL( - const TDesC8& aStatement, - TInt aActualLeaveCode, - TInt aExpectedLeaveCode, - TInt aLineNumber, - const TDesC8& aFileName ) - { - if ( aActualLeaveCode == KErrNoMemory && - aExpectedLeaveCode != KErrNoMemory && - iAllocFailureType == RHeap::EDeterministic ) - { - User::Leave( KErrNoMemory ); - } - if ( aActualLeaveCode != aExpectedLeaveCode ) - { - StopAllocFailureSimulation(); - HBufC8* msg = HBufC8::NewLC( - KAssertLeaveFormat1().Size() + - aStatement.Size() + - KMaxSizeOfTwoIntsAsText ); - msg->Des().Format( KAssertLeaveFormat2, &aStatement, - aExpectedLeaveCode, aActualLeaveCode ); - AssertionFailedL( *msg, aLineNumber, aFileName ); - } - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -EXPORT_C void CSymbianUnitTest::RecordNoLeaveFromStatementL( - const TDesC8& aStatement, - TInt aLineNumber, - const TDesC8& aFileName ) - { - StopAllocFailureSimulation(); - HBufC8* msg = - HBufC8::NewLC( KAssertLeaveFormat1().Size() + aStatement.Size() ); - msg->Des().Format( KAssertLeaveFormat1, &aStatement ); - AssertionFailedL( *msg, aLineNumber, aFileName ); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -EXPORT_C void CSymbianUnitTest::AssertionFailedL( - const TDesC8& aFailureMessage, - TInt aLineNumber, - const TDesC8& aFileName ) - { - TInt dummy( 0 ); - TInt heapCellsBeforeAddingTheFailure( User::Heap().AllocSize( dummy ) ); - - if ( iTestResult ) - { - User::LeaveIfError( iTestResult->AddAssertFailure( - aFailureMessage, aLineNumber, aFileName ) ); - } - - TInt heapCellsAfterAddingTheFailure( User::Heap().AllocSize( dummy ) ); - iHeapCellsReservedByAssertFailure = - heapCellsAfterAddingTheFailure - heapCellsBeforeAddingTheFailure; - User::Leave( KErrSymbianUnitTestAssertionFailed ); - } - - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -EXPORT_C void CSymbianUnitTest::AssertEqualsL( - TInt aExpectedValue, - TInt aActualValue, - TInt aLineNumber, - const TDesC8& aFileName, - const TDesC8& aFailureMessage ) - { - if ( aExpectedValue != aActualValue ) - { - StopAllocFailureSimulation(); - AssertionFailedL( aFailureMessage, aLineNumber, aFileName ); - } - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -EXPORT_C void CSymbianUnitTest::AssertEqualsL( - const TDesC8& aExpectedValue, - const TDesC8& aActualValue, - TInt aLineNumber, - const TDesC8& aFileName, - const TDesC8& aFailureMessage ) - { - if ( aExpectedValue.Compare( aActualValue ) != 0 ) - { - StopAllocFailureSimulation(); - AssertionFailedL( aFailureMessage, aLineNumber, aFileName ); - } - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -EXPORT_C void CSymbianUnitTest::AssertEqualsL( - const TDesC16& aExpectedValue, - const TDesC16& aActualValue, - TInt aLineNumber, - const TDesC8& aFileName, - const TDesC8& aFailureMessage ) - { - if ( aExpectedValue.Compare( aActualValue ) != 0 ) - { - StopAllocFailureSimulation(); - AssertionFailedL( aFailureMessage, aLineNumber, aFileName ); - } - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTest::CSymbianUnitTestCase* -CSymbianUnitTest::CSymbianUnitTestCase::NewL( - const TDesC& aName, - FunctionPtr aSetupFunction, - FunctionPtr aTestFunction, - FunctionPtr aTeardownFunction ) - { - CSymbianUnitTestCase* self = - new( ELeave )CSymbianUnitTestCase( - aSetupFunction, aTestFunction, aTeardownFunction ); - CleanupStack::PushL( self ); - self->ConstructL( aName ); - CleanupStack::Pop( self ); - return self; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTest::CSymbianUnitTestCase::CSymbianUnitTestCase( - FunctionPtr aSetupFunction, - FunctionPtr aTestFunction, - FunctionPtr aTeardownFunction ) : - iSetupFunction( aSetupFunction ), - iTestFunction( aTestFunction ), - iTeardownFunction( aTeardownFunction ) - { - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTest::CSymbianUnitTestCase::ConstructL( const TDesC& aName ) - { - iName = aName.AllocL(); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTest::CSymbianUnitTestCase::~CSymbianUnitTestCase() - { - delete iName; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -const TDesC& CSymbianUnitTest::CSymbianUnitTestCase::Name() const - { - return *iName; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -HBufC8* CSymbianUnitTest::NotEqualsMessageLC( - const TDesC16& aExpectedValue, - const TDesC16& aActualValue ) - { - TInt length = - KDesCsNotEqualFormat().Length() + - aExpectedValue.Length() + - aActualValue.Length(); - HBufC8* msg = HBufC8::NewLC( length ); - - HBufC8* expected = - CnvUtfConverter::ConvertFromUnicodeToUtf8L( aExpectedValue ); - CleanupStack::PushL( expected ); - - HBufC8* actual = CnvUtfConverter::ConvertFromUnicodeToUtf8L( aActualValue ); - CleanupStack::PushL( actual ); - - msg->Des().Format( KDesCsNotEqualFormat, expected, actual ); - - CleanupStack::PopAndDestroy( actual ); - CleanupStack::PopAndDestroy( expected ); - - return msg; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTest::ExecuteTestCaseInThreadL( - CSymbianUnitTestCase& aTestCase, - CSymbianUnitTestResult& aResult, - TInt aTimeout ) - { - iCurrentTestCase = &aTestCase; - iTestResult = &aResult; - - //create exec thread - TName threadName( KTestThreadName ); - // Append a random number to make the name unique - const TInt KThreadIdWidth = 10; - threadName.AppendNumFixedWidthUC( Math::Random(), EHex, KThreadIdWidth ); - RThread execThread; - TInt err = execThread.Create( threadName, - TestThreadEntryFunction, - KDefaultStackSize, - KMinHeapSize, - KTestThreadMaxHeapSize, - this ); - User::LeaveIfError( err ); - CleanupClosePushL( execThread ); - - - //start exec thread - TRequestStatus status = KRequestPending; - execThread.Logon( status ); - execThread.Resume(); - - TBool timedOut = EFalse; - if (aTimeout > 0) - { - SUT_LOG_DEBUGF(_L("run test case with timeout %d"), aTimeout); - //run test case with timeout control - TRequestStatus waitStatus = KRequestPending; - RTimer timer; - User::LeaveIfError(timer.CreateLocal()); - CleanupClosePushL(timer); - timer.After(waitStatus, aTimeout*1000000); - User::WaitForRequest( status, waitStatus ); - if (waitStatus.Int() == KRequestPending) - { - timer.Cancel(); - timer.Close(); - User::WaitForRequest( waitStatus ); - } - - if (status.Int() == KRequestPending) - { - //test case did not complete in time - //terminate the exec thread - SUT_LOG_DEBUG(" test case timed out, kill the exec thread"); - timedOut = ETrue; - - execThread.LogonCancel( status ); - User::WaitForRequest(status); - - execThread.Kill(KErrTimedOut); - aResult.AddTimeOutErrorL( aTimeout ); - } - CleanupStack::PopAndDestroy( &timer ); - } - else - { - SUT_LOG_DEBUG(" run test case without timeout"); - //exec test case without timeout control - User::WaitForRequest(status); - } - if (status.Int() != KErrNone && !timedOut) - { - SUT_LOG_DEBUG("testcase exec thread panic"); - aResult.AddPanicInfoL( - execThread.ExitCategory(), - execThread.ExitReason(), - iAllocFailureRate ); - } - CleanupStack::PopAndDestroy( &execThread ); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TInt CSymbianUnitTest::TestThreadEntryFunction( TAny* aPtr ) - { - CSymbianUnitTest* self = reinterpret_cast< CSymbianUnitTest* >( aPtr ); - TInt err = KErrNoMemory; - CTrapCleanup* cleanupStack = CTrapCleanup::New(); - if ( cleanupStack ) - { - // Operator new used without ELeave on purpose to avoid using TRAP. - CActiveScheduler* scheduler = new CActiveScheduler; - if ( scheduler ) - { - CActiveScheduler::Install( scheduler ); - TRAP( err, self->ExecuteTestCaseL() ) - delete scheduler; - } - } - delete cleanupStack; - return err; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTest::ExecuteTestCaseL() - { - __ASSERT_ALWAYS( iTestResult, User::Leave( KErrNotFound ) ); - __ASSERT_ALWAYS( iCurrentTestCase, User::Leave( KErrNotFound ) ); - iAllocFailureRate = 0; - iLeakedMemory = 0; - iLeakedResource = 0; - iLeakedRequest = 0; - TInt leaveCodeFromTest( KErrNoMemory ); - if ( iAllocFailureType == RHeap::EDeterministic ) - { - TUint counter( 1 ); - while ( leaveCodeFromTest == KErrNoMemory ) - { - iAllocFailureRate = counter; - DoExecuteTestCaseL( leaveCodeFromTest ); - counter++; - } - } - else - { - DoExecuteTestCaseL( leaveCodeFromTest ); - } - // Add the possible failure or memory leak to the results - if ( leaveCodeFromTest == KErrNone ) - { - if ( iLeakedMemory > 0 ) - { - iTestResult->AddMemoryLeakInfoL( iLeakedMemory, iAllocFailureRate ); - } - if ( iLeakedResource > 0 ) - { - iTestResult->AddResourceLeakInfoL( iLeakedResource, iAllocFailureRate ); - } - if ( iLeakedRequest > 0 ) - { - iTestResult->AddRequestLeakInfoL( iLeakedRequest, iAllocFailureRate ); - } - } - else if ( leaveCodeFromTest != KErrSymbianUnitTestAssertionFailed ) - { - iTestResult->AddLeaveFromTestL( leaveCodeFromTest, iAllocFailureRate ); - } - else - { - // No operation here. - // Assertion failure has happened and it has been added to the results. - } - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTest::DoExecuteTestCaseL( TInt& aLeaveCodeFromTest ) - { - __ASSERT_ALWAYS( iTestResult, User::Leave( KErrNotFound ) ); - __ASSERT_ALWAYS( iCurrentTestCase, User::Leave( KErrNotFound ) ); - aLeaveCodeFromTest = KErrNone; - iHeapCellsReservedByAssertFailure = 0; - TInt memoryBeforeTest( 0 ); - TInt heapCellsBeforeTest( User::Heap().AllocSize( memoryBeforeTest ) ); - TInt resourceInThreadBeforeTest, resourceInProcessBeforeTest; - RThread().HandleCount( resourceInProcessBeforeTest, resourceInThreadBeforeTest ); - TInt requestBeforeTest = RThread().RequestCount(); - TRAPD( err, ( this->*iCurrentTestCase->iSetupFunction )() ) - if ( err != KErrNone ) - { - ( this->*iCurrentTestCase->iTeardownFunction )(); - iTestResult->AddSetupErrorL( err ); - return; - } - StartAllocFailureSimulation(); - TRAP( aLeaveCodeFromTest, ( this->*iCurrentTestCase->iTestFunction )() ); - StopAllocFailureSimulation(); - - ( this->*iCurrentTestCase->iTeardownFunction )(); - - TInt memoryAfterTest( 0 ); - TInt heapCellsAfterTest( User::Heap().AllocSize( memoryAfterTest ) ); - TInt leakedHeapCells = - heapCellsAfterTest - - ( heapCellsBeforeTest + iHeapCellsReservedByAssertFailure ); - if ( leakedHeapCells > 0 ) - { - iLeakedMemory = memoryAfterTest - memoryBeforeTest; - } - - TInt resourceInThreadAfterTest, resourceInProcessAfterTest; - RThread().HandleCount( resourceInProcessAfterTest, resourceInThreadAfterTest ); - iLeakedResource = resourceInThreadAfterTest - resourceInThreadBeforeTest; - TInt requestAfterTest = RThread().RequestCount(); - iLeakedRequest = requestAfterTest - requestBeforeTest; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTest::StartAllocFailureSimulation() - { - __UHEAP_SETFAIL( iAllocFailureType, iAllocFailureRate ); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTest::StopAllocFailureSimulation() - { - __UHEAP_RESET; - } diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwframework/src/symbianunittestfailure.cpp --- a/symbianunittestfw/sutfw/sutfwcore/sutfwframework/src/symbianunittestfailure.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,123 +0,0 @@ -/* -* 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 "symbianunittestfailure.h" -#include - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestFailure* CSymbianUnitTestFailure::NewL( - const TDesC& aTestName, - const TDesC8& aFailureMessage, - TInt aLineNumber, - const TDesC8& aFileName ) - { - CSymbianUnitTestFailure* self = - CSymbianUnitTestFailure::NewLC( - aTestName, aFailureMessage, aLineNumber, aFileName ); - CleanupStack::Pop( self ); - return self; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestFailure* CSymbianUnitTestFailure::NewLC( - const TDesC& aTestName, - const TDesC8& aFailureMessage, - TInt aLineNumber, - const TDesC8& aFileName ) - { - CSymbianUnitTestFailure* self = - new( ELeave )CSymbianUnitTestFailure( aLineNumber ); - CleanupStack::PushL( self ); - self->ConstructL( aTestName, aFailureMessage, aFileName ); - return self; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestFailure::CSymbianUnitTestFailure( TInt aLineNumber ) - : iLineNumber( aLineNumber ) - { - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestFailure::ConstructL( - const TDesC& aTestName, - const TDesC8& aFailureMessage, - const TDesC8& aFileName ) - { - iTestName = CnvUtfConverter::ConvertFromUnicodeToUtf8L( aTestName ); - iFailureMessage = aFailureMessage.AllocL(); - iFileName = aFileName.AllocL(); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestFailure::~CSymbianUnitTestFailure() - { - delete iFileName; - delete iFailureMessage; - delete iTestName; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -const TDesC8& CSymbianUnitTestFailure::TestName() - { - return *iTestName; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -const TDesC8& CSymbianUnitTestFailure::FailureMessage() - { - return *iFailureMessage; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TInt CSymbianUnitTestFailure::LineNumber() - { - return iLineNumber; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -const TDesC8& CSymbianUnitTestFailure::FileName() - { - return *iFileName; - } diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwframework/src/symbianunittestresult.cpp --- a/symbianunittestfw/sutfw/sutfwcore/sutfwframework/src/symbianunittestresult.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,404 +0,0 @@ -/* -* 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 "symbianunittestresult.h" -#include "symbianunittestfailure.h" -#include "sutlogger.h" - - -_LIT8( KSymbianUnitTestLeaveCodeMessageFormat, "Leave code: %d" ); -_LIT8( KSymbianUnitTestMemoryLeakPhrase, "Leaked %d bytes of memory" ); -_LIT8( KSymbianUnitTestResourceLeakPhrase, "Leaked %d handles" ); -_LIT8( KSymbianUnitTestRequestLeakPhrase, "Leaked %d requests" ); -_LIT8( KSymbianUnitTestPanicPhrase, "Panic: " ); -_LIT8( KSymbianUnitTestPanicReasonFormat, ", reason: %d" ); -_LIT8( KSymbianUnitTestAllocFailureRateFormat, ", alloc failure rate: %d" ); -_LIT8( KSymbianUnitTestSetupFailed, "Leave from the setup function: %d" ); -_LIT8( KSymbianUnitTestErrorFormat, "Test Failed File[%S], Line[%d], Msg[%S]"); -_LIT8( KSymbianUnitTestFailed, "Test Failed Reason[%S]"); -_LIT( KSymbianUnitTestPass, "pass" ); -_LIT( KSymbianUnitTestFail, "fail" ); -_LIT8( KSymbianUnitTestTimedOut, "Timed out: %d s" ); - -const TInt KMax64BitUintLengthAsDescriptor = 20; -const TInt KMaxLength(1024); - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestResult* CSymbianUnitTestResult::NewLC() - { - CSymbianUnitTestResult* self = new( ELeave )CSymbianUnitTestResult; - CleanupStack::PushL( self ); - self->ConstructL(); - return self; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestResult* CSymbianUnitTestResult::NewL() - { - CSymbianUnitTestResult* self = CSymbianUnitTestResult::NewLC(); - CleanupStack::Pop( self ); - return self; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestResult::CSymbianUnitTestResult() - : iOriginalHeap( User::Heap() ) - { - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestResult::ConstructL() - { - iCurrentTestName = KNullDesC().AllocL(); - iTestCaseNames = new (ELeave)CDesCArrayFlat(10); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestResult::~CSymbianUnitTestResult() - { - delete iCurrentTestName; - delete iTestCaseNames; - iFailures.ResetAndDestroy(); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TInt CSymbianUnitTestResult::TestCount() const - { - return iTestCount; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TInt CSymbianUnitTestResult::PassedTestCount() const - { - return ( iTestCount - iFailures.Count() ); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -RPointerArray< CSymbianUnitTestFailure >& CSymbianUnitTestResult::Failures() - { - return iFailures; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestResult::StartTestL( const TDesC& aTestName ) - { - SUT_LOG_FORMAT(_L("StartCase[%S]"), &aTestName); - HBufC* tmp = aTestName.AllocL(); - delete iCurrentTestName; - iCurrentTestName = tmp; - iTestCount++; - iCurrentResult = ETrue; - iTime.UniversalTime(); - } - - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestResult::EndTestL() - { - TTime now; - now.UniversalTime(); - TTimeIntervalMicroSeconds microSeconds = now.MicroSecondsFrom(iTime); - TReal64 ms= microSeconds.Int64(); - //log the test time in milliseconds - SUT_LOG_FORMAT2(_L("EndCase Result[%S] Time[%d]ms"), - iCurrentResult?&KSymbianUnitTestPass:&KSymbianUnitTestFail, - microSeconds.Int64()/1000); - if (iCurrentResult) - { - //only add passed case to the testcasenames - iTestCaseNames->AppendL(*iCurrentTestName); - } - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TBool CSymbianUnitTestResult::CurrentResult() - { - return iCurrentResult; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestResult::AddSetupErrorL( TInt aError ) - { - const TInt KLength = - KSymbianUnitTestSetupFailed().Length() + - KMax64BitUintLengthAsDescriptor; - HBufC8* errorAsText = HBufC8::NewLC( KLength ); - errorAsText->Des().Format( KSymbianUnitTestSetupFailed, aError ); - User::LeaveIfError( AddFailure( *errorAsText, 0 ) ); - CleanupStack::PopAndDestroy( errorAsText ); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestResult::AddLeaveFromTestL( - TInt aLeaveCode, - TInt aAllocFailureRate ) - { - const TInt KLength = - KSymbianUnitTestLeaveCodeMessageFormat().Length() + - KMax64BitUintLengthAsDescriptor; - HBufC8* failureMsg = HBufC8::NewLC( KLength ); - failureMsg->Des().Format( - KSymbianUnitTestLeaveCodeMessageFormat, aLeaveCode ); - User::LeaveIfError( AddFailure( *failureMsg, aAllocFailureRate ) ); - CleanupStack::PopAndDestroy( failureMsg ); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestResult::AddMemoryLeakInfoL( - TInt aLeakedMemory, - TInt aAllocFailureRate ) - { - const TInt KLength = - KSymbianUnitTestMemoryLeakPhrase().Length() + - KMax64BitUintLengthAsDescriptor; - HBufC8* failureMsg = HBufC8::NewLC( KLength ); - failureMsg->Des().Format( - KSymbianUnitTestMemoryLeakPhrase, aLeakedMemory ); - User::LeaveIfError( AddFailure( *failureMsg, aAllocFailureRate ) ); - CleanupStack::PopAndDestroy( failureMsg ); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestResult::AddResourceLeakInfoL( - TInt aLeakedResource, - TInt aAllocFailureRate ) - { - const TInt KLength = - KSymbianUnitTestResourceLeakPhrase().Length() + - KMax64BitUintLengthAsDescriptor; - HBufC8* failureMsg = HBufC8::NewLC( KLength ); - failureMsg->Des().Format( - KSymbianUnitTestResourceLeakPhrase, aLeakedResource ); - User::LeaveIfError( AddFailure( *failureMsg, aAllocFailureRate ) ); - CleanupStack::PopAndDestroy( failureMsg ); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestResult::AddRequestLeakInfoL( - TInt aLeakedRequest, - TInt aAllocFailureRate ) - { - const TInt KLength = - KSymbianUnitTestRequestLeakPhrase().Length() + - KMax64BitUintLengthAsDescriptor; - HBufC8* failureMsg = HBufC8::NewLC( KLength ); - failureMsg->Des().Format( - KSymbianUnitTestRequestLeakPhrase, aLeakedRequest ); - User::LeaveIfError( AddFailure( *failureMsg, aAllocFailureRate ) ); - CleanupStack::PopAndDestroy( failureMsg ); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestResult::AddPanicInfoL( - const TExitCategoryName& aPanicCategory, - TInt aPanicReason, - TInt aAllocFailureRate ) - { - const TInt KLength = - KSymbianUnitTestPanicPhrase().Length() + aPanicCategory.Length() + - KSymbianUnitTestPanicReasonFormat().Length() + - KMax64BitUintLengthAsDescriptor; - HBufC8* panicAsText = HBufC8::NewLC( KLength ); - TPtr8 panicAsTextPtr( panicAsText->Des() ); - panicAsTextPtr.Append( KSymbianUnitTestPanicPhrase ); - panicAsTextPtr.Append( aPanicCategory ); - panicAsTextPtr.AppendFormat( - KSymbianUnitTestPanicReasonFormat, aPanicReason ); - User::LeaveIfError( AddFailure( panicAsTextPtr, aAllocFailureRate ) ); - CleanupStack::PopAndDestroy( panicAsText ); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TInt CSymbianUnitTestResult::AddAssertFailure( - const TDesC8& aFailureMessage, - TInt aLineNumber, - const TDesC8& aFileName ) - { - RHeap* currentHeap = User::SwitchHeap( &iOriginalHeap ); - TRAPD( err, AddAssertFailureL( aFailureMessage, aLineNumber, aFileName ) ); - User::SwitchHeap( currentHeap ); - return err; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestResult::AddAssertFailureL( - const TDesC8& aFailureMessage, - TInt aLineNumber, - const TDesC8& aFileName ) - { - CSymbianUnitTestFailure* failure = - CSymbianUnitTestFailure::NewLC( - *iCurrentTestName, aFailureMessage, aLineNumber, aFileName ); - TBuf8 strLine; - strLine.Format( KSymbianUnitTestErrorFormat, &aFileName, aLineNumber, &aFailureMessage ); - while(strLine.Length() > 120) - { - TBuf8 line = strLine.MidTPtr( 0, 120 ); - line.Append( '-' ); - SUT_LOG_FORMAT(_L8("%S"), &line ); - line = strLine.Mid( 120 ); - strLine = line; - } - SUT_LOG_FORMAT(_L8("%S"), &strLine ); - iCurrentResult = EFalse; - iFailures.AppendL( failure ); - CleanupStack::Pop( failure ); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestResult::AddTimeOutErrorL( TInt aTimeOut ) - { - const TInt KLength = - KSymbianUnitTestTimedOut().Length() + - KMax64BitUintLengthAsDescriptor; - HBufC8* errorAsText = HBufC8::NewLC( KLength ); - errorAsText->Des().Format( KSymbianUnitTestTimedOut, aTimeOut ); - User::LeaveIfError( AddFailure( *errorAsText, 0 ) ); - CleanupStack::PopAndDestroy( errorAsText ); - } - - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TInt CSymbianUnitTestResult::AddFailure( - const TDesC8& aFailureText, - TInt aAllocFailureRate ) - { - RHeap* currentHeap = User::SwitchHeap( &iOriginalHeap ); - TRAPD( err, AddFailureL( aFailureText, aAllocFailureRate ) ) - User::SwitchHeap( currentHeap ); - return err; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestResult::AddFailureL( - const TDesC8& aFailureText, - TInt aAllocFailureRate ) - { - CSymbianUnitTestFailure* failure = NULL; - if ( aAllocFailureRate > 0 ) - { - const TInt KLength = - aFailureText.Length() + - KSymbianUnitTestAllocFailureRateFormat().Length() + - KMax64BitUintLengthAsDescriptor; - HBufC8* failureMsg = HBufC8::NewLC( KLength ); - failureMsg->Des() = aFailureText; - failureMsg->Des().AppendFormat( - KSymbianUnitTestAllocFailureRateFormat, aAllocFailureRate ); - failure = CSymbianUnitTestFailure::NewL( - *iCurrentTestName, *failureMsg, KErrNotFound, KNullDesC8 ); - CleanupStack::PopAndDestroy( failureMsg ); - CleanupStack::PushL( failure ); - } - else - { - failure = CSymbianUnitTestFailure::NewLC( - *iCurrentTestName, aFailureText, KErrNotFound, KNullDesC8 ); - } - - TBuf8 strLine; - strLine.Format( KSymbianUnitTestFailed, &aFailureText ); - while(strLine.Length() > 120) - { - TBuf8 line = strLine.MidTPtr( 0, 120 ); - line.Append( '-' ); - SUT_LOG_FORMAT(_L8("%S"), &line ); - line = strLine.Mid( 120 ); - strLine = line; - } - SUT_LOG_FORMAT(_L8("%S"), &strLine ); - //SUT_LOG_FORMAT(KSymbianUnitTestFailed, &aFailureText); - iCurrentResult = EFalse; - iFailures.AppendL( failure ); - CleanupStack::Pop( failure ); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -const CDesCArray& CSymbianUnitTestResult::TestCaseNames() const - { - return *iTestCaseNames; - } - diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwframework/src/symbianunittestsuite.cpp --- a/symbianunittestfw/sutfw/sutfwcore/sutfwframework/src/symbianunittestsuite.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,139 +0,0 @@ -/* -* 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 -#include "symbianunittestresult.h" -#include "sutlogger.h" -#include - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -EXPORT_C CSymbianUnitTestSuite* CSymbianUnitTestSuite::NewLC( - const TDesC& aName ) - { - CSymbianUnitTestSuite* self = new( ELeave )CSymbianUnitTestSuite(); - CleanupStack::PushL( self ); - self->ConstructL( aName ); - return self; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -EXPORT_C CSymbianUnitTestSuite* CSymbianUnitTestSuite::NewL( - const TDesC& aName ) - { - CSymbianUnitTestSuite* self = CSymbianUnitTestSuite::NewLC( aName ); - CleanupStack::Pop( self ); - return self; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -EXPORT_C void CSymbianUnitTestSuite::ConstructL( const TDesC& aName ) - { - iName = aName.AllocL(); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -EXPORT_C CSymbianUnitTestSuite::CSymbianUnitTestSuite() - { - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -EXPORT_C CSymbianUnitTestSuite::~CSymbianUnitTestSuite() - { - iTests.ResetAndDestroy(); - delete iName; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -EXPORT_C void CSymbianUnitTestSuite::AddL( - MSymbianUnitTestInterface* aTest ) - { - iTests.AppendL( aTest ); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -EXPORT_C void CSymbianUnitTestSuite::ExecuteL( - MSymbianUnitTestObserver& aObserver, - CSymbianUnitTestResult& aResult, - MSymbianUnitTestInterface::TFailureSimulation aFailureSimulation, - const CDesCArray& aTestCaseNames, - TInt aTimeout ) - { - for ( TInt i=0; i < iTests.Count(); i++ ) - { - iTests[i]->ExecuteL( aObserver, aResult, aFailureSimulation, aTestCaseNames, aTimeout); - } - } - - -// ----------------------------------------------------------------------------- -// From MSymbianUnitTestInterface -// ----------------------------------------------------------------------------- -// -EXPORT_C void CSymbianUnitTestSuite::TestCaseNamesL(CDesCArray& aTestCaseNames) - { - for ( TInt i=0; i < iTests.Count(); i++ ) - { - MSymbianUnitTestInterface* test = iTests[i]; - test->TestCaseNamesL(aTestCaseNames); - } - - } - - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -EXPORT_C TInt CSymbianUnitTestSuite::TestCaseCount() - { - TInt count = 0; - for ( TInt i=0; i < iTests.Count(); i++ ) - { - count += iTests[i]->TestCaseCount(); - } - return count; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -EXPORT_C const TDesC& CSymbianUnitTestSuite::Name() const - { - return *iName; - } diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwframework/tsrc/BWINS/ut_sutfwframeworkU.DEF --- a/symbianunittestfw/sutfw/sutfwcore/sutfwframework/tsrc/BWINS/ut_sutfwframeworkU.DEF Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -EXPORTS - ?CreateTestSuiteL@@YAPAVMSymbianUnitTestInterface@@XZ @ 1 NONAME ; class MSymbianUnitTestInterface * CreateTestSuiteL(void) - ?RecordNoLeaveFromStatementL@CSymbianUnitTest@@IAEXABVTDesC8@@H0@Z @ 2 NONAME ; void CSymbianUnitTest::RecordNoLeaveFromStatementL(class TDesC8 const &, int, class TDesC8 const &) - ??0CSymbianUnitTest@@IAE@XZ @ 3 NONAME ; CSymbianUnitTest::CSymbianUnitTest(void) - ?ConstructL@CSymbianUnitTest@@IAEXABVTDesC8@@@Z @ 4 NONAME ; void CSymbianUnitTest::ConstructL(class TDesC8 const &) - ?AddL@CSymbianUnitTestSuite@@QAEXPAVMSymbianUnitTestInterface@@@Z @ 5 NONAME ; void CSymbianUnitTestSuite::AddL(class MSymbianUnitTestInterface *) - ??1CSymbianUnitTest@@UAE@XZ @ 6 NONAME ; CSymbianUnitTest::~CSymbianUnitTest(void) - ?SetupL@CSymbianUnitTest@@UAEXXZ @ 7 NONAME ; void CSymbianUnitTest::SetupL(void) - ?AssertionFailedL@CSymbianUnitTest@@IAEXABVTDesC8@@H0@Z @ 8 NONAME ; void CSymbianUnitTest::AssertionFailedL(class TDesC8 const &, int, class TDesC8 const &) - ?ConstructL@CSymbianUnitTestSuite@@IAEXABVTDesC16@@@Z @ 9 NONAME ; void CSymbianUnitTestSuite::ConstructL(class TDesC16 const &) - ?AssertEqualsL@CSymbianUnitTest@@IAEXHHHABVTDesC8@@@Z @ 10 NONAME ; void CSymbianUnitTest::AssertEqualsL(int, int, int, class TDesC8 const &) - ?AssertEqualsL@CSymbianUnitTest@@IAEXABVTDesC16@@0HABVTDesC8@@@Z @ 11 NONAME ; void CSymbianUnitTest::AssertEqualsL(class TDesC16 const &, class TDesC16 const &, int, class TDesC8 const &) - ?Name@CSymbianUnitTestSuite@@UBEABVTDesC16@@XZ @ 12 NONAME ; class TDesC16 const & CSymbianUnitTestSuite::Name(void) const - ?Teardown@CSymbianUnitTest@@UAEXXZ @ 13 NONAME ; void CSymbianUnitTest::Teardown(void) - ?AssertLeaveL@CSymbianUnitTest@@IAEXABVTDesC8@@HHH0@Z @ 14 NONAME ; void CSymbianUnitTest::AssertLeaveL(class TDesC8 const &, int, int, int, class TDesC8 const &) - ?AssertEqualsL@CSymbianUnitTest@@IAEXABVTDesC8@@0H0@Z @ 15 NONAME ; void CSymbianUnitTest::AssertEqualsL(class TDesC8 const &, class TDesC8 const &, int, class TDesC8 const &) - ?AssertEqualsL@CSymbianUnitTest@@IAEXABVTDesC8@@0H00@Z @ 16 NONAME ; void CSymbianUnitTest::AssertEqualsL(class TDesC8 const &, class TDesC8 const &, int, class TDesC8 const &, class TDesC8 const &) - ??0CSymbianUnitTestSuite@@IAE@XZ @ 17 NONAME ; CSymbianUnitTestSuite::CSymbianUnitTestSuite(void) - ?AssertEqualsL@CSymbianUnitTest@@IAEXABVTDesC16@@0HABVTDesC8@@1@Z @ 18 NONAME ; void CSymbianUnitTest::AssertEqualsL(class TDesC16 const &, class TDesC16 const &, int, class TDesC8 const &, class TDesC8 const &) - ?Name@CSymbianUnitTest@@UBEABVTDesC16@@XZ @ 19 NONAME ; class TDesC16 const & CSymbianUnitTest::Name(void) const - ?ExecuteL@CSymbianUnitTest@@UAEXAAVMSymbianUnitTestObserver@@AAVCSymbianUnitTestResult@@W4TFailureSimulation@MSymbianUnitTestInterface@@ABVCDesC16Array@@H@Z @ 20 NONAME ; void CSymbianUnitTest::ExecuteL(class MSymbianUnitTestObserver &, class CSymbianUnitTestResult &, enum MSymbianUnitTestInterface::TFailureSimulation, class CDesC16Array const &, int) - ?NewL@CSymbianUnitTestSuite@@SAPAV1@ABVTDesC16@@@Z @ 21 NONAME ; class CSymbianUnitTestSuite * CSymbianUnitTestSuite::NewL(class TDesC16 const &) - ??1CSymbianUnitTestSuite@@UAE@XZ @ 22 NONAME ; CSymbianUnitTestSuite::~CSymbianUnitTestSuite(void) - ?NewLC@CSymbianUnitTestSuite@@SAPAV1@ABVTDesC16@@@Z @ 23 NONAME ; class CSymbianUnitTestSuite * CSymbianUnitTestSuite::NewLC(class TDesC16 const &) - ?ExecuteL@CSymbianUnitTestSuite@@UAEXAAVMSymbianUnitTestObserver@@AAVCSymbianUnitTestResult@@W4TFailureSimulation@MSymbianUnitTestInterface@@ABVCDesC16Array@@H@Z @ 24 NONAME ; void CSymbianUnitTestSuite::ExecuteL(class MSymbianUnitTestObserver &, class CSymbianUnitTestResult &, enum MSymbianUnitTestInterface::TFailureSimulation, class CDesC16Array const &, int) - ?IsMemoryAllocationFailureSimulationUsed@CSymbianUnitTest@@IBEHXZ @ 25 NONAME ; int CSymbianUnitTest::IsMemoryAllocationFailureSimulationUsed(void) const - ?TestCaseCount@CSymbianUnitTestSuite@@UAEHXZ @ 26 NONAME ; int CSymbianUnitTestSuite::TestCaseCount(void) - ?AddTestCaseL@CSymbianUnitTest@@IAEXABVTDesC16@@P81@AEXXZ11@Z @ 27 NONAME ; void CSymbianUnitTest::AddTestCaseL(class TDesC16 const &, void (*)(void), void (*)(void), void (*)(void)) - ?TestCaseCount@CSymbianUnitTest@@UAEHXZ @ 28 NONAME ; int CSymbianUnitTest::TestCaseCount(void) - ?AssertEqualsL@CSymbianUnitTest@@IAEXHHHABVTDesC8@@0@Z @ 29 NONAME ; void CSymbianUnitTest::AssertEqualsL(int, int, int, class TDesC8 const &, class TDesC8 const &) - ?TestCaseNamesL@CSymbianUnitTestSuite@@UAEXAAVCDesC16Array@@@Z @ 30 NONAME ; void CSymbianUnitTestSuite::TestCaseNamesL(class CDesC16Array &) - ?TestCaseNamesL@CSymbianUnitTest@@UAEXAAVCDesC16Array@@@Z @ 31 NONAME ; void CSymbianUnitTest::TestCaseNamesL(class CDesC16Array &) - diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwframework/tsrc/eabi/ut_sutfwframeworku.def --- a/symbianunittestfw/sutfw/sutfwcore/sutfwframework/tsrc/eabi/ut_sutfwframeworku.def Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -EXPORTS - _Z16CreateTestSuiteLv @ 1 NONAME - _ZN16CSymbianUnitTest10ConstructLERK6TDesC8 @ 2 NONAME - _ZN16CSymbianUnitTest12AddTestCaseLERK7TDesC16MS_FvvES4_S4_ @ 3 NONAME - _ZN16CSymbianUnitTest12AssertLeaveLERK6TDesC8iiiS2_ @ 4 NONAME - _ZN16CSymbianUnitTest13AssertEqualsLERK6TDesC8S2_iS2_ @ 5 NONAME - _ZN16CSymbianUnitTest13AssertEqualsLERK6TDesC8S2_iS2_S2_ @ 6 NONAME - _ZN16CSymbianUnitTest13AssertEqualsLERK7TDesC16S2_iRK6TDesC8 @ 7 NONAME - _ZN16CSymbianUnitTest13AssertEqualsLERK7TDesC16S2_iRK6TDesC8S5_ @ 8 NONAME - _ZN16CSymbianUnitTest13AssertEqualsLEiiiRK6TDesC8 @ 9 NONAME - _ZN16CSymbianUnitTest13AssertEqualsLEiiiRK6TDesC8S2_ @ 10 NONAME - _ZN16CSymbianUnitTest13TestCaseCountEv @ 11 NONAME - _ZN16CSymbianUnitTest16AssertionFailedLERK6TDesC8iS2_ @ 12 NONAME - _ZN16CSymbianUnitTest27RecordNoLeaveFromStatementLERK6TDesC8iS2_ @ 13 NONAME - _ZN16CSymbianUnitTest6SetupLEv @ 14 NONAME - _ZN16CSymbianUnitTest8ExecuteLER24MSymbianUnitTestObserverR22CSymbianUnitTestResultN25MSymbianUnitTestInterface18TFailureSimulationERK12CDesC16Arrayi @ 15 NONAME - _ZN16CSymbianUnitTest8TeardownEv @ 16 NONAME - _ZN16CSymbianUnitTestC1Ev @ 17 NONAME - _ZN16CSymbianUnitTestC2Ev @ 18 NONAME - _ZN16CSymbianUnitTestD0Ev @ 19 NONAME - _ZN16CSymbianUnitTestD1Ev @ 20 NONAME - _ZN16CSymbianUnitTestD2Ev @ 21 NONAME - _ZN21CSymbianUnitTestSuite10ConstructLERK7TDesC16 @ 22 NONAME - _ZN21CSymbianUnitTestSuite13TestCaseCountEv @ 23 NONAME - _ZN21CSymbianUnitTestSuite4AddLEP25MSymbianUnitTestInterface @ 24 NONAME - _ZN21CSymbianUnitTestSuite4NewLERK7TDesC16 @ 25 NONAME - _ZN21CSymbianUnitTestSuite5NewLCERK7TDesC16 @ 26 NONAME - _ZN21CSymbianUnitTestSuite8ExecuteLER24MSymbianUnitTestObserverR22CSymbianUnitTestResultN25MSymbianUnitTestInterface18TFailureSimulationERK12CDesC16Arrayi @ 27 NONAME - _ZN21CSymbianUnitTestSuiteC1Ev @ 28 NONAME - _ZN21CSymbianUnitTestSuiteC2Ev @ 29 NONAME - _ZN21CSymbianUnitTestSuiteD0Ev @ 30 NONAME - _ZN21CSymbianUnitTestSuiteD1Ev @ 31 NONAME - _ZN21CSymbianUnitTestSuiteD2Ev @ 32 NONAME - _ZNK16CSymbianUnitTest39IsMemoryAllocationFailureSimulationUsedEv @ 33 NONAME - _ZNK16CSymbianUnitTest4NameEv @ 34 NONAME - _ZNK21CSymbianUnitTestSuite4NameEv @ 35 NONAME - _ZThn4_N16CSymbianUnitTest13TestCaseCountEv @ 36 NONAME - _ZThn4_N16CSymbianUnitTest8ExecuteLER24MSymbianUnitTestObserverR22CSymbianUnitTestResultN25MSymbianUnitTestInterface18TFailureSimulationERK12CDesC16Arrayi @ 37 NONAME - _ZThn4_N16CSymbianUnitTestD0Ev @ 38 NONAME - _ZThn4_N16CSymbianUnitTestD1Ev @ 39 NONAME - _ZThn4_N21CSymbianUnitTestSuite13TestCaseCountEv @ 40 NONAME - _ZThn4_N21CSymbianUnitTestSuite8ExecuteLER24MSymbianUnitTestObserverR22CSymbianUnitTestResultN25MSymbianUnitTestInterface18TFailureSimulationERK12CDesC16Arrayi @ 41 NONAME - _ZThn4_N21CSymbianUnitTestSuiteD0Ev @ 42 NONAME - _ZThn4_N21CSymbianUnitTestSuiteD1Ev @ 43 NONAME - _ZThn4_NK16CSymbianUnitTest4NameEv @ 44 NONAME - _ZThn4_NK21CSymbianUnitTestSuite4NameEv @ 45 NONAME - _ZN16CSymbianUnitTest14TestCaseNamesLER12CDesC16Array @ 46 NONAME - _ZN21CSymbianUnitTestSuite14TestCaseNamesLER12CDesC16Array @ 47 NONAME - _ZThn4_N16CSymbianUnitTest14TestCaseNamesLER12CDesC16Array @ 48 NONAME - _ZThn4_N21CSymbianUnitTestSuite14TestCaseNamesLER12CDesC16Array @ 49 NONAME - diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwframework/tsrc/group/bld.inf --- a/symbianunittestfw/sutfw/sutfwcore/sutfwframework/tsrc/group/bld.inf Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -/* -* 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: Symbian Unit Testing framework -* -*/ - -PRJ_TESTMMPFILES -ut_sutfwframework.mmp diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwframework/tsrc/group/ut_sutfwframework.mmp --- a/symbianunittestfw/sutfw/sutfwcore/sutfwframework/tsrc/group/ut_sutfwframework.mmp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -/* -* 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: -* -*/ - -TARGET ut_sutfwframework.dll -TARGETTYPE dll -UID 0x20022E76 0x20022E76 -NOEXPORTLIBRARY -MACRO SYMBIAN_UNIT_TEST - -// Sources tested -SOURCEPATH ../../src -SOURCE symbianunittest.cpp -SOURCE symbianunittestsuite.cpp -SOURCE symbianunittestfailure.cpp -SOURCE symbianunittestresult.cpp - -// Test sources -SOURCEPATH ../src -SOURCE dllentry.cpp -SOURCE ut_symbianunittest.cpp -SOURCE ut_symbianunittestsuite.cpp -SOURCE ut_symbianunittestfailure.cpp -SOURCE ut_symbianunittestresult.cpp -SOURCE ut_symbianunittestother.cpp - -USERINCLUDE ../inc -USERINCLUDE ../../inc -USERINCLUDE ../../../../inc - -OS_LAYER_SYSTEMINCLUDE_SYMBIAN - -LIBRARY euser.lib -LIBRARY charconv.lib -LIBRARY efsrv.lib -LIBRARY bafl.lib - -LIBRARY flogger.lib - -VENDORID 0x101FB657 - -CAPABILITY ALL -TCB diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwframework/tsrc/inc/ut_symbianunittest.h --- a/symbianunittestfw/sutfw/sutfwcore/sutfwframework/tsrc/inc/ut_symbianunittest.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,101 +0,0 @@ -/* -* 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 UT_SYMBIANUNITTEST_H -#define UT_SYMBIANUNITTEST_H - -// INCLUDES -#include -#include "symbianunittestobserver.h" -#include - -// FORWARD DECLARATIONS -class CSymbianUnitTestResult; - -// CLASS DECLARATION -NONSHARABLE_CLASS(UT_CSymbianUnitTest) : - public CSymbianUnitTest, - public MSymbianUnitTestObserver - { - public: // Constructors and destructor - - static UT_CSymbianUnitTest* NewL(); - static UT_CSymbianUnitTest* NewLC(); - ~UT_CSymbianUnitTest(); - - public: // From MSymbianUnitTestObserver - - void TestPass(const TDesC& aTestCaseName); - void TestFailed(const TDesC& aTestCaseName, const TDesC8& aErrMsg); - - protected: // Test functions - - void SetupL(); - void Teardown(); - void UT_NameL(); - void UT_IsMemoryAllocationFailureSimulationUsedL(); - void UT_PanicInTestL(); - void UT_ErrorInSetupL(); - void UT_LeaveInTestL(); - void UT_MemoryLeakInTestL(); - void UT_EqualsAssertsL(); - void UT_FailingAssertsL(); - void UT_PassingAssertsL(); - void UT_TestCaseNamesL(); - void UT_TimeoutL(); - void UT_ResourceLeakInTestL(); - void UT_RequestLeakInTestL(); - - protected: // Failing functions to simulate failing tests - - void SimulatePanicL(); - void SimulateLeaveL(); - void SimulateMemoryLeakL(); - void SimulateFailingAssertL(); - void SimulateFailingAssertWithIntsL(); - void SimulateFailingAssertWithDesC8sL(); - void SimulateFailingAssertWithDesC16sL(); - void SimulateFailingAssertLeaveL(); - void SimulateFailingAssertLeaveWithSpecificValueL(); - void SimulateTimeoutL(); - void SimulateEqualsAssertWithStringL(); - void SimulateEqualsAssertWithStringFailL(); - void SimulateEqualsAssertWithString8L(); - void SimulateEqualsAssertWithString8FailL(); - void SimulateEqualsAssertWithIntL(); - void SimulateEqualsAssertWithIntFailL(); - void SimulateResourceLeakL(); - void SimulateRequestLeakL(); - - protected: // Dummy function to simulate setup and teardown - - void Dummy(); - - private: // Contructors - - UT_CSymbianUnitTest(); - void ConstructL(); - - private: // Data - - CSymbianUnitTestResult* iTestResult; - UT_CSymbianUnitTest* iUnitTest; - TInt iExecutedTestCount; - CDesCArray* iTestCaseNames; - }; - -#endif // UT_SYMBIANUNITTEST_H diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwframework/tsrc/inc/ut_symbianunittestfailure.h --- a/symbianunittestfw/sutfw/sutfwcore/sutfwframework/tsrc/inc/ut_symbianunittestfailure.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -/* -* 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 UT_SYMBIANUNITTESTFAILURE_H -#define UT_SYMBIANUNITTESTFAILURE_H - -// INCLUDES -#include - -// FORWARD DECLARATIONS -class CSymbianUnitTestFailure; - -// CLASS DECLARATION -NONSHARABLE_CLASS( UT_CSymbianUnitTestFailure ) : public CSymbianUnitTest - { - public: // Constructors and destructor - - static UT_CSymbianUnitTestFailure* NewL(); - static UT_CSymbianUnitTestFailure* NewLC(); - ~UT_CSymbianUnitTestFailure(); - - protected: // Test functions - - void SetupL(); - void Teardown(); - void UT_GettersL(); - - private: // Contructors - - UT_CSymbianUnitTestFailure(); - void ConstructL(); - - private: // Data - - CSymbianUnitTestFailure* iUnitTestFailure; - }; - -#endif // UT_SYMBIANUNITTESTFAILURE_H diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwframework/tsrc/inc/ut_symbianunittestother.h --- a/symbianunittestfw/sutfw/sutfwcore/sutfwframework/tsrc/inc/ut_symbianunittestother.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -/* -* 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 UT_SYMBIANUNITTESTOTHER_H -#define UT_SYMBIANUNITTESTOTHER_H - -// INCLUDES -#include - -// FORWARD DECLARATIONS -class CSymbianUnitTestFailure; - -// CLASS DECLARATION -NONSHARABLE_CLASS( UT_CSymbianUnitTestOther ) : public CSymbianUnitTest - { - public: // Constructors and destructor - - static UT_CSymbianUnitTestOther* NewL(); - static UT_CSymbianUnitTestOther* NewLC(); - ~UT_CSymbianUnitTestOther(); - - protected: // Test functions - - /*void SetupL(); - void Teardown(); */ - void UT_GettersL(); - - private: // Contructors - - UT_CSymbianUnitTestOther(); - void ConstructL(); - - private: // Data - - CSymbianUnitTestFailure* iUnitTestFailure; - }; - -#endif // UT_SYMBIANUNITTESTOTHER_H diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwframework/tsrc/inc/ut_symbianunittestresult.h --- a/symbianunittestfw/sutfw/sutfwcore/sutfwframework/tsrc/inc/ut_symbianunittestresult.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -/* -* 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 UT_SYMBIANUNITTESTRESULT_H -#define UT_SYMBIANUNITTESTRESULT_H - -// INCLUDES -#include - -// FORWARD DECLARATIONS -class CSymbianUnitTestResult; - -// CLASS DECLARATION -NONSHARABLE_CLASS( UT_CSymbianUnitTestResult ) : public CSymbianUnitTest - { - public: // Constructors and destructor - - static UT_CSymbianUnitTestResult* NewL(); - static UT_CSymbianUnitTestResult* NewLC(); - ~UT_CSymbianUnitTestResult(); - - protected: // Test functions - - void SetupL(); - void Teardown(); - void UT_TestCountL(); - void UT_StartTestL(); - void UT_AddFailureL(); - void UT_AddSetupErrorL(); - void UT_AddLeaveFromTestL(); - void UT_AddAssertFailureL(); - void UT_AddMemoryLeakInfoL(); - void UT_AddPanicInfoL(); - void UT_AddTimeOutErrorL(); - - private: // Contructors - - UT_CSymbianUnitTestResult(); - void ConstructL(); - - private: // Data - - CSymbianUnitTestResult* iUnitTestResult; - }; - -#endif // UT_SYMBIANUNITTESTRESULT_H diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwframework/tsrc/inc/ut_symbianunittestsuite.h --- a/symbianunittestfw/sutfw/sutfwcore/sutfwframework/tsrc/inc/ut_symbianunittestsuite.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* -* 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 UT_SYMBIANUNITTESTSUITE_H -#define UT_SYMBIANUNITTESTSUITE_H - -// INCLUDES -#include - -// FORWARD DECLARATIONS -class CSymbianUnitTestSuite; - -// CLASS DECLARATION -NONSHARABLE_CLASS( UT_CSymbianUnitTestSuite ) : public CSymbianUnitTest - { - public: // Constructors and destructor - - static UT_CSymbianUnitTestSuite* NewL(); - static UT_CSymbianUnitTestSuite* NewLC(); - ~UT_CSymbianUnitTestSuite(); - - protected: // Test functions - - void SetupL(); - void Teardown(); - void UT_NameL(); - void UT_AddL(); - - private: // Contructors - - UT_CSymbianUnitTestSuite(); - void ConstructL(); - - private: // Data - - CSymbianUnitTestSuite* iUnitTestSuite; - }; - -#endif // UT_SYMBIANUNITTESTSUITE_H diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwframework/tsrc/src/dllentry.cpp --- a/symbianunittestfw/sutfw/sutfwcore/sutfwframework/tsrc/src/dllentry.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* -* 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 "ut_symbianunittestfailure.h" -#include "ut_symbianunittestresult.h" -#include "ut_symbianunittest.h" -#include "ut_symbianunittestsuite.h" -#include - - -/** - * Test suite factory function. - */ -EXPORT_C MSymbianUnitTestInterface* CreateTestSuiteL() - { - CSymbianUnitTestSuite* testSuite = - CSymbianUnitTestSuite::NewLC( _L("ut_sutfwframework") ); - - testSuite->AddL( UT_CSymbianUnitTestFailure::NewLC() ); - CleanupStack::Pop(); - - testSuite->AddL( UT_CSymbianUnitTestResult::NewLC() ); - CleanupStack::Pop(); - - testSuite->AddL( UT_CSymbianUnitTest::NewLC() ); - CleanupStack::Pop(); - - testSuite->AddL( UT_CSymbianUnitTestSuite::NewLC() ); - CleanupStack::Pop(); - - CleanupStack::Pop( testSuite ); - return testSuite; - } - -// END OF FILE diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwframework/tsrc/src/ut_symbianunittest.cpp --- a/symbianunittestfw/sutfw/sutfwcore/sutfwframework/tsrc/src/ut_symbianunittest.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,711 +0,0 @@ -/* -* 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 "sutlogger.h" -#include "ut_symbianunittest.h" -#include "symbianunittestresult.h" -#include - -const TInt KTimeInterval( 1000000 ); - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -UT_CSymbianUnitTest* UT_CSymbianUnitTest::NewL() - { - UT_CSymbianUnitTest* self = UT_CSymbianUnitTest::NewLC(); - CleanupStack::Pop( self ); - return self; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -UT_CSymbianUnitTest* UT_CSymbianUnitTest::NewLC() - { - UT_CSymbianUnitTest* self = new( ELeave )UT_CSymbianUnitTest(); - CleanupStack::PushL( self ); - self->ConstructL(); - return self; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -UT_CSymbianUnitTest::UT_CSymbianUnitTest() - { - SUT_LOG_DEBUG( "Entering UT_CSymbianUnitTest::UT_CSymbianUnitTest()" ) - SUT_LOG_DEBUG( "Exiting UT_CSymbianUnitTest::UT_CSymbianUnitTest()" ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::ConstructL() - { - BASE_CONSTRUCT - - DEFINE_TEST_CLASS( UT_CSymbianUnitTest ) - - ADD_SUT_WITH_SETUP_AND_TEARDOWN( SetupL, UT_NameL, Teardown ) - ADD_SUT( UT_IsMemoryAllocationFailureSimulationUsedL ) - ADD_SUT( UT_PanicInTestL ) - ADD_SUT( UT_ErrorInSetupL ) - ADD_SUT( UT_LeaveInTestL ) - ADD_SUT( UT_MemoryLeakInTestL ) - ADD_SUT( UT_EqualsAssertsL ) - ADD_SUT( UT_FailingAssertsL ) - ADD_SUT( UT_PassingAssertsL ) - ADD_SUT( UT_TestCaseNamesL ) - ADD_SUT( UT_TimeoutL ) - ADD_SUT( UT_ResourceLeakInTestL ) - ADD_SUT( UT_RequestLeakInTestL ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -UT_CSymbianUnitTest::~UT_CSymbianUnitTest() - { - } - -// --------------------------------------------------------------------------- -// From MSymbianUnitTestObserver -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::TestPass(const TDesC& /*aTestCaseName*/) - { - iExecutedTestCount++; - } -void UT_CSymbianUnitTest::TestFailed(const TDesC& /*aTestCaseName*/, const TDesC8& /*aErrMsg*/) - { - iExecutedTestCount++; - } - - - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::SetupL() - { - iTestResult = CSymbianUnitTestResult::NewL(); - iUnitTest = UT_CSymbianUnitTest::NewL(); - // Remove the test cases added in ConstructL. - // They will be replaced by the functions simulating failures. - iUnitTest->iTestCases.ResetAndDestroy(); - iTestCaseNames = new (ELeave)CDesCArrayFlat(1); - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::Teardown() - { - delete iUnitTest; - iUnitTest = NULL; - delete iTestResult; - iTestResult = NULL; - iExecutedTestCount = 0; - delete iTestCaseNames; - iTestCaseNames = 0; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::UT_NameL() - { - SUT_ASSERT_EQUALS( _L( "UT_CSymbianUnitTest" ), iUnitTest->Name() ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::UT_IsMemoryAllocationFailureSimulationUsedL() - { - SUT_ASSERT( !iUnitTest->IsMemoryAllocationFailureSimulationUsed() ) - - iUnitTest->iAllocFailureType = RHeap::EDeterministic; - SUT_ASSERT( iUnitTest->IsMemoryAllocationFailureSimulationUsed() ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::UT_PanicInTestL() - { - SUT_ASSERT_EQUALS( 0, iTestResult->Failures().Count() ) - SUT_ASSERT_EQUALS( 0, iExecutedTestCount ) - - _LIT( KTestName, "PanicInTest" ); - iUnitTest->AddTestCaseL( - KTestName, - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulatePanicL ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) ); - - // Without memory allocation failure simulation - iUnitTest->ExecuteL( *this, *iTestResult, ENoFailureSimulation, *iTestCaseNames, 0 ); - SUT_ASSERT_EQUALS( 1, iTestResult->Failures().Count() ) - SUT_ASSERT_EQUALS( 1, iExecutedTestCount ) - - // With memory allocation failure simulation - iUnitTest->ExecuteL( *this, *iTestResult, EMemAllocFailureSimulation, *iTestCaseNames, 0 ); - SUT_ASSERT_EQUALS( 2, iTestResult->Failures().Count() ) - SUT_ASSERT_EQUALS( 2, iExecutedTestCount ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::UT_ErrorInSetupL() - { - SUT_ASSERT_EQUALS( 0, iTestResult->Failures().Count() ) - SUT_ASSERT_EQUALS( 0, iExecutedTestCount ) - - _LIT( KTestName, "ErrorInSetup" ); - iUnitTest->AddTestCaseL( - KTestName, - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateLeaveL ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) ); - - // Without memory allocation failure simulation - iUnitTest->ExecuteL( *this, *iTestResult, ENoFailureSimulation, *iTestCaseNames, 0 ); - SUT_ASSERT_EQUALS( 1, iTestResult->Failures().Count() ) - SUT_ASSERT_EQUALS( 1, iExecutedTestCount ) - - // With memory allocation failure simulation - iUnitTest->ExecuteL( *this, *iTestResult, EMemAllocFailureSimulation, *iTestCaseNames, 0 ); - SUT_ASSERT_EQUALS( 2, iTestResult->Failures().Count() ) - SUT_ASSERT_EQUALS( 2, iExecutedTestCount ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::UT_LeaveInTestL() - { - SUT_ASSERT_EQUALS( 0, iTestResult->Failures().Count() ) - SUT_ASSERT_EQUALS( 0, iExecutedTestCount ) - - _LIT( KTestName, "LeaveInTest" ); - iUnitTest->AddTestCaseL( - KTestName, - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateLeaveL ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) ); - - // Without memory allocation failure simulation - iUnitTest->ExecuteL( *this, *iTestResult, ENoFailureSimulation, *iTestCaseNames, 0); - SUT_ASSERT_EQUALS( 1, iTestResult->Failures().Count() ) - SUT_ASSERT_EQUALS( 1, iExecutedTestCount ) - - // With memory allocation failure simulation - iUnitTest->ExecuteL( *this, *iTestResult, EMemAllocFailureSimulation, *iTestCaseNames, 0 ); - SUT_ASSERT_EQUALS( 2, iTestResult->Failures().Count() ) - SUT_ASSERT_EQUALS( 2, iExecutedTestCount ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::UT_MemoryLeakInTestL() - { - SUT_ASSERT_EQUALS( 0, iTestResult->Failures().Count() ) - SUT_ASSERT_EQUALS( 0, iExecutedTestCount ) - - _LIT( KTestName, "MemoryLeakInTest" ); - iUnitTest->AddTestCaseL( - KTestName, - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateMemoryLeakL ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) ); - - // Without memory allocation failure simulation - iUnitTest->ExecuteL( *this, *iTestResult, ENoFailureSimulation, *iTestCaseNames, 0 ); - SUT_ASSERT_EQUALS( 1, iTestResult->Failures().Count() ) - SUT_ASSERT_EQUALS( 1, iExecutedTestCount ) - - // With memory allocation failure simulation - iUnitTest->ExecuteL( *this, *iTestResult, EMemAllocFailureSimulation, *iTestCaseNames, 0 ); - SUT_ASSERT_EQUALS( 2, iTestResult->Failures().Count() ) - SUT_ASSERT_EQUALS( 2, iExecutedTestCount ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::UT_EqualsAssertsL() - { - SUT_ASSERT_EQUALS( 0, iTestResult->Failures().Count() ) - SUT_ASSERT_EQUALS( 0, iExecutedTestCount ) - - _LIT( KTestName, "TestAssertEquals" ); - - iUnitTest->AddTestCaseL( - KTestName, - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateEqualsAssertWithStringL ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) ); - - - iUnitTest->AddTestCaseL( - KTestName, - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateEqualsAssertWithStringFailL ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) ); - - - iUnitTest->AddTestCaseL( - KTestName, - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateEqualsAssertWithString8L ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) ); - - iUnitTest->AddTestCaseL( - KTestName, - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateEqualsAssertWithString8FailL ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) ); - - iUnitTest->AddTestCaseL( - KTestName, - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateEqualsAssertWithIntL ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) ); - - iUnitTest->AddTestCaseL( - KTestName, - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateEqualsAssertWithIntFailL ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) ); - - // Without memory allocation failure simulation - iUnitTest->ExecuteL( *this, *iTestResult, ENoFailureSimulation, *iTestCaseNames, 0 ); - SUT_ASSERT_EQUALS( 3, iTestResult->Failures().Count() ) - SUT_ASSERT_EQUALS( 6, iExecutedTestCount ) - - // With memory allocation failure simulation - iUnitTest->ExecuteL( *this, *iTestResult, EMemAllocFailureSimulation, *iTestCaseNames, 0 ); - SUT_ASSERT_EQUALS( 6, iTestResult->Failures().Count() ) - SUT_ASSERT_EQUALS( 12, iExecutedTestCount ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::UT_FailingAssertsL() - { - SUT_ASSERT_EQUALS( 0, iTestResult->Failures().Count() ) - SUT_ASSERT_EQUALS( 0, iExecutedTestCount ) - - _LIT( KTestName, "TestAssertFailures" ); - iUnitTest->AddTestCaseL( - KTestName, - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateFailingAssertL ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) ); - iUnitTest->AddTestCaseL( - KTestName, - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateFailingAssertWithIntsL ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) ); - iUnitTest->AddTestCaseL( - KTestName, - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateFailingAssertWithDesC8sL ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) ); - iUnitTest->AddTestCaseL( - KTestName, - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateFailingAssertWithDesC16sL ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) ); - iUnitTest->AddTestCaseL( - KTestName, - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateFailingAssertLeaveL ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) ); - iUnitTest->AddTestCaseL( - KTestName, - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateFailingAssertLeaveWithSpecificValueL ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) ); - - // Without memory allocation failure simulation - iUnitTest->ExecuteL( *this, *iTestResult, ENoFailureSimulation, *iTestCaseNames, 0 ); - SUT_ASSERT_EQUALS( 6, iTestResult->Failures().Count() ) - SUT_ASSERT_EQUALS( 6, iExecutedTestCount ) - - // With memory allocation failure simulation - iUnitTest->ExecuteL( *this, *iTestResult, EMemAllocFailureSimulation, *iTestCaseNames, 0 ); - SUT_ASSERT_EQUALS( 12, iTestResult->Failures().Count() ) - SUT_ASSERT_EQUALS( 12, iExecutedTestCount ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::UT_PassingAssertsL() - { - SUT_ASSERT( ETrue ) - SUT_ASSERT_DESC( ETrue, "test assert with desc") - SUT_ASSERT( ETrue == ETrue ) - SUT_ASSERT( 1 == 1 ) - HBufC* ptr( NULL ); - SUT_ASSERT( !ptr ) - ptr = KNullDesC().AllocLC(); - SUT_ASSERT( ptr ) - CleanupStack::PopAndDestroy( ptr ); - - SUT_ASSERT_EQUALS( 1, 1 ) - SUT_ASSERT_EQUALS_DESC( 1, 1, "test assert equals with desc" ) - SUT_ASSERT_EQUALS( KNullDesC8, KNullDesC8 ) - SUT_ASSERT_EQUALS( KNullDesC, KNullDesC ) - - SUT_ASSERT_LEAVE( User::Leave( KErrGeneral ) ) - - SUT_ASSERT_LEAVE_WITH( User::Leave( KErrGeneral ), KErrGeneral ) - } - - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::UT_TestCaseNamesL() - { - SUT_ASSERT_EQUALS( 0, iTestResult->Failures().Count() ) - SUT_ASSERT_EQUALS( 0, iExecutedTestCount ) - - _LIT( KTest1Name, "TestCase1" ); - iUnitTest->AddTestCaseL( - KTest1Name, - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateLeaveL ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) ); - - _LIT( KTest2Name, "TestCase2" ); - iUnitTest->AddTestCaseL( - KTest2Name, - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateLeaveL ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) ); - - _LIT( KTest3Name, "TestCase3" ); - iUnitTest->AddTestCaseL( - KTest3Name, - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateLeaveL ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) ); - - _LIT( LTest1FullName, "UT_CSymbianUnitTest::TestCase1"); - iTestCaseNames->AppendL(LTest1FullName); - - // Without memory allocation failure simulation - iUnitTest->ExecuteL( *this, *iTestResult, ENoFailureSimulation, *iTestCaseNames, 0 ); - SUT_ASSERT_EQUALS( 1, iTestResult->Failures().Count() ) - SUT_ASSERT_EQUALS( 1, iExecutedTestCount ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::UT_TimeoutL() - { - _LIT( KTestName, "TimeoutTestCase" ); - iUnitTest->AddTestCaseL( - KTestName, - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateTimeoutL ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) ); - //run test case without timeout control - iUnitTest->ExecuteL( *this, *iTestResult, ENoFailureSimulation, *iTestCaseNames, 0 ); - SUT_ASSERT_EQUALS( 0, iTestResult->Failures().Count() ) - SUT_ASSERT_EQUALS( 1, iExecutedTestCount ) - //run test case with 3 seconds time out - iUnitTest->ExecuteL( *this, *iTestResult, ENoFailureSimulation, *iTestCaseNames, 3 ); - SUT_ASSERT_EQUALS( 1, iTestResult->Failures().Count() ) - SUT_ASSERT_EQUALS( 2, iExecutedTestCount ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::SimulateTimeoutL() - { - User::After(5* 1000000); - /*RTimer timer; - timer.CreateLocal(); - TRequestStatus status; - timer.After( status, 5* 1000000 ); - User::WaitForRequest( status ); - timer.Cancel(); - timer.Close();*/ - } - - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::SimulatePanicL() - { - _LIT( KPanicString, "kkkkkkkkkkkk"); - TBufC<3> buf( KPanicString ); - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::SimulateLeaveL() - { - User::Leave( KErrGeneral ); - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::SimulateMemoryLeakL() - { - HBufC::NewL( 1 ); - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::SimulateFailingAssertL() - { - SUT_ASSERT( EFalse ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::SimulateFailingAssertWithIntsL() - { - const TInt KFirstValue( -1 ); - const TInt KSecondValue( -2 ); - SUT_ASSERT_EQUALS( KFirstValue, KSecondValue ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::SimulateFailingAssertWithDesC8sL() - { - _LIT8( KSomeText, "some text" ); - SUT_ASSERT_EQUALS( KNullDesC8, KSomeText ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::SimulateFailingAssertWithDesC16sL() - { - _LIT( KSomeText, "some text" ); - SUT_ASSERT_EQUALS( KNullDesC, KSomeText ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::SimulateFailingAssertLeaveL() - { - SUT_ASSERT_LEAVE( Dummy() ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::SimulateFailingAssertLeaveWithSpecificValueL() - { - SUT_ASSERT_LEAVE_WITH( User::Leave( KErrNotFound ), KErrGeneral ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::Dummy() - { - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::SimulateEqualsAssertWithStringL() - { - _LIT( KSomeText, "some text" ); - AssertEqualsL( KSomeText, KSomeText, __LINE__, _L8( __FILE__ ) ); - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::SimulateEqualsAssertWithStringFailL() - { - _LIT( KSomeText, "some text" ); - AssertEqualsL( KNullDesC, KSomeText, __LINE__, _L8( __FILE__ ) ); - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::SimulateEqualsAssertWithString8L() - { - _LIT8( KSomeText, "some text" ); - AssertEqualsL( KSomeText, KSomeText, __LINE__, _L8( __FILE__ ) ); - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::SimulateEqualsAssertWithString8FailL() - { - _LIT8( KSomeText, "some text" ); - AssertEqualsL( KNullDesC8, KSomeText, __LINE__, _L8( __FILE__ ) ); - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::SimulateEqualsAssertWithIntL() - { - const TInt KAssertValue(123); - AssertEqualsL( 123, KAssertValue, __LINE__, _L8( __FILE__ ) ); - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::SimulateEqualsAssertWithIntFailL() - { - const TInt KAssertValue(123); - AssertEqualsL( -1, KAssertValue, __LINE__, _L8( __FILE__ ) ); - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::UT_ResourceLeakInTestL() - { - SUT_ASSERT_EQUALS( 0, iTestResult->Failures().Count() ) - SUT_ASSERT_EQUALS( 0, iExecutedTestCount ) - - _LIT( KTestName, "ResourceLeakInTest" ); - iUnitTest->AddTestCaseL( - KTestName, - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateResourceLeakL ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) ); - - // Without memory allocation failure simulation - iUnitTest->ExecuteL( *this, *iTestResult, ENoFailureSimulation, *iTestCaseNames, 0 ); - SUT_ASSERT_EQUALS( 1, iTestResult->Failures().Count() ) - SUT_ASSERT_EQUALS( 1, iExecutedTestCount ) - - // With memory allocation failure simulation - iUnitTest->ExecuteL( *this, *iTestResult, EMemAllocFailureSimulation, *iTestCaseNames, 0 ); - SUT_ASSERT_EQUALS( 2, iTestResult->Failures().Count() ) - SUT_ASSERT_EQUALS( 2, iExecutedTestCount ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::SimulateResourceLeakL() - { - RTimer timer; - timer.CreateLocal(); - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::UT_RequestLeakInTestL() - { - SUT_ASSERT_EQUALS( 0, iTestResult->Failures().Count() ) - SUT_ASSERT_EQUALS( 0, iExecutedTestCount ) - - _LIT( KTestName, "RequestLeakInTest" ); - iUnitTest->AddTestCaseL( - KTestName, - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateRequestLeakL ), - CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) ); - - // Without memory allocation failure simulation - iUnitTest->ExecuteL( *this, *iTestResult, ENoFailureSimulation, *iTestCaseNames, 0 ); - SUT_ASSERT_EQUALS( 1, iTestResult->Failures().Count() ) - SUT_ASSERT_EQUALS( 1, iExecutedTestCount ) - - // With memory allocation failure simulation - iUnitTest->ExecuteL( *this, *iTestResult, EMemAllocFailureSimulation, *iTestCaseNames, 0 ); - SUT_ASSERT_EQUALS( 2, iTestResult->Failures().Count() ) - SUT_ASSERT_EQUALS( 2, iExecutedTestCount ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTest::SimulateRequestLeakL() - { - RTimer timer; - timer.CreateLocal(); - TRequestStatus status; - timer.After( status, KTimeInterval ); - timer.Close(); - } - diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwframework/tsrc/src/ut_symbianunittestfailure.cpp --- a/symbianunittestfw/sutfw/sutfwcore/sutfwframework/tsrc/src/ut_symbianunittestfailure.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,119 +0,0 @@ -/* -* 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 "ut_symbianunittestfailure.h" -#include "symbianunittestfailure.h" -#include - -_LIT8( KFailedTestName8, "FailedTest" ); -_LIT( KFailedTestName, "FailedTest" ); -_LIT8( KFailureMessage, "FailureMessage" ); -const TInt KFailureLineNumber = 123; -_LIT8( KFailedTestFileName, "UT_Failure.cpp" ); - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -UT_CSymbianUnitTestFailure* UT_CSymbianUnitTestFailure::NewL() - { - UT_CSymbianUnitTestFailure* self = UT_CSymbianUnitTestFailure::NewLC(); - CleanupStack::Pop( self ); - return self; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -UT_CSymbianUnitTestFailure* UT_CSymbianUnitTestFailure::NewLC() - { - UT_CSymbianUnitTestFailure* self = - new( ELeave )UT_CSymbianUnitTestFailure(); - CleanupStack::PushL( self ); - self->ConstructL(); - return self; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -UT_CSymbianUnitTestFailure::UT_CSymbianUnitTestFailure() - { - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTestFailure::ConstructL() - { - BASE_CONSTRUCT - - DEFINE_TEST_CLASS( UT_CSymbianUnitTestFailure ) - - ADD_SUT( UT_GettersL ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -UT_CSymbianUnitTestFailure::~UT_CSymbianUnitTestFailure() - { - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTestFailure::SetupL() - { - iUnitTestFailure = - CSymbianUnitTestFailure::NewL( - KFailedTestName, - KFailureMessage, - KFailureLineNumber, - KFailedTestFileName ); - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTestFailure::Teardown() - { - delete iUnitTestFailure; - iUnitTestFailure = NULL; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTestFailure::UT_GettersL() - { - SUT_ASSERT_EQUALS( - KFailedTestName8, iUnitTestFailure->TestName() ) - SUT_ASSERT_EQUALS( - KFailureMessage, iUnitTestFailure->FailureMessage() ) - SUT_ASSERT_EQUALS( - KFailureLineNumber, iUnitTestFailure->LineNumber() ) - SUT_ASSERT_EQUALS( - KFailedTestFileName, iUnitTestFailure->FileName() ) - } diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwframework/tsrc/src/ut_symbianunittestother.cpp --- a/symbianunittestfw/sutfw/sutfwcore/sutfwframework/tsrc/src/ut_symbianunittestother.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -/* -* 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 "ut_symbianunittestother.h" -#include "symbianunittestfailure.h" -#include - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -UT_CSymbianUnitTestOther* UT_CSymbianUnitTestOther::NewL() - { - UT_CSymbianUnitTestOther* self = UT_CSymbianUnitTestOther::NewLC(); - CleanupStack::Pop( self ); - return self; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -UT_CSymbianUnitTestOther* UT_CSymbianUnitTestOther::NewLC() - { - UT_CSymbianUnitTestOther* self = - new( ELeave )UT_CSymbianUnitTestOther(); - CleanupStack::PushL( self ); - self->ConstructL(); - return self; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -UT_CSymbianUnitTestOther::UT_CSymbianUnitTestOther() - { - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTestOther::ConstructL() - { - BASE_CONSTRUCT - - DEFINE_TEST_CLASS( UT_CSymbianUnitTestOther ) - - ADD_SUT( UT_GettersL ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -UT_CSymbianUnitTestOther::~UT_CSymbianUnitTestOther() - { - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTestOther::UT_GettersL() - { - } diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwframework/tsrc/src/ut_symbianunittestresult.cpp --- a/symbianunittestfw/sutfw/sutfwcore/sutfwframework/tsrc/src/ut_symbianunittestresult.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,258 +0,0 @@ -/* -* 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 "ut_symbianunittestresult.h" -#include "symbianunittestresult.h" -#include "symbianunittestfailure.h" -#include - - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -UT_CSymbianUnitTestResult* UT_CSymbianUnitTestResult::NewL() - { - UT_CSymbianUnitTestResult* self = UT_CSymbianUnitTestResult::NewLC(); - CleanupStack::Pop( self ); - return self; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -UT_CSymbianUnitTestResult* UT_CSymbianUnitTestResult::NewLC() - { - UT_CSymbianUnitTestResult* self = - new( ELeave )UT_CSymbianUnitTestResult(); - CleanupStack::PushL( self ); - self->ConstructL(); - return self; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -UT_CSymbianUnitTestResult::UT_CSymbianUnitTestResult() - { - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTestResult::ConstructL() - { - BASE_CONSTRUCT - - DEFINE_TEST_CLASS( UT_CSymbianUnitTestResult ) - - ADD_SUT( UT_TestCountL ) - ADD_SUT( UT_StartTestL ) - ADD_SUT( UT_AddFailureL ) - ADD_SUT( UT_AddSetupErrorL ) - ADD_SUT( UT_AddLeaveFromTestL ) - ADD_SUT( UT_AddAssertFailureL ) - ADD_SUT( UT_AddMemoryLeakInfoL ) - ADD_SUT( UT_AddPanicInfoL ) - ADD_SUT( UT_AddTimeOutErrorL ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -UT_CSymbianUnitTestResult::~UT_CSymbianUnitTestResult() - { - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTestResult::SetupL() - { - iUnitTestResult = CSymbianUnitTestResult::NewL(); - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTestResult::Teardown() - { - delete iUnitTestResult; - iUnitTestResult = NULL; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTestResult::UT_TestCountL() - { - // No tests - SUT_ASSERT_EQUALS( 0, iUnitTestResult->TestCount() ) - - // Increment the test count - iUnitTestResult->iTestCount++; - SUT_ASSERT_EQUALS( 1, iUnitTestResult->TestCount() ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTestResult::UT_StartTestL() - { - SUT_ASSERT_EQUALS( KNullDesC, *iUnitTestResult->iCurrentTestName ) - SUT_ASSERT_EQUALS( 0, iUnitTestResult->TestCount() ) - - _LIT( KTestName, "FailedTest" ); - iUnitTestResult->StartTestL( KTestName ); - SUT_ASSERT_EQUALS( KTestName, *iUnitTestResult->iCurrentTestName ) - SUT_ASSERT_EQUALS( 1, iUnitTestResult->TestCount() ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTestResult::UT_AddFailureL() - { - SUT_ASSERT_EQUALS( 0, iUnitTestResult->Failures().Count() ) - - _LIT8( KFailureText, "FailureText" ); - - // Memory allocation failure rate 0 - iUnitTestResult->AddFailureL( KFailureText, 0 ); - SUT_ASSERT_EQUALS( 1, iUnitTestResult->Failures().Count() ) - SUT_ASSERT_EQUALS( - KFailureText, iUnitTestResult->Failures()[ 0 ]->FailureMessage() ) - SUT_ASSERT_EQUALS( - KErrNotFound, iUnitTestResult->Failures()[ 0 ]->LineNumber() ) - SUT_ASSERT_EQUALS( - KNullDesC8, iUnitTestResult->Failures()[ 0 ]->FileName() ) - - // Memory allocation failure rate > 0 - iUnitTestResult->AddFailureL( KFailureText, 1 ); - SUT_ASSERT_EQUALS( 2, iUnitTestResult->Failures().Count() ) - SUT_ASSERT( - iUnitTestResult->Failures()[ 1 ]->FailureMessage() != KFailureText ) - SUT_ASSERT_EQUALS( - KErrNotFound, iUnitTestResult->Failures()[ 1 ]->LineNumber() ) - SUT_ASSERT_EQUALS( - KNullDesC8, iUnitTestResult->Failures()[ 1 ]->FileName() ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTestResult::UT_AddSetupErrorL() - { - SUT_ASSERT_EQUALS( 0, iUnitTestResult->Failures().Count() ) - - const TInt KErrorCode = KErrGeneral; - iUnitTestResult->AddSetupErrorL( KErrorCode ); - SUT_ASSERT_EQUALS( 1, iUnitTestResult->Failures().Count() ) - SUT_ASSERT( - iUnitTestResult->Failures()[ 0 ]->FailureMessage().Length () > 0 ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTestResult::UT_AddLeaveFromTestL() - { - SUT_ASSERT_EQUALS( 0, iUnitTestResult->Failures().Count() ) - - iUnitTestResult->AddLeaveFromTestL( KErrGeneral, 0 ); - SUT_ASSERT_EQUALS( 1, iUnitTestResult->Failures().Count() ) - SUT_ASSERT( - iUnitTestResult->Failures()[ 0 ]->FailureMessage().Length () > 0 ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTestResult::UT_AddAssertFailureL() - { - SUT_ASSERT_EQUALS( 0, iUnitTestResult->Failures().Count() ) - - _LIT8( KFailureMessage, "assert failure" ); - const TInt KLineNumber = 123; - _LIT8( KFileName, "myfilename.cpp" ); - iUnitTestResult->AddAssertFailureL( - KFailureMessage, KLineNumber, KFileName ); - SUT_ASSERT_EQUALS( 1, iUnitTestResult->Failures().Count() ) - SUT_ASSERT_EQUALS( - KFailureMessage, iUnitTestResult->Failures()[ 0 ]->FailureMessage() ) - SUT_ASSERT_EQUALS( - KLineNumber, iUnitTestResult->Failures()[ 0 ]->LineNumber() ) - SUT_ASSERT_EQUALS( - KFileName, iUnitTestResult->Failures()[ 0 ]->FileName() ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTestResult::UT_AddMemoryLeakInfoL() - { - SUT_ASSERT_EQUALS( 0, iUnitTestResult->Failures().Count() ) - - iUnitTestResult->AddMemoryLeakInfoL( 1, 0 ); - SUT_ASSERT_EQUALS( 1, iUnitTestResult->Failures().Count() ) - SUT_ASSERT( - iUnitTestResult->Failures()[ 0 ]->FailureMessage().Length () > 0 ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTestResult::UT_AddPanicInfoL() - { - SUT_ASSERT_EQUALS( 0, iUnitTestResult->Failures().Count() ) - - TExitCategoryName dummy; - iUnitTestResult->AddPanicInfoL( dummy, KErrGeneral, 0 ); - SUT_ASSERT_EQUALS( 1, iUnitTestResult->Failures().Count() ) - SUT_ASSERT( - iUnitTestResult->Failures()[ 0 ]->FailureMessage().Length () > 0 ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTestResult::UT_AddTimeOutErrorL() - { - SUT_ASSERT_EQUALS( 0, iUnitTestResult->Failures().Count() ) - - const TInt KTimeOut = 10; - iUnitTestResult->AddTimeOutErrorL( KTimeOut ); - SUT_ASSERT_EQUALS( 1, iUnitTestResult->Failures().Count() ) - SUT_ASSERT( - iUnitTestResult->Failures()[ 0 ]->FailureMessage().Length () > 0 ) - } - diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwframework/tsrc/src/ut_symbianunittestsuite.cpp --- a/symbianunittestfw/sutfw/sutfwcore/sutfwframework/tsrc/src/ut_symbianunittestsuite.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,119 +0,0 @@ -/* -* 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 "ut_symbianunittestsuite.h" -#include -#include - -_LIT( KTestSuiteName, "TestSuite" ); - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -UT_CSymbianUnitTestSuite* UT_CSymbianUnitTestSuite::NewL() - { - UT_CSymbianUnitTestSuite* self = UT_CSymbianUnitTestSuite::NewLC(); - CleanupStack::Pop( self ); - return self; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -UT_CSymbianUnitTestSuite* UT_CSymbianUnitTestSuite::NewLC() - { - UT_CSymbianUnitTestSuite* self = - new( ELeave )UT_CSymbianUnitTestSuite(); - CleanupStack::PushL( self ); - self->ConstructL(); - return self; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -UT_CSymbianUnitTestSuite::UT_CSymbianUnitTestSuite() - { - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTestSuite::ConstructL() - { - BASE_CONSTRUCT - - DEFINE_TEST_CLASS( UT_CSymbianUnitTestSuite ) - - ADD_SUT( UT_NameL ) - ADD_SUT( UT_AddL ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -UT_CSymbianUnitTestSuite::~UT_CSymbianUnitTestSuite() - { - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTestSuite::SetupL() - { - iUnitTestSuite = CSymbianUnitTestSuite::NewL( KTestSuiteName ); - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTestSuite::Teardown() - { - delete iUnitTestSuite; - iUnitTestSuite = NULL; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTestSuite::UT_NameL() - { - SUT_ASSERT_EQUALS( KTestSuiteName, iUnitTestSuite->Name() ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTestSuite::UT_AddL() - { - SUT_ASSERT_EQUALS( 0, iUnitTestSuite->TestCaseCount() ) - - UT_CSymbianUnitTestSuite* thisTest = UT_CSymbianUnitTestSuite::NewLC(); - iUnitTestSuite->AddL( thisTest ); - CleanupStack::Pop( thisTest ); - SUT_ASSERT_EQUALS( - thisTest->TestCaseCount(), iUnitTestSuite->TestCaseCount() ) - } diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwkernel/bwins/symbianunittestlddu.def --- a/symbianunittestfw/sutfw/sutfwcore/sutfwkernel/bwins/symbianunittestlddu.def Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -EXPORTS - ?Setup@DSymbianUnitTest@@UAEHXZ @ 1 NONAME ; int DSymbianUnitTest::Setup(void) - ?AssertEquals@DSymbianUnitTest@@IAEHHHHABVTDesC8@@@Z @ 2 NONAME ; int DSymbianUnitTest::AssertEquals(int, int, int, class TDesC8 const &) - ?Request@DSymbianUnitTest@@EAEHHPAX0@Z @ 3 NONAME ; int DSymbianUnitTest::Request(int, void *, void *) - ?AssertEquals@DSymbianUnitTest@@IAEHABVTDesC8@@0H0@Z @ 4 NONAME ; int DSymbianUnitTest::AssertEquals(class TDesC8 const &, class TDesC8 const &, int, class TDesC8 const &) - ??1DSymbianUnitTestFactory@@UAE@XZ @ 5 NONAME ; DSymbianUnitTestFactory::~DSymbianUnitTestFactory(void) - ?Teardown@DSymbianUnitTest@@UAEHXZ @ 6 NONAME ; int DSymbianUnitTest::Teardown(void) - ?Install@DSymbianUnitTestFactory@@UAEHXZ @ 7 NONAME ; int DSymbianUnitTestFactory::Install(void) - ?AssertionFailed@DSymbianUnitTest@@IAEHABVTDesC8@@H0@Z @ 8 NONAME ; int DSymbianUnitTest::AssertionFailed(class TDesC8 const &, int, class TDesC8 const &) - ?AddTestCase@DSymbianUnitTest@@IAEXABVTDesC8@@P81@AEHXZ11@Z @ 9 NONAME ; void DSymbianUnitTest::AddTestCase(class TDesC8 const &, int (*)(void), int (*)(void), int (*)(void)) - ??0DSymbianUnitTest@@QAE@XZ @ 10 NONAME ; DSymbianUnitTest::DSymbianUnitTest(void) - ??1DSymbianUnitTest@@UAE@XZ @ 11 NONAME ; DSymbianUnitTest::~DSymbianUnitTest(void) - ?GetCaps@DSymbianUnitTestFactory@@UBEXAAVTDes8@@@Z @ 12 NONAME ; void DSymbianUnitTestFactory::GetCaps(class TDes8 &) const - ??0DSymbianUnitTestFactory@@QAE@ABVTDesC8@@@Z @ 13 NONAME ; DSymbianUnitTestFactory::DSymbianUnitTestFactory(class TDesC8 const &) - diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwkernel/eabi/symbianunittestlddu.def --- a/symbianunittestfw/sutfw/sutfwcore/sutfwkernel/eabi/symbianunittestlddu.def Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -EXPORTS - _ZN16DSymbianUnitTest11AddTestCaseERK6TDesC8MS_FivES4_S4_ @ 1 NONAME - _ZN16DSymbianUnitTest12AssertEqualsERK6TDesC8S2_iS2_ @ 2 NONAME - _ZN16DSymbianUnitTest12AssertEqualsEiiiRK6TDesC8 @ 3 NONAME - _ZN16DSymbianUnitTest15AssertionFailedERK6TDesC8iS2_ @ 4 NONAME - _ZN16DSymbianUnitTest5SetupEv @ 5 NONAME - _ZN16DSymbianUnitTest7RequestEiPvS0_ @ 6 NONAME - _ZN16DSymbianUnitTest8TeardownEv @ 7 NONAME - _ZN16DSymbianUnitTestC2Ev @ 8 NONAME - _ZN16DSymbianUnitTestD0Ev @ 9 NONAME - _ZN16DSymbianUnitTestD1Ev @ 10 NONAME - _ZN16DSymbianUnitTestD2Ev @ 11 NONAME - _ZN23DSymbianUnitTestFactory7InstallEv @ 12 NONAME - _ZN23DSymbianUnitTestFactoryC2ERK6TDesC8 @ 13 NONAME - _ZN23DSymbianUnitTestFactoryD0Ev @ 14 NONAME - _ZN23DSymbianUnitTestFactoryD1Ev @ 15 NONAME - _ZN23DSymbianUnitTestFactoryD2Ev @ 16 NONAME - _ZNK23DSymbianUnitTestFactory7GetCapsER5TDes8 @ 17 NONAME - _ZTI16DSymbianUnitTest @ 18 NONAME - _ZTI23DSymbianUnitTestFactory @ 19 NONAME - _ZTIN16DSymbianUnitTest20DSymbianUnitTestCaseE @ 20 NONAME - _ZTV16DSymbianUnitTest @ 21 NONAME - _ZTV23DSymbianUnitTestFactory @ 22 NONAME - _ZTVN16DSymbianUnitTest20DSymbianUnitTestCaseE @ 23 NONAME - diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwkernel/group/bld.inf --- a/symbianunittestfw/sutfw/sutfwcore/sutfwkernel/group/bld.inf Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -/* -* 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: Symbian Unit Testing framework -* -*/ - -PRJ_MMPFILES -symbianunittestldd.mmp -//symbianunittestlddctl.mmp diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwkernel/group/symbianunittestldd.mmp --- a/symbianunittestfw/sutfw/sutfwcore/sutfwkernel/group/symbianunittestldd.mmp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of the License "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: -// e32test/group/d_newldd.mmp -// -// - -#include "kernel/kern_ext.mmh" - -TARGET symbianunittestldd.dll -TARGETTYPE KDLL -UID 0x1000008d 0x20022E74 - -OS_LAYER_SYSTEMINCLUDE_SYMBIAN - -USERINCLUDE ../inc - -SOURCEPATH ../src -SOURCE symbianunittestldd.cpp - -start wins - -win32_library kernel32.lib -#if defined(VC32) -win32_library msvcrt.lib -#endif - - -end - - - -EPOCALLOWDLLDATA - -VENDORID 0x70000001 - -DEFFILE symbianunittestldd.def - -capability all -SMPSAFE diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwkernel/inc/symbianunittestlddctl.h --- a/symbianunittestfw/sutfw/sutfwcore/sutfwkernel/inc/symbianunittestlddctl.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of the License "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 __SYMBIANUNITTESTLDDCTL_H -#define __SYMBIANUNITTESTLDDCTL_H - -#include -#include "symbianunittestlddif.h" -#include "symbianunittestresult.h" -#include "symbianunittestobserver.h" - - -_LIT(KKInstallLddName,"symbianunittest"); - - -class CSymbianUnitTestLddCtl : public CBase -{ - public: // Constructors and destructor - - static CSymbianUnitTestLddCtl* NewLC(const TDesC& aDriverName); - static CSymbianUnitTestLddCtl* NewL(const TDesC& aDriverName); - ~CSymbianUnitTestLddCtl(); - - public: // New functions - TInt LoadDriver(); - TInt ExecuteLddTests( - MSymbianUnitTestObserver& aObserver, - CSymbianUnitTestResult& aResult); - TInt FreeDriver(); - TInt GetTestCaseNames(CDesCArray& aTestCaseNames); - - private: // Constructors - CSymbianUnitTestLddCtl(); - void ConstructL(const TDesC& aDriverName); - - private: // Data - - HBufC* iDriverName; - RSymbianUnitTest iLddconn; -}; - -#endif __SYMBIANUNITTESTLDDCTL_H diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwkernel/src/symbianunittestldd.cpp --- a/symbianunittestfw/sutfw/sutfwcore/sutfwkernel/src/symbianunittestldd.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,423 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of the License "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 -#include "symbianunittestldd.h" -#include "symbianunittestlddif.h" - - -const char* KIntsNotEqualFormat = "Asserted: expected=%d, actual=%d"; -const char* KDesCsNotEqualFormat = "Asserted: expected='%S', actual='%S'"; -const TInt KMaxSizeOfTwoIntsAsText = 80; -const TInt KTestCaseNameLength = 256; - -/* -class DCrashHandler : public DKernelEventHandler - { -public: - // construction & destruction - inline DCrashHandler(); - TInt Create(DLogicalDevice* aDevice); - ~DCrashHandler(); - -private: - static TUint EventHandler(TKernelEvent aEvent, TAny* a1, TAny* a2, TAny* aThis); - void HandleCrash(TAny* aContext); - -private: - DLogicalDevice* iDevice; // open reference to LDD for avoiding lifetime issues - - }; - -inline DCrashHandler::DCrashHandler() - : DKernelEventHandler(EventHandler, this) - { - } - -// -// second-phase c'tor. Called in thread critical section. -// - -TInt DCrashHandler::Create(DLogicalDevice* aDevice) - { -// TInt r; -// r = aDevice->Open(); -// if (r != KErrNone) -// return r; - iDevice = aDevice; - return Add(); - } - -// -// Called when reference count reaches zero. At that point no threads -// are in the handler anymore and the handler has been removed from -// the queue. -// - -DCrashHandler::~DCrashHandler() - { -// if (iDevice) -// iDevice->Close(NULL); - } - -TUint DCrashHandler::EventHandler(TKernelEvent aEvent, TAny* a1, TAny* a2, TAny* aThis) - { - DThread* pC = &Kern::CurrentThread(); - switch (aEvent) - { - case EEventHwExc: - ((DCrashHandler*)aThis)->HandleCrash(a1); - return EExcHandled; - case EEventKillThread: - if (pC->iExitType == EExitPanic) - ((DCrashHandler*)aThis)->HandleCrash(NULL); - return EExcHandled; - default: - // ignore other events - break; - } - return ERunNext; - } - -void DCrashHandler::HandleCrash(TAny* aContext) - { - Kern::Printf("CrashHandler handle crash enter"); - Kern::Printf("CrashHandler handle crash exit"); - } - -*/ - -EXPORT_C DSymbianUnitTestFactory::DSymbianUnitTestFactory(const TDesC& aName) - { - iDriverName.Copy(aName); - } - -EXPORT_C TInt DSymbianUnitTestFactory::Install() - { - iVersion = TVersion(0,0,1); - return SetName(&iDriverName); - } - -EXPORT_C void DSymbianUnitTestFactory::GetCaps(TDes8& /*aDes*/) const - { - //not supported - } - -EXPORT_C DSymbianUnitTestFactory::~DSymbianUnitTestFactory() - { - } - -EXPORT_C DSymbianUnitTest::DSymbianUnitTest() - { - //get the handler for client thread - iClient = &Kern::CurrentThread(); - ((DObject*)iClient)->Open(); - -// iCrashHandler = new DCrashHandler(); -// iCrashHandler->Create(iDevice); - } - -EXPORT_C TInt DSymbianUnitTest::Setup() - { - //do nothing by default - return KErrNone; - } - -EXPORT_C TInt DSymbianUnitTest::Teardown() - { - //do nothing by default - return KErrNone; - } -EXPORT_C DSymbianUnitTest::~DSymbianUnitTest() - { - //delete iName; - iTestCases.ResetAndDestroy(); - - //close the client thread handler - Kern::SafeClose((DObject*&)iClient,NULL); - -// if (iCrashHandler) -// { -// iCrashHandler->Close(); -// delete iCrashHandler; -// } - } - -/* -EXPORT_C void DSymbianUnitTest::Construct() - { - //do nothing by default - } -*/ - -EXPORT_C void DSymbianUnitTest::AddTestCase( - const TDesC& aName, - FunctionPtr aSetupFunction, - FunctionPtr aTestFunction, - FunctionPtr aTeardownFunction ) - { - DSymbianUnitTestCase* testCase = new DSymbianUnitTestCase( - aName, aSetupFunction, aTestFunction, aTeardownFunction ); - iTestCases.Append( testCase ); - } - - -EXPORT_C TInt DSymbianUnitTest::Request(TInt aReqNo, TAny* a1, TAny* a2) - { - switch(aReqNo) - { - //new - case RSymbianUnitTest::EEXECUTETESTCASE: - { - return ExecuteTestCase(a1, (TDes8*)a2); - } - case RSymbianUnitTest::ETESTCOUNT: - return TestCount((TInt*) a1); - case RSymbianUnitTest::ETESTCASENAME: - return GetTestCaseName(a1, (TDes*)a2); - default: - break; - } - return KErrGeneral; - } - - -TInt DSymbianUnitTest::TestCount(TInt* aDest) - { - __KTRACE_OPT(KHARDWARE, - Kern::Printf("DSymbianUnitTest::TestCount() enter")); - TInt count = iTestCases.Count(); - __KTRACE_OPT(KHARDWARE, - Kern::Printf(" kernel space, test case count [%d]", count)); - TInt ret = Kern::ThreadRawWrite(iClient, aDest, &count, sizeof(TInt), NULL); - __KTRACE_OPT(KHARDWARE, - Kern::Printf("DSymbianUnitTest::TestCount() exit")); - return ret; - } - -TInt DSymbianUnitTest::GetTestCaseName(TAny* aIndex, TDes* aCaseName) - { - __KTRACE_OPT(KHARDWARE, - Kern::Printf("DSymbianUnitTest::GetTestCaseName() enter")); - TInt index; - Kern::ThreadRawRead(iClient, aIndex, &index, sizeof(TInt)); - DSymbianUnitTestCase* testCase = iTestCases[index]; - TBuf8 buf8; - buf8.Copy(testCase->Name()); - TInt ret = Kern::ThreadDesWrite(iClient, aCaseName, buf8, 0, &Kern::CurrentThread()); - return ret; - } - - -TInt DSymbianUnitTest::ExecuteTestCase(TAny* aIndex, TDes8* aResult) - { - __KTRACE_OPT(KHARDWARE, - Kern::Printf("DSymbianUnitTest::ExecuteTestCase() enter")); - TInt index; - Kern::ThreadRawRead(iClient, aIndex, &index, sizeof(TInt)); - DSymbianUnitTestCase* testCase = iTestCases[index]; - - TSUTTestCaseResult result; - TPckg resultPckg(result); - iCurrentTestCase = testCase; - iCurrentResult = &result; - - result.iTestName.Copy(iCurrentTestCase->Name()); - __KTRACE_OPT(KHARDWARE, - Kern::Printf("DSymbianUnitTest::Run test case: %S", - &iCurrentTestCase->Name())); - - //set the owning thread for sem - iExecSem.iOwningThread = &Kern::CurrentThread().iNThread; - - __KTRACE_OPT(KHARDWARE, - Kern::Printf("create exec thread")); - SThreadCreateInfo info; - info.iType=EThreadSupervisor; - info.iFunction=(TThreadFunction)DSymbianUnitTest::TestThreadEntryFunction; - info.iPtr=this; - info.iSupervisorStack=NULL; - info.iSupervisorStackSize=0; // zero means use default value - info.iInitialThreadPriority=NKern::CurrentThread()->iPriority; - - info.iName.Set(iCurrentTestCase->Name()); - info.iTotalSize = sizeof(info); - - - NKern::ThreadEnterCS(); - TInt ret = Kern::ThreadCreate(info); - NKern::ThreadLeaveCS(); - - if (ret == KErrNone) - { - - DThread* pT=(DThread*)info.iHandle; - __KTRACE_OPT(KHARDWARE, - Kern::Printf("start exec thread %0 at %08x", pT, pT)); - Kern::ThreadResume(*pT); - __KTRACE_OPT(KHARDWARE, - Kern::Printf("main thread starts to wait on NFastSemaphore")); - NKern::FSWait(&(iExecSem)); - } - else - { - __KTRACE_OPT(KHARDWARE, - Kern::Printf("error from TheadCreate: %d", ret)); - //ret the result - result.iRetCode = ret; - result.iFailureMessage.Copy(_L("error to create kernel thread to execute test case")); - } - - __KTRACE_OPT(KHARDWARE, - Kern::Printf("DSymbianUnitTest::Run test case [%S] return: %d", - &result.iTestName , result.iRetCode)); - __KTRACE_OPT(KHARDWARE, - Kern::Printf("kernel msg:%S line:%d file:%S", - &result.iFailureMessage, - result.iLineNumber, - &result.iFileName)); - return Kern::ThreadDesWrite(iClient, aResult, resultPckg, 0, 0, &Kern::CurrentThread()); - } - -TInt DSymbianUnitTest::ExecuteTestCaseInThread() - { - TInt ret; - ret = (this->*iCurrentTestCase->iSetupFunction)(); - if (ret != KErrNone) - { - return ret; - } - ret = (this->*iCurrentTestCase->iTestFunction)(); - if (ret != KErrNone) - { - return ret; - } - ret = (this->*iCurrentTestCase->iTeardownFunction)(); - if (ret != KErrNone) - { - return ret; - } - return KErrNone; - } - -TInt DSymbianUnitTest::TestThreadEntryFunction( TAny* aPtr ) - { - __KTRACE_OPT(KHARDWARE, - Kern::Printf("enter TestThreadEntryFunction enter")); - DSymbianUnitTest* self = reinterpret_cast< DSymbianUnitTest* >( aPtr ); - TInt ret = self->ExecuteTestCaseInThread(); - __KTRACE_OPT(KHARDWARE, - Kern::Printf("exec thread FSSignal on Semaphore")); - NKern::FSSignal(&(self->iExecSem)); - return KErrNone; - } - - -EXPORT_C TInt DSymbianUnitTest::AssertEquals( - TInt aExpectedValue, - TInt aActualValue, - TInt aLineNumber, - const TDesC8& aFileName ) - { - if ( aExpectedValue != aActualValue ) - { - TBuf8 msg; - Printf(msg, KIntsNotEqualFormat, aExpectedValue, aActualValue); - return AssertionFailed( msg, aLineNumber, aFileName ); - } - return KErrNone; - } - - -EXPORT_C TInt DSymbianUnitTest::AssertEquals( - const TDesC8& aExpectedValue, - const TDesC8& aActualValue, - TInt aLineNumber, - const TDesC8& aFileName ) - { - if ( aExpectedValue.Compare( aActualValue ) != 0 ) - { - TBuf8 msg; - Printf(msg, KDesCsNotEqualFormat, &aExpectedValue, &aActualValue); - return AssertionFailed( msg, aLineNumber, aFileName ); - } - return KErrNone; - } - - -EXPORT_C TInt DSymbianUnitTest::AssertionFailed( - const TDesC8& aFailureMessage, - TInt aLineNumber, - const TDesC8& aFileName ) - { - - __KTRACE_OPT(KHARDWARE, - Kern::Printf("Assertion failed [%S] at file:%S , line number:%d", - &aFailureMessage, &aFileName, aLineNumber)); - iCurrentResult->iLineNumber = aLineNumber; - iCurrentResult->iFailureMessage.Copy(aFailureMessage); - iCurrentResult->iFileName.Copy(aFileName); - - __KTRACE_OPT(KHARDWARE, - Kern::Printf("kernel msg:%S line:%d file:%S", - &iCurrentResult->iFailureMessage, - iCurrentResult->iLineNumber, - &iCurrentResult->iFileName)); - iCurrentResult->iRetCode = KErrGeneral; - return KErrGeneral; - } - -void DSymbianUnitTest::Printf(TDes8 & aDes, const char* aFmt, ...) - { - VA_LIST list; - VA_START(list, aFmt); - Kern::AppendFormat(aDes, aFmt, list); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -DSymbianUnitTest::DSymbianUnitTestCase::DSymbianUnitTestCase( - const TDesC& aName, - FunctionPtr aSetupFunction, - FunctionPtr aTestFunction, - FunctionPtr aTeardownFunction ) : - iSetupFunction( aSetupFunction ), - iTestFunction( aTestFunction ), - iTeardownFunction( aTeardownFunction ) - { - iName = HBuf8::New(aName); - } - - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -DSymbianUnitTest::DSymbianUnitTestCase::~DSymbianUnitTestCase() - { - delete iName; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -const TDesC& DSymbianUnitTest::DSymbianUnitTestCase::Name() const - { - return *iName; - } - diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwkernel/src/symbianunittestlddctl.cpp --- a/symbianunittestfw/sutfw/sutfwcore/sutfwkernel/src/symbianunittestlddctl.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,224 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of the License "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 -#include -#include -#include -#include "symbianunittestlddctl.h" -#include "symbianunittestlddif.h" -#include "sutlogger.h" - -const TInt KTestCaseNameLength = 256; - -TInt RSymbianUnitTest::GetTestCaseCount(TInt* a1) - { - return RBusLogicalChannel::DoControl(RSymbianUnitTest::ETESTCOUNT, a1); - } - -TInt RSymbianUnitTest::ExecTestCase(TInt* a1, TAny* a2) - { - return RBusLogicalChannel::DoControl(RSymbianUnitTest::EEXECUTETESTCASE, a1, a2); - } - -TInt RSymbianUnitTest::GetTestCaseName(TInt* a1, TAny* a2) - { - return RBusLogicalChannel::DoControl(RSymbianUnitTest::ETESTCASENAME, a1, a2); - } - -TInt RSymbianUnitTest::Open(const TDesC& aName) - { - return DoCreate(aName,TVersion(0,0,1),KNullUnit,NULL,NULL); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestLddCtl* CSymbianUnitTestLddCtl::NewLC(const TDesC& aDriverName) - { - CSymbianUnitTestLddCtl* self = new( ELeave )CSymbianUnitTestLddCtl(); - CleanupStack::PushL( self ); - self->ConstructL(aDriverName); - return self; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestLddCtl* CSymbianUnitTestLddCtl::NewL(const TDesC& aDriverName) - { - CSymbianUnitTestLddCtl* self = CSymbianUnitTestLddCtl::NewLC(aDriverName); - CleanupStack::Pop( self ); - return self; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestLddCtl::CSymbianUnitTestLddCtl() - { - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestLddCtl::ConstructL(const TDesC& aDriverName) - { - iDriverName = aDriverName.AllocL(); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestLddCtl::~CSymbianUnitTestLddCtl() - { - delete iDriverName; - } - - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TInt CSymbianUnitTestLddCtl::LoadDriver() - { - return User::LoadLogicalDevice(*iDriverName); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TInt CSymbianUnitTestLddCtl::FreeDriver() - { - return User::FreeLogicalDevice(*iDriverName); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TInt CSymbianUnitTestLddCtl::ExecuteLddTests( - MSymbianUnitTestObserver& aObserver, - CSymbianUnitTestResult& aResult) - { - - TInt ret = iLddconn.Open(*iDriverName); - if (ret != KErrNone) - { - return ret; - } - SUT_LOG_DEBUG("open ldd"); - - TInt count; - ret = iLddconn.GetTestCaseCount(&count); - SUT_LOG_DEBUGF(_L("user space, test case count:%d"), count); - if (ret != KErrNone) - { - return ret; - } - for (TInt i = 0; i < count; i++) - { - SUT_LOG_DEBUGF(_L("kernel ctl run test case index:%d"), i); - TSUTTestCaseResult caseResult; - TPckg resultPckg(caseResult); - - ret = iLddconn.ExecTestCase(&i, (TAny*)&resultPckg); - - if (ret != KErrNone) - { - aResult.AddLeaveFromTestL(ret, 0); - aObserver.TestFailed(_L("unknown"), _L8("fail to run kernel test cases")); - } - - - TBuf testName; - testName.Copy(caseResult.iTestName); - - aResult.StartTestL( testName ); - aResult.EndTestL(); - - if (caseResult.iRetCode != KErrNone) - { - RDebug::Printf("msg:%S line:%d file:%S", - &caseResult.iFailureMessage, - caseResult.iLineNumber, - &caseResult.iFileName); - aResult.AddAssertFailure( - caseResult.iFailureMessage, - caseResult.iLineNumber, - caseResult.iFileName); - SUT_LOG_DEBUGF(_L("kernel test case failed:%S"), &testName); - aObserver.TestFailed(testName, (const TDesC8&)caseResult.iFailureMessage); - - } - else - { - SUT_LOG_DEBUGF(_L("kernel test passed:%S"), &testName); - aObserver.TestPass(testName); - } - - } - - RDebug::Printf("failure count:%d", aResult.Failures().Count()); - - iLddconn.Close(); - SUT_LOG_DEBUG("close ldd"); - return KErrNone; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TInt CSymbianUnitTestLddCtl::GetTestCaseNames(CDesCArray& aTestCaseNames) - { - TInt ret = iLddconn.Open(*iDriverName); - if (ret != KErrNone) - { - return ret; - } - SUT_LOG_DEBUG("open ldd"); - - TInt count; - ret = iLddconn.GetTestCaseCount(&count); - SUT_LOG_DEBUGF(_L("user space, test case count:%d"), count); - if (ret != KErrNone) - { - return ret; - } - - for (TInt i = 0; i < count; i++) - { - TBuf8 testCaseName; - ret = iLddconn.GetTestCaseName(&i, (TAny*) &testCaseName); - if (ret != KErrNone) - { - return ret; - } - TBuf testCaseName16; - testCaseName16.Copy(testCaseName); - aTestCaseNames.AppendL(testCaseName16); - } - iLddconn.Close(); - SUT_LOG_DEBUG("close ldd"); - return KErrNone; - } - diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwoutput/inc/symbianunittestfileoutputwriter.h --- a/symbianunittestfw/sutfw/sutfwcore/sutfwoutput/inc/symbianunittestfileoutputwriter.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -/* -* 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 SYMBIANUNITTESTFILEOUTPUTWRITER_H -#define SYMBIANUNITTESTFILEOUTPUTWRITER_H - -// INCLUDES -#include -#include - -// CLASS DECLARATION -class CSymbianUnitTestFileOutputWriter : public CBase - { - public: // Constructors and destructor - - static CSymbianUnitTestFileOutputWriter* NewLC( - const TDesC& aFileName ); - - static CSymbianUnitTestFileOutputWriter* NewL( - const TDesC& aFileName ); - - ~CSymbianUnitTestFileOutputWriter(); - - public: // New functions - - void WriteDateAndTimeL(); - void WriteL( const TDesC8& aValue ); - void WriteL( const TDesC8& aFormat, TInt aValue ); - void WriteL( const TDesC& aValue); - - private: // Constructors - - CSymbianUnitTestFileOutputWriter(); - void ConstructL( const TDesC& aFileName ); - - private: // Data - - RFile iFile; - RFs iRFs; - }; - -#endif // SYMBIANUNITTESTFILEOUTPUTWRITER_H diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwoutput/inc/symbianunittestoutputashtml.h --- a/symbianunittestfw/sutfw/sutfwcore/sutfwoutput/inc/symbianunittestoutputashtml.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -/* -* 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 SYMBIANUNITTESTOUTPUTASHTML_H -#define SYMBIANUNITTESTOUTPUTASHTML_H - -// INCLUDES -#include "symbianunittestoutputformatter.h" - -// FORWARD DECLARATIONS -class CSymbianUnitTestFailure; - -// CONTANTS -_LIT( KHtmlOutput, "html" ); - -// CLASS DECLARATION -class CSymbianUnitTestOutputAsHtml : public CSymbianUnitTestOutputFormatter - { - public: // Constructors and destructor - - static CSymbianUnitTestOutputAsHtml* NewL( const TDesC& aFileName ); - ~CSymbianUnitTestOutputAsHtml(); - - protected: // From CSymbianUnitTestOutputFormatter - - const TDesC& FileExtension() const; - void PrintHeaderL( CSymbianUnitTestResult& aResult ); - void PrintPassedTestsL( CSymbianUnitTestResult& aResult ); - void PrintFailedTestsL( CSymbianUnitTestResult& aResult ); - void PrintFooterL(); - - private: // Constructors - - CSymbianUnitTestOutputAsHtml(); - - private: // New functions - - void PrintTableRowL( const TDesC8& aTitle, const TDesC8& aValue ); - }; - -#endif // SYMBIANUNITTESTOUTPUTASHTML_H diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwoutput/inc/symbianunittestoutputastext.h --- a/symbianunittestfw/sutfw/sutfwcore/sutfwoutput/inc/symbianunittestoutputastext.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -/* -* 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 SYMBIANUNITTESTOUTPUTASTEXT_H -#define SYMBIANUNITTESTOUTPUTASTEXT_H - -// INCLUDES -#include "symbianunittestoutputformatter.h" - -// FORWARD DECLARATIONS -class CSymbianUnitTestFailure; - -// CONSTANTS -_LIT( KTextOutput, "txt" ); - -// CLASS DECLARATION -class CSymbianUnitTestOutputAsText : public CSymbianUnitTestOutputFormatter - { - public: // Constructors and destructor - - static CSymbianUnitTestOutputAsText* NewL( const TDesC& aFileName ); - ~CSymbianUnitTestOutputAsText(); - - protected: // From CSymbianUnitTestOutputFormatter - - const TDesC& FileExtension() const; - void PrintHeaderL( CSymbianUnitTestResult& aResult ); - void PrintPassedTestsL( CSymbianUnitTestResult& aResult ); - void PrintFailedTestsL( CSymbianUnitTestResult& aResult ); - void PrintFooterL(); - - private: // Constructors - - CSymbianUnitTestOutputAsText(); - - private: // New functions - - void PrintFailureDetailsL( CSymbianUnitTestFailure& aTestFailure ); - }; - -#endif // SYMBIANUNITTESTOUTPUTASTEXT_H diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwoutput/inc/symbianunittestoutputasxml.h --- a/symbianunittestfw/sutfw/sutfwcore/sutfwoutput/inc/symbianunittestoutputasxml.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -/* -* 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 SYMBIANUNITTESTOUTPUTASXML_H -#define SYMBIANUNITTESTOUTPUTASXML_H - -// INCLUDES -#include "symbianunittestoutputformatter.h" - -// FORWARD DECLARATIONS -class CSymbianUnitTestFailure; - -// CONTANTS -_LIT( KXmlOutput, "xml" ); - -// CLASS DECLARATION -class CSymbianUnitTestOutputAsXml : public CSymbianUnitTestOutputFormatter - { - public: // Constructors and destructor - - static CSymbianUnitTestOutputAsXml* NewL( const TDesC& aFileName ); - ~CSymbianUnitTestOutputAsXml(); - - protected: // From CSymbianUnitTestOutputFormatter - - const TDesC& FileExtension() const; - void PrintHeaderL( CSymbianUnitTestResult& aResult ); - void PrintPassedTestsL( CSymbianUnitTestResult& aResult ); - void PrintFailedTestsL( CSymbianUnitTestResult& aResult ); - void PrintFooterL(); - - private: // Constructors - - CSymbianUnitTestOutputAsXml(); - - private: // New functions - - void PrintFailureDetailsL( CSymbianUnitTestFailure& aTestFailure ); - }; - -#endif // SYMBIANUNITTESTOUTPUTASXML_H diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwoutput/inc/symbianunittestoutputfactory.h --- a/symbianunittestfw/sutfw/sutfwcore/sutfwoutput/inc/symbianunittestoutputfactory.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -/* -* 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 SYMBIANUNITTESTOUTPUTFACTORY_H -#define SYMBIANUNITTESTOUTPUTFACTORY_H - -// INCLUDES -#include - -// FORWARD DECLARATIONS -class CSymbianUnitTestOutputFormatter; - -// CLASS DECLARATION -class SymbianUnitTestOutputFactory - { - public: // New functions - - static CSymbianUnitTestOutputFormatter* CreateOutputLC( - const TDesC& aFileNameNoExtension, - const TDesC& aFileExtension ); - }; - -#endif // SYMBIANUNITTESTOUTPUTFACTORY_H diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwoutput/inc/symbianunittestoutputformatter.h --- a/symbianunittestfw/sutfw/sutfwcore/sutfwoutput/inc/symbianunittestoutputformatter.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -/* -* 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 SYMBIANUNITTESTOUTPUTFORMATTER_H -#define SYMBIANUNITTESTOUTPUTFORMATTER_H - -// INCLUDES -#include - -// FORWARD DECLARATIONS -class CSymbianUnitTestResult; -class CSymbianUnitTestFileOutputWriter; - -// CLASS DECLARATION -class CSymbianUnitTestOutputFormatter : public CBase - { - public: // Destructor - - ~CSymbianUnitTestOutputFormatter(); - - public: // New functions - - void PrintL( CSymbianUnitTestResult& aResult ); - - protected: // Constructors - - CSymbianUnitTestOutputFormatter(); - void ConstructL( const TDesC& aFileName ); - - protected: // Pure virtual functions - - virtual const TDesC& FileExtension() const = 0; - virtual void PrintHeaderL( CSymbianUnitTestResult& aResult ) = 0; - virtual void PrintPassedTestsL( CSymbianUnitTestResult& aResult ) = 0; - virtual void PrintFailedTestsL( CSymbianUnitTestResult& aResult ) = 0; - virtual void PrintFooterL() = 0; - - protected: // Data - - CSymbianUnitTestFileOutputWriter* iOutputWriter; // Owned - }; - -#endif // SYMBIANUNITTESTOUTPUTFORMATTER_H diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwoutput/src/symbianunittestfileoutputwriter.cpp --- a/symbianunittestfw/sutfw/sutfwcore/sutfwoutput/src/symbianunittestfileoutputwriter.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,138 +0,0 @@ -/* -* 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 "symbianunittestfileoutputwriter.h" -#include "symbianunittestuicallback.h" -#include - -_LIT( KResultDirectory, "\\sut\\" ); -_LIT8( KDateAndTimeFormat, "%02d.%02d.%04d @ %02d:%02d:%02d" ); - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestFileOutputWriter* CSymbianUnitTestFileOutputWriter::NewLC( - const TDesC& aFileName ) - { - CSymbianUnitTestFileOutputWriter* self = - new( ELeave )CSymbianUnitTestFileOutputWriter(); - CleanupStack::PushL( self ); - self->ConstructL( aFileName ); - return self; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestFileOutputWriter* CSymbianUnitTestFileOutputWriter::NewL( - const TDesC& aFileName ) - { - CSymbianUnitTestFileOutputWriter* self = - CSymbianUnitTestFileOutputWriter::NewLC( aFileName ); - CleanupStack::Pop( self ); - return self; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestFileOutputWriter::ConstructL( const TDesC& aFileName ) - { - User::LeaveIfError( iRFs.Connect() ); - TInt err = iRFs.MkDir( KResultDirectory ); - if ( err == KErrNoMemory ) - { - // Ignore the other errors. The directory may already exist. - User::Leave( err ); - } - User::LeaveIfError( iRFs.SetSessionPath( KResultDirectory ) ); - User::LeaveIfError( iFile.Replace( iRFs, aFileName, EFileWrite ) ); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestFileOutputWriter::CSymbianUnitTestFileOutputWriter() - { - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestFileOutputWriter::~CSymbianUnitTestFileOutputWriter() - { - iFile.Close(); - iRFs.Close(); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestFileOutputWriter::WriteDateAndTimeL() - { - TTime time; - time.HomeTime(); - TDateTime dateTime( time.DateTime() ); - HBufC8* buf = HBufC8::NewLC( KDateAndTimeFormat().Length() ); - buf->Des().Format( KDateAndTimeFormat(), dateTime.Day()+1, - dateTime.Month()+1, dateTime.Year(), dateTime.Hour(), - dateTime.Minute(), dateTime.Second() ); - User::LeaveIfError( iFile.Write( *buf ) ); - CleanupStack::PopAndDestroy( buf ); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestFileOutputWriter::WriteL( const TDesC8& aValue ) - { - User::LeaveIfError( iFile.Write( aValue ) ); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestFileOutputWriter::WriteL( const TDesC& aValue ) - { - HBufC8* value = CnvUtfConverter::ConvertFromUnicodeToUtf8L(aValue); - CleanupStack::PushL(value); - User::LeaveIfError( iFile.Write( *value ) ); - CleanupStack::PopAndDestroy( value ); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestFileOutputWriter::WriteL( - const TDesC8& aFormat, - TInt aValue ) - { - const TInt KIntAsTextMaxLength( 20 ); - HBufC8* buf = HBufC8::NewLC( aFormat.Length() + KIntAsTextMaxLength ); - buf->Des().Format( aFormat, aValue ); - User::LeaveIfError( iFile.Write( *buf ) ); - CleanupStack::PopAndDestroy( buf ); - } diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwoutput/src/symbianunittestoutputashtml.cpp --- a/symbianunittestfw/sutfw/sutfwcore/sutfwoutput/src/symbianunittestoutputashtml.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,178 +0,0 @@ -/* -* 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 "symbianunittestresult.h" -#include "symbianunittestfailure.h" -#include "symbianunittestfileoutputwriter.h" -#include "symbianunittestoutputashtml.h" -#include - -// CONSTANTS -_LIT8( KHtmlHeader, "Unit test results\n" ); -_LIT8( KHtmlFooter, "\n" ); -_LIT8( KHtmlBodyStartTag, "\n" ); -_LIT8( KHtmlBodyEndTag, "\n"); -_LIT8( KHtmlMainHeaderStartTag, "

%d unit tests executed " ); -_LIT8( KHtmlMainHeaderEndTag, "

\n" ); -_LIT8( KHtmlPassedTests, - "

Passed tests: %d

\n" ); -_LIT8( KHtmlFailedTests, - "

Failed tests: %d

\n" ); -_LIT8( KHtmlParagraphBreak, "

\n" ); -_LIT8( KHtmlTableStartTag, "\n" ); -_LIT8( KHtmlTableEndTag, "
\n" ); -_LIT8( KHtmlTRStartTag, "\n" ); -_LIT8( KHtmlTREndTag, "\n" ); -_LIT8( KHtmlTitleColumnStart, "" ); -_LIT8( KHtmlTitleColumnEnd, "\n" ); -_LIT8( KHtmlTestNameTitle, "Test name" ); -_LIT8( KHtmlFileNameTitle, "File name" ); -_LIT8( KHtmlLineNumberTitle, "Line number" ); -_LIT8( KHtmlReasonTitle, "Reason" ); -_LIT8( KHtmlValueColumnStart, "" ); -_LIT8( KHtmlValueColumnEnd, "\n" ); - - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestOutputAsHtml* CSymbianUnitTestOutputAsHtml::NewL( - const TDesC& aFileName ) - { - CSymbianUnitTestOutputAsHtml* self = - new( ELeave )CSymbianUnitTestOutputAsHtml; - CleanupStack::PushL( self ); - self->ConstructL( aFileName ); - CleanupStack::Pop( self ); - return self; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestOutputAsHtml::CSymbianUnitTestOutputAsHtml() - { - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestOutputAsHtml::~CSymbianUnitTestOutputAsHtml() - { - } - -// ----------------------------------------------------------------------------- -// From CSymbianUnitTestOutputFormatter -// ----------------------------------------------------------------------------- -// -const TDesC& CSymbianUnitTestOutputAsHtml::FileExtension() const - { - return KHtmlOutput; - } - -// ----------------------------------------------------------------------------- -// From CSymbianUnitTestOutputFormatter -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestOutputAsHtml::PrintHeaderL( - CSymbianUnitTestResult& aResult ) - { - iOutputWriter->WriteL( KHtmlHeader ); - iOutputWriter->WriteL( KHtmlBodyStartTag ); - iOutputWriter->WriteL( KHtmlMainHeaderStartTag, aResult.TestCount() ); - iOutputWriter->WriteDateAndTimeL(); - iOutputWriter->WriteL( KHtmlMainHeaderEndTag ); - } - -// ----------------------------------------------------------------------------- -// From CSymbianUnitTestOutputFormatter -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestOutputAsHtml::PrintPassedTestsL( - CSymbianUnitTestResult& aResult ) - { - iOutputWriter->WriteL( KHtmlPassedTests, aResult.PassedTestCount() ); - iOutputWriter->WriteL( KHtmlTableStartTag ); - const CDesCArray& testCaseNames = aResult.TestCaseNames(); - for ( TInt i=0; i < testCaseNames.Count(); i++ ) - { - HBufC8* testName = CnvUtfConverter::ConvertFromUnicodeToUtf8L( testCaseNames[i] ); - PrintTableRowL( KHtmlTestNameTitle, *testName ); - delete testName; - } - iOutputWriter->WriteL( KHtmlTableEndTag ); - } - -// ----------------------------------------------------------------------------- -// From CSymbianUnitTestOutputFormatter -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestOutputAsHtml::PrintFailedTestsL( - CSymbianUnitTestResult& aResult ) - { - iOutputWriter->WriteL( KHtmlFailedTests, aResult.Failures().Count() ); - for ( TInt i=0; i < aResult.Failures().Count(); i++ ) - { - CSymbianUnitTestFailure* failure = aResult.Failures()[ i ]; - iOutputWriter->WriteL( KHtmlTableStartTag ); - PrintTableRowL( KHtmlTestNameTitle, failure->TestName() ); - PrintTableRowL( KHtmlReasonTitle, failure->FailureMessage() ); - if ( failure->LineNumber() >= 0 ) - { - TBuf8< 20 > value; - value.AppendNum( failure->LineNumber() ); - PrintTableRowL( KHtmlLineNumberTitle, value ); - } - if ( failure->FileName().Length() > 0 ) - { - PrintTableRowL( KHtmlFileNameTitle, failure->FileName() ); - } - iOutputWriter->WriteL( KHtmlTableEndTag ); - iOutputWriter->WriteL( KHtmlParagraphBreak ); - } - } - -// ----------------------------------------------------------------------------- -// From CSymbianUnitTestOutputFormatter -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestOutputAsHtml::PrintFooterL() - { - iOutputWriter->WriteL( KHtmlBodyEndTag ); - iOutputWriter->WriteL( KHtmlFooter ); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestOutputAsHtml::PrintTableRowL( - const TDesC8& aTitle, - const TDesC8& aValue ) - { - iOutputWriter->WriteL( KHtmlTRStartTag ); - iOutputWriter->WriteL( KHtmlTitleColumnStart ); - iOutputWriter->WriteL( aTitle ); - iOutputWriter->WriteL( KHtmlTitleColumnEnd ); - iOutputWriter->WriteL( KHtmlValueColumnStart ); - iOutputWriter->WriteL( aValue ); - iOutputWriter->WriteL( KHtmlValueColumnEnd ); - iOutputWriter->WriteL( KHtmlTREndTag ); - } diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwoutput/src/symbianunittestoutputastext.cpp --- a/symbianunittestfw/sutfw/sutfwcore/sutfwoutput/src/symbianunittestoutputastext.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,149 +0,0 @@ -/* -* 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 "symbianunittestresult.h" -#include "symbianunittestfailure.h" -#include "symbianunittestfileoutputwriter.h" -#include "symbianunittestoutputastext.h" - -_LIT8( KTxtExecutedTests, "\r\n %d unit tests executed " ); -_LIT8( KTxtPassedTests, " Passed tests: %d\r\n\r\n" ); -_LIT8( KTxtPassedTest, " Test: " ); -_LIT8( KTxtFailedTests, " Failed tests: %d\r\n\r\n" ); -_LIT8( KTxtFailureTest, " Test: " ); -_LIT8( KTxtFailureFile, " File: " ); -_LIT8( KTxtFailureLine, " Line: %d\r\n" ); -_LIT8( KTxtFailureReason, " Reason: " ); -_LIT8( KLineEnd, "\r\n" ); - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestOutputAsText* CSymbianUnitTestOutputAsText::NewL( - const TDesC& aFileName ) - { - CSymbianUnitTestOutputAsText* self = - new( ELeave )CSymbianUnitTestOutputAsText; - CleanupStack::PushL( self ); - self->ConstructL( aFileName ); - CleanupStack::Pop( self ); - return self; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestOutputAsText::CSymbianUnitTestOutputAsText() - { - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestOutputAsText::~CSymbianUnitTestOutputAsText() - { - } - -// ----------------------------------------------------------------------------- -// From CSymbianUnitTestOutputFormatter -// ----------------------------------------------------------------------------- -// -const TDesC& CSymbianUnitTestOutputAsText::FileExtension() const - { - return KTextOutput; - } - -// ----------------------------------------------------------------------------- -// From CSymbianUnitTestOutputFormatter -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestOutputAsText::PrintHeaderL( - CSymbianUnitTestResult& aResult ) - { - iOutputWriter->WriteL( KTxtExecutedTests, aResult.TestCount() ); - iOutputWriter->WriteDateAndTimeL(); - iOutputWriter->WriteL( KLineEnd ); - iOutputWriter->WriteL( KLineEnd ); - } - -// ----------------------------------------------------------------------------- -// From CSymbianUnitTestOutputFormatter -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestOutputAsText::PrintPassedTestsL( - CSymbianUnitTestResult& aResult ) - { - iOutputWriter->WriteL( KTxtPassedTests, aResult.PassedTestCount() ); - const CDesCArray& testCaseNames = aResult.TestCaseNames(); - for ( TInt i=0; i < testCaseNames.Count(); i++ ) - { - iOutputWriter->WriteL( KTxtPassedTest); - iOutputWriter->WriteL( testCaseNames[i]); - iOutputWriter->WriteL( KLineEnd ); - } - } - -// ----------------------------------------------------------------------------- -// From CSymbianUnitTestOutputFormatter -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestOutputAsText::PrintFailedTestsL( - CSymbianUnitTestResult& aResult ) - { - iOutputWriter->WriteL( KTxtFailedTests, aResult.Failures().Count() ); - for ( TInt i=0; i < aResult.Failures().Count(); i++ ) - { - PrintFailureDetailsL( *( aResult.Failures()[ i ] ) ); - } - } - -// ----------------------------------------------------------------------------- -// From CSymbianUnitTestOutputFormatter -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestOutputAsText::PrintFooterL() - { - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestOutputAsText::PrintFailureDetailsL( - CSymbianUnitTestFailure& aTestFailure ) - { - iOutputWriter->WriteL( KTxtFailureTest ); - iOutputWriter->WriteL( aTestFailure.TestName() ); - iOutputWriter->WriteL( KLineEnd ); - if ( aTestFailure.FileName().Length() > 0 ) - { - iOutputWriter->WriteL( KTxtFailureFile ); - iOutputWriter->WriteL( aTestFailure.FileName() ); - iOutputWriter->WriteL( KLineEnd ); - } - if ( aTestFailure.LineNumber() >= 0 ) - { - iOutputWriter->WriteL( KTxtFailureLine, aTestFailure.LineNumber() ); - } - iOutputWriter->WriteL( KTxtFailureReason ); - iOutputWriter->WriteL( aTestFailure.FailureMessage() ); - iOutputWriter->WriteL( KLineEnd ); - iOutputWriter->WriteL( KLineEnd ); - } diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwoutput/src/symbianunittestoutputasxml.cpp --- a/symbianunittestfw/sutfw/sutfwcore/sutfwoutput/src/symbianunittestoutputasxml.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,161 +0,0 @@ -/* -* 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 "symbianunittestresult.h" -#include "symbianunittestfailure.h" -#include "symbianunittestfileoutputwriter.h" -#include "symbianunittestoutputasxml.h" - - -_LIT8( KXmlResultOpenTag, "\r\n" ); -_LIT8( KXmlResultCloseTag, "\r\n" ); -_LIT8( KXmlPassedTestsOpenTag, "\t\r\n" ); -_LIT8( KXmlPassedTestsCloseTag, "\t\r\n" ); -_LIT8( KXmlFailedTestsOpenTag, "\t\r\n" ); -_LIT8( KXmlFailedTestsCloseTag, "\t\r\n" ); -_LIT8( KXmlFailureOpenTag, "\t\t\r\n" ); -_LIT8( KXmlFailureCloseTag, "\t\t\r\n" ); -_LIT8( KXmlTestNameOpenTag, "\t\t\t\r\n" ); -_LIT8( KXmlTestNameCloseTag, "\r\n\t\t\t\r\n" ); -_LIT8( KXmlFileNameOpenTag, "\t\t\t\r\n" ); -_LIT8( KXmlFileNameCloseTag, "\r\n\t\t\t\r\n" ); -_LIT8( KXmlLineNumberOpenTag, "\t\t\t%d\r\n" ); -_LIT8( KXmlLineNumberCloseTag, "\r\n\t\t\t\r\n" ); -_LIT8( KXmlReasonOpenTag, "\t\t\t\r\n" ); -_LIT8( KXmlReasonCloseTag, "\r\n\t\t\t\r\n" ); - - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestOutputAsXml* CSymbianUnitTestOutputAsXml::NewL( - const TDesC& aFileName ) - { - CSymbianUnitTestOutputAsXml* self = - new( ELeave )CSymbianUnitTestOutputAsXml; - CleanupStack::PushL( self ); - self->ConstructL( aFileName ); - CleanupStack::Pop( self ); - return self; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestOutputAsXml::CSymbianUnitTestOutputAsXml() - { - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestOutputAsXml::~CSymbianUnitTestOutputAsXml() - { - } - -// ----------------------------------------------------------------------------- -// From CSymbianUnitTestOutputFormatter -// ----------------------------------------------------------------------------- -// -const TDesC& CSymbianUnitTestOutputAsXml::FileExtension() const - { - return KXmlOutput; - } - -// ----------------------------------------------------------------------------- -// From CSymbianUnitTestOutputFormatter -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestOutputAsXml::PrintHeaderL( - CSymbianUnitTestResult& aResult ) - { - iOutputWriter->WriteL( KXmlResultOpenTag, aResult.TestCount() ); - } - -// ----------------------------------------------------------------------------- -// From CSymbianUnitTestOutputFormatter -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestOutputAsXml::PrintPassedTestsL( - CSymbianUnitTestResult& aResult ) - { - iOutputWriter->WriteL( KXmlPassedTestsOpenTag, aResult.PassedTestCount() ); - const CDesCArray& testCaseNames = aResult.TestCaseNames(); - for ( TInt i=0; i < testCaseNames.Count(); i++ ) - { - iOutputWriter->WriteL( KXmlTestNameOpenTag ); - iOutputWriter->WriteL( testCaseNames[i]); - iOutputWriter->WriteL( KXmlTestNameCloseTag ); - } - iOutputWriter->WriteL( KXmlPassedTestsCloseTag ); - } - -// ----------------------------------------------------------------------------- -// From CSymbianUnitTestOutputFormatter -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestOutputAsXml::PrintFailedTestsL( - CSymbianUnitTestResult& aResult ) - { - iOutputWriter->WriteL( KXmlFailedTestsOpenTag, aResult.Failures().Count() ); - for ( TInt i=0; i < aResult.Failures().Count(); i++ ) - { - iOutputWriter->WriteL( KXmlFailureOpenTag ); - PrintFailureDetailsL( *( aResult.Failures()[ i ] ) ); - iOutputWriter->WriteL( KXmlFailureCloseTag ); - } - iOutputWriter->WriteL( KXmlFailedTestsCloseTag ); - } - -// ----------------------------------------------------------------------------- -// From CSymbianUnitTestOutputFormatter -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestOutputAsXml::PrintFooterL() - { - iOutputWriter->WriteL( KXmlResultCloseTag ); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestOutputAsXml::PrintFailureDetailsL( - CSymbianUnitTestFailure& aTestFailure ) - { - iOutputWriter->WriteL( KXmlTestNameOpenTag ); - iOutputWriter->WriteL( aTestFailure.TestName() ); - iOutputWriter->WriteL( KXmlTestNameCloseTag ); - if ( aTestFailure.FileName().Length() > 0 ) - { - iOutputWriter->WriteL( KXmlFileNameOpenTag ); - iOutputWriter->WriteL( aTestFailure.FileName() ); - iOutputWriter->WriteL( KXmlFileNameCloseTag ); - } - TInt lineNumber( aTestFailure.LineNumber() ); - if ( lineNumber >= 0 ) - { - iOutputWriter->WriteL( KXmlLineNumberOpenTag, lineNumber ); - iOutputWriter->WriteL( KXmlLineNumberCloseTag ); - } - iOutputWriter->WriteL( KXmlReasonOpenTag ); - iOutputWriter->WriteL( aTestFailure.FailureMessage() ); - iOutputWriter->WriteL( KXmlReasonCloseTag ); - } diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwoutput/src/symbianunittestoutputfactory.cpp --- a/symbianunittestfw/sutfw/sutfwcore/sutfwoutput/src/symbianunittestoutputfactory.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -/* -* 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 "symbianunittestoutputfactory.h" -#include "symbianunittestoutputastext.h" -#include "symbianunittestoutputasxml.h" -#include "symbianunittestoutputashtml.h" - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestOutputFormatter* SymbianUnitTestOutputFactory::CreateOutputLC( - const TDesC& aFileNameWithoutExtension, - const TDesC& aFileExtension ) - { - CSymbianUnitTestOutputFormatter* outputFormatter = NULL; - - if ( aFileExtension.CompareF( KTextOutput ) == 0 ) - { - outputFormatter = - CSymbianUnitTestOutputAsText::NewL( aFileNameWithoutExtension ); - } - else if ( aFileExtension.CompareF( KXmlOutput ) == 0 ) - { - outputFormatter = - CSymbianUnitTestOutputAsXml::NewL( aFileNameWithoutExtension ); - } - else if ( aFileExtension.CompareF( KHtmlOutput ) == 0 ) - { - outputFormatter = - CSymbianUnitTestOutputAsHtml::NewL( aFileNameWithoutExtension ); - } - else - { - User::Leave( KErrNotSupported ); - } - - CleanupStack::PushL( outputFormatter ); - - return outputFormatter; - } diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwoutput/src/symbianunittestoutputformatter.cpp --- a/symbianunittestfw/sutfw/sutfwcore/sutfwoutput/src/symbianunittestoutputformatter.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -/* -* 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 "symbianunittestoutputformatter.h" -#include "symbianunittestfileoutputwriter.h" -#include "symbianunittestresult.h" - - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestOutputFormatter::CSymbianUnitTestOutputFormatter() - { - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestOutputFormatter::ConstructL( const TDesC& aFileName ) - { - TInt fileNameLength = aFileName.Length(); - fileNameLength += 1; // dot length - fileNameLength += FileExtension().Length(); - HBufC* fileName = HBufC::NewLC( fileNameLength ); - fileName->Des() = aFileName; - fileName->Des().Append('.'); - fileName->Des().Append( FileExtension() ); - iOutputWriter = CSymbianUnitTestFileOutputWriter::NewL( *fileName ); - CleanupStack::PopAndDestroy( fileName ); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestOutputFormatter::~CSymbianUnitTestOutputFormatter() - { - delete iOutputWriter; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestOutputFormatter::PrintL( CSymbianUnitTestResult& aResult ) - { - PrintHeaderL( aResult ); - PrintPassedTestsL( aResult ); - PrintFailedTestsL( aResult ); - PrintFooterL(); - } diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwcore/sutfwtestrunner/src/symbianunittestrunner.cpp --- a/symbianunittestfw/sutfw/sutfwcore/sutfwtestrunner/src/symbianunittestrunner.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,377 +0,0 @@ -/* -* 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 "symbianunittestrunner.h" -#include "symbianunittestuicallback.h" -#include "symbianunittestoutputformatter.h" -#include "symbianunittestoutputfactory.h" -#include "symbianunittestresult.h" -#include "symbianunittestversion.h" -#include "sutlogger.h" -#include "symbianunittestlddctl.h" -#include -#include - - -// Failures while loading dll: -_LIT( KFailedToFindDll, "Failed to find DLL:\n\"%S\"\n" ); -_LIT( KFailedToLoadLDD, "Failed to load LDD:\n\"%S\"\n" ); -_LIT( KFailedToRunLDD, "Failed to run LDD tests:\n\"%S\"\n" ); -_LIT( KNonCompatibleUIDs, "Cannot use DLL with non-compatible UIDs!\n" ); -_LIT( KExportFuncNotFound, "Cannot find EXPORT function from test DLL!\n" ); -_LIT( KLogVersion, "SymbianUnitTest v%d.%d.%d" ); -_LIT( KLogFinish, "SymbianUnitTest finished" ); - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -EXPORT_C CSymbianUnitTestRunner* CSymbianUnitTestRunner::NewLC( - MSymbianUnitTestUiCallBack& aUiCallBack ) - { - CSymbianUnitTestRunner* self = - new( ELeave )CSymbianUnitTestRunner( aUiCallBack ); - CleanupStack::PushL( self ); - self->ConstructL(); - return self; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -EXPORT_C CSymbianUnitTestRunner* CSymbianUnitTestRunner::NewL( - MSymbianUnitTestUiCallBack& aUiCallBack ) - { - CSymbianUnitTestRunner* self = CSymbianUnitTestRunner::NewLC( aUiCallBack ); - CleanupStack::Pop( self ); - return self; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestRunner::CSymbianUnitTestRunner( - MSymbianUnitTestUiCallBack& aUiCallBack ) - : iUiCallBack( aUiCallBack ) - { - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestRunner::ConstructL() - { - iResult = CSymbianUnitTestResult::NewL(); - //init logger - TBuf<50> version; - version.Format(KLogVersion, SUT_MAJOR_VERSION, SUT_MINOR_VERSION, SUT_BUILD_VERSION); - SUT_LOG_START(version); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -EXPORT_C CSymbianUnitTestRunner::~CSymbianUnitTestRunner() - { - delete iResult; - } - -// ----------------------------------------------------------------------------- -// From MSymbianUnitTestObserver -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestRunner::TestPass(const TDesC& aTestCaseName) - { - iUiCallBack.TestPass(aTestCaseName); - } - -// ----------------------------------------------------------------------------- -// From MSymbianUnitTestObserver -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestRunner::TestFailed(const TDesC& aTestCaseName, const TDesC8& aErrMsg) - { - iUiCallBack.TestFailed(aTestCaseName, aErrMsg); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -EXPORT_C TInt CSymbianUnitTestRunner::TestCount() - { - return iTestCount; - } - -EXPORT_C TInt CSymbianUnitTestRunner::TestCountL(const MDesCArray& aTestDllNames, const MDesCArray& aTestCaseNames) - { - TInt dllCnt = aTestDllNames.MdcaCount(); - if (dllCnt == 0) - { - return 0; - } - TInt caseCnt = aTestCaseNames.MdcaCount(); - if (caseCnt != 0) - { - return caseCnt; - } - else - { - for ( TInt i = 0; i < dllCnt; i++) - { - CDesCArray* testCaseNames = new (ELeave) CDesCArrayFlat(1); - CleanupStack::PushL(testCaseNames); - this->TestCaseNamesL(aTestDllNames.MdcaPoint(i), *testCaseNames); - caseCnt += testCaseNames->Count(); - CleanupStack::PopAndDestroy(testCaseNames); - } - return caseCnt; - } - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -EXPORT_C void CSymbianUnitTestRunner::ExecuteTestsL( - const MDesCArray& aTestDllNames, - TBool aMemoryAllocationFailureSimulation, - const TDesC& aOutputFileName, - const TDesC& aOutputFormat, - const CDesCArray& aTestCaseNames, - TInt aTimeout ) - { - iTestCount = 0; - - MSymbianUnitTestInterface::TFailureSimulation failureSimulation = - MSymbianUnitTestInterface::ENoFailureSimulation; - if ( aMemoryAllocationFailureSimulation ) - { - failureSimulation = - MSymbianUnitTestInterface::EMemAllocFailureSimulation; - } - - for ( TInt i = 0; i < aTestDllNames.MdcaCount(); i++ ) - { - TPtrC16 testDllName( aTestDllNames.MdcaPoint( i ) ); - if (testDllName.Find(_L(".ldd"))>0) - { - ExecuteLddTestsL(testDllName, aTestCaseNames, aTimeout); - } - else - { - //it is dll test - ExecuteDllTestsL(testDllName, failureSimulation, aTestCaseNames, aTimeout); - } - } - - CSymbianUnitTestOutputFormatter* outputFormatter = - SymbianUnitTestOutputFactory::CreateOutputLC( - aOutputFileName, aOutputFormat ); - outputFormatter->PrintL( *iResult ); - CleanupStack::PopAndDestroy( outputFormatter ); - SUT_LOG_INFO(KLogFinish); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -EXPORT_C TInt CSymbianUnitTestRunner::FailedTestCount() - { - return iResult->Failures().Count(); - } - - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -EXPORT_C void CSymbianUnitTestRunner::TestCaseNamesL( - const TDesC& aTestDllName, CDesCArray& aTestCaseNames) - { - - if (aTestDllName.Find(_L(".ldd"))>0) - { - //it is kernel ldd test - return GetLddTestCaseNamesL(aTestDllName, aTestCaseNames); - } - else - { - //it is dll test - return GetDllTestCaseNamesL(aTestDllName, aTestCaseNames); - } - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestRunner::GetDllTestCaseNamesL( - const TDesC& aTestDllName, CDesCArray& aTestCaseNames) - { - RLibrary library; - TInt ret; - ret = library.Load(aTestDllName); - if (ret != KErrNone) - { - iUiCallBack.InfoMsg(KFailedToFindDll, aTestDllName); - SUT_LOG_FORMAT(KFailedToFindDll, &aTestDllName); - User::Leave(ret); - } - CleanupClosePushL(library); - // The second UID of the dll to be used must be compatible - if (library.Type()[1] != KSymbianUnitTestDllUid) - { - iUiCallBack.InfoMsg(KNonCompatibleUIDs); - User::Leave(KErrNotFound); - } - TLibraryFunction entryFunction = library.Lookup(1); - if (!entryFunction) - { - iUiCallBack.InfoMsg(KExportFuncNotFound); - User::Leave(KErrNotFound); - } - - MSymbianUnitTestInterface* test = - reinterpret_cast (entryFunction()); - - TCleanupItem cleanupItem(DeleteTest, test); - CleanupStack::PushL(cleanupItem); - - test->TestCaseNamesL(aTestCaseNames); - CleanupStack::Pop(); // cleanupItem - CleanupStack::PopAndDestroy(&library); - - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestRunner::GetLddTestCaseNamesL( - const TDesC& aTestLddName, CDesCArray& aTestCaseNames) - { - CSymbianUnitTestLddCtl* lddCtl = CSymbianUnitTestLddCtl::NewLC( - aTestLddName); - TInt ret = lddCtl->LoadDriver(); - if (ret != KErrNone) - { - iUiCallBack.InfoMsg(KFailedToLoadLDD, aTestLddName); - SUT_LOG_FORMAT(KFailedToLoadLDD, &aTestLddName); - User::Leave(ret); - } - - ret = lddCtl->GetTestCaseNames(aTestCaseNames); - if (ret != KErrNone) - { - iUiCallBack.InfoMsg(KFailedToRunLDD, aTestLddName); - SUT_LOG_FORMAT(KFailedToRunLDD, &aTestLddName); - User::Leave(ret); - } - lddCtl->FreeDriver(); - CleanupStack::PopAndDestroy(lddCtl); - SUT_LOG_FORMAT(_L(" case name count:%d\n"), aTestCaseNames.Length()); - for (TInt i = 0; i < aTestCaseNames.Length(); i++) - { - SUT_LOG_FORMAT(_L(" case:%S\n"), &aTestCaseNames[i]); - } - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestRunner::DeleteTest( TAny* aTest ) - { - MSymbianUnitTestInterface* test = - reinterpret_cast< MSymbianUnitTestInterface* >( aTest ); - delete test; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestRunner::ExecuteDllTestsL(const TDesC& aTestDllName, MSymbianUnitTestInterface::TFailureSimulation aFailureSimulation, - const CDesCArray& aTestCaseNames, TInt aTimeout) - { - RLibrary library; - TInt ret; - ret = library.Load(aTestDllName); - if (ret != KErrNone) - { - iUiCallBack.InfoMsg(KFailedToFindDll, aTestDllName); - SUT_LOG_FORMAT(KFailedToFindDll, &aTestDllName); - User::Leave(ret); - } - CleanupClosePushL(library); - // The second UID of the dll to be used must be compatible - if (library.Type()[1] != KSymbianUnitTestDllUid) - { - iUiCallBack.InfoMsg(KNonCompatibleUIDs); - User::Leave(KErrNotFound); - } - TLibraryFunction entryFunction = library.Lookup(1); - if (!entryFunction) - { - iUiCallBack.InfoMsg(KExportFuncNotFound); - User::Leave(KErrNotFound); - } - - MSymbianUnitTestInterface* test = - reinterpret_cast (entryFunction()); - TCleanupItem cleanupItem(DeleteTest, test); - CleanupStack::PushL(cleanupItem); - iTestCount += test->TestCaseCount(); - test->ExecuteL(*this, *iResult, aFailureSimulation, aTestCaseNames, - aTimeout); - CleanupStack::Pop(); // cleanupItem - CleanupStack::PopAndDestroy(&library); - } - - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestRunner::ExecuteLddTestsL(const TDesC& aTestLddName, const CDesCArray& /*aTestCaseNames*/, - TInt /*aTimeout*/) - { - CSymbianUnitTestLddCtl* lddCtl = CSymbianUnitTestLddCtl::NewLC( aTestLddName ); - TInt ret = lddCtl->LoadDriver(); - if (ret != KErrNone) - { - iUiCallBack.InfoMsg(KFailedToLoadLDD, aTestLddName); - SUT_LOG_FORMAT(KFailedToLoadLDD, &aTestLddName); - User::Leave(ret); - } - - ret = lddCtl->ExecuteLddTests(*this, *iResult); - if (ret != KErrNone) - { - iUiCallBack.InfoMsg(KFailedToRunLDD, aTestLddName); - SUT_LOG_FORMAT(KFailedToRunLDD, &aTestLddName); - User::Leave(ret); - } - lddCtl->FreeDriver(); - CleanupStack::PopAndDestroy( lddCtl ); - } diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwexamples/group/bld.inf --- a/symbianunittestfw/sutfw/sutfwexamples/group/bld.inf Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -/* -* 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: Symbian Unit Testing framework -* -*/ - -#include "../sutfwracecarexample/tsrc/group/bld.inf" -#include "../sutfwkernelexample/tsrc/group/bld.inf" - diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwexamples/sutfwkernelexample/inc/racecar.h --- a/symbianunittestfw/sutfw/sutfwexamples/sutfwkernelexample/inc/racecar.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -/* -* 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 DRACECAR_H -#define DRACECAR_H - -// INCLUDES -#include -#include "symbianunittestmacros.h" - -// CONSTANTS -const TInt KMaxTyreAngle( 45 ); - -// CLASS DECLARATION -class DRaceCar : public DBase - { - public: // Constructors and Destructor - - DRaceCar( const TDesC8& aColor, TUint aFuelTankSize ); - ~DRaceCar(); - - public: // New functions - - TUint FuelTankSize() const; - - TUint FuelLeft() const; - - TUint AddFuel( TUint aFuel ); - - TInt Steer( TInt aAngle ); - - TInt Direction() const; - - TInt Accelerate( TUint aForce ); - - TUint Speed() const; - - void Brake( TUint aForce ); - - const TDesC8& Color() const; - - void ChangeColorL( const TDesC8& aNewColor ); - - private: // Constructors - - void ConstructL( const TDesC8& aColor ); - DRaceCar( TUint aFuelTankSize ); - - private: // Data - - TUint iFuelTankSize; - HBuf* iColor; - TUint iFuel; - TInt iDirection; - TUint iSpeed; - - private: // Test class - - SYMBIAN_UNIT_TEST_CLASS( UT_DRaceCar ) - }; - -#endif // DRACECAR_H diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwexamples/sutfwkernelexample/src/racecar.cpp --- a/symbianunittestfw/sutfw/sutfwexamples/sutfwkernelexample/src/racecar.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,162 +0,0 @@ -/* -* 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 "racecar.h" - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -DRaceCar::DRaceCar( const TDesC8& aColor, TUint aFuelTankSize ) - : iFuelTankSize( aFuelTankSize ) - { - iColor = HBuf8::New(aColor); - } - - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -DRaceCar::~DRaceCar() - { - delete iColor; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TUint DRaceCar::FuelTankSize() const - { - return iFuelTankSize; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TUint DRaceCar::FuelLeft() const - { - return iFuel; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TUint DRaceCar::AddFuel( TUint aFuel ) - { - TUint extraFuel = 0; - if ( aFuel > iFuelTankSize - iFuel ) - { - extraFuel = aFuel- ( iFuelTankSize - iFuel ); - iFuel = iFuelTankSize; - } - else - { - iFuel += aFuel; - } - return extraFuel; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TInt DRaceCar::Steer( TInt aAngle ) - { - if ( ( iDirection + aAngle ) < -KMaxTyreAngle || - ( iDirection + aAngle ) > KMaxTyreAngle ) - { - return KErrArgument; - } - iDirection += aAngle; - return KErrNone; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TInt DRaceCar::Direction() const - { - return iDirection; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TInt DRaceCar::Accelerate( TUint aForce ) - { - if ( iFuel == 0 ) - { - return KErrGeneral; - } - else - { - iFuel--; - iSpeed += aForce; - } - return KErrNone; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TUint DRaceCar::Speed() const - { - return iSpeed; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void DRaceCar::Brake( TUint aForce ) - { - if ( iSpeed < aForce ) - { - iSpeed = 0; - } - else - { - iSpeed -= aForce; - } - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -const TDesC8& DRaceCar::Color() const - { - return *iColor; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void DRaceCar::ChangeColorL( const TDesC8& aNewColor ) - { - HBuf* tmpColor = HBuf8::New(aNewColor); - delete iColor; - iColor = tmpColor; - } diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwexamples/sutfwkernelexample/tsrc/group/bld.inf --- a/symbianunittestfw/sutfw/sutfwexamples/sutfwkernelexample/tsrc/group/bld.inf Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -/* -* 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: Symbian Unit Testing framework -* -*/ - -PRJ_TESTMMPFILES -ut_kernelracecar.mmp diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwexamples/sutfwkernelexample/tsrc/group/ut_kernelracecar.mmp --- a/symbianunittestfw/sutfw/sutfwexamples/sutfwkernelexample/tsrc/group/ut_kernelracecar.mmp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -/* -* 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 "kernel/kern_ext.mmh" - -TARGET ut_racecar.ldd -TARGETTYPE ldd -UID 0x100000af 0x20022E77 - -MACRO SYMBIAN_UNIT_TEST - -SOURCEPATH ../../src -SOURCE racecar.cpp - -SOURCEPATH ../src -SOURCE ut_racecar.cpp - -USERINCLUDE ../inc -USERINCLUDE ../../inc - -OS_LAYER_SYSTEMINCLUDE -SYSTEMINCLUDE /epoc32/include/symbianunittest - -LIBRARY symbianunittestldd.lib - -start wins - -win32_library kernel32.lib -#if defined(VC32) -win32_library msvcrt.lib -#endif - - -end - -VENDORID 0x101FB657 - -CAPABILITY ALL - - diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwexamples/sutfwkernelexample/tsrc/inc/ut_racecar.h --- a/symbianunittestfw/sutfw/sutfwexamples/sutfwkernelexample/tsrc/inc/ut_racecar.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -/* -* 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 UT_RACECAR_H -#define UT_RACECAR_H - -// INCLUDES -#include -#include - -// FORWARD DECLARATIONS -class DRaceCar; - - -class DRaceCarTestFactory : public DSymbianUnitTestFactory - { - public: - DRaceCarTestFactory(const TDesC& aName) : - DSymbianUnitTestFactory(aName){}; - TInt Create(DLogicalChannelBase*& aChannel); - }; - -// CLASS DECLARATION -class UT_DRaceCar : public DSymbianUnitTest - { - public: // Constructors and destructor - - UT_DRaceCar(); - ~UT_DRaceCar(); - - protected: // From DSymbianUnitTest - - TInt Setup(); - TInt Teardown(); - void Construct(); - - protected: // Test functions - - TInt UT_Fuel(); - TInt UT_Steering(); - TInt UT_Speed(); - TInt UT_Color(); - TInt UT_Crash(); - - - private: // Data - - // The object to be tested as a member variable: - DRaceCar *iRaceCar; - }; - -#endif // UT_RACECAR_H diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwexamples/sutfwkernelexample/tsrc/src/ut_racecar.cpp --- a/symbianunittestfw/sutfw/sutfwexamples/sutfwkernelexample/tsrc/src/ut_racecar.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,210 +0,0 @@ -/* -* 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 -#include "ut_racecar.h" -#include "racecar.h" -#include - -_LIT( KDriveName, "ut_racecar.ldd"); -_LIT( KRed, "red" ); -_LIT( KBlue, "blue" ); -const TInt KInitialFuel( 100 ); - - -DECLARE_STANDARD_LDD() - { - //create factory here. - //Notice: the driver name should set to ldd name - return new DRaceCarTestFactory(KDriveName); - } - -TInt DRaceCarTestFactory::Create(DLogicalChannelBase*& aChannel) - { - aChannel=new UT_DRaceCar(); - return aChannel?KErrNone:KErrNoMemory; - } - -UT_DRaceCar::UT_DRaceCar() - { - Construct();//setup test cases - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_DRaceCar::Construct() - { - DEFINE_TEST_CLASS( UT_DRaceCar ) - - ADD_SUT( UT_Fuel ) - ADD_SUT( UT_Steering ) - ADD_SUT( UT_Speed ) - // Setup and teardown functions can be changed for each test function - // Usually this is not needed, but this is possible. - ADD_SUT_WITH_SETUP_AND_TEARDOWN( Setup, UT_Color, Teardown ) - - //ADD_SUT(UT_Crash ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -UT_DRaceCar::~UT_DRaceCar() - { - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TInt UT_DRaceCar::Setup() - { - iRaceCar = new DRaceCar( KRed, KInitialFuel ); - return KErrNone; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TInt UT_DRaceCar::Teardown() - { - delete iRaceCar; - iRaceCar = NULL; - return KErrNone; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TInt UT_DRaceCar::UT_Fuel() - { - Kern::Printf("test case UT_Fuel"); - - // Test the initial fuel - SUT_ASSERT_EQUALS( KInitialFuel, iRaceCar->FuelTankSize() ) - SUT_ASSERT_EQUALS( 0, iRaceCar->FuelLeft() ) - - // Add a proper amount of fuel - SUT_ASSERT_EQUALS( 0, iRaceCar->AddFuel( KInitialFuel ) ) - SUT_ASSERT_EQUALS( KInitialFuel, iRaceCar->FuelLeft() ) - - // Add too much fuel - SUT_ASSERT_EQUALS( 2, iRaceCar->AddFuel( 1 ) ) //expect to leave - SUT_ASSERT_EQUALS( KInitialFuel, iRaceCar->FuelLeft() ) - return KErrNone; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TInt UT_DRaceCar::UT_Steering() - { - Kern::Printf("test case UT_Steering"); - // Try to steer beyond the allowed values - SUT_ASSERT( iRaceCar->Steer( -( KMaxTyreAngle + 1 ) ) != KErrNone ) - SUT_ASSERT_EQUALS( 0, iRaceCar->Direction() ) - SUT_ASSERT( iRaceCar->Steer( KMaxTyreAngle + 1 ) != KErrNone ) - SUT_ASSERT_EQUALS( 0, iRaceCar->Direction() ) - - // Steer with the an allowed value - SUT_ASSERT_EQUALS( KErrNone, iRaceCar->Steer( KMaxTyreAngle ) ) - SUT_ASSERT_EQUALS( KMaxTyreAngle, iRaceCar->Direction() ) - - // Try beyond the allowed value - SUT_ASSERT( iRaceCar->Steer( 1 ) != KErrNone ) - SUT_ASSERT_EQUALS( KMaxTyreAngle, iRaceCar->Direction() ) - - // Steer to the opposite maximum - SUT_ASSERT_EQUALS( KErrNone, iRaceCar->Steer( -2 * KMaxTyreAngle ) ) - SUT_ASSERT_EQUALS( -KMaxTyreAngle, iRaceCar->Direction() ) - - // Try beyond the allowed value - SUT_ASSERT( iRaceCar->Steer( -1 ) != KErrNone ) - SUT_ASSERT_EQUALS( -KMaxTyreAngle, iRaceCar->Direction() ) - return KErrNone; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TInt UT_DRaceCar::UT_Speed() - { - Kern::Printf("test case UT_Speed"); - // Try to accelerate without fuel - SUT_ASSERT_EQUALS( 0, iRaceCar->Speed() ) - SUT_ASSERT( iRaceCar->Accelerate( 1 ) != KErrNone ) - - // Add fuel and accelerate - iRaceCar->AddFuel( 2 ); - SUT_ASSERT_EQUALS( 2, iRaceCar->FuelLeft() ) - SUT_ASSERT_EQUALS( KErrNone, iRaceCar->Accelerate( 100 ) ) - SUT_ASSERT_EQUALS( 100, iRaceCar->Speed() ) - SUT_ASSERT_EQUALS( 1, iRaceCar->FuelLeft() ) - SUT_ASSERT_EQUALS( KErrNone, iRaceCar->Accelerate( 50 ) ) - SUT_ASSERT_EQUALS( 150, iRaceCar->Speed() ) - SUT_ASSERT_EQUALS( 0, iRaceCar->FuelLeft() ) - - // Try braking - iRaceCar->Brake( 70 ); - SUT_ASSERT_EQUALS( 80, iRaceCar->Speed() ) - iRaceCar->Brake( 90 ); - SUT_ASSERT_EQUALS( 0, iRaceCar->Speed() ) - return KErrNone; - } - - -TInt UT_DRaceCar::UT_Color() - { - Kern::Printf("test case UT_Color"); - // Check the initial color - SUT_ASSERT_EQUALS( KRed, iRaceCar->Color() ) - - // Try to paint the car, color allowed - iRaceCar->ChangeColorL( KBlue ); - SUT_ASSERT_EQUALS( KBlue, iRaceCar->Color() ) - -//leave assertion is not support in kernel test -// SUT_ASSERT_LEAVE( iRaceCar->ChangeColorL( KNullDesC ) ) -// -// SUT_ASSERT_LEAVE_WITH( -// iRaceCar->ChangeColorL( KNullDesC ), KErrArgument ) - return KErrNone; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TInt UT_DRaceCar::UT_Crash() - { - //the car is totaled (: - Kern::Printf("test case UT_Crash enter"); - -// _LIT( KPanicString, "kkkkkkkkkkkk"); -// TBufC8<3> buf( KPanicString ); - - Kern::PanicCurrentThread(_L("Crash"), -100); - //Kern::Printf("test case UT_Crash exits"); - return KErrNone; - } diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwexamples/sutfwracecarexample/inc/racecar.h --- a/symbianunittestfw/sutfw/sutfwexamples/sutfwracecarexample/inc/racecar.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ -/* -* 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 CRACECAR_H -#define CRACECAR_H - -// INCLUDES -#include -#include - -// CONSTANTS -const TInt KMaxTyreAngle( 45 ); - -// CLASS DECLARATION -class CRaceCar : public CBase - { - public: // Constructors and Destructor - - static CRaceCar* NewL( const TDesC& aColor, TUint aFuelTankSize ); - static CRaceCar* NewLC( const TDesC& aColor, TUint aFuelTankSize ); - ~CRaceCar(); - - public: // New functions - - TUint FuelTankSize() const; - - TUint FuelLeft() const; - - TUint AddFuel( TUint aFuel ); - - TInt Steer( TInt aAngle ); - - TInt Direction() const; - - TInt Accelerate( TUint aForce ); - - TUint Speed() const; - - void Brake( TUint aForce ); - - const TDesC& Color() const; - - void ChangeColorL( const TDesC& aNewColor ); - - private: // Constructors - - void ConstructL( const TDesC& aColor ); - CRaceCar( TUint aFuelTankSize ); - - private: // Data - - TUint iFuelTankSize; - HBufC* iColor; - TUint iFuel; - TInt iDirection; - TUint iSpeed; - - private: // Test class - - SYMBIAN_UNIT_TEST_CLASS( UT_CRaceCar ) - }; - -#endif // CRACECAR_H diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwexamples/sutfwracecarexample/src/racecar.cpp --- a/symbianunittestfw/sutfw/sutfwexamples/sutfwracecarexample/src/racecar.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,194 +0,0 @@ -/* -* 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 "racecar.h" - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CRaceCar* CRaceCar::NewL( const TDesC& aColor, TUint aFuelTankSize ) - { - CRaceCar* self = NewLC( aColor, aFuelTankSize ); - CleanupStack::Pop( self ); - return self; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CRaceCar* CRaceCar::NewLC( const TDesC& aColor, TUint aFuelTankSize ) - { - CRaceCar* self = new( ELeave )CRaceCar( aFuelTankSize ); - CleanupStack::PushL( self ); - self->ConstructL( aColor ); - return self; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CRaceCar::CRaceCar( TUint aFuelTankSize ) - : iFuelTankSize( aFuelTankSize ) - { - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CRaceCar::ConstructL( const TDesC& aColor ) - { - iColor = aColor.AllocL(); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CRaceCar::~CRaceCar() - { - delete iColor; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TUint CRaceCar::FuelTankSize() const - { - return iFuelTankSize; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TUint CRaceCar::FuelLeft() const - { - return iFuel; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TUint CRaceCar::AddFuel( TUint aFuel ) - { - TUint extraFuel = 0; - if ( aFuel > iFuelTankSize - iFuel ) - { - extraFuel = aFuel- ( iFuelTankSize - iFuel ); - iFuel = iFuelTankSize; - } - else - { - iFuel += aFuel; - } - return extraFuel; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TInt CRaceCar::Steer( TInt aAngle ) - { - if ( ( iDirection + aAngle ) < -KMaxTyreAngle || - ( iDirection + aAngle ) > KMaxTyreAngle ) - { - return KErrArgument; - } - iDirection += aAngle; - return KErrNone; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TInt CRaceCar::Direction() const - { - return iDirection; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TInt CRaceCar::Accelerate( TUint aForce ) - { - if ( iFuel == 0 ) - { - return KErrGeneral; - } - else - { - iFuel--; - iSpeed += aForce; - } - return KErrNone; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TUint CRaceCar::Speed() const - { - return iSpeed; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CRaceCar::Brake( TUint aForce ) - { - if ( iSpeed < aForce ) - { - iSpeed = 0; - } - else - { - iSpeed -= aForce; - } - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -const TDesC& CRaceCar::Color() const - { - return *iColor; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CRaceCar::ChangeColorL( const TDesC& aNewColor ) - { - __ASSERT_ALWAYS ( aNewColor.Length() > 0, User::Leave( KErrArgument ) ); - - HBufC* tmpColor = aNewColor.AllocL(); - delete iColor; - iColor = tmpColor; - } diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwexamples/sutfwracecarexample/tsrc/BWINS/ut_racecarU.DEF --- a/symbianunittestfw/sutfw/sutfwexamples/sutfwracecarexample/tsrc/BWINS/ut_racecarU.DEF Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -EXPORTS - ?CreateTestL@@YAPAVMSymbianUnitTestInterface@@XZ @ 1 NONAME ; class MSymbianUnitTestInterface * CreateTestL(void) - diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwexamples/sutfwracecarexample/tsrc/EABI/ut_racecarU.DEF --- a/symbianunittestfw/sutfw/sutfwexamples/sutfwracecarexample/tsrc/EABI/ut_racecarU.DEF Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -EXPORTS - _Z11CreateTestLv @ 1 NONAME - _ZTI11UT_CRaceCar @ 2 NONAME - _ZTI8CRaceCar @ 3 NONAME - _ZTV11UT_CRaceCar @ 4 NONAME - _ZTV8CRaceCar @ 5 NONAME - diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwexamples/sutfwracecarexample/tsrc/group/bld.inf --- a/symbianunittestfw/sutfw/sutfwexamples/sutfwracecarexample/tsrc/group/bld.inf Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -/* -* 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: Symbian Unit Testing framework -* -*/ - -PRJ_TESTMMPFILES -ut_racecar.mmp diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwexamples/sutfwracecarexample/tsrc/group/ut_racecar.mmp --- a/symbianunittestfw/sutfw/sutfwexamples/sutfwracecarexample/tsrc/group/ut_racecar.mmp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -/* -* 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: -* -*/ - -TARGET ut_racecar.dll -TARGETTYPE dll -UID 0x20022E76 0x20022E76 - -MACRO SYMBIAN_UNIT_TEST - -SOURCEPATH ../../src -SOURCE racecar.cpp - -SOURCEPATH ../src -SOURCE dllEntry.cpp -SOURCE ut_racecar.cpp - -USERINCLUDE ../inc -USERINCLUDE ../../inc - -OS_LAYER_SYSTEMINCLUDE_SYMBIAN - -LIBRARY euser.lib -LIBRARY symbianunittestfw.lib - -VENDORID 0x101FB657 - -CAPABILITY ALL -TCB - - diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwexamples/sutfwracecarexample/tsrc/inc/ut_racecar.h --- a/symbianunittestfw/sutfw/sutfwexamples/sutfwracecarexample/tsrc/inc/ut_racecar.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -/* -* 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 UT_RACECAR_H -#define UT_RACECAR_H - -// INCLUDES -#include - -// FORWARD DECLARATIONS -class CRaceCar; - -// CLASS DECLARATION -class UT_CRaceCar : public CSymbianUnitTest - { - public: // Constructors and destructor - - static UT_CRaceCar* NewL(); - static UT_CRaceCar* NewLC(); - ~UT_CRaceCar(); - - protected: // From CSymbianUnitTest - - void SetupL(); - void Teardown(); - - protected: // Test functions - - void UT_FuelL(); - void UT_SteeringL(); - void UT_SpeedL(); - void UT_ColorL(); - void UT_TimeoutL(); - void UT_CrashL(); - void UT_QuitL(); - - private: // Contructors - - UT_CRaceCar(); - void ConstructL(); - - private: // Data - - // The object to be tested as a member variable: - CRaceCar *iRaceCar; - }; - -#endif // UT_RACECAR_H diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwexamples/sutfwracecarexample/tsrc/src/dllentry.cpp --- a/symbianunittestfw/sutfw/sutfwexamples/sutfwracecarexample/tsrc/src/dllentry.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -/* -* 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 "ut_racecar.h" -#include - - -// Exactly one exported function returning -// the pointer to the suite of tests for the SymbianUnit framework. -// -EXPORT_C MSymbianUnitTestInterface* CreateTestL() - { - CSymbianUnitTestSuite* testSuite = - CSymbianUnitTestSuite::NewLC( _L("ut_racecar") ); - - testSuite->AddL( UT_CRaceCar::NewLC() ); - CleanupStack::Pop(); - - // Add more tests to the test suite here when testing multiple classes - - CleanupStack::Pop( testSuite ); - return testSuite; - } - - diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwexamples/sutfwracecarexample/tsrc/src/ut_racecar.cpp --- a/symbianunittestfw/sutfw/sutfwexamples/sutfwracecarexample/tsrc/src/ut_racecar.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,232 +0,0 @@ -/* -* 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 "ut_racecar.h" -#include "racecar.h" -#include - -_LIT( KRed, "red" ); -_LIT( KBlue, "blue" ); -const TInt KInitialFuel( 100 ); - - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -UT_CRaceCar* UT_CRaceCar::NewL() - { - UT_CRaceCar* self = UT_CRaceCar::NewLC(); - CleanupStack::Pop( self ); - return self; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -UT_CRaceCar* UT_CRaceCar::NewLC() - { - UT_CRaceCar* self = new( ELeave )UT_CRaceCar(); - CleanupStack::PushL( self ); - self->ConstructL(); - return self; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -UT_CRaceCar::UT_CRaceCar() - { - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CRaceCar::ConstructL() - { - BASE_CONSTRUCT - - DEFINE_TEST_CLASS( UT_CRaceCar ) - - ADD_SUT( UT_FuelL ) - ADD_SUT( UT_SteeringL ) - ADD_SUT( UT_SpeedL ) - // Setup and teardown functions can be changed for each test function - // Usually this is not needed, but this is possible. - ADD_SUT_WITH_SETUP_AND_TEARDOWN( SetupL, UT_ColorL, Teardown ) - - ADD_SUT( UT_TimeoutL ) - ADD_SUT(UT_CrashL ) - ADD_SUT(UT_QuitL ) - - - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -UT_CRaceCar::~UT_CRaceCar() - { - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void UT_CRaceCar::SetupL() - { - iRaceCar = CRaceCar::NewL( KRed, KInitialFuel ); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void UT_CRaceCar::Teardown() - { - delete iRaceCar; - iRaceCar = NULL; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void UT_CRaceCar::UT_FuelL() - { - // Test the initial fuel - SUT_ASSERT_EQUALS( KInitialFuel, iRaceCar->FuelTankSize() ) - SUT_ASSERT_EQUALS( 0, iRaceCar->FuelLeft() ) - - // Add a proper amount of fuel - SUT_ASSERT_EQUALS( 0, iRaceCar->AddFuel( KInitialFuel ) ) - SUT_ASSERT_EQUALS( KInitialFuel, iRaceCar->FuelLeft() ) - - // Add too much fuel - SUT_ASSERT_EQUALS( 2, iRaceCar->AddFuel( 1 ) ) //expect to leave - SUT_ASSERT_EQUALS( KInitialFuel, iRaceCar->FuelLeft() ) - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void UT_CRaceCar::UT_SteeringL() - { - // Try to steer beyond the allowed values - SUT_ASSERT( iRaceCar->Steer( -( KMaxTyreAngle + 1 ) ) != KErrNone ) - SUT_ASSERT_EQUALS( 0, iRaceCar->Direction() ) - SUT_ASSERT( iRaceCar->Steer( KMaxTyreAngle + 1 ) != KErrNone ) - SUT_ASSERT_EQUALS( 0, iRaceCar->Direction() ) - - // Steer with the an allowed value - SUT_ASSERT_EQUALS( KErrNone, iRaceCar->Steer( KMaxTyreAngle ) ) - SUT_ASSERT_EQUALS( KMaxTyreAngle, iRaceCar->Direction() ) - - // Try beyond the allowed value - SUT_ASSERT( iRaceCar->Steer( 1 ) != KErrNone ) - SUT_ASSERT_EQUALS( KMaxTyreAngle, iRaceCar->Direction() ) - - // Steer to the opposite maximum - SUT_ASSERT_EQUALS( KErrNone, iRaceCar->Steer( -2 * KMaxTyreAngle ) ) - SUT_ASSERT_EQUALS( -KMaxTyreAngle, iRaceCar->Direction() ) - - // Try beyond the allowed value - SUT_ASSERT( iRaceCar->Steer( -1 ) != KErrNone ) - SUT_ASSERT_EQUALS( -KMaxTyreAngle, iRaceCar->Direction() ) - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void UT_CRaceCar::UT_SpeedL() - { - // Try to accelerate without fuel - SUT_ASSERT_EQUALS( 0, iRaceCar->Speed() ) - SUT_ASSERT( iRaceCar->Accelerate( 1 ) != KErrNone ) - - // Add fuel and accelerate - iRaceCar->AddFuel( 2 ); - SUT_ASSERT_EQUALS( 2, iRaceCar->FuelLeft() ) - SUT_ASSERT_EQUALS( KErrNone, iRaceCar->Accelerate( 100 ) ) - SUT_ASSERT_EQUALS( 100, iRaceCar->Speed() ) - SUT_ASSERT_EQUALS( 1, iRaceCar->FuelLeft() ) - SUT_ASSERT_EQUALS( KErrNone, iRaceCar->Accelerate( 50 ) ) - SUT_ASSERT_EQUALS( 150, iRaceCar->Speed() ) - SUT_ASSERT_EQUALS( 0, iRaceCar->FuelLeft() ) - - // Try braking - iRaceCar->Brake( 70 ); - SUT_ASSERT_EQUALS( 80, iRaceCar->Speed() ) - iRaceCar->Brake( 90 ); - SUT_ASSERT_EQUALS( 0, iRaceCar->Speed() ) - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void UT_CRaceCar::UT_ColorL() - { - // Check the initial color - SUT_ASSERT_EQUALS( KRed, iRaceCar->Color() ) - - // Try to paint the car, color allowed - iRaceCar->ChangeColorL( KBlue ); - SUT_ASSERT_EQUALS( KBlue, iRaceCar->Color() ) - - // Try to paint the car, color not allowed - SUT_ASSERT_LEAVE( iRaceCar->ChangeColorL( KNullDesC ) ) - - SUT_ASSERT_LEAVE_WITH( - iRaceCar->ChangeColorL( KNullDesC ), KErrArgument ) - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void UT_CRaceCar::UT_TimeoutL() - { - //the car is too slow (: - User::After(7 * 1000000); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void UT_CRaceCar::UT_CrashL() - { - //the car is totaled (: - User::Panic(_L("Crash"), -100); - } - - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void UT_CRaceCar::UT_QuitL() - { - User::Leave(-100); - } diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/group/bld.inf --- a/symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/group/bld.inf Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +0,0 @@ -/* -* 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: Symbian Unit Testing framework -* -*/ - -PRJ_MMPFILES -symbianunittestconsoleui.mmp - -PRJ_TESTMMPFILES - #include "../tsrc/group/bld.inf" diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/group/symbianunittestconsoleui.mmp --- a/symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/group/symbianunittestconsoleui.mmp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -/* -* 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: -* -*/ - -TARGET symbianunittest.exe -TARGETTYPE exe -UID 0x1000008d 0x20022E75 - -SOURCEPATH ../src -SOURCE symbianunittestconsoleui.cpp -SOURCE symbianunittestcommandlineparser.cpp - -USERINCLUDE ../inc -USERINCLUDE ../../../inc - -OS_LAYER_SYSTEMINCLUDE_SYMBIAN - -LIBRARY euser.lib -LIBRARY efsrv.lib -LIBRARY bafl.lib -LIBRARY inetprotutil.lib -LIBRARY symbianunittestfw.lib - -VENDORID 0x101FB657 - -CAPABILITY ALL -TCB -DRM diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/inc/symbianunittestcommandlineparser.h --- a/symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/inc/symbianunittestcommandlineparser.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -/* -* 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 SYMBIANUNITTESTCOMMANDLINEPARSER_H -#define SYMBIANUNITTESTCOMMANDLINEPARSER_H - -// INCLUDES -#include -#include -#include -#include - -// CLASS DECLARATION -class CSymbianUnitTestCommandLineParser : public CBase - { - public: // Constructors and destructor - - static CSymbianUnitTestCommandLineParser* NewLC(); - static CSymbianUnitTestCommandLineParser* NewL(); - ~CSymbianUnitTestCommandLineParser(); - - public: // New functions - - TBool ShowHelp() const; - const MDesCArray& TestDllNames() const; - const CDesCArray& TestCaseNames() const; - TBool MemoryAllocationFailureSimulation() const; - TBool Background() const; - const TDesC& OutputFileName() const; - const TDesC& OutputFormat() const; - TInt Timeout() const; - TBool PromptUser() const; - - private: // Constructors - - void ConstructL(); - CSymbianUnitTestCommandLineParser(); - - private: // New functions - - void SetOutputFormatL(); - void SetTimeoutL(); - void SetTestDllNamesL(); - void SetTestCaseNamesL(); - TBool FindArgument( - const TDesC& aKey, - const TDesC& aShortKey, - TPtrC& aValue ); - - private: // Data - - CCommandLineArguments* iArguments; - TBool iShowHelp; - CDesCArray* iTestDllNames; - CDesCArray* iTestCaseNames; - TBool iAllocFailureSimulation; - HBufC* iOutputFormat; - TBool iNoPrompt; - TBool iBackground; - TInt iTimeout; - - private: // Test - - SYMBIAN_UNIT_TEST_CLASS( UT_CSymbianUnitTestCommandLineParser ) - }; - -#endif // SYMBIANUNITTESTCOMMANDLINEPARSER_H diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/inc/symbianunittestconsoleui.h --- a/symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/inc/symbianunittestconsoleui.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -/* -* 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 SYMBIANUNITTESTCONSOLEUIMAIN_H -#define SYMBIANUNITTESTCONSOLEUIMAIN_H - -// INCLUDES -#include "symbianunittestuicallback.h" -#include -#include - -// FORWARD DECLARATIONS -class CSymbianUnitTestRunner; -class CSymbianUnitTestCommandLineParser; - -// CLASS DECLARATION -class CSymbianUnitTestConsoleUi : - public CActive, - public MSymbianUnitTestUiCallBack - { - public: // Constructors and destructor - - static CSymbianUnitTestConsoleUi* NewLC(); - static CSymbianUnitTestConsoleUi* NewL(); - ~CSymbianUnitTestConsoleUi(); - - protected: // From CActive - - void RunL(); - void DoCancel(); - - public: // From MSymbianUnitTestUiCallBack - - void InfoMsg( const TDesC& aMessage ); - void InfoMsg( const TDesC& aFormat, const TDesC& aMessage ); - void TestPass(const TDesC& aTestCaseName); - void TestFailed(const TDesC& aTestCaseName, const TDesC8& aErrMsg); - - private: // Constructors - - CSymbianUnitTestConsoleUi(); - void ConstructL(); - - private: // New functions - - void PrintAllocFailureSimulationText(); - void IncrementExecutedTestsCount(); - - private: // Data - - CConsoleBase* iConsole; - CSymbianUnitTestCommandLineParser* iCommandLineParser; - CSymbianUnitTestRunner* iTestRunner; - TInt iExecutedTestCount; - TInt iTestCount; - }; - -// Local functions: -LOCAL_C void MainL(); - -#endif // SYMBIANUNITTESTCONSOLEUIMAIN_H diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/inc/symbianunittestdllnameparser.h --- a/symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/inc/symbianunittestdllnameparser.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -/* -* 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 SYMBIANUNITTESTDLLNAMEPARSER_H -#define SYMBIANUNITTESTDLLNAMEPARSER_H - -// INCLUDES -#include - -// CLASS DECLARATION -class TSymbianUnitTestDllNameParser : public TDelimitedParserBase16 - { - public: // New functions - - inline TSymbianUnitTestDllNameParser(); - inline void Parse( const TDesC& aValue ); - }; - -#include "symbianunittestdllnameparser.inl" - -#endif // SYMBIANUNITTESTDLLNAMEPARSER_H - -// End of File diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/inc/symbianunittestdllnameparser.inl --- a/symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/inc/symbianunittestdllnameparser.inl Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -/* -* 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 SYMBIANUNITTESTDLLNAMEPARSER_INL -#define SYMBIANUNITTESTDLLNAMEPARSER_INL - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -inline TSymbianUnitTestDllNameParser::TSymbianUnitTestDllNameParser() - : TDelimitedParserBase16() - { - SetDelimiter(','); - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -inline void TSymbianUnitTestDllNameParser::Parse( const TDesC& aValue ) - { - TDelimitedParserBase16::Parse(aValue); - } - -#endif // SYMBIANUNITTESTDLLNAMEPARSER_INL - -// End of File diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/src/symbianunittestcommandlineparser.cpp --- a/symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/src/symbianunittestcommandlineparser.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,316 +0,0 @@ -/* -* 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 "symbianunittestcommandlineparser.h" -#include "symbianunittestdllnameparser.h" -#include "symbianunittestrunner.h" - -_LIT( KHelpKey, "-help" ); -_LIT( KHelpKeyShort, "-h" ); -_LIT( KTestsKey, "-tests=" ); -_LIT( KTestsKeyShort, "-t=" ); -_LIT( KTestCasesKey, "-cases=" ); -_LIT( KTestCasesKeyShort, "-c=" ); -_LIT( KAllocKey, "-alloc" ); -_LIT( KAllocKeyShort, "-a" ); -_LIT( KBackgroundKey, "-background" ); -_LIT( KBackgroundKeyShort, "-b" ); -_LIT( KOutputKey, "-output=" ); -_LIT( KOutputKeyShort, "-o=" ); -_LIT( KNoPromptKey, "-noprompt" ); -_LIT( KTimeoutKey, "-timeout=" ); -_LIT( KTimeoutKeyShort, "-to=" ); - - -_LIT( KOutputFileName, "SymbianUnitTestResults" ); -_LIT( KDefaultOutputFormat, "html" ); - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestCommandLineParser* CSymbianUnitTestCommandLineParser::NewLC() - { - CSymbianUnitTestCommandLineParser* self = - new( ELeave )CSymbianUnitTestCommandLineParser(); - CleanupStack::PushL( self ); - self->ConstructL(); - return self; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestCommandLineParser* CSymbianUnitTestCommandLineParser::NewL() - { - CSymbianUnitTestCommandLineParser* self = - CSymbianUnitTestCommandLineParser::NewLC(); - CleanupStack::Pop( self ); - return self; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestCommandLineParser::CSymbianUnitTestCommandLineParser() - : iBackground( EFalse ) - { - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestCommandLineParser::ConstructL() - { - iArguments = CCommandLineArguments::NewL(); - TPtrC dummy; - iShowHelp = FindArgument( KHelpKey, KHelpKeyShort, dummy ); - iAllocFailureSimulation = FindArgument( KAllocKey, KAllocKeyShort, dummy ); - iNoPrompt = FindArgument( KNoPromptKey, KNoPromptKey, dummy ); - iBackground = FindArgument( KBackgroundKey, KBackgroundKeyShort, dummy ); - SetOutputFormatL(); - SetTimeoutL(); - SetTestDllNamesL(); - SetTestCaseNamesL(); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestCommandLineParser::~CSymbianUnitTestCommandLineParser() - { - delete iTestDllNames; - delete iTestCaseNames; - delete iOutputFormat; - delete iArguments; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TBool CSymbianUnitTestCommandLineParser::ShowHelp() const - { - return iShowHelp; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -const MDesCArray& CSymbianUnitTestCommandLineParser::TestDllNames() const - { - return *iTestDllNames; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -const CDesCArray& CSymbianUnitTestCommandLineParser::TestCaseNames() const - { - return *iTestCaseNames; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TBool CSymbianUnitTestCommandLineParser::MemoryAllocationFailureSimulation() const - { - return iAllocFailureSimulation; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TBool CSymbianUnitTestCommandLineParser::Background() const - { - return iBackground; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -const TDesC& CSymbianUnitTestCommandLineParser::OutputFileName() const - { - return KOutputFileName; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -const TDesC& CSymbianUnitTestCommandLineParser::OutputFormat() const - { - return *iOutputFormat; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TInt CSymbianUnitTestCommandLineParser::Timeout() const - { - return iTimeout; - } - - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TBool CSymbianUnitTestCommandLineParser::PromptUser() const - { - return !iNoPrompt; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestCommandLineParser::SetOutputFormatL() - { - HBufC* outputFormat = NULL; - TPtrC outputFormatPtr; - TBool found = EFalse; - found = FindArgument( KOutputKey, KOutputKeyShort, outputFormatPtr ); - if ( found ) - { - outputFormat = outputFormatPtr.AllocL(); - } - else - { - outputFormat = KDefaultOutputFormat().AllocL(); - } - delete iOutputFormat; - iOutputFormat = outputFormat; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestCommandLineParser::SetTimeoutL() - { - iTimeout = KSymbianUnitTestDefaultTimeout; //use default - TPtrC timeoutPtr; - TBool hasTimeout = FindArgument( KTimeoutKey, KTimeoutKeyShort, timeoutPtr ); - if ( hasTimeout) - { - TLex timeoutLex(timeoutPtr); - TInt timeout; - TInt ret = timeoutLex.Val(timeout); - hasTimeout = ( ret == KErrNone && timeout >= 0 ); - if ( hasTimeout ) - { - iTimeout = timeout; - } - } - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestCommandLineParser::SetTestDllNamesL() - { - CDesCArray* testDllNames = new( ELeave )CDesCArrayFlat( 1 ); - CleanupStack::PushL( testDllNames ); - TPtrC testDllNamesPtr; - TBool found = EFalse; - found = FindArgument( KTestsKey, KTestsKeyShort, testDllNamesPtr ); - if ( found ) - { - TSymbianUnitTestDllNameParser parser; - parser.Parse( testDllNamesPtr ); - TPtrC testDllNamePtr; - TBool hasNext = EFalse; - hasNext = ( parser.GetNext( testDllNamePtr ) == KErrNone ); - while ( hasNext ) - { - testDllNames->AppendL( testDllNamePtr ); - hasNext = ( parser.GetNext( testDllNamePtr ) == KErrNone ); - } - } - iShowHelp = ( testDllNames->Count() == 0 ); - CleanupStack::Pop( testDllNames ); - delete iTestDllNames; - iTestDllNames = testDllNames; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestCommandLineParser::SetTestCaseNamesL() - { - CDesCArray* testCaseNames = new( ELeave )CDesCArrayFlat( 1 ); - CleanupStack::PushL( testCaseNames ); - TPtrC testCaseNamesPtr; - TBool found = EFalse; - found = FindArgument( KTestCasesKey, KTestCasesKeyShort, testCaseNamesPtr ); - if ( found ) - { - //reuse the testdll parser here for case names - TSymbianUnitTestDllNameParser parser; - parser.Parse( testCaseNamesPtr ); - TPtrC testCaseNamePtr; - TBool hasNext = EFalse; - hasNext = ( parser.GetNext( testCaseNamePtr ) == KErrNone ); - while ( hasNext ) - { - testCaseNames->AppendL( testCaseNamePtr ); - hasNext = ( parser.GetNext( testCaseNamePtr ) == KErrNone ); - } - } - CleanupStack::Pop( testCaseNames ); - delete iTestCaseNames; - iTestCaseNames = testCaseNames; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -TBool CSymbianUnitTestCommandLineParser::FindArgument( - const TDesC& aKey, - const TDesC& aShortKey, - TPtrC& aValue ) - { - TBool found( EFalse ); - for ( TInt i = 0; i < iArguments->Count(); i++ ) - { - TPtrC arg( iArguments->Arg( i ) ); - if ( arg.FindF( aKey ) == 0 || arg.FindF( aShortKey ) == 0 ) - { - found = ETrue; - TInt equalsPos = arg.Locate( '=' ); - if ( equalsPos > 0 & equalsPos < arg.Length() - 1 ) - { - aValue.Set( arg.Mid( equalsPos + 1 ) ); - } - } - } - return found; - } diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/src/symbianunittestconsoleui.cpp --- a/symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/src/symbianunittestconsoleui.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,320 +0,0 @@ -/* -* 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 - -#include "symbianunittestconsoleui.h" -#include "symbianunittestcommandlineparser.h" -#include "symbianunittestrunner.h" -#include "symbianunittestversion.h" - -_LIT( KTitleTxt, "\n==== SymbianUnit v%d.%d.%d ====\n\n" ); -_LIT( KAllocOnTxt, " Alloc: ON\n\n" ); -_LIT( KAllocOffTxt, " Alloc: OFF\n\n" ); -_LIT( KExecutingTestsTxt, " Executing...\n" ); -_LIT( KTestRunnerFailedTxt, " Test run failed!\n Reason: %d\n" ); -_LIT( KNoTestsFoundTxt, " No tests found!\n" ); -_LIT( KTestsExecutedTxt, " Executed: %d / %d\n" ); -_LIT( KPassedTestsTxt, " Passed: %d\n" ); -//_LIT( KFailedTestsTxt, " Failed: %d\n" ); -_LIT( KFailedTestsTxt2, " Failed: %S\n" ); -_LIT( KWindowName, "SymbianUnit" ); -_LIT( KSymbianUnitTestPanic, "SymbianUnit creation" ); -_LIT( KPressAnyKeyTxt, "\n==[ press any key ]==\n " ); - -_LIT( KHelpTxt, -"Allowed arguments:\n\n\ --tests|t=\n\ --cases|c=\n\ --alloc|a\n\ --background|b\n\ --help|h\n\ --output|o=\n\ --timeout|to\n\ --noprompt\n" ); - - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -GLDEF_C TInt E32Main() - { - //__UHEAP_MARK; - CTrapCleanup* cleanup = CTrapCleanup::New(); - TRAPD( err, MainL() ); - __ASSERT_ALWAYS( - err == KErrNone, User::Panic( KSymbianUnitTestPanic, err ) ); - delete cleanup; - //__UHEAP_MARKEND; -// User::Heap().Reset(); - return err; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -LOCAL_C void MainL() - { - // install an active scheduler - CActiveScheduler* scheduler = new( ELeave )CActiveScheduler; - CActiveScheduler::Install( scheduler ); - CleanupStack::PushL( scheduler ); - - - CSymbianUnitTestConsoleUi* main = NULL; - - TRAPD( err, main = CSymbianUnitTestConsoleUi::NewL() ); - if ( err == KErrNone ) - { - CActiveScheduler::Start(); - } - - CleanupStack::Pop( scheduler ); - delete main; - delete scheduler; - // Do not delete console. It will check for memory leaks. - // This is not what is wanted if running tests without - // memory leak detection. - //delete console; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestConsoleUi* CSymbianUnitTestConsoleUi::NewLC() - { - CSymbianUnitTestConsoleUi* self = - new( ELeave )CSymbianUnitTestConsoleUi(); - CleanupStack::PushL( self ); - self->ConstructL(); - return self; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestConsoleUi* CSymbianUnitTestConsoleUi::NewL() - { - CSymbianUnitTestConsoleUi* self = - CSymbianUnitTestConsoleUi::NewLC(); - CleanupStack::Pop( self ); - return self; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestConsoleUi::CSymbianUnitTestConsoleUi() - : CActive( EPriorityStandard ) - { - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestConsoleUi::ConstructL() - { - User::SetJustInTime( EFalse ); // Do not stop on test case panics - iCommandLineParser = CSymbianUnitTestCommandLineParser::NewL(); - iTestRunner = CSymbianUnitTestRunner::NewL( *this ); - if( !iCommandLineParser->Background() ) - { - TSize size( KConsFullScreen, KConsFullScreen ); - iConsole = Console::NewL( KWindowName, size ); - RThread().SetPriority( EPriorityAbsoluteForeground ); - } - else - { - RThread().SetPriority( EPriorityAbsoluteBackground ); - } - - CActiveScheduler::Add( this ); - // Set ready to run immediately - TRequestStatus *status = &iStatus; - User::RequestComplete( status, KErrNone ); - SetActive (); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -CSymbianUnitTestConsoleUi::~CSymbianUnitTestConsoleUi() - { - Cancel(); - delete iTestRunner; - delete iCommandLineParser; - delete iConsole; - } - -// ----------------------------------------------------------------------------- -// From CActive -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestConsoleUi::RunL() - { - if (iCommandLineParser->Background()) - { - //run in background - TRAPD( err, - iTestRunner->ExecuteTestsL( - iCommandLineParser->TestDllNames(), - iCommandLineParser->MemoryAllocationFailureSimulation(), - iCommandLineParser->OutputFileName(), - iCommandLineParser->OutputFormat(), - iCommandLineParser->TestCaseNames(), - iCommandLineParser->Timeout()) ) - if ( err != KErrNone) - { - RDebug::Print( KTestRunnerFailedTxt, err ); - } - } - else - { - iConsole->Printf( KTitleTxt, SUT_MAJOR_VERSION, SUT_MINOR_VERSION, SUT_BUILD_VERSION); - if ( iCommandLineParser->ShowHelp() ) - { - InfoMsg( KHelpTxt ); - } - else - { - PrintAllocFailureSimulationText(); - InfoMsg( KExecutingTestsTxt ); - TRAPD(err, - iTestCount = iTestRunner->TestCountL( - iCommandLineParser->TestDllNames(), - iCommandLineParser->TestCaseNames())); - TRAP( err, - iTestRunner->ExecuteTestsL( - iCommandLineParser->TestDllNames(), - iCommandLineParser->MemoryAllocationFailureSimulation(), - iCommandLineParser->OutputFileName(), - iCommandLineParser->OutputFormat(), - iCommandLineParser->TestCaseNames(), - iCommandLineParser->Timeout()) ) - if ( err != KErrNone ) - { - iConsole->Printf( KTestRunnerFailedTxt, err ); - } - else - { - if ( iExecutedTestCount == 0 ) - { - InfoMsg( KNoTestsFoundTxt ); - } - } - } - if ( iCommandLineParser->PromptUser() ) - { - InfoMsg( KPressAnyKeyTxt ); - iConsole->Getch(); // get and ignore character - } - } - CActiveScheduler::Stop(); - } - -// ----------------------------------------------------------------------------- -// From CActive -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestConsoleUi::DoCancel() - { - } - -// ----------------------------------------------------------------------------- -// From MSymbianUnitTestUiCallBack -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestConsoleUi::InfoMsg( const TDesC& aMessage ) - { - iConsole->Printf( aMessage ); - } - -// ----------------------------------------------------------------------------- -// From MSymbianUnitTestUiCallBack -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestConsoleUi::InfoMsg( - const TDesC& aFormat, - const TDesC& aMessage ) - { - iConsole->Printf( aFormat, &aMessage ); - } - -// ----------------------------------------------------------------------------- -// From MSymbianUnitTestUiCallBack -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestConsoleUi::TestPass(const TDesC& /*aTestCaseName*/) - { - IncrementExecutedTestsCount(); - } - -void CSymbianUnitTestConsoleUi::TestFailed(const TDesC& /*aTestCaseName*/, const TDesC8& /*aErrMsg*/) - { - IncrementExecutedTestsCount(); - } - - -void CSymbianUnitTestConsoleUi::IncrementExecutedTestsCount() - { - if (iCommandLineParser->Background()) - { - return; - } - TPoint pos = iConsole->CursorPos(); - pos.iY -= 1; - if ( iExecutedTestCount > 0 ) - { - pos.iY -= 2; - } - iConsole->SetCursorPosAbs( pos ); - - iExecutedTestCount++; - iConsole->Printf( - KTestsExecutedTxt, iExecutedTestCount, iTestCount); - - TInt passedTestCount = iExecutedTestCount - iTestRunner->FailedTestCount(); - iConsole->Printf( KPassedTestsTxt, passedTestCount ); - - TInt count = iTestRunner->FailedTestCount(); - TBuf<10> txtCount; - txtCount.AppendFormat( _L("%d"), count ); - InfoMsg( KFailedTestsTxt2, txtCount ); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void CSymbianUnitTestConsoleUi::PrintAllocFailureSimulationText() - { - if ( iCommandLineParser->MemoryAllocationFailureSimulation() ) - { - InfoMsg( KAllocOnTxt ); - } - else - { - InfoMsg( KAllocOffTxt ); - } - } diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/tsrc/bwins/ut_symbianunittestconsoleuiu.def --- a/symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/tsrc/bwins/ut_symbianunittestconsoleuiu.def Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -EXPORTS - ?CreateTestL@@YAPAVMSymbianUnitTestInterface@@XZ @ 1 NONAME ; class MSymbianUnitTestInterface * CreateTestL(void) - diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/tsrc/eabi/ut_symbianunittestconsoleuiu.def --- a/symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/tsrc/eabi/ut_symbianunittestconsoleuiu.def Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -EXPORTS - _Z11CreateTestLv @ 1 NONAME - diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/tsrc/group/bld.inf --- a/symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/tsrc/group/bld.inf Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -/* -* 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: Symbian Unit Testing framework -* -*/ - -PRJ_TESTMMPFILES -ut_symbianunittestconsoleui.mmp diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/tsrc/group/ut_symbianunittestconsoleui.mmp --- a/symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/tsrc/group/ut_symbianunittestconsoleui.mmp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -/* -* 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: -* -*/ - -TARGET ut_symbianunittestconsoleui.dll -TARGETTYPE dll -NOEXPORTLIBRARY -UID 0x20022E76 0x20022E76 - -MACRO SYMBIAN_UNIT_TEST - -SOURCEPATH ../../src -SOURCE symbianunittestcommandlineparser.cpp - -SOURCEPATH ../src -SOURCE dllEntry.cpp -SOURCE ut_symbianunittestcommandlineparser.cpp -SOURCE commandlineargumentsstub.cpp - -USERINCLUDE ../inc -USERINCLUDE ../../inc -USERINCLUDE ../../../../inc - -OS_LAYER_SYSTEMINCLUDE_SYMBIAN - -LIBRARY euser.lib -LIBRARY bafl.lib -LIBRARY inetprotutil.lib -LIBRARY symbianunittestfw.lib - -VENDORID 0x101FB657 - -CAPABILITY ALL -TCB - - diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/tsrc/inc/bacline.h --- a/symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/tsrc/inc/bacline.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -// BACLINE.H -// -// Copyright (c) 1997-1999 Symbian Ltd. All rights reserved. -// - -/* -* 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: Stub for unit testing -* -*/ - -#ifndef BACLINESTUB_H -#define BACLINESTUB_H - -#include -#include - -class CCommandLineArguments : public CBase - { - public: - // construct/destruct - static CCommandLineArguments* NewLC(); - static CCommandLineArguments* NewL(); - ~CCommandLineArguments(); - // extract - TPtrC Arg(TInt aArg) const; - TInt Count() const; - - public: // For unit testing purposes, not in the real implementation - CDesCArray& Args(); - - private: - CCommandLineArguments(); - void ConstructL(); - - private: // For unit testing purposes, not in the real implementation - CDesCArray* iArgs; - }; - -#endif diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/tsrc/inc/ut_symbianunittestcommandlineparser.h --- a/symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/tsrc/inc/ut_symbianunittestcommandlineparser.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -/* -* 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 UT_SYMBIANUNITTESTCOMMANDLINEPARSER_H -#define UT_SYMBIANUNITTESTCOMMANDLINEPARSER_H - -// INCLUDES -#include - -// FORWARD DECLARATIONS -class CSymbianUnitTestCommandLineParser; - -// CLASS DECLARATION -class UT_CSymbianUnitTestCommandLineParser : public CSymbianUnitTest - { - public: // Constructors and destructor - - static UT_CSymbianUnitTestCommandLineParser* NewL(); - static UT_CSymbianUnitTestCommandLineParser* NewLC(); - ~UT_CSymbianUnitTestCommandLineParser(); - - protected: // Test functions - - void SetupL(); - void Teardown(); - void UT_SetOutputFormatL(); - void UT_SetTestDllNamesL(); - void UT_FindArgumentL(); - void UT_SetTimeoutL(); - void UT_SetTestCaseNamesL(); - - // new added. - void UT_TestCommandLineL(); - void LaunchExample( TInt aType ); - - private: // Contructors - - UT_CSymbianUnitTestCommandLineParser(); - void ConstructL(); - - private: // Data - - // The object to be tested as a member variable: - CSymbianUnitTestCommandLineParser* iParser; - }; - -#endif // UT_SYMBIANUNITTESTCOMMANDLINEPARSER_H diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/tsrc/src/commandlineargumentsstub.cpp --- a/symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/tsrc/src/commandlineargumentsstub.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,101 +0,0 @@ -/* -* 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 "bacline.h" - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -CCommandLineArguments* CCommandLineArguments::NewL() - { - CCommandLineArguments* self = - CCommandLineArguments::NewLC(); - CleanupStack::Pop( self ); - return self; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -CCommandLineArguments* CCommandLineArguments::NewLC() - { - CCommandLineArguments* self = - new( ELeave )CCommandLineArguments(); - CleanupStack::PushL( self ); - self->ConstructL(); - return self; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -CCommandLineArguments::CCommandLineArguments() - { - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CCommandLineArguments::ConstructL() - { - iArgs = new( ELeave )CDesCArrayFlat( 1 ); - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -CCommandLineArguments::~CCommandLineArguments() - { - delete iArgs; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -TPtrC CCommandLineArguments::Arg( TInt aArg ) const - { - TPtrC arg; - if ( aArg < iArgs->Count() ) - { - arg.Set( iArgs->MdcaPoint( aArg ) ); - } - return arg; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -TInt CCommandLineArguments::Count() const - { - return iArgs->Count(); - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -CDesCArray& CCommandLineArguments::Args() - { - return *iArgs; - } diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/tsrc/src/dllentry.cpp --- a/symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/tsrc/src/dllentry.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -/* -* 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 "ut_symbianunittestcommandlineparser.h" -#include - - -// Exactly one exported function returning -// the pointer to the suite of tests for the SymbianUnit framework. -// -EXPORT_C MSymbianUnitTestInterface* CreateTestL() - { - CSymbianUnitTestSuite* testSuite = - CSymbianUnitTestSuite::NewLC( _L("ut_consoleui") ); - - testSuite->AddL( UT_CSymbianUnitTestCommandLineParser::NewLC() ); - CleanupStack::Pop(); - - // Add more tests to the test suite here when testing multiple classes - - CleanupStack::Pop( testSuite ); - return testSuite; - } diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/tsrc/src/ut_symbianunittestcommandlineparser.cpp --- a/symbianunittestfw/sutfw/sutfwui/sutfwconsoleui/tsrc/src/ut_symbianunittestcommandlineparser.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,352 +0,0 @@ -/* -* 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 "ut_symbianunittestcommandlineparser.h" -#include "symbianunittestcommandlineparser.h" -#include - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -UT_CSymbianUnitTestCommandLineParser* UT_CSymbianUnitTestCommandLineParser::NewL() - { - UT_CSymbianUnitTestCommandLineParser* self = - UT_CSymbianUnitTestCommandLineParser::NewLC(); - CleanupStack::Pop( self ); - return self; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -UT_CSymbianUnitTestCommandLineParser* UT_CSymbianUnitTestCommandLineParser::NewLC() - { - UT_CSymbianUnitTestCommandLineParser* self = - new( ELeave )UT_CSymbianUnitTestCommandLineParser(); - CleanupStack::PushL( self ); - self->ConstructL(); - return self; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -UT_CSymbianUnitTestCommandLineParser::UT_CSymbianUnitTestCommandLineParser() - { - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTestCommandLineParser::ConstructL() - { - BASE_CONSTRUCT - - DEFINE_TEST_CLASS( UT_CSymbianUnitTestCommandLineParser ) - - ADD_SUT( UT_SetOutputFormatL ) - ADD_SUT( UT_SetTestDllNamesL ) - ADD_SUT( UT_FindArgumentL ) - ADD_SUT( UT_SetTimeoutL ) - ADD_SUT( UT_SetTestCaseNamesL ) - //ADD_SUT( UT_TestCommandLineL ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -UT_CSymbianUnitTestCommandLineParser::~UT_CSymbianUnitTestCommandLineParser() - { - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void UT_CSymbianUnitTestCommandLineParser::SetupL() - { - iParser = CSymbianUnitTestCommandLineParser::NewL(); - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void UT_CSymbianUnitTestCommandLineParser::Teardown() - { - delete iParser; - iParser = NULL; - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void UT_CSymbianUnitTestCommandLineParser::UT_SetOutputFormatL() - { - // Output format not found - _LIT( KDefaultOutputFormat, "html" ); - iParser->SetOutputFormatL(); - SUT_ASSERT_EQUALS( KDefaultOutputFormat, iParser->OutputFormat() ) - - // Output format found, long form - _LIT( KOutputFormatLong, "-output=xml" ); - iParser->iArguments->Args().AppendL( KOutputFormatLong ); - iParser->SetOutputFormatL(); - SUT_ASSERT_EQUALS( _L( "xml" ), iParser->OutputFormat() ) - - // Output format found, short form - _LIT( KOutputFormatShort, "-o=txt" ); - iParser->iArguments->Args().Reset(); - iParser->iArguments->Args().AppendL( KOutputFormatShort ); - iParser->SetOutputFormatL(); - SUT_ASSERT_EQUALS( _L( "txt" ), iParser->OutputFormat() ) - } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void UT_CSymbianUnitTestCommandLineParser::UT_SetTimeoutL() - { - // Default timeout. - iParser->iArguments->Args().Reset(); - iParser->SetTimeoutL(); - SUT_ASSERT_EQUALS( iParser->Timeout(), 30 ) - - // Set timeout=50, long form. - _LIT( KTimeoutLong, "-timeout=50" ); - iParser->iArguments->Args().Reset(); - iParser->iArguments->Args().AppendL( KTimeoutLong ); - iParser->SetTimeoutL(); - SUT_ASSERT_EQUALS( iParser->Timeout(), 50 ) - - // Set timeout=50, short form. - _LIT( KTimeoutShort, "-to=20" ); - iParser->iArguments->Args().Reset(); - iParser->iArguments->Args().AppendL( KTimeoutShort ); - iParser->SetTimeoutL(); - SUT_ASSERT_EQUALS( iParser->Timeout(), 20 ) - - // Set timeout to invalid value, long form. - _LIT( KInvalidTimeoutLong, "-timeout=-50" ); - iParser->iArguments->Args().Reset(); - iParser->iArguments->Args().AppendL( KInvalidTimeoutLong ); - iParser->SetTimeoutL(); - SUT_ASSERT_EQUALS( iParser->Timeout(), 30 ) - } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void UT_CSymbianUnitTestCommandLineParser::UT_SetTestDllNamesL() - { - // Test DLL name not found - iParser->SetTestDllNamesL(); - SUT_ASSERT_EQUALS( 0, iParser->TestDllNames().MdcaCount() ) - SUT_ASSERT( iParser->ShowHelp() ) - - // One test DLL name found - _LIT( KOneTestDllName, "-tests=test1.dll" ); - iParser->iArguments->Args().AppendL( KOneTestDllName ); - iParser->SetTestDllNamesL(); - SUT_ASSERT_EQUALS( 1, iParser->TestDllNames().MdcaCount() ) - SUT_ASSERT_EQUALS( - _L( "test1.dll" ), iParser->TestDllNames().MdcaPoint( 0 ) ) - SUT_ASSERT( !iParser->ShowHelp() ) - - // Two test DLL names found - _LIT( KTwoTestDllNames, "-tests=test1.dll,test2.dll" ); - iParser->iArguments->Args().Reset(); - iParser->iArguments->Args().AppendL( KTwoTestDllNames ); - iParser->SetTestDllNamesL(); - SUT_ASSERT_EQUALS( 2, iParser->TestDllNames().MdcaCount() ) - SUT_ASSERT_EQUALS( - _L( "test1.dll" ), iParser->TestDllNames().MdcaPoint( 0 ) ) - SUT_ASSERT_EQUALS( - _L( "test2.dll" ), iParser->TestDllNames().MdcaPoint( 1 ) ) - SUT_ASSERT( !iParser->ShowHelp() ) - - // Two test DLL names found, short key name used - _LIT( KTwoTestDllNamesWithShortForm, "-t=test3.dll,test4.dll" ); - iParser->iArguments->Args().Reset(); - iParser->iArguments->Args().AppendL( KTwoTestDllNamesWithShortForm ); - iParser->SetTestDllNamesL(); - SUT_ASSERT_EQUALS( 2, iParser->TestDllNames().MdcaCount() ) - SUT_ASSERT_EQUALS( - _L( "test3.dll" ), iParser->TestDllNames().MdcaPoint( 0 ) ) - SUT_ASSERT_EQUALS( - _L( "test4.dll" ), iParser->TestDllNames().MdcaPoint( 1 ) ) - SUT_ASSERT( !iParser->ShowHelp() ) - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void UT_CSymbianUnitTestCommandLineParser::UT_SetTestCaseNamesL() - { - // Testcase Names, no name. - iParser->SetTestCaseNamesL(); - SUT_ASSERT( !iParser->TestCaseNames().MdcaCount() ) - - // One testcase name, long form. - _LIT( KOneTestCaseNameLong, "-cases=case1" ); - iParser->iArguments->Args().Reset(); - iParser->iArguments->Args().AppendL( KOneTestCaseNameLong ); - iParser->SetTestCaseNamesL(); - SUT_ASSERT_EQUALS( 1, iParser->TestCaseNames().MdcaCount() ) - SUT_ASSERT_EQUALS( - _L( "case1" ), iParser->TestCaseNames().MdcaPoint( 0 ) ) - - // One testcase name, short form. - _LIT( KOneTestCaseNameShort, "-c=case2" ); - iParser->iArguments->Args().Reset(); - iParser->iArguments->Args().AppendL( KOneTestCaseNameShort ); - iParser->SetTestCaseNamesL(); - SUT_ASSERT_EQUALS( 1, iParser->TestCaseNames().MdcaCount() ) - SUT_ASSERT_EQUALS( - _L( "case2" ), iParser->TestCaseNames().MdcaPoint( 0 ) ) - - // Two testcase names, long form. - _LIT( KTwoTestCaseNameLong, "-cases=case3,case4" ); - iParser->iArguments->Args().Reset(); - iParser->iArguments->Args().AppendL( KTwoTestCaseNameLong ); - iParser->SetTestCaseNamesL(); - SUT_ASSERT_EQUALS( 2, iParser->TestCaseNames().MdcaCount() ) - SUT_ASSERT_EQUALS( - _L( "case3" ), iParser->TestCaseNames().MdcaPoint( 0 ) ) - SUT_ASSERT_EQUALS( - _L( "case4" ), iParser->TestCaseNames().MdcaPoint( 1 ) ) - - // Two testcase names, short form. - _LIT( KTwoTestCaseNameShort, "-c=case5,case6" ); - iParser->iArguments->Args().Reset(); - iParser->iArguments->Args().AppendL( KTwoTestCaseNameShort ); - iParser->SetTestCaseNamesL(); - SUT_ASSERT_EQUALS( 2, iParser->TestCaseNames().MdcaCount() ) - SUT_ASSERT_EQUALS( - _L( "case5" ), iParser->TestCaseNames().MdcaPoint( 0 ) ) - SUT_ASSERT_EQUALS( - _L( "case6" ), iParser->TestCaseNames().MdcaPoint( 1 ) ) - } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -// -void UT_CSymbianUnitTestCommandLineParser::UT_FindArgumentL() - { - _LIT( KKey, "key" ); - TPtrC value; - - // Argument not found - SUT_ASSERT( !iParser->FindArgument( KKey, KNullDesC, value ) ) - SUT_ASSERT_EQUALS( KNullDesC, value ) - - // Argument found, no equals sign - _LIT( KOnlyKeyArgument, "key" ); - iParser->iArguments->Args().AppendL( KOnlyKeyArgument ); - SUT_ASSERT( iParser->FindArgument( KKey, KNullDesC, value ) ) - SUT_ASSERT_EQUALS( KNullDesC, value ) - - // Argument found, equals sign as the first character - _LIT( KKeyStartingWithEqualsSign, "=key" ); - _LIT( KKeyStartingWithEqualsSignArgument, "=keysomething" ); - iParser->iArguments->Args().Reset(); - iParser->iArguments->Args().AppendL( KKeyStartingWithEqualsSignArgument ); - SUT_ASSERT( - iParser->FindArgument( KKeyStartingWithEqualsSign, KNullDesC, value ) ) - SUT_ASSERT_EQUALS( KNullDesC, value ) - - // Argument found, equals sign as the last character - _LIT( KKeyEndingWithEqualsSignArgument, "key=" ); - iParser->iArguments->Args().Reset(); - iParser->iArguments->Args().AppendL( KKeyEndingWithEqualsSignArgument ); - SUT_ASSERT( iParser->FindArgument( KKey, KNullDesC, value ) ) - SUT_ASSERT_EQUALS( KNullDesC, value ) - - // Argument found, equals sign as not the first and not the last - _LIT( KValidArgument, "key=value" ); - iParser->iArguments->Args().Reset(); - iParser->iArguments->Args().AppendL( KValidArgument ); - SUT_ASSERT( iParser->FindArgument( KKey, KNullDesC, value ) ) - SUT_ASSERT_EQUALS( _L( "value" ), value ) - - // Short form of the argument found - _LIT( KValidArgument2, "k=value2" ); - iParser->iArguments->Args().Reset(); - iParser->iArguments->Args().AppendL( KValidArgument2 ); - _LIT( KShortKey, "k" ); - SUT_ASSERT( iParser->FindArgument( KNullDesC, KShortKey, value ) ) - SUT_ASSERT_EQUALS( _L( "value2" ), value ) - } - -void UT_CSymbianUnitTestCommandLineParser::LaunchExample( TInt aType ) -{ - _LIT( KSymbianUnitTestFilename, "symbianunittest.exe" ); - _LIT( KSymbianUnitTestArgs, "-t=ut_racecar.dll -noprompt -output=" ); - - const TInt KMaxArgLength( 255 ); - TBuf strArgs; - strArgs.Copy( KSymbianUnitTestArgs ); - - switch( aType ) - { - case 0: // html - strArgs.Append( _L("html") ); - break; - - case 1: // xml - strArgs.Append( _L("xml") ); - break; - - case 2: // txt - strArgs.Append( _L("txt") ); - break; - - default: - //strArgs.Append( _L("html") ); - strArgs = strArgs.Left( 27 ); - } - - RProcess proc; - proc.Create( KSymbianUnitTestFilename, strArgs ); - TRequestStatus status; - proc.Logon( status ); - proc.Resume(); - - User::WaitForRequest( status ); - proc.Close(); - if ( KErrNone != status.Int() ) - { - User::LeaveIfError( status.Int() ); - } -} - -void UT_CSymbianUnitTestCommandLineParser::UT_TestCommandLineL() - { - // set output = html, xml, txt, default; - for(TInt i=0; i<30; ++i) - { - LaunchExample(i); - } - } diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/symbianunittestfw_pub/group/bld.inf --- a/symbianunittestfw/symbianunittestfw_pub/group/bld.inf Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -/* -* 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: Symbian Unit Testing framework -* -*/ - -#include "../symbian_unit_test_api/group/bld.inf" - diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/symbianunittestfw_pub/symbian_unit_test_api/group/bld.inf --- a/symbianunittestfw/symbianunittestfw_pub/symbian_unit_test_api/group/bld.inf Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -/* -* 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: Symbian Unit Testing framework -* -*/ - -PRJ_PLATFORMS -DEFAULT - -PRJ_EXPORTS -../inc/symbianunittestinterface.h OS_LAYER_PLATFORM_EXPORT_PATH(symbianunittestinterface.h) -../inc/symbianunittest.h OS_LAYER_PLATFORM_EXPORT_PATH(symbianunittest.h) -../inc/symbianunittestsuite.h OS_LAYER_PLATFORM_EXPORT_PATH(symbianunittestsuite.h) -../inc/symbianunittestmacros.h OS_LAYER_PLATFORM_EXPORT_PATH(symbianunittestmacros.h) -../inc/symbianunittestldd.h OS_LAYER_PLATFORM_EXPORT_PATH(symbianunittestldd.h) -../inc/symbianunittestlddif.h OS_LAYER_PLATFORM_EXPORT_PATH(symbianunittestlddif.h) diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/symbianunittestfw_pub/symbian_unit_test_api/inc/symbianunittest.h --- a/symbianunittestfw/symbianunittestfw_pub/symbian_unit_test_api/inc/symbianunittest.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,416 +0,0 @@ -/* -* 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 SYMBIANUNITTEST_H -#define SYMBIANUNITTEST_H - -// INCLUDES -#include -#include -#include - -// FORWARD DECLARATIONS -class CSymbianUnitTestResult; - -// CLASS DECLARATION -/** -* The base class for unit test classes. -* The classes inheriting from this class should call -* CSymbianUnitTest::ConstructL from their ConstructL. -* Although the functions implemented in this class -* for unit test assertions and adding test cases -* can be called directly from the subclasses, -* the macros defined in symbianunittestmacros.h should be used instead. -* -* @lib symbianunittestfw.lib -*/ -class CSymbianUnitTest : public CBase, public MSymbianUnitTestInterface - { - public: // Typedefs - - typedef void ( CSymbianUnitTest::*FunctionPtr )(); - - public: // Destructor - - /** - * Destructor - */ - IMPORT_C ~CSymbianUnitTest(); - - public: // From MSymbianUnitTestInterface - - /** - * Function called by the framework to execute - * the unit tests in the subclass. - * There is no need to call this function directly - * from the unit test classes. - * - * @param aObserver an observer for the test progress - * @param aResult the test result - * @param aFailureSimulation the type of failure simulation to be used - * @param aTestCaseNames the test cases to run - * @param aTimeout the time out value for test execution - */ - IMPORT_C void ExecuteL( - MSymbianUnitTestObserver& aObserver, - CSymbianUnitTestResult& aResult, - MSymbianUnitTestInterface::TFailureSimulation aFailureSimulation, - const CDesCArray& aTestCaseNamesi, - TInt aTimeout ); - - /** - * Returns the number of unit test cases contained in this object. - * @return The number of unit test cases in this object - */ - IMPORT_C TInt TestCaseCount(); - - /** - * @return The name of this unit test class - */ - IMPORT_C const TDesC& Name() const; - - /** - * @return the array of test case names - */ - IMPORT_C void TestCaseNamesL(CDesCArray& aTestCaseNames); - - protected: // Constructors - - /** - * Constructor - */ - IMPORT_C CSymbianUnitTest(); - - /** - * This function should be called - * from the ConstructL of the subclass - * - * @param aName the name of the unit test class - */ - IMPORT_C void ConstructL( const TDesC8& aName ); - - public: // New functions - - /** - * This function should be overidden in the actual unit test classes. - * It is the default setup function that gets executed - * by the framework before each unit test case. - */ - IMPORT_C virtual void SetupL(); - - /** - * This function should be overidden in the actual unit test classes. - * It is the default teardown function that gets executed - * by the framework after each unit test case. - */ - IMPORT_C virtual void Teardown(); - - protected: // New functions - /** - * Checks whteher the test case is being run using memory - * allocation failure simulation. - * @return ETrue if the test case is being run using memory - * allocation failure simulation, EFalse if not - */ - IMPORT_C TBool IsMemoryAllocationFailureSimulationUsed() const; - - /** - * Adds a new unit test case to this unit test. - * Use macro ADD_SYMBIAN_UT in symbianunittestmacros.h - * instead to avoid the need to pass - * the name of the unit test case as a parameter. - * - * @param aName the name of the unit test case - * @param aSetupFunction a function pointer to the setup function - * that will be executed before the actual unit test case - * @param aTestFunction a function pointer to the unit test case - * @param aTeardownFunction a function pointer to the teardown function - * that will be executed after the actual unit test case - */ - IMPORT_C void AddTestCaseL( - const TDesC& aName, - CSymbianUnitTest::FunctionPtr aSetupFunction, - CSymbianUnitTest::FunctionPtr aTestFunction, - CSymbianUnitTest::FunctionPtr aTeardownFunction ); - - /** - * Asserts that two TInt values are equal. - * Leaves with a Symbian unit test framework specific error code - * if the values are not equal. - * In case of a failed assertion, the framework records - * the failure reason, line number and file name to the test results. - * Use macro SYMBIAN_UT_ASSERT_EQUALS in symbianunittestmacros.h - * instead to avoid the need to pass the other parameters - * than the actual asserted values. - * - * @param aExpectedValue the expected value - * @param aActualValue the actual value - * @param aLineNumber the line number of the assertion - * @param aFileName the name of the file where the assertion is located - */ - IMPORT_C void AssertEqualsL( - TInt aExpectedValue, - TInt aActualValue, - TInt aLineNumber, - const TDesC8& aFileName ); - - /** - * Asserts that two TDesC8 values are equal. - * Leaves with a Symbian unit test framework specific error code - * if the values are not equal. - * In case of a failed assertion, the framework records - * the failure reason, line number and file name to the test results. - * Use macro SYMBIAN_UT_ASSERT_EQUALS in symbianunittestmacros.h - * instead to avoid the need to pass the other parameters - * than the actual asserted values. - * - * @param aExpectedValue the expected value - * @param aActualValue the actual value - * @param aLineNumber the line number of the assertion - * @param aFileName the name of the file where the assertion is located - */ - IMPORT_C void AssertEqualsL( - const TDesC8& aExpectedValue, - const TDesC8& aActualValue, - TInt aLineNumber, - const TDesC8& aFileName ); - - /** - * Asserts that two TDesC16 values are equal. - * Leaves with a Symbian unit test framework specific error code - * if the values are not equal. - * In case of a failed assertion, the framework records - * the failure reason, line number and file name to the test results. - * Use macro SYMBIAN_UT_ASSERT_EQUALS in symbianunittestmacros.h - * instead to avoid the need to pass the other parameters - * than the actual asserted values. - * - * @param aExpectedValue the expected value - * @param aActualValue the actual value - * @param aLineNumber the line number of the assertion - * @param aFileName the name of the file where the assertion is located - */ - IMPORT_C void AssertEqualsL( - const TDesC16& aExpectedValue, - const TDesC16& aActualValue, - TInt aLineNumber, - const TDesC8& aFileName ); - - /** - * Asserts that a statement leaves an expected value. - * Leaves with a Symbian unit test framework specific error code - * if the leave code is not the expected one. - * In case of a failed assertion, the framework records - * the failure reason, line number and file name to the test results. - * Use macro SYMBIAN_UT_ASSERT_LEAVE in symbianunittestmacros.h - * instead to avoid the need to pass the other parameters - * than the actual statement that is checked for the leave. - * - * @param aStatement textual presentation of the statement - * @param aActualLeaveCode the actual leave code from the statement - * @param aExpectedLeaveCode the expected leave code - * @param aLineNumber the line number of the assertion - * @param aFileName the name of the file where the assertion is located - */ - IMPORT_C void AssertLeaveL( - const TDesC8& aStatement, - TInt aActualLeaveCode, - TInt aExpectedLeaveCode, - TInt aLineNumber, - const TDesC8& aFileName ); - - /** - * Records a failed assertion to the test results and - * leaves with a Symbian unit test framework specific error code - * to quit the execution of the test function. - * Use macro SYMBIAN_UT_ASSERT in symbianunittestmacros.h - * to perform the actual assertion. - * - * @param aFailureMessage the failed assertion as text - * @param aLineNumber the line number of the assertion - * @param aFileName the name of the file where the assertion is located - */ - IMPORT_C void AssertionFailedL( - const TDesC8& aFailureMessage, - TInt aLineNumber, - const TDesC8& aFileName ); - - /** - * Records a non-leaving statement to the test results and - * leaves with a Symbian unit test framework specific error code - * to quit the execution of the test function. - * This function is called from macro SYMBIAN_UT_ASSERT_LEAVE - * in symbianunittestmacros.h to record the result of a failed assertion. - * There is usually no need to call this function directly. - * - * @param aStatement textual presentation of the statement - * @param aLineNumber the line number of the assertion - * @param aFileName the name of the file where the assertion is located - */ - IMPORT_C void RecordNoLeaveFromStatementL( - const TDesC8& aStatement, - TInt aLineNumber, - const TDesC8& aFileName ); - - - - /** - * Asserts that two TInt values are equal. - * Leaves with a Symbian unit test framework specific error code - * if the values are not equal. - * In case of a failed assertion, the framework records - * the failure reason, line number and file name to the test results. - * Use macro SYMBIAN_UT_ASSERT_EQUALS in symbianunittestmacros.h - * instead to avoid the need to pass the other parameters - * than the actual asserted values. - * - * @param aExpectedValue the expected value - * @param aActualValue the actual value - * @param aLineNumber the line number of the assertion - * @param aFileName the name of the file where the assertion is located - * @param aFailureMessage the error message - */ - IMPORT_C void AssertEqualsL( - TInt aExpectedValue, - TInt aActualValue, - TInt aLineNumber, - const TDesC8& aFileName, - const TDesC8& aFailureMessage ); - - /** - * Asserts that two TDesC8 values are equal. - * Leaves with a Symbian unit test framework specific error code - * if the values are not equal. - * In case of a failed assertion, the framework records - * the failure reason, line number and file name to the test results. - * Use macro SYMBIAN_UT_ASSERT_EQUALS in symbianunittestmacros.h - * instead to avoid the need to pass the other parameters - * than the actual asserted values. - * - * @param aExpectedValue the expected value - * @param aActualValue the actual value - * @param aLineNumber the line number of the assertion - * @param aFileName the name of the file where the assertion is located - * @param aFailureMessage the error message - */ - IMPORT_C void AssertEqualsL( - const TDesC8& aExpectedValue, - const TDesC8& aActualValue, - TInt aLineNumber, - const TDesC8& aFileName, - const TDesC8& aFailureMessage ); - - /** - * Asserts that two TDesC16 values are equal. - * Leaves with a Symbian unit test framework specific error code - * if the values are not equal. - * In case of a failed assertion, the framework records - * the failure reason, line number and file name to the test results. - * Use macro SYMBIAN_UT_ASSERT_EQUALS in symbianunittestmacros.h - * instead to avoid the need to pass the other parameters - * than the actual asserted values. - * - * @param aExpectedValue the expected value - * @param aActualValue the actual value - * @param aLineNumber the line number of the assertion - * @param aFileName the name of the file where the assertion is located - * @param aFailureMessage the error message - */ - IMPORT_C void AssertEqualsL( - const TDesC16& aExpectedValue, - const TDesC16& aActualValue, - TInt aLineNumber, - const TDesC8& aFileName, - const TDesC8& aFailureMessage ); - - private: // Internal class for a unit test function's data - - class CSymbianUnitTestCase : public CBase - { - public: // Constructors and destructor - - static CSymbianUnitTestCase* NewL( - const TDesC& aName, - CSymbianUnitTest::FunctionPtr aSetupFunction, - CSymbianUnitTest::FunctionPtr aTestFunction, - CSymbianUnitTest::FunctionPtr aTeardownFunction ); - - ~CSymbianUnitTestCase(); - - public: // New functions - - const TDesC& Name() const; - - public: // Data - - CSymbianUnitTest::FunctionPtr iSetupFunction; - CSymbianUnitTest::FunctionPtr iTestFunction; - CSymbianUnitTest::FunctionPtr iTeardownFunction; - - private: // Constructors - - CSymbianUnitTestCase( - CSymbianUnitTest::FunctionPtr aSetupFunction, - CSymbianUnitTest::FunctionPtr aTestFunction, - CSymbianUnitTest::FunctionPtr aTeardownFunction ); - void ConstructL( const TDesC& aName ); - - private: // Data - - HBufC* iName; - }; - - private: // New functions - - HBufC8* NotEqualsMessageLC( const TDesC16& aExpected, - const TDesC16& aActual ); - - void ExecuteTestCaseInThreadL( - CSymbianUnitTestCase& aTestCase, - CSymbianUnitTestResult& aResult, - TInt aTimeout); - - static TInt TestThreadEntryFunction( TAny* aPtr ); - - void ExecuteTestCaseL(); - - void DoExecuteTestCaseL( TInt& aLeaveCodeFromTest ); - - void StartAllocFailureSimulation(); - - void StopAllocFailureSimulation(); - - static TInt TimerThreadEntryFunction( TAny* aPtr); - - private: // Data - - HBufC* iName; - RHeap::TAllocFail iAllocFailureType; - TUint iAllocFailureRate; - TInt iLeakedMemory; - TInt iLeakedResource; - TInt iLeakedRequest; - TInt iHeapCellsReservedByAssertFailure; - RPointerArray< CSymbianUnitTestCase > iTestCases; - CSymbianUnitTestResult* iTestResult; // Not owned - CSymbianUnitTestCase* iCurrentTestCase; // Not owned - - private: // Test - - SYMBIAN_UNIT_TEST_CLASS( UT_CSymbianUnitTest ) - }; - -#endif // SYMBIANUNITTEST_H diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/symbianunittestfw_pub/symbian_unit_test_api/inc/symbianunittestinterface.h --- a/symbianunittestfw/symbianunittestfw_pub/symbian_unit_test_api/inc/symbianunittestinterface.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,99 +0,0 @@ -/* -* 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 SYMBIANUNITTESTINTERFACE_H -#define SYMBIANUNITTESTINTERFACE_H - -// INCLUDES -#include -#include - -// FORWARD DECLARATIONS -class MSymbianUnitTestObserver; -class CSymbianUnitTestResult; - -// CONSTANTS -/** -* All the DLLs containing Symbian unit tests should use the following UID -*/ -const TUid KSymbianUnitTestDllUid = { 0x20022E76 }; - -// CLASS DECLARATION -/** -* The interface that is implemented by all -* the unit tests and collections of unit tests. -* Provides a common interface -* for Symbian unit test framework to execute the unit tests. -* -* @lib symbianunittestfw.lib -*/ -class MSymbianUnitTestInterface - { - public: // Enumerations - - /** Test failure simulation types */ - enum TFailureSimulation - { - /** No failure simulation */ - ENoFailureSimulation, - /** Memory allocation failure simulation */ - EMemAllocFailureSimulation - }; - - public: // New functions - - /** - * Virtual destructor to enable the framework to delete - * the unit test or the unit test collection through this interface - */ - virtual ~MSymbianUnitTestInterface() { } - - /** - * Function called by the framework to execute - * the unit tests contained in this object. - * - * @param aObserver an observer for the test progress - * @param aResult the test result - * @param aFailureSimulation the type of failure simulation to be used - * @param aTestCaseNames the test cases to run - * @param aTimeout the time out value for test execution - */ - virtual void ExecuteL( - MSymbianUnitTestObserver& aObserver, - CSymbianUnitTestResult& aResult, - TFailureSimulation aFailureSimulation, - const CDesCArray& aTestCaseNames, - TInt aTimeout) = 0; - - /** - * Returns the number of unit tests contained in this object - * @return The number of unit tests in this object - */ - virtual TInt TestCaseCount() = 0; - - /** - * @return The name of this unit test or unit test collection - */ - virtual const TDesC& Name() const = 0; - - /** - * @return the array of test case names - */ - virtual void TestCaseNamesL(CDesCArray& aTestCaseNames) = 0; - }; - -#endif // SYMBIANUNITTESTINTERFACE_H diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/symbianunittestfw_pub/symbian_unit_test_api/inc/symbianunittestldd.h --- a/symbianunittestfw/symbianunittestfw_pub/symbian_unit_test_api/inc/symbianunittestldd.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,239 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of the License "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 __D_SYMBIANUNITTESTLDD_H -#define __D_SYMBIANUNITTESTLDD_H - - -#include -#include "symbianunittestlddif.h" - - -// CLASS DECLARATION - - -class DSymbianUnitTestFactory : public DLogicalDevice -{ -public: - IMPORT_C DSymbianUnitTestFactory(const TDesC& aName); - IMPORT_C virtual ~DSymbianUnitTestFactory(); - IMPORT_C virtual TInt Install(); - IMPORT_C virtual void GetCaps(TDes8& aDes) const; - virtual TInt Create(DLogicalChannelBase*& aChannel) = 0; - -private: - TName iDriverName; - -}; - - - - - -/** -* The base class for kernel unit test classes. -* It implements logical driver to run test code in kernel mode -* The classes inheriting from this class should implements Construct -* for adding test case -* @lib symbianunittestldd.lib -*/ -class DSymbianUnitTest : public DLogicalChannelBase -{ - -public: // Typedefs - - typedef TInt ( DSymbianUnitTest::*FunctionPtr )(); - - -public: - - //Constructor - IMPORT_C DSymbianUnitTest(); - - // Destructor - IMPORT_C virtual ~DSymbianUnitTest(); - - /** - * This function should be overidden in the actual unit test classes. - * It is the default setup function that gets executed - * by the framework before each unit test case. - */ - IMPORT_C virtual TInt Setup(); - - /** - * This function should be overidden in the actual unit test classes. - * It is the default teardown function that gets executed - * by the framework after each unit test case. - */ - IMPORT_C virtual TInt Teardown(); - - -protected: - - /** - * Adds a new unit test case to this unit test. - * Use macro ADD_SYMBIAN_UT in symbianunittestmacros.h - * instead to avoid the need to pass - * the name of the unit test case as a parameter. - * - * @param aName the name of the unit test case - * @param aSetupFunction a function pointer to the setup function - * that will be executed before the actual unit test case - * @param aTestFunction a function pointer to the unit test case - * @param aTeardownFunction a function pointer to the teardown function - * that will be executed after the actual unit test case - */ - IMPORT_C void AddTestCase( - const TDesC& aName, - DSymbianUnitTest::FunctionPtr aSetupFunction, - DSymbianUnitTest::FunctionPtr aTestFunction, - DSymbianUnitTest::FunctionPtr aTeardownFunction ); - - /** - * Asserts that two TInt values are equal. - * Leaves with a Symbian unit test framework specific error code - * if the values are not equal. - * In case of a failed assertion, the framework records - * the failure reason, line number and file name to the test results. - * Use macro SYMBIAN_UT_ASSERT_EQUALS in symbianunittestmacros.h - * instead to avoid the need to pass the other parameters - * than the actual asserted values. - * - * @param aExpectedValue the expected value - * @param aActualValue the actual value - * @param aLineNumber the line number of the assertion - * @param aFileName the name of the file where the assertion is located - */ - IMPORT_C TInt AssertEquals( - TInt aExpectedValue, - TInt aActualValue, - TInt aLineNumber, - const TDesC8& aFileName ); - - /** - * Asserts that two TDesC8 values are equal. - * Leaves with a Symbian unit test framework specific error code - * if the values are not equal. - * In case of a failed assertion, the framework records - * the failure reason, line number and file name to the test results. - * Use macro SYMBIAN_UT_ASSERT_EQUALS in symbianunittestmacros.h - * instead to avoid the need to pass the other parameters - * than the actual asserted values. - * - * @param aExpectedValue the expected value - * @param aActualValue the actual value - * @param aLineNumber the line number of the assertion - * @param aFileName the name of the file where the assertion is located - */ - IMPORT_C TInt AssertEquals( - const TDesC8& aExpectedValue, - const TDesC8& aActualValue, - TInt aLineNumber, - const TDesC8& aFileName ); - - - - /** - * Records a failed assertion to the test results and - * leaves with a Symbian unit test framework specific error code - * to quit the execution of the test function. - * Use macro SYMBIAN_UT_ASSERT in symbianunittestmacros.h - * to perform the actual assertion. - * - * @param aFailureMessage the failed assertion as text - * @param aLineNumber the line number of the assertion - * @param aFileName the name of the file where the assertion is located - */ - IMPORT_C TInt AssertionFailed( - const TDesC8& aFailureMessage, - TInt aLineNumber, - const TDesC8& aFileName ); - - /** - * Add test cases - * Although the functions implemented in this class - * for unit test assertions and adding test cases - * can be called directly from the subclasses, - * the macros defined in symbianunittestmacros.h should be used instead. - */ - virtual void Construct() = 0; - - -private: // Internal class for a unit test function's data - - class DSymbianUnitTestCase : public DBase - { - public: // Constructors and destructor - - DSymbianUnitTestCase( - const TDesC& aName, - DSymbianUnitTest::FunctionPtr aSetupFunction, - DSymbianUnitTest::FunctionPtr aTestFunction, - DSymbianUnitTest::FunctionPtr aTeardownFunction ); - - ~DSymbianUnitTestCase(); - - public: // New functions - - const TDesC& Name() const; - - public: // Data - - DSymbianUnitTest::FunctionPtr iSetupFunction; - DSymbianUnitTest::FunctionPtr iTestFunction; - DSymbianUnitTest::FunctionPtr iTeardownFunction; - - private: // Data - - HBuf* iName; - }; - -private: - - - TInt TestCount(TInt* aDest); - - TInt ExecuteTestCase(TAny* aIndex, TDes8* aResult); - - TInt GetTestCaseName(TAny* aIndex, TDes* aCaseName); - - TInt ExecuteTestCaseInThread(); - - static TInt TestThreadEntryFunction( TAny* aPtr ); - - void Printf(TDes8& aDes, const char* aFmt, ...); - - IMPORT_C virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2); - -private: // Data - - HBuf* iName; - RPointerArray< DSymbianUnitTestCase > iTestCases; - DSymbianUnitTestCase* iCurrentTestCase; // Not owned - - DThread* iClient; //pointer to client thread for read/write data - TSUTTestCaseResult* iCurrentResult; // Not owned - NFastSemaphore iExecSem;//semaphore for synchronization between main thread and execworkder thread - - //TUint iExecThreadId; //id of the current exec workder thread. - //DCrashHandler* iCrashHandler; - -}; - - - -#endif //__D_SYMBIANUNITTESTLDD_H - diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/symbianunittestfw_pub/symbian_unit_test_api/inc/symbianunittestlddif.h --- a/symbianunittestfw/symbianunittestfw_pub/symbian_unit_test_api/inc/symbianunittestlddif.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of the License "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 __SYMBIANUNITTESTLDDIF_H -#define __SYMBIANUNITTESTLDDIF_H - -#include - -class RSymbianUnitTest : public RBusLogicalChannel -{ -public: - enum TControl - { - ETESTCOUNT=1, - EEXECUTETESTCASE=2, - ETESTCASENAME=3 - }; - - TInt GetTestCaseCount(TInt* a1); - TInt ExecTestCase(TInt* a1, TAny* a2); - TInt GetTestCaseName(TInt* a1, TAny* a2); - TInt Open(const TDesC& aName); -}; - -typedef TBuf8<80> TTestName; -typedef TBuf8<256> TFAILUREMESSAGE; -typedef TBuf8<256> TFILENAME; - -class TSUTTestCaseResult - { - public: TSUTTestCaseResult() : iRetCode (0), iLineNumber (0) - { - iTestName.Zero(); - iFailureMessage.Zero(); - iFileName.Zero(); - } - public: - TInt iRetCode; - TInt iLineNumber; - TTestName iTestName; - TFAILUREMESSAGE iFailureMessage; - TFILENAME iFileName; - }; - - -#endif __SYMBIANUNITTESTLDDIF_H diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/symbianunittestfw_pub/symbian_unit_test_api/inc/symbianunittestmacros.h --- a/symbianunittestfw/symbianunittestfw_pub/symbian_unit_test_api/inc/symbianunittestmacros.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,337 +0,0 @@ -/* -* 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 SYMBIANUNITTESTMACROS_H -#define SYMBIANUNITTESTMACROS_H - - -#ifndef __KERNEL_MODE__ -// INCLUDES -#include -#endif - - -// MACROS -#ifdef SYMBIAN_UNIT_TEST - -const TInt KMaxPathLength( 255 ); - -#ifndef __KERNEL_MODE__ - - inline TInt operator==( TTrue, TInt aInt ) - { - return aInt; - } - - inline TInt operator==( TInt aInt, TTrue ) - { - return aInt; - } - - inline TInt operator!=( TTrue, TInt aInt ) - { - return !aInt; - } - - inline TInt operator!=( TInt aInt, TTrue ) - { - return !aInt; - } - - - /** - * Calls the base class constructor that sets the name of unit test. - */ - #define BASE_CONSTRUCT\ - CSymbianUnitTest::ConstructL( _L8( __PRETTY_FUNCTION__ ) ); - - /** - * Adds a new unit test case to this unit test. - * The default setup and teardown functions will be used. - * @param aTestPtr a function pointer to the unit test case - */ - #ifndef __GCCE__ - #define ADD_SUT( aTestPtr )\ - AddTestCaseL(\ - _L( #aTestPtr ),\ - CSymbianUnitTest::FunctionPtr( SetupL ),\ - CSymbianUnitTest::FunctionPtr( aTestPtr ),\ - CSymbianUnitTest::FunctionPtr( Teardown ) ); - - #else - #define ADD_SUT( aTestPtr )\ - AddTestCaseL(\ - _L( #aTestPtr ),\ - CSymbianUnitTest::FunctionPtr( &CSymbianUnitTest::SetupL ),\ - CSymbianUnitTest::FunctionPtr( &TYPE::aTestPtr ),\ - CSymbianUnitTest::FunctionPtr( &CSymbianUnitTest::Teardown ) ); - #endif - - - /** - * Adds a new unit test case to this unit test. - * The user can specify - * @param aSetupPtr a function pointer to the setup function - * that will be executed before the actual unit test case - * @param aTestPtr a function pointer to the unit test case - * @param aTeardownPtr a function pointer to the teardown function - * that will be executed after the actual unit test case - */ - #ifndef __GCCE__ - #define ADD_SUT_WITH_SETUP_AND_TEARDOWN( aSetupPtr, aTestPtr, aTeardownPtr )\ - AddTestCaseL(\ - _L( #aTestPtr ),\ - CSymbianUnitTest::FunctionPtr( aSetupPtr ),\ - CSymbianUnitTest::FunctionPtr( aTestPtr ),\ - CSymbianUnitTest::FunctionPtr( aTeardownPtr ) ); - #else - #define ADD_SUT_WITH_SETUP_AND_TEARDOWN( aSetupPtr, aTestPtr, aTeardownPtr )\ - AddTestCaseL(\ - _L( #aTestPtr ),\ - CSymbianUnitTest::FunctionPtr( &TYPE::aSetupPtr ),\ - CSymbianUnitTest::FunctionPtr( &TYPE::aTestPtr ),\ - CSymbianUnitTest::FunctionPtr( &TYPE::aTeardownPtr ) ); - - #endif - - /** - * Asserts a condition in a unit test case. - * Leaves with a Symbian unit test framework specific error code - * if the condition evaluates to EFalse. - * In case of a failed assertion, the framework records - * the failure reason, line number and file name to the test results. - * @param aCondition the asserted condition. - */ - - - #define SUT_ASSERT( aCondition )\ - if ( aCondition ) {} else\ - {\ - TBuf8 fullFileName( _L8( __FILE__ ) );\ - TChar ch1 = '\\';\ - TChar ch2 = '/';\ - TInt idx1 = fullFileName.LocateReverseF( ch1 );\ - TInt idx2 = fullFileName.LocateReverseF( ch2 );\ - idx1 = idx1>idx2?idx1:idx2;\ - TPtrC8 ptr = fullFileName.Mid( idx1 + 1 );\ - AssertionFailedL( _L8( #aCondition ), __LINE__, ptr );\ - } - - /** - * Asserts a condition in a unit test case. - * Leaves with a Symbian unit test framework specific error code - * if the condition evaluates to EFalse. - * In case of a failed assertion, the framework records - * the failure reason, line number and file name to the test results. - * @param aCondition the asserted condition. - * @param aDescription the error description - */ - - - #define SUT_ASSERT_DESC( aCondition, aDescription )\ - if ( aCondition ) {} else\ - {\ - TBuf8 fullFileName( _L8( __FILE__ ) );\ - TChar ch1 = '\\';\ - TChar ch2 = '/';\ - TInt idx1 = fullFileName.LocateReverseF( ch1 );\ - TInt idx2 = fullFileName.LocateReverseF( ch2 );\ - idx1 = idx1>idx2?idx1:idx2;\ - TPtrC8 ptr = fullFileName.Mid( idx1 + 1);\ - AssertionFailedL( _L8( aDescription ), __LINE__, ptr );\ - } - - - /** - * Asserts that two values are equal. - * Leaves with a Symbian unit test framework specific error code - * if the values are not equal. - * In case of a failed assertion, the framework records - * the failure reason, line number and file name to the test results. - * @param aExpectedValue the expected value - * @param aActualValue the actual value - */ - #define SUT_ASSERT_EQUALS( aExpected, aActual )\ - {\ - TBuf8 fullFileName( _L8( __FILE__ ) );\ - TChar ch1 = '\\';\ - TChar ch2 = '/';\ - TInt idx1 = fullFileName.LocateReverseF( ch1 );\ - TInt idx2 = fullFileName.LocateReverseF( ch2 );\ - idx1 = idx1>idx2?idx1:idx2;\ - TPtrC8 ptr = fullFileName.Mid( idx1 + 1);\ - AssertEqualsL( aExpected, aActual, __LINE__, ptr );\ - } - - /** - * Asserts that two values are equal. - * Leaves with a Symbian unit test framework specific error code - * if the values are not equal. - * In case of a failed assertion, the framework records - * the failure reason, line number and file name to the test results. - * @param aExpectedValue the expected value - * @param aActualValue the actual value - * @param aDescription the error description - */ - #define SUT_ASSERT_EQUALS_DESC( aExpected, aActual, aDescription )\ - {\ - TBuf8 fullFileName( _L8( __FILE__ ) );\ - TChar ch1 = '\\';\ - TChar ch2 = '/';\ - TInt idx1 = fullFileName.LocateReverseF( ch1 );\ - TInt idx2 = fullFileName.LocateReverseF( ch2 );\ - idx1 = idx1>idx2?idx1:idx2;\ - TPtrC8 ptr = fullFileName.Mid( idx1 + 1);\ - AssertEqualsL( aExpected, aActual, __LINE__, ptr, _L8(aDescription) );\ - } - - /** - * Asserts that a statement leaves an expected value. - * Leaves with a Symbian unit test framework specific error code - * if the leave code is not the expected one. - * In case of a failed assertion, the framework records - * the failure reason, line number and file name to the test results. - * @param aStatement the statement - * @param aError the expected leave code - */ - #define SUT_ASSERT_LEAVE_WITH( aStatement, aError )\ - {\ - TInt KLine( __LINE__ );\ - TRAPD( err, aStatement )\ - if ( aError!=err )\ - {\ - TBuf8 fullFileName( _L8( __FILE__ ) );\ - TChar ch1 = '\\';\ - TChar ch2 = '/';\ - TInt idx1 = fullFileName.LocateReverseF( ch1 );\ - TInt idx2 = fullFileName.LocateReverseF( ch2 );\ - idx1 = idx1>idx2?idx1:idx2;\ - TPtrC8 ptr = fullFileName.Mid( idx1 + 1);\ - AssertLeaveL( _L8( #aStatement ), err, aError, KLine, ptr );\ - }\ - } - - /** - * Asserts that a statement leaves. - * The macro itself leaves with a Symbian unit test framework - * specific error code if the statement leaves. - * In case of a failed assertion, the framework records - * the failure reason, the line number and file name to the test results. - * - * Note: SUT_ASSERT_LEAVE_WITH should be used instead - * whenever possible, because the implementation of - * SYMBIAN_UT_ASSERT_LEAVE TRAPs also KErrNoMemory. - * This means that all the memory allocations are not looped through - * during the memory allocation failure simulation. - * @param aStatement the statement - */ - #define SUT_ASSERT_LEAVE( aStatement )\ - {\ - TInt KLine( __LINE__ );\ - TRAPD( err, aStatement)\ - if ( err==KErrNone )\ - {\ - TBuf8 fullFileName( _L8( __FILE__ ) );\ - TChar ch1 = '\\';\ - TChar ch2 = '/';\ - TInt idx1 = fullFileName.LocateReverseF( ch1 );\ - TInt idx2 = fullFileName.LocateReverseF( ch2 );\ - idx1 = idx1>idx2?idx1:idx2;\ - TPtrC8 ptr = fullFileName.Mid( idx1 + 1);\ - RecordNoLeaveFromStatementL( _L8( #aStatement ), KLine, ptr );\ - }\ - } - - -#else // macro defined for kernel testing - - #ifndef __GCCE__ - #define ADD_SUT( aTestPtr )\ - AddTestCase(\ - _L( #aTestPtr ),\ - DSymbianUnitTest::FunctionPtr( Setup ),\ - DSymbianUnitTest::FunctionPtr(aTestPtr),\ - DSymbianUnitTest::FunctionPtr( Teardown ) ); - - #else - #define ADD_SUT( aTestPtr )\ - AddTestCase(\ - _L( #aTestPtr ),\ - DSymbianUnitTest::FunctionPtr( &DSymbianUnitTest::Setup ),\ - DSymbianUnitTest::FunctionPtr(&TYPE::aTestPtr),\ - DSymbianUnitTest::FunctionPtr( &DSymbianUnitTest::Teardown ) ); - #endif - - #ifndef __GCCE__ - #define ADD_SUT_WITH_SETUP_AND_TEARDOWN( aSetupPtr, aTestPtr, aTeardownPtr )\ - AddTestCase(\ - _L( #aTestPtr ),\ - DSymbianUnitTest::FunctionPtr( aSetupPtr ),\ - DSymbianUnitTest::FunctionPtr( aTestPtr ),\ - DSymbianUnitTest::FunctionPtr( aTeardownPtr ) ); - #else - #define ADD_SUT_WITH_SETUP_AND_TEARDOWN( aSetupPtr, aTestPtr, aTeardownPtr )\ - AddTestCase(\ - _L( #aTestPtr ),\ - DSymbianUnitTest::FunctionPtr( &TYPE::aSetupPtr ),\ - DSymbianUnitTest::FunctionPtr( &TYPE::aTestPtr ),\ - DSymbianUnitTest::FunctionPtr( &TYPE::aTeardownPtr ) ); - - #endif - - #define SUT_ASSERT( aCondition )\ - if ( aCondition ) {} else\ - {\ - return AssertionFailed( _L8( #aCondition ), __LINE__, _L8( __FILE__ ) );\ - } - - #define SUT_ASSERT_DESC( aCondition, aDescription )\ - if ( aCondition ) {} else\ - {\ - return AssertionFailed( _L8( aDescription ), __LINE__, _L8( __FILE__ ) );\ - } - - - #define SUT_ASSERT_EQUALS( aExpected, aActual )\ - if ( AssertEquals(aExpected, aActual, __LINE__, _L8( __FILE__ )) == KErrNone ) {} else\ - {\ - return KErrGeneral;\ - } - - #define SUT_ASSERT_EQUALS_DESC( aExpected, aActual, aDescription )\ - if ( AssertEquals( aExpected, aActual, __LINE__, _L8( __FILE__ ), _L8(aDescription)) == KErrNone ) {} else\ - {\ - return KErrGeneral;\ - } - - - -#endif // __IN_KERNEL__ - - /** - * Can be used to hide the friend declaration for a unit test class. - */ - #define SYMBIAN_UNIT_TEST_CLASS( ClassName ) friend class ClassName; - - #define DEFINE_TEST_CLASS( aClassName )\ - typedef aClassName TYPE; - -#else - #define SYMBIAN_UNIT_TEST_CLASS( ClassName ) -#endif //SYMBIAN_UNIT_TEST - -#endif // SYMBIANUNITTESTMACROS_H diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/symbianunittestfw_pub/symbian_unit_test_api/inc/symbianunittestsuite.h --- a/symbianunittestfw/symbianunittestfw_pub/symbian_unit_test_api/inc/symbianunittestsuite.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,112 +0,0 @@ -/* -* 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 SYMBIANUNITTESTSUITE_H -#define SYMBIANUNITTESTSUITE_H - -// INCLUDES -#include -#include - -// CLASS DECLARATION -/** -* A class to collect a number of unit tests to be executed -* during a particular test run. -* -* @lib symbianunittestfw.lib -*/ -class CSymbianUnitTestSuite : public CBase, public MSymbianUnitTestInterface - { - public: // Constructors and destructor - - /** - * Creates an empty unit test suite. - * @param aName the name of the unit test suite - * @return a new instance of CSymbianUnitTestSuite, - * the ownership is transferred - */ - IMPORT_C static CSymbianUnitTestSuite* NewL( const TDesC& aName ); - - /** - * Creates an empty unit test suite and pushes it to the CleanupStack. - * @param aName the name of the unit test suite - * @return a new instance of CSymbianUnitTestSuite, - * the ownership is transferred - */ - IMPORT_C static CSymbianUnitTestSuite* NewLC( const TDesC& aName ); - - /** - * Destructor - */ - IMPORT_C ~CSymbianUnitTestSuite(); - - public: // From MSymbianUnitTestInterface - - /** - * Function called by the framework to execute - * the unit tests contained in this test suite. - * There is no need to call this function directly from the unit tests. - * - * @param aObserver an observer for the test progress - * @param aResult the test result - * @param aFailureSimulation the type of failure simulation to be used - * @param aTestCaseNames the test cases to run - * @param aTimeout the time out value for test execution - */ - IMPORT_C void ExecuteL( - MSymbianUnitTestObserver& aObserver, - CSymbianUnitTestResult& aResult, - MSymbianUnitTestInterface::TFailureSimulation aFailureSimulation, - const CDesCArray& aTestCaseNames, - TInt aTimeout ); - - /** - * Returns the number of unit tests contained in this unit test suite - * @return The number of unit tests in this unit test suite - */ - IMPORT_C TInt TestCaseCount(); - - /** - * @return The name of this unit test suite - */ - IMPORT_C const TDesC& Name() const; - - /** - * @return the array of test case names - */ - IMPORT_C void TestCaseNamesL(CDesCArray& aTestCaseNames); - - public: // New functions - - /** - * Adds a new unit test to this unit test suite. - * @param aTest the test to be added, the ownership is transferred. - */ - IMPORT_C void AddL( MSymbianUnitTestInterface* aTest ); - - protected: // Constructors - - IMPORT_C CSymbianUnitTestSuite(); - IMPORT_C void ConstructL( const TDesC& aName ); - - private: // Data - - RPointerArray< MSymbianUnitTestInterface > iTests; - HBufC* iName; - }; - -#endif // SYMBIANUNITTESTSUITE_H diff -r 6edeef394eb7 -r 9397a16b6eb8 symbianunittestfw/tsrc/eunit_to_symbianunit.pl --- a/symbianunittestfw/tsrc/eunit_to_symbianunit.pl Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,248 +0,0 @@ -# -# 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: -# - -#!/usr/bin/perl -use strict; -use warnings; -use Getopt::Long; -#use Cwd 'abs_path'; -use Cwd; - - -# Main -my $root_dir = ""; -GetOptions("dir=s" => \$root_dir); -if ($root_dir eq "") { - $root_dir = "."; -} -convert_cpp_in_directory($root_dir); -convert_files_in_directory($root_dir); -print "Conversion completed.\n"; - -sub convert_cpp_in_directory { - my $dir_name = shift; - print "Opening directory: " . $dir_name . "\n"; - opendir(DIR, $dir_name) || die "Cannot open directory " . $dir_name; - chdir($dir_name); - my @sourcefiles = readdir(DIR); - foreach (@sourcefiles) { - if ( $_ =~ /.cpp$/i ) { - # make the file writable (0666 is in linux/unix terms rw-) - chmod(0666,$_); - print "Converting: "; - print $_; - my $converted_file_content = ""; - if (/.cpp$/ ) { - $converted_file_content = convert_source_file_content($_); - } - open(my $result_file_handle, ">", $_) or die(". Writing " . $_ . " failed!\n"); - print $result_file_handle $converted_file_content; - close $result_file_handle; - print ". Done\n"; - } - elsif ( /\./ ) { - # Other types of files - } - else { - # Directories - convert_cpp_in_directory($_); - chdir(".."); # After recursion change back to the current directory - } - } - closedir DIR; -} - -sub convert_files_in_directory { - my $dir_name = shift; - print "Opening directory: " . $dir_name . "\n"; - opendir(DIR, $dir_name) || die "Cannot open directory " . $dir_name; - chdir($dir_name); - my @sourcefiles = readdir(DIR); - foreach (@sourcefiles) { - if ( $_ =~ /.h$/i || $_ =~ /.mmp$/i || $_ =~ /.def$/i) { - # make the file writable (0666 is in linux/unix terms rw-) - chmod(0666,$_); - print "Converting: "; - print $_; - my $converted_file_content = ""; - if (/.h$/) { - $converted_file_content = convert_source_file_content($_); - } - elsif (/.mmp$/) { - $converted_file_content = convert_mmp_file_content($_); - } - else { - $converted_file_content = convert_def_file_content($_); - } - open(my $result_file_handle, ">", $_) or die(". Writing " . $_ . " failed!\n"); - print $result_file_handle $converted_file_content; - close $result_file_handle; - print ". Done\n"; - } - elsif ( /\./ ) { - # Other types of files - } - else { - # Directories - convert_files_in_directory($_); - chdir(".."); # After recursion change back to the current directory - } - } - closedir DIR; -} - - -sub convert_source_file_content { - my $file_name = shift; - - my $file_content = read_file_content_into_string($file_name); - - #check if this source include a separate test table header file - #in that case, we need to insert the test table content from header first - if ($file_content =~ m/\#include\s*\"(.*)testtable\.h\"/) { - my $curpath = cwd; - my $table_file_name = $curpath . "/../inc/" . $1 . "testtable.h"; - print "\n try to merge header file at: " . $table_file_name . "\n"; - my $tabledef = read_file_content_into_string($table_file_name); - #remove copyright and other comments - $tabledef =~ s/\/\/.*|\/\*[\s\S]*?\*\///g; - $tabledef =~ s/#include\s*\".*\"//g; - $file_content =~ s/\#include\s*\".*testtable\.h\"/$tabledef/g; - - - } - - # Convert the EUnit test table to SymbianUnit tests and move it to the constructor - my $symbianunit_constructor_content = "BASE_CONSTRUCT"; - my $converted_test_table = convert_eunit_test_table($file_content); - #print "converted test table: " . $converted_test_table . "\n"; - $symbianunit_constructor_content .= $converted_test_table; - $file_content =~ s/CEUnitTestSuiteClass::ConstructL\(.*\)\;/$symbianunit_constructor_content/g; - - # Remove the EUnit test table - $file_content =~ s/EUNIT_BEGIN_TEST_TABLE(.*)EUNIT_END_TEST_TABLE//ms; - $file_content =~ s/\/\/ TEST TABLE//ms; - - # Do rest of the conversions - $file_content =~ s/#include /#include /gi; - $file_content =~ s/#include /#include /gi; - $file_content =~ s/#include /#include /gi; - $file_content =~ s/#include //gi; - $file_content =~ s/CEUnitTestSuiteClass/CSymbianUnitTest/g; - $file_content =~ s/CEUnitTestSuite/CSymbianUnitTestSuite/g; - $file_content =~ s/MEUnitTest/MSymbianUnitTestInterface/g; - $file_content =~ s/EUNIT_DECLARE_TEST_TABLE;//g; - $file_content =~ s/EUNIT_ASSERT_SPECIFIC_LEAVE/SUT_ASSERT_LEAVE_WITH/g; - $file_content =~ s/EUNIT_ASSERT_LEAVE/SUT_ASSERT_LEAVE/g; - $file_content =~ s/EUNIT_ASSERT_EQUALS/SUT_ASSERT_EQUALS/g; - $file_content =~ s/EUNIT_ASSERT_NO_LEAVE//g; - $file_content =~ s/EUNIT_ASSERT/SUT_ASSERT/g; - $file_content =~ s/EUNIT_ASSERT_DESC/SUT_ASSERT_DESC/g; - $file_content =~ s/EUNIT_ASSERT_EQUALS_DESC/SUT_ASSERT_EQUALS_DESC/g; - $file_content =~ s/EUNIT_PRINT/\/\/EUNIT_PRINT/g; - - return $file_content; -} - - -sub convert_mmp_file_content { - my $file_name = shift; - - my $file_content = read_file_content_into_string($file_name); - - $file_content =~ s/eunit.lib/symbianunittestfw.lib/gi; - $file_content =~ s/eunitutil.lib//gi; - $file_content =~ s/\/epoc32\/include\/Digia\/EUnit//gi; - $file_content =~ s/\/epoc32\/include\/platform\/Digia\/EUnit//gi; - $file_content =~ s/TARGETPATH(.*)\/DigiaEUnit\/Tests//gi; - $file_content =~ s/UID(.*)0x1000af5a/MACRO SYMBIAN_UNIT_TEST\nUID 0x20022E76/gi; - - return $file_content; -} - - -sub convert_def_file_content { - my $file_name = shift; - - my $file_content = read_file_content_into_string($file_name); - - $file_content =~ s/MEUnitTest/MSymbianUnitTestInterface/g; - - return $file_content; -} - - -sub read_file_content_into_string { - my $file_name = shift; - - open(my $src_file_handle, "<", $file_name) or die("\nFile not found!\n"); - my @file_content_array = <$src_file_handle>; - my $file_content = ""; - foreach (@file_content_array) { - $file_content .= $_; - } - close $src_file_handle; - - return $file_content; -} - - -sub convert_eunit_test_table { - my $file_content = shift; - my $converted_test_table = "\n"; - if ($file_content =~ /EUNIT_BEGIN_TEST_TABLE(.*)EUNIT_END_TEST_TABLE/ms) { - my $test_table_content = $1; - my @test_list = split(/EUNIT_TEST/, $test_table_content); - shift @test_list; # Remove the test table parameters before the first test - foreach (@test_list) { - if ($_ =~ /\((.*)\)/ms) { - $converted_test_table .= "\n"; - $converted_test_table .= convert_eunit_test_entry($1); - } - } - } - return $converted_test_table; -} - - -sub convert_eunit_test_entry { - # Parameters for EUNIT_TEST: - # text1, text2, text3, text4, setupFunc, runFunc, teardownFunc - my $eunit_test_parameters = shift; - # Remove whitespaces, tabs and line breaks - $eunit_test_parameters =~ s/\s//g; - my @test_parameter_array = split(/,/, $eunit_test_parameters); - my $result = ""; - if (@test_parameter_array == 7) { - if ($test_parameter_array[4] ne "SetupL" || - $test_parameter_array[6] ne "Teardown") { - # Non-default setup or teardown used - $result = " ADD_SUT_WITH_SETUP_AND_TEARDOWN( "; - $result .= $test_parameter_array[4]; - $result .= ", "; - $result .= $test_parameter_array[5]; - $result .= ", "; - $result .= $test_parameter_array[6]; - $result .= " )"; - } - else { - $result = " ADD_SUT( "; - $result .= $test_parameter_array[5]; - $result .= " )"; - } - } - return $result; -} diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/group/bld.inf --- a/testexecmdw/tef/group/bld.inf Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ -// -// 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: -// Reads configuration from ini files for test programs -// - -/** - @file -*/ - -// ini file parser -#include "../inifileparser/group/bld.inf" - -// tef -#include "../tef/group/bld.inf" \ No newline at end of file diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/inifileparser/bwins/iniparseru.def --- a/testexecmdw/tef/inifileparser/bwins/iniparseru.def Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ -EXPORTS - ??0CIniData@@IAE@ABVTDesC16@@@Z @ 1 NONAME ; CIniData::CIniData(class TDesC16 const &) - ??0CIniData@@IAE@XZ @ 2 NONAME ; CIniData::CIniData(void) - ??1CIniData@@UAE@XZ @ 3 NONAME ; CIniData::~CIniData(void) - ?AddValue@CIniData@@QAEHABVTDesC16@@00@Z @ 4 NONAME ; int CIniData::AddValue(class TDesC16 const &, class TDesC16 const &, class TDesC16 const &) - ?AddValue@CIniData@@QAEHABVTDesC16@@0@Z @ 5 NONAME ; int CIniData::AddValue(class TDesC16 const &, class TDesC16 const &) - ?ConstructL@CIniData@@IAEXABVTDesC16@@@Z @ 6 NONAME ; void CIniData::ConstructL(class TDesC16 const &) - ?FindVar@CIniData@@QAEHABVTDesC16@@0AAH@Z @ 7 NONAME ; int CIniData::FindVar(class TDesC16 const &, class TDesC16 const &, int &) - ?FindVar@CIniData@@QAEHABVTDesC16@@0AAVTPtrC16@@@Z @ 8 NONAME ; int CIniData::FindVar(class TDesC16 const &, class TDesC16 const &, class TPtrC16 &) - ?FindVar@CIniData@@QAEHABVTDesC16@@AAH@Z @ 9 NONAME ; int CIniData::FindVar(class TDesC16 const &, int &) - ?FindVar@CIniData@@QAEHABVTDesC16@@AAVTPtrC16@@@Z @ 10 NONAME ; int CIniData::FindVar(class TDesC16 const &, class TPtrC16 &) - ?NewL@CIniData@@SAPAV1@ABVTDesC16@@0@Z @ 11 NONAME ; class CIniData * CIniData::NewL(class TDesC16 const &, class TDesC16 const &) - ?NewL@CIniData@@SAPAV1@ABVTDesC16@@@Z @ 12 NONAME ; class CIniData * CIniData::NewL(class TDesC16 const &) - ?SetValue@CIniData@@QAEHABVTDesC16@@00@Z @ 13 NONAME ; int CIniData::SetValue(class TDesC16 const &, class TDesC16 const &, class TDesC16 const &) - ?SetValue@CIniData@@QAEHABVTDesC16@@0@Z @ 14 NONAME ; int CIniData::SetValue(class TDesC16 const &, class TDesC16 const &) - ?WriteToFileL@CIniData@@QAEXXZ @ 15 NONAME ; void CIniData::WriteToFileL(void) - ?FindVar@CIniData@@QAEHABVTDesC16@@0AA_J@Z @ 16 NONAME ; int CIniData::FindVar(class TDesC16 const &, class TDesC16 const &, long long &) - diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/inifileparser/eabi/iniparseru.def --- a/testexecmdw/tef/inifileparser/eabi/iniparseru.def Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -EXPORTS - _ZN8CIniData10ConstructLERK7TDesC16 @ 1 NONAME - _ZN8CIniData12WriteToFileLEv @ 2 NONAME - _ZN8CIniData4NewLERK7TDesC16 @ 3 NONAME - _ZN8CIniData4NewLERK7TDesC16S2_ @ 4 NONAME - _ZN8CIniData7FindVarERK7TDesC16R7TPtrC16 @ 5 NONAME - _ZN8CIniData7FindVarERK7TDesC16Ri @ 6 NONAME - _ZN8CIniData7FindVarERK7TDesC16S2_R7TPtrC16 @ 7 NONAME - _ZN8CIniData7FindVarERK7TDesC16S2_Ri @ 8 NONAME - _ZN8CIniData8AddValueERK7TDesC16S2_ @ 9 NONAME - _ZN8CIniData8AddValueERK7TDesC16S2_S2_ @ 10 NONAME - _ZN8CIniData8SetValueERK7TDesC16S2_ @ 11 NONAME - _ZN8CIniData8SetValueERK7TDesC16S2_S2_ @ 12 NONAME - _ZN8CIniDataC1ERK7TDesC16 @ 13 NONAME - _ZN8CIniDataC1Ev @ 14 NONAME - _ZN8CIniDataC2ERK7TDesC16 @ 15 NONAME - _ZN8CIniDataC2Ev @ 16 NONAME - _ZN8CIniDataD0Ev @ 17 NONAME - _ZN8CIniDataD1Ev @ 18 NONAME - _ZN8CIniDataD2Ev @ 19 NONAME - _ZTI8CIniData @ 20 NONAME ; ## - _ZTV8CIniData @ 21 NONAME ; ## - _ZN8CIniData7FindVarERK7TDesC16S2_Rx @ 22 NONAME - diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/inifileparser/group/bld.inf --- a/testexecmdw/tef/inifileparser/group/bld.inf Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -// -// 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: -// Reads configuration from ini files for test programs -// - -/** - @file -*/ - - -PRJ_EXPORTS -..\inc\iniparser.h OS_LAYER_PUBLIC_EXPORT_PATH(iniparser.h) -.\iniparser.iby \epoc32\rom\include\iniparser.iby - -PRJ_TESTEXPORTS - -PRJ_MMPFILES -iniparser.mmp - -PRJ_TESTMMPFILES diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/inifileparser/group/inifileparser.mrp --- a/testexecmdw/tef/inifileparser/group/inifileparser.mrp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -# -# 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_testexecmdw_inifileparser -source /src/tools/ana/testfw/testexecmdw/inifileparser -exports /src/tools/ana/testfw/testexecmdw/inifileparser/group -binary /src/tools/ana/testfw/testexecmdw/inifileparser/group all -notes_source /src/tools/ana/testfw/testexecmdw/inifileparser/group/release.txt - - -# == IPR section auto-inserted from distribution.policy files == -ipr T - -# == end auto-inserted section == diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/inifileparser/group/iniparser.cfg --- a/testexecmdw/tef/inifileparser/group/iniparser.cfg Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ -// -// 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 -// - -// Uncomment these lines for an All Capability build -//#if !defined (TEF_ALL_CAP) -//#define TEF_ALL_CAP -//#endif diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/inifileparser/group/iniparser.iby --- a/testexecmdw/tef/inifileparser/group/iniparser.iby Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +0,0 @@ -// -// 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 __INIPARSER_IBY__ -#define __INIPARSER_IBY__ - -file=ABI_DIR\DEBUG_DIR\iniparser.dll sys\bin\iniparser.dll - -#endif diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/inifileparser/group/iniparser.mmp --- a/testexecmdw/tef/inifileparser/group/iniparser.mmp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* -* 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 "iniparser.cfg" - -TARGET iniparser.dll - -CAPABILITY All - -TARGETTYPE dll -UID 0x1000008d 0x10210D51 -VENDORID 0x70000001 -SOURCEPATH ../src -SOURCE iniparser.cpp -USERINCLUDE ../inc -OS_LAYER_SYSTEMINCLUDE_SYMBIAN -LIBRARY efsrv.lib euser.lib - -#if defined(WINS) -#elif defined(GCC32) -DEFFILE ..\arm4\iniparser.def -#else -DEFFILE ..\EABI\iniparser.def -#endif diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/inifileparser/group/release.txt --- a/testexecmdw/tef/inifileparser/group/release.txt Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -NOTESRC_RELEASER -Nokia Corporation. - -NOTESRC_RELEASE_REASON -inifileparser release. diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/inifileparser/inc/iniparser.h --- a/testexecmdw/tef/inifileparser/inc/iniparser.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,98 +0,0 @@ -/* -* 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(__INIPARSER_H__) -#define __INIPARSER_H__ - -#include -#include - -_LIT(KUseSystemDrive, "$:"); - -class CIniData : public CBase -/** - * - * @publishedPartner - * @test - * - * Defines the interface to acess to ini data file - * - * The basic functions, FindVar(), SetValue(), AddValue() and WriteToFileL() - * Compulsory to call WriteToFileL() after calling any SetValue() or AddValue() - */ - { -public: - // Constructor, pass in name of ini file to open - // Default search path is 'c:\system\data' on target filesystem - // ie. 'NewL(_L("c:\\system\\data\\ttools.ini"))' is equivalent - // to 'NewL(_L("ttools.ini"))' - IMPORT_C static CIniData* NewL(const TDesC& aName); - IMPORT_C virtual ~CIniData(); - - IMPORT_C TBool FindVar(const TDesC &aKeyName, // Key to look for - TPtrC &aResult); // Buffer to store value - - IMPORT_C TBool FindVar(const TDesC &aKeyName, // Key to look for - TInt &aResult); // Int ref to store result - - IMPORT_C TBool FindVar(const TDesC &aSection, // Section to look under - const TDesC &aKeyName, // Key to look for - TPtrC &aResult); // Buffer to store result - - IMPORT_C TBool FindVar(const TDesC &aSection, // Section to look under - const TDesC &aKeyName, // Key to look for - TInt &aResult); // Int ref to store result - - IMPORT_C TInt SetValue(const TDesC& aKeyName,// Key to look for - const TDesC& aValue); // aValue being modified - IMPORT_C TInt SetValue(const TDesC& aSection, // Section to look under - const TDesC& aKeyName, // Key to look for - const TDesC& aValue); // aValue being modified - IMPORT_C TInt AddValue(const TDesC& aSection, // Section to look under - const TDesC& aKeyName, // Key to look for - const TDesC& aValue); // aValue being modified - IMPORT_C TInt AddValue(const TDesC& aKeyName, // Key to look for - const TDesC& aValue); // aValue being modified - IMPORT_C void WriteToFileL(); - // Overloaded NewL() added to recieve optional system drive letter from the user - // And expand ${SYSDRIVE} variable. Else, the variable expands to RFs::GetSystemDrive() - IMPORT_C static CIniData* NewL(const TDesC& aName, const TDesC& aSysDrive); -protected: - IMPORT_C CIniData(); - IMPORT_C CIniData(const TDesC& aSysDrive); - IMPORT_C void ConstructL(const TDesC& aName); -public: - IMPORT_C TBool FindVar(const TDesC &aSection, // Section to look under - const TDesC &aKeyName, // Key to look for - TInt64 &aResult); // Int64 ref to store result - -private: - void UpdateVariablesL(); - TBool FindVar(const TDesC &aSectName,const TDesC &aKeyName,TPtrC &aResult, TPtr& aIniDataPtr); -private: - HBufC* iName; - HBufC* iToken; - HBufC* iIniData; - TPtr iPtr; - TPtr iPtrExpandedVars; - TDriveName iDefaultSysDrive; - TDriveName iSysDrive; - }; - -#endif diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/inifileparser/src/iniparser.cpp --- a/testexecmdw/tef/inifileparser/src/iniparser.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,688 +0,0 @@ -/* -* 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: -* CINIDATA.CPP -* -*/ - - - -#include -#include "iniparser.h" - -// Default directory to look for INI file -_LIT(KIniFileDir,"\\System\\Data\\"); -_LIT(KIniSysDrive, "${SYSDRIVE}"); -_LIT(KLegacySysDrive, "C:"); - -// Constant Value changed for defect047130 fix -const TInt KTokenSize=256; - -enum TIniPanic - { - ESectionNameTooBig, - EKeyNameTooBig, - }; - -#ifndef EKA2 -//////////////////////////////////////////////////////////////////////////////// -// -// DLL entry point -// -GLDEF_C TInt E32Dll(TDllReason /*aReason*/) - - { - return (KErrNone); - } -#endif - -//////////////////////////////////////////////////////////////////////////////// -void Panic(TIniPanic aPanic) - { - _LIT(CIniData,"CIniData"); - User::Panic(CIniData,aPanic); - } - -/** - * Updates ${SYSDRIVE} variables in the ini file buffer - * To the system drive set during object constrcution - */ -void CIniData::UpdateVariablesL() - { - if (iIniData != NULL) - { - //prevent re-allocating to copy the same data again - TPtr temp(iIniData->Des()) ; - if(iPtr.Compare(temp) != 0) - { - delete iIniData; - iIniData = NULL ; - } - } - // if iIniData was never allocated or just deleted... - if(iIniData == NULL) - { - iIniData = iPtr.AllocL(); - } - - iPtrExpandedVars.Set(iIniData->Des()); - - if(iPtrExpandedVars.FindF(KIniSysDrive) == KErrNotFound) - return; - - while ( iPtrExpandedVars.Find(KIniSysDrive) != KErrNotFound ) - { - TInt offset = iPtrExpandedVars.Find(KIniSysDrive); - iPtrExpandedVars.Replace(offset, 11, iSysDrive); - } - } - -/** - * Constructor - */ -EXPORT_C CIniData::CIniData() - : iPtr(NULL,0), iPtrExpandedVars(NULL,0) - { - __DECLARE_NAME(_S("CIniData")); - iSysDrive.Copy(KLegacySysDrive); - } - -/** - * Overloaded constructor - * Takes in the system drive letter to overwrite - */ -EXPORT_C CIniData::CIniData(const TDesC& aSysDrive) - : iPtr(NULL,0), iPtrExpandedVars(NULL,0) - { - __DECLARE_NAME(_S("CIniData")); - if ( aSysDrive.Length() == 2 ) - iSysDrive.Copy(aSysDrive); - } - -/** - * Destructor - * Frees the resources located in second-phase constructor - */ -EXPORT_C CIniData::~CIniData() - { - if( iIniData != NULL ) - delete iIniData; - delete (TText*)iPtr.Ptr(); - delete iToken; - delete iName; - } - -/** - * Creates, and returns a pointer to CIniData object, leave on failure - * @param aName - Path and name of the ini file to be parsed - * @return A pointer to the CiniData object - */ -EXPORT_C CIniData* CIniData::NewL(const TDesC& aName) - { - CIniData* p=new(ELeave) CIniData(); - CleanupStack::PushL(p); - p->ConstructL(aName); - CleanupStack::Pop(); - return p; - } - -/** - * Creates, and returns a pointer to CIniData object, leave on failure - * @param aName - Path and name of the ini file to be parsed - * @param aSysDrive - Drive letter to overwrite the default system drive - * @return A pointer to the CiniData object - */ -EXPORT_C CIniData* CIniData::NewL(const TDesC& aName, const TDesC& aSysDrive) - { - CIniData* p=new(ELeave) CIniData(aSysDrive); - CleanupStack::PushL(p); - p->ConstructL(aName); - CleanupStack::Pop(); - return p; - } - -/** - * Second-phase constructor. - * The function attempts to allocate a buffer and Read file's contents into iPtr - * @param aName the name of the file which contains the ini data - * @leave One of the system-wide error codes - */ -EXPORT_C void CIniData::ConstructL(const TDesC& aName) - { - // Allocate space for token - iToken=HBufC::NewL(KTokenSize+2); // 2 extra chars for [tokenName] - - // Connect to file server - TAutoClose fs; - User::LeaveIfError(fs.iObj.Connect()); - fs.PushL(); - - // Find file, given name - TFindFile ff(fs.iObj); - TFileName iniFileDir(KLegacySysDrive); - iniFileDir.Append(KIniFileDir); - User::LeaveIfError(ff.FindByDir(aName, iniFileDir)); - iName=ff.File().AllocL(); - - // Open file - TAutoClose file; - TInt size; - User::LeaveIfError(file.iObj.Open(fs.iObj,*iName,EFileStreamText|EFileShareReadersOrWriters)); - file.PushL(); - - // Get file size and read in - User::LeaveIfError(file.iObj.Size(size)); - TText* data=(TText*)User::AllocL(size); - iPtr.Set(data, size/sizeof(TText), size/sizeof(TText)); - TPtr8 dest((TUint8*)data, 0, size); - User::LeaveIfError(file.iObj.Read(dest)); - TUint8* ptr = (TUint8*)data; - - // - // This is orderred as FEFF assuming the processor is Little Endian - // The data in the file is FFFE. PRR 28/9/98 - // - if(size>=(TInt)sizeof(TText) && iPtr[0]==0xFEFF) - { - // UNICODE Text file so lose the FFFE - Mem::Copy(ptr, ptr+sizeof(TText), size-sizeof(TText)); - iPtr.Set(data, size/sizeof(TText)-1, size/sizeof(TText)-1); - } - else if(size) - { - // NON-UNICODE so convert to UNICODE - TText* newdata = (TText*)User::AllocL(size*sizeof(TText)); - iPtr.Set(newdata, size, size); - TInt i; - for(i=0 ; i 0 ) - { - TBool FoundSection(false); - while ( ! FoundSection ) - { - // Move search buffer to next area of interest - SearchBuf.Set(aIniDataPtr.Mid(posI)); - - // Make up token "[SECTIONNAME]", to search for - TPtr sectionToken=iToken->Des(); - _LIT(sectionTokenFmtString,"[%S]"); - sectionToken.Format(sectionTokenFmtString,&aSectName); - - // Search for next occurrence of aSectName - TInt posSB = SearchBuf.Find(sectionToken); - - if (posSB==KErrNotFound) - return(EFalse); - - // Check this is at beginning of line (ie. non-commented) - // ie. Check preceding char was LF - if(posSB>0) - { - // Create a Buffer, starting one char before found subBuf - TPtrC CharBefore(SearchBuf.Right(SearchBuf.Length()-posSB+1)); - // Check first char is end of prev - if(CharBefore[0] == '\n') - { - FoundSection = ETrue; // found - posI = posI + posSB; - } - else - { - posI = posI + posSB + 1; // try again - } - } - else - { - FoundSection = ETrue; - } - - } // while ( ! FoundSection ) - - // Set start of section, after section name, (incl '[' and ']') - posStartOfSection = posI + aSectName.Length() + 2; - - // Set end of section, by finding begin of next section or end - SearchBuf.Set(aIniDataPtr.Mid(posI)); - _LIT(nextSectionBuf,"\n["); - TInt posSB = SearchBuf.Find(nextSectionBuf); - if(posSB != KErrNotFound) - { - posEndOfSection = posI + posSB; - } - else - { - posEndOfSection = aIniDataPtr.Length(); - } - - } // if( aSectName.Length() > 0 ) - - // Look for key in ini file data Buffer - posI = posStartOfSection; - TBool FoundKey(false); - while ( ! FoundKey ) - { - // Search for next occurrence of aKeyName - SearchBuf.Set(aIniDataPtr.Mid(posI,posEndOfSection-posI)); - TInt posSB = SearchBuf.Find(aKeyName); - - // If not found, return - if (posSB==KErrNotFound) - return(EFalse); - - // Check this is at beginning of line (ie. non-commented) - // ie. Check preceding char was CR or LF - if(posSB>0) - { - // Create a Buffer, starting one char before found subBuf - TPtrC CharBefore(SearchBuf.Right(SearchBuf.Length()-posSB+1)); - // Check if the first char is end of prev and also check - // if the token found is not a substring of another string - TBool beginningOK = ((CharBefore[0] == '\n') || (CharBefore[0] == ' ') || (CharBefore[0] == '\t')); - TBool endingOK = ((CharBefore[aKeyName.Length()+1] == '=') || (CharBefore[aKeyName.Length()+1] == ' ') || (CharBefore[aKeyName.Length()+1] == '\t')); - if (beginningOK && endingOK) - { - FoundKey = ETrue; - posI = posI + posSB; - } - else - { - posI = posI + posSB + 1; - } - } - else - { - FoundKey = ETrue; - } - } // while ( ! FoundKey ) - - // Set pos, to just after '=' sign - SearchBuf.Set(aIniDataPtr.Mid(posI)); - TInt posSB = SearchBuf.Locate('='); - if(posSB==KErrNotFound) // Illegal format, should flag this... - return(EFalse); - - // Identify start and end of data (EOL or EOF) - posI = posI + posSB + 1; // 1 char after '=' - TInt posValStart = posI; - TInt posValEnd; - SearchBuf.Set(aIniDataPtr.Mid(posI)); - posSB = SearchBuf.Locate('\n'); - if(posSB!=KErrNotFound) - { - // ini file uses LF for EOL - posValEnd = posI + posSB; - } - else - { - posValEnd = aIniDataPtr.Length(); - } - - // Check we are still in the section requested - if( aSectName.Length() > 0 ) - { - if( posValEnd > posEndOfSection ) - { - return(EFalse); - } - } - // Parse Buffer from posn of key - // Start one space after '=' - TLex lex(aIniDataPtr.Mid(posValStart, posValEnd-posValStart)); - lex.SkipSpaceAndMark(); // Should be at the start of the data - aResult.Set(lex.MarkedToken().Ptr(),posValEnd-posValStart - lex.Offset() ); - - TInt filterOffset; - - // Mark the offset value to the end of the value string - filterOffset = aResult.Length() - 1; - - // Loop from end of the value string marked by the offset fetched by above process - // And check to see if there is spaces, tabs or carriage returns - while(filterOffset >= 0 && - (aResult[filterOffset] == '\t' || - aResult[filterOffset] == ' ' || - aResult[filterOffset] == '\r')) - { - // If found, reduce the offset by 1 for every space and tab during the while loop - filterOffset--; - } - - // The final offset value indicating end of actual value - // within the ini data is set to the result string reference passed in - aResult.Set(aResult.Mid(0,filterOffset + 1)); - - return(ETrue); - } - -/** - * Find an integer value from given aKeyName regardless the section in the ini data file - * @param aKeyName Key being searched for - * @param aResult On return, contains the TInt result - * @return ETrue if found, otherwise EFalse - */ -EXPORT_C TBool CIniData::FindVar(const TDesC &aKeyName, TInt &aResult) - { - TPtrC ptr(NULL,0); - if (FindVar(aKeyName,ptr)) - { - TLex lex(ptr); - if (lex.Val(aResult)==KErrNone) - return(ETrue); - } - return(EFalse); - } - -/** - * Find an integer value from given aKeyName and aSecName in the ini data file - * @param aSectName Section containing key - * @param aKeyName Key being searched for in aSectName - * @param aResult On return, contains TInt result - * @return ETrue if found, otherwise EFalse - */ -EXPORT_C TBool CIniData::FindVar(const TDesC &aSection,const TDesC &aKeyName,TInt &aResult) - { - TPtrC ptr(NULL,0); - if (FindVar(aSection,aKeyName,ptr)) - { - TLex lex(ptr); - if (lex.Val(aResult)==KErrNone) - return(ETrue); - } - return(EFalse); - } -/** - * Find an 64-bit integer value from given aKeyName and aSecName in the ini data file - * @param aSectName Section containing key - * @param aKeyName Key being searched for in aSectName - * @param aResult On return, contains TInt64 result - * @return ETrue if found, otherwise EFalse - */ -EXPORT_C TBool CIniData::FindVar(const TDesC &aSection, // Section to look under - const TDesC &aKeyName, // Key to look for - TInt64 &aResult) // Int64 ref to store result - { - TPtrC ptr(NULL,0); - if (FindVar(aSection,aKeyName,ptr)) - { - TLex lex(ptr); - if (lex.Val(aResult)==KErrNone) - return(ETrue); - } - return(EFalse); - } -/** - * Set a text value to given aKeyName and aSecName in the ini data file - * @param aSectName Section containing key - * @param aKeyName Key being set in aSectName - * @param aValue A text value set for the aKeyName in section ASecName - * @return KErrNone if sucessful, otherwise system error - */ -EXPORT_C TInt CIniData::SetValue(const TDesC& aSection,const TDesC& aKeyName,const TDesC& aValue) - { - // First find the variable - this gives us a descriptor into the - // ini data giving the bound of the item that has got to be replaced. - TPtrC ptr; - - if (!FindVar(aSection, aKeyName, ptr, iPtr)) - return KErrNotFound; - - TInt pos = ptr.Ptr()-iPtr.Ptr(); - TInt size = iPtr.Length()+aValue.Length()-ptr.Length(); - - if (size>iPtr.MaxLength()) - { - size = size * sizeof(TText); - TText* newdata = (TText*)User::ReAlloc((TUint8*)iPtr.Ptr(), size); - if (newdata == 0) - return KErrNoMemory; - - iPtr.Set(newdata, iPtr.Length(), iPtr.Length()>size/(TInt)sizeof(TText)?iPtr.Length():size/(TInt)sizeof(TText)); - } - iPtr.Replace(pos, ptr.Length(), aValue); - return(KErrNone); - } - -/** - * Set a text value to given aKeyName regardless of the section in the ini data file - * @param aKeyName Key being searched for - * @param aValue A text value set for the aKeyName - * @return KErrNone if sucessful, otherwise system error - */ -EXPORT_C TInt CIniData::SetValue(const TDesC& aKeyName,const TDesC& aValue) - { - // Call with no section, so starts at beginning - return SetValue((TDesC&)KNullDesC, aKeyName, aValue); - } - -/** - * Add key aKeyName to end of ini data file - * @param aKeyName aKeyName Key being added - * @param aValue Text value assigned to the aKeyName - * @return KErrNone if sucessful, otherwise system error - */ -EXPORT_C TInt CIniData::AddValue(const TDesC& aKeyName,const TDesC& aValue) - { - // Call with no section, so starts at beginning - return AddValue((TDesC&)KNullDesC, aKeyName, aValue); - } - -/** - * Add key aKeyName to section aSectName - * @param aSectName Section - * @param aKeyName Key being added to section aSectName - * @param aValue A text value added to the aKeyName - * @return KErrNone if sucessful, otherwise system error - */ -EXPORT_C TInt CIniData::AddValue(const TDesC& aSectName,const TDesC& aKeyName,const TDesC& aValue) - { - // The request will be denied if the variable exists. - // - // If the variable is not there then making an implementation. - // If the Section name existed in the ini file then just append it - // to this section otherwise append the section, key name and - // variable at the end of the ini file. - TPtrC ptr; - - if (FindVar(aSectName, aKeyName, ptr)) - return KErrAlreadyExists; // an key name exists, - // not allow to add value again to same key - ///////////////////////////// - TPtr insertSection =iToken->Des(); - TInt size; - - TInt posEndOfSection(iPtr.Length()); // Default to the entire length of the ini data - TPtrC SearchBuf; - - // If there is a section, set pos to section start - TInt posI(0); // Initiate to 0. Position in internal data Buffer - TInt posSB(0); - if( aSectName.Length() > 0 ) - { - TBool FoundSection(false); - while ( ! FoundSection ) - { - // Move search buffer to next area of interest - SearchBuf.Set(iPtr.Mid(posI)); - - // Make up token "[SECTIONNAME]", to search for - TPtr sectionToken=iToken->Des(); - _LIT(sectionTokenFmtString,"[%S]"); - sectionToken.Format(sectionTokenFmtString,&aSectName); - - // Search for next occurrence of aSectName - posSB = SearchBuf.Find(sectionToken); - - // If not found, return - if (posSB==KErrNotFound) - { - FoundSection = ETrue; //Stop while searching - _LIT(insertSectionfmt,"\r\n[%S]\r\n%S = %S\r\n"); //if there is no section existed - insertSection.Format(insertSectionfmt,&aSectName,&aKeyName, &aValue); - } - - - // Check this is at beginning of line (ie. non-commented) - // ie. Check preceding char was LF - if(posSB>=0) - { - // Create a Buffer, starting one char before found subBuf - TPtrC CharBefore(SearchBuf.Right(SearchBuf.Length()-posSB+1)); - // Check first char is end of prev - if(CharBefore[0] == '\n' or posSB == 0) - { - FoundSection = ETrue; // found - posI = posI + posSB; - _LIT(insertSectionfmt,"\r\n%S = %S\r\n"); //if there is no section existed - insertSection.Format(insertSectionfmt,&aKeyName, &aValue); - } - else - { - posI = posI + posSB + 1; // try again - } - } - else - { - FoundSection = ETrue; //found at the beginning of the search buffer - } - - } // while ( ! FoundSection ) - - // Set start of section, after section name, (incl '[' and ']') - if(posSB!=KErrNotFound) - { - - // Set end of section, by finding begin of next section or end - SearchBuf.Set(iPtr.Mid(posI)); - _LIT(nextSectionBuf,"\n["); - TInt posSB = SearchBuf.Find(nextSectionBuf); - if(posSB != KErrNotFound) - { - posEndOfSection = posI + posSB+1; //insert it between \n and [ - } - else - { - posEndOfSection = iPtr.Length(); - } - } - - } // if( aSectName.Length() > 0 ) - - // append/insert here - size = (iPtr.Length()+ insertSection.Length())*sizeof(TText); - if (size>iPtr.MaxLength()) - { - TText* newdata = (TText*)User::ReAlloc((TUint8*)iPtr.Ptr(), size); - if (newdata == 0) - return KErrNoMemory; - - iPtr.Set(newdata, iPtr.Length(), size/(TInt)sizeof(TText)); - } - - iPtr.Insert(posEndOfSection,insertSection); - return(KErrNone); - } - - -/** - * A method used to flush the data in the buffer to the file given in second-phase constructor - */ -EXPORT_C void CIniData::WriteToFileL() - { - -#ifndef __WINC__ - - TAutoClose fs; - User::LeaveIfError(fs.iObj.Connect()); - fs.PushL(); - - TAutoClose file; - User::LeaveIfError(file.iObj.Replace(fs.iObj,*iName,EFileStreamText|EFileShareExclusive)); - file.PushL(); - - // convert 16 bits to 8 bits stream - - HBufC8* buf8 = HBufC8::NewL(iPtr.Length()); - TPtr8 ptr8(buf8->Des()); - ptr8.Copy(iPtr); - User::LeaveIfError(file.iObj.Write(ptr8)); - - delete buf8; - - // Refresh the iPtrExpandedVars with the new written ini file content - // Repeat the process of expanding the ${SYSDRIVE} - UpdateVariablesL(); - - file.Pop(); - fs.Pop(); -#endif - } diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/group/base_testexecutelite.iby --- a/testexecmdw/tef/tef/group/base_testexecutelite.iby Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -// -// 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 __BASE_TEFLITE_IBY__ -#define __BASE_TEFLITE_IBY__ - -REM This file is intended to be included by oby files which are to be processed "rom.bat" - - -file=\epoc32\release\##MAIN##\##BUILD##\testexecutelite.exe Sys\Bin\testexecute.exe -file=\epoc32\release\##MAIN##\##BUILD##\testexecuteutils.dll Sys\Bin\testexecuteutils.dll - -file=\epoc32\release\##MAIN##\##BUILD##\testexecutelogclient.dll Sys\Bin\testexecutelogclient.dll -file=\epoc32\release\##MAIN##\##BUILD##\testexecutelogengine.exe Sys\Bin\testexecutelogengine.exe -file=\epoc32\release\##MAIN##\##BUILD##\RFileLoggerClient.dll Sys\Bin\RFileLoggerClient.dll -file=\epoc32\release\##MAIN##\##BUILD##\RFileLoggerServer.exe Sys\Bin\RFileLoggerServer.exe -file=\epoc32\release\##MAIN##\##BUILD##\testexecutepipslogclient.dll Sys\Bin\testexecutepipslogclient.dll -file=\epoc32\release\##MAIN##\##BUILD##\wrapperutilsplugin1.dll Sys\Bin\wrapperutilsplugin.dll - -data=\epoc32\data\z\system\data\testexecute.ini system\data\testexecute.ini - -#ifndef __BASE_INIPARSER__ -#define __BASE_INIPARSER__ -file=\epoc32\release\##MAIN##\##BUILD##\iniparser.dll sys\bin\iniparser.dll -#endif __BASE_INIPARSER__ - -#endif __BASE_TEFLITE_IBY__ diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/group/bld.inf --- a/testexecmdw/tef/tef/group/bld.inf Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -// -// 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 "../scriptengine/group/bld.inf" -#include "../tefunit/group/bld.inf" -#include "../javaplugin/group/bld.inf" -#include "../tefutilities/group/bld.inf" -#include "../test/regressiontest/group/bld.inf" - -PRJ_EXPORTS -..\group\testexecute.iby \epoc32\rom\include\testexecute.iby -..\group\testexecute.ini \epoc32\winscw\c\system\data\testexecute.ini -..\group\testexecute.ini \epoc32\data\z\system\data\testexecute.ini -..\group\base_testexecutelite.iby \epoc32\rom\include\base_testexecutelite.iby - -PRJ_MMPFILES - -PRJ_TESTMMPFILES - -PRJ_TESTEXPORTS - - -#if !(defined TEF_LITE_VERSION) -#include "../workshop/demoipsuite/group/bld.inf" -#endif diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/group/release.txt --- a/testexecmdw/tef/tef/group/release.txt Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -NOTESRC_RELEASER -Nokia Corporation. - -NOTESRC_RELEASE_REASON -tef release. diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/group/tef.mrp --- a/testexecmdw/tef/tef/group/tef.mrp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -# -# 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 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/group/tef.tdf --- a/testexecmdw/tef/tef/group/tef.tdf Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,181 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/group/testexecute.cfg --- a/testexecmdw/tef/tef/group/testexecute.cfg Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -// -// 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 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/group/testexecute.iby --- a/testexecmdw/tef/tef/group/testexecute.iby Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -// -// 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_IBY__ -#define __TESTEXECUTE_IBY__ - -#include -#include -#include -#include -#include - -#ifdef TEF_LITE -file=ABI_DIR\DEBUG_DIR\testexecutelite.exe Sys\Bin\testexecute.exe -#else -file=ABI_DIR\DEBUG_DIR\testexecute.exe Sys\Bin\testexecute.exe -#endif - -file=ABI_DIR\DEBUG_DIR\testexecuteutils.dll Sys\Bin\testexecuteutils.dll - - -data=EPOCROOT##epoc32\data\z\system\data\testexecute.ini system\data\testexecute.ini -#endif diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/group/testexecute.ini --- a/testexecmdw/tef/tef/group/testexecute.ini Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -[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 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/group/testexecutelite.cfg --- a/testexecmdw/tef/tef/group/testexecutelite.cfg Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ -// -// 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 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/javaplugin/bin/tef.vp Binary file testexecmdw/tef/tef/javaplugin/bin/tef.vp has changed diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/javaplugin/group/bld.inf --- a/testexecmdw/tef/tef/javaplugin/group/bld.inf Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -// -// 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 -..\bin\tef.vp \epoc32\engineeringtools\plugins\tef.vp - diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/javaplugin/src/plugin.xml --- a/testexecmdw/tef/tef/javaplugin/src/plugin.xml Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/javaplugin/src/tefdocumentloader.java --- a/testexecmdw/tef/tef/javaplugin/src/tefdocumentloader.java Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,82 +0,0 @@ -/* -* 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: -* -*/ - -/*** - * @author - Symbian Ltd 2005 - * - * This file is a plugin file which takes XML and XSL input files and - * requests the DocumentLoaderFactory class to create a data model out of it - * - */ - -import com.symbian.et.viewer.loader.*; -import java.io.File; - -public class TefDocumentLoader implements LoaderFactory -{ - //Constructor - public TefDocumentLoader() - { - } - //To call the transformation function with the specified xml and xsl file - public void loadDocument() throws PluginLoaderException - { - DocumentLoaderFactory lFactory = DocumentLoaderFactory.getInstance(); - lFactory.transform(fXml, fXsl); - lFactory.setModel(); - - } - - //Set the editable to false - public boolean isEditable() - { - return false; - } - - //Set the filterable to true - public boolean isFilterable() - { - return true; - } - - //Set the sortable to true - public boolean isSortable() - { - return true; - } - - //Assign xml file to fxml - public void setXmlFile(String aFile) - { - fXml = new File(aFile); - } - - //Assign xsl file to fxsl - public void setXslFile(String aFile) - { - fXsl = new File(aFile); - } - - - public String getPluginComment() - { - return "TEF report plugin for general purpose viewer"; - } - - private File fXml; - private File fXsl; -} diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/javaplugin/stylesheet/tef.xsl --- a/testexecmdw/tef/tef/javaplugin/stylesheet/tef.xsl Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,215 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - - - - - 2 - - - - - 3 - - - - - 4 - - - - - 5 - - - - - 6 - - - - - 7 - - - - - 8 - - - - - 9 - - - - - 10 - - - - - 11 - - - - - 12 - - - - - 13 - - - - - 14 - - - - - 15 - - - - - 16 - - - - - 17 - - - - - 18 - - - - - 19 - - - - - 20 - - - - - 21 - - - - - 22 - - - - - 23 - - - - - 24 - - - - - 25 - - - - - 26 - - - - - 27 - - - - - 28 - - - - - 29 - - - - - 30 - - - - - 31 - - - - - - - - - - - \ No newline at end of file diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/logger/bmarm/testexecutelogclientu.def --- a/testexecmdw/tef/tef/logger/bmarm/testexecutelogclientu.def Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,10 +0,0 @@ -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 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/logger/bwins/testexecutelogclientu.def --- a/testexecmdw/tef/tef/logger/bwins/testexecutelogclientu.def Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -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 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/logger/bwins/testexecutelogengineu.def --- a/testexecmdw/tef/tef/logger/bwins/testexecutelogengineu.def Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -EXPORTS - ?NewServer@@YAHXZ @ 1 NONAME ; int __cdecl NewServer(void) - diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/logger/eabi/testexecutelogclientu.def --- a/testexecmdw/tef/tef/logger/eabi/testexecutelogclientu.def Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -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 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/logger/group/bld.inf --- a/testexecmdw/tef/tef/logger/group/bld.inf Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -// -// 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 SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(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 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/logger/group/testexecutelogclient.mmp --- a/testexecmdw/tef/tef/logger/group/testexecutelogclient.mmp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* -* 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 "../../Group/testexecute.cfg" -//Unpaged -TARGET testexecutelogclient.dll - -CAPABILITY All -TARGETTYPE dll -UID 0x1000008d 0x101F778B -VENDORID 0x70000001 - -//CAPABILITY ReadSystemData WriteSystemData ReadUserData WriteUserData PhoneNetwork //LocalNetwork - -SOURCEPATH ../src -SOURCE client.cpp - -OS_LAYER_SYSTEMINCLUDE_SYMBIAN - -USERINCLUDE ../src - -LIBRARY euser.lib - diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/logger/group/testexecutelogengine.mmp --- a/testexecmdw/tef/tef/logger/group/testexecutelogengine.mmp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* -* 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 -* -*/ - - - -TARGET testexecutelogengine.exe -CAPABILITY All -Tcb -TARGETTYPE exe -UID 0x100039CE 0x10281ADF -VENDORID 0x70000001 - -//CAPABILITY - -SOURCEPATH ../src -SOURCE server.cpp -SOURCE main.cpp - -OS_LAYER_SYSTEMINCLUDE_SYMBIAN - -USERINCLUDE ../src - -LIBRARY euser.lib -LIBRARY efsrv.lib diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/logger/group/testexecutelogger.iby --- a/testexecmdw/tef/tef/logger/group/testexecutelogger.iby Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -// -// 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\DEBUG_DIR\testexecutelogclient.dll Sys\Bin\testexecutelogclient.dll -file=ABI_DIR\DEBUG_DIR\testexecutelogengine.exe Sys\Bin\testexecutelogengine.exe - -#endif diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/logger/inc/testexecutelog.h --- a/testexecmdw/tef/tef/logger/inc/testexecutelog.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,117 +0,0 @@ -/* -* 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 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/logger/src/client.cpp --- a/testexecmdw/tef/tef/logger/src/client.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,409 +0,0 @@ -/* -* 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 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/logger/src/main.cpp --- a/testexecmdw/tef/tef/logger/src/main.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,79 +0,0 @@ -/* -* 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 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/logger/src/server.cpp --- a/testexecmdw/tef/tef/logger/src/server.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,373 +0,0 @@ -/* -* 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 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/logger/src/server.h --- a/testexecmdw/tef/tef/logger/src/server.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,115 +0,0 @@ -/* -* 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 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/logger/src/server.inl --- a/testexecmdw/tef/tef/logger/src/server.inl Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -/* -* 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 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/logger/test/group/testexecuteloggertest.mmp --- a/testexecmdw/tef/tef/logger/test/group/testexecuteloggertest.mmp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -/* -* 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 -* -*/ - - - -TARGET testexecuteloggertest.exe -TARGETTYPE exe -UID 0x100039CE 0x101F778D -VENDORID 0x70000001 - -SOURCEPATH ../src -SOURCE testexecuteloggertest.cpp - -OS_LAYER_SYSTEMINCLUDE_SYMBIAN - -LIBRARY euser.lib -LIBRARY efsrv.lib -LIBRARY testexecutelogclient.lib diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/logger/test/src/testexecuteloggertest.cpp --- a/testexecmdw/tef/tef/logger/test/src/testexecuteloggertest.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,129 +0,0 @@ -/* -* 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 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/pipslogger/bwins/testexecutepipslogclientu.def --- a/testexecmdw/tef/tef/pipslogger/bwins/testexecutepipslogclientu.def Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -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 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/pipslogger/eabi/testexecutepipslogclientu.def --- a/testexecmdw/tef/tef/pipslogger/eabi/testexecutepipslogclientu.def Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -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 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/pipslogger/group/bld.inf --- a/testexecmdw/tef/tef/pipslogger/group/bld.inf Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -// -// 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 SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(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 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/pipslogger/group/testexecutepipslogclient.mmp --- a/testexecmdw/tef/tef/pipslogger/group/testexecutepipslogclient.mmp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -/* -* 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 "../../Group/testexecute.cfg" - -TARGET testexecutepipslogclient.dll - -CAPABILITY All -TARGETTYPE dll -UID 0x1000008d 0x10210D4D -VENDORID 0x70000001 - -SOURCEPATH ../src -SOURCE client.cpp - -OS_LAYER_SYSTEMINCLUDE_SYMBIAN - -USERINCLUDE ../src - -LIBRARY euser.lib diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/pipslogger/group/testexecutepipslogengine.mmp --- a/testexecmdw/tef/tef/pipslogger/group/testexecutepipslogengine.mmp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -/* -* 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 -* -*/ - - - -TARGET testexecutepipslogengine.exe -CAPABILITY All -Tcb -TARGETTYPE exe -UID 0x100039CE 0x10210D4C -VENDORID 0x70000001 - -SOURCEPATH ../src -SOURCE server.cpp -SOURCE main.cpp - -OS_LAYER_SYSTEMINCLUDE_SYMBIAN -OS_LAYER_LIBC_SYSTEMINCLUDE - -USERINCLUDE ../src - -LIBRARY euser.lib -LIBRARY efsrv.lib - -LIBRARY libc.lib -STATICLIBRARY libcrt0.lib diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/pipslogger/group/testexecutepipslogger.iby --- a/testexecmdw/tef/tef/pipslogger/group/testexecutepipslogger.iby Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +0,0 @@ -// -// 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\DEBUG_DIR\testexecutepipslogengine.exe Sys\Bin\testexecutepipslogengine.exe - -#endif diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/pipslogger/group/testexecutepipsloggerclient.iby --- a/testexecmdw/tef/tef/pipslogger/group/testexecutepipsloggerclient.iby Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -// -// 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\DEBUG_DIR\testexecutepipslogclient.dll Sys\Bin\testexecutepipslogclient.dll - - -#endif diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/pipslogger/inc/testexecutepipslog.h --- a/testexecmdw/tef/tef/pipslogger/inc/testexecutepipslog.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,118 +0,0 @@ -/* -* 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 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/pipslogger/src/client.cpp --- a/testexecmdw/tef/tef/pipslogger/src/client.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,366 +0,0 @@ -/* -* 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 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/pipslogger/src/main.cpp --- a/testexecmdw/tef/tef/pipslogger/src/main.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,84 +0,0 @@ -/* -* 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 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/pipslogger/src/server.cpp --- a/testexecmdw/tef/tef/pipslogger/src/server.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,207 +0,0 @@ -/* -* 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 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/pipslogger/src/server.h --- a/testexecmdw/tef/tef/pipslogger/src/server.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -/* -* 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 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/pipslogger/src/server.inl --- a/testexecmdw/tef/tef/pipslogger/src/server.inl Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -/* -* 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 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/pipslogger/test/group/testexecutepipsloggertest.mmp --- a/testexecmdw/tef/tef/pipslogger/test/group/testexecutepipsloggertest.mmp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -/* -* 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 -* -*/ - - - -TARGET testexecutepipsloggertest.exe -TARGETTYPE exe -UID 0x100039CE 0x101F778D -VENDORID 0x70000001 - -SOURCEPATH ../src -SOURCE testexecutepipsloggertest.cpp - -OS_LAYER_SYSTEMINCLUDE_SYMBIAN -OS_LAYER_LIBC_SYSTEMINCLUDE - -LIBRARY euser.lib -LIBRARY testexecutepipslogclient.lib -LIBRARY libc.lib -STATICLIBRARY libcrt0.lib \ No newline at end of file diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/pipslogger/test/src/testexecutepipsloggertest.cpp --- a/testexecmdw/tef/tef/pipslogger/test/src/testexecutepipsloggertest.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,138 +0,0 @@ -/* -* 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 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/scriptengine/group/bld.inf --- a/testexecmdw/tef/tef/scriptengine/group/bld.inf Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ -// -// 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_MMPFILES -testexecute.mmp -testexecutelite.mmp -gwstestexecute.mmp - diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/scriptengine/group/gwstestexecute.mmp --- a/testexecmdw/tef/tef/scriptengine/group/gwstestexecute.mmp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -/* -* 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 -* Define GWS to include grapical window server -* -*/ - - - -#include "../../Group/testexecute.cfg" -//Unpaged -MACRO GWS -#define GWS - -TARGET gwstestexecute.exe -TARGETTYPE exe -UID 0x100039CE 0x10201D07 -VENDORID 0x70000001 - -SOURCEPATH ../src -SOURCE testexecute.cpp -SOURCE scriptengine.cpp -SOURCE testwatcher.cpp - -OS_LAYER_SYSTEMINCLUDE_SYMBIAN - -USERINCLUDE ../inc -USERINCLUDE ../../utils/inc - -LIBRARY euser.lib -LIBRARY testexecuteutils.lib -LIBRARY efsrv.lib -LIBRARY testexecutelogclient.lib -LIBRARY testexecutepipslogclient.lib -LIBRARY iniparser.lib - - -#if !defined(TEF_LITE_VERSION) -LIBRARY domaincli.lib -LIBRARY ws32.lib -#endif - -// Graphical window server hooks -// Turned off by default -// Add MACRO and #define to turn them on -// NB: This screws up serial comms on -#ifdef GWS -#endif - -// We're quite heavy on the stack... 4k in WinS isn't enough... -EPOCSTACKSIZE 0x11800 -EPOCHEAPSIZE 0x1000 0x1240000 - - diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/scriptengine/group/testexecute.mmp --- a/testexecmdw/tef/tef/scriptengine/group/testexecute.mmp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -/* -* 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 "TestExecuteCommon.mmp" - -OS_LAYER_SYSTEMINCLUDE_SYMBIAN - diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/scriptengine/group/testexecutecommon.mmp --- a/testexecmdw/tef/tef/scriptengine/group/testexecutecommon.mmp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -/* -* 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: -* testexecute.mmp -* Using relative paths for sourcepath and user includes -* -*/ - - -#if !(defined TEF_LITE_VERSION) -TARGET testexecute.exe -#else -TARGET testexecutelite.exe -#endif - -CAPABILITY All -Tcb -TARGETTYPE exe -UID 0x100039CE 0x10210D61 -VENDORID 0x70000001 - -SOURCEPATH ../src -SOURCE testexecute.cpp -SOURCE scriptengine.cpp -SOURCE testwatcher.cpp - -OS_LAYER_SYSTEMINCLUDE_SYMBIAN - -USERINCLUDE ../inc -USERINCLUDE ../../utils/inc - -LIBRARY euser.lib -LIBRARY testexecuteutils.lib -LIBRARY efsrv.lib -LIBRARY testexecutelogclient.lib -LIBRARY testexecutepipslogclient.lib -LIBRARY iniparser.lib - -#if !defined(TEF_LITE_VERSION) -LIBRARY domaincli.lib -LIBRARY ws32.lib -#endif - -// Graphical window server hooks -// Turned off by default -// Add MACRO and #define to turn them on -#ifdef GWS -#endif - -// We're quite heavy on the stack... 4k in WinS isn't enough... -EPOCSTACKSIZE 0x11800 -EPOCHEAPSIZE 0x1000 0x1240000 - diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/scriptengine/group/testexecutelite.mmp --- a/testexecmdw/tef/tef/scriptengine/group/testexecutelite.mmp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -/* -* 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: -* testexecute.mmp -* Using relative paths for sourcepath and user includes -* -*/ - - - -#include "../../Group/testexecutelite.cfg" - -#include "TestExecuteCommon.mmp" - -OS_LAYER_SYSTEMINCLUDE_SYMBIAN - diff -r 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/scriptengine/inc/scriptengine.h --- a/testexecmdw/tef/tef/scriptengine/inc/scriptengine.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,478 +0,0 @@ -/* -* 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 -#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 - // Delete dependence of MW apparc.lib. - // apparc.lib is moved from OS layer to MW layer. - // TEF will delete this dependece because TEF is built on OS layer. - SUB_PROC_TYPE iProgramWS; - 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 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/scriptengine/inc/scriptengine.inl --- a/testexecmdw/tef/tef/scriptengine/inc/scriptengine.inl Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,156 +0,0 @@ -/* -* 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 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/scriptengine/inc/testwatcher.h --- a/testexecmdw/tef/tef/scriptengine/inc/testwatcher.h Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +0,0 @@ -/* -* 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 6edeef394eb7 -r 9397a16b6eb8 testexecmdw/tef/tef/scriptengine/src/scriptengine.cpp --- a/testexecmdw/tef/tef/scriptengine/src/scriptengine.cpp Fri Sep 03 07:55:01 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4039 +0,0 @@ -/* -* 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 -*/ - -// 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()); - } - - // Delete dependence of MW apparc.lib. - // apparc.lib is moved from OS layer to MW layer. - // TEF will delete this dependece because TEF is built on OS layer. - 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); - } - // Delete dependence of MW apparc.lib. - // apparc.lib is moved from OS layer to MW layer. - // TEF will delete this dependece because TEF is built on OS layer. - User::LeaveIfError(iProgramWS.Create(lex.MarkedToken(),iProgramArgs)); - } -#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.Logon(iStatus); - iProgramWS.Resume(); - } - #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