usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/src/mockcusbidpinobserver.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 <usbotgdefs.h>
       
    19 #include <NormalHardcodedAssert.h>
       
    20 
       
    21 #include "stifassertmacros.h"
       
    22 #include "mockcusbidpinobserver.h"
       
    23 
       
    24 #include "debug.h"
       
    25 #include "panic.h"
       
    26 
       
    27 // ---------------------------------------------------------------------------
       
    28 // ?description_if_needed
       
    29 // ---------------------------------------------------------------------------
       
    30 //
       
    31 CUsbIdPinObserver::CUsbIdPinObserver() : iIdPinOn(EFalse)
       
    32     {
       
    33     }
       
    34 
       
    35 
       
    36 // ---------------------------------------------------------------------------
       
    37 // ?description_if_needed
       
    38 // ---------------------------------------------------------------------------
       
    39 //
       
    40 void CUsbIdPinObserver::ConstructL()
       
    41     {
       
    42     iWait = new ( ELeave )CActiveSchedulerWait();
       
    43     }
       
    44     
       
    45 CUsbIdPinObserver* CUsbIdPinObserver::NewL()
       
    46     {
       
    47     LOG( "[USBOTGWATCHER]\tMockCUsbIdPinObserver::NewL" );
       
    48     
       
    49     CUsbIdPinObserver* self = new( ELeave ) CUsbIdPinObserver();
       
    50     CleanupStack::PushL( self );
       
    51     self->ConstructL();
       
    52     CleanupStack::Pop( self );
       
    53     return self;        
       
    54     }
       
    55         
       
    56 // ---------------------------------------------------------------------------
       
    57 // ?description_if_needed
       
    58 // ---------------------------------------------------------------------------
       
    59 //
       
    60 CUsbIdPinObserver::~CUsbIdPinObserver()
       
    61     {
       
    62     LOG( ( "[USBOTGWATCHER]\tMockCUsbIdPinObserver::~CUsbIdPinObserver" ) );
       
    63     }
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 // ?description_if_needed
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 CUsbIdPinObserver::TState CUsbIdPinObserver::IdPin() /* const! But for some reason RProperty::Get is not const! */
       
    70     {
       
    71     // not found in Symbian docs clear definition of this property. Verification is needed   
       
    72     return (0 == iIdPinOn? EIdPinOff : EIdPinOn);
       
    73     }
       
    74     
       
    75    
       
    76 void CUsbIdPinObserver::SubscribeL(MUsbIdPinObserver& aObserver)
       
    77     {
       
    78     //iLog->Log(_L("[USBOTGWATCHER] >>MockCUsbIdPinObserver::SubscribeL"));
       
    79     LOG(("[USBOTGWATCHER]\tMockCUsbIdPinObserver::SubscribeL"));
       
    80     STIF_ASSERT_NOT_NULL(&aObserver);
       
    81     
       
    82     iObserver = &aObserver;
       
    83 
       
    84     //iLog->Log(_L("[USBOTGWATCHER] <<MockCUsbIdPinObserver::SubscribeL"));
       
    85     }
       
    86 
       
    87 void CUsbIdPinObserver::UnsubscribeL(MUsbIdPinObserver& aObserver)
       
    88     {
       
    89     LOG(("[USBOTGWATCHER]\tMockCUsbIdPinObserver::UnsubscribeL"));
       
    90     STIF_ASSERT_NOT_NULL(&aObserver);    
       
    91     
       
    92     iObserver = NULL;
       
    93     }
       
    94 
       
    95 void CUsbIdPinObserver::TriggerPinOnL()
       
    96     {
       
    97     LOG(("[USBOTGWATCHER]\tMockCUsbIdPinObserver::TriggerPinOn"));
       
    98     STIF_ASSERT_NOT_NULL(iObserver);
       
    99 
       
   100     iIdPinOn = 1;
       
   101     iObserver->IdPinOnL();
       
   102     LOG(("[USBOTGWATCHER] <<MockCUsbIdPinObserver::TriggerPinOn"));
       
   103     }
       
   104 
       
   105 void CUsbIdPinObserver::TriggerPinOffL()
       
   106     {
       
   107     LOG(("[USBOTGWATCHER]\tMockCUsbIdPinObserver::TriggerPinOff"));
       
   108     STIF_ASSERT_NOT_NULL(iObserver);
       
   109 
       
   110     iIdPinOn = 0;
       
   111     iObserver->IdPinOffL();
       
   112     }