297
|
1 |
// Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
|
0
|
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 |
//
|
|
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 |
#include "cmsdrive.h"
|
|
27 |
#include "tmsprintdrive.h"
|
|
28 |
#include "ttestutils.h"
|
|
29 |
|
|
30 |
extern CMsDrive* msDrive;
|
|
31 |
|
|
32 |
RTest test(_L("T_MSSUSPEND"));
|
|
33 |
RFs fsSession;
|
|
34 |
|
|
35 |
|
|
36 |
class TTestMsSuspend
|
|
37 |
{
|
|
38 |
public:
|
|
39 |
void t1L();
|
|
40 |
|
|
41 |
private:
|
|
42 |
void DrvWrite();
|
|
43 |
};
|
|
44 |
|
|
45 |
|
|
46 |
void TTestMsSuspend::t1L()
|
|
47 |
{
|
|
48 |
test.Start(_L("Test"));
|
|
49 |
test.Next(_L("Test1"));
|
|
50 |
TTestTimer iTimer;
|
|
51 |
// #1
|
|
52 |
DrvWrite();
|
|
53 |
// wait for suspend
|
|
54 |
test.Printf(_L("Waiting for host to suspend..."));
|
|
55 |
iTimer.Start();
|
|
56 |
TBool usbActive = TTestUtils::WaitForConnectionStateEventL();
|
|
57 |
test(usbActive == EFalse);
|
|
58 |
iTimer.End();
|
|
59 |
|
|
60 |
// #2
|
|
61 |
// Resume device by accessing drive
|
|
62 |
DrvWrite();
|
|
63 |
// wait for suspend
|
|
64 |
test.Printf(_L("Waiting for host to suspend..."));
|
|
65 |
iTimer.Start();
|
|
66 |
usbActive = TTestUtils::WaitForConnectionStateEventL();
|
|
67 |
iTimer.End();
|
|
68 |
test(usbActive == EFalse);
|
|
69 |
|
|
70 |
// #3
|
|
71 |
// Resume device by accessing drive
|
|
72 |
DrvWrite();
|
|
73 |
// wait for suspend
|
|
74 |
test.Printf(_L("Waiting for host to suspend..."));
|
|
75 |
iTimer.Start();
|
|
76 |
usbActive = TTestUtils::WaitForConnectionStateEventL();
|
|
77 |
iTimer.End();
|
|
78 |
test(usbActive == EFalse);
|
|
79 |
|
|
80 |
// #4
|
|
81 |
// Resume device by accessing drive
|
|
82 |
DrvWrite();
|
|
83 |
// wait for suspend
|
|
84 |
test.Printf(_L("Waiting for host to suspend..."));
|
|
85 |
iTimer.Start();
|
|
86 |
usbActive = TTestUtils::WaitForConnectionStateEventL();
|
|
87 |
iTimer.End();
|
|
88 |
test(usbActive == EFalse);
|
|
89 |
test.End();
|
|
90 |
}
|
|
91 |
|
|
92 |
|
|
93 |
void TTestMsSuspend::DrvWrite()
|
|
94 |
{
|
|
95 |
RFile file;
|
|
96 |
|
|
97 |
static const TInt KFileSize = 1000;
|
|
98 |
_LIT(KTxtControlFile, "ControlFile.txt");
|
|
99 |
static const TChar KFillChar = 'x';
|
|
100 |
|
|
101 |
TBuf8<KFileSize> testData;
|
|
102 |
testData.Fill(KFillChar, KFileSize);
|
|
103 |
|
|
104 |
// write control file
|
|
105 |
TInt err = file.Replace(fsSession, KTxtControlFile, EFileStream);
|
|
106 |
test(err == KErrNone);
|
|
107 |
|
|
108 |
err = file.Write(testData);
|
|
109 |
test(err == KErrNone);
|
|
110 |
|
|
111 |
file.Close();
|
|
112 |
|
|
113 |
// delete the file
|
|
114 |
err = fsSession.Delete(KTxtControlFile);
|
|
115 |
test(err == KErrNone);
|
|
116 |
}
|
|
117 |
|
|
118 |
|
|
119 |
void CallTestsL()
|
|
120 |
{
|
|
121 |
TInt driveNumber = msDrive->DriveNumber();
|
|
122 |
// Print drive info
|
|
123 |
TRAPD(err, TMsPrintDrive::VolInfoL(driveNumber));
|
|
124 |
err = err;
|
|
125 |
TTestMsSuspend t;
|
|
126 |
t.t1L();
|
|
127 |
|
|
128 |
}
|