0
|
1 |
// Copyright (c) 2008-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 |
// f32test\server\t_msmain.cpp
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#include <e32def.h>
|
|
19 |
#include <e32cmn.h>
|
|
20 |
#include <e32base.h>
|
|
21 |
#include <f32file.h>
|
|
22 |
#include <e32debug.h>
|
|
23 |
#include <e32test.h>
|
|
24 |
|
|
25 |
#include "rfsydebug.h"
|
|
26 |
#include "rusbhostsession.h"
|
|
27 |
#include "rusbotgsession.h"
|
|
28 |
#include "cmsdrive.h"
|
|
29 |
|
|
30 |
/*
|
297
|
31 |
OTG Platform configuration
|
|
32 |
Define for H4 and undefine for Navi Engine
|
0
|
33 |
*/
|
297
|
34 |
#define _OTG_CONFIG
|
0
|
35 |
|
|
36 |
extern RTest test;
|
|
37 |
extern RFs fsSession;
|
|
38 |
|
|
39 |
CMsDrive* msDrive;
|
|
40 |
|
|
41 |
extern void CallTestsL();
|
|
42 |
|
|
43 |
|
|
44 |
GLDEF_C void MainL()
|
|
45 |
{
|
|
46 |
TInt err;
|
|
47 |
CleanupClosePushL(fsSession);
|
|
48 |
User::LeaveIfError(fsSession.Connect());
|
|
49 |
|
|
50 |
msDrive = CMsDrive::NewL();
|
|
51 |
CleanupStack::PushL(msDrive);
|
|
52 |
|
|
53 |
RUsbOtgSession usbOtgSession;
|
|
54 |
err = usbOtgSession.Connect();
|
|
55 |
User::LeaveIfError(err);
|
|
56 |
CleanupClosePushL(usbOtgSession);
|
|
57 |
test.Printf(_L("USB OTG Server Connected\n"));
|
|
58 |
|
|
59 |
|
|
60 |
#ifdef _OTG_CONFIG
|
|
61 |
TBool deviceInserted = usbOtgSession.DeviceInserted();
|
|
62 |
test.Printf(_L("hub inserted = %d\n"), deviceInserted);
|
|
63 |
|
|
64 |
while (!deviceInserted)
|
|
65 |
{
|
|
66 |
TBool change;
|
|
67 |
TRequestStatus status;
|
|
68 |
test.Printf(_L("Waiting for hub inserted event...\n"));
|
|
69 |
usbOtgSession.NotifyChange(change, status);
|
297
|
70 |
|
0
|
71 |
User::WaitForRequest(status);
|
|
72 |
User::LeaveIfError(status.Int());
|
|
73 |
|
|
74 |
TBool deviceInserted = usbOtgSession.DeviceInserted();
|
|
75 |
test.Printf(_L("hub inserted = %d\n"), deviceInserted);
|
|
76 |
}
|
|
77 |
#else
|
|
78 |
TBool deviceInserted = ETrue;
|
|
79 |
#endif
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
RUsbHostSession usbHostSession;
|
|
85 |
err = usbHostSession.Connect();
|
|
86 |
User::LeaveIfError(err);
|
|
87 |
CleanupClosePushL(usbHostSession);
|
|
88 |
test.Printf(_L("USB Host Server Connected\n"));
|
|
89 |
|
|
90 |
err = usbHostSession.Start();
|
|
91 |
User::LeaveIfError(err);
|
|
92 |
test.Printf(_L("USB Host Server Started\n"));
|
|
93 |
|
|
94 |
|
|
95 |
if (deviceInserted)
|
|
96 |
{
|
|
97 |
TBool driveFound = EFalse;
|
|
98 |
|
|
99 |
do
|
|
100 |
{
|
|
101 |
TRequestStatus status;
|
|
102 |
fsSession.NotifyChange(ENotifyAll, status);
|
|
103 |
|
|
104 |
// trigger fileserver to update drive lists
|
|
105 |
TDriveList driveList;
|
|
106 |
User::LeaveIfError(fsSession.DriveList(driveList));
|
|
107 |
|
|
108 |
test.Printf(_L("Waiting for File System change notifcation...\r\n"));
|
|
109 |
User::WaitForRequest(status);
|
|
110 |
test.Printf(_L("NotifyChange status=%d\r\n"), status.Int());
|
|
111 |
|
|
112 |
driveFound = msDrive->GetUsbDeviceL();
|
|
113 |
} while (!driveFound);
|
|
114 |
|
|
115 |
msDrive->SetSessionPathL();
|
|
116 |
|
|
117 |
if (!msDrive->DrivePresent())
|
|
118 |
{
|
|
119 |
test.Printf(_L("Media Not present !\n"));
|
|
120 |
User::Leave(KErrNotReady);
|
|
121 |
}
|
|
122 |
|
|
123 |
test.Printf(_L("#--> ==== All mount enhancements are disabled ====\n"));
|
|
124 |
RFsyDebug fsyDebug(msDrive->DriveNumber());
|
|
125 |
fsyDebug.DisableAll();
|
|
126 |
|
|
127 |
CallTestsL();
|
|
128 |
}
|
|
129 |
else
|
|
130 |
{
|
|
131 |
test.Printf(_L("Hub not inserted!\n"));
|
|
132 |
test(EFalse);
|
|
133 |
}
|
|
134 |
|
297
|
135 |
|
0
|
136 |
test.Printf(_L("Destroying sessions...\n"));
|
|
137 |
test.Printf(_L("Destroying USB Host session...\n"));
|
|
138 |
CleanupStack::PopAndDestroy(&usbHostSession);
|
|
139 |
// Wait for thread to die
|
|
140 |
User::After(1000 * 1000 * 4);
|
|
141 |
|
|
142 |
test.Printf(_L("Destroying USB OTG session...\n"));
|
|
143 |
CleanupStack::PopAndDestroy(&usbOtgSession);
|
|
144 |
test.Printf(_L("Sessions Destroyed.\n"));
|
|
145 |
// Wait for thread to die
|
|
146 |
User::After(1000 * 1000 * 4);
|
|
147 |
|
|
148 |
CleanupStack::PopAndDestroy(msDrive);
|
|
149 |
CleanupStack::PopAndDestroy(); // fsSession
|
|
150 |
}
|
|
151 |
|
|
152 |
|
|
153 |
GLDEF_C TInt E32Main()
|
297
|
154 |
{
|
0
|
155 |
CTrapCleanup* cleanup = CTrapCleanup::New();
|
297
|
156 |
__UHEAP_MARK;
|
0
|
157 |
test.Title();
|
|
158 |
test.Start(_L("Starting tests..."));
|
|
159 |
|
297
|
160 |
TTime timerC;
|
|
161 |
timerC.HomeTime();
|
0
|
162 |
|
297
|
163 |
TRAPD(err, MainL());
|
0
|
164 |
test(err == KErrNone);
|
|
165 |
|
|
166 |
TTime endTimeC;
|
|
167 |
endTimeC.HomeTime();
|
|
168 |
TTimeIntervalSeconds timeTakenC;
|
|
169 |
err = endTimeC.SecondsFrom(timerC,timeTakenC);
|
|
170 |
test(err == KErrNone);
|
|
171 |
test.Printf(_L("Time taken for test = %d seconds\n"),timeTakenC.Int());
|
|
172 |
|
297
|
173 |
test.End();
|
|
174 |
test.Close();
|
|
175 |
__UHEAP_MARKEND;
|
|
176 |
delete cleanup;
|
|
177 |
return KErrNone;
|
|
178 |
}
|
0
|
179 |
|