--- a/tsrc/group/bld.inf Tue Jul 13 00:13:42 2010 +0300
+++ b/tsrc/group/bld.inf Tue Jul 13 00:24:10 2010 +0300
@@ -19,10 +19,13 @@
PRJ_PLATFORMS
DEFAULT
+//build files for Stub Framework
+#include "../testtools/stubsrv/group/bld.inf"
//build files for usb
#include "../../usbclasses/msmmplugin/tsrc/MsmmPluginTest/group/bld.inf"
#include "../../usbuis/usbuinotif/tsrc/USBUiNotifApiTest/group/bld.inf"
#include "../../usbclasses/usbhidclassdriver/tsrc/UsbHidClassDriverTest/group/bld.inf"
+#include "../../usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/group/bld.inf"
PRJ_EXPORTS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/testtools/stubsrv/bwins/apibehavioru.def Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,9 @@
+EXPORTS
+ ??0TApiBehavior@@QAE@II@Z @ 1 NONAME ; TApiBehavior::TApiBehavior(unsigned int, unsigned int)
+ ?MatchId@TApiBehavior@@QBEHII@Z @ 2 NONAME ; int TApiBehavior::MatchId(unsigned int, unsigned int) const
+ ?MatchId@TApiBehavior@@QBEHABV1@@Z @ 3 NONAME ; int TApiBehavior::MatchId(class TApiBehavior const &) const
+ ??0TApiBehavior@@QAE@IIHHABVTDesC8@@@Z @ 4 NONAME ; TApiBehavior::TApiBehavior(unsigned int, unsigned int, int, int, class TDesC8 const &)
+ ??8TApiBehavior@@QBEHABV0@@Z @ 5 NONAME ; int TApiBehavior::operator==(class TApiBehavior const &) const
+ ??9TApiBehavior@@QBEHABV0@@Z @ 6 NONAME ; int TApiBehavior::operator!=(class TApiBehavior const &) const
+ ??0TApiBehavior@@QAE@XZ @ 7 NONAME ; TApiBehavior::TApiBehavior(void)
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/testtools/stubsrv/bwins/stubberu.def Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,9 @@
+EXPORTS
+ ?InvokeApiCancel@CStubber@@QAEXXZ @ 1 NONAME ; void CStubber::InvokeApiCancel(void)
+ ?DeleteBehaviors@CStubber@@QAEXII@Z @ 2 NONAME ; void CStubber::DeleteBehaviors(unsigned int, unsigned int)
+ ?NewL@CStubber@@SAPAV1@XZ @ 3 NONAME ; class CStubber * CStubber::NewL(void)
+ ?InvokeApi@CStubber@@QAEXAAVTApiBehavior@@W4TApiInvokeMode@@@Z @ 4 NONAME ; void CStubber::InvokeApi(class TApiBehavior &, enum TApiInvokeMode)
+ ??1CStubber@@UAE@XZ @ 5 NONAME ; CStubber::~CStubber(void)
+ ?InvokeApiL@CStubber@@QAEXAAVMApiInvoker@@IIW4TApiInvokeMode@@@Z @ 6 NONAME ; void CStubber::InvokeApiL(class MApiInvoker &, unsigned int, unsigned int, enum TApiInvokeMode)
+ ?EnqueBehavior@CStubber@@QAEXABVTApiBehavior@@H@Z @ 7 NONAME ; void CStubber::EnqueBehavior(class TApiBehavior const &, int)
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/testtools/stubsrv/eabi/apibehavioru.def Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,12 @@
+EXPORTS
+ _ZN12TApiBehaviorC1Ejj @ 1 NONAME
+ _ZN12TApiBehaviorC1EjjiiRK6TDesC8 @ 2 NONAME
+ _ZN12TApiBehaviorC1Ev @ 3 NONAME
+ _ZN12TApiBehaviorC2Ejj @ 4 NONAME
+ _ZN12TApiBehaviorC2EjjiiRK6TDesC8 @ 5 NONAME
+ _ZN12TApiBehaviorC2Ev @ 6 NONAME
+ _ZNK12TApiBehavior7MatchIdERKS_ @ 7 NONAME
+ _ZNK12TApiBehavior7MatchIdEjj @ 8 NONAME
+ _ZNK12TApiBehavioreqERKS_ @ 9 NONAME
+ _ZNK12TApiBehaviorneERKS_ @ 10 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/testtools/stubsrv/eabi/stubberu.def Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,11 @@
+EXPORTS
+ _ZN8CStubber10InvokeApiLER11MApiInvokerjj14TApiInvokeMode @ 1 NONAME
+ _ZN8CStubber13EnqueBehaviorERK12TApiBehaviori @ 2 NONAME
+ _ZN8CStubber15DeleteBehaviorsEjj @ 3 NONAME
+ _ZN8CStubber15InvokeApiCancelEv @ 4 NONAME
+ _ZN8CStubber4NewLEv @ 5 NONAME
+ _ZN8CStubber9InvokeApiER12TApiBehavior14TApiInvokeMode @ 6 NONAME
+ _ZN8CStubberD0Ev @ 7 NONAME
+ _ZN8CStubberD1Ev @ 8 NONAME
+ _ZN8CStubberD2Ev @ 9 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/testtools/stubsrv/group/apibehavior.mmp Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+CAPABILITY All -Tcb
+
+TARGET apibehavior.dll
+TARGETTYPE dll
+
+UID 0x1000008d 0xE0000092
+
+SOURCEPATH ../src
+SOURCE apibehavior.cpp
+
+USERINCLUDE ../inc
+SYSTEMINCLUDE /epoc32/include
+
+LIBRARY euser.lib
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/testtools/stubsrv/group/bld.inf Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+PRJ_TESTEXPORTS
+../inc/apibehavior.h /epoc32/include/mw/stubsrv/apibehavior.h
+../inc/stubber.h /epoc32/include/mw/stubsrv/stubber.h
+../inc/stubsrvconst.h /epoc32/include/mw/stubsrv/stubsrvconst.h
+../rom/stubsrv.iby /epoc32/rom/include/core/mw/stubsrv.iby
+
+PRJ_MMPFILES
+
+PRJ_TESTMMPFILES
+apibehavior.mmp
+stubber.mmp
+stubsrv.mmp
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/testtools/stubsrv/group/stubber.mmp Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+CAPABILITY All -Tcb
+
+TARGET stubber.dll
+TARGETTYPE dll
+
+UID 0x1000008d 0xE0000091
+
+SOURCEPATH ../src
+SOURCE stubclient.cpp
+SOURCE stubber.cpp
+
+USERINCLUDE ../inc
+SYSTEMINCLUDE /epoc32/include /epoc32/include/stubsrv
+
+LIBRARY euser.lib
+LIBRARY apibehavior.lib
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/testtools/stubsrv/group/stubsrv.mmp Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+CAPABILITY All -Tcb
+
+TARGET stubsrv.exe
+TARGETTYPE exe
+
+UID 0x1000008d 0xE0000090
+
+// EPOCHEAPSIZE 0x500 0x400000
+
+SOURCEPATH ../src
+SOURCE stubsrv.cpp
+SOURCE stubsrvsession.cpp
+SOURCE stubsrvapiexecutor.cpp
+
+USERINCLUDE ../inc
+SYSTEMINCLUDE /epoc32/include /epoc32/include/platform/ /epoc32/include/stubsrv
+
+LIBRARY euser.lib
+LIBRARY apibehavior.lib
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/testtools/stubsrv/inc/apibehavior.h Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,137 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef APIBEHAVIOR_H
+#define APIBEHAVIOR_H
+
+#include <e32base.h>
+
+const TInt KApiOutputSize = 512;
+
+/**
+ * The specification of the behavior of an API.
+ */
+NONSHARABLE_CLASS(TApiBehavior)
+{
+public:
+
+ /**
+ * Constructs by default.
+ * Members are initialized to:
+ * iLib: 0
+ * iApi: 0
+ * iCompleteCode: 0.
+ * iAsyncCompleteCode: 0.
+ * iOutput: KNullDes8.
+ */
+ IMPORT_C TApiBehavior();
+
+ /**
+ * Constructs by specified.
+ * @param aLib the library identifier
+ * @param aApi the API identifier
+ *
+ * Other members are initialized to:
+ * iCompleteCode: 0.
+ * iAsyncCompleteCode: 0.
+ * iOutput: KNullDes8.
+ */
+ IMPORT_C TApiBehavior(TUint aLib, TUint aApi);
+
+ /**
+ * Construct by specified.
+ *
+ * @param aLib the library identifier
+ * @param aApi the API identifier
+ * @param aCompleteCode the expected completion code of the API call
+ * @param aAsyncCompleteCode the expected asynchronous completion code of the API call
+ * @param aOutput the expected output
+ */
+ IMPORT_C TApiBehavior(TUint aLib, TUint aApi,
+ TInt aCompleteCode, TInt aAsyncCompleteCode,
+ const TDesC8& aOutput);
+
+ /**
+ * Compares if the identifiers of this API match with the specified.
+ * @param aLib the library identifier
+ * @param aApi the APi identifier
+ *
+ * @return ETrue if the ids match; EFalse otherwise.
+ */
+ IMPORT_C TBool MatchId(TUint aLib, TUint aApi) const;
+
+ /**
+ * Compares if the identifiers of this API match with the identifiers of the specified.
+ * @param aLib the library identifier
+ * @param aApi the APi identifier
+ *
+ * @return ETrue if the ids match; EFalse otherwise.
+ */
+ IMPORT_C TBool MatchId(const TApiBehavior& aBeh) const;
+
+ /**
+ * Operator ==
+ *
+ * @return ETrue if if the content of this is identical with the specified; EFalse otherwise.
+ */
+ IMPORT_C TBool operator==(const TApiBehavior& aBeh) const;
+
+ /**
+ * Operator !=
+ *
+ * @return ETrue if if the content of this is different with the specified; EFalse otherwise.
+ */
+ IMPORT_C TBool operator!=(const TApiBehavior& aBeh) const;
+
+public:
+
+ /**
+ * The identifier of the library that provides this API
+ */
+ TUint iLib;
+
+ /**
+ * The identifier of this API in the library.
+ *
+ * iLib and iApi identify a unique API in the scope of testing framework.
+ */
+ TUint iApi;
+
+ /**
+ * The completion code of the API call, either the return error code if
+ * the function returns one or the leave code if the function is leavable.
+ * This should be ignored by void type APIs.
+ */
+ TInt iCompleteCode;
+
+ /**
+ * The completion code of asynchronous service provided by this API.
+ * This should be ignored by synchronous API.
+ */
+ TInt iAsyncCompleteCode;
+
+ /**
+ * The expected output of this API.
+ */
+ TBuf8<KApiOutputSize> iOutput;
+ };
+
+typedef TPckgBuf<TApiBehavior> TApiBehaviorPckgBuf;
+typedef TPckg<TApiBehavior> TApiBehaviorPckg;
+
+#endif
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/testtools/stubsrv/inc/stubber.h Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,124 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef STUBBER_H
+#define STUBBER_H
+
+#include <e32base.h>
+#include <apibehavior.h>
+#include <stubsrvconst.h>
+
+class RStubClient;
+
+class MApiInvoker
+{
+public:
+ virtual void InvokeApiComplete(const TApiBehavior& aBeh) = 0;
+};
+
+NONSHARABLE_CLASS(CStubber) : public CActive
+ {
+public:
+
+ IMPORT_C static CStubber* NewL();
+
+ IMPORT_C ~CStubber();
+
+ /**
+ * Queues an API behavior specification to Stub server.
+ *
+ * This method is called by API behavior controllers, e.g. a module test, to specify the next expected
+ * behavior of an API. When InvokeApi() is called, the first queued behavior matching
+ * the lib identifier and API identifier will be extracted and returned.
+ *
+ * @param aApi an API behavior.
+ * @param aExeDuration, specifies the execution time of InvokeApi() in microseconds.
+ * value less than 0 means never completing InvokeApi();
+ * value 0 means completing InvokeApi() asap;
+ * value 1000000 means InvokeApi() takes 1 sec execution time;
+ * and so on.
+ */
+ IMPORT_C void EnqueBehavior(const TApiBehavior& aBeh, TInt aExeDuration = 0);
+
+ /**
+ * Deletes all queued behaviors of the specified API.
+ *
+ * @param aLib the identifier of a stub
+ * @param aApi the identifier of the API
+ */
+ IMPORT_C void DeleteBehaviors(TUint aLib, TUint aApi);
+
+ /**
+ * Invokes an API.
+ *
+ * If there is a queued behavior for this API, Stub server will perform according to the execution setting;
+ * otherwise stub server will act according to the specified mode.
+ *
+ * @param aBeh contains the lib and API identifiers when passed in;
+ * will contain the behavior at complete.
+ * @param aMode the mode to be used if no queued behavior is found for the specified API;
+ * In case of ECompleteIfNoBehaviorSet mode, stub server will complete this function
+ * immediately and return a default TApiBehavior(TUint, TUint);
+ * stub server will keep this function call pending until a behavior is queued if the mode
+ * is ESuspendIfBehaviorSet.
+ */
+ IMPORT_C void InvokeApi(TApiBehavior& aBeh, TApiInvokeMode aMode = ECompleteIfNoBehaviorSet);
+
+ /**
+ * asynchronous version of InvokeAPI(), MApiInvoker::InvokeApiComplete will be called when
+ * this opeation is completed by stub server
+ *
+ * Only one InvokeApiL is allowed at a time.
+ *
+ * Leaves if the completion code in the behavior to be extracted is not KErrNone.
+ *
+ * @param aLib the identifier of a stub
+ * @param aApi the identifier of the API
+ * @param aMode the mode to be used if no queued behavior is found for the specified API;
+ * In case of ECompleteIfNoBehaviorSet mode, stub server will complete this function
+ * immediately and return a default TApiBehavior(TUint, TUint);
+ * stub server will keep this function call pending until a behavior is queued if the mode
+ * is ESuspendIfBehaviorSet.
+ */
+ IMPORT_C void InvokeApiL(MApiInvoker& aInvoker, TUint aLib, TUint aApi, TApiInvokeMode aMode = ECompleteIfNoBehaviorSet);
+
+ /**
+ * Cancels InvokeApi()
+ */
+ IMPORT_C void InvokeApiCancel();
+
+protected:
+ void RunL();
+ void DoCancel();
+ TInt RunError(TInt aReason);
+
+protected:
+ CStubber();
+
+ void ConstructL();
+
+protected:
+ MApiInvoker* iInvoker;
+
+ TApiBehavior iBeh;
+ TApiBehaviorPckg iBehPckg;
+
+ RStubClient* iClient;
+ };
+
+#endif // STUBBER_H
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/testtools/stubsrv/inc/stubclient.h Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,103 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef STUBCLIENT_H
+#define STUBCLIENT_H
+
+#include <e32std.h>
+#include <stubsrvconst.h>
+#include <apibehavior.h>
+
+class RStubClient : public RSessionBase
+ {
+
+public:
+
+ /**
+ * Queues an API behavior specification to Stub server.
+ *
+ * This method is called by API behavior controllers, e.g. a module test, to specify the next expected
+ * behavior of an API. When InvokeApi() is called, the first queued behavior matching
+ * the lib identifier and API identifier will be extracted and returned.
+ *
+ * @param aApi an API behavior.
+ * @param aExeDuration, specifies the execution time of InvokeApi() in microseconds.
+ * value less than 0 means never completing InvokeApi();
+ * value 0 means completing InvokeApi() asap;
+ * value 1000000 means InvokeApi() takes 1 sec execution time;
+ * and so on.
+ */
+ void EnqueBehavior(const TApiBehavior& aBeh, TInt aExeDuration = 0);
+
+ /**
+ * Deletes all queued behaviors of the specified API.
+ *
+ * @param aLib the identifier of a stub
+ * @param aApi the identifier of the API
+ */
+ void DeleteBehaviors(TUint aLib, TUint aApi);
+
+ /**
+ * Invokes an API.
+ *
+ * If there is a queued behavior for this API, stub server will perform according to the execution setting;
+ * otherwise stub server will act according to the specified mode.
+ *
+ * @param aBehPckg contains the lib and API identifiers when passed in;
+ * will contain the behavior at complete.
+ * @param aMode the mode to be used if no queued behavior is found for the specified API;
+ * In case of ECompleteIfNoBehaviorSet mode, stub server will complete this function
+ * immediately and return a default TApiBehavior(TUint, TUint);
+ * stub server will keep this function call pending until a behavior is queued if the mode
+ * is ESuspendIfBehaviorSet.
+ */
+ void InvokeApi(TApiBehaviorPckg& aBehPckg, TApiInvokeMode aMode);
+
+ /**
+ * asynchronous version of InvokeAPI().
+ *
+ * Leaves if the completion code in the behavior is not KErrNone
+ */
+ void InvokeApiL(TApiBehaviorPckg& aBehPckg, TRequestStatus& aStatus, TApiInvokeMode aMode);
+
+ /**
+ * Cancels InvokeApi()
+ * @param aLib the identifier of library which provides the API
+ * @param aApi the identifier of the API
+ */
+ void InvokeApiCancel(TUint aLib, TUint aApi);
+
+public:
+
+ /**
+ * @return Version information about the server
+ */
+ TVersion Version() const;
+
+ /**
+ * Establishes a session with stub server.
+ * @return error code
+ */
+ TInt Connect();
+
+private:
+
+ void CheckSession();
+
+ };
+
+#endif // STUBCLIENT_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/testtools/stubsrv/inc/stubclientsrv.h Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef CLIENTSERVER_H
+#define CLIENTSERVER_H
+
+_LIT(KStubSrvName, "stubsrv");
+
+const TUid KStubSrvUid3 = {0xE0000090};
+
+const TInt KStubSrvMajorVersionNumber = 1;
+const TInt KStubSrvMinorVersionNumber = 1;
+const TInt KStubSrvBuildNumber = 0;
+
+enum TIpcConstant
+ {
+ EStubSrvEnqueApiBehavior,
+ EStubSrvDeleteApiBehaviors,
+ EStubSrvInvokeApi,
+ EStubSrvInvokeApiCancel,
+ EStubSrvGetApiCompletionCode,
+ EStubSrvInvalidIpc,
+ };
+
+#endif
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/testtools/stubsrv/inc/stubsrv.h Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,102 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef STUBSRV_H
+#define STUBSRV_H
+
+#include <e32svr.h>
+#include <e32base.h>
+#include <apibehavior.h>
+#include "stubclientsrv.h"
+
+enum TStubfPanic
+ {
+ EStubfBadRequest = 100000,
+ EStubfBadDescriptor,
+ EStubfNotCompletedApis,
+ EStubfBadMessage,
+ EStubfNoLimitedMessage,
+ EStubfClassMemberVariableIsNull,
+ EStubfClassMemberVariableIsNotNull,
+ EMainSchedulerError,
+ EStubfApiAlreadyStarted,
+ EStubfApiNotStarted,
+ };
+
+class CStubSrvSess;
+
+NONSHARABLE_CLASS(CStubSrv) : public CPolicyServer
+ {
+
+public:
+
+ static CStubSrv* NewLC();
+
+ ~CStubSrv();
+
+public:
+
+ void StartShutdownTimerIfNoSessions();
+
+ TInt ClientOpened(CStubSrvSess& aSession);
+
+ void ClientClosed(CStubSrvSess& aSession);
+
+ void EnqueueL(const RMessage2& aMessage);
+
+ void DeleteQueues(const RMessage2& aMessage);
+
+ TInt Dequeue(TApiBehavior& aBeh, TInt& aExeDuration, TInt aTransactionId);
+
+ void GetApiCompleteCodeL(const RMessage2& aMessage);
+
+private:
+
+ CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const;
+
+private:
+
+ CStubSrv(TInt aPriority);
+
+ void ConstructL();
+
+ void CancelShutdownTimer();
+
+ static TInt TimerFired(TAny* aThis);
+
+private:
+ class TApiQueueItem
+ {
+ public:
+ TApiBehavior iBeh;
+ TInt iExeDuration;
+ TInt iTransactionId;
+ };
+
+private:
+
+ CPeriodic* iTimer;
+
+ RPointerArray<CStubSrvSess> iSessions;
+
+ RPointerArray<TApiQueueItem> iBehQueue;
+ TInt iTransctionUnique;
+ };
+
+#endif
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/testtools/stubsrv/inc/stubsrvapiexecutor.h Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef C_STUBFAPISPEC_H
+#define C_STUBFAPISPEC_H
+
+#include <e32base.h>
+#include <apibehavior.h>
+#include "stubsrvconst.h"
+
+class CStubSrvSess;
+
+class CApiExecutor : public CActive
+ {
+
+public:
+
+ static CApiExecutor* NewL();
+
+ virtual ~CApiExecutor();
+
+ const TApiBehavior& ApiBehavior() const;
+
+ TApiInvokeMode Mode() const;
+
+ void ExecuteL(const RMessage2& aMessage, CStubSrvSess& aSession, TUint aLib, TUint aApi);
+
+ void ExecuteL(const RMessage2& aMessage, CStubSrvSess& aSession, const TApiBehavior& aBeh, TInt aExeDuration);
+
+ void Resume(const TApiBehavior& aBeh, TInt aExeDuration);
+
+private:
+
+ void RunL();
+
+ TInt RunError(TInt aReason);
+
+ void DoCancel();
+
+private:
+
+ CApiExecutor();
+
+ void ConstructL();
+
+private:
+
+ CStubSrvSess* iSess; // The associated client who started this API.
+ TApiBehavior iBeh;
+
+ TApiInvokeMode iMode;
+
+ TInt iTimeout;
+
+ RTimer iTimer;
+
+ RMessage2 iMessage;
+ };
+
+#endif // C_STUBFAPISPEC_H
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/testtools/stubsrv/inc/stubsrvconst.h Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef STUBCONSTANTS_H
+#define STUBCONSTANTS_H
+
+enum TApiInvokeMode
+ {
+ ECompleteIfNoBehaviorSet,
+ ESuspendIfNoBehaviorSet,
+ };
+
+
+#endif
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/testtools/stubsrv/inc/stubsrvsecuritypolicy.h Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef SERVER_SECURITYPOLICY_H
+#define SERVER_SECURITYPOLICY_H
+
+#include "stubclientsrv.h"
+
+const TInt KStubSrvIpcRanges[] =
+ {
+ 0,
+ EStubSrvInvalidIpc,
+ };
+
+const TInt KStubSrvIpcRangeCount = sizeof(KStubSrvIpcRanges) / sizeof(TInt);
+
+const TUint8 KStubSrvElementsIndex[KStubSrvIpcRangeCount] =
+ {
+ 0,
+ CPolicyServer::ENotSupported
+ };
+
+const CPolicyServer::TPolicyElement KStubSrvElements[] =
+ {
+ {TSecurityPolicy::EAlwaysPass, CPolicyServer::EFailClient},
+ };
+
+const CPolicyServer::TPolicy KStubSrvPolicy =
+ {
+ CPolicyServer::EAlwaysPass,
+ KStubSrvIpcRangeCount,
+ KStubSrvIpcRanges,
+ KStubSrvElementsIndex,
+ KStubSrvElements
+ };
+
+#endif
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/testtools/stubsrv/inc/stubsrvsession.h Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef SESSION_H
+#define SESSION_H
+
+#include <e32base.h>
+#include <apibehavior.h>
+
+class CStubSrv;
+class CApiExecutor;
+
+/**
+* CStubSrvSess class represent session on server side
+*
+*/
+NONSHARABLE_CLASS(CStubSrvSess) : public CSession2
+ {
+public:
+
+ static CStubSrvSess* NewL(CStubSrv& aServer);
+
+ ~CStubSrvSess();
+
+ void InvokeApiComplete();
+
+ TInt ConsumeApiBehavior(const TApiBehavior& aBeh, TInt aExeDuration);
+
+private:
+
+ void ServiceL(const RMessage2& aMessage);
+
+ void DispatchMessageL(const RMessage2& aMessage);
+
+
+private:
+
+ CStubSrvSess(CStubSrv& aServer);
+
+ void ConstructL();
+
+private:
+ CStubSrv& iServer;
+
+ CApiExecutor* iExecutor;
+ };
+
+#endif // SESSION_H
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/testtools/stubsrv/rom/stubsrv.iby Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef STUBSRV_IBY
+#define STUBSRV_IBY
+
+file=ABI_DIR\BUILD_DIR\apibehavior.dll SHARED_LIB_DIR\apibehavior.dll
+file=ABI_DIR\BUILD_DIR\stubber.dll SHARED_LIB_DIR\stubber.dll
+file=ABI_DIR\BUILD_DIR\stubsrv.exe PROGRAMS_DIR\stubsrv.exe
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/testtools/stubsrv/src/apibehavior.cpp Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include "apibehavior.h"
+
+EXPORT_C TApiBehavior::TApiBehavior()
+ : iLib(0), iApi(0), iCompleteCode(0), iAsyncCompleteCode(0), iOutput(KNullDesC8)
+ {
+ }
+
+EXPORT_C TApiBehavior::TApiBehavior(TUint aLib, TUint aApi)
+ : iLib(aLib), iApi(aApi), iCompleteCode(0), iAsyncCompleteCode(0), iOutput(KNullDesC8)
+ {
+ }
+
+EXPORT_C TApiBehavior::TApiBehavior(TUint aLib, TUint aApi,
+ TInt aCompleteCode, TInt aAsyncCompleteCode, const TDesC8& aOutput)
+ : iLib(aLib), iApi(aApi), iCompleteCode(aCompleteCode),
+ iAsyncCompleteCode(aAsyncCompleteCode), iOutput(aOutput)
+ {
+ }
+
+EXPORT_C TBool TApiBehavior::MatchId(TUint aLib, TUint aApi) const
+ {
+ return iLib == aLib && iApi == aApi;
+ }
+
+EXPORT_C TBool TApiBehavior::MatchId(const TApiBehavior& aBeh) const
+ {
+ return MatchId(aBeh.iLib, aBeh.iApi);
+ }
+
+EXPORT_C TBool TApiBehavior::operator==(const TApiBehavior& aBeh) const
+ {
+ return
+ (iLib == aBeh.iLib &&
+ iApi == aBeh.iApi &&
+ iCompleteCode == aBeh.iCompleteCode &&
+ iAsyncCompleteCode == aBeh.iAsyncCompleteCode &&
+ iOutput == aBeh.iOutput);
+ }
+
+EXPORT_C TBool TApiBehavior::operator!=(const TApiBehavior& aBeh) const
+ {
+ return !(*this == aBeh);
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/testtools/stubsrv/src/stubber.cpp Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,102 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include "stubber.h"
+#include "stubclient.h"
+
+
+EXPORT_C CStubber* CStubber::NewL()
+ {
+ CStubber* self = new (ELeave) CStubber();
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+EXPORT_C CStubber::~CStubber()
+ {
+ Cancel();
+ if (iClient)
+ iClient->Close();
+ delete iClient;
+ }
+
+EXPORT_C void CStubber::EnqueBehavior(const TApiBehavior& aBeh, TInt aExeDuration)
+ {
+ iClient->EnqueBehavior(aBeh, aExeDuration);
+ }
+
+EXPORT_C void CStubber::DeleteBehaviors(TUint aLib, TUint aApi)
+ {
+ iClient->DeleteBehaviors(aLib, aApi);
+ }
+
+EXPORT_C void CStubber::InvokeApi(TApiBehavior& aBeh, TApiInvokeMode aMode)
+ {
+ aBeh = TApiBehavior(aBeh.iLib, aBeh.iApi);
+ TApiBehaviorPckg pckg(aBeh);
+ iClient->InvokeApi(pckg, aMode);
+ }
+
+EXPORT_C void CStubber::InvokeApiL(MApiInvoker& aInvoker, TUint aLib, TUint aApi, TApiInvokeMode aMode)
+ {
+ if (IsActive())
+ {
+ User::Panic(_L("Stubber"), KErrInUse);
+ }
+ iInvoker = &aInvoker;
+ iBeh = TApiBehavior(aLib, aApi);
+ iClient->InvokeApiL(iBehPckg, iStatus, aMode);
+ SetActive();
+ }
+
+EXPORT_C void CStubber::InvokeApiCancel()
+ {
+ Cancel();
+ }
+
+void CStubber::RunL()
+ {
+ if (iStatus != KErrNone)
+ {
+ iBeh.iAsyncCompleteCode = iStatus.Int();
+ }
+ iInvoker->InvokeApiComplete(iBeh);
+ }
+
+void CStubber::DoCancel()
+ {
+ iClient->InvokeApiCancel(iBeh.iLib, iBeh.iApi);
+ }
+
+TInt CStubber::RunError(TInt /*aReason*/)
+ {
+ return KErrNone;
+ }
+
+CStubber::CStubber() :
+ CActive(EPriorityStandard), iBehPckg(iBeh)
+ {
+ CActiveScheduler::Add(this);
+ }
+
+void CStubber::ConstructL()
+ {
+ iClient = new (ELeave) RStubClient();
+ User::LeaveIfError(iClient->Connect());
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/testtools/stubsrv/src/stubclient.cpp Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,102 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include <e32cmn.h>
+#include "stubclient.h"
+#include "stubclientsrv.h"
+
+_LIT(KStubSrvExe, "stubsrv.exe");
+static TInt ClientStart()
+ {
+ RProcess server;
+ TInt r = server.Create(KStubSrvExe, KNullDesC, TUidType(KNullUid, KNullUid, KStubSrvUid3));
+ if (r!=KErrNone)
+ return r;
+ TRequestStatus stat;
+ server.Rendezvous(stat);
+ if (stat != KRequestPending)
+ server.Kill(0);
+ else
+ server.Resume();
+ User::WaitForRequest(stat);
+ r = (server.ExitType() == EExitPanic) ? KErrGeneral : stat.Int();
+ server.Close();
+ return r;
+ }
+
+void RStubClient::EnqueBehavior(const TApiBehavior& aBeh, TInt aExeDuration)
+ {
+ CheckSession();
+ TApiBehaviorPckgBuf buf(aBeh);
+ (void) SendReceive(EStubSrvEnqueApiBehavior, TIpcArgs(&buf, aExeDuration));
+ }
+
+void RStubClient::DeleteBehaviors(TUint aLib, TUint aApi)
+ {
+ CheckSession();
+ (void) SendReceive(EStubSrvDeleteApiBehaviors, TIpcArgs(aLib, aApi));
+ }
+
+void RStubClient::InvokeApi(TApiBehaviorPckg& aBehPckg, TApiInvokeMode aMode)
+ {
+ CheckSession();
+ (void) SendReceive(EStubSrvInvokeApi, TIpcArgs(&aBehPckg, aMode, 0));
+ }
+
+void RStubClient::InvokeApiL(TApiBehaviorPckg& aBehPckg, TRequestStatus& aStatus, TApiInvokeMode aMode)
+ {
+ CheckSession();
+ TInt transctionId = 0;
+ TPckg<TInt> transpckg(transctionId);
+ TInt err = SendReceive(EStubSrvGetApiCompletionCode, TIpcArgs(aBehPckg().iLib, aBehPckg().iApi, &transpckg));
+ if (err)
+ {
+ User::Leave(err);
+ }
+ SendReceive(EStubSrvInvokeApi, TIpcArgs(&aBehPckg, aMode, transctionId), aStatus);
+ }
+
+void RStubClient::InvokeApiCancel(TUint aLib, TUint aApi)
+ {
+ CheckSession();
+ (void) SendReceive(EStubSrvInvokeApiCancel, TIpcArgs(aLib, aApi));
+ }
+
+TInt RStubClient::Connect()
+ {
+ TInt retVal = CreateSession(KStubSrvName, Version());
+ if (retVal)
+ {
+ retVal = ClientStart();
+ if (!retVal)
+ retVal = CreateSession(KStubSrvName, Version());
+ }
+ return retVal;
+ }
+
+TVersion RStubClient::Version() const
+ {
+ return(TVersion(KStubSrvMajorVersionNumber, KStubSrvMinorVersionNumber, KStubSrvBuildNumber));
+ }
+
+_LIT(KPanicCat, "!Stubsrv");
+
+void RStubClient::CheckSession()
+ {
+ if (!Handle())
+ User::Panic(KPanicCat, KErrBadHandle);
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/testtools/stubsrv/src/stubsrv.cpp Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,201 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include "stubsrv.h"
+#include "stubsrvsession.h"
+#include "stubsrvapiexecutor.h"
+#include "apibehavior.h"
+#include "stubsrvsecuritypolicy.h"
+
+CStubSrv::CStubSrv(TInt aPriority)
+ :CPolicyServer(aPriority, KStubSrvPolicy)
+ {
+ }
+
+CStubSrv* CStubSrv::NewLC()
+ {
+ CStubSrv* self = new (ELeave) CStubSrv(EPriorityNormal);
+ CleanupStack::PushL(self);
+ self->StartL(KStubSrvName);
+ self->ConstructL();
+ return self;
+ }
+
+CStubSrv::~CStubSrv()
+ {
+ iBehQueue.ResetAndDestroy();
+ iBehQueue.Close();
+ iSessions.Close();
+ delete iTimer;
+ }
+
+const TInt KShutdownDelay = 1000000;
+
+void CStubSrv::StartShutdownTimerIfNoSessions()
+ {
+ if (iSessions.Count() == 0 && !iTimer->IsActive())
+ {
+ iTimer->Start(KShutdownDelay, 0, TCallBack(CStubSrv::TimerFired, this));
+ }
+ }
+
+TInt CStubSrv::ClientOpened(CStubSrvSess& aSession)
+ {
+ return iSessions.Append(&aSession);
+ }
+
+void CStubSrv::ClientClosed(CStubSrvSess& aSession)
+ {
+ const TUint sessCount = iSessions.Count();
+ for ( TUint ii = 0 ; ii < sessCount ; ++ii )
+ {
+ if ( iSessions[ii] == &aSession )
+ {
+ iSessions.Remove(ii);
+ break;
+ }
+ }
+ StartShutdownTimerIfNoSessions();
+ }
+
+void CStubSrv::EnqueueL(const RMessage2& aMessage)
+ {
+ TApiBehaviorPckgBuf buf;
+ aMessage.ReadL(0, buf);
+ TInt duration = aMessage.Int1();
+
+ TInt sesss = iSessions.Count();
+ for (TInt i = 0; i < sesss; i++)
+ {
+ TInt err = iSessions[i]->ConsumeApiBehavior(buf(), duration);
+ if (err == KErrNone)
+ {
+ return;
+ }
+ }
+ TApiQueueItem* item = new (ELeave) TApiQueueItem();
+ item->iBeh = buf();
+ item->iExeDuration = duration;
+ item->iTransactionId = 0;
+ CleanupStack::PushL(item);
+ iBehQueue.AppendL(item);
+ CleanupStack::Pop(item);
+ }
+
+void CStubSrv::DeleteQueues(const RMessage2& aMessage)
+ {
+ TUint lib = aMessage.Int0();
+ TUint api = aMessage.Int1();
+ TInt count = iBehQueue.Count();
+ for (TInt i = count - 1; i >= 0; i--)
+ {
+ if (iBehQueue[i]->iBeh.MatchId(lib, api))
+ {
+ delete iBehQueue[i];
+ iBehQueue.Remove(i);
+ }
+ }
+ }
+
+TInt CStubSrv::Dequeue(TApiBehavior& aBeh, TInt& aExeDuration, TInt aTransactionId)
+ {
+ TInt count = iBehQueue.Count();
+ for (TInt i = 0; i < count; i++)
+ {
+ if (iBehQueue[i]->iBeh.MatchId(aBeh.iLib, aBeh.iApi) &&
+ aTransactionId == iBehQueue[i]->iTransactionId)
+ {
+ aBeh = iBehQueue[i]->iBeh;
+ aExeDuration = iBehQueue[i]->iExeDuration;
+ delete iBehQueue[i];
+ iBehQueue.Remove(i);
+ return KErrNone;
+ }
+ }
+ return KErrNotFound;
+ }
+
+void CStubSrv::GetApiCompleteCodeL(const RMessage2& aMessage)
+ {
+ TUint lib = aMessage.Int0();
+ TUint api = aMessage.Int1();
+ TInt count = iBehQueue.Count();
+ for (TInt i = 0; i < count; i++)
+ {
+ if (iBehQueue[i]->iBeh.MatchId(lib, api))
+ {
+ iBehQueue[i]->iTransactionId = iTransctionUnique++;
+ TPckgBuf<TInt> buf(iBehQueue[i]->iTransactionId);
+ aMessage.WriteL(2, buf);
+ aMessage.Complete(iBehQueue[i]->iBeh.iCompleteCode);
+ return;
+ }
+ }
+ aMessage.Complete(0);
+ }
+
+void CStubSrv::ConstructL()
+ {
+ iTimer = CPeriodic::NewL(CActive::EPriorityStandard);
+ }
+
+CSession2* CStubSrv::NewSessionL(const TVersion& aVersion, const RMessage2& /*aMessage*/) const
+ {
+ TVersion v(KStubSrvMajorVersionNumber, KStubSrvMinorVersionNumber, KStubSrvBuildNumber);
+ if ( !User::QueryVersionSupported(v, aVersion) )
+ User::Leave(KErrNotSupported);
+ CStubSrvSess* session = CStubSrvSess::NewL(const_cast<CStubSrv&>(*this));
+ const_cast<CStubSrv*>(this)->CancelShutdownTimer();
+ return session;
+ }
+
+void CStubSrv::CancelShutdownTimer()
+ {
+ iTimer->Cancel();
+ }
+
+TInt CStubSrv::TimerFired(TAny* /*aThis*/)
+ {
+ CActiveScheduler::Stop();
+ return KErrNone;
+ }
+
+static void RunServerL()
+ {
+ static_cast<void>(User::LeaveIfError(User::RenameThread(KStubSrvName)));
+ CActiveScheduler* scheduler = new(ELeave) CActiveScheduler;
+ CleanupStack::PushL(scheduler);
+ CActiveScheduler::Install(scheduler);
+ CStubSrv::NewLC();
+ RProcess::Rendezvous(KErrNone);
+ CActiveScheduler::Start();
+ CleanupStack::PopAndDestroy(2, scheduler);
+ }
+
+GLDEF_C TInt E32Main()
+ {
+ TInt ret = KErrNoMemory;
+ __UHEAP_MARK;
+ CTrapCleanup* cleanup = CTrapCleanup::New();
+ if (cleanup)
+ {
+ TRAP(ret, RunServerL());
+ delete cleanup;
+ }
+ __UHEAP_MARKEND;
+ return ret;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/testtools/stubsrv/src/stubsrvapiexecutor.cpp Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,138 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+// INCLUDE FILES
+
+#include "stubsrvapiexecutor.h"
+#include "stubsrvsession.h"
+
+CApiExecutor* CApiExecutor::NewL()
+ {
+ CApiExecutor* self = new (ELeave) CApiExecutor();
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+CApiExecutor::~CApiExecutor()
+ {
+ Cancel();
+ iTimer.Close();
+ if (iMessage.Handle())
+ {
+ iMessage.Complete(KErrCancel);
+ }
+ }
+
+const TApiBehavior& CApiExecutor::ApiBehavior() const
+ {
+ return iBeh;
+ }
+
+TApiInvokeMode CApiExecutor::Mode() const
+ {
+ return iMode;
+ }
+
+void CApiExecutor::ExecuteL(const RMessage2& aMessage, CStubSrvSess& aSession, TUint aLib, TUint aApi)
+ {
+ iMessage = aMessage;
+ iSess = &aSession;
+ iBeh = TApiBehavior(aLib, aApi);
+ iMode = (TApiInvokeMode) iMessage.Int1();
+ if (iMode == ECompleteIfNoBehaviorSet)
+ {
+ TRequestStatus* status = &iStatus;
+ User::RequestComplete(status, KErrNone);
+ SetActive();
+ }
+ }
+
+void CApiExecutor::ExecuteL(const RMessage2& aMessage, CStubSrvSess& aSession, const TApiBehavior& aBeh, TInt aExeDuration)
+ {
+ iMessage = aMessage;
+ iSess = &aSession;
+ iMode = ECompleteIfNoBehaviorSet;
+ iBeh = aBeh;
+ iTimeout = aExeDuration;
+ if (iTimeout == 0)
+ {
+ TRequestStatus* status = &iStatus;
+ User::RequestComplete(status, KErrNone);
+ SetActive();
+ }
+ else if (iTimeout > 0)
+ {
+ iTimer.After(iStatus, iTimeout);
+ SetActive();
+ }
+ }
+
+void CApiExecutor::Resume(const TApiBehavior& aBeh, TInt aExeDuration)
+ {
+ iBeh = aBeh;
+ iTimeout = aExeDuration;
+ iMode = ECompleteIfNoBehaviorSet;
+ if (iTimeout == 0)
+ {
+ TRequestStatus* status = &iStatus;
+ User::RequestComplete(status, KErrNone);
+ SetActive();
+ }
+ else if (iTimeout > 0)
+ {
+ iTimer.After(iStatus, iTimeout);
+ SetActive();
+ }
+ }
+
+void CApiExecutor::RunL()
+ {
+ TInt err = KErrNone;
+ TApiBehaviorPckgBuf pckg(iBeh);
+ err = iMessage.Write(0, pckg);
+ iMessage.Complete(err);
+ iSess->InvokeApiComplete();
+ }
+
+TInt CApiExecutor::RunError(TInt /*aReason*/)
+ {
+ return KErrNone;
+ }
+
+void CApiExecutor::DoCancel()
+ {
+ iTimer.Cancel();
+ if (iMessage.Handle())
+ {
+ iMessage.Complete(KErrCancel);
+ }
+ }
+
+CApiExecutor::CApiExecutor()
+ : CActive(CActive::EPriorityStandard)
+ {
+ CActiveScheduler::Add(this);
+ }
+
+void CApiExecutor::ConstructL()
+ {
+ iTimer.CreateLocal();
+ }
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/testtools/stubsrv/src/stubsrvsession.cpp Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,135 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+// INCLUDE FILES
+#include "stubsrvsession.h"
+#include "stubsrv.h"
+#include "stubsrvapiexecutor.h"
+#include "stubclientsrv.h"
+
+CStubSrvSess* CStubSrvSess::NewL(CStubSrv& aServer)
+ {
+ CStubSrvSess* self = new (ELeave) CStubSrvSess (aServer);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+CStubSrvSess::~CStubSrvSess()
+ {
+ delete iExecutor;
+ iServer.ClientClosed(*this);
+ }
+
+void CStubSrvSess::InvokeApiComplete()
+ {
+ delete iExecutor;
+ iExecutor = NULL;
+ }
+
+TInt CStubSrvSess::ConsumeApiBehavior(const TApiBehavior& aBeh, TInt aExeDuration)
+ {
+ if (iExecutor && iExecutor->Mode() == ESuspendIfNoBehaviorSet &&
+ iExecutor->ApiBehavior().MatchId(aBeh))
+ {
+ iExecutor->Resume(aBeh, aExeDuration);
+ return KErrNone;
+ }
+ return KErrNotFound;
+ }
+
+void CStubSrvSess::ServiceL(const RMessage2& aMessage)
+ {
+ TRAPD(err, DispatchMessageL( aMessage ));
+ if (err != KErrNone)
+ {
+ aMessage.Panic(KStubSrvName, err);
+ }
+ }
+
+void CStubSrvSess::DispatchMessageL(const RMessage2& aMessage)
+ {
+ switch (aMessage.Function())
+ {
+ case EStubSrvEnqueApiBehavior:
+ {
+ iServer.EnqueueL(aMessage);
+ aMessage.Complete(KErrNone);
+ break;
+ }
+ case EStubSrvDeleteApiBehaviors:
+ {
+ iServer.DeleteQueues(aMessage);
+ aMessage.Complete(KErrNone);
+ break;
+ }
+ case EStubSrvInvokeApi:
+ {
+ if (iExecutor)
+ {
+ aMessage.Panic(KStubSrvName, EStubfApiAlreadyStarted);
+ break;
+ }
+ TApiBehavior beh;
+ TApiBehaviorPckg pckg(beh);
+ aMessage.ReadL(0, pckg);
+ TInt transactionId = aMessage.Int2();
+ TInt dur = 0;
+ TInt err = iServer.Dequeue(beh, dur, transactionId);
+ iExecutor = CApiExecutor::NewL();
+ if (err)
+ {
+ iExecutor->ExecuteL(aMessage, *this, beh.iLib, beh.iApi);
+ }
+ else
+ {
+ iExecutor->ExecuteL(aMessage, *this, beh, dur);
+ }
+ break;
+ }
+ case EStubSrvInvokeApiCancel:
+ {
+ delete iExecutor;
+ iExecutor = NULL;
+ aMessage.Complete(KErrNone);
+ break;
+ }
+ case EStubSrvGetApiCompletionCode:
+ {
+ iServer.GetApiCompleteCodeL(aMessage);
+ break;
+ }
+ default:
+ {
+ aMessage.Panic(KStubSrvName, EStubfBadRequest);
+ break;
+ }
+ }
+ }
+
+CStubSrvSess::CStubSrvSess(CStubSrv& aServer) : iServer(aServer)
+ {
+ }
+
+void CStubSrvSess::ConstructL()
+ {
+ iServer.ClientOpened(*this);
+ }
+
+
+// End of File
--- a/usbengines/usbotgwatcher/inc/cusbindicatornotifier.h Tue Jul 13 00:13:42 2010 +0300
+++ b/usbengines/usbotgwatcher/inc/cusbindicatornotifier.h Tue Jul 13 00:24:10 2010 +0300
@@ -40,8 +40,11 @@
* Class implements functionality of showing/blinking usb indicator
* Class does not provide method to get response from the user
*/
-NONSHARABLE_CLASS( CUsbIndicatorNotifier ): public CUsbNotifier, MUsbOtgWatcherStateObserver, MUsbVBusObserver
+NONSHARABLE_CLASS( CUsbIndicatorNotifier ): public MUsbOtgWatcherStateObserver, MUsbVBusObserver
{
+
+ friend class CtUsbOtgWatcher;
+
public:
/**
* Two-phased constructor.
@@ -78,12 +81,6 @@
*/
virtual void VBusObserverErrorL(TInt aError);
- // From base class CUsbNotifier
- /**
- * Start to show notifier
- */
- virtual void ShowL();
-
/**
* Stop showing notifier
*/
@@ -104,23 +101,10 @@
void ConstructL();
/**
- * Set USB indicator On or Off
+ * Set USB Connecting indicator On or Off
* @param aState Indicator states
*/
- void SetIndicatorState(const TInt aState);
-
- /**
- * Show/hide static icon of the indicator.
- * If the indicator is blinking, stop blinking it and show/hide the static
- * form of the indicator.
- * @param aVisible ETrue - Show the indicator, EFalse - Hide the indicator
- */
- void ShowStatic(TBool aVisible);
-
- /**
- * Blinks indicator
- */
- void Blink();
+ void ToggleConnectingIndicator(TBool aEnable);
/**
* Sets indicator accordingly
--- a/usbengines/usbotgwatcher/src/cusbindicatornotifier.cpp Tue Jul 13 00:13:42 2010 +0300
+++ b/usbengines/usbotgwatcher/src/cusbindicatornotifier.cpp Tue Jul 13 00:24:10 2010 +0300
@@ -71,8 +71,7 @@
//
CUsbIndicatorNotifier::CUsbIndicatorNotifier(CUsbNotifManager& aNotifManager,
CUsbOtgWatcher& aOtgWatcher) :
- CUsbNotifier(aNotifManager, KUsbUiNotifOtgIndicator, NULL), iOtgWatcher(
- aOtgWatcher)
+ iOtgWatcher(aOtgWatcher)
{
LOG_FUNC
@@ -94,48 +93,13 @@
// Subscribe for otg watcher states change notifications
iOtgWatcher.SubscribeL(*this);
+ iConnectingIndicatorOn = EFalse;
+
// check here for condition to set usb indicator
SetIndicator();
- }
-
-// ---------------------------------------------------------------------------
-// Show/hide static icon of the indicator.
-// If the indicator is blinking, stop blinking it and show/hide the static
-// form of the indicator.
-// ---------------------------------------------------------------------------
-//
-void CUsbIndicatorNotifier::ShowStatic(TBool aVisible)
- {
- LOG_FUNC
-
- LOG1("aVisible = %d" , aVisible);
-
- SetIndicatorState(aVisible
- ? EIndicatorStateOn
- : EIndicatorStateOff);
+
}
-// ---------------------------------------------------------------------------
-//
-// ---------------------------------------------------------------------------
-//
-void CUsbIndicatorNotifier::Blink()
- {
- LOG_FUNC
-
- SetIndicatorState( EIndicatorConnecting );
- }
-
-// ---------------------------------------------------------------------------
-// From base class CUsbNotifier
-// ---------------------------------------------------------------------------
-//
-void CUsbIndicatorNotifier::ShowL()
- {
- LOG_FUNC
-
- ShowStatic(ETrue);
- }
// ---------------------------------------------------------------------------
// From CUsbNotifier
@@ -145,20 +109,20 @@
{
LOG_FUNC
- ShowStatic(EFalse);
+ ToggleConnectingIndicator( EFalse );
}
// ---------------------------------------------------------------------------
// Set USB indicator On or Off
// ---------------------------------------------------------------------------
//
-void CUsbIndicatorNotifier::SetIndicatorState(const TInt aState)
+void CUsbIndicatorNotifier::ToggleConnectingIndicator(TBool aEnable)
{
- LOG1( "USB indicator State = %d" , aState);
+ LOG1( "toggle connecting indicator = %d" , aEnable);
TBool success = ETrue;
- if ((aState == EIndicatorConnecting) && !iConnectingIndicatorOn)
+ if (aEnable && !iConnectingIndicatorOn)
{
success = iUsbConnectingIndicator->Activate(KUsbConnectingIndicator);
LOG1( "calling CHbIndicatorSymbian::Activate(), returned %d", success);
@@ -169,7 +133,7 @@
}
- if ((aState != EIndicatorConnecting) && iConnectingIndicatorOn)
+ if (!aEnable && iConnectingIndicatorOn)
{
success = iUsbConnectingIndicator->Deactivate(KUsbConnectingIndicator);
if (success)
@@ -193,6 +157,7 @@
//
void CUsbIndicatorNotifier::OtgWatcherStateChangedL(TUsbStateIds aState)
{
+ LOG_FUNC
SetIndicator();
}
@@ -202,6 +167,7 @@
//
void CUsbIndicatorNotifier::VBusDownL()
{
+ LOG_FUNC
SetIndicator();
}
@@ -211,6 +177,7 @@
//
void CUsbIndicatorNotifier::VBusUpL()
{
+ LOG_FUNC
SetIndicator();
}
@@ -220,6 +187,7 @@
//
void CUsbIndicatorNotifier::VBusObserverErrorL(TInt aError)
{
+ LOG_FUNC
// do nothing
}
@@ -229,6 +197,7 @@
//
void CUsbIndicatorNotifier::SetIndicator()
{
+ LOG_FUNC
if (!(iOtgWatcher.IsDeviceA()) || iOtgWatcher.CurrentHostState()->Id() == EUsbStateHostAPeripheral)
{
// if B or peripheral, than other party (usbwatcher) takes care of usb indicator
@@ -236,22 +205,16 @@
return;
}
- // if VBus Up and we are host -> show indicator
+ // if VBus up and we are not host -> show connecting indicator
if ((iOtgWatcher.VBusObserver()->VBus() == CUsbVBusObserver::EVBusUp)
- && (iOtgWatcher.CurrentHostState()->Id() == EUsbStateHostAHost))
- {
- ShowStatic(ETrue);
- }
- // if VBus up and we are not host -> Blink indicator
- else if ((iOtgWatcher.VBusObserver()->VBus() == CUsbVBusObserver::EVBusUp)
&& (iOtgWatcher.CurrentHostState()->Id() != EUsbStateHostAHost))
{
- Blink();
+ ToggleConnectingIndicator( ETrue );
}
else
// Otherwise do not show indicator
{
- ShowStatic(EFalse);
+ ToggleConnectingIndicator( EFalse );
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/Bmarm/UsbOtgWatcherTestu.def Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,3 @@
+EXPORTS
+ LibEntryL__FR13CTestModuleIf @ 1 NONAME R3UNUSED ; LibEntryL(CTestModuleIf &)
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/Bwins/UsbOtgWatcherTestu.def Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,3 @@
+EXPORTS
+ ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * __cdecl LibEntryL(class CTestModuleIf &)
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/conf/UsbOtgWatcherTest.cfg Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,118 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+[StifSettings]
+CapsModifier= UsbOtgWatcherTest.exe
+[EndStifSettings]
+
+// UsbOtgWatcherTest Module - total 10 tc
+
+// UsbOtgWatcherTest Api Tests (1 tc)
+
+[Test]
+title SetupTearDown
+create UsbOtgWatcherTest tester
+tester SetupTearDown API
+delete tester
+[Endtest]
+
+
+// Add new api tests here
+// ...
+
+
+// UsbOtgWatcherTest Module Tests (9 tc)
+
+// Add new module tests here
+// ...
+
+[Test]
+title PinOnTest_Success
+create UsbOtgWatcherTest tester
+tester PinOnTest_Success MODULE
+delete tester
+[Endtest]
+
+
+[Test]
+title PinOffTest_Success
+create UsbOtgWatcherTest tester
+tester PinOffTest_Success MODULE
+delete tester
+[Endtest]
+
+[Test]
+title PinOnTest_EmptyCable
+create UsbOtgWatcherTest tester
+tester PinOnTest_EmptyCable MODULE
+delete tester
+[Endtest]
+
+[Test]
+title PinOnTest_TryStartError
+create UsbOtgWatcherTest tester
+tester PinOnTest_TryStartError MODULE
+delete tester
+[Endtest]
+
+[Test]
+title PinOnTest_BusRequestError
+create UsbOtgWatcherTest tester
+tester PinOnTest_BusRequestError MODULE
+delete tester
+[Endtest]
+
+[Test]
+title DeviceAttached_BadHubPostion
+create UsbOtgWatcherTest tester
+tester DeviceAttached_BadHubPostion MODULE
+delete tester
+[Endtest]
+
+[Test]
+title DeviceAttached_TooMuchRequired
+create UsbOtgWatcherTest tester
+tester DeviceAttached_TooMuchRequired MODULE
+delete tester
+[Endtest]
+
+[Test]
+title DeviceAttached_SupportedDevice
+create UsbOtgWatcherTest tester
+tester DeviceAttached_SupportedDevice MODULE
+delete tester
+[Endtest]
+
+[Test]
+title DeviceDetached_SupportedDevice
+create UsbOtgWatcherTest tester
+tester DeviceDetached_SupportedDevice MODULE
+delete tester
+[Endtest]
+
+[Test]
+title IndicatorNotifier_IndicatorActivateL
+create UsbOtgWatcherTest tester
+tester IndicatorNotifier_IndicatorActivateL MODULE
+delete tester
+[Endtest]
+
+
+// UsbOtgWatcherTest Branch Tests (... tc)
+
+// Add new branch tests here
+// ...
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/eabi/UsbOtgWatcherTestu.def Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,23 @@
+EXPORTS
+ _Z9LibEntryLR13CTestModuleIf @ 1 NONAME
+ _ZN14CUsbOtgWatcher4NewLER4RUsb @ 2 NONAME
+ _ZN14CUsbOtgWatcher9IsDeviceAEv @ 3 NONAME
+ _ZTI14CUsbOtgWatcher @ 4 NONAME
+ _ZTI16CUsbNotifManager @ 5 NONAME
+ _ZTIN16CUsbNoteNotifier15CNotifierActiveE @ 6 NONAME
+ _ZTV14CUsbOtgWatcher @ 7 NONAME
+ _ZTV16CUsbNotifManager @ 8 NONAME
+ _ZTVN16CUsbNoteNotifier15CNotifierActiveE @ 9 NONAME
+ _ZTI16CUsbVBusObserver @ 10 NONAME
+ _ZTI17CUsbIdPinObserver @ 11 NONAME
+ _ZTI20CUsbOtgStateObserver @ 12 NONAME
+ _ZTI23CUsbBusActivityObserver @ 13 NONAME
+ _ZTI31CUsbMessageNotificationObserver @ 14 NONAME
+ _ZTI33CUsbHostEventNotificationObserver @ 15 NONAME
+ _ZTV16CUsbVBusObserver @ 16 NONAME
+ _ZTV17CUsbIdPinObserver @ 17 NONAME
+ _ZTV20CUsbOtgStateObserver @ 18 NONAME
+ _ZTV23CUsbBusActivityObserver @ 19 NONAME
+ _ZTV31CUsbMessageNotificationObserver @ 20 NONAME
+ _ZTV33CUsbHostEventNotificationObserver @ 21 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/group/UsbOtgWatcherTest.mmp Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,104 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#if defined(__S60_)
+ // To get the MW_LAYER_SYSTEMINCLUDE-definition
+ #include <platform_paths.hrh>
+#endif
+
+TARGET UsbOtgWatcherTest.dll
+TARGETTYPE dll
+UID 0x1000008D 0x101FB3E3
+
+CAPABILITY ALL -TCB
+//CAPABILITY LocalServices ReadDeviceData NetworkControl WriteDeviceData DiskAdmin ReadUserData WriteUserData ProtServ CommDD
+//CAPABILITY CommDD NetworkControl WriteDeviceData NetworkServices LocalServices ProtServ
+VENDORID VID_DEFAULT
+
+DEFFILE UsbOtgWatcherTest.def
+
+MW_LAYER_SYSTEMINCLUDE
+MACRO STIF_STUB
+MACRO STIF
+
+//includes for stubbing
+SYSTEMINCLUDE /epoc32/include/mw/stubsrv/
+SYSTEMINCLUDE /epoc32/include/mw/taf/
+
+USERINCLUDE ../inc
+SOURCEPATH ../src
+
+SOURCE UsbOtgWatcherTest.cpp
+SOURCE UsbOtgWatcherTestBlocks.cpp
+
+// Mock classes (used for emulation of real ones)
+SOURCE mockcusbidpinobserver.cpp
+SOURCE mockcusbvbusobserver.cpp
+SOURCE mockcusbotgstateobserver.cpp
+SOURCE mockcusbhosteventnotificationobserver.cpp
+SOURCE mockcusbmessagenotificationobserver.cpp
+SOURCE mockcusbbusactivityobserver.cpp
+SOURCE mockrusb.cpp
+SOURCE mockcusbtimer.cpp
+SOURCE mockcusbnotifmanager.cpp
+SOURCE mockchbindicatorsymbian.cpp
+
+// real classes to be tested
+SOURCEPATH ../../../src
+USERINCLUDE ../../../inc
+
+SOURCE cusbotgwatcher.cpp
+SOURCE cusbstate.cpp
+SOURCE cusbstatehostabase.cpp
+SOURCE cusbstatehostainitiate.cpp
+SOURCE cusbstatehostahost.cpp
+SOURCE cusbstatehostaperipheral.cpp
+SOURCE cusbstatehosthandle.cpp
+SOURCE cusbservicecontrol.cpp
+SOURCE cusbnotifier.cpp
+SOURCE cusbwarningnotifier.cpp
+SOURCE CUsbNoteNotifier.cpp
+SOURCE CUsbStateHostHandleDropping.cpp
+SOURCE CUsbStateHostDelayNotAttachedHandle.cpp
+SOURCE CUsbStateHostDelayAttachedHandle.cpp
+SOURCE CUsbStateHostUndefined.cpp
+SOURCE cusbstatehostdelayhandle.cpp
+SOURCE cusbindicatornotifier.cpp
+
+
+
+
+//standart lib for stif testing
+LIBRARY euser.lib
+LIBRARY stiftestinterface.lib
+LIBRARY stiftestengine.lib
+
+//lib for stubbing
+LIBRARY apibehavior.lib
+LIBRARY stubber.lib
+
+//lib for component testing
+LIBRARY usbdescriptors.lib
+LIBRARY usbdi_utils.lib
+LIBRARY aknnotify.lib
+
+LANG SC
+
+
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/group/UsbOtgWatcherTest_ats.pkg Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,69 @@
+;
+; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: Installation file for STIF
+;
+
+
+;
+; Installation file for STIF
+;
+
+; Languages
+&EN
+
+; Provide value for uid
+#{"UsbOtgWatcherTest"},(0x00000000),1,1,0,TYPE=SA
+
+; Series60 product id for S60 5.2
+[0x20022E6D], 0, 0, 0, {"Series60ProductID"}
+
+; Localised Vendor name
+%{"Nokia"}
+
+; Unique Vendor name;
+:"Nokia"
+
+
+; Logo
+; None
+
+; Package signature - Optional
+; None
+
+; Start of Package body
+
+; Condition blocks
+; None
+
+; Options list
+; None
+
+; Install files
+"/epoc32/release/armv5/udeb/UsbOtgWatcherTest.dll"-"C:/Sys/Bin/UsbOtgWatcherTest.dll"
+"/epoc32/release/armv5/udeb/UsbOtgWatcherTest.exe"-"C:/Sys/Bin/UsbOtgWatcherTest.exe"
+
+"../conf/UsbOtgWatcherTest.cfg"-"E:/testing/conf/UsbOtgWatcherTest.cfg"
+"../init/UsbOtgWatcherTest.ini"-"E:/testing/init/UsbOtgWatcherTest_ats.ini"
+
+; Embedded SIS
+; None
+
+; End of Package body
+
+; PKG dependencies
+; None
+
+; PKG capabilities
+; None
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/group/UsbOtgWatcherTest_exe.mmp Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#if defined(__S60_)
+ #include <platform_paths.hrh>
+#endif
+
+TARGET UsbOtgWatcherTest.exe
+TARGETTYPE exe
+UID 0 0xEF4892C6
+
+CAPABILITY CommDD NetworkControl WriteDeviceData NetworkServices LocalServices ProtServ
+VENDORID VID_DEFAULT
+
+MW_LAYER_SYSTEMINCLUDE
+
+SOURCEPATH ../src
+
+SOURCE UsbOtgWatcherTest_exe.cpp
+
+LIBRARY euser.lib
+LIBRARY stiftestinterface.lib
+
+EPOCSTACKSIZE 40960
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/group/UsbOtgWatcherTest_phone.pkg Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,64 @@
+
+; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: Installation file for STIF
+;
+
+; Languages
+&EN
+
+; Provide value for uid
+#{"UsbOtgWatcherTest"},(0x00000000),1,1,0,TYPE=SA
+
+; Series60 product id for S60 5.2
+[0x20022E6D], 0, 0, 0, {"Series60ProductID"}
+
+; Localised Vendor name
+%{"Nokia"}
+
+; Unique Vendor name;
+:"Nokia"
+
+
+; Logo
+; None
+
+; Package signature - Optional
+; None
+
+; Start of Package body
+
+; Condition blocks
+; None
+
+; Options list
+; None
+
+; Install files
+"/epoc32/release/armv5/udeb/UsbOtgWatcherTest.dll"-"C:/Sys/Bin/UsbOtgWatcherTest.dll"
+"/epoc32/release/armv5/udeb/UsbOtgWatcherTest.exe"-"C:/Sys/Bin/UsbOtgWatcherTest.exe"
+
+"../conf/UsbOtgWatcherTest.cfg"-"C:/testframework/UsbOtgWatcherTest.cfg"
+"../init/UsbOtgWatcherTest_phone.ini"-"C:/testframework/testframework.ini"
+
+; Embedded SIS
+; None
+
+; End of Package body
+
+; PKG dependencies
+; None
+
+; PKG capabilities
+; None
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/group/bld.inf Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_TESTEXPORTS
+
+../inc/usbmandll_stub.h /epoc32/include/mw/taf/usbmandll_stub.h
+
+
+PRJ_TESTMMPFILES
+UsbOtgWatcherTest.mmp
+UsbOtgWatcherTest_exe.mmp
+
+PRJ_MMPFILES
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/group/build_sis_ats.bat Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,20 @@
+@rem
+@rem Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+
+call sbs -c armv5.test
+call makesis UsbOtgWatcherTest_ats.pkg
+call signsis UsbOtgWatcherTest_ats.sis UsbOtgWatcherTest_ats.sisx rd.cer rd-key.pem
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/group/build_sis_phone.bat Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,20 @@
+@rem
+@rem Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+
+call sbs -c armv5.test
+call makesis UsbOtgWatcherTest_phone.pkg
+call signsis UsbOtgWatcherTest_phone.sis UsbOtgWatcherTest_phone.sisx rd.cer rd-key.pem
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/inc/UsbOtgWatcherTest.h Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,277 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#ifndef USBOTGWATCHERTEST_H
+#define USBOTGWATCHERTEST_H
+
+// INCLUDES
+#include <StifLogger.h>
+#include <TestScripterInternal.h>
+#include <StifTestModule.h>
+#include <TestclassAssert.h>
+#include "stifassertmacros.h"
+// INCLUDES FOR STUBS
+#include <stubber.h>
+#include <apibehavior.h>
+#include <usbmandll_stub.h>
+// INCLUDES FOR TEST
+#include <usbstates.h>
+#include <usbuinotif.h>
+#include "cusbotgwatcher.h"
+#include "cusbnotifier.h"
+#include "cusbstatehostainitiate.h"
+#include "cusbstatehosthandle.h"
+#include "cusbservicecontrol.h"
+
+
+// CONSTANTS
+// Logging path
+_LIT( KUsbOtgWatcherTestLogPath, "\\logs\\testframework\\UsbOtgWatcherTest\\" );
+
+// Logging path for ATS - for phone builds comment this line
+//_LIT( KUsbOtgWatcherTestLogPath, "e:\\testing\\stiflogs\\" );
+
+// Log file
+_LIT( KUsbOtgWatcherTestLogFile, "UsbOtgWatcherTest.txt" );
+_LIT( KUsbOtgWatcherTestLogFileWithTitle, "UsbOtgWatcherTest_[%S].txt" );
+
+// MACROS
+#define TEST_CLASS_VERSION_MAJOR 0
+#define TEST_CLASS_VERSION_MINOR 0
+#define TEST_CLASS_VERSION_BUILD 0
+
+// Macros used to extract test block parameters
+#define TESTENTRY( A, B )\
+ if ( !iTestBlockParams.iTestBlockName.Compare( TPtrC( ( TText* ) L ##A ) ) )\
+ { iTestBlockFunction = &B; iTestBlockFound = ETrue; }\
+ if ( !iTestBlockParams.iTestBlockName.Compare( TPtrC( ( TText* ) L ##A ) ) )
+
+#define TESTPARAM( A, B )\
+ GetTestBlockParamL( ( TGetTestBlockParamOperation ) A, ( TTestBlockParamName ) B );
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+class CUsbOtgWatcher;
+class RUsb;
+
+// DATA TYPES
+
+// Enum type used to determine test block execution result
+enum TUsbOtgWatcherTestResult
+ {
+ ETestCasePassed,
+ ETestCaseFailed
+ };
+
+// Enum type indicating test block parameter which should be used to store
+// data extracted from test script
+enum TTestBlockParamName
+ {
+ eTestOption1,
+ eTestOption2,
+ eTestOption3,
+ eTestIntOption1,
+ eTestIntOption2,
+ eTestIntOption3,
+ eTestCharOption1,
+ eTestCharOption2,
+ eTestCharOption3
+ };
+
+// Enum type used to indicate which get parameter function should be used
+enum TGetTestBlockParamOperation
+ {
+ eGetString,
+ eGetInt,
+ eGetChar
+ };
+
+// CLASS DECLARATION
+/**
+* TUsbOtgWatcherTestBlockParams test class for storing test block parameters.
+*/
+NONSHARABLE_CLASS( TUsbOtgWatcherTestBlockParams )
+ {
+ public:
+ TPtrC iTestBlockName;
+
+ TPtrC iTestOption1;
+ TPtrC iTestOption2;
+ TPtrC iTestOption3;
+
+ TInt iTestIntOption1;
+ TInt iTestIntOption2;
+ TInt iTestIntOption3;
+
+ TChar iTestCharOption1;
+ TChar iTestCharOption2;
+ TChar iTestCharOption3;
+ };
+
+/**
+* CUsbOtgWatcherTest test class for STIF Test Framework TestScripter.
+*/
+NONSHARABLE_CLASS( CtUsbOtgWatcher ) : public CScriptBase
+ {
+ public: // Constructors and destructor
+
+ /**
+ * Two-phased constructor.
+ */
+ static CtUsbOtgWatcher* NewL( CTestModuleIf& aTestModuleIf );
+
+ /**
+ * Destructor.
+ */
+ virtual ~CtUsbOtgWatcher();
+
+ public: // New functions
+ public: // Functions from base classes
+
+ /**
+ * From CScriptBase Runs a script line.
+ * @since ?Series60_version
+ * @param aItem Script line containing method name and parameters
+ * @return Symbian OS error code
+ */
+ virtual TInt RunMethodL( CStifItemParser& aItem );
+
+ protected: // New functions
+ protected: // Functions from base classes
+ private:
+
+ /**
+ * C++ default constructor.
+ */
+ CtUsbOtgWatcher( CTestModuleIf& aTestModuleIf );
+
+ /**
+ * By default Symbian 2nd phase constructor is private.
+ */
+ void ConstructL();
+
+ /**
+ * Frees all resources allocated from test methods.
+ * @since ?Series60_version
+ */
+ void TestDelete();
+
+ /**
+ * Constructs all test resources for test methods.
+ */
+ void TestConstructL();
+
+ /**
+ * Extracts test block parameters from script file
+ */
+ void TestBlocksInfoL();
+
+ /**
+ * Executes test block
+ */
+ TInt ExecuteTestBlock( CStifItemParser& aItem );
+
+ /**
+ * Executes proper get parameter function indicated by its arguments
+ */
+ void GetTestBlockParamL( TGetTestBlockParamOperation aOperation,
+ TTestBlockParamName aParamName );
+
+ /**
+ * Method used to log version of test class
+ */
+ void SendTestClassVersion();
+
+ // ADD NEW METHOD DEC HERE
+ // [TestMethods] - Do not remove
+ void ExampleTestL( TUsbOtgWatcherTestBlockParams& aParams,
+ TUsbOtgWatcherTestResult& aTestResult );
+
+ void SetupTearDownL( TUsbOtgWatcherTestBlockParams& aParams,
+ TUsbOtgWatcherTestResult& aTestResult );
+
+ void PinOnTest_SuccessL( TUsbOtgWatcherTestBlockParams& aParams,
+ TUsbOtgWatcherTestResult& aTestResult );
+
+ void PinOffTest_SuccessL( TUsbOtgWatcherTestBlockParams& aParams,
+ TUsbOtgWatcherTestResult& aTestResult );
+
+ void PinOnTest_EmptyCableL( TUsbOtgWatcherTestBlockParams& aParams,
+ TUsbOtgWatcherTestResult& aTestResult );
+
+ void PinOnTest_TryStartErrorL( TUsbOtgWatcherTestBlockParams& aParams,
+ TUsbOtgWatcherTestResult& aTestResult );
+
+ void PinOnTest_BusRequestErrorL( TUsbOtgWatcherTestBlockParams& aParams,
+ TUsbOtgWatcherTestResult& aTestResult );
+
+ void DeviceAttached_BadHubPostionL( TUsbOtgWatcherTestBlockParams& aParams,
+ TUsbOtgWatcherTestResult& aTestResult );
+
+ void DeviceAttached_TooMuchRequiredL( TUsbOtgWatcherTestBlockParams& aParams,
+ TUsbOtgWatcherTestResult& aTestResult );
+
+ void DeviceAttached_SupportedDeviceL( TUsbOtgWatcherTestBlockParams& aParams,
+ TUsbOtgWatcherTestResult& aTestResult );
+
+ void DeviceDetached_SupportedDeviceL( TUsbOtgWatcherTestBlockParams& aParams,
+ TUsbOtgWatcherTestResult& aTestResult );
+
+ void IndicatorNotifier_IndicatorActivateL( TUsbOtgWatcherTestBlockParams& aParams,
+ TUsbOtgWatcherTestResult& aTestResult );
+
+ //others method
+ void SetupL();
+ void TearDown();
+
+ public: // Data
+ protected: // Data
+ private: // Data
+
+ // Member object used to store test block parameters
+ TUsbOtgWatcherTestBlockParams iTestBlockParams;
+ TTestResult iResult;
+
+ // Used to indicate if test block with specified parameters exist
+ TBool iTestBlockFound;
+
+ // Function pointer used to call proper test block methods
+ void ( CtUsbOtgWatcher::*iTestBlockFunction )
+ ( TUsbOtgWatcherTestBlockParams&, TUsbOtgWatcherTestResult& );
+
+ // Not own
+ CStifItemParser* iItem;
+ CStubber * iStubber;
+ RUsb* iUsbMan;
+ CUsbOtgWatcher* iWatcher;
+
+ // Reserved pointer for future extension
+ //TAny* iReserved;
+
+ // ADD NEW DATA DEC HERE
+
+
+ public: // Friend classes
+ protected: // Friend classes
+ private: // Friend classes
+
+ };
+#endif // USBOTGWATCHERTEST_H
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/inc/mockcusbbusactivityobserver.h Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,108 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef C_USBBUSACTIVITYOBSERVER_H
+#define C_USBBUSACTIVITYOBSERVER_H
+
+#include <e32base.h>
+
+#include "tassertbase.h"
+
+class MUsbBusActivityObserver
+ {
+public:
+
+ virtual void BusIdleL() = 0;
+ virtual void BusActiveL() = 0;
+ };
+
+/**
+ * Class observes OTG State property, see usbotgdefs.h
+ *
+ * @lib ?library
+ * @since S60 ?S60_version *** for example, S60 v3.0
+ */
+class CUsbBusActivityObserver : public TAssertBase
+ {
+ friend class CtUsbOtgWatcher;
+ friend class CUsbOtgWatcherTest;
+
+public:
+
+ enum TBusActivity
+ {
+ EBusIdle = 0,
+ EBusActive = 1
+ };
+
+ /**
+ * Two-phased constructor.
+ * @param ?arg1 ?description
+ * @param ?arg2 ?description
+ */
+ // ?IMPORT_C
+ static CUsbBusActivityObserver* NewL();
+
+ /**
+ * Destructor.
+ */
+ virtual ~CUsbBusActivityObserver();
+
+ /**
+ * ?description
+ *
+ * @since S60 ?S60_version
+ * @param ?arg1 ?description
+ * @param ?arg2 ?description
+ * @return ?description
+ */
+ // ?IMPORT_C
+ TBusActivity BusActivity();
+
+ /**
+ * ?description
+ *
+ * @since S60 ?S60_version
+ * @param ?arg1 ?description
+ * @param ?arg2 ?description
+ * @return ?description
+ */
+ void SubscribeL(MUsbBusActivityObserver&);
+
+ void UnsubscribeL(MUsbBusActivityObserver&);
+
+ void TriggerBusIdleL();
+
+ void TriggerBusActiveL();
+
+private:
+
+ CUsbBusActivityObserver();
+
+ void ConstructL();
+
+private:
+ // data
+
+ // The observer reports state changes to own observers
+ // Owns
+ MUsbBusActivityObserver* iObserver;
+
+ TInt iBusActivity;
+ };
+
+#endif // C_USBOTGSTATEOBSERVER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/inc/mockcusbhosteventnotificationobserver.h Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,97 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef C_USBHOSTEVENTNOTIFICATIONOBSERVER_H
+#define C_USBHOSTEVENTNOTIFICATIONOBSERVER_H
+
+#include <e32base.h>
+#include <usbhostdefs.h>
+
+#include <StifTestModule.h>
+#include <StifLogger.h>
+
+#include "tassertbase.h"
+
+class RUsb;
+
+class MUsbHostEventNotificationObserver
+ {
+public:
+
+ virtual void DeviceAttachedL(TDeviceEventInformation) = 0;
+ virtual void DeviceDetachedL(TDeviceEventInformation) = 0;
+ virtual void DriverLoadSuccessL(TDeviceEventInformation) = 0;
+ virtual void DriverLoadPartialSuccessL(TDeviceEventInformation) = 0;
+ virtual void DriverLoadFailureL(TDeviceEventInformation) = 0;
+
+ };
+
+/**
+ * Class observes USB Notifications
+ *
+ * @lib ?library
+ * @since S60 ?S60_version *** for example, S60 v3.0
+ */
+class CUsbHostEventNotificationObserver : public TAssertBase
+ {
+ friend class CtUsbOtgWatcher;
+ friend class CUsbOtgWatcherTest;
+
+public:
+
+ /**
+ * Two-phased constructor.
+ * @param ?arg1 ?description
+ * @param ?arg2 ?description
+ */
+ // ?IMPORT_C
+ static CUsbHostEventNotificationObserver* NewL(RUsb* aUsb);
+
+ /**
+ * Destructor.
+ */
+ virtual ~CUsbHostEventNotificationObserver();
+
+ void SubscribeL(MUsbHostEventNotificationObserver&);
+
+ void UnsubscribeL(MUsbHostEventNotificationObserver&);
+
+ void TriggerDeviceAttachedL(TDeviceEventInformation eventInfo);
+ void TriggerDeviceDetachedL(TDeviceEventInformation eventInfo);
+ void TriggerDriverLoadSuccessL(TDeviceEventInformation eventInfo);
+ void TriggerDriverLoadPartialSuccessL(TDeviceEventInformation eventInfo);
+ void TriggerDriverLoadFailureL(TDeviceEventInformation eventInfo);
+
+private:
+
+ CUsbHostEventNotificationObserver(RUsb* aUsb);
+
+ void ConstructL();
+
+private:
+ // data
+
+ // The observer reports changes to own observers
+ // Owns
+ MUsbHostEventNotificationObserver* iObserver;
+
+ // Notifications come from USB
+ // Not own
+ RUsb* iUsb;
+ };
+
+#endif // C_USBHOSTEVENTNOTIFICATIONOBSERVER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/inc/mockcusbidpinobserver.h Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,113 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef MOCK_C_USBIDPINOBSERVER_H
+#define MOCK_C_USBIDPINOBSERVER_H
+
+#include <e32base.h>
+
+#include <StifTestModule.h>
+#include <StifLogger.h>
+#include <e32property.h>
+
+#include "tassertbase.h"
+
+class CStifLogger;
+
+class MUsbIdPinObserver
+ {
+public:
+
+ virtual void IdPinOffL() = 0;
+ virtual void IdPinOnL() = 0;
+
+ };
+
+/**
+ * Class observes ID-PIN property
+ *
+ * @lib ?library
+ * @since S60 ?S60_version *** for example, S60 v3.0
+ */
+class CUsbIdPinObserver : public TAssertBase
+ {
+ friend class CtUsbOtgWatcher;
+ friend class CUsbOtgWatcherTest;
+public:
+ enum TState
+ {
+ EIdPinOff = 0,
+ EIdPinOn = 1
+ };
+
+ /**
+ * Two-phased constructor.
+ * @param ?arg1 ?description
+ * @param ?arg2 ?description
+ */
+ // ?IMPORT_C
+ static CUsbIdPinObserver* NewL();
+
+ /**
+ * Destructor.
+ */
+ virtual ~CUsbIdPinObserver();
+
+ /**
+ * ?description
+ *
+ * @since S60 ?S60_version
+ * @param ?arg1 ?description
+ * @param ?arg2 ?description
+ * @return ?description
+ */
+ // ?IMPORT_C
+ TState IdPin() /* const! read comment in impl*/;
+
+ /**
+ * ?description
+ *
+ * @since S60 ?S60_version
+ * @param ?arg1 ?description
+ * @param ?arg2 ?description
+ * @return ?description
+ */
+
+ void SubscribeL(MUsbIdPinObserver&);
+
+ void UnsubscribeL(MUsbIdPinObserver&);
+
+ void TriggerPinOnL();
+
+ void TriggerPinOffL();
+
+private:
+
+ CUsbIdPinObserver();
+
+ void ConstructL();
+
+private:
+ // data
+ // The observer reports state changes to its own observers
+ // Own
+ MUsbIdPinObserver* iObserver;
+ TInt iIdPinOn;
+ CActiveSchedulerWait * iWait;
+ };
+
+#endif // MOCK_C_USBIDPINOBSERVER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/inc/mockcusbmessagenotificationobserver.h Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,96 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef C_USBMESSAGENOTIFICATIONOBSERVER_H
+#define C_USBMESSAGENOTIFICATIONOBSERVER_H
+
+#include <e32base.h>
+
+#include "tassertbase.h"
+
+class RUsb;
+
+class MUsbMessageNotificationObserver
+ {
+public:
+
+ virtual void MessageNotificationReceivedL(TInt) = 0;
+ virtual void BadHubPositionL() = 0;
+ virtual void VBusErrorL() = 0;
+ virtual void SrpReceivedL() = 0;
+ virtual void SessionRequestedL() = 0;
+ };
+
+/**
+ * Class observes USB Notifications
+ *
+ * @lib ?library
+ * @since S60 ?S60_version *** for example, S60 v3.0
+ */
+class CUsbMessageNotificationObserver : public TAssertBase
+ {
+ friend class CtUsbOtgWatcher;
+ friend class CUsbOtgWatcherTest;
+
+public:
+
+ /**
+ * Two-phased constructor.
+ * @param ?arg1 ?description
+ * @param ?arg2 ?description
+ */
+ // ?IMPORT_C
+ static CUsbMessageNotificationObserver* NewL(RUsb* aUsb);
+
+ /**
+ * Destructor.
+ */
+ virtual ~CUsbMessageNotificationObserver();
+
+ void SubscribeL(MUsbMessageNotificationObserver&);
+
+ void UnsubscribeL(MUsbMessageNotificationObserver&);
+
+ void TriggerMessageNotificationReceivedL(TInt);
+ void TriggerBadHubPositionL();
+ void TriggerVBusErrorL();
+ void TriggerSrpReceivedL();
+ void TriggerSessionRequestedL();
+
+private:
+
+ CUsbMessageNotificationObserver(RUsb* aUsb);
+
+ void ConstructL();
+
+private:
+ // data
+
+ // The observer reports to own observers
+ // Owns
+ MUsbMessageNotificationObserver* iObserver;
+
+ // Notifications come from USB
+ // Not own
+ RUsb* iUsb;
+
+ // Info from notification comes to this member
+ TInt iMessage;
+
+ };
+
+#endif // C_USBMESSAGENOTIFICATIONOBSERVER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/inc/mockcusbnotifmanager.h Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,90 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef C_USBNOTIFMANAGER_H
+#define C_USBNOTIFMANAGER_H
+
+#include <e32base.h>
+
+#include <StifTestModule.h>
+#include <StifLogger.h>
+
+#include "tassertbase.h"
+#include "cusbnotifier.h"
+#include "cusbwarningnotifier.h"
+#include "cusbotgwatcher.h"
+
+#define INVALID_VALUE NULL
+
+// forward declaration
+class CUsbWaitNotifier;
+class CUsbNotifier;
+
+class MWaitNotifierObserver
+{
+public:
+
+ // feedback to observer
+ virtual void WaitNotifierCompletedL(TInt aFeedback) = 0;
+};
+
+/**
+ * Function of the class is own and share RNotifier, own list of CWaitNotifier(s),
+ * show notifiers, which are synchronous, and cancel it with a delay
+ *
+ * @lib ?library
+ * @since S60 ?S60_version *** for example, S60 v3.0
+ */
+class CUsbNotifManager : public TAssertBase
+ {
+friend class CtUsbOtgWatcher;
+ friend class CUsbOtgWatcherTest;
+
+public:
+ static CUsbNotifManager* NewL(CUsbOtgWatcher& aOtgWatcher);
+
+ virtual ~CUsbNotifManager();
+
+ void ShowNotifierL(TUid aCat, TUint aNotifId, MWaitNotifierObserver* aObserver = NULL );
+
+ void BlinkIndicatorL(TBool aBlinking = ETrue);
+
+ void ShowIndicatorL(TBool aVisible = ETrue);
+
+ void CloseAllNotifiers();
+
+ TBool GetUsbIconBlinking() { return iUsbIconBlinking; };
+
+private:
+
+ CUsbNotifManager();
+
+ void ConstructL();
+
+ // call back. Notifier show is over
+ void NotifierShowCompletedL(CUsbNotifier& aWaitNotifier, TInt aResult, TInt aFeedback);
+
+private: // data
+ TUid iCat;
+ TUint iNotifId;
+ MWaitNotifierObserver* iObserver;
+
+ TBool iUsbIconBlinking;
+ TBool iUsbIconShown;
+ };
+
+#endif // C_USBNOTIFMANAGER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/inc/mockcusbotgstateobserver.h Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,115 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef C_USBOTGSTATEOBSERVER_H
+#define C_USBOTGSTATEOBSERVER_H
+
+#include <e32base.h>
+#include <usbotgdefs.h>
+
+#include <StifTestModule.h>
+#include <StifLogger.h>
+
+#include "tassertbase.h"
+
+class MUsbOtgStateObserver
+ {
+public:
+
+ virtual void AIdleL() = 0;
+ virtual void AHostL() = 0;
+ virtual void APeripheralL() = 0;
+ virtual void AVBusErrorL() = 0;
+ virtual void BIdleL() = 0;
+ virtual void BPeripheralL() = 0;
+ virtual void BHostL() = 0;
+ };
+
+/**
+ * Class observes OTG State property, see usbotgdefs.h
+ *
+ * @lib ?library
+ * @since S60 ?S60_version *** for example, S60 v3.0
+ */
+class CUsbOtgStateObserver : public TAssertBase
+ {
+ friend class CtUsbOtgWatcher;
+ friend class CUsbOtgWatcherTest;
+
+public:
+
+ /**
+ * Two-phased constructor.
+ * @param ?arg1 ?description
+ * @param ?arg2 ?description
+ */
+ // ?IMPORT_C
+ static CUsbOtgStateObserver* NewL();
+
+ /**
+ * Destructor.
+ */
+ virtual ~CUsbOtgStateObserver();
+
+ /**
+ * ?description
+ *
+ * @since S60 ?S60_version
+ * @param ?arg1 ?description
+ * @param ?arg2 ?description
+ * @return ?description
+ */
+ // ?IMPORT_C
+ TUsbOtgState OtgState();
+
+ /**
+ * ?description
+ *
+ * @since S60 ?S60_version
+ * @param ?arg1 ?description
+ * @param ?arg2 ?description
+ * @return ?description
+ */
+ void SubscribeL(MUsbOtgStateObserver&);
+
+ void UnsubscribeL(MUsbOtgStateObserver&);
+
+ void TriggerAIdleL();
+ void TriggerAHostL();
+ void TriggerAPeripheralL();
+ void TriggerAVBusErrorL();
+ void TriggerBIdleL();
+ void TriggerBPeripheralL();
+ void TriggerBHostL();
+
+private:
+
+ CUsbOtgStateObserver();
+
+ void ConstructL();
+
+private:
+ // data
+
+ // The observer reports state changes to own observers
+ // Owns
+ MUsbOtgStateObserver* iObserver;
+
+ TInt iOtgState;
+ };
+
+#endif // C_USBOTGSTATEOBSERVER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/inc/mockcusbtimer.h Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,103 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef C_USBTIMER_H
+#define C_USBTIMER_H
+
+#include <e32base.h>
+
+#include <StifTestModule.h>
+#include <StifLogger.h>
+
+#include "tassertbase.h"
+
+class CUsbTimer;
+
+/**
+ * timer ids for usbotgwatcher
+ */
+enum TUsbTimerId
+ {
+ EDeviceAttachmentTimer,
+ EInactiveTimer,
+ EIconBlinkingTimer,
+ ETooMuchPowerRequiredTimer,
+ EDriversNotFoundTimer
+ };
+
+
+class MUsbTimerObserver
+ {
+ friend class CtUsbOtgWatcher;
+ friend class CUsbOtgWatcherTest;
+public:
+
+ virtual void TimerElapsedL(TUsbTimerId aTimerId) = 0;
+ };
+
+// Wrapper class, will report to MUsbTimerObserver once time is over
+// Name CUsbTimer is given due to CTimer name already used
+NONSHARABLE_CLASS(CUsbTimer) : public TAssertBase
+ {
+public:
+
+ /**
+ * Two-phased constructor
+ *
+ * @param aTimeOver pointer to a call back function. Called when time is over.
+ */
+ static CUsbTimer* NewL(MUsbTimerObserver& aObserver, TUsbTimerId aTimerId);
+
+ /**
+ * Destructor.
+ */
+ virtual ~CUsbTimer();
+
+ // calls RunL after aMilliseconds
+ void After(TInt aMilliseconds);
+
+ //cancels timer
+ void Cancel();
+
+ TBool IsActive();
+
+ void TriggerTimerElapsedL();
+
+public:
+
+ // from base class CActive
+
+ void RunL();
+
+ TInt RunError( TInt /*aError*/);
+
+ void DoCancel();
+
+private:
+
+ CUsbTimer(MUsbTimerObserver& aObserver, TUsbTimerId aTimerId);
+
+ void ConstructL();
+
+private: // data
+
+ MUsbTimerObserver* iObserver;
+ TBool iActive;
+ TUsbTimerId iTimerId;
+ };
+
+#endif // C_USBTIMER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/inc/mockcusbvbusobserver.h Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,115 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef C_USBVBUSOBSERVER_H
+#define C_USBVBUSOBSERVER_H
+
+#include <e32base.h>
+
+#include <StifTestModule.h>
+#include <StifLogger.h>
+
+#include "tassertbase.h"
+
+class RUsb;
+
+class MUsbVBusObserver
+ {
+public:
+
+ void virtual VBusDownL() = 0;
+ void virtual VBusUpL() = 0;
+
+ };
+
+/**
+ * Class observes VBUS property
+ *
+ * @lib ?library
+ * @since S60 ?S60_version *** for example, S60 v3.0
+ */
+class CUsbVBusObserver : public TAssertBase
+ {
+ friend class CtUsbOtgWatcher;
+ friend class CUsbOtgWatcherTest;
+
+public:
+ enum TState
+ {
+ EVBusDown = 0,
+ EVBusUp = 1
+ };
+
+ /**
+ * Two-phased constructor.
+ * @param ?arg1 ?description
+ * @param ?arg2 ?description
+ */
+ // ?IMPORT_C
+ static CUsbVBusObserver* NewL();
+
+ /**
+ * Destructor.
+ */
+ virtual ~CUsbVBusObserver();
+
+ /**
+ * ?description
+ *
+ * @since S60 ?S60_version
+ * @param ?arg1 ?description
+ * @param ?arg2 ?description
+ * @return ?description
+ */
+ // ?IMPORT_C
+ TState VBus() /* const! read comment in impl*/;
+
+ /**
+ * ?description
+ *
+ * @since S60 ?S60_version
+ * @param ?arg1 ?description
+ * @param ?arg2 ?description
+ * @return ?description
+ */
+
+ void SubscribeL(MUsbVBusObserver&);
+
+ void UnsubscribeL(MUsbVBusObserver&);
+
+ void SetRUsb(RUsb* aRUsb);
+
+ void TriggerVBusUpL();
+
+ void TriggerVBusDownL();
+private:
+
+ CUsbVBusObserver();
+
+ void ConstructL();
+
+private:
+ // data
+ RUsb* iUsb;
+
+ // The observer reports state changes to own observers
+ // Own
+ MUsbVBusObserver* iObserver;
+
+ };
+
+#endif // C_USBVBUSOBSERVER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/inc/mockusbman.h Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,152 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef __USBMAN_H__
+#define __USBMAN_H__
+
+//#ifndef R_USB_H
+//#define R_USB_H
+
+#include <usbhostdefs.h>
+
+#include <StifTestModule.h>
+#include <StifLogger.h>
+
+#include "tassertbase.h"
+#include <usbstates.h>
+
+//enum TUsbMockServiceState
+// {
+// EUsbServiceStateIdle = 0x01,
+// EUsbServiceStateStarting = 0x02,
+// EUsbServiceStateStarted = 0x04,
+// EUsbServiceStateStopping = 0x08,
+// EUsbServiceStateFatalError = 0x10
+// };
+
+class RUsb : public TAssertBase
+ {
+
+ // Request types, the interest of which can be cancelled by clients
+ enum TUsbReqType
+ {
+ EStart,
+ EStop,
+ ETryStart,
+ ETryStop
+ };
+
+public:
+ static RUsb* NewL();
+
+ ~RUsb();
+ // from base class MUsb
+ /**
+ */
+ void TryStart(TInt aPersonalityId, TRequestStatus& aStatus);
+
+ /**
+ */
+ void StartCancel(TRequestStatus& aStatus);
+
+ /**
+ */
+ void TryStop(TRequestStatus& aStatus);
+
+ /**
+ */
+ void MessageNotification(TRequestStatus& aStatus, TInt& aMessage);
+
+ /**
+ */
+ void MessageNotificationCancel();
+
+ /**
+ */
+ void HostEventNotification(TRequestStatus& aStatus,
+ TDeviceEventInformation& aDeviceInformation);
+
+ /**
+ */
+ void HostEventNotificationCancel();
+
+ /**
+ */
+ TInt EnableFunctionDriverLoading();
+
+ /**
+ */
+ void DisableFunctionDriverLoading();
+
+ /**
+ */
+ TInt BusRequest();
+
+ /**
+ */
+ TInt BusRespondSrp();
+
+ /**
+ */
+ TInt BusClearError();
+
+ /**
+ */
+ TInt BusDrop();
+
+ void ServiceStateNotification(TUsbServiceState &aState, TRequestStatus &aStatus);
+
+ TInt GetCurrentPersonalityId(TInt &aPersonalityId);
+
+ TInt CancelInterest(TUsbReqType aMessageId); // to pending op. of usb service state
+
+ void ServiceStateNotificationCancel();
+
+ TInt GetOtgDescriptor(TUint aDeviceId, TOtgDescriptor& aDescriptor);
+
+ // from base class RSessionBase
+ /**
+ */
+ void Close();
+
+ //Mock methods
+ void SetTryStartError(TInt aError);
+ void SetBusRequestError(TInt aError);
+ void SetUsbServiceState(TUsbServiceState aUsbServiceState);
+ void SetCurrentPersonality(TInt aPersonality);
+
+ TBool GetVBusUp();
+
+ TInt GetServiceState(TUsbServiceState& aState);
+private:
+ RUsb();
+
+ void ConstructL();
+
+private: // data
+ TBool iBusCleared;
+ TBool iBusRequested;
+ TBool iServiceStateNotificationRequested;
+
+ TInt iTryStartError;
+ TInt iBusRequestError;
+ TInt iCurrentPersonalityId;
+
+ TUsbServiceState iUsbServiceState;
+ };
+
+#endif // __USBMAN_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/inc/stifassertmacros.h Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,62 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#ifndef STIFASSERT_MACRO_H
+#define STIFASSERT_MACRO_H
+
+#ifdef __STIF_ASSERT_SHARED
+#undef __STIF_ASSERT_SHARED
+/*********************************************************************************
+ * Assert Macros
+ *********************************************************************************/
+#define __STIF_ASSERT_SHARED( aFunction, aMessage ) \
+ if(!aFunction) \
+ { \
+ iLog->Log( aMessage, __STIF_DBG_FILE__, __LINE__ );\
+ iResult.SetResult( KErrGeneral, _L("Testcase failed"));\
+ return;\
+ }
+#endif
+
+#ifdef __STIF_ASSERT_SHARED_DESC
+#undef __STIF_ASSERT_SHARED_DESC
+#define __STIF_ASSERT_SHARED_DESC( aFunction, aMessage, aDesc ) \
+ if(!aFunction) \
+ { \
+ iLog->Log( aMessage, __STIF_DBG_FILE__, __LINE__ );\
+ iResult.SetResult( KErrGeneral, aDesc );\
+ return;\
+ } \
+ else \
+ { \
+ iResult.SetResult( KErrNone, aDesc ); \
+ }
+#endif
+
+#ifdef STIF_ASSERT_PANIC_DESC
+#undef STIF_ASSERT_PANIC_DESC
+
+#define STIF_ASSERT_PANIC_DESC( aPanicCode, aStatement, aDescription ) \
+ { \
+ TestModuleIf().SetExitReason( CTestModuleIf::EPanic, aPanicCode ); \
+ iResult.SetResult(KErrNone, aDescription); \
+ aStatement; \
+ }
+#endif
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/inc/tassertbase.h Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#ifndef TASSERTBASE_H
+#define TASSERTBASE_H
+
+#include <StifTestModule.h>
+#include <StifLogger.h>
+
+class TAssertBase
+ {
+public:
+ // Pointer to logger
+ // Not own
+ CStifLogger * iLog;
+
+ // Test result
+ TTestResult iResult;
+
+ void SetStifLogger(CStifLogger* aLog)
+ {
+ iLog = aLog;
+ }
+
+ TBool IsTestResultNoneError()
+ {
+ return iResult.iResult == KErrNone;
+ }
+ };
+
+#endif //ASSERTBASE_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/inc/testdebug.h Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef TESTDEBUG_H_
+#define TESTDEBUG_H_
+
+// INCLUDES
+#include <e32debug.h>
+#include <e32def.h>
+
+// CONSTANTS
+_LIT8(KStifTestPrefix8, "[STIF_LOG] ");
+_LIT( KStifTestPrefix, "[STIF_LOG] ");
+_LIT8( KStifEntryPrefix8, ">>> %S" );
+_LIT8( KStifExitPrefix8, "<<< %S" );
+
+const TInt KMaxLogLineLength = 512;
+typedef TBuf8< KMaxLogLineLength > TLogBuf8;
+typedef TBuf16< KMaxLogLineLength > TLogBuf16;
+
+// CLASS DECLARATION
+NONSHARABLE_CLASS( TTestLogger )
+ {
+public:
+ static inline TLogBuf16 CreateLogBuf( TRefByValue<const TDesC8> aFmt, ... );
+ static inline TLogBuf16 CreateLogBuf( TRefByValue<const TDesC16> aFmt, ... );
+ static inline void Trace( CStifLogger& aLog, TLogBuf16 aLogBuf );
+ };
+
+// MACROS
+#define TRACE( p ) {\
+ TLogBuf16 buf = TTestLogger::CreateLogBuf( _L( p ) );\
+ TTestLogger::Trace( *iLog, buf );\
+ }
+#define TRACE_INFO( p, args... ) {\
+ TLogBuf16 buf = TTestLogger::CreateLogBuf( _L( p ), args );\
+ TTestLogger::Trace( *iLog, buf );\
+ }
+#define TRACE_FUNC_ENTRY {\
+ TPtrC8 ptr8( ( TUint8* ) __FUNCTION__ );\
+ TLogBuf16 buf = TTestLogger::CreateLogBuf( KStifEntryPrefix8, &ptr8 );\
+ TTestLogger::Trace( *iLog, buf );\
+ }
+#define TRACE_FUNC_EXIT {\
+ TPtrC8 ptr8( ( TUint8* ) __FUNCTION__ );\
+ TLogBuf16 buf = TTestLogger::CreateLogBuf( KStifExitPrefix8, &ptr8 );\
+ TTestLogger::Trace( *iLog, buf );\
+ }
+
+#include "testdebug.inl"
+
+#endif /* TESTDEBUG_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/inc/testdebug.inl Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,69 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include <e32debug.h>
+
+NONSHARABLE_CLASS( TOverflowTruncate8 ) : public TDes8Overflow
+ {
+public:
+ void Overflow( TDes8& /*aDes*/ ) {}
+ };
+
+NONSHARABLE_CLASS( TOverflowTruncate16 ) : public TDes16Overflow
+ {
+public:
+ void Overflow( TDes16& /*aDes*/ ) {}
+ };
+
+TLogBuf16 TTestLogger::CreateLogBuf( TRefByValue<const TDesC8> aFmt, ... )
+ {
+ VA_LIST list;
+ VA_START( list, aFmt );
+ TOverflowTruncate8 overflow;
+ TLogBuf8 buf8;
+ TLogBuf16 buf16;
+ buf8.AppendFormatList( aFmt, list, &overflow );
+ buf16.Copy( buf8 );
+ return buf16;
+ };
+
+TLogBuf16 TTestLogger::CreateLogBuf( TRefByValue<const TDesC16> aFmt, ... )
+ {
+ VA_LIST list;
+ VA_START( list, aFmt );
+ TOverflowTruncate16 overflow;
+ TLogBuf16 buf16;
+ buf16.AppendFormatList( aFmt, list, &overflow );
+ return buf16;
+ };
+
+void TTestLogger::Trace( CStifLogger& aLog, TLogBuf16 aLogBuf )
+ {
+ RBuf16 buf;
+ RBuf16 bufStifLog;
+
+ buf.Create( KMaxLogLineLength );
+ buf.Append( KStifTestPrefix );
+ buf.Append( aLogBuf );
+ bufStifLog.Create( KMaxLogLineLength );
+ bufStifLog.Append( aLogBuf );
+
+ RDebug::Print( buf );
+ aLog.Log( bufStifLog );
+ buf.Close();
+ bufStifLog.Close();
+ };
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/inc/usbmandll_stub.h Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#ifndef USBMANDLL_STUB_H_
+#define USBMANDLL_STUB_H_
+
+static const TUint KUsbManStubAgentDll = 0x00000033;
+
+enum TUsbManStubAgentApi
+ {
+ EConnect,
+ EGetDeviceState,
+ EStart,
+ EStop,
+ ETryStartAsync,
+ ETryStopAsync,
+ EDeviceStateNotification,
+ EGetCurrentPersonalityId,
+ ECancelInterest,
+ EDeviceStateNotificationCancel,
+ EServiceState,
+ ESetCtlSessionMode,
+ EGetPersonalityProperty
+ };
+
+#endif /*USBMANDLL_STUB_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/init/UsbOtgWatcherTest_ats.ini Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,232 @@
+# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: Installation file for STIF
+#
+
+
+#
+# This is STIF initialization file
+# Comment lines start with '#'-character.
+# See STIF TestFramework users guide.doc for instructions
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set following test engine settings:
+# - Set Test Reporting mode. TestReportMode's possible values are:
+# + 'Summary': Summary of the tested test cases.
+# + 'Environment': Hardware and software info.
+# + 'TestCases': Test case report.
+# + 'FullReport': Set of all above ones.
+# + Example 'TestReportMode= Summary TestCases'
+#
+# - CreateTestReport setting controls report creation mode
+# + YES, Test report will created.
+# + NO, No Test report.
+#
+# - File path indicates the base path of the test report.
+# - File name indicates the name of the test report.
+#
+# - File format indicates the type of the test report.
+# + TXT, Test report file will be txt type, for example 'TestReport.txt'.
+# + HTML, Test report will be html type, for example 'TestReport.html'.
+#
+# - 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= E:/Testing/Logs/
+TestReportFileName= UsbOtgWatcherTest_TestReport.log
+
+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'
+
+Timeout= 0 # Default timeout value for each test case. In milliseconds
+UITestingSupport= YES # Possible values: YES or NO
+#SeparateProcesses= YES # Possible values: YES or NO (default: NO)
+[End_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Module configurations start
+# Modules are added between module tags
+# tags. Module name is specified after ModuleName= tag, like
+# ModuleName= UsbOtgWatcherTestUsbOtgWatcherTestUsbOtgWatcherTest
+# Modules might have initialisation file, specified as
+# IniFile= c:/testframework/YYYYYY
+# Modules might have several configuration files, like
+# TestCaseFile= c:/testframework/NormalCases.txt
+# TestCaseFile= c:/testframework/SmokeCases.txt
+# TestCaseFile= c:/testframework/ManualCases.txt
+
+# (TestCaseFile is synonym for old term ConfigFile)
+
+# Following case specifies demo module settings. Demo module
+# does not read any settings from file, so tags
+# IniFile and TestCaseFile are not used.
+# In the simplest case it is enough to specify only the
+# name of the test module when adding new test module
+
+[New_Module]
+ModuleName= TestScripter
+TestCaseFile= E:/testing/conf/UsbOtgWatcherTest.cfg
+[End_Module]
+
+
+# Load testmoduleUsbOtgWatcherTest, optionally with initialization file and/or test case files
+#[New_Module]
+#ModuleName= testmodulexxx
+
+#TestModuleUsbOtgWatcherTest used initialization file
+#IniFile= c:/testframework/init.txt
+
+#TestModuleUsbOtgWatcherTest used configuration file(s)
+#TestCaseFile= c:/testframework/testcases1.cfg
+#TestCaseFile= c:/testframework/testcases2.cfg
+#TestCaseFile= c:/testframework/manualtestcases.cfg
+
+#[End_Module]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set STIF logging overwrite parameters for Logger.
+# Hardware and emulator environment logging path and styles can
+# be configured from here to overwrite the Logger's implemented values.
+#
+# Settings description:
+# - Indicates option for creation log directory/directories. If log directory/directories
+# is/are not created by user they will make by software.
+# + YES, Create log directory/directories if not allready exist.
+# + NO, Log directory/directories not created. Only created one is used.
+#
+# - Overwrite emulator path setting.
+# + Example: If 'EmulatorBasePath= C:/LOGS/TestFramework/' and in code is defined
+# Logger's path 'D://LOGS//Module//' with those definition the path
+# will be 'C:/LOGS/TestFramework/LOGS/Module/'
+#
+# - Overwrite emulator's logging format.
+# + TXT, Log file(s) will be txt type(s), for example 'Module.txt'.
+# + HTML, Log file(s) will be html type(s), for example 'Module.html'.
+#
+# - Overwrited emulator logging output source.
+# + FILE, Logging to file(s).
+# + RDEBUG, Logging to using rdebug(s).
+#
+# - Overwrite hardware path setting (Same description as above in emulator path).
+# - Overwrite hardware's logging format(Same description as above in emulator format).
+# - Overwrite hardware's logging output source(Same description as above in emulator output).
+#
+# - File Creation Mode indicates file overwriting if file exist.
+# + OVERWRITE, Overwrites if file(s) exist.
+# + APPEND, Continue logging after the old logging information if file(s) exist.
+#
+# - Will thread id include to the log filename.
+# + YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'.
+# + NO, No thread id to log file(s), Example filename 'Module.txt'.
+#
+# - Will time stamps include the to log file.
+# + YES, Time stamp added to each line in log file(s). Time stamp is
+# for example'12.Nov.2003 115958 LOGGING INFO'
+# + NO, No time stamp(s).
+#
+# - Will line breaks include to the log file.
+# + YES, Each logging event includes line break and next log event is in own line.
+# + NO, No line break(s).
+#
+# - Will event ranking include to the log file.
+# + YES, Event ranking number added to each line in log file(s). Ranking number
+# depends on environment's tics, for example(includes time stamp also)
+# '012 12.Nov.2003 115958 LOGGING INFO'
+# + NO, No event ranking.
+#
+# - Will write log file in unicode format.
+# + YES, Log file will be written in unicode format
+# + NO, Log will be written as normal, not unicode, file.
+#
+
+[Logger_Defaults]
+
+#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#'
+#NOTE: TestEngine and TestServer logging settings cannot change here
+
+CreateLogDirectories= YES # Possible values: YES or NO
+
+#EmulatorBasePath= C:/LOGS/TestFramework/
+#EmulatorFormat= HTML # Possible values: TXT or HTML
+#EmulatorOutput= FILE # Possible values: FILE or RDEBUG
+
+#HardwareBasePath= D:/LOGS/TestFramework/
+#HardwareFormat= HTML # Possible values: TXT or HTML
+#HardwareOutput= FILE # Possible values: FILE or RDEBUG
+
+#FileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND
+
+#ThreadIdToLogFile= YES # Possible values: YES or NO
+#WithTimeStamp= YES # Possible values: YES or NO
+#WithLineBreak= YES # Possible values: YES or NO
+#WithEventRanking= YES # Possible values: YES or NO
+
+#FileUnicode= YES # Possible values: YES or NO
+#AddTestCaseTitle= YES # Possible values: YES or NO
+[End_Logger_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set filters to be used by ConsoleUI.
+# If you want to use filter with ConsoleUI, simply remove comments
+# from section below and provide valid filter entries.
+# Each filter line has to start with "filter= " keyword.
+# Filter can contain special wildcard characters:
+# * which stands for none or any literal;
+# ? which stands for single character.
+# Filters are not case-sensitive.
+
+#[Filters]
+#filter= *math*
+#filter= *radio*
+#[End_Filters]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+# End of file
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/init/UsbOtgWatcherTest_phone.ini Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,233 @@
+# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: Installation file for STIF
+#
+
+
+
+#
+# This is STIF initialization file
+# Comment lines start with '#'-character.
+# See STIF TestFramework users guide.doc for instructions
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set following test engine settings:
+# - Set Test Reporting mode. TestReportMode's possible values are:
+# + 'Summary': Summary of the tested test cases.
+# + 'Environment': Hardware and software info.
+# + 'TestCases': Test case report.
+# + 'FullReport': Set of all above ones.
+# + Example 'TestReportMode= Summary TestCases'
+#
+# - CreateTestReport setting controls report creation mode
+# + YES, Test report will created.
+# + NO, No Test report.
+#
+# - File path indicates the base path of the test report.
+# - File name indicates the name of the test report.
+#
+# - File format indicates the type of the test report.
+# + TXT, Test report file will be txt type, for example 'TestReport.txt'.
+# + HTML, Test report will be html type, for example 'TestReport.html'.
+#
+# - 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\TemplateScriptUsbOtgWatcherTest\
+TestReportFileName= UsbOtgWatcherTest_TestReport.log
+
+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'
+
+Timeout= 0 # Default timeout value for each test case. In milliseconds
+UITestingSupport= YES # Possible values: YES or NO
+#SeparateProcesses= YES # Possible values: YES or NO (default: NO)
+[End_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Module configurations start
+# Modules are added between module tags
+# tags. Module name is specified after ModuleName= tag, like
+# ModuleName= UsbOtgWatcherTestUsbOtgWatcherTestUsbOtgWatcherTest
+# Modules might have initialisation file, specified as
+# IniFile= c:/testframework/YYYYYY
+# Modules might have several configuration files, like
+# TestCaseFile= c:/testframework/NormalCases.txt
+# TestCaseFile= c:/testframework/SmokeCases.txt
+# TestCaseFile= c:/testframework/ManualCases.txt
+
+# (TestCaseFile is synonym for old term ConfigFile)
+
+# Following case specifies demo module settings. Demo module
+# does not read any settings from file, so tags
+# IniFile and TestCaseFile are not used.
+# In the simplest case it is enough to specify only the
+# name of the test module when adding new test module
+
+[New_Module]
+ModuleName= TestScripter
+TestCaseFile= c:\testframework\UsbOtgWatcherTest.cfg
+[End_Module]
+
+
+# Load testmoduleUsbOtgWatcherTest, optionally with initialization file and/or test case files
+#[New_Module]
+#ModuleName= testmodulexxx
+
+#TestModuleUsbOtgWatcherTest used initialization file
+#IniFile= c:/testframework/init.txt
+
+#TestModuleUsbOtgWatcherTest used configuration file(s)
+#TestCaseFile= c:/testframework/testcases1.cfg
+#TestCaseFile= c:/testframework/testcases2.cfg
+#TestCaseFile= c:/testframework/manualtestcases.cfg
+
+#[End_Module]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set STIF logging overwrite parameters for Logger.
+# Hardware and emulator environment logging path and styles can
+# be configured from here to overwrite the Logger's implemented values.
+#
+# Settings description:
+# - Indicates option for creation log directory/directories. If log directory/directories
+# is/are not created by user they will make by software.
+# + YES, Create log directory/directories if not allready exist.
+# + NO, Log directory/directories not created. Only created one is used.
+#
+# - Overwrite emulator path setting.
+# + Example: If 'EmulatorBasePath= C:/LOGS/TestFramework/' and in code is defined
+# Logger's path 'D://LOGS//Module//' with those definition the path
+# will be 'C:/LOGS/TestFramework/LOGS/Module/'
+#
+# - Overwrite emulator's logging format.
+# + TXT, Log file(s) will be txt type(s), for example 'Module.txt'.
+# + HTML, Log file(s) will be html type(s), for example 'Module.html'.
+#
+# - Overwrited emulator logging output source.
+# + FILE, Logging to file(s).
+# + RDEBUG, Logging to using rdebug(s).
+#
+# - Overwrite hardware path setting (Same description as above in emulator path).
+# - Overwrite hardware's logging format(Same description as above in emulator format).
+# - Overwrite hardware's logging output source(Same description as above in emulator output).
+#
+# - File Creation Mode indicates file overwriting if file exist.
+# + OVERWRITE, Overwrites if file(s) exist.
+# + APPEND, Continue logging after the old logging information if file(s) exist.
+#
+# - Will thread id include to the log filename.
+# + YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'.
+# + NO, No thread id to log file(s), Example filename 'Module.txt'.
+#
+# - Will time stamps include the to log file.
+# + YES, Time stamp added to each line in log file(s). Time stamp is
+# for example'12.Nov.2003 115958 LOGGING INFO'
+# + NO, No time stamp(s).
+#
+# - Will line breaks include to the log file.
+# + YES, Each logging event includes line break and next log event is in own line.
+# + NO, No line break(s).
+#
+# - Will event ranking include to the log file.
+# + YES, Event ranking number added to each line in log file(s). Ranking number
+# depends on environment's tics, for example(includes time stamp also)
+# '012 12.Nov.2003 115958 LOGGING INFO'
+# + NO, No event ranking.
+#
+# - Will write log file in unicode format.
+# + YES, Log file will be written in unicode format
+# + NO, Log will be written as normal, not unicode, file.
+#
+
+[Logger_Defaults]
+
+#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#'
+#NOTE: TestEngine and TestServer logging settings cannot change here
+
+CreateLogDirectories= YES # Possible values: YES or NO
+
+#EmulatorBasePath= C:/LOGS/TestFramework/
+#EmulatorFormat= HTML # Possible values: TXT or HTML
+#EmulatorOutput= FILE # Possible values: FILE or RDEBUG
+
+#HardwareBasePath= D:/LOGS/TestFramework/
+#HardwareFormat= HTML # Possible values: TXT or HTML
+#HardwareOutput= FILE # Possible values: FILE or RDEBUG
+
+#FileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND
+
+#ThreadIdToLogFile= YES # Possible values: YES or NO
+#WithTimeStamp= YES # Possible values: YES or NO
+#WithLineBreak= YES # Possible values: YES or NO
+#WithEventRanking= YES # Possible values: YES or NO
+
+#FileUnicode= YES # Possible values: YES or NO
+#AddTestCaseTitle= YES # Possible values: YES or NO
+[End_Logger_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set filters to be used by ConsoleUI.
+# If you want to use filter with ConsoleUI, simply remove comments
+# from section below and provide valid filter entries.
+# Each filter line has to start with "filter= " keyword.
+# Filter can contain special wildcard characters:
+# * which stands for none or any literal;
+# ? which stands for single character.
+# Filters are not case-sensitive.
+
+#[Filters]
+#filter= *math*
+#filter= *radio*
+#[End_Filters]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+# End of file
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/src/UsbOtgWatcherTest.cpp Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,329 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+// INCLUDE FILES
+#include <Stiftestinterface.h>
+#include <SettingServerClient.h>
+#include "UsbOtgWatcherTest.h"
+#include "testdebug.h"
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES
+
+// CONSTANTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CUsbOtgWatcherTest::CUsbOtgWatcherTest
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CtUsbOtgWatcher::CtUsbOtgWatcher(
+ CTestModuleIf& aTestModuleIf ):
+ CScriptBase( aTestModuleIf )
+ {
+ }
+
+// -----------------------------------------------------------------------------
+// CtUsbOtgWatcher::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CtUsbOtgWatcher::ConstructL()
+ {
+ //Read logger settings to check whether test case name is to be
+ //appended to log file name.
+ RSettingServer settingServer;
+ TInt ret = settingServer.Connect();
+ if(ret != KErrNone)
+ {
+ User::Leave(ret);
+ }
+ // Struct to StifLogger settigs.
+ TLoggerSettings loggerSettings;
+ // Parse StifLogger defaults from STIF initialization file.
+ ret = settingServer.GetLoggerSettings( loggerSettings );
+ if( ret != KErrNone )
+ {
+ User::Leave( ret );
+ }
+ // Close Setting server session
+ settingServer.Close();
+
+ TFileName logFileName;
+
+ if( loggerSettings.iAddTestCaseTitle )
+ {
+ TName title;
+ TestModuleIf().GetTestCaseTitleL( title );
+ logFileName.Format( KUsbOtgWatcherTestLogFileWithTitle, &title );
+ }
+ else
+ {
+ logFileName.Copy( KUsbOtgWatcherTestLogFile );
+ }
+
+ iLog = CStifLogger::NewL( KUsbOtgWatcherTestLogPath,
+ logFileName,
+ CStifLogger::ETxt,
+ CStifLogger::EFile,
+ EFalse );
+
+ SendTestClassVersion();
+ TestConstructL();
+ }
+
+// -----------------------------------------------------------------------------
+// CtUsbOtgWatcher::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CtUsbOtgWatcher* CtUsbOtgWatcher::NewL(
+ CTestModuleIf& aTestModuleIf )
+ {
+ CtUsbOtgWatcher* self = new (ELeave) CtUsbOtgWatcher( aTestModuleIf );
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
+
+// Destructor
+CtUsbOtgWatcher::~CtUsbOtgWatcher()
+ {
+
+ // Delete resources allocated from test methods
+ TestDelete();
+
+ // Delete logger
+ delete iLog;
+
+ }
+
+// -----------------------------------------------------------------------------
+// CtUsbOtgWatcher::RunMethodL
+// Run specified method. Contains also table of test mothods and their names.
+// -----------------------------------------------------------------------------
+
+TInt CtUsbOtgWatcher::RunMethodL(
+ CStifItemParser& aItem )
+ {
+ return ExecuteTestBlock( aItem );
+ }
+
+// -----------------------------------------------------------------------------
+// CtUsbOtgWatcher::ExecuteTestBlock
+// -----------------------------------------------------------------------------
+
+TInt CtUsbOtgWatcher::ExecuteTestBlock( CStifItemParser& aItem )
+ {
+ TRACE_FUNC_ENTRY
+ iItem = &aItem;
+ TInt res;
+ TUsbOtgWatcherTestResult testResult = ETestCaseFailed;
+
+ res = iItem -> GetString( _L( "tester" ), iTestBlockParams.iTestBlockName );
+ if ( res != KErrNone )
+ {
+ TRACE_INFO( "Getting test block name failed with: %d", res )
+ TRACE_FUNC_EXIT
+ return res;
+ }
+ TRACE_INFO( "Test block name: %S", &iTestBlockParams.iTestBlockName )
+
+ TRACE( "Extracting test block parameters..." )
+ TRAP( res, TestBlocksInfoL() );
+ if ( res != KErrNone )
+ {
+ TRACE_INFO( "Extracting parameters failed: %d", res )
+ TRACE_FUNC_EXIT
+ return res;
+ }
+ if ( !iTestBlockFound )
+ {
+ TRACE( "Test block not found!" )
+ TRACE_FUNC_EXIT
+ return KErrNotFound;
+ }
+ TRACE( "Extracting parameters successful" )
+
+ TRAP( res, ( this ->*iTestBlockFunction )( iTestBlockParams, testResult ) );
+ if ( res != KErrNone )
+ {
+ TRACE_INFO( "ExecuteTestBlockL error: %d", res )
+ TRACE_FUNC_EXIT
+ return res;
+ }
+
+ if (ETestCasePassed != testResult)
+ {
+ return KErrGeneral;
+ }
+ TRACE( "Test block passed!" );
+ TRACE_FUNC_EXIT
+ return KErrNone;
+ }
+
+// -----------------------------------------------------------------------------
+// CtUsbOtgWatcher::GetTestBlockParamL
+// -----------------------------------------------------------------------------
+
+void CtUsbOtgWatcher::GetTestBlockParamL( TGetTestBlockParamOperation aOperation, TTestBlockParamName aParamName )
+ {
+ switch( aOperation )
+ {
+ case eGetString:
+ {
+ switch ( aParamName )
+ {
+ case eTestOption1:
+ {
+ User::LeaveIfError( iItem -> GetNextString( iTestBlockParams.iTestOption1 ) );
+ break;
+ }
+ case eTestOption2:
+ {
+ User::LeaveIfError( iItem -> GetNextString( iTestBlockParams.iTestOption2 ) );
+ break;
+ }
+ case eTestOption3:
+ {
+ User::LeaveIfError( iItem -> GetNextString( iTestBlockParams.iTestOption3 ) );
+ break;
+ }
+ default:
+ {
+ User::Leave( KErrArgument );
+ break;
+ }
+ }
+ break;
+ }
+ case eGetInt:
+ {
+ switch ( aParamName )
+ {
+ case eTestIntOption1:
+ {
+ User::LeaveIfError( iItem -> GetNextInt( iTestBlockParams.iTestIntOption1 ) );
+ break;
+ }
+ case eTestIntOption2:
+ {
+ User::LeaveIfError( iItem -> GetNextInt( iTestBlockParams.iTestIntOption2 ) );
+ break;
+ }
+ case eTestIntOption3:
+ {
+ User::LeaveIfError( iItem -> GetNextInt( iTestBlockParams.iTestIntOption3 ) );
+ break;
+ }
+ default:
+ {
+ User::Leave( KErrArgument );
+ break;
+ }
+ }
+ break;
+ }
+ case eGetChar:
+ {
+ switch ( aParamName )
+ {
+ case eTestCharOption1:
+ {
+ User::LeaveIfError( iItem -> GetNextChar( iTestBlockParams.iTestCharOption1 ) );
+ break;
+ }
+ case eTestCharOption2:
+ {
+ User::LeaveIfError( iItem -> GetNextChar( iTestBlockParams.iTestCharOption2 ) );
+ break;
+ }
+ case eTestCharOption3:
+ {
+ User::LeaveIfError( iItem -> GetNextChar( iTestBlockParams.iTestCharOption3 ) );
+ break;
+ }
+ default:
+ {
+ User::Leave( KErrArgument );
+ }
+ }
+ break;
+ }
+ default:
+ {
+ User::Leave( KErrArgument );
+ }
+ }
+ }
+
+//-----------------------------------------------------------------------------
+// CtUsbOtgWatcher::SendTestClassVersion
+// Method used to send version of test class
+//-----------------------------------------------------------------------------
+//
+void CtUsbOtgWatcher::SendTestClassVersion()
+ {
+ TVersion moduleVersion;
+ moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR;
+ moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR;
+ moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD;
+
+ TFileName moduleName;
+ moduleName = _L("UsbOtgWatcherTest.dll");
+
+ TBool newVersionOfMethod = ETrue;
+ TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod);
+ }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// LibEntryL is a polymorphic Dll entry point.
+// Returns: CScriptBase: New CScriptBase derived object
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CScriptBase* LibEntryL(
+ CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
+ {
+
+ return ( CScriptBase* ) CtUsbOtgWatcher::NewL( aTestModuleIf );
+
+ }
+
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/src/UsbOtgWatcherTestBlocks.cpp Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,703 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+// [INCLUDE FILES] - do not remove
+#include <e32svr.h>
+#include <StifParser.h>
+#include <Stiftestinterface.h>
+#include "UsbOtgWatcherTest.h"
+#include "testdebug.h"
+#include "panic.h"
+//#include "UsbWatcherInternalPSKeys.h"
+#include "mockusbman.h"
+#include "mockcusbnotifmanager.h"
+#include <usbpersonalityids.h>
+#include "cusbindicatornotifier.h"
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES
+
+// CONSTANTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CtUsbOtgWatcher::TestConstructL
+// Construct here all test resources for test methods.
+// Called from ConstructL.
+// -----------------------------------------------------------------------------
+
+void CtUsbOtgWatcher::TestConstructL()
+ {
+ TRACE_FUNC_ENTRY
+
+ iStubber = CStubber::NewL();
+
+ TRACE_FUNC_EXIT
+ }
+
+// -----------------------------------------------------------------------------
+// CtUsbOtgWatcher::TestDelete
+// Delete here all resources allocated and opened from test methods.
+// Called from destructor.
+// -----------------------------------------------------------------------------
+
+void CtUsbOtgWatcher::TestDelete()
+ {
+ TRACE_FUNC_ENTRY
+
+ delete iStubber;
+
+ TRACE_FUNC_EXIT
+ }
+
+// -----------------------------------------------------------------------------
+// CtUsbOtgWatcher::TestBlocksInfoL
+// Add new test block parameter entries below
+// -----------------------------------------------------------------------------
+
+void CtUsbOtgWatcher::TestBlocksInfoL()
+ {
+
+ TESTENTRY( "ExampleTestL", CtUsbOtgWatcher::ExampleTestL )
+ {
+ TESTPARAM( eGetString, eTestOption1 )
+ TESTPARAM( eGetString, eTestOption2 )
+ TESTPARAM( eGetInt, eTestIntOption1 )
+ TESTPARAM( eGetChar, eTestCharOption1 )
+ }
+
+ TESTENTRY( "SetupTearDown", CtUsbOtgWatcher::SetupTearDownL )
+ {
+ TESTPARAM( eGetString, eTestOption1 )
+ }
+
+ TESTENTRY( "PinOnTest_Success", CtUsbOtgWatcher::PinOnTest_SuccessL )
+ {
+ TESTPARAM( eGetString, eTestOption1 )
+ }
+
+ TESTENTRY( "PinOffTest_Success", CtUsbOtgWatcher::PinOffTest_SuccessL )
+ {
+ TESTPARAM( eGetString, eTestOption1 )
+ }
+
+ TESTENTRY( "PinOnTest_EmptyCable", CtUsbOtgWatcher::PinOnTest_EmptyCableL )
+ {
+ TESTPARAM( eGetString, eTestOption1 )
+ }
+
+ TESTENTRY( "PinOnTest_TryStartError", CtUsbOtgWatcher::PinOnTest_TryStartErrorL )
+ {
+ TESTPARAM( eGetString, eTestOption1 )
+ }
+
+ TESTENTRY( "PinOnTest_BusRequestError", CtUsbOtgWatcher::PinOnTest_BusRequestErrorL )
+ {
+ TESTPARAM( eGetString, eTestOption1 )
+ }
+
+ TESTENTRY( "DeviceAttached_BadHubPostion", CtUsbOtgWatcher::DeviceAttached_BadHubPostionL )
+ {
+ TESTPARAM( eGetString, eTestOption1 )
+ }
+
+ TESTENTRY( "DeviceAttached_TooMuchRequired", CtUsbOtgWatcher::DeviceAttached_TooMuchRequiredL )
+ {
+ TESTPARAM( eGetString, eTestOption1 )
+ }
+
+ TESTENTRY( "DeviceAttached_SupportedDevice", CtUsbOtgWatcher::DeviceAttached_SupportedDeviceL )
+ {
+ TESTPARAM( eGetString, eTestOption1 )
+ }
+
+ TESTENTRY( "DeviceDetached_SupportedDevice", CtUsbOtgWatcher::DeviceDetached_SupportedDeviceL )
+ {
+ TESTPARAM( eGetString, eTestOption1 )
+ }
+
+ TESTENTRY( "IndicatorNotifier_IndicatorActivateL", CtUsbOtgWatcher::IndicatorNotifier_IndicatorActivateL )
+ {
+ TESTPARAM( eGetString, eTestOption1 )
+ }
+ }
+
+// Add test block methods implementation here
+// -----------------------------------------------------------------------------
+// CtUsbOtgWatcher::ExampleTestL
+// -----------------------------------------------------------------------------
+
+void CtUsbOtgWatcher::ExampleTestL( TUsbOtgWatcherTestBlockParams& aParams,
+ TUsbOtgWatcherTestResult& aTestResult )
+ {
+ TRACE_FUNC_ENTRY
+
+ //iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, ETryStartAsync, 0, 0, _L8( "stub" ) ) );
+
+ if ( !aParams.iTestOption1.Compare( _L( "API" ) ) )
+ {
+ TRACE_INFO( "Api test option: %S", &aParams.iTestOption1 )
+ TRACE_INFO( "Api test sub-option: %S", &aParams.iTestOption2 )
+ TRACE_INFO( "Api test int option: %d", aParams.iTestIntOption1 )
+ TRACE_INFO( "Api test char option: %c", TText( aParams.iTestCharOption1 ) )
+ }
+ else if ( !aParams.iTestOption1.Compare( _L( "MODULE" ) ) )
+ {
+ TRACE_INFO( "Module test option: %S", &aParams.iTestOption1 )
+ TRACE_INFO( "Module test sub-option: %S", &aParams.iTestOption2 )
+ TRACE_INFO( "Module test int option: %d", aParams.iTestIntOption1 )
+ TRACE_INFO( "Module test char option: %c", TText( aParams.iTestCharOption1 ) )
+ }
+ else if ( !aParams.iTestOption1.Compare( _L( "BRANCH" ) ) )
+ {
+ TRACE_INFO( "Branch test option: %S", &aParams.iTestOption1 )
+ TRACE_INFO( "Branch test sub-option: %S", &aParams.iTestOption2 )
+ TRACE_INFO( "Branch test int option: %d", aParams.iTestIntOption1 )
+ TRACE_INFO( "Branch test char option: %c", TText( aParams.iTestCharOption1 ) )
+ }
+ else
+ {
+ TRACE( "Invalid test parameter" )
+ TRACE_FUNC_EXIT
+ User::Leave( KErrNotFound );
+ }
+
+ aTestResult = ETestCasePassed;
+ TRACE_FUNC_EXIT
+ }
+
+
+void CtUsbOtgWatcher::SetupTearDownL( TUsbOtgWatcherTestBlockParams& aParams,
+ TUsbOtgWatcherTestResult& aTestResult )
+ {
+ TRACE_FUNC_ENTRY;
+
+ TRACE( "Create classes of the state machine" );
+ SetupL();
+
+ TRACE( "Destroy classes of the state machine" );
+ TearDown();
+
+ aTestResult = ETestCasePassed;
+ }
+
+
+void CtUsbOtgWatcher::PinOnTest_SuccessL( TUsbOtgWatcherTestBlockParams& aParams,
+ TUsbOtgWatcherTestResult& aTestResult )
+ {
+ TRACE(">>CtUsbOtgWatcher::PinOnTest_SuccessL");
+
+ SetupL();
+
+ // Idpin observer should be subscribed
+ STIF_ASSERT_TRUE(iWatcher->IdPinObserver()->iObserver != NULL);
+
+ TRACE( "State machine initialized" );
+ CUsbStateHostAInitiate* aInitiate = (CUsbStateHostAInitiate*)(iWatcher->State(EUsbStateHostAInitiate));
+ STIF_ASSERT_NOT_NULL(aInitiate);
+
+ STIF_ASSERT_EQUALS(CUsbVBusObserver::EVBusDown, iWatcher->VBusObserver()->VBus());
+
+ TRACE( "Trigger pin on" );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EServiceState, 0, 0, _L8( "EUsbServiceIdle" ) ) );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EGetCurrentPersonalityId, 0, 0, _L8( "UsbPersonalityIdMTP" ) ) );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EServiceState, 0, 0, _L8( "EUsbServiceStarted" ) ) );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EServiceState, 0, 0, _L8( "EUsbServiceStarted" ) ) );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EGetCurrentPersonalityId, 0, 0, _L8( "UsbPersonalityIdMTP" ) ) );
+// iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EServiceState, 0, 0, _L8( "EUsbServiceStarted" ) ) );
+
+ STIF_ASSERT_NOT_LEAVES(iWatcher->IdPinObserver()->TriggerPinOnL());
+ TRACE_INFO("Status iWatcher->iUsbServiceControl->iStatus: %d",iWatcher->iUsbServiceControl->iStatus.Int());
+
+ iWatcher->iUsbServiceControl->RunL();
+
+ TRACE_INFO("iWatcher->IdPinObserver()->IsTestResultNoneError(): %d", iWatcher->IdPinObserver()->IsTestResultNoneError() ? 1 : 0 );
+ STIF_ASSERT_TRUE(iWatcher->IdPinObserver()->IsTestResultNoneError());
+
+ TRACE_INFO("iWatcher->VBusObserver()->iObserver: %d", iWatcher->VBusObserver()->iObserver ? 1 : 0 );
+ STIF_ASSERT_TRUE(iWatcher->VBusObserver()->iObserver != NULL);
+
+ TRACE_INFO("iWatcher->OtgStateObserver()->iObserver: %d", iWatcher->OtgStateObserver()->iObserver ? 1 : 0 );
+ STIF_ASSERT_TRUE(iWatcher->OtgStateObserver()->iObserver != NULL);
+
+ TRACE_INFO("iWatcher->BusActivityObserver()->iObserver: %d", iWatcher->BusActivityObserver()->iObserver ? 1 : 0 );
+ STIF_ASSERT_TRUE(iWatcher->BusActivityObserver()->iObserver != NULL);
+
+ TRACE_INFO("iWatcher->HostEventNotificationObserver()->iObserver: %d", iWatcher->HostEventNotificationObserver()->iObserver ? 1 : 0 );
+ STIF_ASSERT_TRUE(iWatcher->HostEventNotificationObserver()->iObserver != NULL);
+
+ TRACE_INFO("iWatcher->MessageNotificationObserver()->iObserver: %d", iWatcher->MessageNotificationObserver()->iObserver ? 1 : 0 );
+ STIF_ASSERT_TRUE(iWatcher->MessageNotificationObserver()->iObserver != NULL);
+
+ TRACE_INFO("CUsbVBusObserver::EVBusUp == iWatcher->VBusObserver()->VBus(): %d", CUsbVBusObserver::EVBusUp == iWatcher->VBusObserver()->VBus() ? 1 : 0 );
+ STIF_ASSERT_EQUALS(CUsbVBusObserver::EVBusUp, iWatcher->VBusObserver()->VBus());
+
+
+ TRACE( "Trigger vbus on" );
+ STIF_ASSERT_NOT_LEAVES(iWatcher->VBusObserver()->TriggerVBusUpL());
+
+ TRACE_INFO("iWatcher->VBusObserver()->IsTestResultNoneError(): %d", iWatcher->VBusObserver()->IsTestResultNoneError() ? 1 : 0 );
+ STIF_ASSERT_TRUE(iWatcher->VBusObserver()->IsTestResultNoneError());
+
+ STIF_ASSERT_EQUALS(CUsbVBusObserver::EVBusUp, iWatcher->VBusObserver()->VBus());
+
+ TRACE_INFO("iWatcher->CurrentHostState() == iWatcher->iStates[EUsbStateHostAInitiate]: %d", iWatcher->CurrentHostState() == iWatcher->iStates[EUsbStateHostAInitiate] ? 1 : 0 );
+ STIF_ASSERT_TRUE(iWatcher->CurrentHostState() == iWatcher->iStates[EUsbStateHostAInitiate]);
+
+ TRACE_INFO("aInitiate->iAttachmentTimer->IsActive(): %d", aInitiate->iAttachmentTimer->IsActive() ? 1 : 0 );
+ STIF_ASSERT_TRUE(aInitiate->iAttachmentTimer->IsActive());
+
+ TRACE_INFO("CUsbVBusObserver::EVBusUp == iWatcher->VBusObserver()->VBus(): %d", CUsbVBusObserver::EVBusUp == iWatcher->VBusObserver()->VBus() ? 1 : 0 );
+ STIF_ASSERT_EQUALS(CUsbVBusObserver::EVBusUp, iWatcher->VBusObserver()->VBus());
+
+// iUsbMan->StartCancel(iWatcher->iUsbServiceControl->iStatus);
+
+ TearDown();
+
+ aTestResult = ETestCasePassed;
+
+ TRACE("<<CtUsbOtgWatcher::PinOnTest_SuccessL");
+ }
+
+void CtUsbOtgWatcher::PinOffTest_SuccessL( TUsbOtgWatcherTestBlockParams& aParams,
+ TUsbOtgWatcherTestResult& aTestResult )
+ {
+ TRACE(">>CtUsbOtgWatcher::PinOffTest_SuccessL");
+ SetupL();
+
+ // Idpin observer should be subscribed
+ STIF_ASSERT_TRUE(iWatcher->IdPinObserver()->iObserver != NULL);
+
+ STIF_ASSERT_EQUALS(CUsbVBusObserver::EVBusDown, iWatcher->VBusObserver()->VBus());
+
+ TRACE( "Trigger pin on" );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, ETryStartAsync, 0, 0, _L8( "stub" ) ) );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EServiceState, 0, 0, _L8( "EUsbServiceIdle" ) ) );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EServiceState, 0, 0, _L8( "EUsbServiceStarted" ) ) );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EServiceState, 0, 0, _L8( "EUsbServiceStarted" ) ) );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EGetCurrentPersonalityId, 0, 0, _L8( "UsbPersonalityIdMTP" ) ) );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EGetCurrentPersonalityId, 0, 0, _L8( "UsbPersonalityIdMTP" ) ) );
+// iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EServiceState, 0, 0, _L8( "EUsbServiceStarted" ) ) );
+ iWatcher->IdPinObserver()->TriggerPinOnL();
+ iWatcher->iUsbServiceControl->RunL();
+
+ TRACE( "Trigger vbus on" );
+ iWatcher->VBusObserver()->TriggerVBusUpL();
+
+ STIF_ASSERT_TRUE(iWatcher->CurrentHostState() == iWatcher->iStates[EUsbStateHostAInitiate]);
+ STIF_ASSERT_EQUALS(CUsbVBusObserver::EVBusUp, iWatcher->VBusObserver()->VBus());
+// iUsbMan->StartCancel(iWatcher->iUsbServiceControl->iStatus);
+
+ TRACE( "Trigger vbus off" );
+ iWatcher->IdPinObserver()->TriggerPinOffL();
+ iWatcher->iUsbServiceControl->RunL();
+
+ STIF_ASSERT_TRUE(iWatcher->CurrentHostState() != NULL);
+
+ STIF_ASSERT_TRUE(iWatcher->CurrentHostState() != iWatcher->iStates[EUsbStateHostAInitiate]);
+ STIF_ASSERT_TRUE(iWatcher->VBusObserver()->IsTestResultNoneError());
+ STIF_ASSERT_TRUE(iWatcher->IdPinObserver()->IsTestResultNoneError());
+ STIF_ASSERT_TRUE(iWatcher->VBusObserver()->iObserver != NULL);
+ STIF_ASSERT_TRUE(iWatcher->OtgStateObserver()->iObserver != NULL);
+ STIF_ASSERT_TRUE(iWatcher->BusActivityObserver()->iObserver != NULL);
+ STIF_ASSERT_TRUE(iWatcher->HostEventNotificationObserver()->iObserver != NULL);
+ STIF_ASSERT_TRUE(iWatcher->MessageNotificationObserver()->iObserver != NULL);
+
+// iUsbMan->StartCancel(iWatcher->iUsbServiceControl->iStatus);
+ TearDown();
+
+ aTestResult = ETestCasePassed;
+
+ TRACE("<<CtUsbOtgWatcher::PinOffTest_SuccessL");
+ }
+
+void CtUsbOtgWatcher::PinOnTest_EmptyCableL( TUsbOtgWatcherTestBlockParams& aParams,
+ TUsbOtgWatcherTestResult& aTestResult )
+ {
+ TRACE(">>CtUsbOtgWatcher::PinOnTest_EmptyCable");
+ SetupL();
+
+ TRACE("State machine initialized");
+ CUsbStateHostAInitiate* aInitiate = (CUsbStateHostAInitiate*)(iWatcher->State(EUsbStateHostAInitiate));
+
+ TRACE( "Trigger pin on" );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, ETryStartAsync, 0, 0, _L8( "stub" ) ) );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EServiceState, 0, 0, _L8( "EUsbServiceStarted" ) ) );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EServiceState, 0, 0, _L8( "EUsbServiceStarted" ) ) );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EGetCurrentPersonalityId, 0, 0, _L8( "UsbPersonalityIdMTP" ) ) );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EGetCurrentPersonalityId, 0, 0, _L8( "UsbPersonalityIdMTP" ) ) );
+// iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EServiceState, 0, 0, _L8( "EUsbServiceStarted" ) ) );
+
+ STIF_ASSERT_NOT_LEAVES(iWatcher->IdPinObserver()->TriggerPinOnL());
+ iWatcher->iUsbServiceControl->RunL();
+
+ TRACE( "Trigger vbus on" );
+ STIF_ASSERT_NOT_LEAVES(iWatcher->VBusObserver()->TriggerVBusUpL());
+
+// STIF_ASSERT_TRUE(iWatcher->NotifManager()->GetUsbIconBlinking());
+
+ TRACE( "Trigger attachment timer elapsed" );
+ STIF_ASSERT_NOT_LEAVES(aInitiate->iAttachmentTimer->TriggerTimerElapsedL());
+ aInitiate->iAttachmentTimer->TriggerTimerElapsedL();
+ STIF_ASSERT_TRUE(aInitiate->iAttachmentTimer->IsTestResultNoneError());
+
+ STIF_ASSERT_TRUE(iWatcher->CurrentHostState() == iWatcher->iStates[EUsbStateHostHandleDropping]);
+ STIF_ASSERT_TRUE(KUsbUiNotifOtgError == iWatcher->iNotifManager->iCat);
+ STIF_ASSERT_TRUE(EUsbOtgErrorAttachTimedOut == iWatcher->iNotifManager->iNotifId);
+
+ STIF_ASSERT_TRUE(NULL != iWatcher->iNotifManager->iObserver);
+ STIF_ASSERT_FALSE(iWatcher->iNotifManager->iUsbIconBlinking);
+ STIF_ASSERT_FALSE(iWatcher->iNotifManager->iUsbIconShown);
+
+ STIF_ASSERT_EQUALS(CUsbVBusObserver::EVBusDown, iWatcher->VBusObserver()->VBus());
+ TearDown();
+
+ aTestResult = ETestCasePassed;
+
+ TRACE("<<CtUsbOtgWatcher::PinOnTest_EmptyCable");
+ }
+
+void CtUsbOtgWatcher::PinOnTest_TryStartErrorL( TUsbOtgWatcherTestBlockParams& aParams,
+ TUsbOtgWatcherTestResult& aTestResult )
+ {
+ TRACE(">>CtUsbOtgWatcher::PinOnTest_TryStartErrorL");
+
+ SetupL();
+
+ CUsbStateHostAInitiate* aInitiate = (CUsbStateHostAInitiate*)(iWatcher->State(EUsbStateHostAInitiate));
+ STIF_ASSERT_NOT_NULL(aInitiate);
+
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, ETryStartAsync, 0, 0, _L8( "stub" ) ) );
+ iWatcher->Usb().SetTryStartError(KErrGeneral);
+ STIF_ASSERT_PANIC(ECanNotStartUsbServices, iWatcher->IdPinObserver()->TriggerPinOnL());
+
+ TestModuleIf().SetExitReason( CTestModuleIf::ENormal, KErrNone );
+
+ TearDown();
+
+ aTestResult = ETestCasePassed;
+
+ TRACE("<<CtUsbOtgWatcher::PinOnTest_TryStartErrorL");
+ }
+
+void CtUsbOtgWatcher::PinOnTest_BusRequestErrorL( TUsbOtgWatcherTestBlockParams& aParams,
+ TUsbOtgWatcherTestResult& aTestResult )
+ {
+ TRACE(">>CtUsbOtgWatcher::PinOnTest_BusRequestErrorL");
+
+ SetupL();
+
+ CUsbStateHostAInitiate* aInitiate = (CUsbStateHostAInitiate*)(iWatcher->State(EUsbStateHostAInitiate));
+ STIF_ASSERT_NOT_NULL(aInitiate);
+
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, ETryStartAsync, 0, 0, _L8( "stub" ) ) );
+ iWatcher->Usb().SetBusRequestError(KErrGeneral);
+ STIF_ASSERT_PANIC(EBusRequestError, iWatcher->IdPinObserver()->TriggerPinOnL());
+
+ TestModuleIf().SetExitReason( CTestModuleIf::ENormal, KErrNone );
+
+ TearDown();
+
+ aTestResult = ETestCasePassed;
+
+ TRACE("<<CtUsbOtgWatcher::PinOnTest_BusRequestErrorL");
+ }
+
+void CtUsbOtgWatcher::DeviceAttached_BadHubPostionL( TUsbOtgWatcherTestBlockParams& aParams,
+ TUsbOtgWatcherTestResult& aTestResult )
+ {
+ TRACE(">>CtUsbOtgWatcher::DeviceAttached_BadHubPostionL");
+ SetupL();
+
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, ETryStartAsync, 0, 0, _L8( "stub" ) ) );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EServiceState, 0, 0, _L8( "EUsbServiceIdle" ) ) );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EServiceState, 0, 0, _L8( "EUsbServiceStarted" ) ) );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EServiceState, 0, 0, _L8( "EUsbServiceStarted" ) ) );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EGetCurrentPersonalityId, 0, 0, _L8( "UsbPersonalityIdMTP" ) ) );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EGetCurrentPersonalityId, 0, 0, _L8( "UsbPersonalityIdMTP" ) ) );
+// iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EServiceState, 0, 0, _L8( "EUsbServiceStarted" ) ) );
+
+ TRACE( "PinOn triggered" );
+ STIF_ASSERT_NOT_LEAVES(iWatcher->IdPinObserver()->TriggerPinOnL());
+ iWatcher->iUsbServiceControl->RunL();
+
+ TRACE( "Trigger vbus on" );
+ STIF_ASSERT_NOT_LEAVES(iWatcher->VBusObserver()->TriggerVBusUpL());
+
+ TRACE( "BadHubPosition triggered" );
+ STIF_ASSERT_NOT_LEAVES(iWatcher->MessageNotificationObserver()->TriggerBadHubPositionL());
+ TRACE( "BadHubPosition test result" );
+ STIF_ASSERT_TRUE(iWatcher->MessageNotificationObserver()->IsTestResultNoneError());
+
+ TRACE( "Poscondition check" );
+ STIF_ASSERT_TRUE(KUsbUiNotifOtgError == iWatcher->iNotifManager->iCat);
+ STIF_ASSERT_TRUE(EUsbOtgHubUnsupported == iWatcher->iNotifManager->iNotifId);
+ STIF_ASSERT_TRUE(NULL != iWatcher->iNotifManager->iObserver);
+
+ STIF_ASSERT_EQUALS(CUsbVBusObserver::EVBusDown, iWatcher->VBusObserver()->VBus());
+
+ TearDown();
+
+ aTestResult = ETestCasePassed;
+
+ TRACE("<<CtUsbOtgWatcher::DeviceAttached_BadHubPostionL");
+ }
+
+void CtUsbOtgWatcher::DeviceAttached_TooMuchRequiredL( TUsbOtgWatcherTestBlockParams& aParams,
+ TUsbOtgWatcherTestResult& aTestResult )
+ {
+ TRACE("<<CtUsbOtgWatcher::DeviceAttached_TooMuchRequiredL");
+ SetupL();
+
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, ETryStartAsync, 0, 0, _L8( "stub" ) ) );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EServiceState, 0, 0, _L8( "EUsbServiceIdle" ) ) );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EServiceState, 0, 0, _L8( "EUsbServiceStarted" ) ) );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EServiceState, 0, 0, _L8( "EUsbServiceStarted" ) ) );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EGetCurrentPersonalityId, 0, 0, _L8( "UsbPersonalityIdMTP" ) ) );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EGetCurrentPersonalityId, 0, 0, _L8( "UsbPersonalityIdMTP" ) ) );
+// iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EServiceState, 0, 0, _L8( "EUsbServiceStarted" ) ) );
+
+ TRACE( "PinOn triggered" );
+ STIF_ASSERT_NOT_LEAVES(iWatcher->IdPinObserver()->TriggerPinOnL());
+ iWatcher->iUsbServiceControl->RunL();
+
+ TRACE( "Trigger vbus on" );
+ STIF_ASSERT_NOT_LEAVES(iWatcher->VBusObserver()->TriggerVBusUpL());
+
+// STIF_ASSERT_TRUE(iWatcher->iNotifManager->GetUsbIconBlinking());
+ TDeviceEventInformation eventInfo;
+ eventInfo.iEventType = EDeviceAttachment;
+ eventInfo.iError = KErrBadPower;
+ TRACE( "Trigger device attched - KErrBadPower" );
+ iWatcher->HostEventNotificationObserver()->TriggerDeviceAttachedL(eventInfo);
+
+ STIF_ASSERT_TRUE(iWatcher->CurrentHostState() == iWatcher->iStates[EUsbStateHostDelayNotAttachedHandle]);
+// STIF_ASSERT_TRUE(iWatcher->CurrentHostState() == iWatcher->iStates[EUsbStateHostHandleDropping]);
+
+ STIF_ASSERT_EQUALS(CUsbVBusObserver::EVBusUp, iWatcher->VBusObserver()->VBus());
+
+// TRACE( "Trigger timer ETooMuchPowerRequiredTimer elapsed" );
+// CUsbStateHostHandle* stateHostHandle = (CUsbStateHostHandle*)iWatcher->CurrentHostState();
+// STIF_ASSERT_NOT_LEAVES( stateHostHandle->iTooMuchPowerTimer->TriggerTimerElapsedL() );
+
+// STIF_ASSERT_FALSE(iWatcher->iNotifManager->iUsbIconBlinking);
+// STIF_ASSERT_FALSE(iWatcher->iNotifManager->iUsbIconShown);
+
+// STIF_ASSERT_EQUALS(CUsbVBusObserver::EVBusDown, iWatcher->VBusObserver()->VBus());
+
+ TearDown();
+
+ aTestResult = ETestCasePassed;
+
+ TRACE("<<CtUsbOtgWatcher::DeviceAttached_TooMuchRequiredL");
+ }
+
+void CtUsbOtgWatcher::DeviceAttached_SupportedDeviceL( TUsbOtgWatcherTestBlockParams& aParams,
+ TUsbOtgWatcherTestResult& aTestResult )
+ {
+ TRACE(">>CtUsbOtgWatcher::DeviceAttached_SupportedDeviceL");
+
+ SetupL();
+
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, ETryStartAsync, 0, 0, _L8( "stub" ) ) );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EServiceState, 0, 0, _L8( "EUsbServiceIdle" ) ) );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EServiceState, 0, 0, _L8( "EUsbServiceStarted" ) ) );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EServiceState, 0, 0, _L8( "EUsbServiceStarted" ) ) );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EGetCurrentPersonalityId, 0, 0, _L8( "UsbPersonalityIdMTP" ) ) );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EGetCurrentPersonalityId, 0, 0, _L8( "UsbPersonalityIdMTP" ) ) );
+// iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EServiceState, 0, 0, _L8( "EUsbServiceStarted" ) ) );
+
+ iLog->Log(_L("PinOn triggered"));
+ STIF_ASSERT_NOT_LEAVES(iWatcher->IdPinObserver()->TriggerPinOnL());
+ iWatcher->iUsbServiceControl->RunL();
+ iLog->Log(_L("Trigger vbus on"));
+ STIF_ASSERT_NOT_LEAVES(iWatcher->VBusObserver()->TriggerVBusUpL());
+
+ TDeviceEventInformation eventInfo;
+ eventInfo.iEventType = EDeviceAttachment;
+ eventInfo.iError = 0;
+ iLog->Log(_L("Trigger device attached"));
+ iWatcher->HostEventNotificationObserver()->TriggerDeviceAttachedL(eventInfo);
+
+ eventInfo.iEventType = EDriverLoad;
+ eventInfo.iError = 0;
+ iLog->Log(_L("Trigger device driver loaded"));
+ iWatcher->HostEventNotificationObserver()->TriggerDriverLoadSuccessL(eventInfo);
+ STIF_ASSERT_TRUE(iWatcher->CurrentHostState() == iWatcher->iStates[EUsbStateHostAHost]);
+
+// STIF_ASSERT_FALSE(iWatcher->iNotifManager->iUsbIconBlinking);
+//
+// STIF_ASSERT_TRUE(iWatcher->iNotifManager->iUsbIconShown);
+
+ STIF_ASSERT_EQUALS(CUsbVBusObserver::EVBusUp, iWatcher->VBusObserver()->VBus());
+
+ TearDown();
+
+ aTestResult = ETestCasePassed;
+
+ TRACE("<<CtUsbOtgWatcher::DeviceAttached_SupportedDeviceL");
+ }
+
+void CtUsbOtgWatcher::DeviceDetached_SupportedDeviceL( TUsbOtgWatcherTestBlockParams& aParams,
+ TUsbOtgWatcherTestResult& aTestResult )
+ {
+ TRACE(">>CtUsbOtgWatcher::DeviceDetached_SupportedDeviceL");
+
+ SetupL();
+
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, ETryStartAsync, 0, 0, _L8( "stub" ) ) );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EServiceState, 0, 0, _L8( "EUsbServiceIdle" ) ) );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EServiceState, 0, 0, _L8( "EUsbServiceStarted" ) ) );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EServiceState, 0, 0, _L8( "EUsbServiceStarted" ) ) );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EGetCurrentPersonalityId, 0, 0, _L8( "UsbPersonalityIdMTP" ) ) );
+ iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EGetCurrentPersonalityId, 0, 0, _L8( "UsbPersonalityIdMTP" ) ) );
+// iStubber -> EnqueBehavior( TApiBehavior( KUsbManStubAgentDll, EServiceState, 0, 0, _L8( "EUsbServiceStarted" ) ) );
+
+ TRACE( "PinOn triggered" );
+ STIF_ASSERT_NOT_LEAVES(iWatcher->IdPinObserver()->TriggerPinOnL());
+ iWatcher->iUsbServiceControl->RunL();
+ TRACE( "Trigger vbus on" );
+ STIF_ASSERT_NOT_LEAVES(iWatcher->VBusObserver()->TriggerVBusUpL());
+
+ TDeviceEventInformation eventInfo;
+ eventInfo.iEventType = EDeviceAttachment;
+ eventInfo.iError = 0;
+ TRACE( "Trigger device attached" );
+ iWatcher->HostEventNotificationObserver()->TriggerDeviceAttachedL(eventInfo);
+
+ eventInfo.iEventType = EDriverLoad;
+ eventInfo.iError = 0;
+ TRACE( "Trigger device driver loaded" );
+ iWatcher->HostEventNotificationObserver()->TriggerDriverLoadSuccessL(eventInfo);
+
+ eventInfo.iEventType = EDeviceDetachment;
+ eventInfo.iError = 0;
+ TRACE( "Trigger device detached" );
+ iWatcher->HostEventNotificationObserver()->TriggerDeviceDetachedL(eventInfo);
+
+ STIF_ASSERT_TRUE(iWatcher->CurrentHostState() == iWatcher->iStates[EUsbStateHostAInitiate]);
+
+// STIF_ASSERT_TRUE(iWatcher->iNotifManager->iUsbIconBlinking);
+
+ STIF_ASSERT_EQUALS(CUsbVBusObserver::EVBusUp, iWatcher->VBusObserver()->VBus());
+
+ TearDown();
+
+ aTestResult = ETestCasePassed;
+
+ TRACE("<<CtUsbOtgWatcher::DeviceDetached_SupportedDeviceL");
+ }
+
+void CtUsbOtgWatcher::IndicatorNotifier_IndicatorActivateL( TUsbOtgWatcherTestBlockParams& aParams,
+ TUsbOtgWatcherTestResult& aTestResult )
+ {
+ TRACE(">> IndicatorNotifier_IndicatorActivateL");
+
+ SetupL();
+
+ CUsbNotifManager* notifManager = CUsbNotifManager::NewL(*iWatcher);
+ CleanupStack::PushL(notifManager);
+ CUsbIndicatorNotifier* notifier = CUsbIndicatorNotifier::NewL(*notifManager, *iWatcher);
+ CleanupStack::PushL(notifier);
+
+ notifier->ToggleConnectingIndicator(ETrue);
+
+ STIF_ASSERT_TRUE(notifier->iConnectingIndicatorOn);
+
+ CleanupStack::PopAndDestroy(2);
+
+ TearDown();
+
+ aTestResult = ETestCasePassed;
+ TRACE("<< IndicatorNotifier_IndicatorActivateL");
+ }
+
+// Add other member functions implementation here
+
+void CtUsbOtgWatcher::SetupL()
+ {
+ TRACE_FUNC_ENTRY;
+
+ TRACE( "UsbMan initialization" );
+ iUsbMan = RUsb::NewL();
+ User::LeaveIfNull(iUsbMan);
+ TInt err;
+
+ TUsbServiceState serviceState;
+ //set service state
+ iUsbMan->SetUsbServiceState(EUsbServiceIdle);
+
+ err = iUsbMan->GetServiceState(serviceState);
+ TRACE_INFO( "UsbMan.GetServiceState err: %d", err );
+ User::LeaveIfError(err);
+
+ TRACE_INFO( "UsbMan.GetServiceState serviceState: %d, exspected: %d", serviceState, EUsbServiceIdle );
+ if(serviceState != EUsbServiceIdle)
+ {
+ TRACE("UsbMan ServiceState didn't set properly!");
+ User::Leave(KErrNotFound);
+ }
+
+ TRACE( "UsbOtgWatcher initialization" );
+ iWatcher = CUsbOtgWatcher::NewL(*iUsbMan);
+ if( !iWatcher )
+ {
+ TRACE("CUsbOtgWatcher::NewL Failed!");
+ User::LeaveIfNull(iWatcher);
+ }
+
+ iWatcher->VBusObserver()->SetRUsb(iUsbMan);
+
+ TRACE_FUNC_EXIT;
+ }
+
+void CtUsbOtgWatcher::TearDown()
+ {
+ TRACE_FUNC_ENTRY;
+
+ TRACE("delete iWatcher");
+ if (iWatcher)
+ delete iWatcher;
+
+ TRACE("delete iUsbMan");
+ if (iUsbMan)
+ delete iUsbMan;
+
+ TRACE_FUNC_EXIT;
+ }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+// None
+
+// [End of File] - Do not remove
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/src/UsbOtgWatcherTest_exe.cpp Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <e32svr.h>
+#include <StifTestInterface.h>
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES
+
+// ================= OTHER EXPORTED FUNCTIONS =================================
+
+/*
+-------------------------------------------------------------------------------
+
+ Class: -
+
+ Method: E32Main
+
+ Description:
+
+ Parameters: None
+
+ Return Values: TInt: Symbian error code
+
+ Errors/Exceptions: None
+
+ Status: Draft
+
+-------------------------------------------------------------------------------
+*/
+GLDEF_C TInt E32Main()
+ {
+ _LIT( KProcessMsgStart, "New process starting" );
+ RDebug::Print( KProcessMsgStart );
+
+
+ // This starts a new session that get capabilites that is used in
+ // UsbOtgWatcherTest_exe.mmp file.
+ TInt r = StartSession();
+
+ _LIT( KProcessMsgEnd, "New process ends" );
+ RDebug::Print( KProcessMsgEnd );
+
+ return r;
+
+ }
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/src/mockchbindicatorsymbian.cpp Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,80 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#include <hb/hbcore/hbindicatorsymbian.h>
+#include "debug.h"
+
+EXPORT_C CHbIndicatorSymbian* CHbIndicatorSymbian::NewL()
+ {
+ CHbIndicatorSymbian *me = new CHbIndicatorSymbian();
+ me->ConstructL();
+ return me;
+ }
+
+EXPORT_C CHbIndicatorSymbian::~CHbIndicatorSymbian()
+{
+ delete d;
+}
+
+/*!
+ Activates an indicator of type \a aIndicatorType.
+ An extra parameter can be passed along to the indicator plugin.
+ Returns true, if the indicator is activated, false, if an error occurred.
+
+ \sa Deactivate
+ */
+EXPORT_C TBool CHbIndicatorSymbian::Activate(const TDesC& aIndicatorType, const CHbSymbianVariant* aParameter)
+{
+ LOG( (" MockCHbIndicatorSymbian::Activate"));
+ return true;
+}
+
+/*!
+ Deactivates an indicator of type \a indicatorType.
+ An extra parameter can be passed along to the indicator plugin.
+ If indicator is not currently active, does nothing and returns true.
+ Returns false, if error occurred.
+
+ \sa Activate
+ */
+EXPORT_C TBool CHbIndicatorSymbian::Deactivate(const TDesC& aIndicatorType, const CHbSymbianVariant* aParameter)
+{
+ return true;
+}
+
+/*!
+ Returns the last error code. The code is cleared when any other API function than error() is called.
+*/
+EXPORT_C TInt CHbIndicatorSymbian::Error() const
+{
+ return 0;
+}
+
+EXPORT_C void CHbIndicatorSymbian::SetObserver(MHbIndicatorSymbianObserver* aObserver)
+{
+
+}
+
+CHbIndicatorSymbian::CHbIndicatorSymbian()
+{
+}
+
+void CHbIndicatorSymbian::ConstructL()
+{
+
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/src/mockcusbbusactivityobserver.cpp Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,104 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include <e32base.h>
+#include <NormalHardcodedAssert.h>
+
+#include "stifassertmacros.h"
+
+#include "mockcusbbusactivityobserver.h"
+
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+// ?description_if_needed
+// ---------------------------------------------------------------------------
+//
+CUsbBusActivityObserver::CUsbBusActivityObserver() :
+ iBusActivity(0)
+ {
+ }
+
+// ---------------------------------------------------------------------------
+// ?description_if_needed
+// ---------------------------------------------------------------------------
+//
+void CUsbBusActivityObserver::ConstructL()
+ {
+ }
+
+CUsbBusActivityObserver* CUsbBusActivityObserver::NewL()
+ {
+ LOG( "[USBOTGWATCHER]\tMockCUsbBusActivityObserver::NewL" );
+
+ CUsbBusActivityObserver* self = new( ELeave ) CUsbBusActivityObserver();
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+// ?description_if_needed
+// ---------------------------------------------------------------------------
+//
+CUsbBusActivityObserver::~CUsbBusActivityObserver()
+ {
+ LOG( ( "[USBOTGWATCHER]\tMockCUsbBusActivityObserver::~CUsbBusActivityObserver" ) );
+ }
+
+// ---------------------------------------------------------------------------
+// ?description_if_needed
+// ---------------------------------------------------------------------------
+//
+CUsbBusActivityObserver::TBusActivity CUsbBusActivityObserver::BusActivity()
+ {
+ LOG1( "[USBOTGWATCHER]\tMockCUsbBusActivityObserver::State = %d", iBusActivity);
+
+ return (0 == iBusActivity ? EBusActive : EBusIdle);
+ }
+
+void CUsbBusActivityObserver::SubscribeL(MUsbBusActivityObserver& aObserver)
+ {
+ LOG( ("[USBOTGWATCHER]\tMockCUsbBusActivityObserver::SubscribeL"));
+ STIF_ASSERT_NOT_NULL(&aObserver);
+
+ iObserver = &aObserver;
+ }
+
+void CUsbBusActivityObserver::UnsubscribeL(MUsbBusActivityObserver& aObserver)
+ {
+ LOG( ("[USBOTGWATCHER]\tMockCUsbBusActivityObserver::UnsubscribeL"));
+ STIF_ASSERT_NOT_NULL(&aObserver);
+
+ iObserver = NULL;
+ }
+
+void CUsbBusActivityObserver::TriggerBusIdleL()
+ {
+ STIF_ASSERT_NOT_NULL(iObserver);
+
+ iObserver->BusIdleL();
+ }
+
+void CUsbBusActivityObserver::TriggerBusActiveL()
+ {
+ STIF_ASSERT_NOT_NULL(iObserver);
+
+ iObserver->BusActiveL();
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/src/mockcusbhosteventnotificationobserver.cpp Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,125 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include <e32base.h>
+#include <NormalHardcodedAssert.h>
+
+#include "stifassertmacros.h"
+
+#include "mockcusbhosteventnotificationobserver.h"
+
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+// ?description_if_needed
+// ---------------------------------------------------------------------------
+//
+CUsbHostEventNotificationObserver::CUsbHostEventNotificationObserver(
+ RUsb* aUsb) :
+ iUsb(aUsb)
+ {
+ }
+
+// ---------------------------------------------------------------------------
+// ?description_if_needed
+// ---------------------------------------------------------------------------
+//
+void CUsbHostEventNotificationObserver::ConstructL()
+ {
+ }
+
+CUsbHostEventNotificationObserver* CUsbHostEventNotificationObserver::NewL(
+ RUsb* aUsb)
+ {
+ LOG(( "[USBOTGWATCHER]\tMockCUsbHostEventNotificationObserver::NewL" ) );
+
+ CUsbHostEventNotificationObserver* self = new( ELeave ) CUsbHostEventNotificationObserver(aUsb);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+// ?description_if_needed
+// ---------------------------------------------------------------------------
+//
+CUsbHostEventNotificationObserver::~CUsbHostEventNotificationObserver()
+ {
+ LOG(( "[USBOTGWATCHER]\tMockCUsbHostEventNotificationObserver::~CUsbHostEventNotificationObserver" ) );
+ }
+
+void CUsbHostEventNotificationObserver::SubscribeL(
+ MUsbHostEventNotificationObserver& aObserver)
+ {
+ LOG(("[USBOTGWATCHER]\tMockCUsbHostEventNotificationObserver::SubscribeL"));
+ STIF_ASSERT_NOT_NULL(&aObserver);
+
+ iObserver = &aObserver;
+ }
+
+void CUsbHostEventNotificationObserver::UnsubscribeL(
+ MUsbHostEventNotificationObserver& aObserver)
+ {
+ LOG(("[USBOTGWATCHER]\tMockCUsbHostEventNotificationObserver::UnsubscribeL"));
+ STIF_ASSERT_NOT_NULL(&aObserver);
+
+ iObserver = NULL;
+ }
+
+void CUsbHostEventNotificationObserver::TriggerDeviceAttachedL(TDeviceEventInformation eventInfo)
+ {
+ STIF_ASSERT_NOT_NULL(iObserver);
+
+ //.iEventType = EDeviceAttachment
+ iObserver->DeviceAttachedL(eventInfo);
+
+ }
+
+void CUsbHostEventNotificationObserver::TriggerDeviceDetachedL(TDeviceEventInformation eventInfo)
+ {
+ STIF_ASSERT_NOT_NULL(iObserver);
+
+ //.iEventType = EDeviceDetachment
+ iObserver->DeviceDetachedL(eventInfo);
+ }
+
+void CUsbHostEventNotificationObserver::TriggerDriverLoadSuccessL(TDeviceEventInformation eventInfo)
+ {
+ STIF_ASSERT_NOT_NULL(iObserver);
+
+ //.iEventType = EDriverLoad, .iDriverLoadStatus = EDriverLoadSuccess
+ iObserver->DriverLoadSuccessL(eventInfo);
+ }
+
+void CUsbHostEventNotificationObserver::TriggerDriverLoadPartialSuccessL(TDeviceEventInformation eventInfo)
+ {
+ STIF_ASSERT_NOT_NULL(iObserver);
+
+ //.iEventType = EDriverLoad, .iDriverLoadStatus = EDriverLoadPartialSuccess
+ iObserver->DriverLoadPartialSuccessL(eventInfo);
+ }
+
+void CUsbHostEventNotificationObserver::TriggerDriverLoadFailureL(TDeviceEventInformation eventInfo)
+ {
+ STIF_ASSERT_NOT_NULL(iObserver);
+
+ //.iEventType = EDriverLoad, .iDriverLoadStatus = EDriverLoadFailure
+ iObserver->DriverLoadFailureL(eventInfo);
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/src/mockcusbidpinobserver.cpp Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,112 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include <usbotgdefs.h>
+#include <NormalHardcodedAssert.h>
+
+#include "stifassertmacros.h"
+#include "mockcusbidpinobserver.h"
+
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+// ?description_if_needed
+// ---------------------------------------------------------------------------
+//
+CUsbIdPinObserver::CUsbIdPinObserver() : iIdPinOn(EFalse)
+ {
+ }
+
+
+// ---------------------------------------------------------------------------
+// ?description_if_needed
+// ---------------------------------------------------------------------------
+//
+void CUsbIdPinObserver::ConstructL()
+ {
+ iWait = new ( ELeave )CActiveSchedulerWait();
+ }
+
+CUsbIdPinObserver* CUsbIdPinObserver::NewL()
+ {
+ LOG( "[USBOTGWATCHER]\tMockCUsbIdPinObserver::NewL" );
+
+ CUsbIdPinObserver* self = new( ELeave ) CUsbIdPinObserver();
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop( self );
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+// ?description_if_needed
+// ---------------------------------------------------------------------------
+//
+CUsbIdPinObserver::~CUsbIdPinObserver()
+ {
+ LOG( ( "[USBOTGWATCHER]\tMockCUsbIdPinObserver::~CUsbIdPinObserver" ) );
+ }
+
+// ---------------------------------------------------------------------------
+// ?description_if_needed
+// ---------------------------------------------------------------------------
+//
+CUsbIdPinObserver::TState CUsbIdPinObserver::IdPin() /* const! But for some reason RProperty::Get is not const! */
+ {
+ // not found in Symbian docs clear definition of this property. Verification is needed
+ return (0 == iIdPinOn? EIdPinOff : EIdPinOn);
+ }
+
+
+void CUsbIdPinObserver::SubscribeL(MUsbIdPinObserver& aObserver)
+ {
+ //iLog->Log(_L("[USBOTGWATCHER] >>MockCUsbIdPinObserver::SubscribeL"));
+ LOG(("[USBOTGWATCHER]\tMockCUsbIdPinObserver::SubscribeL"));
+ STIF_ASSERT_NOT_NULL(&aObserver);
+
+ iObserver = &aObserver;
+
+ //iLog->Log(_L("[USBOTGWATCHER] <<MockCUsbIdPinObserver::SubscribeL"));
+ }
+
+void CUsbIdPinObserver::UnsubscribeL(MUsbIdPinObserver& aObserver)
+ {
+ LOG(("[USBOTGWATCHER]\tMockCUsbIdPinObserver::UnsubscribeL"));
+ STIF_ASSERT_NOT_NULL(&aObserver);
+
+ iObserver = NULL;
+ }
+
+void CUsbIdPinObserver::TriggerPinOnL()
+ {
+ LOG(("[USBOTGWATCHER]\tMockCUsbIdPinObserver::TriggerPinOn"));
+ STIF_ASSERT_NOT_NULL(iObserver);
+
+ iIdPinOn = 1;
+ iObserver->IdPinOnL();
+ LOG(("[USBOTGWATCHER] <<MockCUsbIdPinObserver::TriggerPinOn"));
+ }
+
+void CUsbIdPinObserver::TriggerPinOffL()
+ {
+ LOG(("[USBOTGWATCHER]\tMockCUsbIdPinObserver::TriggerPinOff"));
+ STIF_ASSERT_NOT_NULL(iObserver);
+
+ iIdPinOn = 0;
+ iObserver->IdPinOffL();
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/src/mockcusbmessagenotificationobserver.cpp Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,123 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include <e32base.h>
+#include <NormalHardcodedAssert.h>
+
+#include "stifassertmacros.h"
+
+#include "mockcusbmessagenotificationobserver.h"
+
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+// ?description_if_needed
+// ---------------------------------------------------------------------------
+//
+CUsbMessageNotificationObserver::CUsbMessageNotificationObserver(RUsb* aUsb) :
+ iUsb(aUsb)
+ {
+ }
+
+// ---------------------------------------------------------------------------
+// ?description_if_needed
+// ---------------------------------------------------------------------------
+//
+void CUsbMessageNotificationObserver::ConstructL()
+ {
+ }
+
+CUsbMessageNotificationObserver* CUsbMessageNotificationObserver::NewL(
+ RUsb* aUsb)
+ {
+ LOG( ( "[USBOTGWATCHER]\tMockCUsbMessageNotificationObserver::NewL" ) );
+
+ CUsbMessageNotificationObserver* self = new( ELeave ) CUsbMessageNotificationObserver(aUsb);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+// ?description_if_needed
+// ---------------------------------------------------------------------------
+//
+CUsbMessageNotificationObserver::~CUsbMessageNotificationObserver()
+ {
+ LOG( ( "[USBOTGWATCHER]\tMockCUsbMessageNotificationObserver::~CUsbMessageNotificationObserver" ) );
+ }
+
+void CUsbMessageNotificationObserver::SubscribeL(
+ MUsbMessageNotificationObserver& aObserver)
+ {
+ LOG( ("[USBOTGWATCHER]\tMockCUsbMessageNotificationObserver::SubscribeL"));
+ STIF_ASSERT_NOT_NULL(&aObserver);
+
+ iObserver = &aObserver;
+ }
+
+void CUsbMessageNotificationObserver::UnsubscribeL(
+ MUsbMessageNotificationObserver& aObserver)
+ {
+ LOG( ("[USBOTGWATCHER]\tMockCUsbMessageNotificationObserver::UnsubscribeL"));
+ STIF_ASSERT_NOT_NULL(&aObserver);
+
+ iObserver = NULL;
+ }
+
+void CUsbMessageNotificationObserver::TriggerMessageNotificationReceivedL(
+ TInt aMessage)
+ {
+ STIF_ASSERT_NOT_NULL(iObserver);
+
+ // default, others
+ iObserver->MessageNotificationReceivedL(aMessage);
+ }
+
+void CUsbMessageNotificationObserver::TriggerBadHubPositionL()
+ {
+ STIF_ASSERT_NOT_NULL(iObserver);
+
+ //KErrUsbBadHubPosition
+ iObserver->BadHubPositionL();
+ }
+
+void CUsbMessageNotificationObserver::TriggerVBusErrorL()
+ {
+ STIF_ASSERT_NOT_NULL(iObserver);
+
+ //KErrUsbOtgVbusError
+ iObserver->VBusErrorL();
+ }
+
+void CUsbMessageNotificationObserver::TriggerSrpReceivedL()
+ {
+ STIF_ASSERT_NOT_NULL(iObserver);
+
+ //KUsbMessageSrpReceived
+ iObserver->SrpReceivedL();
+ }
+
+void CUsbMessageNotificationObserver::TriggerSessionRequestedL()
+ {
+ STIF_ASSERT_NOT_NULL(iObserver);
+
+ //KUsbMessageRequestSession
+ iObserver->SessionRequestedL();
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/src/mockcusbnotifmanager.cpp Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,113 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include <usbuinotif.h>
+#include <NormalHardcodedAssert.h>
+
+#include "stifassertmacros.h"
+
+#include "mockcusbnotifmanager.h"
+
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+// ?description_if_needed
+// ---------------------------------------------------------------------------
+//
+CUsbNotifManager::CUsbNotifManager() :
+ iNotifId(INVALID_VALUE),
+ iObserver(INVALID_VALUE),
+ iUsbIconBlinking(EFalse),
+ iUsbIconShown(EFalse)
+ {
+ iCat.iUid = INVALID_VALUE;
+ }
+
+// ---------------------------------------------------------------------------
+// ?description_if_needed
+// ---------------------------------------------------------------------------
+//
+void CUsbNotifManager::ConstructL()
+ {
+ LOG( ( "[USBOTGWATCHER]\tMockCUsbNotifManager::ConstructL" ) );
+
+ }
+
+CUsbNotifManager* CUsbNotifManager::NewL(CUsbOtgWatcher& aOtgWatcher)
+ {
+ LOG( ( "[USBOTGWATCHER]\tMockCUsbNotifManager::NewL" ) );
+
+ CUsbNotifManager* self = new( ELeave ) CUsbNotifManager();
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop( self );
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+// ?description_if_needed
+// ---------------------------------------------------------------------------
+//
+CUsbNotifManager::~CUsbNotifManager()
+ {
+ LOG( ( "[USBOTGWATCHER]\tMockCUsbNotifManager::~CUsbNotifManager" ) );
+
+ }
+
+// ---------------------------------------------------------------------------
+// ?description_if_needed
+// ---------------------------------------------------------------------------
+//
+void CUsbNotifManager::ShowNotifierL(TUid aCat, TUint aNotifId, MWaitNotifierObserver* aObserver )
+{
+ LOG3 ("[USBOTGWATCHER]\tMockCUsbNotifManager::ShowNotifier aCat = 0x%X aNotifId = %d, aObserver=0x%X", aCat, aNotifId, aObserver);
+ iCat = aCat;
+ iNotifId = aNotifId;
+ iObserver = aObserver;
+}
+
+void CUsbNotifManager::BlinkIndicatorL(TBool aBlinking)
+ {
+ LOG1 ( "[USBOTGWATCHER]\tMockCUsbNotifManager::BlinkIndicatorL, aBlinking=%d", aBlinking);
+
+ iUsbIconBlinking = aBlinking;
+ }
+
+void CUsbNotifManager::ShowIndicatorL(TBool aVisible)
+ {
+ LOG1 ( "[USBOTGWATCHER]\tMockCUsbNotifManager::ShowIndicatorL, aVisible=%d", aVisible);
+
+ iUsbIconShown = aVisible;
+ iUsbIconBlinking = EFalse;
+ }
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void CUsbNotifManager::NotifierShowCompletedL(CUsbNotifier& aWaitNotifier, TInt aResult, TInt aFeedback)
+{
+ LOG1 ( "[USBOTGWATCHER]\tMockCUsbNotifManager::NotifierShowCompleted aResult = %d", aResult);
+
+}
+
+void CUsbNotifManager::CloseAllNotifiers()
+{
+ LOG( ( "[USBOTGWATCHER]\tMockCUsbNotifManager::CloseAllNotifiers" ) );
+
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/src/mockcusbotgstateobserver.cpp Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,145 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include <e32base.h>
+#include <NormalHardcodedAssert.h>
+
+#include "stifassertmacros.h"
+
+#include "mockcusbotgstateobserver.h"
+
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+// ?description_if_needed
+// ---------------------------------------------------------------------------
+//
+CUsbOtgStateObserver::CUsbOtgStateObserver()
+ {
+ }
+
+// ---------------------------------------------------------------------------
+// ?description_if_needed
+// ---------------------------------------------------------------------------
+//
+void CUsbOtgStateObserver::ConstructL()
+ {
+ }
+
+CUsbOtgStateObserver* CUsbOtgStateObserver::NewL()
+ {
+ LOG(("[USBOTGWATCHER]\tMockCUsbOtgStateObserver::NewL" ));
+
+ CUsbOtgStateObserver* self = new( ELeave ) CUsbOtgStateObserver();
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+// ?description_if_needed
+// ---------------------------------------------------------------------------
+//
+CUsbOtgStateObserver::~CUsbOtgStateObserver()
+ {
+ LOG(("[USBOTGWATCHER]\tMockCUsbOtgStateObserver::~CUsbOtgStateObserver" ));
+ }
+
+// ---------------------------------------------------------------------------
+// ?description_if_needed
+// ---------------------------------------------------------------------------
+//
+TUsbOtgState CUsbOtgStateObserver::OtgState()
+ {
+ return (TUsbOtgState)iOtgState;
+ }
+
+void CUsbOtgStateObserver::SubscribeL(MUsbOtgStateObserver& aObserver)
+ {
+ LOG(("[USBOTGWATCHER]\tMockCUsbOtgStateObserver::SubscribeL"));
+ STIF_ASSERT_NOT_NULL(&aObserver);
+
+ iObserver = &aObserver;
+ }
+
+void CUsbOtgStateObserver::UnsubscribeL(MUsbOtgStateObserver& aObserver)
+ {
+ LOG(("[USBOTGWATCHER]\tMockCUsbOtgStateObserver::UnsubscribeL"));
+ STIF_ASSERT_NOT_NULL(&aObserver);
+
+ iObserver = NULL;
+ }
+
+//ignore EUsbOtgStateReset
+
+void CUsbOtgStateObserver::TriggerAIdleL()
+ {
+ STIF_ASSERT_NOT_NULL(iObserver);
+
+ //EUsbOtgStateAIdle
+ iObserver->AIdleL();
+ }
+
+void CUsbOtgStateObserver::TriggerAHostL()
+ {
+ STIF_ASSERT_NOT_NULL(iObserver);
+
+ //EUsbOtgStateAHost
+ iObserver->AHostL();
+ }
+
+void CUsbOtgStateObserver::TriggerAPeripheralL()
+ {
+ STIF_ASSERT_NOT_NULL(iObserver);
+
+ //EUsbOtgStateAPeripheral
+ iObserver->APeripheralL();
+ }
+
+void CUsbOtgStateObserver::TriggerAVBusErrorL()
+ {
+ STIF_ASSERT_NOT_NULL(iObserver);
+
+ //EUsbOtgStateAVbusError
+ iObserver->AVBusErrorL();
+ }
+
+void CUsbOtgStateObserver::TriggerBIdleL()
+ {
+ STIF_ASSERT_NOT_NULL(iObserver);
+
+ //EUsbOtgStateBIdle
+ iObserver->BIdleL();
+ }
+
+void CUsbOtgStateObserver::TriggerBPeripheralL()
+ {
+ STIF_ASSERT_NOT_NULL(iObserver);
+
+ //EUsbOtgStateBPeripheral
+ iObserver->BPeripheralL();
+ }
+
+void CUsbOtgStateObserver::TriggerBHostL()
+ {
+ STIF_ASSERT_NOT_NULL(iObserver);
+
+ //EUsbOtgStateBHost
+ iObserver->BHostL();
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/src/mockcusbtimer.cpp Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,78 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include <e32base.h>
+#include <NormalHardcodedAssert.h>
+
+#include "stifassertmacros.h"
+
+#include "mockcusbtimer.h"
+
+#include "debug.h"
+
+CUsbTimer::CUsbTimer(MUsbTimerObserver& aObserver, TUsbTimerId aTimerId) :
+ iObserver(&aObserver),
+ iActive(EFalse),
+ iTimerId(aTimerId)
+ {
+ }
+
+CUsbTimer::~CUsbTimer()
+ {
+ LOG( ( "[USBOTGWATCHER]\tMockCUsbTimer::~CUsbTimer" ) );
+ }
+
+void CUsbTimer::ConstructL()
+ {
+ }
+
+CUsbTimer* CUsbTimer::NewL(MUsbTimerObserver& anObserver, TUsbTimerId aTimerId)
+ {
+ LOG( ( "[USBOTGWATCHER]\tMockCUsbTimer::NewL" ) );
+
+ CUsbTimer* self = new ( ELeave ) CUsbTimer(anObserver, aTimerId);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(); // pop self
+ return self;
+ }
+
+void CUsbTimer::After(TInt aMilliseconds)
+ {
+ LOG1 ( "[USBOTGWATCHER]\tMockCUsbTimer::After aMilliseconds %d", aMilliseconds);
+ iActive = ETrue;
+ }
+
+void CUsbTimer::Cancel()
+ {
+ }
+
+TBool CUsbTimer::IsActive()
+ {
+ return iActive;
+ }
+
+void CUsbTimer::TriggerTimerElapsedL()
+ {
+ //STIF_ASSERT_NOT_NULL(iObserver);
+ LOG1( "[USBOTGWATCHER]\tMockCUsbTimer::TriggerTimerElapsedL iObserver: %d", (iObserver ? 1 : 0 ));
+ LOG1( "[USBOTGWATCHER]\tMockCUsbTimer::TriggerTimerElapsedL iTimerId: %d", (iTimerId ? 1 : 0 ));
+
+ iObserver->TimerElapsedL(iTimerId);
+ LOG( ( "[USBOTGWATCHER]\tMockCUsbTimer::TriggerTimerElapsedL" ) );
+ iActive = EFalse;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/src/mockcusbvbusobserver.cpp Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,115 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include <usbotgdefs.h>
+#include <NormalHardcodedAssert.h>
+
+#include "mockusbman.h"
+
+#include "stifassertmacros.h"
+
+#include "mockcusbvbusobserver.h"
+
+#include "debug.h"
+#include "panic.h"
+
+// ---------------------------------------------------------------------------
+// ?description_if_needed
+// ---------------------------------------------------------------------------
+//
+CUsbVBusObserver::CUsbVBusObserver()
+ {
+ }
+
+
+// ---------------------------------------------------------------------------
+// ?description_if_needed
+// ---------------------------------------------------------------------------
+//
+void CUsbVBusObserver::ConstructL()
+ {
+ }
+
+CUsbVBusObserver* CUsbVBusObserver::NewL()
+ {
+ LOG(("[USBOTGWATCHER]\tMockCUsbVBusObserver::NewL"));
+
+ CUsbVBusObserver* self = new( ELeave ) CUsbVBusObserver();
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop( self );
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+// ?description_if_needed
+// ---------------------------------------------------------------------------
+//
+CUsbVBusObserver::~CUsbVBusObserver()
+ {
+ LOG(("[USBOTGWATCHER]\tMockCUsbVBusObserver::~CUsbVBusObserver"));
+ }
+
+// ---------------------------------------------------------------------------
+// ?description_if_needed
+// ---------------------------------------------------------------------------
+//
+CUsbVBusObserver::TState CUsbVBusObserver::VBus() /* const! But for some reason RProperty::Get is not const! */
+ {
+ LOG(("[USBOTGWATCHER]\tMockCUsbVBusObserver::VBus"));
+
+ return (iUsb->GetVBusUp() ? EVBusUp : EVBusDown);
+ //return (iVBusDown ? EVBusDown : EVBusUp);
+ }
+
+void CUsbVBusObserver::SubscribeL(MUsbVBusObserver& aObserver)
+ {
+ LOG(("[USBOTGWATCHER]\tMockCUsbVBusObserver::SubscribeL"));
+ STIF_ASSERT_NOT_NULL(&aObserver);
+ iObserver = &aObserver;
+ }
+
+void CUsbVBusObserver::UnsubscribeL(MUsbVBusObserver& aObserver)
+ {
+ LOG(("[USBOTGWATCHER]\tMockCUsbVBusObserver::UnsubscribeL"));
+ STIF_ASSERT_NOT_NULL(&aObserver);
+ iObserver = NULL;
+ }
+
+void CUsbVBusObserver::SetRUsb(RUsb* aRUsb)
+ {
+ iUsb = aRUsb;
+ }
+
+void CUsbVBusObserver::TriggerVBusUpL()
+ {
+ LOG(("[USBOTGWATCHER]\tMockCUsbVBusObserver::TriggerVBusUpL"));
+ STIF_ASSERT_NOT_NULL(iObserver);
+ //STIF_ASSERT_TRUE(iUsb->GetVBusUp() == EVBusUp);
+ //iVBusDown = EFalse;
+ iObserver->VBusUpL();
+ }
+
+void CUsbVBusObserver::TriggerVBusDownL()
+ {
+ LOG(("[USBOTGWATCHER]\tMockCUsbVBusObserver::TriggerVBusDownL"));
+ //STIF_ASSERT_NOT_NULL(iObserver);
+ //STIF_ASSERT_TRUE(iUsb->GetVBusUp() == EVBusDown);
+
+ //iVBusDown = ETrue;
+ iObserver->VBusDownL();
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/src/mockrusb.cpp Tue Jul 13 00:24:10 2010 +0300
@@ -0,0 +1,388 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include <e32base.h>
+#include <NormalHardcodedAssert.h>
+
+#include <stubber.h>
+#include <usbmandll_stub.h>
+#include <usbpersonalityids.h>
+
+#include "mockusbman.h"
+#include "stifassertmacros.h"
+
+#include "mockcusbvbusobserver.h"
+#include "debug.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+RUsb* RUsb::NewL()
+ {
+ LOG( ( " MockRUsb::NewL" ) );
+ RUsb* self = new ( ELeave ) RUsb();
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(); // pop self
+ return self;
+ }
+
+void RUsb::ConstructL()
+ {
+
+ }
+
+// ---------------------------------------------------------------------------
+// From class MUsb
+// ?implementation_description
+// ---------------------------------------------------------------------------
+//
+RUsb::RUsb() :
+ iBusCleared(EFalse),
+ iBusRequested(EFalse),
+ iServiceStateNotificationRequested(EFalse),
+ iTryStartError(KErrNone),
+ iBusRequestError(KErrNone),
+ iCurrentPersonalityId(0),
+ iUsbServiceState(EUsbServiceIdle)
+ {
+ LOG1 (" MockRUsb::RUsb: %d", iUsbServiceState );
+ }
+
+RUsb::~RUsb()
+ {
+ }
+
+// ---------------------------------------------------------------------------
+// From class MUsb
+// ?implementation_description
+// ---------------------------------------------------------------------------
+//
+void RUsb::TryStart(TInt aPersonalityId, TRequestStatus& aStatus)
+ {
+ LOG( (" MockRUsb::TryStart"));
+
+// CStubber* stubber = CStubber::NewL();
+// TApiBehavior beh( KUsbManStubAgentDll, ETryStartAsync, 0, 0, KNullDesC8 );
+// stubber -> InvokeApi( beh );
+//
+// delete stubber;
+// stubber = NULL;
+//
+// if ( beh.iOutput != KNullDesC8 )
+// {
+ TRequestStatus* status = &aStatus;
+ User::RequestComplete(status, iTryStartError);
+// }
+ }
+
+void RUsb::StartCancel(TRequestStatus& aStatus)
+ {
+ LOG( (" MockRUsb::StartCancel"));
+
+ TRequestStatus* status = &aStatus;
+ User::RequestComplete(status, iTryStartError);
+
+ }
+
+// ---------------------------------------------------------------------------
+// From class MUsb
+// ?implementation_description
+// ---------------------------------------------------------------------------
+//
+void RUsb::TryStop(TRequestStatus& aStatus)
+ {
+ LOG( (" MockRUsb::TryStop"));
+
+// CStubber* stubber = CStubber::NewL();
+// TApiBehavior beh( KUsbManStubAgentDll, ETryStartAsync, 0, 0, KNullDesC8 );
+// stubber -> InvokeApi( beh );
+//
+// delete stubber;
+// stubber = NULL;
+//
+// if ( beh.iOutput != KNullDesC8 )
+// {
+ TRequestStatus* status = &aStatus;
+ User::RequestComplete(status, KErrNone);
+// }
+ }
+
+// ---------------------------------------------------------------------------
+// From class MUsb
+// ?implementation_description
+// ---------------------------------------------------------------------------
+//
+void RUsb::MessageNotification(TRequestStatus& aStatus, TInt& aMessage)
+ {
+ LOG( (" MockRUsb::MessageNotification"));
+
+ }
+
+// ---------------------------------------------------------------------------
+// From class MUsb
+// ?implementation_description
+// ---------------------------------------------------------------------------
+//
+void RUsb::MessageNotificationCancel()
+ {
+ LOG( (" MockRUsb::MessageNotificationCancel"));
+
+ }
+
+// ---------------------------------------------------------------------------
+// From class MUsb
+// ?implementation_description
+// ---------------------------------------------------------------------------
+//
+void RUsb::HostEventNotification(TRequestStatus& aStatus,
+ TDeviceEventInformation& aDeviceInformation)
+ {
+ LOG( (" MockRUsb::HostEventNotification"));
+
+ }
+
+// ---------------------------------------------------------------------------
+// From class MUsb
+// ?implementation_description
+// ---------------------------------------------------------------------------
+//
+void RUsb::HostEventNotificationCancel()
+ {
+ LOG( (" MockRUsb::HostEventNotificationCancel"));
+
+ }
+
+// ---------------------------------------------------------------------------
+// From class MUsb
+// ?implementation_description
+// ---------------------------------------------------------------------------
+//
+TInt RUsb::EnableFunctionDriverLoading()
+ {
+ LOG( (" MockRUsb::EnableFunctionDriverLoading"));
+
+ return KErrNone;
+ }
+
+// ---------------------------------------------------------------------------
+// From class MUsb
+// ?implementation_description
+// ---------------------------------------------------------------------------
+//
+void RUsb::DisableFunctionDriverLoading()
+ {
+ LOG( (" MockRUsb::DisableFunctionDriverLoading"));
+
+ }
+
+// ---------------------------------------------------------------------------
+// From class MUsb
+// ?implementation_description
+// ---------------------------------------------------------------------------
+//
+TInt RUsb::BusRequest()
+ {
+ LOG1 (" MockRUsb::BusRequest, ret=%d", iBusRequestError );
+
+ iBusRequested = ETrue;
+
+ return iBusRequestError;
+ }
+
+// ---------------------------------------------------------------------------
+// From class MUsb
+// ?implementation_description
+// ---------------------------------------------------------------------------
+//
+TInt RUsb::BusRespondSrp()
+ {
+ LOG( (" MockRUsb::BusRespondSrp"));
+
+ return KErrNone;
+ }
+
+// ---------------------------------------------------------------------------
+// From class MUsb
+// ?implementation_description
+// ---------------------------------------------------------------------------
+//
+TInt RUsb::BusClearError()
+ {
+ LOG( (" MockRUsb::BusClearError"));
+ iBusCleared = ETrue;
+
+ return KErrNone;
+ }
+
+// ---------------------------------------------------------------------------
+// From class MUsb
+// ?implementation_description
+// ---------------------------------------------------------------------------
+//
+TInt RUsb::BusDrop()
+ {
+ LOG( (" MockRUsb::BusDrop"));
+
+ iBusRequested = EFalse;
+
+ return KErrNone;
+ }
+
+// ---------------------------------------------------------------------------
+// From class RSessionBase
+// ?implementation_description
+// ---------------------------------------------------------------------------
+//
+void RUsb::Close()
+ {
+ LOG( (" MockRUsb::Close"));
+
+ }
+
+void RUsb::SetTryStartError(TInt aError)
+ {
+ iTryStartError = aError;
+ }
+
+void RUsb::SetBusRequestError(TInt aError)
+ {
+ iBusRequestError = aError;
+ }
+
+void RUsb::SetUsbServiceState(TUsbServiceState aUsbServiceState)
+ {
+ LOG2 (" MockRUsb::SetUsbServiceState: %d, %d", iUsbServiceState, aUsbServiceState );
+ iUsbServiceState = aUsbServiceState;
+ }
+
+TBool RUsb::GetVBusUp()
+ {
+ LOG2 (" MockRUsb::GetVBusUp, iBusRequested=%d, iBusRequestError=%d", iBusRequested , iBusRequestError);
+
+ return iBusRequested && !iBusRequestError;
+ }
+
+TInt RUsb::GetServiceState(TUsbServiceState& aState)
+ {
+ LOG( (" MockRUsb::GetServiceState"));
+ aState = iUsbServiceState;
+
+ CStubber* stubber = CStubber::NewL();
+ TApiBehavior beh( KUsbManStubAgentDll, EServiceState, 0, 0, KNullDesC8 );
+ stubber -> InvokeApi( beh );
+
+ delete stubber;
+ stubber = NULL;
+
+ if ( beh.iOutput != KNullDesC8 )
+ {
+ if ( !beh.iOutput.Compare( _L8( "EUsbServiceIdle" ) ) )
+ aState = EUsbServiceIdle;
+ else if ( !beh.iOutput.Compare( _L8( "EUsbServiceStarting" ) ) )
+ aState = EUsbServiceStarting;
+ else if ( !beh.iOutput.Compare( _L8( "EUsbServiceStarted" ) ) )
+ aState = EUsbServiceStarted;
+ else if ( !beh.iOutput.Compare( _L8( "EUsbServiceStopping" ) ) )
+ aState = EUsbServiceStopping;
+ else if ( !beh.iOutput.Compare( _L8( "EUsbServiceFatalError" ) ) )
+ aState = EUsbServiceFatalError;
+ }
+
+ LOG1 (" iUsbServiceState: %d", aState);
+
+ return KErrNone;
+ }
+
+void RUsb::ServiceStateNotification(TUsbServiceState &aState, TRequestStatus &aStatus)
+{
+ LOG( (" MockRUsb::ServiceStateNotification"));
+ if(iServiceStateNotificationRequested)
+ {
+ TRequestStatus* status = &aStatus;
+ User::RequestComplete(status, KErrGeneral); // already requested
+ return;
+ }
+
+ iServiceStateNotificationRequested = ETrue;
+ TRequestStatus* status = &aStatus;
+ User::RequestComplete(status, KErrNone);
+}
+
+TInt RUsb::GetCurrentPersonalityId(TInt &aPersonalityId)
+{
+ LOG( (" MockRUsb::GetCurrentPersonalityId"));
+
+ CStubber* stubber = CStubber::NewL();
+ TApiBehavior beh( KUsbManStubAgentDll, EGetCurrentPersonalityId, 0, 0, KNullDesC8 );
+ stubber -> InvokeApi( beh );
+
+ delete stubber;
+ stubber = NULL;
+
+ if ( beh.iOutput != KNullDesC8 )
+ {
+ if ( !beh.iOutput.Compare( _L8( "UsbPersonalityIdPCSuite" ) ) )
+ aPersonalityId = KUsbPersonalityIdPCSuite;
+ else if ( !beh.iOutput.Compare( _L8( "UsbPersonalityIdMS" ) ) )
+ aPersonalityId = KUsbPersonalityIdMS;
+ else if ( !beh.iOutput.Compare( _L8( "UsbPersonalityIdPTP" ) ) )
+ aPersonalityId = KUsbPersonalityIdPTP;
+ else if ( !beh.iOutput.Compare( _L8( "UsbPersonalityIdMTP" ) ) )
+ aPersonalityId = KUsbPersonalityIdMTP;
+ else if ( !beh.iOutput.Compare( _L8( "UsbPersonalityIdPCSuiteMTP" ) ) )
+ aPersonalityId = KUsbPersonalityIdPCSuiteMTP;
+
+ LOG1( " MockRUsb::GetCurrentPersonalityId iStubbedPersonalityId: %d", aPersonalityId);
+ }
+ else
+ aPersonalityId = iCurrentPersonalityId;
+
+ LOG1( " MockRUsb::GetCurrentPersonalityId iCurrentPersonalityId: %d", iCurrentPersonalityId);
+
+ return KErrNone;
+}
+
+TInt RUsb::CancelInterest(TUsbReqType aMessageId) // to pending op. of usb service state
+{
+ LOG( (" MockRUsb::CancelInterest"));
+ iServiceStateNotificationRequested = EFalse;
+ return KErrNone;
+}
+
+void RUsb::ServiceStateNotificationCancel()
+{
+ LOG( (" MockRUsb::ServiceStateNotificationCancel"));
+ iServiceStateNotificationRequested = EFalse;
+}
+
+void RUsb::SetCurrentPersonality(TInt aPersonalityId)
+{
+ LOG( (" MockRUsb::SetCurrentPersonality"));
+ iCurrentPersonalityId = aPersonalityId;
+}
+
+TInt RUsb::GetOtgDescriptor(TUint aDeviceId, TOtgDescriptor& aDescriptor)
+{
+ LOG( (" MockRUsb::GetOtgDescriptor"));
+
+ aDescriptor.iAttributes = 1;
+ aDescriptor.iDeviceId = 2;
+
+ return KErrNone;
+}
+
+// End of File