|
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 "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 // __ACTION_INFO_BEGIN__ |
|
15 // [Action Name] |
|
16 // FreeDiskSpace |
|
17 // [Action Parameters] |
|
18 // [Action Description] |
|
19 // Free the disk space |
|
20 // __ACTION_INFO_END__ |
|
21 // |
|
22 // |
|
23 |
|
24 #include <f32file.h> |
|
25 |
|
26 #include "CMtfTestCase.h" |
|
27 #include "CMtfTestActionParameters.h" |
|
28 #include "CMtfTestActionFreeDiskSpace.h" |
|
29 |
|
30 _LIT(KSMSUResourceFile, "C:\\private\\101f7989\\sms\\smsu.rsc"); |
|
31 // Location of directory for reserving disk space |
|
32 _LIT(KTempDiskSpaceDirName, "C:\\sms\\temp\\"); |
|
33 |
|
34 |
|
35 /** |
|
36 Function : NewL |
|
37 Description : |
|
38 @internalTechnology |
|
39 @param : aTestCase - CMtfTestCase for the CMtfTestAction base class |
|
40 @param : aActionParams - CMtfTestActionParameters |
|
41 @return : CMtfTestAction* - a base class pointer to the newly created CMtfTestActionFreeDiskSpace object |
|
42 @pre none |
|
43 @post none |
|
44 */ |
|
45 CMtfTestAction* CMtfTestActionFreeDiskSpace::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) |
|
46 { |
|
47 CMtfTestActionFreeDiskSpace* self = new (ELeave) CMtfTestActionFreeDiskSpace(aTestCase); |
|
48 CleanupStack::PushL(self); |
|
49 self->ConstructL(aActionParameters); |
|
50 CleanupStack::Pop(self); |
|
51 return self; |
|
52 } |
|
53 |
|
54 /** |
|
55 Function : CMtfTestActionFreeDiskSpace |
|
56 Description : Constructor |
|
57 @internalTechnology |
|
58 @param : aTestCase - CMtfTestCase for the CMtfTestAction base class |
|
59 @return : N/A |
|
60 @pre none |
|
61 @post none |
|
62 */ |
|
63 CMtfTestActionFreeDiskSpace::CMtfTestActionFreeDiskSpace(CMtfTestCase& aTestCase) : CMtfSynchronousTestAction(aTestCase) |
|
64 {} |
|
65 |
|
66 /** |
|
67 Function : ~CMtfTestActionFreeDiskSpace |
|
68 Description : Destructor |
|
69 @internalTechnology |
|
70 @param : |
|
71 @return : |
|
72 @pre |
|
73 @post |
|
74 */ |
|
75 CMtfTestActionFreeDiskSpace::~CMtfTestActionFreeDiskSpace() |
|
76 { |
|
77 } |
|
78 |
|
79 /** |
|
80 Function : ExecuteActionL |
|
81 Description : Entry point for the this test action in the test framework |
|
82 @internalTechnology |
|
83 @param : none |
|
84 @return : void |
|
85 @pre none |
|
86 @post none |
|
87 */ |
|
88 void CMtfTestActionFreeDiskSpace::ExecuteActionL() |
|
89 { |
|
90 TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionFreeDiskSpace); |
|
91 |
|
92 |
|
93 RFs fs; |
|
94 User::LeaveIfError(fs.Connect()); |
|
95 |
|
96 // |
|
97 // Check if the directories actually exists, and contains something. |
|
98 // There is no point writing logging when nothing happened. |
|
99 // |
|
100 TInt ret; |
|
101 |
|
102 ret = fs.RmDir(KTempDiskSpaceDirName); |
|
103 if (ret == KErrNone || ret == KErrNotFound || ret == KErrPathNotFound) |
|
104 { |
|
105 return; |
|
106 } |
|
107 |
|
108 // |
|
109 // We need to delete the folder and it's contents... |
|
110 // |
|
111 TestCase().INFO_PRINTF1(_L("Releasing Drive C reserved disk space.")); |
|
112 |
|
113 // |
|
114 // Check the current disk space available level... |
|
115 // |
|
116 TVolumeInfo volumeInfo; |
|
117 |
|
118 User::LeaveIfError(fs.Volume(volumeInfo, EDriveC)); |
|
119 TestCase().INFO_PRINTF2(_L(" Drive C currently has %ld bytes free."), volumeInfo.iFree); |
|
120 |
|
121 // |
|
122 // Delete the whole temporary directory. Using the File Manager class |
|
123 // is the easiest way... |
|
124 // |
|
125 CFileMan* fileManager = CFileMan::NewL(fs); |
|
126 CleanupStack::PushL(fileManager); |
|
127 |
|
128 ret = fileManager->RmDir(KTempDiskSpaceDirName); |
|
129 if (ret != KErrPathNotFound && ret != KErrNone) |
|
130 { |
|
131 TestCase().INFO_PRINTF2(_L(" Delete of temporary files returned %d"), ret); |
|
132 User::Leave(ret); |
|
133 } |
|
134 |
|
135 CleanupStack::PopAndDestroy(fileManager); |
|
136 |
|
137 // |
|
138 // Displace the new free disk space value... |
|
139 // |
|
140 User::LeaveIfError(fs.Volume(volumeInfo, EDriveC)); |
|
141 TestCase().INFO_PRINTF2(_L(" Drive C now has %ld bytes free."), volumeInfo.iFree); |
|
142 |
|
143 |
|
144 // |
|
145 // Remove the RSC file... |
|
146 // Removes the low and high limits and returns the SMSU.RSC to default. |
|
147 |
|
148 |
|
149 ret = fs.Delete(KSMSUResourceFile); |
|
150 if (ret != KErrNone && ret != KErrNotFound) |
|
151 { |
|
152 User::Leave(ret); |
|
153 } |
|
154 |
|
155 fs.Close(); |
|
156 |
|
157 TestCase().INFO_PRINTF2( _L("Test Action %S completed."), &KTestActionFreeDiskSpace ); |
|
158 TestCase().ActionCompletedL( *this ); |
|
159 } |
|
160 |
|
161 |