usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/inc/mockcusbtimer.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 C_USBTIMER_H
       
    19 #define C_USBTIMER_H
       
    20 
       
    21 #include <e32base.h>
       
    22 
       
    23 #include <StifTestModule.h>
       
    24 #include <StifLogger.h>
       
    25 
       
    26 #include "tassertbase.h"
       
    27 
       
    28 class CUsbTimer;
       
    29 
       
    30 /**
       
    31  * timer ids for usbotgwatcher
       
    32  */
       
    33 enum TUsbTimerId
       
    34     {
       
    35     EDeviceAttachmentTimer,
       
    36     EInactiveTimer,
       
    37     EIconBlinkingTimer,
       
    38     ETooMuchPowerRequiredTimer,
       
    39     EDriversNotFoundTimer
       
    40     };
       
    41 
       
    42 
       
    43 class MUsbTimerObserver
       
    44     {
       
    45     friend class CtUsbOtgWatcher;
       
    46     friend class CUsbOtgWatcherTest;
       
    47 public:
       
    48 
       
    49     virtual void TimerElapsedL(TUsbTimerId aTimerId) = 0;
       
    50     };
       
    51 
       
    52 // Wrapper class, will report to MUsbTimerObserver once time is over
       
    53 // Name CUsbTimer is given due to CTimer name already used
       
    54 NONSHARABLE_CLASS(CUsbTimer) : public TAssertBase
       
    55     {
       
    56 public:
       
    57 
       
    58     /**
       
    59      * Two-phased constructor
       
    60      *
       
    61      * @param aTimeOver pointer to a call back function. Called when time is over.
       
    62      */
       
    63     static CUsbTimer* NewL(MUsbTimerObserver& aObserver, TUsbTimerId aTimerId);
       
    64 
       
    65     /**
       
    66      * Destructor.
       
    67      */
       
    68     virtual ~CUsbTimer();
       
    69 
       
    70     // calls RunL after aMilliseconds
       
    71     void After(TInt aMilliseconds);
       
    72 
       
    73     //cancels timer
       
    74     void Cancel();
       
    75 
       
    76     TBool IsActive();
       
    77 
       
    78     void TriggerTimerElapsedL();
       
    79 
       
    80 public:
       
    81 
       
    82     // from base class CActive
       
    83 
       
    84     void RunL();
       
    85 
       
    86     TInt RunError( TInt /*aError*/);
       
    87 
       
    88     void DoCancel();
       
    89 
       
    90 private:
       
    91 
       
    92     CUsbTimer(MUsbTimerObserver& aObserver, TUsbTimerId aTimerId);
       
    93 
       
    94     void ConstructL();
       
    95 
       
    96 private: // data
       
    97 
       
    98     MUsbTimerObserver* iObserver;
       
    99     TBool iActive;
       
   100     TUsbTimerId iTimerId;
       
   101     };
       
   102 
       
   103 #endif //  C_USBTIMER_H