# HG changeset patch # User Maciej Seroka # Date 1258111206 0 # Node ID 862cab47b1ba86bca0e98fc3d28f926112368f4d # Parent dd806856a8f6af6d156b91fabb451e2d4ebd5ddb# Parent 736214c0060b7d0e39566829ffbbb34a5873f807 merged heads - non trivial merge in smoketest. Manual merge of those changes. diff -r dd806856a8f6 -r 862cab47b1ba common/build.postbuild.xml --- a/common/build.postbuild.xml Fri Nov 13 09:56:18 2009 +0000 +++ b/common/build.postbuild.xml Fri Nov 13 11:20:06 2009 +0000 @@ -323,7 +323,8 @@ - + + @@ -343,6 +344,13 @@ + + + + + + + diff -r dd806856a8f6 -r 862cab47b1ba common/tools/ats/smoketest/Group/bld.inf --- a/common/tools/ats/smoketest/Group/bld.inf Fri Nov 13 09:56:18 2009 +0000 +++ b/common/tools/ats/smoketest/Group/bld.inf Fri Nov 13 11:20:06 2009 +0000 @@ -29,3 +29,4 @@ #include "../lbs/group/bld.inf" #include "../uiresources/group/bld.inf" #include "../inputmethods/group/Bld.inf" +#include "../IM/group/bld.inf" diff -r dd806856a8f6 -r 862cab47b1ba common/tools/ats/smoketest/Group/smoketest.pl --- a/common/tools/ats/smoketest/Group/smoketest.pl Fri Nov 13 09:56:18 2009 +0000 +++ b/common/tools/ats/smoketest/Group/smoketest.pl Fri Nov 13 11:20:06 2009 +0000 @@ -69,5 +69,7 @@ copy($epoc . "data/c/smoketest/ui_testsdkskinsu.cfg", "temp/smoketest/general/ui_testsdkskinsu.cfg"); copy($epoc . "release/winscw/udeb/InputMethodSmokeTestModule.dll", "temp/smoketest/winscw_udeb/InputMethodSmokeTestModule.dll"); copy($epoc . "winscw/c/smoketest/InputMethodSmokeTestModule.cfg", "temp/smoketest/general/InputMethodSmokeTestModule.cfg"); +copy($epoc . "release/winscw/udeb/IMApiTest.dll", "temp/smoketest/winscw_udeb/IMApiTest.dll"); +copy($epoc . "data/c/smoketest/imapitest.ini", "temp/smoketest/general/imapitest.ini"); system("7z a -tzip smoketest.zip ./temp/*"); diff -r dd806856a8f6 -r 862cab47b1ba common/tools/ats/smoketest/Group/smoketest.xml --- a/common/tools/ats/smoketest/Group/smoketest.xml Fri Nov 13 09:56:18 2009 +0000 +++ b/common/tools/ats/smoketest/Group/smoketest.xml Fri Nov 13 11:20:06 2009 +0000 @@ -437,6 +437,25 @@ + + + install + + + + + + + + + install + + + + + + + execute @@ -481,6 +500,15 @@ + + + execute + + + + + + @@ -537,5 +565,8 @@ smoketest/general/ui_testsdkskinsu.cfg smoketest/winscw_udeb/InputMethodSmokeTestModule.dll smoketest/general/InputMethodSmokeTestModule.cfg + smoketest/winscw_udeb/IMApiTest.dll + smoketest/general/imapitest.ini + diff -r dd806856a8f6 -r 862cab47b1ba common/tools/ats/smoketest/IM/BWINS/DEMOMODULEU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/tools/ats/smoketest/IM/BWINS/DEMOMODULEU.DEF Fri Nov 13 11:20:06 2009 +0000 @@ -0,0 +1,6 @@ +EXPORTS + ?LibEntryL@@YAPAVCTestModuleBase@@XZ @ 1 NONAME ; class CTestModuleBase * __cdecl LibEntryL(void) + ?SetRequirements@@YAHAAPAVCTestModuleParam@@AAK@Z @ 2 NONAME ; int __cdecl SetRequirements(class CTestModuleParam * &,unsigned long &) + ?Log@CTestLogger1@@SAXV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 3 NONAME ; void CTestLogger1::Log(class TRefByValue, ...) + ?Log@CTestLogger@@SAXV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 4 NONAME ; void CTestLogger::Log(class TRefByValue, ...) + diff -r dd806856a8f6 -r 862cab47b1ba common/tools/ats/smoketest/IM/EABI/DemomoduleU.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/tools/ats/smoketest/IM/EABI/DemomoduleU.def Fri Nov 13 11:20:06 2009 +0000 @@ -0,0 +1,16 @@ +EXPORTS + _Z9LibEntryLv @ 1 NONAME + _Z15SetRequirementsRP16CTestModuleParamRm @ 2 NONAME + _ZN11CTestLogger3LogE11TRefByValueIK7TDesC16Ez @ 3 NONAME + _ZN12CTestLogger13LogE11TRefByValueIK7TDesC16Ez @ 4 NONAME + _ZTI11CTestRunner @ 5 NONAME ; ## + _ZTI14CTestScheduler @ 6 NONAME ; ## + _ZTI19CConnectionObserver @ 7 NONAME ; ## + _ZTI19CIMApiClientHandler @ 8 NONAME ; ## + _ZTV11CTestRunner @ 9 NONAME ; ## + _ZTV14CTestScheduler @ 10 NONAME ; ## + _ZTV19CConnectionObserver @ 11 NONAME ; ## + _ZTV19CIMApiClientHandler @ 12 NONAME ; ## + _ZTI16CImpsSettingFile @ 13 NONAME ; ## + _ZTV16CImpsSettingFile @ 14 NONAME ; ## + diff -r dd806856a8f6 -r 862cab47b1ba common/tools/ats/smoketest/IM/group/Bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/tools/ats/smoketest/IM/group/Bld.inf Fri Nov 13 11:20:06 2009 +0000 @@ -0,0 +1,75 @@ +/* +* Copyright (c) 2002 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 "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: STIF TestFramework's IMApiTest +* +* +*/ + + + +/* +------------------------------------------------------------------------------- + + DESCRIPTION + + Build information for STIF Test Framework's IMApiTest. + +------------------------------------------------------------------------------- +*/ + + +PRJ_PLATFORMS +// specify the platforms your component needs to be built for here +// defaults to WINS MARM so you can ignore this if you just build these +DEFAULT + +PRJ_TESTEXPORTS +// NOTE: If using ARS requirements all export operations should be done under this. +// 'abld test export' +../init/imapitest.ini c:/smoketest/imapitest.ini +//../init/TestFramework.ini /epoc32/winscw/c/TestFramework/TestFramework_im.ini + +PRJ_EXPORTS +// Specify the source file followed by its destination here +// copy will be used to copy the source file to its destination +// If there's no destination then the source file will be copied +// to the same name in /epoc32/include +// Example: +/* +/agnmodel/inc/AGMCOMON.H +*/ + +PRJ_TESTMMPFILES +// NOTE: If using ARS requirements .mmp file operation should be done under this. +// 'abld test build' +IMApiTest.mmp + + +PRJ_MMPFILES +// Specify the .mmp files required for building the important component +// releasables. +// +// Specify "tidy" if the component you need to build doesn't need to be +// released. Specify "ignore" if the MMP file exists but should be +// ignored. +// Example: +/* +/agnmodel/group/agnmodel.mmp +#ifndef __WINS__ +/agnmodel/group/agsvexe.mmp +#endif +*/ + + +// End of File diff -r dd806856a8f6 -r 862cab47b1ba common/tools/ats/smoketest/IM/group/IMApiTest.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/tools/ats/smoketest/IM/group/IMApiTest.mmp Fri Nov 13 11:20:06 2009 +0000 @@ -0,0 +1,74 @@ +/* +* Copyright (c) 2002 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 "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: STIF TestFramework's IMApiTest +* +* +*/ + + + +/* +------------------------------------------------------------------------------- + + DESCRIPTION + + MMP file for STIF Test Framework's IMApiTest. + +------------------------------------------------------------------------------- +*/ +#if defined(__S60_) + //To get the OS_LAYER_SYSTEMINCLUDE-definition + #include +#endif + +TARGET IMApiTest.dll +TARGETTYPE dll +DEFFILE Demomodule.def + +CAPABILITY ALL -TCB +VENDORID 0x101FB657 +SECUREID 0x102073DB + +LIBRARY commdb.lib +LIBRARY euser.lib +LIBRARY stiftestinterface.lib +LIBRARY ECom.lib +LIBRARY bafl.lib +LIBRARY cntmodel.lib +LIBRARY flogger.lib +LIBRARY efsrv.lib +LIBRARY estor.lib // ReadStream + + +SOURCEPATH ../src +SOURCE IMApiTest.cpp +SOURCE IMApiTestCases.cpp +SOURCE IMApiMTHandlers.cpp +SOURCE TestRunner.cpp +SOURCE ParserUtils.cpp + + +USERINCLUDE ../inc +//USERINCLUDE ../../inc + +#if defined(__S60_) + APP_LAYER_SYSTEMINCLUDE +#else + SYSTEMINCLUDE /epoc32/include/ecom +#endif + + +// First UID is DLL UID, Second UID is STIF Test Framework UID +UID 0x1000008D 0x101FB3E7 +// End of File diff -r dd806856a8f6 -r 862cab47b1ba common/tools/ats/smoketest/IM/inc/IMApiMTHandlers.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/tools/ats/smoketest/IM/inc/IMApiMTHandlers.h Fri Nov 13 11:20:06 2009 +0000 @@ -0,0 +1,112 @@ +/* +* Copyright (c) 2002 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 "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Handler class +* +*/ + + +#ifndef TESTHANDLERS_H +#define TESTHANDLERS_H + + +#include +#include "imconnection.h" +#include "imclient.h" +#include "imerrors.h" +#include +// FORWARD Declarations + +// CLASS DECLARATIONS + +//************************************************************************************* +// CIMApiClientHandler +//************************************************************************************* +class CIMApiClientHandler : public MImObserver, public CBase + { + public: + static CIMApiClientHandler* NewL( TRequestStatus& aStatus ); + virtual ~CIMApiClientHandler(); + + void HandleRegisterL( + const TInt aErrorCode ); + + void HandleMessageSentL( + const TInt aOpCode, + const TInt aErrorCode ); + + void HandleNewPToPMessageL( + const TInt aErrorCode, + const TContactItemId aContactId, + const TDesC& aUserId, + const TDesC& aMessageType, + const TDesC8& aContent ); + + void HandleNewPToPMessageL( + const TInt aErrorCode, + const TContactItemId aContactId, + const TDesC& aUserId, + const TDesC& aMessageType, + const TDesC16& aContent ); + + void HandleSendErrorL( + const TInt aOpCode, + const TInt aErrorCode, + MImClientDetailedError* aDetailedError ); + +// protected: + void TimedOut(); + + private: + CIMApiClientHandler( TRequestStatus& aStatus ); + void ConstructL(); + + private: + TRequestStatus& iStatus; + + }; + + +class CConnectionObserver : public CBase, + public MImConnectionObserver + { + public: + static CConnectionObserver* NewL( TRequestStatus& aStatus ); + virtual ~CConnectionObserver(); + + void HandleConnectL( const TInt aErrorCode ); + void HandleDisconnectL(); + + void HandleLoginL( const TInt aErrorCode ); + void HandleCancelLoginL( const TInt aErrorCode ); + void HandleLogoutL( const TInt aErrorCode ); + + private: + CConnectionObserver( TRequestStatus& aStatus ); + void ConstructL(); + + private: + TRequestStatus& iStatus; + }; + +class CTestLogger : public CBase + { + public: + //IMPORT_C static void CTestLogger::Log(TRefByValue aFmt,...); + IMPORT_C static void Log( TRefByValue aFmt, ... ); + }; + + + + +#endif diff -r dd806856a8f6 -r 862cab47b1ba common/tools/ats/smoketest/IM/inc/IMApiTest.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/tools/ats/smoketest/IM/inc/IMApiTest.h Fri Nov 13 11:20:06 2009 +0000 @@ -0,0 +1,330 @@ +/* +* Copyright (c) 2002 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 "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This class contains all test framework related parts of + this test module. +* +* +*/ + + + +/* +------------------------------------------------------------------------------- + + DESCRIPTION + + This file contains the header file of IMApiTest of + STIF TestFramework. + +------------------------------------------------------------------------------- +*/ +#ifndef IMApiTest_H +#define IMApiTest_H + +// INCLUDES +#include "StifTestModule.h" +#include +#include "IMApiMTHandlers.h" +#include "imerrors.h" +#include "imconnection.h" +#include "imclient.h" +#include "TestRunner.h" + +// CONSTANTS +// None + +// MACROS +// None + +// Logging path +_LIT( KIMApiTestLogPath, "\\logs\\testframework\\IMApiTest\\" ); +// Log file +_LIT( KIMApiTestLogFile, "IMApiTest.txt" ); + +// Function pointer related internal definitions + +#define GETPTR & +#define ENTRY(str,func) {_S(str), GETPTR func,0,0,0} +#define FUNCENTRY(func) {_S(#func), GETPTR func,0,0,0} +#define OOM_ENTRY(str,func,a,b,c) {_S(str), GETPTR func,a,b,c} +#define OOM_FUNCENTRY(func,a,b,c) {_S(#func), GETPTR func,a,b,c} + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +class CIMApiTest; + +// DATA TYPES +// None + +// A typedef for function that does the actual testing, +// function is a type +// TInt CIMApiTest:: ( TTestResult& aResult ) +typedef TInt ( CIMApiTest::* TestFunction )( TTestResult& ); + +// CLASS DECLARATION + +/** +* An internal structure containing a test case name and +* the pointer to function doing the test +* +* @lib ?library +* @since ?Series60_version +*/ +class TCaseInfoInternal + { + public: + const TText* iCaseName; + TestFunction iMethod; + TBool iIsOOMTest; + TInt iFirstMemoryAllocation; + TInt iLastMemoryAllocation; + }; + +// CLASS DECLARATION + +/** +* A structure containing a test case name and +* the pointer to function doing the test +* +* @lib ?library +* @since ?Series60_version +*/ +class TCaseInfo + { + public: + TPtrC iCaseName; + TestFunction iMethod; + TBool iIsOOMTest; + TInt iFirstMemoryAllocation; + TInt iLastMemoryAllocation; + + TCaseInfo( const TText* a ) : iCaseName( ( TText* ) a ) + { + }; + + }; + + +// CLASS DECLARATION + +/** +* This a IMApiTest class. +* ?other_description_lines +* +* @lib ?library +* @since ?Series60_version +*/ +NONSHARABLE_CLASS( CIMApiTest ) : public CTestModuleBase + { +public: // Constructors and destructor + + + /** + * Two-phased constructor. + */ + static CIMApiTest* NewL(); + + /** + * Destructor. + */ + virtual ~CIMApiTest(); + +public: // New functions + // None + +public: // Functions from base classes + + /** + * From CTestModuleBase InitL is used to initialize the + * IMApiTest. It is called once for every instance of + * TestModuleIMApiTest after its creation. + * @since ?Series60_version + * @param aIniFile Initialization file for the test module (optional) + * @param aFirstTime Flag is true when InitL is executed for first + * created instance of IMApiTest. + * @return Symbian OS error code + */ + TInt InitL( TFileName& aIniFile, TBool aFirstTime ); + + /** + * From CTestModuleBase GetTestCasesL is used to inquiry test cases + * from IMApiTest. + * @since ?Series60_version + * @param aTestCaseFile Test case file (optional) + * @param aTestCases Array of TestCases returned to test framework + * @return Symbian OS error code + */ + TInt GetTestCasesL( const TFileName& aTestCaseFile, + RPointerArray& aTestCases ); + + /** + * From CTestModuleBase RunTestCaseL is used to run an individual + * test case. + * @since ?Series60_version + * @param aCaseNumber Test case number + * @param aTestCaseFile Test case file (optional) + * @param aResult Test case result returned to test framework (PASS/FAIL) + * @return Symbian OS error code (test case execution error, which is + * not reported in aResult parameter as test case failure). + */ + TInt RunTestCaseL( const TInt aCaseNumber, + const TFileName& aTestCaseFile, + TTestResult& aResult ); + + /** + * From CTestModuleBase; OOMTestQueryL is used to specify is particular + * test case going to be executed using OOM conditions + * @param aTestCaseFile Test case file (optional) + * @param aCaseNumber Test case number (optional) + * @param aFailureType OOM failure type (optional) + * @param aFirstMemFailure The first heap memory allocation failure value (optional) + * @param aLastMemFailure The last heap memory allocation failure value (optional) + * @return TBool + */ + virtual TBool OOMTestQueryL( const TFileName& /* aTestCaseFile */, + const TInt /* aCaseNumber */, + TOOMFailureType& aFailureType, + TInt& /* aFirstMemFailure */, + TInt& /* aLastMemFailure */ ); + + /** + * From CTestModuleBase; OOMTestInitializeL may be used to initialize OOM + * test environment + * @param aTestCaseFile Test case file (optional) + * @param aCaseNumber Test case number (optional) + * @return None + */ + virtual void OOMTestInitializeL( const TFileName& /* aTestCaseFile */, + const TInt /* aCaseNumber */ ); + /** + * From CTestModuleBase; OOMTestFinalizeL may be used to finalize OOM + * test environment + * @param aTestCaseFile Test case file (optional) + * @param aCaseNumber Test case number (optional) + * @return None + */ + virtual void OOMTestFinalizeL( const TFileName& /* aTestCaseFile */, + const TInt /* aCaseNumber */ ); + + /** + * From CTestModuleBase; OOMHandleWarningL + * @param aTestCaseFile Test case file (optional) + * @param aCaseNumber Test case number (optional) + * @param aFailNextValue FailNextValue for OOM test execution (optional) + * @return None + */ + virtual void OOMHandleWarningL( const TFileName& /* aTestCaseFile */, + const TInt /* aCaseNumber */, + TInt& /* aFailNextValue */ ); +protected: // New functions + // None + +protected: // Functions from base classes + // None + +private: + + /** + * C++ default constructor. + */ + CIMApiTest(); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + // Prohibit copy constructor if not deriving from CBase. + // ?classname( const ?classname& ); + // Prohibit assigment operator if not deriving from CBase. + // ?classname& operator=( const ?classname& ); + + /** + * Function returning test case name and pointer to test case function. + * @since ?Series60_version + * @param aCaseNumber test case number + * @return TCaseInfo + */ + const TCaseInfo Case ( const TInt aCaseNumber ) const; + + /** + * Printing loop test case. + * @since ?Series60_version + * @param aResult Test case result (PASS/FAIL) + * @return Symbian OS error code (test case execution error + * that is not returned as test case result in aResult) + */ + TInt CreateImClientL( TTestResult& aResult ); + TInt InvalidLoginL( TTestResult& aResult ); + TInt LoginL( TTestResult& aResult ); + TInt SendPToPValidUserIDL( TTestResult& aResult ); + TInt SendPToPValidTwoUserIDL( TTestResult& aResult ); + TInt SendPToPValidContactL( TTestResult& aResult ); + TInt SendPToPValidTwoContactL( TTestResult& aResult ); + TInt SendPToPContactContentTypeL( TTestResult& aResult ); + TInt SendPToPUserIDContentTypeL( TTestResult& aResult ); + TInt LogoutL( TTestResult& aResult ); + TInt CancelLoginL( TTestResult& aResult ); + +public: // Data + // None + +protected: // Data + // None + +private: // Data + // Pointer to test (function) to be executed + TestFunction iMethod; + + // Pointer to logger + CStifLogger * iLog; + CTestRunner* iRunner; + + CIMApiClientHandler* iImObserver; + CConnectionObserver* iConnObserver; + CImConnection* iOpenApi; + MImClient* iImClient; + CConsoleBase* iConsole; + TBool iRepeat; + + /*TInt iAP; + TBuf<50> iUser; + TBuf<50> iPwd; + TBuf<50> iRecipient; + TBuf<50> iRecipient1; + TBuf<50> iMySapAp; + TBuf<50> iClientId; + */ + // ?one_line_short_description_of_data + //?data_declaration; + + // Reserved pointer for future extension + //TAny* iReserved; + +public: // Friend classes + // None + friend class CTestRunner; +protected: // Friend classes + // None + +private: // Friend classes + // None + + }; + +#endif // IMApiTest_H + +// End of File \ No newline at end of file diff -r dd806856a8f6 -r 862cab47b1ba common/tools/ats/smoketest/IM/inc/ParserUtils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/tools/ats/smoketest/IM/inc/ParserUtils.h Fri Nov 13 11:20:06 2009 +0000 @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2002 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 "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: The class handles IMPS Setting file reading. +* +*/ + + +#include +#include + +// FORWARD DECLARATION + +//********************************** +// CImpsSettingFile +//********************************** +// Read key-value pairs from ASCII file +class CImpsSettingFile: public CBase + { + public: + /** + * Constructor. + */ + static CImpsSettingFile* NewL( + RFs& aFs ); + + ~CImpsSettingFile(); + + /** + * Opens a file. It is closed in destructor! + */ + void OpenL( TDesC& aResFile ); + + /** + * Get the key value. Leave with KErrNotFound if not found. + */ + TPtrC8 KeyValueL( const TDesC8& aKey ); + + private: + CImpsSettingFile( RFs& aFs ); + + void ReadRowL( TPtrC8& aKey, TPtrC8& aValue ); + private: + // Data + RFs& iFs; + RFileReadStream iReader; + TBuf8<128> iRowBuffer; + TFileName iFileName; + TBool iOpen; + + }; + +// End of File diff -r dd806856a8f6 -r 862cab47b1ba common/tools/ats/smoketest/IM/inc/TestRunner.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/tools/ats/smoketest/IM/inc/TestRunner.h Fri Nov 13 11:20:06 2009 +0000 @@ -0,0 +1,183 @@ +/* +* Copyright (c) 2002 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 "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: The class handles the test case running. +* +*/ + + +#ifndef TESTRUNNER_H +#define TESTRUNNER_H + +// INCLUDES +#include +#include +#include "IMApiMTHandlers.h" +#include "StifTestModule.h" +#include +#include + +#include +#include +#include +#include +#include + + + +// FORWARD DECLARATIONS +class CTestRunner; + +// FORWARD DECLARATIONS +class CErrorHandler; +class CAccessHandler; +class CTestIdleTimer; +class CTestTimer; +class CPureHandler; + +// ENUMS + +enum TWhichCase + { + InvalidLogin = 1, + Login, + SendMessageValidUserId, + SendMessageValidTwoUserId, + SendMessageValidContact, + SendMessageValidTwoContact, + SendPToPContactContentType, + SendPToPUserIDContentType, + Logout, + CancelLogin, + Finish, + CreateImClient + }; + + +// CONSTANTS +const TInt KImpsMaxLen = 100; +const TInt KImpsMaxSapLen = 100; +const TInt KImpsMaxUserIdLen = 50; +const TInt KImpsMaxClientIdLen = 64; // maximum Client ID, this is not sure! + + +// CLASS DECLARATIONS + + +class CTestRunner : public CActive + { + public: + /** + * Static factory method, + * + * Entry point into Symbian's 2 phase construction pattern. + */ + static CTestRunner* NewL(); + + /** + * Destructor. + */ + virtual ~CTestRunner(); + + /** + * Start the execution. + */ + void StartRunL( TWhichCase aCase ); + + CContactIdArray* GetWVContactIdsLC(); + + /** + * Symbian's 2 phase construction pattern. + */ + void ConstructL( ); + + TInt CreateInstanceL(); + TInt RegisterConnObserverL(); + TInt LoadIMInterfaceL(); + TInt IMRegisterL(); + TInt LoginL( const TDesC& aUserID ); + TInt SendPToPValidUserIDL(); + TInt SendPToPValidTwoUserIDL(); + TInt SendPToPValidContactL(); + TInt SendPToPValidTwoContactL(); + TInt SendPToPContactContentTypeL(); + TInt SendPToPUserIDContentTypeL(); + TInt QueryIMConnectionStatusL(); + TInt CancelLoginL(); + + void GetDefaultAccessPoint(); + + void ReadIniFileL(); + TBuf iSapValue; + TBuf iUserIdValue; + TBuf iPassword; + TBuf iClientId; // 1.3 Client ID Implementation + TBuf iUserId1; + TBuf iUserId2; + TInt iIAP; + + public: // Functions from base classes + + /** + * Active object completion + */ + void RunL(); + /** + * Active object cancellation + */ + void DoCancel(); + + private: + + // By default, prohibit copy constructor + CTestRunner( const CTestRunner& ); + + // Prohibit assigment operator + CTestRunner& operator= ( const CTestRunner& ); + + /** + * C-style constructor. + */ + CTestRunner(); + + // actual runner, that is leave trapped + void DoRunL(); + + private: // Data + + TWhichCase iCase; + CIMApiClientHandler* iImObserver; //earlier code + //MImObserver* iImObserver; + CConnectionObserver* iConnObserver; + CImConnection* iOpenApi; + MImClient* iImClient; + CStifLogger* iLog; + CContactDatabase* iDatabase; + }; + + + +class CTestScheduler : public CActiveScheduler + { + public: + void Error ( TInt aError ) const; + }; + +class CTestLogger1 : public CBase + { + public: + //IMPORT_C static void CTestLogger::Log(TRefByValue aFmt,...); + IMPORT_C static void Log( TRefByValue aFmt, ... ); + }; + +#endif diff -r dd806856a8f6 -r 862cab47b1ba common/tools/ats/smoketest/IM/init/TestFramework.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/tools/ats/smoketest/IM/init/TestFramework.ini Fri Nov 13 11:20:06 2009 +0000 @@ -0,0 +1,192 @@ +# +# This is STIFTestFramework initialization file +# Comment lines start with '#'-character. +# See STIF TestFramework users guide.doc for instructions + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set following test engine settings: +# - Set Test Reporting mode. TestReportMode's possible values are: +# + 'Summary': Summary of the tested test cases. +# + 'Environment': Hardware and software info. +# + 'TestCases': Test case report. +# + 'FullReport': Set of all above ones. +# + Example 'TestReportMode= Summary TestCases' +# +# - CreateTestReport setting controls report creation mode +# + YES, Test report will created. +# + NO, No Test report. +# +# - File path indicates the base path of the test report. +# - File name indicates the name of the test report. +# +# - File format indicates the type of the test report. +# + TXT, Test report file will be txt type, for example 'TestReport.txt'. +# + HTML, Test report will be html type, for example 'TestReport.html'. +# +# - File output indicates output source of the test report. +# + FILE, Test report logging to file. +# + RDEBUG, Test report logging to using rdebug. +# +# - File Creation Mode indicates test report overwriting if file exist. +# + OVERWRITE, Overwrites if the Test report file exist. +# + APPEND, Continue logging after the old Test report information if +# report exist. +# - Sets a device reset module's dll name(Reboot). +# + If Nokia specific reset module is not available or it is not correct one +# StifHWResetStub module may use as a template for user specific reset +# module. +# - Sets STIF test measurement disable options. e.g. pluging1 and pluging2 disablation +# DisableMeasurement= stifmeasurementplugin01 stifmeasurementplugin02 +# + +[Engine_Defaults] + +TestReportMode= FullReport # Possible values are: 'Empty', 'Summary', 'Environment', + 'TestCases' or 'FullReport' + +CreateTestReport= YES # Possible values: YES or NO + +TestReportFilePath= C:\LOGS\TestFramework\ +TestReportFileName= TestReport + +TestReportFormat= TXT # Possible values: TXT or HTML +TestReportOutput= FILE # Possible values: FILE or RDEBUG +TestReportFileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +DeviceResetDllName= StifResetForNokia.dll # e.g. 'StifHWResetStub.dll' for user specific reseting + +DisableMeasurement= stifmeasurementdisablenone # Possible values are: + # 'stifmeasurementdisablenone', 'stifmeasurementdisableall' + # 'stifmeasurementplugin01', 'stifmeasurementplugin02', + # 'stifmeasurementplugin03', 'stifmeasurementplugin04', + # 'stifmeasurementplugin05' or 'stifbappeaprofiler' + +[End_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Module configurations start +# Modules are added between module tags +# tags. Module name is specified after ModuleName= tag, like +# ModuleName= XXXXXXXXX +# Modules might have initialisation file, specified as +# IniFile= c:\testframework\YYYYYY +# Modules might have several configuration files, like +# TestCaseFile= c:\testframework\NormalCases.txt +# TestCaseFile= c:\testframework\SmokeCases.txt +# TestCaseFile= c:\testframework\ManualCases.txt + +# (TestCaseFile is synonym for old term ConfigFile) + +# Following case specifies demo module settings. Demo module +# does not read any settings from file, so tags +# IniFile and TestCaseFile are not used. +# In the simplest case it is enough to specify only the +# name of the test module when adding new test module +[New_Module] +ModuleName= IMApiTest +[End_Module] + +# Load testmoduleXXX, optionally with initialization file and/or test case files +#[New_Module] +#ModuleName= testmodulexxx + +#TestModuleXXX used initialization file +#IniFile= c:\testframework\init.txt + +#TestModuleXXX used configuration file(s) +#TestCaseFile= c:\testframework\testcases1.cfg +#TestCaseFile= c:\testframework\testcases2.cfg +#TestCaseFile= c:\testframework\manualtestcases.cfg + +#[End_Module] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set STIFTestFramework logging overwrite parameters for Logger. +# Hardware and emulator environment logging path and styles can +# be configured from here to overwrite the Logger's implemented values. +# +# Settings description: +# - Indicates option for creation log directory/directories. If log directory/directories +# is/are not created by user they will make by software. +# + YES, Create log directory/directories if not allready exist. +# + NO, Log directory/directories not created. Only created one is used. +# +# - Overwrite emulator path setting. +# + Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined +# Logger's path 'D:\\LOGS\\Module\\' with those definition the path +# will be 'C:\LOGS\TestFramework\LOGS\Module\' +# +# - Overwrite emulator's logging format. +# + TXT, Log file(s) will be txt type(s), for example 'Module.txt'. +# + HTML, Log file(s) will be html type(s), for example 'Module.html'. +# +# - Overwrited emulator logging output source. +# + FILE, Logging to file(s). +# + RDEBUG, Logging to using rdebug(s). +# +# - Overwrite hardware path setting (Same description as above in emulator path). +# - Overwrite hardware's logging format(Same description as above in emulator format). +# - Overwrite hardware's logging output source(Same description as above in emulator output). +# +# - File Creation Mode indicates file overwriting if file exist. +# + OVERWRITE, Overwrites if file(s) exist. +# + APPEND, Continue logging after the old logging information if file(s) exist. +# +# - Will thread id include to the log filename. +# + YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'. +# + NO, No thread id to log file(s), Example filename 'Module.txt'. +# +# - Will time stamps include the to log file. +# + YES, Time stamp added to each line in log file(s). Time stamp is +# for example'12.Nov.2003 115958 LOGGING INFO' +# + NO, No time stamp(s). +# +# - Will line breaks include to the log file. +# + YES, Each logging event includes line break and next log event is in own line. +# + NO, No line break(s). +# +# - Will event ranking include to the log file. +# + YES, Event ranking number added to each line in log file(s). Ranking number +# depends on environment's tics, for example(includes time stamp also) +# '012 12.Nov.2003 115958 LOGGING INFO' +# + NO, No event ranking. +# +# - Will write log file in unicode format. +# + YES, Log file will be written in unicode format +# + NO, Log will be written as normal, not unicode, file. +# + +[Logger_Defaults] + +#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#' +#NOTE: TestEngine and TestServer logging settings cannot change here + +#CreateLogDirectories= YES # Possible values: YES or NO + +#EmulatorBasePath= C:\LOGS\TestFramework\ +#EmulatorFormat= HTML # Possible values: TXT or HTML +#EmulatorOutput= FILE # Possible values: FILE or RDEBUG + +#HardwareBasePath= D:\LOGS\TestFramework\ +#HardwareFormat= HTML # Possible values: TXT or HTML +#HardwareOutput= FILE # Possible values: FILE or RDEBUG + +#FileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +#ThreadIdToLogFile= YES # Possible values: YES or NO +#WithTimeStamp= YES # Possible values: YES or NO +#WithLineBreak= YES # Possible values: YES or NO +#WithEventRanking= YES # Possible values: YES or NO + +#FileUnicode= YES # Possible values: YES or NO + +[End_Logger_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + +# End of file \ No newline at end of file diff -r dd806856a8f6 -r 862cab47b1ba common/tools/ats/smoketest/IM/init/imapitest.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/tools/ats/smoketest/IM/init/imapitest.ini Fri Nov 13 11:20:06 2009 +0000 @@ -0,0 +1,33 @@ +# IMPS Engine IM SDK API test module static settings +# Copy this file to %epocroot%\testframework + +# SAP +# Service Access Point for Presence services +SAP=http://195.134.231.100/wv + +# Userid +# UserId of the SIM registered at SAP +Userid=test + +# Password +# password for accessing SAP +password=test + +# Clientid +# no need to modify this +clientid=apiclient@imps.org + +# IAP +# If run on emulator, IAP=11 +# If run on HW, IAP is ID of Access Point using the SIM Operator's GPRS network, This can be found from "Access point" settings on Phone +IAP=13 + +# userid1 +# Any other userid +userid1=bc2 + +#userid2 +# Any other userid +userid2=bc3 + +# end of file diff -r dd806856a8f6 -r 862cab47b1ba common/tools/ats/smoketest/IM/src/IMApiMTHandlers.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/tools/ats/smoketest/IM/src/IMApiMTHandlers.cpp Fri Nov 13 11:20:06 2009 +0000 @@ -0,0 +1,300 @@ +/* +* Copyright (c) 2002 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 "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Handler class +* +* +*/ + + +// INCLUDE FILES +#include +#include +#include "IMApiMTHandlers.h" +#include "TestRunner.h" + +/****************************************************************************** +* +* CIMApiClientHandler +* +******************************************************************************/ + +////////////////////////////////////////////////////////////////////////// +// Handler class +CIMApiClientHandler* CIMApiClientHandler::NewL( TRequestStatus& aStatus ) + { + CIMApiClientHandler* self = new( ELeave ) CIMApiClientHandler( aStatus ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +void CIMApiClientHandler::ConstructL() + { + } + +CIMApiClientHandler::CIMApiClientHandler( TRequestStatus& aStatus ) + : iStatus( aStatus ) + { + } + +CIMApiClientHandler::~CIMApiClientHandler() + { + } + + +void CIMApiClientHandler::HandleMessageSentL( const TInt aOpCode, + const TInt aErrorCode ) + { + TRequestStatus* s = &iStatus; + CTestLogger::Log( _L( "HandleMessageSentL Passed - aErrorCode=%d" ), aErrorCode ); + + if ( aErrorCode == 0 || aErrorCode == KImApiErrInvalidUserId || aErrorCode == KImApiErrNotLogged || aErrorCode == KImApiErrPartialSuccess ) + { + if ( aErrorCode == 0 ) + { + User::RequestComplete( s, KErrNone ); // OK + } + else if ( aErrorCode == KImApiErrInvalidUserId ) + { + User::RequestComplete( s, KErrNone ); // OK + } + else if ( aErrorCode == KImApiErrPartialSuccess ) + { + User::RequestComplete( s, KErrNone ); // OK + } + else + { + User::RequestComplete( s, KErrNone ); + } + } + else + { + User::RequestComplete( s, aErrorCode ); // FAILED + } + } + +void CIMApiClientHandler::HandleSendErrorL( const TInt aOpCode, + const TInt aErrorCode, + MImClientDetailedError* aDetailedError ) + + { + TRequestStatus* s = &iStatus; + TBuf<500> buffer; + + CTestLogger::Log( _L( "HandleSendErrorL - aErrorCode=%d" ), aErrorCode ); + if ( aErrorCode == 0 || aErrorCode == KImApiErrInvalidUserId || aErrorCode == KImApiErrNotLogged || aErrorCode == KImApiErrPartialSuccess ) + { + if ( aErrorCode == 0 ) + { + User::RequestComplete( s, KErrNone ); // OK + } + else if ( aErrorCode == KImApiErrInvalidUserId ) + { + User::RequestComplete( s, KErrNone ); // OK + } + else if ( aErrorCode == KImApiErrPartialSuccess ) + { + for ( TInt i = 0; i < aDetailedError->Count(); i++ ) + { + buffer.Copy( aDetailedError->UserId( i ) ); + } + User::RequestComplete( s, KErrNone ); // OK + } + else + { + User::RequestComplete( s, KErrNone ); + } + } + else + { + User::RequestComplete( s, KErrNone ); // PASSED sad but true + } + } + + +void CIMApiClientHandler::HandleNewPToPMessageL( const TInt aErrorCode, + const TContactItemId aContactId, + const TDesC& aUserId, + const TDesC& aMessageType, + const TDesC16& aContent ) + { + TRequestStatus* s = &iStatus; + CTestLogger::Log( _L( "HandleNewPToPMessageL Passed - aErrorCode=%d" ), aErrorCode ); + + if ( aErrorCode == 0 ) + { + User::RequestComplete( s, KErrNone ); + } + else + { + User::RequestComplete( s, aErrorCode ); + } + } + +void CIMApiClientHandler::HandleNewPToPMessageL( const TInt aErrorCode, + const TContactItemId aContactId, + const TDesC& aUserId, + const TDesC& aMessageType, + const TDesC8& aContent ) + { + TRequestStatus* s = &iStatus; + CTestLogger::Log( _L( "HandleNewPToPMessageL Passed - aErrorCode=%d" ), aErrorCode ); + if ( aErrorCode == 0 ) + { + User::RequestComplete( s, KErrNone ); + } + else + { + User::RequestComplete( s, aErrorCode ); + } + } + + +void CIMApiClientHandler::TimedOut() + { + TRequestStatus* s = &iStatus; + User::RequestComplete( s, KErrTimedOut ); + } + + + +////////////////////////////////////////////////////////////////////////// + +CConnectionObserver* CConnectionObserver::NewL( TRequestStatus& aStatus ) + { + CConnectionObserver* self = new( ELeave ) CConnectionObserver( aStatus ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +void CConnectionObserver::ConstructL() + { + } + +CConnectionObserver::CConnectionObserver( TRequestStatus& aStatus ) + : iStatus( aStatus ) + { + } + +CConnectionObserver::~CConnectionObserver() + { + } + + +void CConnectionObserver::HandleConnectL( const TInt aErrorCode ) + { + TRequestStatus* s = &iStatus; + CTestLogger::Log( _L( "HandleConnectL Passed - aErrorCode=%d" ), aErrorCode ); + + if ( aErrorCode == 0 ) + { + User::RequestComplete( s, KErrNone ); // OK + } + else if ( aErrorCode == KImApiErrInvalidUserId ) + { + User::RequestComplete( s, KErrNone ); // OK + } + else if ( aErrorCode == -33 ) + { + User::RequestComplete( s, aErrorCode ); // FAILED + } + else if ( aErrorCode == -4154 ) + { + User::RequestComplete( s, aErrorCode ); // FAILED + } + else if ( aErrorCode == -16 ) + { + User::RequestComplete( s, KErrNone ); // OK IN IMAPI POINT OF WIEV + } + else if ( aErrorCode == KImApiErrLoginInProgress ) + { + User::RequestComplete( s, KErrNone ); // OK IN IMAPI POINT OF WIEV + } + else + { + User::RequestComplete( s, aErrorCode );// FAILED + } + } + +void CConnectionObserver::HandleDisconnectL() + { + TRequestStatus* s = &iStatus; + CTestLogger::Log( _L( " HandleDisconnectL " ) ); + User::RequestComplete( s, KErrNone ); //OK + } + +void CConnectionObserver::HandleLoginL( const TInt aErrorCode ) + { + CTestLogger::Log( _L( "HandleLoginL Passed - aErrorCode=%d" ), aErrorCode ); + + TRequestStatus* s = &iStatus; + if ( aErrorCode == 0 ) + { + User::RequestComplete( s, KErrNone ); + } + else + { + User::RequestComplete( s, aErrorCode ); + } + } + +void CConnectionObserver::HandleCancelLoginL( const TInt aErrorCode ) + { + CTestLogger::Log( _L( "HandleCancelLoginL Passed - aErrorCode=%d" ), aErrorCode ); + TRequestStatus* s = &iStatus; + if ( aErrorCode == 0 ) + { + User::RequestComplete( s, KErrNone ); + } + else + { + User::RequestComplete( s, aErrorCode ); + } + } + +void CConnectionObserver::HandleLogoutL( const TInt aErrorCode ) + { + CTestLogger::Log( _L( "HandleLogoutL Passed- aErrorCode=%d" ), aErrorCode ); + CActiveScheduler::Stop(); + } + + + +//********************************** +// CImpsClientLogger +//********************************** +const TInt KLogBufferLength = 256; +_LIT( KLogDir, "impsc" ); +_LIT( KLogFile, "IMAPIHandlersLog.txt" ); + +EXPORT_C void CTestLogger::Log( TRefByValue aFmt, ... ) + { + VA_LIST list; + VA_START( list, aFmt ); + + // Print to log file + TBuf buf; + buf.FormatList( aFmt, list ); + + // Write to log file + RFileLogger::Write( KLogDir, KLogFile, EFileLoggingModeAppend, buf ); + } + +void CTestScheduler::Error( TInt /*anError */ ) const + { + CTestLogger::Log( _L( "ClientTester RunL ERROR RECEIVED" ) ); + } diff -r dd806856a8f6 -r 862cab47b1ba common/tools/ats/smoketest/IM/src/IMApiTest.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/tools/ats/smoketest/IM/src/IMApiTest.cpp Fri Nov 13 11:20:06 2009 +0000 @@ -0,0 +1,547 @@ +/* +* Copyright (c) 2002 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 "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This class contains all test framework related parts of + this test module. +* +* +*/ + + + +// INCLUDE FILES +#include +#include "IMApiTest.h" +#include + +// EXTERNAL DATA STRUCTURES +// None + +// EXTERNAL FUNCTION PROTOTYPES +// None + +// CONSTANTS +// None + +// MACROS +// None + +// LOCAL CONSTANTS AND MACROS +// None + +// MODULE DATA STRUCTURES +// None + +// LOCAL FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +// None + +// ==================== LOCAL FUNCTIONS ======================================= + + +/* +------------------------------------------------------------------------------- + + DESCRIPTION + + This file (IMApiTest.cpp) contains all test framework related parts of + this test module. Actual test cases are implemented in file + IMApiTestCases.cpp. + + CIMApiTest is an example of test module implementation. This example + uses hard coded test cases (i.e it does not have any test case + configuration file). + + Example uses function pointers to call test cases. This provides an easy + method to add new test cases. + + See function Cases in file IMApiTestCases.cpp for instructions how to + add new test cases. It is not necessary to modify this file when adding + new test cases. + + To take this module into use, add following lines to test framework + initialisation file: + +# Demo module +[New_Module] +ModuleName= IMApiTest +[End_Module] + +------------------------------------------------------------------------------- +*/ + +// ================= MEMBER FUNCTIONS ========================================= + +/* +------------------------------------------------------------------------------- + + Class: CIMApiTest + + Method: CIMApiTest + + Description: C++ default constructor can NOT contain any code, that + might leave. + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Approved + +------------------------------------------------------------------------------- +*/ +CIMApiTest::CIMApiTest() + { + } + +/* +------------------------------------------------------------------------------- + + Class: CIMApiTest + + Method: ConstructL + + Description: Symbian 2nd phase constructor that can leave. + + Note: If OOM test case uses STIF Logger, then STIF Logger must be created + with static buffer size parameter (aStaticBufferSize). Otherwise Logger + allocates memory from heap and therefore causes error situations with OOM + testing. For more information about STIF Logger construction, see STIF + Users Guide. + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Approved + +------------------------------------------------------------------------------- +*/ +void CIMApiTest::ConstructL() + { + // Constructing static buffer size logger, needed with OOM testing because + // normally logger allocates memory from heap! + iLog = CStifLogger::NewL( KIMApiTestLogPath, + KIMApiTestLogFile, + CStifLogger::ETxt, + CStifLogger::EFile, + ETrue, + ETrue, + ETrue, + EFalse, + ETrue, + EFalse, + 100 ); + + // Sample how to use logging + _LIT( KLogInfo, "IMApiTest logging starts!" ); + iLog->Log( KLogInfo ); + iRunner = CTestRunner::NewL(); + } + +/* +------------------------------------------------------------------------------- + + Class: CIMApiTest + + Method: NewL + + Description: Two-phased constructor. Constructs new CIMApiTest + instance and returns pointer to it. + + Parameters: None + + Return Values: CIMApiTest*: new object. + + Errors/Exceptions: Leaves if memory allocation fails or ConstructL leaves. + + Status: Approved + +------------------------------------------------------------------------------- +*/ +CIMApiTest* CIMApiTest::NewL() + { + CIMApiTest* self = new ( ELeave ) CIMApiTest; + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + + return self; + } + +/* +------------------------------------------------------------------------------- + + Class: CIMApiTest + + Method: ~CIMApiTest + + Description: Destructor. + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Approved + +------------------------------------------------------------------------------- +*/ +CIMApiTest::~CIMApiTest() + { + delete iLog; + if ( iRunner ) + delete iRunner; + } + +/* +------------------------------------------------------------------------------- + Class: CIMApiTest + + Method: InitL + + Description: Method for test case initialization + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Approved +------------------------------------------------------------------------------- +*/ +TInt CIMApiTest::InitL( TFileName& /*aIniFile*/, + TBool /*aFirstTime*/ ) + { + return KErrNone; + + } + +/* +------------------------------------------------------------------------------- + + Class: CIMApiTest + + Method: GetTestCases + + Description: GetTestCases is used to inquire test cases + from the test module. Because this test module has hard coded test cases + (i.e cases are not read from file), paramter aConfigFile is not used. + + This function loops through all cases defined in Cases() function and + adds corresponding items to aTestCases array. + + Parameters: const TFileName& : in: Configuration file name. Not used + RPointerArray& aTestCases: out: + Array of TestCases. + + Return Values: KErrNone: No error + + Errors/Exceptions: Function leaves if any memory allocation operation fails + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +TInt CIMApiTest::GetTestCasesL( const TFileName& /*aConfig*/, + RPointerArray& aTestCases ) + { + // Loop through all test cases and create new + // TTestCaseInfo items and append items to aTestCase array + for ( TInt i = 0; Case( i ).iMethod != NULL; i++ ) + { + // Allocate new TTestCaseInfo from heap for a testcase definition. + TTestCaseInfo* newCase = new( ELeave ) TTestCaseInfo(); + + // PushL TTestCaseInfo to CleanupStack. + CleanupStack::PushL( newCase ); + + // Set number for the testcase. + // When the testcase is run, this comes as a parameter to RunTestCaseL. + newCase->iCaseNumber = i; + + // Set title for the test case. This is shown in UI to user. + newCase->iTitle.Copy( Case( i ).iCaseName ); + + // Append TTestCaseInfo to the testcase array. After appended + // successfully the TTestCaseInfo object is owned (and freed) + // by the TestServer. + User::LeaveIfError( aTestCases.Append ( newCase ) ); + + // Pop TTestCaseInfo from the CleanupStack. + CleanupStack::Pop( newCase ); + } + + return KErrNone; + + } + +/* +------------------------------------------------------------------------------- + + Class: CIMApiTest + + Method: RunTestCase + + Description: Run a specified testcase. + + Function runs a test case specified by test case number. Test case file + parameter is not used. + + If case number is valid, this function runs a test case returned by + function Cases(). + + Parameters: const TInt aCaseNumber: in: Testcase number + const TFileName& : in: Configuration file name. Not used + TTestResult& aResult: out: Testcase result + + Return Values: KErrNone: Testcase ran. + KErrNotFound: Unknown testcase + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +TInt CIMApiTest::RunTestCaseL( const TInt aCaseNumber, + const TFileName& /* aConfig */, + TTestResult& aResult ) + { + // Return value + TInt execStatus = KErrNone; + + // Get the pointer to test case function + TCaseInfo tmp = Case ( aCaseNumber ); + + TestModuleIf().SetBehavior( CTestModuleIf::ETestLeaksRequests ); + TestModuleIf().SetBehavior( CTestModuleIf::ETestLeaksHandles ); + + _LIT( KLogInfo, "Starting testcase [%S]" ); + iLog->Log( KLogInfo, &tmp.iCaseName ); + + // Check that case number was valid + if ( tmp.iMethod != NULL ) + { + // Valid case was found, call it via function pointer + iMethod = tmp.iMethod; + execStatus = ( this->*iMethod )( aResult ); + } + else + { + // Valid case was not found, return error. + execStatus = KErrNotFound; + } + + // Return case execution status (not the result of the case execution) + return execStatus; + + } + +/* +------------------------------------------------------------------------------- + + Class: CIMApiTest + + Method: OOMTestQueryL + + Description: Checks test case information for OOM execution. + + Return Values: TBool + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +TBool CIMApiTest::OOMTestQueryL( const TFileName& /* aTestCaseFile */, + const TInt aCaseNumber, + TOOMFailureType& /* aFailureType */, + TInt& aFirstMemFailure, + TInt& aLastMemFailure ) + { + _LIT( KLogInfo, "CIMApiTest::OOMTestQueryL" ); + iLog->Log( KLogInfo ); + + aFirstMemFailure = Case( aCaseNumber ).iFirstMemoryAllocation; + aLastMemFailure = Case( aCaseNumber ).iLastMemoryAllocation; + + return Case( aCaseNumber ).iIsOOMTest; + } + +/* +------------------------------------------------------------------------------- + + Class: CIMApiTest + + Method: OOMTestInitializeL + + Description: Used to perform the test environment setup for a particular + OOM test case. Test Modules may use the initialization file to read + parameters for Test Module initialization but they can also have their own + configure file or some other routine to initialize themselves. + + NOTE: User may add implementation for OOM test environment initialization. + Usually no implementation is required. + + Return Values: None + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +void CIMApiTest::OOMTestInitializeL( const TFileName& /* aTestCaseFile */, + const TInt /* aCaseNumber */ ) + { + _LIT( KLogInfo, "CIMApiTest::OOMTestInitializeL" ); + iLog->Log( KLogInfo ); + + } + +/* +------------------------------------------------------------------------------- + + Class: CIMApiTest + + Method: OOMHandleWarningL + + Description: Used in OOM testing to provide a way to the derived TestModule + to handle warnings related to non-leaving or TRAPped allocations. + + In some cases the allocation should be skipped, either due to problems in + the OS code or components used by the code being tested, or even inside the + tested components which are implemented this way on purpose (by design), so + it is important to give the tester a way to bypass allocation failures. + + NOTE: User may add implementation for OOM test warning handling. Usually no + implementation is required. + + Return Values: None + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +void CIMApiTest::OOMHandleWarningL( const TFileName& /* aTestCaseFile */, + const TInt /* aCaseNumber */, + TInt& /* aFailNextValue */ ) + { + _LIT( KLogInfo, "CIMApiTest::OOMHandleWarningL" ); + iLog->Log( KLogInfo ); + + } + +/* +------------------------------------------------------------------------------- + + Class: CIMApiTest + + Method: OOMTestFinalizeL + + Description: Used to perform the test environment cleanup for a particular OOM + test case. + + NOTE: User may add implementation for OOM test environment finalization. + Usually no implementation is required. + + Return Values: None + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +void CIMApiTest::OOMTestFinalizeL( const TFileName& /* aTestCaseFile */, + const TInt /* aCaseNumber */ ) + { + _LIT( KLogInfo, "CIMApiTest::OOMTestFinalizeL" ); + iLog->Log( KLogInfo ); + + } + +// ========================== OTHER EXPORTED FUNCTIONS ========================= + +// ----------------------------------------------------------------------------- +// LibEntryL is a polymorphic Dll entry point +// Returns: CTestModuleBase*: Pointer to Test Module object +// ----------------------------------------------------------------------------- +// +EXPORT_C CTestModuleBase* LibEntryL() + { + return CIMApiTest::NewL(); + + } + +// ----------------------------------------------------------------------------- +// SetRequirements handles test module parameters(implements evolution +// version 1 for test module's heap and stack sizes configuring). +// Returns: TInt: Symbian error code. +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt SetRequirements( CTestModuleParam*& /*aTestModuleParam*/, + TUint32& /*aParameterValid*/ ) + { + + /* --------------------------------- NOTE --------------------------------- + USER PANICS occurs in test thread creation when: + 1) "The panic occurs when the value of the stack size is negative." + 2) "The panic occurs if the minimum heap size specified is less + than KMinHeapSize". + KMinHeapSize: "Functions that require a new heap to be allocated will + either panic, or will reset the required heap size to this value if + a smaller heap size is specified". + 3) "The panic occurs if the minimum heap size specified is greater than + the maximum size to which the heap can grow". + Other: + 1) Make sure that your hardware or Symbian OS is supporting given sizes. + e.g. Hardware might support only sizes that are divisible by four. + ------------------------------- NOTE end ------------------------------- */ + + // Normally STIF uses default heap and stack sizes for test thread, see: + // KTestThreadMinHeap, KTestThreadMinHeap and KStackSize. + // If needed heap and stack sizes can be configured here by user. Remove + // comments and define sizes. + + /* + aParameterValid = KStifTestModuleParameterChanged; + + CTestModuleParamVer01* param = CTestModuleParamVer01::NewL(); + // Stack size + param->iTestThreadStackSize= 16384; // 16K stack + // Heap sizes + param->iTestThreadMinHeap = 4096; // 4K heap min + param->iTestThreadMaxHeap = 1048576;// 1M heap max + + aTestModuleParam = param; + */ + return KErrNone; + + } + + +// End of File diff -r dd806856a8f6 -r 862cab47b1ba common/tools/ats/smoketest/IM/src/IMApiTestcases.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/tools/ats/smoketest/IM/src/IMApiTestcases.cpp Fri Nov 13 11:20:06 2009 +0000 @@ -0,0 +1,297 @@ +/* +* Copyright (c) 2002 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 "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This module contains the implementation of CIMApiTest class + member functions that does the actual tests. +* +* +*/ + + + +// INCLUDE FILES +#include +#include "IMApiTest.h" + +// EXTERNAL DATA STRUCTURES +// None + +// EXTERNAL FUNCTION PROTOTYPES +// None + +// CONSTANTS +// None + +// MACROS +// None + +// LOCAL CONSTANTS AND MACROS +// None + +// MODULE DATA STRUCTURES +// None + +// LOCAL FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +// None + +// ==================== LOCAL FUNCTIONS ======================================= + +/* +------------------------------------------------------------------------------- + + DESCRIPTION + + This module contains the implementation of CIMApiTest class + member functions that does the actual tests. + +------------------------------------------------------------------------------- +*/ + +// ============================ MEMBER FUNCTIONS =============================== + +/* +------------------------------------------------------------------------------- + + Class: CIMApiTest + + Method: Case + + Description: Returns a test case by number. + + This function contains an array of all available test cases + i.e pair of case name and test function. If case specified by parameter + aCaseNumber is found from array, then that item is returned. + + The reason for this rather complicated function is to specify all the + test cases only in one place. It is not necessary to understand how + function pointers to class member functions works when adding new test + cases. See function body for instructions how to add new test case. + + Parameters: const TInt aCaseNumber :in: Test case number + + Return Values: const TCaseInfo Struct containing case name & function + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +const TCaseInfo CIMApiTest::Case ( + const TInt aCaseNumber ) const + { + + /* + * To add new test cases, implement new test case function and add new + * line to KCases array specify the name of the case and the function + * doing the test case + * In practice, do following + * + * 1) Make copy of existing test case function and change its name + * and functionality. Note that the function must be added to + * OOMHard.cpp file and to OOMHard.h + * header file. + * + * 2) Add entry to following KCases array either by using: + * + * 2.1: FUNCENTRY or ENTRY macro + * ENTRY macro takes two parameters: test case name and test case + * function name. + * + * FUNCENTRY macro takes only test case function name as a parameter and + * uses that as a test case name and test case function name. + * + * Or + * + * 2.2: OOM_FUNCENTRY or OOM_ENTRY macro. Note that these macros are used + * only with OOM (Out-Of-Memory) testing! + * + * OOM_ENTRY macro takes five parameters: test case name, test case + * function name, TBool which specifies is method supposed to be run using + * OOM conditions, TInt value for first heap memory allocation failure and + * TInt value for last heap memory allocation failure. + * + * OOM_FUNCENTRY macro takes test case function name as a parameter and uses + * that as a test case name, TBool which specifies is method supposed to be + * run using OOM conditions, TInt value for first heap memory allocation + * failure and TInt value for last heap memory allocation failure. + */ + + static TCaseInfoInternal const KCases[] = + { + // To add new test cases, add new items to this array + + // NOTE: When compiled to GCCE, there must be Classname:: + // declaration in front of the method name, e.g. + // CIMApiTest::PrintTest. Otherwise the compiler + // gives errors. + + ENTRY( "Create IM Client", CIMApiTest::CreateImClientL ), +// ENTRY( "Invalid Login", CIMApiTest::InvalidLoginL ), +// ENTRY( "Login", CIMApiTest::LoginL ), +// ENTRY( "Send P To P ValidUserID", CIMApiTest::SendPToPValidUserIDL ), +// ENTRY( "Send P To P ValidTvoUserID", CIMApiTest::SendPToPValidTwoUserIDL ), +// ENTRY( "Send P To P ValidContact", CIMApiTest::SendPToPValidContactL ), +// ENTRY( "Send P To P ValidTwoContact", CIMApiTest::SendPToPValidTwoContactL ), +// ENTRY( "Send P To P ContactContentType", CIMApiTest::SendPToPContactContentTypeL ), +// ENTRY( "Send P To P UserIDContentType", CIMApiTest::SendPToPUserIDContentTypeL ), +// ENTRY( "Logout", CIMApiTest::LogoutL ), +// ENTRY( "Cancel Login", CIMApiTest::CancelLoginL ), + }; + + // Verify that case number is valid + if ( ( TUint ) aCaseNumber >= sizeof( KCases ) / + sizeof( TCaseInfoInternal ) ) + { + + // Invalid case, construct empty object + TCaseInfo null( ( const TText* ) L"" ); + null.iMethod = NULL; + null.iIsOOMTest = EFalse; + null.iFirstMemoryAllocation = 0; + null.iLastMemoryAllocation = 0; + return null; + + } + + // Construct TCaseInfo object and return it + TCaseInfo tmp ( KCases[ aCaseNumber ].iCaseName ); + tmp.iMethod = KCases[ aCaseNumber ].iMethod; + tmp.iIsOOMTest = KCases[ aCaseNumber ].iIsOOMTest; + tmp.iFirstMemoryAllocation = KCases[ aCaseNumber ].iFirstMemoryAllocation; + tmp.iLastMemoryAllocation = KCases[ aCaseNumber ].iLastMemoryAllocation; + return tmp; + + } + +TInt CIMApiTest::CreateImClientL( TTestResult& aResult ) + { + iRunner->StartRunL( CreateImClient ); + // Sets test case result and description(Maximum size is KStifMaxResultDes) + _LIT( KDescription, "CreateImClientL Passed" ); + aResult.SetResult( KErrNone, KDescription ); + // Case was executed + return KErrNone; + + } + +TInt CIMApiTest::InvalidLoginL( TTestResult& aResult ) + { + iRunner->StartRunL( InvalidLogin ); + // Sets test case result and description(Maximum size is KStifMaxResultDes) + _LIT( KDescription, "LoginL Passed" ); + aResult.SetResult( KErrNone, KDescription ); + // Case was executed + return KErrNone; + + } + +TInt CIMApiTest::LoginL( TTestResult& aResult ) + { + iRunner->StartRunL( Login ); + // Sets test case result and description(Maximum size is KStifMaxResultDes) + _LIT( KDescription, "LoginL Passed" ); + aResult.SetResult( KErrNone, KDescription ); + // Case was executed + return KErrNone; + } + + +TInt CIMApiTest::SendPToPValidUserIDL( TTestResult& aResult ) + { + iRunner->StartRunL( SendMessageValidUserId ); + // Sets test case result and description(Maximum size is KStifMaxResultDes) + _LIT( KDescription, "SendPToPValidUserIDL Passed" ); + aResult.SetResult( KErrNone, KDescription ); + // Case was executed + return KErrNone; + } + + +TInt CIMApiTest::SendPToPValidTwoUserIDL( TTestResult& aResult ) + { + iRunner->StartRunL( SendMessageValidTwoUserId ); + // Sets test case result and description(Maximum size is KStifMaxResultDes) + _LIT( KDescription, "SendPToPValidTwoUserIDL Passed" ); + aResult.SetResult( KErrNone, KDescription ); + // Case was executed + return KErrNone; + } + + +TInt CIMApiTest::SendPToPValidContactL( TTestResult& aResult ) + { + iRunner->StartRunL( SendMessageValidContact ); + // Sets test case result and description(Maximum size is KStifMaxResultDes) + _LIT( KDescription, "SendPToPValidContactL Passed" ); + aResult.SetResult( KErrNone, KDescription ); + // Case was executed + return KErrNone; + } + + +TInt CIMApiTest::SendPToPValidTwoContactL( TTestResult& aResult ) + { + iRunner->StartRunL( SendMessageValidTwoContact ); + // Sets test case result and description(Maximum size is KStifMaxResultDes) + _LIT( KDescription, "SendPToPValidTwoContactL Passed" ); + aResult.SetResult( KErrNone, KDescription ); + // Case was executed + return KErrNone; + } + +TInt CIMApiTest::SendPToPContactContentTypeL( TTestResult& aResult ) + { + iRunner->StartRunL( SendPToPContactContentType ); + // Sets test case result and description(Maximum size is KStifMaxResultDes) + _LIT( KDescription, "SendPToPContactContentTypeL Passed" ); + aResult.SetResult( KErrNone, KDescription ); + // Case was executed + return KErrNone; + } + +TInt CIMApiTest::SendPToPUserIDContentTypeL( TTestResult& aResult ) + { + iRunner->StartRunL( SendPToPUserIDContentType ); + // Sets test case result and description(Maximum size is KStifMaxResultDes) + _LIT( KDescription, "SendPToPUserIDContentTypeL Passed" ); + aResult.SetResult( KErrNone, KDescription ); + // Case was executed + return KErrNone; + } + +TInt CIMApiTest::LogoutL( TTestResult& aResult ) + { + iRunner->StartRunL( Logout ); + // Sets test case result and description(Maximum size is KStifMaxResultDes) + _LIT( KDescription, "LogoutL Passed" ); + aResult.SetResult( KErrNone, KDescription ); + // Case was executed + return KErrNone; + } + + +TInt CIMApiTest::CancelLoginL( TTestResult& aResult ) + { + iRunner->StartRunL( CancelLogin ); + // Sets test case result and description(Maximum size is KStifMaxResultDes) + _LIT( KDescription, "CancelLoginL Passed" ); + aResult.SetResult( KErrNone, KDescription ); + // Case was executed + return KErrNone; + } + +// End of File diff -r dd806856a8f6 -r 862cab47b1ba common/tools/ats/smoketest/IM/src/ParserUtils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/tools/ats/smoketest/IM/src/ParserUtils.cpp Fri Nov 13 11:20:06 2009 +0000 @@ -0,0 +1,122 @@ +/* +* Copyright (c) 2002-2005 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 "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: The class handles IMPS Setting file reading. +* +* +*/ + + +// INCLUDE FILES +#include +#ifdef _DEBUG +#include +#endif +#include "ParserUtils.h" + +// ================= MEMBER FUNCTIONS ======================= + + + +//********************************** +// CImpsSettingFile +//********************************** + +CImpsSettingFile* CImpsSettingFile::NewL( + RFs& aFs ) + { + CImpsSettingFile* self = new ( ELeave ) CImpsSettingFile( aFs ); + return self; + } + +CImpsSettingFile::~CImpsSettingFile() + { + if ( iOpen ) + { + iReader.Close(); + } + iOpen = EFalse; + } + +CImpsSettingFile::CImpsSettingFile( RFs& aFs ) + : iFs( aFs ), + iOpen( EFalse ) + { + + } + +void CImpsSettingFile::OpenL( TDesC& aResFile ) + { + // open a file + iFileName = aResFile; + + TInt myError = iReader.Open( iFs, + iFileName, + EFileShareReadersOnly ); + + User::LeaveIfError( myError ); + iOpen = ETrue; + + } + +TPtrC8 CImpsSettingFile::KeyValueL( const TDesC8& aKey ) + { + + TPtrC8 myKey; + TPtrC8 myValue; + TBool getIt( EFalse ); + TInt err = 0; + + // Reset the reader + OpenL( iFileName ); + + // Start to search + while ( !getIt ) + { + TRAP ( err, ReadRowL( myKey, myValue ) ); + if ( err != KErrNone ) + { + User::Leave( KErrNotFound ); + } + if ( !myKey.CompareF( aKey ) ) + { + return myValue; + } + } + return TPtrC8(); + } + +void CImpsSettingFile::ReadRowL( TPtrC8& aKey, TPtrC8& aValue ) + { + // READ ONE ROW + TChar delim( 10 ); + iReader.ReadL( iRowBuffer, delim ); + TInt length = iRowBuffer.Length(); + if ( length > 2 ) + { + // DROP CR+LF FROM THE END OF LINE + iRowBuffer.Delete( length - 2, 2 ); + + TInt pos = 0; + pos = iRowBuffer.Find( _L8( "=" ) ); + if ( pos > 0 ) + { + aKey.Set( iRowBuffer.Left( pos ) ); + // Cut off separator + aValue.Set( iRowBuffer.Mid( pos + 1 ) ); + } + } + } + +// End of File + diff -r dd806856a8f6 -r 862cab47b1ba common/tools/ats/smoketest/IM/src/TestRunner.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/tools/ats/smoketest/IM/src/TestRunner.cpp Fri Nov 13 11:20:06 2009 +0000 @@ -0,0 +1,701 @@ +/* +* Copyright (c) 2002-2005 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 "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: The class handles the test case running. +* +* +*/ + + + +// INCLUDE FILES +#include +#include +#include "imerrors.h" +#include +#include "IMApiMTHandlers.h" +#include "TestRunner.h" +#include "IMApiTest.h" +#include "ParserUtils.h" + +_LIT( KImpsIMApiMTIniFile, "c:\\smoketest\\imapitest.ini" ); +_LIT8( KImpsSAP, "SAP" ); +_LIT8( KImpsUserID, "Userid" ); +_LIT8( KImpsPassword, "password" ); +_LIT8( KImpsClientid, "clientid" ); +_LIT8( KImpsIAP, "IAP" ); +_LIT8( KImpsUserid1, "userid1" ); +_LIT8( KImpsUserid2, "userid2" ); + +void SetupSchedulerL() + { + // Create a scheduler + CTestScheduler* scheduler = new( ELeave )CTestScheduler; + CleanupStack::PushL( scheduler ); + CActiveScheduler::Install( scheduler ); + CleanupStack::Pop(); // scheduler + } + +void CTestRunner::ReadIniFileL() + { + RFs myFs; + TInt err = 0; + TUint32 myTime = 0; + TLex lex; + err = myFs.Connect(); + //CleanupClosePushL( myFs ); + CImpsSettingFile* configFile = CImpsSettingFile::NewL( myFs ); + CleanupStack::PushL( configFile ); + TFileName fileN( KImpsIMApiMTIniFile ); + // Open config file + TRAP( err, configFile->OpenL( fileN ) ); + User::LeaveIfError( err ); + + TBuf myPtr; + TRAP( err, myPtr.Copy( configFile->KeyValueL( KImpsSAP ) ) ); + if ( !err ) + { + iSapValue.Copy( myPtr ); + } + TRAP( err, myPtr.Copy( configFile->KeyValueL( KImpsUserID ) ) ); + if ( !err ) + { + iUserIdValue.Copy( myPtr ); + } + TRAP( err, myPtr.Copy( configFile->KeyValueL( KImpsPassword ) ) ); + if ( !err ) + { + iPassword.Copy( myPtr ); + } + TRAP( err, myPtr.Copy( configFile->KeyValueL( KImpsClientid ) ) ); + if ( !err ) + { + iClientId.Copy( myPtr ); + } + TRAP( err, myPtr.Copy( configFile->KeyValueL( KImpsIAP ) ) ); + if ( !err ) + { + lex.Assign( myPtr ); + lex.Val( myTime, EDecimal ); + iIAP = ( TInt ) myTime; + } + TRAP( err, myPtr.Copy( configFile->KeyValueL( KImpsUserid1 ) ) ); + if ( !err ) + { + iUserId1.Copy( myPtr ); + } + TRAP( err, myPtr.Copy( configFile->KeyValueL( KImpsUserid2 ) ) ); + if ( !err ) + { + iUserId2.Copy( myPtr ); + } + CleanupStack::PopAndDestroy( 1 ); // configFile + } + + + +CTestRunner* CTestRunner::NewL() + { + CTestRunner* self = new ( ELeave ) CTestRunner(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); //self + return self; + } + +void CTestRunner::ConstructL() + { + SetupSchedulerL(); + iCase = Login; + iDatabase = CContactDatabase::OpenL(); + iImObserver = CIMApiClientHandler::NewL( iStatus ); + iConnObserver = CConnectionObserver::NewL( iStatus ); + ReadIniFileL(); + + CActiveScheduler::Add( this ); + } + +CTestRunner::~CTestRunner() + { + + if ( iOpenApi != NULL ) + { + iOpenApi->UnregisterObserver(); + } + CTestLogger1::Log( _L( "Test Case Number #16" ) ); + CTestLogger1::Log( _L( "CImConnection::UnregisterObserver" ) ); + if ( iOpenApi != NULL ) + { + delete iOpenApi; + iOpenApi = NULL; + } + if ( iImClient != NULL ) + { + delete iImClient; + iImClient = NULL; + } + if ( iConnObserver != NULL ) + { + delete iConnObserver; + iConnObserver = NULL; + } + if ( iImObserver != NULL ) + { + delete iImObserver; + iImObserver = NULL; + } + if ( iDatabase != NULL ) + { + delete iDatabase; + iDatabase = NULL; + } + + } + + + +void CTestRunner::DoCancel() + { + // Complete the request with error + TRequestStatus* s = &iStatus; + User::RequestComplete( s, KErrCancel ); + } + + +CTestRunner::CTestRunner() + : CActive( 0 ) + { + } + + +void CTestRunner::StartRunL( TWhichCase aCase ) + { + iCase = aCase; + SetActive(); + TRequestStatus *s = &iStatus; + User::RequestComplete( s, KErrNone ); + CActiveScheduler::Start(); + } + +void CTestRunner::RunL() + { + TInt errxx = 0; + TRAP( errxx, DoRunL() ); + if ( errxx < 0 ) + { + CActiveScheduler::Stop(); + } + } + + +void CTestRunner::DoRunL() + { + if ( iCase >= Finish ) + { + Cancel(); + CActiveScheduler::Stop(); + return; + } + + if ( iStatus != KErrNone ) + { + Cancel(); + CActiveScheduler::Stop(); + return; + } + switch ( iCase ) + { + case CreateImClient: + { + CreateInstanceL(); //NewL - instantiate the object + RegisterConnObserverL(); //RegisterObserverL - register the observer methods + LoadIMInterfaceL(); //CreateImClientL - get the IM interface + } + break; + case InvalidLogin: + { + CreateInstanceL(); + RegisterConnObserverL(); + LoadIMInterfaceL(); + IMRegisterL(); + LoginL( _L( "InvalidUser" ) ); + } + break; + case Login: + { + CreateInstanceL(); + RegisterConnObserverL(); + LoadIMInterfaceL(); + IMRegisterL(); + LoginL( iUserIdValue ); + } + break; + case SendMessageValidUserId: + { + SendPToPValidUserIDL(); + } + break; + case SendMessageValidTwoUserId: + { + SendPToPValidTwoUserIDL(); + } + break; + case SendMessageValidContact: + { + SendPToPValidContactL(); + } + break; + case SendMessageValidTwoContact: + { + SendPToPValidTwoContactL(); + } + break; + case SendPToPContactContentType: + { + SendPToPContactContentTypeL(); + } + break; + case SendPToPUserIDContentType: + { + SendPToPUserIDContentTypeL(); + } + break; + + case Logout: + { + QueryIMConnectionStatusL(); + } + break; + case CancelLogin: + { + CancelLoginL(); + } + break; + } + + iCase = Finish; + + return; + } + + +CContactIdArray* CTestRunner::GetWVContactIdsLC( ) + { + _LIT( KWVStart, "" ); + // Specify in which fields search should be performed + CContactItemFieldDef* fieldToSearchIn = new ( ELeave ) CContactItemFieldDef(); + CleanupStack::PushL( fieldToSearchIn ); + fieldToSearchIn->AppendL( KUidContactFieldVCardMapWV ); + + // search in contact database + CContactIdArray *array = iDatabase->FindLC( KWVStart, fieldToSearchIn ); + CleanupStack::Pop(); //>> array + CleanupStack::PopAndDestroy(); //>> fieldToSearchIn + CleanupStack::PushL( array ); + + return array; + } + + + +TInt CTestRunner::RegisterConnObserverL() + { + CTestLogger1::Log( _L( "Test Case Number #2" ) ); + TRAPD( err, iOpenApi->RegisterObserverL( iConnObserver ) ); + // Catch errors + if ( err == KImApiGeneralError ) // -30133 + { + iStatus = err; // Failed + CTestLogger1::Log( _L( "CImConnection::RegisterObserverL - err=%d" ), err ); + } + else + { + iStatus = KErrNone; //OK + CTestLogger1::Log( _L( "CImConnection::RegisterObserverL - err=%d" ), err ); + } + } + + +TInt CTestRunner::CreateInstanceL() + { + CTestLogger1::Log( _L( "Test Case Number #1" ) ); + iOpenApi = CImConnection::NewL( iClientId ); + CTestLogger1::Log( _L( "CImConnection::NewL" ) ); + return KErrNone; //OK + } + + +TInt CTestRunner::LoadIMInterfaceL() + { + CTestLogger1::Log( _L( "Test Case Number #3" ) ); + TRAPD( err, iImClient = iOpenApi->CreateImClientL() ); + // Catch errrors + if ( err == 0 ) + { + iStatus = KErrNone; // OK + CTestLogger1::Log( _L( "CreateImClientL - err=%d" ), err ); + } + else + { + iStatus = err; // Failed + CTestLogger1::Log( _L( "CreateImClientL - err=%d" ), err ); + } + } + + +TInt CTestRunner::IMRegisterL() + { + CTestLogger1::Log( _L( "Test Case Number #4" ) ); + TRAPD( err, iImClient -> RegisterObserverL( iImObserver ) ); + // Catch errors + if ( err == KImApiGeneralError ) //- 30133 + { + iStatus = err; // Failes + CTestLogger1::Log( _L( "MImClient::RegisterObserverL - err=%d" ), err ); + } + else + { + iStatus = KErrNone; //OK + CTestLogger1::Log( _L( "MImClient::RegisterObserverL - err=%d" ), err ); + } + } + +TInt CTestRunner::LoginL( const TDesC& aUserID ) + { + if ( aUserID.Compare( _L( "InvalidUser" ) ) ) + CTestLogger1::Log( _L( "Test Case Number #6" ) ); + else + { + CTestLogger1::Log( _L( "Invalid Login" ) ); + CTestLogger1::Log( _L( "Test Case Number #5" ) ); + } + + if ( iSapValue.Size() == 0 || iPassword.Size() == 0 || aUserID.Size() == 0 ) + { + iStatus = KErrNone; + CTestLogger1::Log( _L( "Invalid login parametres" ) ); + Cancel(); + CActiveScheduler::Stop(); + return KErrNone; + } + + TRAPD( err, iOpenApi->LoginL( iSapValue, aUserID, iPassword, iIAP ) ); + // Catch errors + if ( err ) + { + iStatus = err; // Failes + CTestLogger1::Log( _L( "LoginL - err=%d" ), err ); + return err; + } + else + { + iStatus = KRequestPending; + CTestLogger1::Log( _L( "LoginL - err=%d" ), err ); + SetActive(); + return KErrNone; + } + } + +TInt CTestRunner::SendPToPValidUserIDL() + { + CTestLogger1::Log( _L( "Test Case Number #7" ) ); + if ( iUserId1.Length() == 0 ) + { + CTestLogger1::Log( _L( "SendPToPMessageL(ValidUserId) UserID1 is NULL " ) ); + iStatus = KErrNone; + Cancel(); + CActiveScheduler::Stop(); + return KErrNone; + } + CDesCArray* userIds = new( ELeave ) CDesCArrayFlat( 1 ); // Create user list + CleanupStack::PushL( userIds ); + userIds->AppendL( iUserId1 ); // Add one user + + _LIT( KContentType, "text/plain" ); // Message type + _LIT( KMessage, "5. Hello In One Time Valid UserId" ); // Message + TInt OpId = 0; + // Send message + TRAPD ( err, OpId = iImClient->SendPToPMessageL( iUserId1, KMessage ) ); + // Catch errors + if ( err == KImApiErrInvalidUserId && OpId == 0 ) // KImApiErrInvalidUserId + { + CTestLogger1::Log( _L( "SendPToPMessageL(ValidUserId) - err=%d" ), err ); + CleanupStack::PopAndDestroy(); // userIds + iStatus = err; + return err; + } + else if ( err == KImApiGeneralError && OpId == 0 ) // General ImApi errror + { + CTestLogger1::Log( _L( "SendPToPMessageL(ValidUserId) - err=%d" ), err ); + CleanupStack::PopAndDestroy(); // userIds + iStatus = err; + return err; + } + else + { + CTestLogger1::Log( _L( "SendPToPMessageL(ValidUserId) - err=%d" ), err ); + CleanupStack::PopAndDestroy(); // userIds + iStatus = KRequestPending; + SetActive(); + return KErrNone; + } + } + + +TInt CTestRunner::SendPToPValidTwoUserIDL() + { + CTestLogger1::Log( _L( "Test Case Number #8" ) ); + CDesCArray* userIds = new( ELeave ) CDesCArrayFlat( 2 ); // Create new user list + CleanupStack::PushL( userIds ); + userIds->AppendL( iUserId1 ); // Add user 0 nok3 + userIds->AppendL( iUserId2 ); // Add user 1 nok5 + + _LIT( KContentType, "text/plain" ); + _LIT( KMessage, "6. Hello In Two Times Valid UserId" ); + TInt OpId = 0; + // Send Message + TRAPD ( err, OpId = iImClient->SendPToPMessageL( *userIds, KMessage ) ); + // Catch errors + if ( err == KImApiErrInvalidUserId && OpId == 0 ) // KImApiErrInvalidUserId + { + CTestLogger1::Log( _L( "SendPToPMessageL(ValidTwoUserIds) - err=%d" ), err ); + CleanupStack::PopAndDestroy(); // userIds + iStatus = err; + return err; + } + else if ( err == KImApiGeneralError && OpId == 0 ) // General ImApi errror + { + CTestLogger1::Log( _L( "SendPToPMessageL(ValidTwoUserIds) - err=%d" ), err ); + CleanupStack::PopAndDestroy(); // userIds + iStatus = err; + return err; + } + else + { + CTestLogger1::Log( _L( "SendPToPMessageL(ValidTwoUserIds) - err=%d" ), err ); + CleanupStack::PopAndDestroy(); // userIds + iStatus = KRequestPending; + SetActive(); + return KErrNone; + } + } + + +TInt CTestRunner::SendPToPValidContactL() + { + CTestLogger1::Log( _L( "Test Case Number #9" ) ); + CContactIdArray* contactIDArray = GetWVContactIdsLC(); + if ( contactIDArray->Count() == 0 ) + { + CTestLogger1::Log( _L( "Can not find WvContact ID" ) ); + CleanupStack::PopAndDestroy(); + iStatus = KErrNone; + Cancel(); + CActiveScheduler::Stop(); + return KErrNone; + } + TInt OpId = 0; + // Be sure that two contact is real WV contact + // Select first contact + TContactItemId& OmaContact = ( *contactIDArray )[0]; + + //Add first contact + CContactIdArray* myContactIds = CContactIdArray::NewL(); + myContactIds->AddL( OmaContact ); + + // Check that we have only one contact + TInt nuberofcontacts = myContactIds->Count(); + //CTestLogger1::Log( _L("nuberofcontacts =%d"), nuberofcontacts ); + //Send message to myContacts + TRAPD( err, OpId = iImClient->SendPToPMessageL( OmaContact/*myContactIds*/, _L( "12. Hello One Valid Contact" ) ) ); + // Just checking return value + if ( err == KImApiErrInvalidContactId && OpId == 0 ) // KImApiErrInvalidContactId and OperationId is 0 + { + CTestLogger1::Log( _L( "SendPToPMessageL(ValidContact) - err=%d" ), err ); + CleanupStack::PopAndDestroy(); + iStatus = KErrNone; + Cancel(); + CActiveScheduler::Stop(); + return err; + } + else if ( err == KImApiGeneralError && OpId == 0 ) // General ImApi error + { + CTestLogger1::Log( _L( "SendPToPMessageL(ValidContact) - err=%d" ), err ); + CleanupStack::PopAndDestroy(); // userIds + iStatus = err; + return err; + } + else + { + CTestLogger1::Log( _L( "SendPToPMessageL(ValidContact) - err=%d" ), err ); + CleanupStack::PopAndDestroy(); + iStatus = KRequestPending; + SetActive(); + return KErrNone; //OpId; + } + } + + +TInt CTestRunner::SendPToPValidTwoContactL() + { + CTestLogger1::Log( _L( "Test Case Number #10" ) ); + CContactIdArray* contactIDArray = GetWVContactIdsLC(); + TInt OpId = 0; + // Be sure that two contact is real WV contact + //Is there three contacts + TInt nuberofcontacts = contactIDArray->Count(); + if ( contactIDArray->Count() == 0 ) + { + CTestLogger1::Log( _L( "Can not find WvContact ID" ) ); + CleanupStack::PopAndDestroy(); + iStatus = KErrNone; + Cancel(); + CActiveScheduler::Stop(); + return KErrNone; + } + // Remove third contact + // Never commit the reset + if ( contactIDArray->Count() >= 3 ) + { + contactIDArray->Remove( 2 ); + } + + + // Check if Remove is OK + TRAPD( err1, OpId = iImClient->SendPToPMessageL( *contactIDArray, _L( "text/plain" ), _L8( "Hello All" ) ) ); + + //Send message + TRAPD( err, OpId = iImClient->SendPToPMessageL( *contactIDArray, _L( "13. Hello In Two Times Valid Contact" ) ) ); + + // Just checking return value + if ( err == KImApiErrInvalidContactId && OpId == 0 ) // KImApiErrInvalidContactId and OperationId is 0 + { + CTestLogger1::Log( _L( "SendPToPMessageL(ValidTwoContact) - err=%d" ), err ); + CleanupStack::PopAndDestroy(); + iStatus = KErrNone; + Cancel(); + CActiveScheduler::Stop(); + return err; + } + else if ( err == KImApiGeneralError && OpId == 0 ) // General ImApi error + { + CTestLogger1::Log( _L( "SendPToPMessageL(ValidTwoContact) - err=%d" ), err ); + CleanupStack::PopAndDestroy(); // userIds + iStatus = err; + return err; + } + else + { + CTestLogger1::Log( _L( "SendPToPMessageL(ValidTwoContact) - err=%d" ), err ); + CleanupStack::PopAndDestroy(); + iStatus = KRequestPending; + SetActive(); + return KErrNone; // OpId; + } + } + +TInt CTestRunner::SendPToPContactContentTypeL() + { + //This SDK API is not supported. Test case is added to increase the code coverage + CTestLogger1::Log( _L( "Test Case Number #11" ) ); + CTestLogger1::Log( _L( "SendPToPContactContentTypeL" ) ); + TInt OpId = 0; + CContactIdArray* contactIDArray = GetWVContactIdsLC(); + if ( contactIDArray->Count() == 0 ) + { + CTestLogger1::Log( _L( "Can not find WvContact ID" ) ); + CleanupStack::PopAndDestroy(); + iStatus = KErrNone; + Cancel(); + CActiveScheduler::Stop(); + return KErrNone; + } + TRAPD( err, OpId = iImClient->SendPToPMessageL( *contactIDArray, _L( "text/plain" ), _L8( "Hello All" ) ) ); + CleanupStack::PopAndDestroy(); // userIds + iStatus = err; + Cancel(); + CActiveScheduler::Stop(); + return err; + } + +TInt CTestRunner::SendPToPUserIDContentTypeL() + { + //This SDK API is not supported. Test case is added to increase the code coverage + CTestLogger1::Log( _L( "Test Case Number #12" ) ); + CTestLogger1::Log( _L( "SendPToPUserIDContentTypeL" ) ); + TInt OpId = 0; + CDesCArray* userIds = new( ELeave ) CDesCArrayFlat( 2 ); + CleanupStack::PushL( userIds ); + + TRAPD( err, OpId = iImClient->SendPToPMessageL( *userIds, _L( "text/plain" ), _L8( "Hello All" ) ) ); + CleanupStack::PopAndDestroy(); // userIds + iStatus = err; + Cancel(); + CActiveScheduler::Stop(); + return err; + } + + +TInt CTestRunner::QueryIMConnectionStatusL() + { + CTestLogger1::Log( _L( "Test Case Number #13" ) ); + TInt ret = iOpenApi->ImConnectionStatus(); + // Check returnvalue + if ( ret == 0 ) // iLoggedIn + { + CTestLogger1::Log( _L( "LogoutL" ) ); + iOpenApi->LogoutL(); + iStatus = KErrNone; + return 0; + } + else // 1 + { + iStatus = KErrNone; + Cancel(); + CActiveScheduler::Stop(); + return ret; + } + } + + +TInt CTestRunner::CancelLoginL() + { + CTestLogger1::Log( _L( "Test Case Number #14" ) ); + LoginL( iUserIdValue ); + TRAPD ( err, iOpenApi->CancelLoginL() ); + CTestLogger1::Log( _L( "CancelLoginL - err=%d" ), err ); + iImClient->UnregisterObserver(); + CTestLogger1::Log( _L( "Test Case Number #15" ) ); + CTestLogger1::Log( _L( "CImClient::UnregisterObserver" ) ); + } + +//********************************** +// Logger +//********************************** +const TInt KLogBufferLength = 256; +_LIT( KLogDir, "impsc" ); +_LIT( KLogFile, "IMAPITestCaseLog.txt" ); + +EXPORT_C void CTestLogger1::Log( TRefByValue aFmt, ... ) + { + VA_LIST list; + VA_START( list, aFmt ); + + // Print to log file + TBuf buf; + buf.FormatList( aFmt, list ); + + // Write to log file + RFileLogger::Write( KLogDir, KLogFile, EFileLoggingModeAppend, buf ); + } + diff -r dd806856a8f6 -r 862cab47b1ba common/tools/brag/brag.xsl --- a/common/tools/brag/brag.xsl Fri Nov 13 09:56:18 2009 +0000 +++ b/common/tools/brag/brag.xsl Fri Nov 13 11:20:06 2009 +0000 @@ -108,10 +108,17 @@

Step:

-
+ +
()
    -
  • +
  • + +
    (Too much text to show everything; lines not shown.) +
    + +
    +
@@ -138,7 +145,13 @@
    -
  • :
  • +
  • + +
    (Too much text to show everything; lines not shown.) +
    + +
    +
diff -r dd806856a8f6 -r 862cab47b1ba common/tools/brag/logToBRAG.pl --- a/common/tools/brag/logToBRAG.pl Fri Nov 13 09:56:18 2009 +0000 +++ b/common/tools/brag/logToBRAG.pl Fri Nov 13 11:20:06 2009 +0000 @@ -100,7 +100,7 @@ { last if $rule->{severity} eq "ignore"; # We found a match - my $failure = bless{ Kids => [ bless { Text => $line }, "Characters" ] }, "failure"; + my $failure = bless{ Kids => [ bless { Kids => [ bless { Text => $line }, "Characters" ]}, "effect"] }, "failure"; # Ensure we have a tag for this severity if (!exists $severityShortcut->{$rule->{severity}}) { diff -r dd806856a8f6 -r 862cab47b1ba common/tools/brag/raptorToBRAG.pl --- a/common/tools/brag/raptorToBRAG.pl Fri Nov 13 09:56:18 2009 +0000 +++ b/common/tools/brag/raptorToBRAG.pl Fri Nov 13 11:20:06 2009 +0000 @@ -18,10 +18,12 @@ use FindBin; use lib "$FindBin::Bin/../lib"; +use lib "$FindBin::Bin"; use Getopt::Long; use Text::CSV; +use ToBrag; my $raptorSummary; my $help = 0; @@ -39,24 +41,9 @@ } # Start to build structure to be output as XML (same format as XML::Parser would create for us) -my $xmlNewline = bless { Text => "\n" }, "Characters"; -my $buildStatus = -[ - bless - { - Kids => - [ - $xmlNewline, - bless - { - name => "Build", - Kids => [ $xmlNewline ] - }, "phase", - ] - }, "buildStatus" -]; -# Get a shortcut reference to the bit we will use a lot -my $buildPhase = $buildStatus->[0]->{Kids}->[-1]; +my $buildStatus = ToBrag::createBuildStatus(); +# Obtain a phase object +my $buildPhase = ToBrag::ensurePhase($buildStatus, "Build"); # READ SUMMARY.CSV FILE open(CSV, $raptorSummary); @@ -98,116 +85,34 @@ $failure->{subcategory} ||= 'uncategorized'; $failure->{severity} ||= 'unknown'; - # Look through the steps to see if we already have one to match this config - my $step; - foreach (@{$buildPhase->{Kids}}) - { - next unless ref $_ eq "step"; - if ($_->{name} eq $failure->{config}) - { - $step = $_; - last; - } - } - unless ($step) - { - # First item found in this step - create step entry - $step = bless { name => $failure->{config}, Kids => [ $xmlNewline ] }, "step"; - push @{$buildPhase->{Kids}}, $step, $xmlNewline; - # Also create empty tags with severities in a sensible order - foreach my $severity (qw{critical major minor}) - { - my $failureSet = bless { level => $severity, Kids => [ $xmlNewline ] }, "failures"; - push @{$step->{Kids}}, $failureSet, $xmlNewline; - } - } + # Obtain a matching step + my $step = ToBrag::ensureStep($buildPhase, $failure->{config}); + # Also create empty tags with severities in a sensible order + ToBrag::ensureFailureSet($step, "critical"); + ToBrag::ensureFailureSet($step, "major"); + ToBrag::ensureFailureSet($step, "minor"); - # Look through the sets of failures in this step to see if we hve one which matches this severity - my $failureSet; - foreach (@{$step->{Kids}}) - { - next unless ref $_ eq "failures"; - if ($_->{level} eq $failure->{severity}) - { - $failureSet = $_; - last; - } - } - unless ($failureSet) - { - # First item found at this severity - create failures entry - $failureSet = bless { level => $failure->{severity}, Kids => [ $xmlNewline ] }, "failures"; - push @{$step->{Kids}}, $failureSet, $xmlNewline; - } + # Obtain a set of failures which matches this severity + my $failureSet = ToBrag::ensureFailureSet($step, $failure->{severity}); # Now create the failure itself, and add it to this failure set my $failureItem = bless { -# href => "", - Kids => [ bless { Text => $failure->{subcategory} }, "Characters" ] + Kids => [ bless { Kids => [ bless { Text => $failure->{subcategory} }, "Characters" ]}, "effect" ], }, "failure"; if ($failure->{component}) { $failure->{component} =~ s{^(/sf/.*?/.*?)/.*$}{$1}; $failureItem->{package} = $failure->{component}; } - push @{$failureSet->{Kids}}, $failureItem, $xmlNewline; + push @{$failureSet->{Kids}}, $failureItem, $ToBrag::xmlNewline; } close(CSV); # Print XML print "\n"; print "\n"; -printTree($buildStatus->[0]); +ToBrag::printTree($buildStatus->[0]); print "\n"; exit(0); -sub printTree -{ - my $tree = shift or die; - die unless ref $tree; - - my $tagName = ref $tree; - $tagName =~ s{^main::}{}; - if ($tagName eq "Characters") - { - print $tree->{Text}; - return; - } - - print "<$tagName"; - - foreach my $attr ( - sort { - my $order = "name level start stop href"; - my $ixA = index $order, $a; - my $ixB = index $order, $b; - die "$a $b" if $ixA + $ixB == -2; - $ixA - $ixB; - } - grep { - ! ref $tree->{$_} - } - keys %$tree) - { - print " $attr=\"$tree->{$attr}\""; - } - - my $children = $tree->{Kids} || []; - if (scalar @$children) - { - print ">"; - foreach my $child (@$children) - { - printTree($child); - } - print ""; -} - diff -r dd806856a8f6 -r 862cab47b1ba common/tools/brag/sbsToBrag.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/tools/brag/sbsToBrag.pl Fri Nov 13 11:20:06 2009 +0000 @@ -0,0 +1,153 @@ +#!perl -w +# +# Copyright (c) 2009 Symbian Foundation Ltd +# 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: +# Symbian Foundation Ltd - initial contribution. +# +# Contributors: +# +# Description: +# Generate the BRAG-compatible XML summary of the Raptor log from the CSV output of the raptor parser + +use strict; + +use FindBin; +use lib "$FindBin::Bin"; + +use XML::Parser; +#use Getopt::Long; + +use ToBrag; + +my $raptorLogGlob = shift or die "First argument must be raptor XML log to read\n"; +shift and die "Only one argument please\n"; + +@ARGV = glob $raptorLogGlob; + +# Start to build structure to be output as XML (same format as XML::Parser would create for us) +my ($doc, $buildStatus) = ToBrag::createDocumentAndRoot("buildStatus"); +# Obtain a phase object +my $buildPhase = ToBrag::ensureChild($buildStatus, "phase", "name", "Build"); + +# Parse the Raptor logs +# (Use XML::Parser in "Stream" mode so we don't have to hold all the data in memory at the same time) +my $xml = XML::Parser->new(Style => "Stream", Pkg => "main"); + +foreach my $log (@ARGV) +{ + $xml->parsefile($log); +} + +print "\n"; +print "\n"; +ToBrag::printTree($doc->[0]); +print "\n"; + +exit (0); + +my $context; +sub StartTag +{ + my $expat = shift; + my $tagName = shift; + my %attrib = %_; + + if ($tagName eq "recipe") + { + $context = {%attrib}; + } + elsif ($tagName eq "status") + { + $context->{"exit"} = $attrib{"exit"}; + } +} +sub EndTag +{ + my $expat = shift; + my $tagName = shift; + + if ($tagName eq "recipe") + { + die unless $context; + + if ($context->{"exit"} ne "ok") + { + # Create a more readable error message + my %errorIdToDetail = ( + tem => {message => "Failed to execute '$context->{source}' invoked via $context->{bldinf}", severity => "major"}, + msvctoolscompile => {message => "Failed to compile $context->{source}", severity => "minor"}, + compile => {message => "Failed to compile $context->{source}", severity => "minor"}, + compile2object => {message => "Failed to compile $context->{source}", severity => "minor"}, + win32compile2object => {message => "Failed to compile $context->{source}", severity => "minor"}, + tools2lib => {message => "Failed to build library $context->{target}", severity => "minor"}, + ar => {message => "Failed to build library $context->{target}", severity => "minor"}, + win32archive => {message => "Failed to build library $context->{target}", severity => "minor"}, + "link" => {message => "Failed to create symbols for $context->{target}", severity => "minor"}, + postlink => {message => "Failed to link $context->{target}", severity => "minor"}, + win32stageonelink => {message => "Failed to link $context->{target} (stage 1)", severity => "minor"}, + win32stagetwolink => {message => "Failed to link $context->{target}", severity => "minor"}, + win32simplelink => {message => "Failed to link $context->{target}", severity => "minor"}, + win32processexports => {message => "Failed to export $context->{source} to $context->{target}", severity => "minor"}, + tracecompile => {message => "Trace compile failure for $context->{target}", severity => "unknown"}, + extension_makefile => {message => "Failed within an extension makefile connected to $context->{bldinf}", severity => "major"}, + ); +# die $context->{name} unless exists $errorIdToDetail{$context->{name}}; + + my $message = $errorIdToDetail{$context->{name}}->{message} || "Unknown failure tag '$context->{name}' ($context->{source} -> $context->{target})"; + $context->{severity} = $errorIdToDetail{$context->{name}}->{severity} || "unknown"; + + # Obtain a step object + my $step = ToBrag::ensureStep($buildPhase, $context->{config}); + # Also create empty tags with severities in a sensible order + ToBrag::ensureFailureSet($step, "critical"); + ToBrag::ensureFailureSet($step, "major"); + ToBrag::ensureFailureSet($step, "minor"); + # Obtain a failures object + my $failureSet = ToBrag::ensureFailureSet($step, $context->{severity}); + + # Now create the failure itself, and add it to this failure set + my $failureItem = bless { + Kids => [ bless { Kids => [ bless { Text => $message }, "Characters" ]}, "effect" ], + }, "failure"; + if ($context->{component}) + { + $context->{bldinf} =~ s{^\w:(/sf/.*?/.*?)/.*$}{$1}; + $failureItem->{package} = $context->{bldinf}; + } + my @causes = grep { $_ && ! m/^\+ / } split("\n", $context->{Chars}); + @causes = map { " $_" } @causes; + if (@causes) + { + my @reportedCauses = @causes[0 .. min($#causes, 49)]; + my $causesItem = bless { + Kids => [ bless { Text => join "\n", @reportedCauses }, "Characters" ] + }, "causes"; + push @{$failureItem->{Kids}}, $causesItem; + my $unreportedCauses = scalar @causes - scalar @reportedCauses; + $failureItem->{unreported_causes} = $unreportedCauses; + } + push @{$failureSet->{Kids}}, $failureItem, $ToBrag::xmlNewline; + } + + $context = undef; + } +} +sub Text +{ + s/^\n*//; + if ($context) + { + $context->{Chars} .= $_; + } +} + +sub min +{ + return ($_[0] < $_[1]) ? $_[0] : $_[1] ; +} + diff -r dd806856a8f6 -r 862cab47b1ba common/tools/brag/toBrag.pm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/tools/brag/toBrag.pm Fri Nov 13 11:20:06 2009 +0000 @@ -0,0 +1,160 @@ +#!perl -w +# +# Copyright (c) 2009 Symbian Foundation Ltd +# 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: +# Symbian Foundation Ltd - initial contribution. +# +# Contributors: +# +# Description: +# Functionality common to BRAG file generation + +use strict; + +package ToBrag; + +# A useful constant +our $xmlNewline = bless { Text => "\n" }, "Characters"; + +sub createDocumentAndRoot +{ + my $rootTag = shift; + + my $root = bless + { + Kids => + [ $ToBrag::xmlNewline ] + }, $rootTag; + + return [$root], $root; +} + +sub createBuildStatus +{ + return [ + bless + { + Kids => + [ $ToBrag::xmlNewline ] + }, "buildStatus" + ]; +} + +sub ensurePhase +{ + my $buildStatus = shift; + my $phaseName = shift; + + my ($phase) = grep { ref $_ eq "phase" && $_->{name} eq $phaseName } @{$buildStatus->[-1]->{Kids}}; + unless ($phase) + { + $phase = bless + { + name => $phaseName, + Kids => [ $ToBrag::xmlNewline ] + }, "phase"; + push @{$buildStatus->[-1]->{Kids}}, $phase, $ToBrag::xmlNewline; + } + return $phase; +} + +sub ensureStep +{ + my $phase = shift; + my $stepName = shift; + + return ensureChild($phase, "step", "name", $stepName); +} + +sub ensureFailureSet +{ + my $step = shift; + my $level = shift; + + return ensureChild($step, "failures", "level", $level); +} + +sub ensureChild +{ + my $parent = shift; + my $childName = shift; + my $childAttr = shift; + my $childAttrValue = shift; + + my ($child) = grep { ref $_ eq $childName && $_->{$childAttr} eq $childAttrValue } @{$parent->{Kids}}; + unless ($child) + { + $child = bless + { + $childAttr => $childAttrValue, + Kids => [ $ToBrag::xmlNewline ] + }, $childName; + push @{$parent->{Kids}}, $child, $ToBrag::xmlNewline; + } + return $child; +} + +# Prints out the XML tree to STDOUT +sub printTree +{ + my $tree = shift or die; + die unless ref $tree; + + my $tagName = ref $tree; + $tagName =~ s{^main::}{}; + if ($tagName eq "Characters") + { + if ($tree->{Text} =~ m{[<>&]}) + { + print "{Text}]]>"; + } + else + { + print $tree->{Text}; + } + return; + } + + print "<$tagName"; + + foreach my $attr ( + sort { + my $order = "name level start stop href package effect"; + my $ixA = index $order, $a; + my $ixB = index $order, $b; + die "$a $b" if $ixA + $ixB == -2; + $ixA - $ixB; + } + grep { + ! ref $tree->{$_} + } + keys %$tree) + { + print " $attr=\"$tree->{$attr}\""; + } + + my $children = $tree->{Kids} || []; + if (scalar @$children) + { + print ">"; + foreach my $child (@$children) + { + printTree($child); + } + print ""; +} + +1; + diff -r dd806856a8f6 -r 862cab47b1ba common/tools/brag/yarpToBRAG.pl --- a/common/tools/brag/yarpToBRAG.pl Fri Nov 13 09:56:18 2009 +0000 +++ b/common/tools/brag/yarpToBRAG.pl Fri Nov 13 11:20:06 2009 +0000 @@ -18,10 +18,13 @@ use FindBin; use lib "$FindBin::Bin/../lib"; +use lib "$FindBin::Bin"; use Getopt::Long; use Text::CSV; +use ToBrag; + if (!@ARGV) { warn "Generate an XML summary of the Raptor build from a Yarp CSV file\n"; @@ -30,20 +33,9 @@ } # Start to build structure to be output as XML (same format as XML::Parser would create for us) -my $xmlNewline = bless { Text => "\n" }, "Characters"; -my $buildPhase = bless { name => "Build", Kids => [ $xmlNewline ] }, "phase"; -my $buildStatus = -[ - bless - { - Kids => - [ - $xmlNewline, - $buildPhase, - $xmlNewline, - ] - }, "buildStatus" -]; +my $buildStatus = ToBrag::createBuildStatus(); +# Obtain a phase object +my $buildPhase = ToBrag::ensurePhase($buildStatus, "Build"); @ARGV = map { glob $_ } @ARGV; @@ -114,113 +106,32 @@ # die $failure->{name} unless exists $errorIdToDetail{$failure->{name}}; my $message = $errorIdToDetail{$failure->{name}}->{message} || "Unknown failure tag '$failure->{name}' ($failure->{source} -> $failure->{target})"; $failure->{severity} = $errorIdToDetail{$failure->{name}}->{severity} || "unknown"; - - # Look through the steps to see if we already have one to match this platform - my $step; - foreach (@{$buildPhase->{Kids}}) - { - next unless ref $_ eq "step"; - if ($_->{name} eq $failure->{platform}) - { - $step = $_; - last; - } - } - unless ($step) - { - # First item found for this platform - create step entry - $step = bless { name => $failure->{platform}, Kids => [ $xmlNewline ] }, "step"; - push @{$buildPhase->{Kids}}, $step, $xmlNewline; - # Also create empty tags with severities in a sensible order - foreach my $severity (qw{critical major minor}) - { - my $failureSet = bless { level => $severity, Kids => [ $xmlNewline ] }, "failures"; - push @{$step->{Kids}}, $failureSet, $xmlNewline; - } - } - # Look through the sets of failures in this step to see if we hve one which matches this severity - my $failureSet; - foreach (@{$step->{Kids}}) - { - next unless ref $_ eq "failures"; - if ($_->{level} eq $failure->{severity}) - { - $failureSet = $_; - last; - } - } - unless ($failureSet) - { - # First item found at this severity - create failures entry - $failureSet = bless { level => $failure->{severity}, Kids => [ $xmlNewline ] }, "failures"; - push @{$step->{Kids}}, $failureSet, $xmlNewline; - } + # Obtain a matching step + my $step = ToBrag::ensureStep($buildPhase, $failure->{platform}); + # Also create empty tags with severities in a sensible order + ToBrag::ensureFailureSet($step, "critical"); + ToBrag::ensureFailureSet($step, "major"); + ToBrag::ensureFailureSet($step, "minor"); + + # Obtain a set of failures which matches this severity + my $failureSet = ToBrag::ensureFailureSet($step, $failure->{severity}); # Now create the failure itself, and add it to this failure set my $failureItem = bless { # href => "", "package" => $failure->{package}, - Kids => [ bless { Text => $message }, "Characters" ], + Kids => [ bless { Kids => [ bless { Text => $message }, "Characters" ]}, "effect"], }, "failure"; - push @{$failureSet->{Kids}}, $failureItem, $xmlNewline; + push @{$failureSet->{Kids}}, $failureItem, $ToBrag::xmlNewline; } close(CSV); } # Print XML print "\n"; print "\n"; -printTree($buildStatus->[0]); +ToBrag::printTree($buildStatus->[0]); print "\n"; exit(0); -sub printTree -{ - my $tree = shift or die; - die unless ref $tree; - - my $tagName = ref $tree; - $tagName =~ s{^main::}{}; - if ($tagName eq "Characters") - { - print $tree->{Text}; - return; - } - - print "<$tagName"; - - foreach my $attr ( - sort { - my $order = "name level start stop href"; - my $ixA = index $order, $a; - my $ixB = index $order, $b; - die "$a $b" if $ixA + $ixB == -2; - $ixA - $ixB; - } - grep { - ! ref $tree->{$_} - } - keys %$tree) - { - print " $attr=\"$tree->{$attr}\""; - } - - my $children = $tree->{Kids} || []; - if (scalar @$children) - { - print ">"; - foreach my $child (@$children) - { - printTree($child); - } - print ""; -} - diff -r dd806856a8f6 -r 862cab47b1ba sf-platform/platform_props.ant.xml --- a/sf-platform/platform_props.ant.xml Fri Nov 13 09:56:18 2009 +0000 +++ b/sf-platform/platform_props.ant.xml Fri Nov 13 11:20:06 2009 +0000 @@ -7,11 +7,11 @@ - + - +