kerneltest/f32test/shostmassstorage/msman/test/ttestutils.cpp
changeset 43 96e5fb8b040d
child 297 b2826f67641f
equal deleted inserted replaced
-1:000000000000 43:96e5fb8b040d
       
     1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // USB Host Mass Storage
       
    15 // 
       
    16 //
       
    17 
       
    18 
       
    19 
       
    20 /**
       
    21  @file
       
    22 */
       
    23 
       
    24 #include <e32std.h>
       
    25 #include <e32property.h>
       
    26 
       
    27 
       
    28 #include "ttestutils.h"
       
    29 #include "tmslog.h"
       
    30 #include "e32test.h"
       
    31 #include "e32debug.h"
       
    32 
       
    33 extern RTest test;
       
    34 
       
    35     const TUid KMyPropertyCat = {0x10285B2E};
       
    36     enum TMyPropertyKeys
       
    37         {
       
    38         EMyPropertyEvent = 1,
       
    39         EMyPropertyServer = 2,
       
    40         EMyPropertyConnectionStateEvent = 3
       
    41         };
       
    42 
       
    43     const TUid KUsbmanSvrSid = {0x101fe1db};
       
    44 
       
    45 
       
    46 
       
    47 void TTestUtils::WaitForBusEventL()
       
    48     {
       
    49     __MSFNSLOG
       
    50     _LIT_SECURITY_POLICY_PASS(KMsAllowAllPolicy);
       
    51     _LIT_SECURITY_POLICY_S0(KMsWritePolicy, KUsbmanSvrSid.iUid);
       
    52 
       
    53     RProperty evProp;
       
    54     User::LeaveIfError(evProp.Define(KMyPropertyCat,
       
    55                                      EMyPropertyEvent,
       
    56                                      RProperty::EInt,
       
    57                                      KMsAllowAllPolicy,
       
    58                                      KMsWritePolicy));
       
    59 
       
    60     TInt err = evProp.Attach(KMyPropertyCat, EMyPropertyEvent);
       
    61     User::LeaveIfError(err);
       
    62 
       
    63     TRequestStatus status;
       
    64     evProp.Subscribe(status);
       
    65     User::WaitForRequest(status);
       
    66 
       
    67     // Notification complete, retrieve the counter value.
       
    68     TInt event;
       
    69     evProp.Get(event);
       
    70 
       
    71     RProperty::Delete(EMyPropertyEvent);
       
    72     }
       
    73 
       
    74 
       
    75 TBool TTestUtils::WaitForConnectionStateEventL()
       
    76     {
       
    77     __MSFNSLOG
       
    78     _LIT_SECURITY_POLICY_PASS(KMsAllowAllPolicy);
       
    79     _LIT_SECURITY_POLICY_S0(KMsWritePolicy, KUsbmanSvrSid.iUid);
       
    80 
       
    81     RProperty evProp;
       
    82     User::LeaveIfError(evProp.Define(KUsbmanSvrSid,
       
    83                                      EMyPropertyConnectionStateEvent,
       
    84                                      RProperty::EInt,
       
    85                                      KMsAllowAllPolicy,
       
    86                                      KMsWritePolicy));
       
    87 
       
    88     TInt err = evProp.Attach(KUsbmanSvrSid, EMyPropertyConnectionStateEvent);
       
    89     User::LeaveIfError(err);
       
    90 
       
    91     TRequestStatus status;
       
    92     evProp.Subscribe(status);
       
    93     User::WaitForRequest(status);
       
    94 
       
    95     // Notification complete, retrieve the counter value.
       
    96     TBool event;
       
    97     evProp.Get(event);
       
    98 
       
    99     RProperty::Delete(KUsbmanSvrSid, EMyPropertyConnectionStateEvent);
       
   100     return event;
       
   101     }
       
   102 
       
   103 
       
   104 
       
   105 TTestTimer::TTestTimer()
       
   106     {
       
   107 
       
   108     }
       
   109 
       
   110 void TTestTimer::Start()
       
   111     {
       
   112     iStart.HomeTime();
       
   113     }
       
   114 
       
   115 void TTestTimer::End()
       
   116     {
       
   117     iEnd.HomeTime();
       
   118 
       
   119     TTimeIntervalSeconds timeTaken;
       
   120     iEnd.SecondsFrom(iStart, timeTaken);
       
   121     TUint totalTime = timeTaken.Int();
       
   122     test.Printf(_L("Time taken is %dHrs:%dmins:%dsecs\n"),
       
   123                   totalTime/3600,
       
   124                   (totalTime/60)%60,
       
   125                   totalTime%60);
       
   126     }
       
   127 
       
   128 TTestTimer::~TTestTimer()
       
   129     {
       
   130     }