300
|
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 |
#include "cblockdevicetester.h"
|
|
30 |
|
|
31 |
extern CMsDrive* msDrive;
|
|
32 |
|
|
33 |
RTest test(_L("T_MSRMB"));
|
|
34 |
RFs fsSession;
|
|
35 |
|
|
36 |
class TTests
|
|
37 |
{
|
|
38 |
public:
|
|
39 |
TTests(TInt aDriveNumber);
|
|
40 |
|
|
41 |
void FullFormat();
|
|
42 |
|
|
43 |
void tRemovableSet();
|
|
44 |
void tRemovableClr();
|
|
45 |
void RemountDrive();
|
|
46 |
|
|
47 |
private:
|
|
48 |
TInt iDriveNumber;
|
|
49 |
};
|
|
50 |
|
|
51 |
TTests::TTests(TInt aDriveNumber)
|
|
52 |
: iDriveNumber(aDriveNumber)
|
|
53 |
{
|
|
54 |
}
|
|
55 |
|
|
56 |
|
|
57 |
void TTests::RemountDrive()
|
|
58 |
{
|
|
59 |
TDriveInfo info;
|
|
60 |
const TUint KMediaRemountForceMediaChange = 0x00000001;
|
|
61 |
|
|
62 |
TRequestStatus changeStatus;
|
|
63 |
fsSession.NotifyChange(ENotifyAll, changeStatus);
|
|
64 |
|
|
65 |
test.Printf(_L("Remounting the drive\n"));
|
|
66 |
TInt err = fsSession.RemountDrive(iDriveNumber, NULL, KMediaRemountForceMediaChange);
|
|
67 |
test(err == KErrNotReady || err == KErrNone);
|
|
68 |
|
|
69 |
do
|
|
70 |
{
|
|
71 |
test.Printf(_L("Waiting for media change...\n"));
|
|
72 |
User::WaitForRequest(changeStatus);
|
|
73 |
|
|
74 |
err = fsSession.Drive(info, iDriveNumber);
|
|
75 |
test.Printf(_L("Completed\n"));
|
|
76 |
|
|
77 |
fsSession.NotifyChange(ENotifyAll, changeStatus);
|
|
78 |
}
|
|
79 |
while (err == KErrNotReady);
|
|
80 |
fsSession.NotifyChangeCancel(changeStatus);
|
|
81 |
}
|
|
82 |
|
|
83 |
|
|
84 |
void TTests::tRemovableSet()
|
|
85 |
{
|
|
86 |
test.Start(_L("tRemovableSet\n"));
|
|
87 |
|
|
88 |
TDriveInfo driveInfo;
|
|
89 |
TInt err = fsSession.Drive(driveInfo);
|
|
90 |
test(err == KErrNone);
|
|
91 |
|
|
92 |
test.Printf(_L("DriveInfo DriveAtt= %x\n"), driveInfo.iDriveAtt);
|
|
93 |
|
|
94 |
test(driveInfo.iDriveAtt&KDriveAttRemovable != 0);
|
|
95 |
test.End();
|
|
96 |
}
|
|
97 |
|
|
98 |
|
|
99 |
void TTests::tRemovableClr()
|
|
100 |
{
|
|
101 |
test.Start(_L("tRemovableClr\n"));
|
|
102 |
|
|
103 |
TDriveInfo driveInfo;
|
|
104 |
TInt err = fsSession.Drive(driveInfo);
|
|
105 |
test(err == KErrNone);
|
|
106 |
|
|
107 |
test.Printf(_L("DriveInfo DriveAtt= %x\n"), driveInfo.iDriveAtt);
|
|
108 |
|
|
109 |
test(driveInfo.iDriveAtt&KDriveAttRemovable != 0);
|
|
110 |
test.End();
|
|
111 |
}
|
|
112 |
|
|
113 |
|
|
114 |
void TTests::FullFormat()
|
|
115 |
{
|
|
116 |
TInt counter;
|
|
117 |
RFormat format;
|
|
118 |
test.Next(_L("Test EFullFormat"));
|
|
119 |
|
|
120 |
TInt err = format.Open(fsSession, msDrive->GetSessionPath(), EFullFormat, counter);
|
|
121 |
test(err == KErrNone);
|
|
122 |
while (counter)
|
|
123 |
{
|
|
124 |
err = format.Next(counter);
|
|
125 |
test(err == KErrNone);
|
|
126 |
}
|
|
127 |
format.Close();
|
|
128 |
}
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
void CallTestsL()
|
|
133 |
{
|
|
134 |
TInt driveNumber = msDrive->DriveNumber();
|
|
135 |
// Print drive info
|
|
136 |
TRAPD(err, TMsPrintDrive::VolInfoL(driveNumber));
|
|
137 |
err = err;
|
|
138 |
|
|
139 |
TTests t(driveNumber);
|
|
140 |
|
|
141 |
test.Printf(_L("Preparing target drive..."));
|
|
142 |
//t.FullFormat();
|
|
143 |
|
|
144 |
CWrPrTester* wpTester = CWrPrTester::NewL(driveNumber);
|
|
145 |
CleanupStack::PushL(wpTester);
|
|
146 |
test.Printf(_L("Target drive ready.\n"));
|
|
147 |
|
|
148 |
test.Start(_L("REMOVABLE"));
|
|
149 |
|
|
150 |
test.Next(_L("Test RMB=Set\n"));
|
|
151 |
err = wpTester->SetRemovableL();
|
|
152 |
test(err == KErrNone);
|
|
153 |
t.RemountDrive();
|
|
154 |
t.tRemovableSet();
|
|
155 |
|
|
156 |
test.Next(_L("Test RMB=Clr\n"));
|
|
157 |
err = wpTester->ClrRemovableL();
|
|
158 |
test(err == KErrNone);
|
|
159 |
t.RemountDrive();
|
|
160 |
t.tRemovableClr();
|
|
161 |
test.End();
|
|
162 |
|
|
163 |
CleanupStack::PopAndDestroy(wpTester);
|
|
164 |
}
|