|
1 // Copyright (c) 2007-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 // Write a x MB file on the disk (user is expected to take the card out when |
|
15 // the file is being written to the disk) |
|
16 // |
|
17 // |
|
18 |
|
19 #include "sdbigfilewrite.h" |
|
20 |
|
21 static const TInt KBlockSize = 65536; |
|
22 static TBuf8<KBlockSize> DataBlock; |
|
23 |
|
24 /* |
|
25 Class constructor |
|
26 |
|
27 @param None |
|
28 @return None |
|
29 */ |
|
30 CBaseTestSDBigFileWrite::CBaseTestSDBigFileWrite() |
|
31 { |
|
32 SetTestStepName(KTestStepBigFileWrite); |
|
33 } |
|
34 |
|
35 /* |
|
36 Test Step Preamble |
|
37 - Initialise attribute iDrive |
|
38 - Connect to the File Server |
|
39 |
|
40 @param None |
|
41 @return EPass if successful or EFail if not |
|
42 @see TVerdict |
|
43 */ |
|
44 TVerdict CBaseTestSDBigFileWrite::doTestStepPreambleL() |
|
45 { |
|
46 SetTestStepResult(EFail); |
|
47 |
|
48 if (!InitDriveLetter()) |
|
49 return TestStepResult(); |
|
50 if (!InitFileServer()) |
|
51 return TestStepResult(); |
|
52 |
|
53 SetTestStepResult(EPass); |
|
54 return TestStepResult(); |
|
55 } |
|
56 |
|
57 /* |
|
58 Test step |
|
59 |
|
60 @param None |
|
61 @return EPass if successful or EFail if not |
|
62 @see TVerdict |
|
63 */ |
|
64 TVerdict CBaseTestSDBigFileWrite::doTestStepL() |
|
65 { |
|
66 TInt r; |
|
67 TPtrC name; |
|
68 TInt size; |
|
69 |
|
70 _LIT(KTestName, "BigFileName"); |
|
71 _LIT(KTestSize, "BigFileSize"); |
|
72 _LIT8(KTestPattern, "0123456789ABCDEF"); |
|
73 |
|
74 if (!GetStringFromConfig(ConfigSection(), KTestName, name)) |
|
75 { |
|
76 ERR_PRINTF1(_L("INI File Read Error")); |
|
77 SetTestStepResult(EFail); |
|
78 return TestStepResult(); |
|
79 } |
|
80 if (!GetIntFromConfig(ConfigSection(), KTestSize, size)) |
|
81 { |
|
82 ERR_PRINTF1(_L("INI File Read Error")); |
|
83 SetTestStepResult(EFail); |
|
84 return TestStepResult(); |
|
85 } |
|
86 |
|
87 TInt i; |
|
88 for (i = 0; i < KBlockSize; i += KTestPattern().Length()) |
|
89 { |
|
90 DataBlock.Append(KTestPattern); |
|
91 } |
|
92 |
|
93 TFileName filename; |
|
94 RFile file; |
|
95 filename.Format(_L("%c:\\%S"), 'A' + iDrive, &name); |
|
96 r = file.Create(iFs, filename, EFileWrite); |
|
97 if (r != KErrNone) |
|
98 { |
|
99 ERR_PRINTF3(_L("Error %d RFile::Create %S"), r, &filename); |
|
100 SetTestStepResult(EFail); |
|
101 return TestStepResult(); |
|
102 } |
|
103 for (i = 0; i < (size << 20); i += KBlockSize) |
|
104 { |
|
105 r = file.Write(i, DataBlock); |
|
106 if (r != KErrNone) |
|
107 { |
|
108 INFO_PRINTF2(_L("Error %d RFile::Write"), r); |
|
109 break; |
|
110 } |
|
111 } |
|
112 file.Close(); |
|
113 SetTestStepResult(EPass); |
|
114 return TestStepResult(); |
|
115 } |
|
116 |
|
117 /* |
|
118 Test step postamble |
|
119 |
|
120 @param None |
|
121 @return EPass if successful or EFail if not |
|
122 @see TVerdict |
|
123 */ |
|
124 TVerdict CBaseTestSDBigFileWrite::doTestStepPostambleL() |
|
125 { |
|
126 DataBlock = _L8(""); |
|
127 return TestStepResult(); |
|
128 } |