19 #include <e32cons.h> |
19 #include <e32cons.h> |
20 #include <e32svr.h> |
20 #include <e32svr.h> |
21 #include <f32file.h> |
21 #include <f32file.h> |
22 #include <HAL.h> |
22 #include <HAL.h> |
23 #include <hal_data.h> |
23 #include <hal_data.h> |
24 #include <stiflogger.h> |
24 #include "stiflogger.h" |
25 #include <QString> |
25 #include <QString> |
26 #include "stifexecutor.h" |
26 #include "stifexecutor.h" |
27 #include "StifTFwIf.h" |
27 #include "StifTFwIf.h" |
28 |
28 |
|
29 _LIT( KLogPath, "\\Logs\\STFUI\\" ); |
|
30 // Log file |
|
31 _LIT( KLogFile, "StifUi.log" ); |
29 |
32 |
30 CStifExecutor::CStifExecutor() : |
33 CStifExecutor::CStifExecutor() : |
31 listenerList(NULL) |
34 listenerList(NULL) |
32 { |
35 { |
33 // __LOG(_L("started")); |
36 iLog = CStifLogger::NewL( KLogPath, |
|
37 KLogFile, |
|
38 CStifLogger::ETxt, |
|
39 CStifLogger::EFile, |
|
40 ETrue, |
|
41 ETrue, |
|
42 ETrue, |
|
43 EFalse, |
|
44 ETrue, |
|
45 EFalse, |
|
46 100 ); |
|
47 |
|
48 |
|
49 iLog->Log(_L("started")); |
34 TInt result; |
50 TInt result; |
35 TRAP(result, CUIStoreIf::ConstructL()); |
51 TRAP(result, CUIStoreIf::ConstructL()); |
36 // __LOG1(_L("CUIStoreIf ConstructL, result=%d"), result); |
52 iLog->Log(_L("CUIStoreIf ConstructL, result=%d"), result); |
37 if (result != KErrNone) |
53 if (result != KErrNone) |
38 { |
54 { |
39 return; |
55 return; |
40 } |
56 } |
41 TRAP(result, iBuffer = HBufC::NewL(500)); |
57 TRAP(result, iBuffer = HBufC::NewL(500)); |
42 // __LOG1(_L("Create Case Execution output buffer, result=%d"), result); |
58 iLog->Log(_L("Create Case Execution output buffer, result=%d"), result); |
43 |
59 |
44 } |
60 } |
45 |
61 |
46 CStifExecutor::~CStifExecutor() |
62 CStifExecutor::~CStifExecutor() |
47 { |
63 { |
110 |
138 |
111 QList<CSTFModule> CStifExecutor::GetModuleList() |
139 QList<CSTFModule> CStifExecutor::GetModuleList() |
112 { |
140 { |
113 QList<CSTFModule> list; |
141 QList<CSTFModule> list; |
114 RRefArray<TDesC> modules; |
142 RRefArray<TDesC> modules; |
115 // __LOG(_L("GetModuleList")); |
143 iLog->Log(_L("GetModuleList")); |
116 TInt ret = UIStore().Modules(modules); |
144 TInt ret = UIStore().Modules(modules); |
117 // __LOG1(_L("LoadAllModules %d"), ret); |
145 iLog->Log(_L("LoadAllModules %d"), ret); |
118 // __LOG1(_L("Modules number=%d"), modules.Count()); |
146 iLog->Log(_L("Modules number=%d"), modules.Count()); |
119 for (TInt i = 0; i < modules.Count(); i++) |
147 for (TInt i = 0; i < modules.Count(); i++) |
120 { |
148 { |
121 // __LOG1(_L("Get Module Names %d"), i); |
149 iLog->Log(_L("Get Module Names %d"), i); |
|
150 iLog->Log(_L("Get Module Name = %d .=%s"),i,modules[i].Ptr()); |
|
151 |
122 CSTFModule module; |
152 CSTFModule module; |
123 module.SetName(QString::fromUtf16(modules[i].Ptr(), |
153 module.SetName(QString::fromUtf16(modules[i].Ptr(), |
124 modules[i].Length())); |
154 modules[i].Length())); |
125 //module.SetName(TDesC2QString(modules[i])); |
155 //module.SetName(TDesC2QString(modules[i])); |
126 list.append(module); |
156 list.append(module); |
150 return list; |
181 return list; |
151 } |
182 } |
152 |
183 |
153 void CStifExecutor::ExecuteSingleCase(const QString& moduleName, const int caseIndex) |
184 void CStifExecutor::ExecuteSingleCase(const QString& moduleName, const int caseIndex) |
154 { |
185 { |
155 // __LOG(_L("ExecuteCase start")); |
186 iLog->Log(_L("ExecuteCase start")); |
156 TPtrC name = QString2TPtrC(moduleName); |
187 TPtrC name = QString2TPtrC(moduleName); |
157 RRefArray<CTestInfo> testCases; |
188 RRefArray<CTestInfo> testCases; |
158 TInt ret = UIStore().TestCases(testCases, name, KNullDesC); |
189 TInt ret = UIStore().TestCases(testCases, name, KNullDesC); |
159 // __LOG1(_L("Get TestCases return code=%d"), ret); |
190 iLog->Log(_L("Get TestCases return code=%d"), ret); |
160 if (testCases.Count() > caseIndex) |
191 if (testCases.Count() > caseIndex) |
161 { |
192 { |
162 TInt index; |
193 TInt index; |
163 UIStore().StartTestCase(testCases[caseIndex], index); |
194 UIStore().StartTestCase(testCases[caseIndex], index); |
164 // __LOG1(_L("start test case index=%d"), index); |
195 iLog->Log(_L("start test case index=%d"), index); |
165 } |
196 } |
166 testCases.Reset(); |
197 testCases.Reset(); |
167 testCases.Close(); |
198 testCases.Close(); |
168 // __LOG(_L("ExecuteCase end")); |
199 iLog->Log(_L("ExecuteCase end")); |
169 |
200 |
170 } |
201 } |
171 |
202 |
172 QList<QString> CStifExecutor::GetSetList() |
203 QList<QString> CStifExecutor::GetSetList() |
173 { |
204 { |
174 QList<QString> list; |
205 QList<QString> list; |
175 RRefArray<TDesC> aArray; |
206 RRefArray<TDesC> aArray; |
176 TInt ret = UIStore().GetTestSetsList(aArray); |
207 TInt ret = UIStore().GetTestSetsList(aArray); |
177 // __LOG1(_L("Get TestSet list return code=%d"), ret); |
208 iLog->Log(_L("Get TestSet list return code=%d"), ret); |
178 if (ret != KErrNone) //setInfos.Count() != 1 |
209 if (ret != KErrNone) //setInfos.Count() != 1 |
179 { |
210 { |
180 return list; |
211 return list; |
181 } |
212 } |
182 for (int i = 0; i < aArray.Count(); i++) |
213 for (int i = 0; i < aArray.Count(); i++) |
188 return list; |
219 return list; |
189 } |
220 } |
190 |
221 |
191 QList<CSTFCase> CStifExecutor::GetCaseListFromSet(const QString& setName) |
222 QList<CSTFCase> CStifExecutor::GetCaseListFromSet(const QString& setName) |
192 { |
223 { |
193 // __LOG(_L("GetCaseListFromSet start.")); |
224 iLog->Log(_L("GetCaseListFromSet start.")); |
194 QList<CSTFCase> list; |
225 QList<CSTFCase> list; |
195 TPtrC name = QString2TPtrC(setName); |
226 TPtrC name = QString2TPtrC(setName); |
196 |
227 |
197 //__LOG(name); |
228 //iLog->Log(name); |
198 if (name.Length() == 0) |
229 if (name.Length() == 0) |
199 { |
230 { |
200 return list; |
231 return list; |
201 } |
232 } |
202 |
233 |
203 // __LOG1(_L("name.Length()=%d"), name.Length()); |
234 iLog->Log(_L("name.Length()=%d"), name.Length()); |
204 TInt ret = UIStore().LoadTestSet(name); |
235 TInt ret = UIStore().LoadTestSet(name); |
205 // __LOG1(_L("Load Test Set return=%d"),ret); |
236 iLog->Log(_L("Load Test Set return=%d"),ret); |
206 const CTestSetInfo* set = NULL; |
237 const CTestSetInfo* set = NULL; |
207 TRAP(ret , set = &UIStore().TestSetL(name)); |
238 TRAP(ret , set = &UIStore().TestSetL(name)); |
208 // __LOG(_L("GetCaseListFromSet TestSetL.")); |
239 iLog->Log(_L("GetCaseListFromSet TestSetL.")); |
209 if(ret != KErrNone) |
240 if(ret != KErrNone) |
210 { |
241 { |
211 return list; |
242 return list; |
212 } |
243 } |
213 const RRefArray<const CTestInfo>& testCases = set->TestCases(); |
244 const RRefArray<const CTestInfo>& testCases = set->TestCases(); |
214 // __LOG(_L("GetCaseListFromSet TestCases.")); |
245 iLog->Log(_L("GetCaseListFromSet TestCases.")); |
215 TInt count = testCases.Count(); |
246 TInt count = testCases.Count(); |
216 for (TInt i = 0; i < count; i++) |
247 for (TInt i = 0; i < count; i++) |
217 { |
248 { |
218 CSTFCase testcase; |
249 CSTFCase testcase; |
219 testcase.SetName(TDesC2QString(testCases[i].TestCaseTitle())); |
250 testcase.SetName(TDesC2QString(testCases[i].TestCaseTitle())); |
220 testcase.SetIndex(testCases[i].TestCaseNum()); |
251 testcase.SetIndex(testCases[i].TestCaseNum()); |
221 testcase.SetModuleName(TDesC2QString(testCases[i].ModuleName())); |
252 testcase.SetModuleName(TDesC2QString(testCases[i].ModuleName())); |
222 list.append(testcase); |
253 list.append(testcase); |
223 } |
254 } |
224 // __LOG(_L("GetCaseListFromSet end.")); |
255 iLog->Log(_L("GetCaseListFromSet end.")); |
225 return list; |
256 return list; |
226 } |
257 } |
227 |
258 |
228 void CStifExecutor::CreateSet(const QString& setName) |
259 bool CStifExecutor::CreateSet(const QString& setName) |
229 { |
260 { |
230 TPtrC name = QString2TPtrC(setName); |
261 TPtrC name = QString2TPtrC(setName); |
231 TInt ret = UIStore().CreateTestSet(name); |
262 TInt ret = UIStore().CreateTestSet(name); |
232 // __LOG1(_L("CreateSet return: %d"), ret); |
263 return LogResult(ret, "CreateSet"); |
233 // ret = UIStore().LoadTestSet(name); |
264 } |
234 // __LOG1(_L("Load Set after CreateSet return: %d"), ret); |
265 |
235 |
266 bool CStifExecutor::SaveSet(QString& setName) |
236 |
|
237 } |
|
238 |
|
239 void CStifExecutor::SaveSet(QString& setName) |
|
240 { |
267 { |
241 TPtrC name = QString2TPtrC(setName); |
268 TPtrC name = QString2TPtrC(setName); |
242 TFileName testSetName; |
269 TFileName testSetName; |
243 testSetName.Copy(name); |
270 testSetName.Copy(name); |
244 TInt ret = UIStore().SaveTestSet(testSetName); |
271 TInt ret = UIStore().SaveTestSet2(testSetName); |
245 setName = TDesC2QString(testSetName); |
272 setName = TDesC2QString(testSetName); |
246 // __LOG1(_L("SaveSet return: %d"),ret); |
273 return LogResult(ret, "SaveSet"); |
247 } |
274 } |
248 |
275 |
249 void CStifExecutor::RemoveSet(const QString& setName) |
276 bool CStifExecutor::RemoveSet(const QString& setName) |
250 { |
277 { |
251 //This method wil not work at this stage. |
278 //This method wil not work at this stage. |
252 TPtrC name = QString2TPtrC(setName); |
279 TPtrC name = QString2TPtrC(setName); |
253 UIStore().RemoveTestSet(name); |
280 TInt ret = UIStore().RemoveTestSet(name); |
254 } |
281 return LogResult(ret, "RemoveSet"); |
255 |
282 } |
256 void CStifExecutor::AddtoSet(const QString& setName, CSTFCase& caseInfo) |
283 |
257 { |
284 bool CStifExecutor::AddtoSet(const QString& setName, CSTFCase& caseInfo) |
|
285 { |
|
286 iLog->Log(_L("AddToSet Start")); |
|
287 |
258 //IMPORT_C TInt AddToTestSet( const TDesC& aSetName, const CTestInfo& aTestInfo ); |
288 //IMPORT_C TInt AddToTestSet( const TDesC& aSetName, const CTestInfo& aTestInfo ); |
259 TPtrC modulename = QString2TPtrC(caseInfo.ModuleName()); |
289 TPtrC modulename = QString2TPtrC(caseInfo.ModuleName()); |
|
290 iLog->Log(_L("AddToSet dealwith module: %s"), modulename.Ptr()); |
|
291 iLog->Log(_L("Case name: %s"),QString2TPtrC(caseInfo.Name()).Ptr()); |
|
292 iLog->Log(_L("Case index: %d"),caseInfo.Index()); |
|
293 TInt caseIndex = caseInfo.Index(); |
|
294 if(caseInfo.ModuleName().toLower() == "testscripter" |
|
295 ||caseInfo.ModuleName().toLower() == "teftestmodule") |
|
296 { |
|
297 caseIndex++; |
|
298 } |
260 RRefArray<CTestInfo> testCases; |
299 RRefArray<CTestInfo> testCases; |
261 TInt ret = UIStore().TestCases(testCases, modulename, KNullDesC); |
300 TInt ret = UIStore().TestCases(testCases, modulename, KNullDesC); |
262 // __LOG1(_L("Get TestCases: %d"), ret); |
301 if(!LogResult(ret, "AddToSet, GetTestCases")) |
|
302 { |
|
303 return false; |
|
304 } |
|
305 |
|
306 ret = -1; |
263 for (TInt i = 0; i < testCases.Count(); i++) |
307 for (TInt i = 0; i < testCases.Count(); i++) |
264 { |
308 { |
265 // __LOG1(_L("Case Number: %d"),testCases[i].TestCaseNum()); |
309 iLog->Log(_L("Case Number: %d"),testCases[i].TestCaseNum()); |
266 if (TDesC2QString(testCases[i].TestCaseTitle()) == caseInfo.Name() |
310 iLog->Log(_L("Case Title: %s"),testCases[i].TestCaseTitle().Ptr()); |
267 && testCases[i].TestCaseNum() == caseInfo.Index()) |
311 |
|
312 if (testCases[i].TestCaseNum() == caseIndex) |
268 { |
313 { |
269 ret = UIStore().AddToTestSet(QString2TPtrC(setName), testCases[i]); |
314 ret = UIStore().AddToTestSet(QString2TPtrC(setName), testCases[i]); |
270 // __LOG1(_L("AddToTestSet: %d"), ret); |
315 iLog->Log(_L("AddToTestSet: %d"), ret); |
271 break; |
316 break; |
272 } |
317 } |
273 } |
318 } |
274 testCases.Reset(); |
319 testCases.Reset(); |
275 testCases.Close(); |
320 testCases.Close(); |
|
321 return LogResult(ret, "AddToSet"); |
276 } |
322 } |
277 |
323 |
278 void CStifExecutor::ExecuteSet(const QString& SetName, const int startIndex, |
324 void CStifExecutor::ExecuteSet(const QString& SetName, const int startIndex, |
279 const TSTFCaseRunningType type) |
325 const TSTFCaseRunningType type) |
280 { |
326 { |
285 } |
331 } |
286 const CTestSetInfo* set = NULL; |
332 const CTestSetInfo* set = NULL; |
287 TInt ret; |
333 TInt ret; |
288 TBuf<30> test; |
334 TBuf<30> test; |
289 test.Append(QString2TPtrC(SetName)); |
335 test.Append(QString2TPtrC(SetName)); |
290 // __LOG(_L("StartTestSet GetSetName:")); |
336 iLog->Log(_L("StartTestSet GetSetName:")); |
291 // __LOG(test); |
337 iLog->Log(test); |
292 TRAP(ret, set = &UIStore().TestSetL(test)); |
338 TRAP(ret, set = &UIStore().TestSetL(test)); |
293 |
339 |
294 //const CTestSetInfo& set = UIStore().TestSetL(QString2TPtrC(SetName)); |
340 //const CTestSetInfo& set = UIStore().TestSetL(QString2TPtrC(SetName)); |
295 if(ret != KErrNone) |
341 if(ret != KErrNone) |
296 { |
342 { |
297 // __LOG1(_L("StartTestSet GetTestSet Error return=%d"),ret); |
343 iLog->Log(_L("StartTestSet GetTestSet Error return=%d"),ret); |
298 return; |
344 return; |
299 } |
345 } |
300 int a = startIndex; |
346 int a = startIndex; |
301 ret = UIStore().StartTestSet(*set, a, setType); |
347 ret = UIStore().StartTestSet(*set, a, setType); |
302 // __LOG1(_L("StartTestSet return=%d"),ret); |
348 iLog->Log(_L("StartTestSet return=%d"),ret); |
303 } |
349 } |
304 |
350 |
305 void CStifExecutor::Update(CStartedTestCase* aCase, int flags) |
351 void CStifExecutor::Update(CStartedTestCase* aCase, int flags) |
306 { |
352 { |
307 // __LOG1(_L("CStifExecutor::Update return case=%d"),aCase); |
353 iLog->Log(_L("CStifExecutor::Update return case=%d"),aCase); |
308 // __LOG1(_L("CStifExecutor::Update return status=%d"),flags); |
354 iLog->Log(_L("CStifExecutor::Update return status=%d"),flags); |
309 |
355 |
310 if(aCase == NULL) |
356 if(aCase == NULL) |
311 { |
357 { |
312 return; |
358 return; |
313 } |
359 } |