0
|
1 |
// Copyright (c) 2006-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 |
// Performs the reading and writing to a disk
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
|
|
19 |
#include "basetestfat32readwrite.h"
|
|
20 |
|
|
21 |
/**
|
|
22 |
Class Constructor
|
|
23 |
*/
|
|
24 |
CBaseTestFat32ReadWrite::CBaseTestFat32ReadWrite()
|
|
25 |
{
|
|
26 |
SetTestStepName(KTestStepReadWrite);
|
|
27 |
}
|
|
28 |
|
|
29 |
/**
|
|
30 |
Class Destructor
|
|
31 |
*/
|
|
32 |
CBaseTestFat32ReadWrite::~CBaseTestFat32ReadWrite()
|
|
33 |
{
|
|
34 |
}
|
|
35 |
|
|
36 |
/**
|
|
37 |
Writes and reads a file on the drive
|
|
38 |
The disk should be removed while doing read or write operation.
|
|
39 |
|
|
40 |
@return EPass if test passes and EFail if test fails
|
|
41 |
*/
|
|
42 |
TVerdict CBaseTestFat32ReadWrite::doTestStepL()
|
|
43 |
{
|
|
44 |
SetTestStepResult(EPass);
|
|
45 |
|
|
46 |
TInt r;
|
|
47 |
RFile rfile;
|
|
48 |
_LIT(KFileCreate, "RFs::Replace, expecting KErrNone");
|
|
49 |
_LIT(KTestFilename, "%c:\\TEST.txt");
|
|
50 |
TBuf<255> testFilename;
|
|
51 |
testFilename.Format(KTestFilename, (TUint)iDriveToTest);
|
|
52 |
r = rfile.Replace(iTheFs,testFilename, EFileWrite);
|
|
53 |
FAT_TEST(r == KErrNone, KFileCreate);
|
|
54 |
|
|
55 |
_LIT(KData, "Testing file operation");
|
|
56 |
TBuf8<25> buffer;
|
|
57 |
buffer.Copy(KData);
|
|
58 |
TUint index = 0;
|
|
59 |
TInt pos = 0;
|
|
60 |
|
|
61 |
while(index++<1000)
|
|
62 |
{
|
|
63 |
r = rfile.Write(buffer);
|
|
64 |
if(r == KErrNotReady)
|
|
65 |
{
|
|
66 |
INFO_PRINTF2(_L("Write Failed:%d"), r);
|
|
67 |
break;
|
|
68 |
}
|
|
69 |
}
|
|
70 |
if(r == KErrNone)
|
|
71 |
{
|
|
72 |
rfile.Seek(ESeekStart, pos);
|
|
73 |
index = 0;
|
|
74 |
while(index++ < 1000)
|
|
75 |
{
|
|
76 |
rfile.Read(buffer, 25);
|
|
77 |
if(r==KErrNotReady)
|
|
78 |
{
|
|
79 |
INFO_PRINTF2(_L("Read Failed:%d"), r);
|
|
80 |
break;
|
|
81 |
}
|
|
82 |
}
|
|
83 |
}
|
|
84 |
rfile.Close();
|
|
85 |
return TestStepResult();
|
|
86 |
}
|
|
87 |
|