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 // Perofrms various types of formatting of a disk |
|
15 // |
|
16 // |
|
17 |
|
18 #include "basetestfat32format.h" |
|
19 |
|
20 /** |
|
21 Class Constructor |
|
22 */ |
|
23 CBaseTestFat32Format::CBaseTestFat32Format() |
|
24 { |
|
25 SetTestStepName(KTestStepFormat); |
|
26 } |
|
27 |
|
28 /** |
|
29 Class Destructor |
|
30 */ |
|
31 CBaseTestFat32Format::~CBaseTestFat32Format() |
|
32 { |
|
33 } |
|
34 |
|
35 |
|
36 /** |
|
37 Get the type of format required from the ini file and format the disk |
|
38 |
|
39 @return EPass if test passes and EFail if test fails |
|
40 */ |
|
41 |
|
42 TVerdict CBaseTestFat32Format::doTestStepL() |
|
43 { |
|
44 _LIT(KFormatType,"FormatType"); |
|
45 TBuf<4> formatType; |
|
46 TPtrC16 format = formatType; |
|
47 SetTestStepResult(EFail); |
|
48 TDriveUnit drive (CurrentDrive()); |
|
49 TBool alright = GetStringFromConfig(ConfigSection(), KFormatType, format); |
|
50 if(alright) |
|
51 { |
|
52 TInt r = FormatFat(drive, format); |
|
53 if (r != KErrNone) |
|
54 { |
|
55 _LIT(KFormatError, "Error %d - could not format %c drive"); |
|
56 INFO_PRINTF3(KFormatError, r, (TUint)iDriveToTest); |
|
57 SetTestStepResult(EFail); |
|
58 return TestStepResult(); |
|
59 } |
|
60 } |
|
61 else |
|
62 { |
|
63 _LIT(KErrorRead, "Cannot get the format type from the ini file"); |
|
64 INFO_PRINTF1(KErrorRead); |
|
65 SetTestStepResult(EFail); |
|
66 return TestStepResult(); |
|
67 } |
|
68 SetTestStepResult(EPass); |
|
69 return TestStepResult(); |
|
70 } |
|
71 |
|
72 |
|
73 /** |
|
74 Format the disk |
|
75 |
|
76 @param aDrive The drive to format |
|
77 @param aFormat The type of format to perform |
|
78 |
|
79 @return EPass if test passes and EFail if test fails |
|
80 */ |
|
81 TInt CBaseTestFat32Format::FormatFat(TDriveUnit aDrive, TPtrC16 aFormat) |
|
82 { |
|
83 TInt count; |
|
84 RFormat format; |
|
85 TInt r; |
|
86 TFormatMode formatMode = EFullFormat; |
|
87 if (aFormat == _L("Full")) |
|
88 { |
|
89 formatMode = EFullFormat; |
|
90 } |
|
91 else if (aFormat == _L("Special")) |
|
92 { |
|
93 formatMode = ESpecialFormat; |
|
94 } |
|
95 else if (aFormat == _L("Quick")) |
|
96 { |
|
97 formatMode = EQuickFormat; |
|
98 } |
|
99 |
|
100 r = format.Open(iTheFs,aDrive.Name(),formatMode,count); |
|
101 if(r!=KErrNone) |
|
102 { |
|
103 _LIT(KFormatOpen, "Device could not be opened for formatting"); |
|
104 INFO_PRINTF1(KFormatOpen); |
|
105 return r; |
|
106 } |
|
107 INFO_PRINTF2(_L("Count = %d"), count); |
|
108 do { |
|
109 r = format.Next(count); |
|
110 if (r != KErrNone) |
|
111 { |
|
112 _LIT(KFormatNextError, "format.Next() error %d count %d\n"); |
|
113 INFO_PRINTF3(KFormatNextError, r, count); |
|
114 return r; |
|
115 } |
|
116 }while (count > 0); |
|
117 format.Close(); |
|
118 INFO_PRINTF2(_L("Count = %d"), count); |
|
119 return r; |
|
120 } |
|