usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/src/mockcusbotgstateobserver.cpp
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 #include <e32base.h>
       
    19 #include <NormalHardcodedAssert.h>
       
    20 
       
    21 #include "stifassertmacros.h"
       
    22 
       
    23 #include "mockcusbotgstateobserver.h"
       
    24 
       
    25 #include "debug.h"
       
    26 #include "panic.h"
       
    27 
       
    28 // ---------------------------------------------------------------------------
       
    29 // ?description_if_needed
       
    30 // ---------------------------------------------------------------------------
       
    31 //
       
    32 CUsbOtgStateObserver::CUsbOtgStateObserver()
       
    33     {
       
    34     }
       
    35 
       
    36 // ---------------------------------------------------------------------------
       
    37 // ?description_if_needed
       
    38 // ---------------------------------------------------------------------------
       
    39 //
       
    40 void CUsbOtgStateObserver::ConstructL()
       
    41     {
       
    42     }
       
    43 
       
    44 CUsbOtgStateObserver* CUsbOtgStateObserver::NewL()
       
    45     {
       
    46     LOG(("[USBOTGWATCHER]\tMockCUsbOtgStateObserver::NewL" ));
       
    47 
       
    48     CUsbOtgStateObserver* self = new( ELeave ) CUsbOtgStateObserver();
       
    49     CleanupStack::PushL(self);
       
    50     self->ConstructL();
       
    51     CleanupStack::Pop(self);
       
    52     return self;
       
    53     }
       
    54 
       
    55 // ---------------------------------------------------------------------------
       
    56 // ?description_if_needed
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 CUsbOtgStateObserver::~CUsbOtgStateObserver()
       
    60     {
       
    61     LOG(("[USBOTGWATCHER]\tMockCUsbOtgStateObserver::~CUsbOtgStateObserver" ));
       
    62     }
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 // ?description_if_needed
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 TUsbOtgState CUsbOtgStateObserver::OtgState()
       
    69     {
       
    70     return (TUsbOtgState)iOtgState;
       
    71     }
       
    72 
       
    73 void CUsbOtgStateObserver::SubscribeL(MUsbOtgStateObserver& aObserver)
       
    74     {
       
    75     LOG(("[USBOTGWATCHER]\tMockCUsbOtgStateObserver::SubscribeL"));
       
    76     STIF_ASSERT_NOT_NULL(&aObserver);
       
    77 
       
    78     iObserver = &aObserver;
       
    79     }
       
    80 
       
    81 void CUsbOtgStateObserver::UnsubscribeL(MUsbOtgStateObserver& aObserver)
       
    82     {
       
    83     LOG(("[USBOTGWATCHER]\tMockCUsbOtgStateObserver::UnsubscribeL"));
       
    84     STIF_ASSERT_NOT_NULL(&aObserver);
       
    85 
       
    86     iObserver = NULL;
       
    87     }
       
    88 
       
    89 //ignore EUsbOtgStateReset
       
    90 
       
    91 void CUsbOtgStateObserver::TriggerAIdleL()
       
    92     {
       
    93     STIF_ASSERT_NOT_NULL(iObserver);
       
    94 
       
    95     //EUsbOtgStateAIdle
       
    96     iObserver->AIdleL();
       
    97     }
       
    98 
       
    99 void CUsbOtgStateObserver::TriggerAHostL()
       
   100     {
       
   101     STIF_ASSERT_NOT_NULL(iObserver);
       
   102 
       
   103     //EUsbOtgStateAHost
       
   104     iObserver->AHostL();
       
   105     }
       
   106 
       
   107 void CUsbOtgStateObserver::TriggerAPeripheralL()
       
   108     {
       
   109     STIF_ASSERT_NOT_NULL(iObserver);
       
   110 
       
   111     //EUsbOtgStateAPeripheral
       
   112     iObserver->APeripheralL();
       
   113     }
       
   114 
       
   115 void CUsbOtgStateObserver::TriggerAVBusErrorL()
       
   116     {
       
   117     STIF_ASSERT_NOT_NULL(iObserver);
       
   118 
       
   119     //EUsbOtgStateAVbusError
       
   120     iObserver->AVBusErrorL();
       
   121     }
       
   122 
       
   123 void CUsbOtgStateObserver::TriggerBIdleL()
       
   124     {
       
   125     STIF_ASSERT_NOT_NULL(iObserver);
       
   126 
       
   127     //EUsbOtgStateBIdle
       
   128     iObserver->BIdleL();
       
   129     }
       
   130 
       
   131 void CUsbOtgStateObserver::TriggerBPeripheralL()
       
   132     {
       
   133     STIF_ASSERT_NOT_NULL(iObserver);
       
   134 
       
   135     //EUsbOtgStateBPeripheral
       
   136     iObserver->BPeripheralL();
       
   137     }
       
   138 
       
   139 void CUsbOtgStateObserver::TriggerBHostL()
       
   140     {
       
   141     STIF_ASSERT_NOT_NULL(iObserver);
       
   142 
       
   143     //EUsbOtgStateBHost
       
   144     iObserver->BHostL();
       
   145     }