24 const QString DEFAULTINI = "c:\\testframework\\testframework.ini"; |
24 const QString DEFAULTINI = "c:\\testframework\\testframework.ini"; |
25 |
25 |
26 |
26 |
27 |
27 |
28 StfQtUIController::StfQtUIController(IStfQtUIModel* aModel) : |
28 StfQtUIController::StfQtUIController(IStfQtUIModel* aModel) : |
29 model(aModel), isShowOutput(false) |
29 model(aModel), |
|
30 isShowOutput(false), |
|
31 iCurrentRunPos(0), |
|
32 isLoopInfinitely(false), |
|
33 loopTimes(0) |
|
34 |
30 { |
35 { |
31 executor = new CStifExecutor(); |
36 executor = new CStifExecutor(); |
32 executor->OpenIniFile(DEFAULTINI); |
37 executor->OpenIniFile(DEFAULTINI); |
33 executor->AddStifCaseUpdateListener(this); |
38 executor->AddStifCaseUpdateListener(this); |
34 } |
39 } |
133 RunSets(TEMPSETNAME, type); |
138 RunSets(TEMPSETNAME, type); |
134 executor->RemoveSet(TEMPSETNAME); |
139 executor->RemoveSet(TEMPSETNAME); |
135 } |
140 } |
136 } |
141 } |
137 |
142 |
|
143 // run cases repeatly. |
|
144 // By default, loopTimes = -1 means loop infinitely util user stop it. |
|
145 void StfQtUIController::RepeatRunCases(const QList<CSTFCase>& aCaseList, const bool aIsLoopInfinitely, const int aLoopTimes) |
|
146 { |
|
147 InitRepeatSetting(aIsLoopInfinitely, aLoopTimes); |
|
148 repeatRunCaseList = aCaseList; |
|
149 |
|
150 Execution(); |
|
151 |
|
152 } |
|
153 |
|
154 void StfQtUIController::InitRepeatSetting(const bool aIsLoopInfinitely, const int aLoopTimes) |
|
155 { |
|
156 loopTimes = aLoopTimes; |
|
157 isLoopInfinitely = aIsLoopInfinitely; |
|
158 iCurrentRunPos = 0; |
|
159 } |
|
160 |
|
161 void StfQtUIController::ResetRepeatSetting() |
|
162 { |
|
163 iCurrentRunPos = 0; |
|
164 isLoopInfinitely = false; |
|
165 loopTimes = 0; |
|
166 } |
|
167 |
|
168 // Repeat execution cases |
|
169 void StfQtUIController::Execution() |
|
170 { |
|
171 if(loopTimes > 0 || isLoopInfinitely) |
|
172 { |
|
173 int count = repeatRunCaseList.count(); |
|
174 CSTFCase aCase = repeatRunCaseList.at(iCurrentRunPos); |
|
175 QString msg = "Start execute case:" + aCase.Name(); |
|
176 FireOnGetOutput(msg); |
|
177 executor->ExecuteSingleCase(aCase.ModuleName(), aCase.Index()); |
|
178 |
|
179 iCurrentRunPos++; |
|
180 if( iCurrentRunPos >= count ) |
|
181 { |
|
182 iCurrentRunPos = 0; |
|
183 loopTimes --; |
|
184 } |
|
185 } |
|
186 } |
|
187 |
138 bool StfQtUIController::AddCaseToSet(const QList<CSTFCase>& caseList, |
188 bool StfQtUIController::AddCaseToSet(const QList<CSTFCase>& caseList, |
139 const QString& setName) |
189 const QString& setName) |
140 { |
190 { |
141 QString name = setName; |
191 QString name = setName; |
142 bool rst = true; |
192 bool rst = true; |
281 { |
331 { |
282 FireOnCaseOutputChanged(IStfEventListener::EClose, (int) aCase, ""); |
332 FireOnCaseOutputChanged(IStfEventListener::EClose, (int) aCase, ""); |
283 model->RemoveRunningCase(aCase); |
333 model->RemoveRunningCase(aCase); |
284 model->AddCaseByStatus(EStatusAborted, stfcase); |
334 model->AddCaseByStatus(EStatusAborted, stfcase); |
285 msg += "aborted"; |
335 msg += "aborted"; |
|
336 |
|
337 //reset repeat execution information |
|
338 ResetRepeatSetting(); |
286 |
339 |
287 } |
340 } |
288 else if (flags & CUIStoreIf::EStatusExecuted) |
341 else if (flags & CUIStoreIf::EStatusExecuted) |
289 { |
342 { |
290 FireOnCaseOutputChanged(IStfEventListener::EClose, (int) aCase, ""); |
343 FireOnCaseOutputChanged(IStfEventListener::EClose, (int) aCase, ""); |