0
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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 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".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
#include <e32def.h>
|
|
18 |
#include <e32cmn.h>
|
|
19 |
#include <e32base.h>
|
|
20 |
#include <f32file.h>
|
|
21 |
#include <e32cons.h>
|
|
22 |
#include <e32debug.h>
|
|
23 |
#define __E32TEST_EXTENSION__
|
|
24 |
#include <e32test.h>
|
|
25 |
|
|
26 |
|
|
27 |
#include "rusbhostsession.h"
|
|
28 |
#include "rusbotgsession.h"
|
|
29 |
|
|
30 |
#include "cmsdrive.h"
|
|
31 |
#include "tmsprintdrive.h"
|
|
32 |
#include "ttestutils.h"
|
|
33 |
|
|
34 |
RTest test(_L("T_MSVBUS"));
|
|
35 |
RFs fsSession;
|
|
36 |
RUsbOtgSession usbOtgSession;
|
|
37 |
|
|
38 |
extern CMsDrive* msDrive;
|
|
39 |
|
|
40 |
|
|
41 |
void Test1L()
|
|
42 |
{
|
|
43 |
test.Start(_L("Test1"));
|
|
44 |
test.Next(_L("Test1"));
|
|
45 |
|
|
46 |
usbOtgSession.BusDrop();
|
|
47 |
usbOtgSession.DeviceInserted();
|
|
48 |
|
|
49 |
TTestTimer iTimer;
|
|
50 |
// #1
|
|
51 |
// wait for suspend
|
|
52 |
|
|
53 |
iTimer.Start();
|
|
54 |
TBool usbActive = TTestUtils::WaitForConnectionStateEventL();
|
|
55 |
test(usbActive == EFalse);
|
|
56 |
iTimer.End();
|
|
57 |
|
|
58 |
// #2
|
|
59 |
// wait for suspend
|
|
60 |
iTimer.Start();
|
|
61 |
usbActive = TTestUtils::WaitForConnectionStateEventL();
|
|
62 |
iTimer.End();
|
|
63 |
test(usbActive == EFalse);
|
|
64 |
|
|
65 |
// #3
|
|
66 |
// wait for suspend
|
|
67 |
iTimer.Start();
|
|
68 |
usbActive = TTestUtils::WaitForConnectionStateEventL();
|
|
69 |
iTimer.End();
|
|
70 |
test(usbActive == EFalse);
|
|
71 |
|
|
72 |
// #4
|
|
73 |
// wait for suspend
|
|
74 |
iTimer.Start();
|
|
75 |
usbActive = TTestUtils::WaitForConnectionStateEventL();
|
|
76 |
iTimer.End();
|
|
77 |
test(usbActive == EFalse);
|
|
78 |
test.End();
|
|
79 |
}
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
void CallTestsL()
|
|
84 |
{
|
|
85 |
CleanupClosePushL(fsSession);
|
|
86 |
User::LeaveIfError(fsSession.Connect());
|
|
87 |
|
|
88 |
TTestUtils::WaitForBusEventL();
|
|
89 |
|
|
90 |
Test1L();
|
|
91 |
|
|
92 |
CleanupStack::PopAndDestroy();
|
|
93 |
}
|
|
94 |
|
|
95 |
|
|
96 |
GLDEF_C void MainL()
|
|
97 |
{
|
|
98 |
TInt err;
|
|
99 |
|
|
100 |
RUsbHostSession usbHostSession;
|
|
101 |
err = usbHostSession.Connect();
|
|
102 |
User::LeaveIfError(err);
|
|
103 |
CleanupClosePushL(usbHostSession);
|
|
104 |
test.Printf(_L("USB Host Server Connected\n"));
|
|
105 |
|
|
106 |
err = usbHostSession.Start();
|
|
107 |
User::LeaveIfError(err);
|
|
108 |
test.Printf(_L("USB Host Server Started\n"));
|
|
109 |
|
|
110 |
err = usbOtgSession.Connect();
|
|
111 |
User::LeaveIfError(err);
|
|
112 |
CleanupClosePushL(usbOtgSession);
|
|
113 |
test.Printf(_L("USB OTG Server Connected\n"));
|
|
114 |
|
|
115 |
TBool deviceInserted;
|
|
116 |
deviceInserted = usbOtgSession.DeviceInserted();
|
|
117 |
RDebug::Printf(">>>>>>>>>>>> %d", deviceInserted);
|
|
118 |
|
|
119 |
CallTestsL();
|
|
120 |
|
|
121 |
test.Printf(_L("Destroying sessions...\n"));
|
|
122 |
test.Printf(_L("Destroying USB OTG session...\n"));
|
|
123 |
CleanupStack::PopAndDestroy(&usbOtgSession);
|
|
124 |
|
|
125 |
test.Printf(_L("Destroying USB Host session...\n"));
|
|
126 |
CleanupStack::PopAndDestroy(&usbHostSession);
|
|
127 |
test.Printf(_L("Sessions Destroyed.\n"));
|
|
128 |
}
|
|
129 |
|
|
130 |
|
|
131 |
GLDEF_C TInt E32Main()
|
297
|
132 |
{
|
0
|
133 |
CTrapCleanup* cleanup = CTrapCleanup::New();
|
297
|
134 |
__UHEAP_MARK;
|
0
|
135 |
test.Title();
|
|
136 |
test.Start(_L("Starting tests..."));
|
|
137 |
|
297
|
138 |
TTime timerC;
|
|
139 |
timerC.HomeTime();
|
0
|
140 |
|
297
|
141 |
TRAPD(err, MainL());
|
0
|
142 |
|
|
143 |
if (err != KErrNone)
|
|
144 |
{
|
|
145 |
RDebug::Print(_L("MainL error: %d\n"),err);
|
|
146 |
}
|
|
147 |
|
|
148 |
TTime endTimeC;
|
|
149 |
endTimeC.HomeTime();
|
|
150 |
TTimeIntervalSeconds timeTakenC;
|
|
151 |
err = endTimeC.SecondsFrom(timerC,timeTakenC);
|
|
152 |
test(err == KErrNone);
|
|
153 |
test.Printf(_L("Time taken for test = %d seconds\n"),timeTakenC.Int());
|
|
154 |
|
297
|
155 |
test.End();
|
|
156 |
test.Close();
|
|
157 |
__UHEAP_MARKEND;
|
|
158 |
delete cleanup;
|
|
159 |
return KErrNone;
|
|
160 |
}
|