|
1 // Copyright (c) 2003-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 // See the test specification for details of what these test cases do. |
|
15 |
|
16 |
|
17 #include <f32file.h> |
|
18 |
|
19 #include "TE_comsdbgServer.h" |
|
20 #include "TestMessage.h" |
|
21 #include "Setup.h" |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 /** |
|
28 * Function Name : CFloggerTest_Setup |
|
29 * Input parameters : None |
|
30 * Output parameters : None |
|
31 * Description : This is the constructor |
|
32 */ |
|
33 |
|
34 CFloggerTest_Setup::CFloggerTest_Setup() |
|
35 { |
|
36 // store the name of this test case |
|
37 SetTestStepName(_L("Setup_File")); |
|
38 } |
|
39 |
|
40 |
|
41 /** |
|
42 * Function Name : ~CFloggerTest_Setup |
|
43 * Input parameters : None |
|
44 * Output parameters : None |
|
45 * Description : This is the destructor |
|
46 */ |
|
47 |
|
48 |
|
49 CFloggerTest_Setup::~CFloggerTest_Setup() |
|
50 { |
|
51 } |
|
52 |
|
53 /** |
|
54 * Function Name : doTestStepL |
|
55 * Input parameters : None |
|
56 * Output parameters : TVerdict |
|
57 * Description : This function sets the flogger.ini file to run the test |
|
58 harness for flogger |
|
59 */ |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 TVerdict CFloggerTest_Setup::doTestStepL( ) |
|
65 { |
|
66 |
|
67 TInt ret = KErrNone; |
|
68 TInt r; |
|
69 RFs fileSystem; |
|
70 ret = fileSystem.Connect(); |
|
71 if (ret != 0) |
|
72 { |
|
73 SetTestStepResult(EFail); return TestStepResult(); |
|
74 } |
|
75 |
|
76 CFileMan *fman = CFileMan::NewL(fileSystem); |
|
77 // rename flogger.ini to a backup name. If not found, ignore. |
|
78 // overwrite backup if found. |
|
79 ret = fileSystem.SetAtt(KFloggerIniFile,KEntryAttNormal, KEntryAttReadOnly); |
|
80 |
|
81 ret = fman->Rename(KFloggerIniFile, KTempPreserveFloggerIniFile, CFileMan::EOverWrite ); |
|
82 |
|
83 TRAP(r,constructFloggerIniL(KDefaultIniFileSettings)); |
|
84 |
|
85 if (r == KErrNone) |
|
86 { |
|
87 ret = fileSystem.SetAtt(KFloggerIniFile,KEntryAttNormal, KEntryAttReadOnly); |
|
88 } |
|
89 else |
|
90 { |
|
91 ret = r; |
|
92 } |
|
93 delete fman; |
|
94 fileSystem.Close(); |
|
95 |
|
96 // Check to see if the setup step was successful. |
|
97 if(ret == KErrNone) |
|
98 { |
|
99 INFO_PRINTF1(_L("Setup completed.")); |
|
100 } |
|
101 else |
|
102 { |
|
103 INFO_PRINTF2(_L("Setup failed with error %d."), ret); } |
|
104 |
|
105 if (ret == 0) |
|
106 { |
|
107 SetTestStepResult(EPass); |
|
108 } |
|
109 else |
|
110 { |
|
111 SetTestStepResult(EFail); |
|
112 } |
|
113 |
|
114 return TestStepResult(); |
|
115 } |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 /** |
|
121 Simply initializes the flogger.ini to the default test config. |
|
122 */ |
|
123 |
|
124 CFloggerTest_InitializeIniFile::CFloggerTest_InitializeIniFile() |
|
125 { |
|
126 // store the name of this test case |
|
127 SetTestStepName(_L("Setup_InitializeIniFile")); |
|
128 } |
|
129 |
|
130 |
|
131 CFloggerTest_InitializeIniFile::~CFloggerTest_InitializeIniFile() |
|
132 { |
|
133 } |
|
134 |
|
135 |
|
136 |
|
137 TVerdict CFloggerTest_InitializeIniFile::doTestStepL( ) |
|
138 { |
|
139 |
|
140 TRAPD(ret,constructFloggerIniL(KDefaultIniFileSettings)); |
|
141 |
|
142 if (ret == KErrNone) |
|
143 { |
|
144 SetTestStepResult(EPass); return TestStepResult(); |
|
145 } |
|
146 else |
|
147 { |
|
148 SetTestStepResult(EFail); return TestStepResult(); |
|
149 } |
|
150 } |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 |
|
156 /** |
|
157 * Function Name : CFloggerTest_Restore |
|
158 * Input parameters : None |
|
159 * Output parameters : None |
|
160 * Description : This is the constructor |
|
161 */ |
|
162 |
|
163 |
|
164 CFloggerTest_Restore::CFloggerTest_Restore() |
|
165 { |
|
166 // store the name of this test case |
|
167 SetTestStepName(_L("Restore_File")); |
|
168 } |
|
169 |
|
170 |
|
171 /** |
|
172 * Function Name : ~CFloggerTest_Restore |
|
173 * Input parameters : None |
|
174 * Output parameters : None |
|
175 * Description : This is the destructor |
|
176 */ |
|
177 |
|
178 |
|
179 CFloggerTest_Restore::~CFloggerTest_Restore() |
|
180 { |
|
181 } |
|
182 |
|
183 /** |
|
184 * Function Name : doTestStepL |
|
185 * Input parameters : None |
|
186 * Output parameters : TVerdict |
|
187 * Description : This function restores the orginal flogger.ini file |
|
188 */ |
|
189 |
|
190 |
|
191 |
|
192 TVerdict CFloggerTest_Restore::doTestStepL( ) |
|
193 { |
|
194 RFs fileSystem; |
|
195 TInt ret = 0; |
|
196 ret = fileSystem.Connect(); |
|
197 if (ret == KErrNone) |
|
198 { |
|
199 // if replace fails, ignore since most likely the preserved file is not there |
|
200 fileSystem.Replace(KTempPreserveFloggerIniFile, KFloggerIniFile); |
|
201 } |
|
202 fileSystem.Close(); |
|
203 |
|
204 if (ret == 0) |
|
205 { |
|
206 SetTestStepResult(EPass); return TestStepResult(); |
|
207 } |
|
208 else |
|
209 { |
|
210 SetTestStepResult(EFail); return TestStepResult(); |
|
211 } |
|
212 } |
|
213 |
|
214 |
|
215 |