First public contribution.
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
23 #define __E32TEST_EXTENSION__
27 #include "rusbhostsession.h"
28 #include "rusbotgsession.h"
31 #include "tmsprintdrive.h"
32 #include "ttestutils.h"
35 RTest test(_L("T_MSVBUS"));
37 RUsbOtgSession usbOtgSession;
39 extern CMsDrive* msDrive;
44 test.Start(_L("Test1"));
45 test.Next(_L("Test1"));
47 usbOtgSession.BusDrop();
48 usbOtgSession.DeviceInserted();
55 TBool usbActive = TTestUtils::WaitForConnectionStateEventL();
56 test(usbActive == EFalse);
62 usbActive = TTestUtils::WaitForConnectionStateEventL();
64 test(usbActive == EFalse);
69 usbActive = TTestUtils::WaitForConnectionStateEventL();
71 test(usbActive == EFalse);
76 usbActive = TTestUtils::WaitForConnectionStateEventL();
78 test(usbActive == EFalse);
86 CleanupClosePushL(fsSession);
87 User::LeaveIfError(fsSession.Connect());
89 TTestUtils::WaitForBusEventL();
93 CleanupStack::PopAndDestroy();
103 RUsbHostSession usbHostSession;
104 err = usbHostSession.Connect();
105 User::LeaveIfError(err);
106 CleanupClosePushL(usbHostSession);
107 test.Printf(_L("USB Host Server Connected\n"));
109 err = usbHostSession.Start();
110 User::LeaveIfError(err);
111 test.Printf(_L("USB Host Server Started\n"));
113 err = usbOtgSession.Connect();
114 User::LeaveIfError(err);
115 CleanupClosePushL(usbOtgSession);
116 test.Printf(_L("USB OTG Server Connected\n"));
118 TBool deviceInserted;
119 deviceInserted = usbOtgSession.DeviceInserted();
120 RDebug::Printf(">>>>>>>>>>>> %d", deviceInserted);
124 test.Printf(_L("Destroying sessions...\n"));
125 test.Printf(_L("Destroying USB OTG session...\n"));
126 CleanupStack::PopAndDestroy(&usbOtgSession);
128 test.Printf(_L("Destroying USB Host session...\n"));
129 CleanupStack::PopAndDestroy(&usbHostSession);
130 test.Printf(_L("Sessions Destroyed.\n"));
134 GLDEF_C TInt E32Main()
136 CTrapCleanup* cleanup = CTrapCleanup::New();
139 test.Start(_L("Starting tests..."));
148 RDebug::Print(_L("MainL error: %d\n"),err);
153 TTimeIntervalSeconds timeTakenC;
154 err = endTimeC.SecondsFrom(timerC,timeTakenC);
155 test(err == KErrNone);
156 test.Printf(_L("Time taken for test = %d seconds\n"),timeTakenC.Int());