usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/inc/mockusbman.h
branchRCL_3
changeset 92 dde4619868dc
parent 86 703a2b94c06c
child 95 55a3258355ea
equal deleted inserted replaced
86:703a2b94c06c 92:dde4619868dc
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __USBMAN_H__
       
    19 #define __USBMAN_H__
       
    20 
       
    21 //#ifndef R_USB_H
       
    22 //#define R_USB_H
       
    23 
       
    24 #include <usbhostdefs.h>
       
    25 
       
    26 #include <StifTestModule.h>
       
    27 #include <StifLogger.h>
       
    28 
       
    29 #include "tassertbase.h"
       
    30 #include <usbstates.h>
       
    31 
       
    32 //enum TUsbMockServiceState
       
    33 //    {
       
    34 //    EUsbServiceStateIdle = 0x01,
       
    35 //    EUsbServiceStateStarting = 0x02,
       
    36 //    EUsbServiceStateStarted = 0x04,
       
    37 //    EUsbServiceStateStopping = 0x08,
       
    38 //    EUsbServiceStateFatalError = 0x10
       
    39 //    };
       
    40 		
       
    41 class RUsb : public TAssertBase
       
    42     {
       
    43     
       
    44 	// Request types, the interest of which can be cancelled by clients
       
    45 	enum TUsbReqType
       
    46 		{
       
    47 		EStart,
       
    48 		EStop,
       
    49 		ETryStart,
       
    50 		ETryStop
       
    51 		};
       
    52 		
       
    53 public:
       
    54     static RUsb* NewL();
       
    55       
       
    56     ~RUsb();
       
    57     // from base class MUsb
       
    58     /**
       
    59     */
       
    60     void TryStart(TInt aPersonalityId, TRequestStatus& aStatus);
       
    61 
       
    62     /**
       
    63     */
       
    64     void StartCancel(TRequestStatus& aStatus);
       
    65 
       
    66     /**
       
    67     */
       
    68     void TryStop(TRequestStatus& aStatus);
       
    69 
       
    70     /**
       
    71     */
       
    72     void MessageNotification(TRequestStatus& aStatus, TInt& aMessage);
       
    73 
       
    74     /**
       
    75     */
       
    76     void MessageNotificationCancel();
       
    77 
       
    78     /**
       
    79     */
       
    80     void HostEventNotification(TRequestStatus& aStatus,
       
    81                                         TDeviceEventInformation& aDeviceInformation);
       
    82 
       
    83     /**
       
    84     */
       
    85     void HostEventNotificationCancel();
       
    86     
       
    87     /**
       
    88     */
       
    89     TInt EnableFunctionDriverLoading();
       
    90 
       
    91     /**
       
    92     */
       
    93     void DisableFunctionDriverLoading();
       
    94 
       
    95     /**
       
    96     */
       
    97     TInt BusRequest();
       
    98 
       
    99     /**
       
   100     */
       
   101     TInt BusRespondSrp();
       
   102 
       
   103     /**
       
   104     */
       
   105     TInt BusClearError();
       
   106 
       
   107     /**
       
   108     */
       
   109     TInt BusDrop();
       
   110     
       
   111     void ServiceStateNotification(TUsbServiceState &aState, TRequestStatus &aStatus);
       
   112     
       
   113     TInt GetCurrentPersonalityId(TInt &aPersonalityId);
       
   114     
       
   115     TInt CancelInterest(TUsbReqType aMessageId); // to pending op. of usb service state
       
   116     
       
   117     void ServiceStateNotificationCancel();
       
   118     
       
   119     TInt GetOtgDescriptor(TUint aDeviceId, TOtgDescriptor& aDescriptor);
       
   120 	
       
   121     // from base class RSessionBase
       
   122     /**
       
   123     */
       
   124     void Close();
       
   125 
       
   126     //Mock methods
       
   127     void SetTryStartError(TInt aError);
       
   128     void SetBusRequestError(TInt aError);
       
   129     void SetUsbServiceState(TUsbServiceState aUsbServiceState);
       
   130     void SetCurrentPersonality(TInt aPersonality);
       
   131     
       
   132     TBool GetVBusUp();
       
   133     
       
   134     TInt GetServiceState(TUsbServiceState& aState);
       
   135 private:
       
   136     RUsb();
       
   137     
       
   138     void ConstructL();
       
   139     
       
   140 private: // data
       
   141     TBool iBusCleared;
       
   142     TBool iBusRequested;
       
   143     TBool iServiceStateNotificationRequested;
       
   144     
       
   145     TInt iTryStartError;
       
   146     TInt iBusRequestError;
       
   147     TInt iCurrentPersonalityId;
       
   148     
       
   149     TUsbServiceState iUsbServiceState;
       
   150     };
       
   151 
       
   152 #endif // __USBMAN_H__