1 /* |
|
2 * Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 /** |
|
22 @file |
|
23 */ |
|
24 #ifndef __TINTEGRITYSERVICESSTEP_H__ |
|
25 #define __TINTEGRITYSERVICESSTEP_H__ |
|
26 |
|
27 #include "tintegrityservicescommon.h" |
|
28 #include "tststestsuitestep.h" |
|
29 #include "tintegrityservicesclientserver.h" |
|
30 #include "journal.h" |
|
31 #include "integrityservices.h" |
|
32 |
|
33 |
|
34 // Base class for all steps |
|
35 class CIntegrityServicesStepBase : public CStsBaseTestStep |
|
36 { |
|
37 public: |
|
38 CIntegrityServicesStepBase(CStsTestServer &aStsTestServer); |
|
39 virtual void ImplTestStepPreambleL(); |
|
40 virtual void ImplTestStepPostambleL(); |
|
41 |
|
42 private: |
|
43 void ReadFailureSettingsL(); |
|
44 |
|
45 protected: |
|
46 // Extension of config parser to allow you to get array of descriptors |
|
47 void GetStringArrayFromConfigL(const TDesC& aSectName, const TDesC& aKeyName, RArray<TPtrC>& aArray); |
|
48 |
|
49 TBool CheckFilesL(); |
|
50 void doInstallL(); |
|
51 void doRecoverL(); |
|
52 void doCleanupL(); |
|
53 |
|
54 protected: |
|
55 RIntegrityServicesServerSession iIntegritySession; |
|
56 }; |
|
57 |
|
58 // Step which starts installation |
|
59 class CInstallStep : public CIntegrityServicesStepBase |
|
60 { |
|
61 public: |
|
62 CInstallStep(CStsTestServer &aStsTestServer); |
|
63 virtual void ImplTestStepL(); |
|
64 }; |
|
65 |
|
66 // Step which recovers a previous failed installation |
|
67 class CRecoverStep : public CIntegrityServicesStepBase |
|
68 { |
|
69 public: |
|
70 CRecoverStep(CStsTestServer &aStsTestServer); |
|
71 virtual void ImplTestStepL(); |
|
72 }; |
|
73 |
|
74 // Step which cleans up files between test cases |
|
75 class CCleanupStep : public CIntegrityServicesStepBase |
|
76 { |
|
77 public: |
|
78 CCleanupStep(CStsTestServer &aStsTestServer); |
|
79 virtual void ImplTestStepL(); |
|
80 }; |
|
81 |
|
82 // Step which checks for files |
|
83 class CCheckStep : public CIntegrityServicesStepBase |
|
84 { |
|
85 public: |
|
86 CCheckStep(CStsTestServer &aStsTestServer); |
|
87 virtual void ImplTestStepL(); |
|
88 }; |
|
89 |
|
90 //---------- new unit tests developed as part of the STS framework ---------- |
|
91 union TIntValue |
|
92 { |
|
93 TInt8 int8; |
|
94 TInt16 int16; |
|
95 TInt32 int32; |
|
96 }; |
|
97 |
|
98 enum TIntMode |
|
99 { |
|
100 Mode8Bit =1, |
|
101 Mode16Bit =2, |
|
102 Mode32Bit =4 |
|
103 }; |
|
104 |
|
105 _LIT(KEmptyString, ""); |
|
106 _LIT(KDriveLetterC, "c"); |
|
107 _LIT(KDriveLetterE, "e"); |
|
108 _LIT(KKournalFileExt, ".log"); |
|
109 |
|
110 class CTestFile : public CBase |
|
111 { |
|
112 public: |
|
113 CTestFile(RFs& aFs); |
|
114 ~CTestFile(); |
|
115 static CTestFile* NewL(RFs& aFs); |
|
116 void OpenJournalFileL(const TDesC& aFileName, TFileMode aMode); |
|
117 void CloseJournalFile(); |
|
118 void CreateJournalFileL(const TDesC& aFileName, TFileMode aMode); |
|
119 void WriteIntToJournalFileL(TIntValue value, TIntMode mode); |
|
120 TIntValue ReadIntFromJournalFileL(TIntMode mode); |
|
121 void SeekInJournalFileL(TSeek aSeekMode, TInt &aPos); |
|
122 |
|
123 protected: |
|
124 RFs& iFs; |
|
125 RFile journalFile; |
|
126 }; |
|
127 |
|
128 class CJournalFileUnitTest : public CStsBaseTestStep |
|
129 { |
|
130 public: |
|
131 CJournalFileUnitTest(CStsTestServer &aStsTestServer); |
|
132 ~CJournalFileUnitTest(); |
|
133 virtual void ImplTestStepPreambleL(); |
|
134 virtual void ImplTestStepPostambleL(); |
|
135 virtual void ImplTestStepL(); |
|
136 |
|
137 protected: |
|
138 void OpenJournalFileL(const TDesC& aFileName, TFileMode aMode); |
|
139 void CloseJournalFile(); |
|
140 void CreateJournalFileL(const TDesC& aFileName, TFileMode aMode); |
|
141 void WriteIntToJournalFileL(TIntValue value, TIntMode mode); |
|
142 TIntValue ReadIntFromJournalFileL(TIntMode mode); |
|
143 void SeekInJournalFileL(TSeek aSeekMode, TInt &aPos); |
|
144 |
|
145 protected: |
|
146 RFs iFs; |
|
147 RLoader iLoader; |
|
148 CTestFile* testJournalFile; |
|
149 }; |
|
150 |
|
151 class CJournalFileUnitTestScenarioBase : public CStsBaseTestStep |
|
152 { |
|
153 public: |
|
154 CJournalFileUnitTestScenarioBase(CStsTestServer &aStsTestServer); |
|
155 ~CJournalFileUnitTestScenarioBase(); |
|
156 virtual void ImplTestStepPreambleL(); |
|
157 virtual void ImplTestStepPostambleL(); |
|
158 virtual void ImplTestStepL(); |
|
159 |
|
160 private: |
|
161 static void InTestCleanup(TAny* aObject); |
|
162 virtual void ImplTestCaseScenarioL()=0; //implements the real test scenario executed in OOM test |
|
163 |
|
164 protected: |
|
165 RFs iFs; |
|
166 RLoader iLoader; |
|
167 TPtrC iJournalFileName; |
|
168 HBufC* iTargetFileName; |
|
169 HBufC* iBackupFileName; |
|
170 TDriveUnit iJournaldrive; |
|
171 TBool iCleanupNeeded; |
|
172 }; |
|
173 |
|
174 class CJournalFileUnitTestAdd : public CJournalFileUnitTestScenarioBase |
|
175 { |
|
176 public: |
|
177 CJournalFileUnitTestAdd(CStsTestServer &aStsTestServer); |
|
178 virtual void ImplTestCaseScenarioL(); |
|
179 }; |
|
180 |
|
181 class CJournalFileUnitTestTemp : public CJournalFileUnitTestScenarioBase |
|
182 { |
|
183 public: |
|
184 CJournalFileUnitTestTemp(CStsTestServer &aStsTestServer); |
|
185 virtual void ImplTestCaseScenarioL(); |
|
186 }; |
|
187 |
|
188 class CJournalFileUnitTestRemove : public CJournalFileUnitTestScenarioBase |
|
189 { |
|
190 public: |
|
191 CJournalFileUnitTestRemove(CStsTestServer &aStsTestServer); |
|
192 virtual void ImplTestCaseScenarioL(); |
|
193 }; |
|
194 |
|
195 class CJournalFileUnitTestRead : public CJournalFileUnitTestScenarioBase |
|
196 { |
|
197 public: |
|
198 CJournalFileUnitTestRead(CStsTestServer &aStsTestServer); |
|
199 virtual void ImplTestCaseScenarioL(); |
|
200 }; |
|
201 |
|
202 class CJournalFileUnitTestEvent : public CJournalFileUnitTestScenarioBase |
|
203 { |
|
204 public: |
|
205 CJournalFileUnitTestEvent(CStsTestServer &aStsTestServer); |
|
206 virtual void ImplTestCaseScenarioL(); |
|
207 }; |
|
208 |
|
209 class CJournalUnitTest : public CStsBaseTestStep |
|
210 { |
|
211 public: |
|
212 CJournalUnitTest(CStsTestServer &aStsTestServer); |
|
213 ~CJournalUnitTest(); |
|
214 virtual void ImplTestStepPreambleL(); |
|
215 virtual void ImplTestStepPostambleL(); |
|
216 virtual void ImplTestStepL(); |
|
217 |
|
218 private: |
|
219 void TestCase1L(); |
|
220 |
|
221 protected: |
|
222 RFs iFs; |
|
223 RLoader iLoader; |
|
224 CTestFile* iTestFileInterface; |
|
225 TInt iTrID; |
|
226 TPtrC iJournalPathInIni; |
|
227 }; |
|
228 |
|
229 |
|
230 class CJournalUnitTestScenarioBase : public CStsBaseTestStep |
|
231 { |
|
232 public: |
|
233 CJournalUnitTestScenarioBase(CStsTestServer &aStsTestServer); |
|
234 ~CJournalUnitTestScenarioBase(); |
|
235 virtual void ImplTestStepPreambleL(); |
|
236 virtual void ImplTestStepPostambleL(); |
|
237 virtual void ImplTestStepL(); |
|
238 |
|
239 protected: |
|
240 virtual void ScenarioEndL(Usif::CJournal* aJournal)=0; |
|
241 static void InTestCleanUp(TAny* aObject); |
|
242 |
|
243 protected: |
|
244 RFs iFs; |
|
245 RLoader iLoader; |
|
246 TInt iTrID; |
|
247 TPtrC iJournalPathInIni; |
|
248 HBufC* iTargetFileName; |
|
249 TDriveUnit iDriveUnitC; |
|
250 TDriveUnit iDriveUnitE; |
|
251 HBufC* iJournalFileName; |
|
252 HBufC* iDrvFileName; |
|
253 HBufC* iBackupFileName; |
|
254 }; |
|
255 |
|
256 class CJournalUnitTestInstall : public CJournalUnitTestScenarioBase |
|
257 { |
|
258 public: |
|
259 CJournalUnitTestInstall(CStsTestServer &aStsTestServer); |
|
260 protected: |
|
261 virtual void ScenarioEndL(Usif::CJournal* aJournal); |
|
262 }; |
|
263 |
|
264 class CJournalUnitTestRollback : public CJournalUnitTestScenarioBase |
|
265 { |
|
266 public: |
|
267 CJournalUnitTestRollback(CStsTestServer &aStsTestServer); |
|
268 protected: |
|
269 virtual void ScenarioEndL(Usif::CJournal* aJournal); |
|
270 }; |
|
271 |
|
272 _LIT(KTransactionPath, "\\sys\\install\\integrityservices\\"); |
|
273 |
|
274 class CIntegrityServicesTestScenarioBase : public CStsBaseTestStep |
|
275 { |
|
276 public: |
|
277 CIntegrityServicesTestScenarioBase(CStsTestServer &aStsTestServer); |
|
278 ~CIntegrityServicesTestScenarioBase(); |
|
279 virtual void ImplTestStepPreambleL(); |
|
280 virtual void ImplTestStepPostambleL(); |
|
281 virtual void ImplTestStepL(); |
|
282 |
|
283 protected: |
|
284 virtual void ScenarioEndL(Usif::CIntegrityServices* aIntegrServ)=0; |
|
285 static void InTestCleanUp(TAny* aObject); |
|
286 void NormalizeDirectoryName(TDes& aFileName); |
|
287 |
|
288 protected: |
|
289 RFs iFs; |
|
290 RLoader iLoader; |
|
291 TInt iTrID; |
|
292 TPtrC iTargetPathInIni; |
|
293 HBufC* iTargetFileName; |
|
294 TDriveUnit iDriveUnitC; |
|
295 TDriveUnit iDriveUnitE; |
|
296 HBufC* iBackupFileName; |
|
297 HBufC* iTransactionBackupDirectoryPath; |
|
298 HBufC* iJournalFileName; |
|
299 HBufC* iDrvFileName; |
|
300 }; |
|
301 |
|
302 class CIntegrityServicesTestInstall : public CIntegrityServicesTestScenarioBase |
|
303 { |
|
304 public: |
|
305 CIntegrityServicesTestInstall(CStsTestServer &aStsTestServer); |
|
306 protected: |
|
307 virtual void ScenarioEndL(Usif::CIntegrityServices* aIntegrServ); |
|
308 }; |
|
309 |
|
310 class CIntegrityServicesTestRollback : public CIntegrityServicesTestScenarioBase |
|
311 { |
|
312 public: |
|
313 CIntegrityServicesTestRollback(CStsTestServer &aStsTestServer); |
|
314 protected: |
|
315 virtual void ScenarioEndL(Usif::CIntegrityServices* aIntegrServ); |
|
316 }; |
|
317 |
|
318 #endif |
|