|
1 /* |
|
2 * Copyright (c) 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 "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: QT C++ based Class. |
|
15 * |
|
16 */ |
|
17 #include <QtGui> |
|
18 #include "frmmain.h" |
|
19 #include "stfqtuicontroller.h" |
|
20 #include "stfqtuimodel.h" |
|
21 #include <QList> |
|
22 #include "version.h" |
|
23 #include <QCursor> |
|
24 |
|
25 const QString SELECTITEMHEADER = " * "; |
|
26 const QString UNSELECTITEMHEADER = " "; |
|
27 |
|
28 frmMain::frmMain() |
|
29 { |
|
30 uiSetting = new UiSetting(); |
|
31 createMenus(); |
|
32 load(); |
|
33 LoadSubMenu(); |
|
34 model = new StfQtUIModel(); |
|
35 model->AddStifModelEventListener(this); |
|
36 controller = new StfQtUIController(model); |
|
37 controller->AddStfEventListener(this); |
|
38 loadContent(); |
|
39 dlgOutput = new DlgOutput(controller); |
|
40 setSetting(); |
|
41 } |
|
42 |
|
43 frmMain::~frmMain() |
|
44 { |
|
45 model->AbortCase(); |
|
46 controller->RemoveStfEventListener(this); |
|
47 model->RemoveStifModelEventListener(this); |
|
48 |
|
49 delete uiSetting; |
|
50 delete dlgOutput; |
|
51 delete controller; |
|
52 delete model; |
|
53 } |
|
54 |
|
55 void frmMain::setSetting() |
|
56 { |
|
57 controller->SetShowOutput(uiSetting->ReadSetting("showoutput") == "true"); |
|
58 } |
|
59 |
|
60 void frmMain::OnGetMessage(const QString& aMessage) |
|
61 { |
|
62 txtOutput->appendPlainText(aMessage); |
|
63 } |
|
64 |
|
65 void frmMain::OnRunningCaseChanged() |
|
66 { |
|
67 QList<CSTFCase> caseList = controller->GetCasesByStatus(EStatusRunning); |
|
68 lstStartedCases->clear(); |
|
69 foreach(CSTFCase aCase, caseList) |
|
70 { |
|
71 lstStartedCases->addItem(aCase.Name()); |
|
72 } |
|
73 if (caseList.size() != 0) |
|
74 { |
|
75 btnPauseCase->setEnabled(true); |
|
76 btnAbortCase->setEnabled(true); |
|
77 actPause->setEnabled(true); |
|
78 actAbort->setEnabled(true); |
|
79 } |
|
80 else |
|
81 { |
|
82 btnPauseCase->setEnabled(false); |
|
83 btnAbortCase->setEnabled(false); |
|
84 actPause->setEnabled(false); |
|
85 actAbort->setEnabled(false); |
|
86 } |
|
87 } |
|
88 |
|
89 void frmMain::OnCaseOutputChanged(const IStfEventListener::CaseOutputCommand& /*cmd*/, const QString& /*index*/, const QString& /*msg*/) |
|
90 { |
|
91 //nothing to do. |
|
92 } |
|
93 |
|
94 void frmMain::OnSetListChanged() |
|
95 { |
|
96 loadSetList(); |
|
97 } |
|
98 |
|
99 void frmMain::OnCaseStatisticChanged() |
|
100 { |
|
101 loadStatistic(); |
|
102 } |
|
103 |
|
104 void frmMain::createMenus() |
|
105 { |
|
106 //operateMenu = menuBar()->addMenu(tr("&Operation")); |
|
107 actAbout = new QAction(tr("&About"), this); |
|
108 connect(actAbout, SIGNAL(triggered()), this, |
|
109 SLOT(on_actAbout_triggered())); |
|
110 |
|
111 actExit = new QAction(tr("&Exit"), this); |
|
112 connect(actExit, SIGNAL(triggered()), this, SLOT(close())); |
|
113 |
|
114 actOpenFile = new QAction(tr("&Open Ini File"), this); |
|
115 connect(actOpenFile, SIGNAL(triggered()), this, |
|
116 SLOT(on_actOpenFile_triggered())); |
|
117 |
|
118 actRunCaseSeq = new QAction(tr("Run Case Sequentially"), this); |
|
119 connect(actRunCaseSeq, SIGNAL(triggered()), this, |
|
120 SLOT(on_actRunCaseSeq_triggered())); |
|
121 |
|
122 actRunCasePar = new QAction(tr("Run Case Parallel"), this); |
|
123 connect(actRunCasePar, SIGNAL(triggered()), this, |
|
124 SLOT(on_actRunCasePar_triggered())); |
|
125 |
|
126 actAddtoSet = new QAction(tr("Add cases to Set"), this); |
|
127 connect(actAddtoSet, SIGNAL(triggered()), this, |
|
128 SLOT(on_actAddtoSet_triggered())); |
|
129 |
|
130 actSelectAll = new QAction(tr("Select All"), this); |
|
131 connect(actSelectAll, SIGNAL(triggered()), this, |
|
132 SLOT(on_actSelectAll_triggered())); |
|
133 |
|
134 actExpandAll = new QAction(tr("Expand All"), this); |
|
135 connect(actExpandAll, SIGNAL(triggered()), this, |
|
136 SLOT(on_actExpandAll_triggered())); |
|
137 |
|
138 actCollapseAll = new QAction(tr("Collapse All"), this); |
|
139 connect(actCollapseAll, SIGNAL(triggered()), this, |
|
140 SLOT(on_actCollapseAll_triggered())); |
|
141 |
|
142 actSetting = new QAction(tr("Setting"), this); |
|
143 connect(actSetting, SIGNAL(triggered()), this, |
|
144 SLOT(on_actSetting_triggered())); |
|
145 |
|
146 actRunSetSeq = new QAction(tr("Run Set Sequentially"), this); |
|
147 connect(actRunSetSeq, SIGNAL(triggered()), this, |
|
148 SLOT(on_actRunSetSeq_triggered())); |
|
149 |
|
150 actRunSetPar = new QAction(tr("Run Set Parallel"), this); |
|
151 connect(actRunSetPar, SIGNAL(triggered()), this, |
|
152 SLOT(on_actRunSetPar_triggered())); |
|
153 |
|
154 actNewSet = new QAction(tr("Create New Set"), this); |
|
155 connect(actNewSet, SIGNAL(triggered()), this, |
|
156 SLOT(on_actNewSet_triggered())); |
|
157 |
|
158 actDelSet = new QAction(tr("Delete Set"), this); |
|
159 connect(actDelSet, SIGNAL(triggered()), this, |
|
160 SLOT(on_actDelSet_triggered())); |
|
161 |
|
162 actPause = new QAction(tr("Pause"), this); |
|
163 actPause->setEnabled(false); |
|
164 connect(actPause, SIGNAL(triggered()), this, |
|
165 SLOT(on_actPause_triggered())); |
|
166 |
|
167 actAbort = new QAction(tr("Abort"), this); |
|
168 actAbort->setEnabled(false); |
|
169 connect(actAbort, SIGNAL(triggered()), this, |
|
170 SLOT(on_actAbort_triggered())); |
|
171 |
|
172 actClearStatistics = new QAction(tr("Clear Statistics"), this); |
|
173 connect(actClearStatistics, SIGNAL(triggered()), this, |
|
174 SLOT(on_actClearStatistics_triggered())); |
|
175 |
|
176 } |
|
177 |
|
178 void frmMain::load() |
|
179 { |
|
180 this->setContextMenuPolicy(Qt::NoContextMenu); |
|
181 QSize btnSize(100,35); |
|
182 QGridLayout *mainLayout = new QGridLayout(this); |
|
183 mainLayout->setVerticalSpacing(2); |
|
184 mainLayout->setHorizontalSpacing(2); |
|
185 mainLayout->setSpacing(2); |
|
186 mainLayout->setMargin(2); |
|
187 |
|
188 MainWidget = new QWidget(this); |
|
189 MainWidget->setContextMenuPolicy(Qt::NoContextMenu); |
|
190 |
|
191 //tab control |
|
192 tabWidget = new QTabWidget(this); |
|
193 tabWidget->setContextMenuPolicy(Qt::NoContextMenu); |
|
194 tabCase = new QWidget(tabWidget); |
|
195 tabCase->setContextMenuPolicy(Qt::NoContextMenu); |
|
196 tabWidget->addTab(tabCase, tr("Cases")); |
|
197 tabSet = new QWidget(tabWidget); |
|
198 tabSet->setContextMenuPolicy(Qt::NoContextMenu); |
|
199 tabWidget->addTab(tabSet, tr(" Set ")); |
|
200 tabStarted = new QWidget(tabWidget); |
|
201 tabStarted->setContextMenuPolicy(Qt::NoContextMenu); |
|
202 tabWidget->addTab(tabStarted, tr("Running")); |
|
203 tabStatistic = new QWidget(tabWidget); |
|
204 tabStatistic->setContextMenuPolicy(Qt::NoContextMenu); |
|
205 tabWidget->addTab(tabStatistic, tr("Statistics")); |
|
206 connect(tabWidget, SIGNAL(currentChanged(int)), this, |
|
207 SLOT(onTabWidgetSelectIndexChanged())); |
|
208 |
|
209 //output panel |
|
210 QGroupBox *groupBox = new QGroupBox(this); |
|
211 groupBox->setFixedHeight(150); |
|
212 groupBox->setContextMenuPolicy(Qt::NoContextMenu); |
|
213 groupBox->setTitle(tr("Information")); |
|
214 QFont serifFont("Times", 5, QFont::Normal); |
|
215 txtOutput = new QPlainTextEdit(groupBox); |
|
216 txtOutput->setFont(serifFont); |
|
217 txtOutput->setContextMenuPolicy(Qt::NoContextMenu); |
|
218 txtOutput->setReadOnly(true); |
|
219 txtOutput->setFocusPolicy(Qt::NoFocus); |
|
220 //txtOutput->setEditFocus(false); |
|
221 QGridLayout *groupBoxLayout = new QGridLayout(this); |
|
222 groupBoxLayout->setVerticalSpacing(2); |
|
223 groupBoxLayout->setHorizontalSpacing(2); |
|
224 groupBoxLayout->setSpacing(2); |
|
225 groupBoxLayout->setMargin(2); |
|
226 groupBoxLayout->addWidget(txtOutput, 0, 0); |
|
227 groupBox->setLayout(groupBoxLayout); |
|
228 |
|
229 //Create MainLayout and MainWidget |
|
230 mainLayout->addWidget(tabWidget, 0, 0); |
|
231 mainLayout->addWidget(groupBox, 1, 0, Qt::AlignBottom); |
|
232 MainWidget->setLayout(mainLayout); |
|
233 |
|
234 |
|
235 //Tab page: Case |
|
236 QGridLayout *tabCaseLayout = new QGridLayout(this); |
|
237 tabCaseLayout->setVerticalSpacing(2); |
|
238 tabCaseLayout->setHorizontalSpacing(2); |
|
239 tabCaseLayout->setSpacing(2); |
|
240 tabCaseLayout->setMargin(2); |
|
241 treeModuleList = new QTreeWidget(tabCase); |
|
242 treeModuleList->setContextMenuPolicy(Qt::NoContextMenu); |
|
243 treeModuleList->headerItem()->setText(0, tr("Module List")); |
|
244 treeModuleList->setSelectionBehavior(QAbstractItemView::SelectRows); |
|
245 treeModuleList->setEditFocus(false); |
|
246 connect(treeModuleList, SIGNAL(itemClicked(QTreeWidgetItem* , int)), this, |
|
247 SLOT(on_treeModuleList_itemClicked(QTreeWidgetItem* , int))); |
|
248 |
|
249 |
|
250 QWidget *caseToolWidget = new QWidget(tabCase); |
|
251 caseToolWidget->setContextMenuPolicy(Qt::NoContextMenu); |
|
252 QGridLayout *caseToolWidgetLayout = new QGridLayout; |
|
253 QPushButton *btnRunCase = new QPushButton(tr("Run"), caseToolWidget); |
|
254 btnRunCase->setContextMenuPolicy(Qt::NoContextMenu); |
|
255 btnRunCase->setFixedSize(btnSize); |
|
256 connect(btnRunCase, SIGNAL(clicked()), this, |
|
257 SLOT(on_actRunCaseSeq_triggered())); |
|
258 QPushButton *btnExpandAll = new QPushButton(tr("Expand"), caseToolWidget); |
|
259 btnExpandAll->setContextMenuPolicy(Qt::NoContextMenu); |
|
260 btnExpandAll->setFixedSize(btnSize); |
|
261 connect(btnExpandAll, SIGNAL(clicked()), this, |
|
262 SLOT(on_actExpandAll_triggered())); |
|
263 QPushButton *btnCollapseAll = new QPushButton(tr("Collapse"), |
|
264 caseToolWidget); |
|
265 btnCollapseAll->setContextMenuPolicy(Qt::NoContextMenu); |
|
266 btnCollapseAll->setFixedSize(btnSize); |
|
267 connect(btnCollapseAll, SIGNAL(clicked()), this, |
|
268 SLOT(on_actCollapseAll_triggered())); |
|
269 |
|
270 caseToolWidgetLayout->addWidget(btnRunCase, 0, 0); |
|
271 caseToolWidgetLayout->addWidget(btnExpandAll, 0, 1); |
|
272 caseToolWidgetLayout->addWidget(btnCollapseAll, 0, 2); |
|
273 caseToolWidget->setLayout(caseToolWidgetLayout); |
|
274 |
|
275 tabCaseLayout->addWidget(caseToolWidget, 1, 0); |
|
276 tabCaseLayout->addWidget(treeModuleList, 0, 0); |
|
277 tabCase->setLayout(tabCaseLayout); |
|
278 |
|
279 //Tab page: Set |
|
280 |
|
281 QGridLayout *tabSetLayout = new QGridLayout(this); |
|
282 tabSetLayout->setVerticalSpacing(2); |
|
283 tabSetLayout->setHorizontalSpacing(2); |
|
284 tabSetLayout->setSpacing(2); |
|
285 tabSetLayout->setMargin(2); |
|
286 |
|
287 QGridLayout *tabSetMainLayout = new QGridLayout(this); |
|
288 tabSetMainLayout->setVerticalSpacing(2); |
|
289 tabSetMainLayout->setHorizontalSpacing(2); |
|
290 tabSetMainLayout->setSpacing(2); |
|
291 tabSetMainLayout->setMargin(2); |
|
292 QWidget *tabSetMainWidget = new QWidget(tabSet); |
|
293 tabSetMainWidget->setContextMenuPolicy(Qt::NoContextMenu); |
|
294 QLabel *lblSet = new QLabel(tr("Test Set:"), tabSetMainWidget); |
|
295 lblSet->setContextMenuPolicy(Qt::NoContextMenu); |
|
296 QLabel *lblCase = new QLabel(tr("Cases:"), tabSetMainWidget); |
|
297 lblCase->setContextMenuPolicy(Qt::NoContextMenu); |
|
298 cboSetList = new QComboBox(tabSetMainWidget); |
|
299 cboSetList->setContextMenuPolicy(Qt::NoContextMenu); |
|
300 cboSetList->setEditable(false); |
|
301 connect(cboSetList, SIGNAL(currentIndexChanged(QString)), this, |
|
302 SLOT(on_cboSetList_currentIndexChanged(QString))); |
|
303 lstSetCases = new QListWidget(tabSetMainWidget); |
|
304 lstSetCases->setContextMenuPolicy(Qt::NoContextMenu); |
|
305 tabSetMainLayout->addWidget(lblSet, 0, 0); |
|
306 tabSetMainLayout->addWidget(cboSetList, 0, 1); |
|
307 tabSetMainLayout->addWidget(lblCase, 1, 0, |
|
308 (Qt::AlignTop | Qt::AlignRight)); |
|
309 tabSetMainLayout->addWidget(lstSetCases, 1, 1); |
|
310 tabSetMainWidget->setLayout(tabSetMainLayout); |
|
311 |
|
312 QWidget *setToolWidget = new QWidget(tabSet); |
|
313 setToolWidget->setContextMenuPolicy(Qt::NoContextMenu); |
|
314 QGridLayout *setToolWidgetLayout = new QGridLayout(this); |
|
315 setToolWidgetLayout->setVerticalSpacing(2); |
|
316 setToolWidgetLayout->setHorizontalSpacing(2); |
|
317 setToolWidgetLayout->setSpacing(2); |
|
318 setToolWidgetLayout->setMargin(2); |
|
319 QPushButton *btnRunSetCase = new QPushButton(tr("Run"), setToolWidget); |
|
320 btnRunSetCase->setContextMenuPolicy(Qt::NoContextMenu); |
|
321 btnRunSetCase->setFixedSize(btnSize); |
|
322 connect(btnRunSetCase, SIGNAL(clicked()), this, |
|
323 SLOT(on_actRunSetSeq_triggered())); |
|
324 QPushButton *btnNewSet = new QPushButton(tr("New Set"), setToolWidget); |
|
325 btnNewSet->setContextMenuPolicy(Qt::NoContextMenu); |
|
326 btnNewSet->setFixedSize(btnSize); |
|
327 connect(btnNewSet, SIGNAL(clicked()), this, |
|
328 SLOT(on_actNewSet_triggered())); |
|
329 QPushButton *btnDelSet = new QPushButton(tr("Delete Set"), setToolWidget); |
|
330 btnDelSet->setContextMenuPolicy(Qt::NoContextMenu); |
|
331 btnDelSet->setFixedSize(btnSize); |
|
332 connect(btnDelSet, SIGNAL(clicked()), this, |
|
333 SLOT(on_actDelSet_triggered())); |
|
334 |
|
335 setToolWidgetLayout->addWidget(btnRunSetCase, 0, 0); |
|
336 setToolWidgetLayout->addWidget(btnNewSet, 0, 1); |
|
337 setToolWidgetLayout->addWidget(btnDelSet, 0, 2); |
|
338 setToolWidget->setLayout(setToolWidgetLayout); |
|
339 |
|
340 tabSetLayout->addWidget(tabSetMainWidget, 0, 0); |
|
341 tabSetLayout->addWidget(setToolWidget, 1, 0); |
|
342 tabSet->setLayout(tabSetLayout); |
|
343 |
|
344 //Tab Started |
|
345 QGridLayout *tabStartedLayout = new QGridLayout(this); |
|
346 tabStartedLayout->setVerticalSpacing(2); |
|
347 tabStartedLayout->setHorizontalSpacing(2); |
|
348 tabStartedLayout->setSpacing(2); |
|
349 tabStartedLayout->setMargin(2); |
|
350 lstStartedCases = new QListWidget(tabStarted); |
|
351 lstStartedCases->setContextMenuPolicy(Qt::NoContextMenu); |
|
352 QWidget *startedToolWidget = new QWidget(tabStarted); |
|
353 startedToolWidget->setContextMenuPolicy(Qt::NoContextMenu); |
|
354 QGridLayout *startedToolWidgetLayout = new QGridLayout(this); |
|
355 startedToolWidgetLayout->setVerticalSpacing(2); |
|
356 startedToolWidgetLayout->setHorizontalSpacing(2); |
|
357 startedToolWidgetLayout->setSpacing(2); |
|
358 startedToolWidgetLayout->setMargin(2); |
|
359 btnPauseCase = new QPushButton(tr("Pause"), startedToolWidget); |
|
360 btnPauseCase->setContextMenuPolicy(Qt::NoContextMenu); |
|
361 btnPauseCase->setFixedSize(btnSize); |
|
362 connect(btnPauseCase, SIGNAL(clicked()), this, |
|
363 SLOT(on_actPause_triggered())); |
|
364 btnPauseCase->setEnabled(false); |
|
365 |
|
366 btnAbortCase = new QPushButton(tr("Abort"), startedToolWidget); |
|
367 btnAbortCase->setContextMenuPolicy(Qt::NoContextMenu); |
|
368 btnAbortCase->setFixedSize(btnSize); |
|
369 connect(btnAbortCase, SIGNAL(clicked()), this, |
|
370 SLOT(on_actAbort_triggered())); |
|
371 btnAbortCase->setEnabled(false); |
|
372 // |
|
373 // QPushButton *btnShowOutput = new QPushButton(tr("Output"), startedToolWidget); |
|
374 // connect(btnShowOutput, SIGNAL(clicked()), this, |
|
375 // SLOT(on_btnShowOutput_clicked())); |
|
376 |
|
377 |
|
378 startedToolWidgetLayout->addWidget(btnPauseCase, 0, 0); |
|
379 startedToolWidgetLayout->addWidget(btnAbortCase, 0, 1); |
|
380 //startedToolWidgetLayout->addWidget(btnShowOutput, 0, 2); |
|
381 startedToolWidget->setLayout(startedToolWidgetLayout); |
|
382 |
|
383 tabStartedLayout->addWidget(lstStartedCases, 0, 0); |
|
384 tabStartedLayout->addWidget(startedToolWidget, 1, 0); |
|
385 tabStarted->setLayout(tabStartedLayout); |
|
386 |
|
387 //Tab Statistic |
|
388 QGridLayout *tabStatisticLayout = new QGridLayout(this); |
|
389 tabStatisticLayout->setVerticalSpacing(2); |
|
390 tabStatisticLayout->setHorizontalSpacing(2); |
|
391 tabStatisticLayout->setSpacing(2); |
|
392 tabStatisticLayout->setMargin(2); |
|
393 |
|
394 treeStatistic = new QTreeWidget(tabStatistic); |
|
395 treeStatistic->setContextMenuPolicy(Qt::NoContextMenu); |
|
396 treeStatistic->headerItem()->setText(0, tr("Statistics")); |
|
397 tabStatisticLayout->addWidget(treeStatistic, 0, 0); |
|
398 tabStatistic->setLayout(tabStatisticLayout); |
|
399 |
|
400 executedItems = new QTreeWidgetItem(treeStatistic); |
|
401 executedItems->setText(0, tr("Executed Cases(0)")); |
|
402 passedItems = new QTreeWidgetItem(treeStatistic); |
|
403 passedItems->setText(0, tr("Passed Cases(0)")); |
|
404 failedItems = new QTreeWidgetItem(treeStatistic); |
|
405 failedItems->setText(0, tr("Failed Cases(0)")); |
|
406 crashedItems = new QTreeWidgetItem(treeStatistic); |
|
407 crashedItems->setText(0, tr("Crashed Cases(0)")); |
|
408 abortedItems = new QTreeWidgetItem(treeStatistic); |
|
409 abortedItems->setText(0, tr("Aborted Cases(0)")); |
|
410 |
|
411 |
|
412 setCentralWidget(MainWidget); |
|
413 |
|
414 } |
|
415 |
|
416 void frmMain::LoadSubMenu() |
|
417 { |
|
418 menuBar()->clear(); |
|
419 menuBar()->setContextMenuPolicy(Qt::NoContextMenu); |
|
420 if (tabWidget->currentIndex() == 0) |
|
421 { |
|
422 //Cases Tab |
|
423 menuBar()->addAction(actOpenFile); |
|
424 menuBar()->addAction(actRunCaseSeq); |
|
425 menuBar()->addAction(actRunCasePar); |
|
426 menuBar()->addSeparator(); |
|
427 menuBar()->addAction(actAddtoSet); |
|
428 menuBar()->addSeparator(); |
|
429 menuBar()->addAction(actSelectAll); |
|
430 menuBar()->addAction(actExpandAll); |
|
431 menuBar()->addAction(actCollapseAll); |
|
432 } |
|
433 else if (tabWidget->currentIndex() == 1) |
|
434 { |
|
435 //Set Tab |
|
436 menuBar()->addAction(actRunSetSeq); |
|
437 menuBar()->addAction(actRunSetPar); |
|
438 menuBar()->addSeparator(); |
|
439 menuBar()->addAction(actNewSet); |
|
440 menuBar()->addAction(actDelSet); |
|
441 } |
|
442 else if (tabWidget->currentIndex() == 2) |
|
443 { |
|
444 //Started Tab |
|
445 menuBar()->addAction(actPause); |
|
446 menuBar()->addAction(actAbort); |
|
447 |
|
448 } |
|
449 else |
|
450 { |
|
451 //Staticstic tab |
|
452 menuBar()->addAction(actClearStatistics); |
|
453 } |
|
454 menuBar()->addSeparator(); |
|
455 menuBar()->addAction(actSetting); |
|
456 menuBar()->addAction(actAbout); |
|
457 menuBar()->addAction(actExit); |
|
458 |
|
459 } |
|
460 |
|
461 void frmMain::onTabWidgetSelectIndexChanged() |
|
462 { |
|
463 LoadSubMenu(); |
|
464 } |
|
465 |
|
466 void frmMain::loadContent() |
|
467 { |
|
468 //Load ModuleList |
|
469 loadModuleList(); |
|
470 //Load SetList |
|
471 loadSetList(); |
|
472 //Load Statistic List |
|
473 loadStatistic(); |
|
474 } |
|
475 |
|
476 void frmMain::loadModuleList() |
|
477 { |
|
478 treeModuleList->clear(); |
|
479 |
|
480 QList<QString> moduleList = controller->GetModuleList(); |
|
481 foreach(QString moduleName, moduleList) |
|
482 { |
|
483 QTreeWidgetItem* item = new QTreeWidgetItem(treeModuleList); |
|
484 item->setText(0, UNSELECTITEMHEADER + moduleName); |
|
485 |
|
486 QList<QString> caseList = controller->GetCaseListByModule( |
|
487 moduleName); |
|
488 |
|
489 foreach(QString caseName, caseList) |
|
490 { |
|
491 QTreeWidgetItem* caseItem = new QTreeWidgetItem(item); |
|
492 caseItem->setText(0, UNSELECTITEMHEADER + caseName); |
|
493 } |
|
494 } |
|
495 if (moduleList.size() > 0) |
|
496 { |
|
497 treeModuleList->setCurrentItem(treeModuleList->topLevelItem(0)); |
|
498 } |
|
499 } |
|
500 |
|
501 void frmMain::reloadStatisticItem(QString name, QTreeWidgetItem* item, |
|
502 TSTFCaseStatusType type) |
|
503 { |
|
504 QList<CSTFCase> caseList = controller->GetCasesByStatus(type); |
|
505 while (item->childCount() != 0) |
|
506 { |
|
507 item->removeChild(item->child(0)); |
|
508 } |
|
509 item->setText(0, name + "(" + QString::number(caseList.size(), 10) + ")"); |
|
510 foreach(CSTFCase aCase, caseList) |
|
511 { |
|
512 QTreeWidgetItem* child = new QTreeWidgetItem(item); |
|
513 child->setText(0, aCase.Name()); |
|
514 } |
|
515 } |
|
516 |
|
517 void frmMain::loadStatistic() |
|
518 { |
|
519 //executedItems; |
|
520 reloadStatisticItem("Executed Cases", executedItems, EStatusExecuted); |
|
521 |
|
522 //passedItems; |
|
523 reloadStatisticItem("Passed Cases", passedItems, EStatusPassed); |
|
524 |
|
525 //failedItems; |
|
526 reloadStatisticItem("Failed Cases", failedItems, EStatusFailed); |
|
527 |
|
528 //crashedItems; |
|
529 reloadStatisticItem("Crashed Cases", crashedItems, EStatusCrashed); |
|
530 |
|
531 //abortedItems; |
|
532 reloadStatisticItem("Aborted Cases", abortedItems, EStatusAborted); |
|
533 |
|
534 } |
|
535 |
|
536 void frmMain::loadSetList() |
|
537 { |
|
538 cboSetList->clear(); |
|
539 |
|
540 QList<QString> setList = controller->GetSetList(); |
|
541 foreach(QString setName, setList) |
|
542 { |
|
543 cboSetList->addItem(setName); |
|
544 } |
|
545 // if (setList.size() > 0) |
|
546 // { |
|
547 // //cboSetList->setCurrentIndex(0); |
|
548 // on_cboSetList_currentIndexChanged(setList.at(0)); |
|
549 // } |
|
550 } |
|
551 |
|
552 QList<CSTFCase> frmMain::getSelectedCases() |
|
553 { |
|
554 int index = 0; |
|
555 QTreeWidgetItem* item = treeModuleList->topLevelItem(index); |
|
556 QList<CSTFCase> caseList; |
|
557 while (item != 0) |
|
558 { |
|
559 for (int i = 0; i < item->childCount(); i++) |
|
560 { |
|
561 QTreeWidgetItem* child = item->child(i); |
|
562 if (child->text(0).startsWith(SELECTITEMHEADER)) |
|
563 { |
|
564 CSTFCase aCase(child->text(0).remove(0,3), i); |
|
565 aCase.SetIndex(i); |
|
566 //aCase.SetModuleName(moduleBox->text()); |
|
567 aCase.SetModuleName(item->text(0).remove(0,3)); |
|
568 caseList.append(aCase); |
|
569 } |
|
570 } |
|
571 index++; |
|
572 item = treeModuleList->topLevelItem(index); |
|
573 } |
|
574 return caseList; |
|
575 } |
|
576 |
|
577 void frmMain::on_cboSetList_currentIndexChanged(QString item) |
|
578 { |
|
579 lstSetCases->clear(); |
|
580 QList<QString> list = controller->GetCaseListBySet(item); |
|
581 foreach(QString caseName, list) |
|
582 { |
|
583 lstSetCases->addItem(caseName); |
|
584 } |
|
585 } |
|
586 |
|
587 void frmMain::on_actRunCaseSeq_triggered() |
|
588 { |
|
589 //run case seq |
|
590 controller->RunCases(getSelectedCases(), Sequentially); |
|
591 } |
|
592 |
|
593 void frmMain::on_actRunCasePar_triggered() |
|
594 { |
|
595 controller->RunCases(getSelectedCases(), Parallel); |
|
596 } |
|
597 |
|
598 void frmMain::on_actAddtoSet_triggered() |
|
599 { |
|
600 |
|
601 QList<CSTFCase> list = getSelectedCases(); |
|
602 if (list.size() == 0) |
|
603 { |
|
604 QErrorMessage *errorMessageDialog = new QErrorMessage(this); |
|
605 errorMessageDialog->showMessage(tr( |
|
606 "Please select cases you want to added to set.")); |
|
607 return; |
|
608 } |
|
609 |
|
610 QList<QString> setList = controller->GetSetList(); |
|
611 |
|
612 /* |
|
613 bool ok; |
|
614 QString setName = QInputDialog::getItem(this, tr( |
|
615 "Add select cases to Set"), tr("Sets:"), setList, 0, false, &ok); |
|
616 if (ok && !setName.isEmpty()) |
|
617 { |
|
618 controller->AddCaseToSet(list, setName); |
|
619 } |
|
620 */ |
|
621 |
|
622 //temp code, because UIStore()->AddCaseToSet() is not support to define a set name. |
|
623 controller->AddCaseToSet(list, ""); |
|
624 tabWidget->setCurrentIndex(1); |
|
625 |
|
626 } |
|
627 |
|
628 void frmMain::on_actSelectAll_triggered() |
|
629 { |
|
630 QString header = UNSELECTITEMHEADER; |
|
631 if(actSelectAll->text() == "Select All") |
|
632 { |
|
633 actSelectAll->setText("UnSelect All"); |
|
634 header = SELECTITEMHEADER; |
|
635 } |
|
636 else |
|
637 { |
|
638 actSelectAll->setText("Select All"); |
|
639 } |
|
640 |
|
641 int index = 0; |
|
642 QTreeWidgetItem* item = treeModuleList->topLevelItem(index); |
|
643 while (item != 0) |
|
644 { |
|
645 item->setText(0, item->text(0).replace(0,3, header)); |
|
646 for (int i = 0; i < item->childCount(); i++) |
|
647 { |
|
648 QTreeWidgetItem* child = item->child(i); |
|
649 child->setText(0,child->text(0).replace(0,3,header)); |
|
650 } |
|
651 index++; |
|
652 item = treeModuleList->topLevelItem(index); |
|
653 } |
|
654 } |
|
655 |
|
656 void frmMain::on_actExpandAll_triggered() |
|
657 { |
|
658 treeModuleList->expandAll(); |
|
659 } |
|
660 |
|
661 void frmMain::on_actCollapseAll_triggered() |
|
662 { |
|
663 treeModuleList->collapseAll(); |
|
664 } |
|
665 |
|
666 void frmMain::on_actSetting_triggered() |
|
667 { |
|
668 DlgSetting dlgSet(uiSetting); |
|
669 int result = dlgSet.exec(); |
|
670 if(result == QDialog::Accepted) |
|
671 { |
|
672 setSetting(); |
|
673 } |
|
674 } |
|
675 |
|
676 void frmMain::on_actRunSetSeq_triggered() |
|
677 { |
|
678 QString setName = cboSetList->currentText(); |
|
679 controller->RunSets(setName, Sequentially); |
|
680 } |
|
681 |
|
682 void frmMain::on_actRunSetPar_triggered() |
|
683 { |
|
684 QString setName = cboSetList->currentText(); |
|
685 controller->RunSets(setName, Parallel); |
|
686 } |
|
687 |
|
688 void frmMain::on_actNewSet_triggered() |
|
689 { |
|
690 //not supported. |
|
691 QErrorMessage *errorMessageDialog = new QErrorMessage(this); |
|
692 errorMessageDialog->showMessage( |
|
693 tr( |
|
694 "The feature is not supported in this version.\r\n \ |
|
695 If you want to Add test set.\r\n \ |
|
696 Please switch to \"Case\" tab, Select case(s) and perform \"Add case to set\".")); |
|
697 return; |
|
698 /* |
|
699 * These function is not supported in this version. |
|
700 * Unless this function has been impelemented: |
|
701 * UIStore()->AddSet(setName); |
|
702 * |
|
703 bool ok; |
|
704 QString text = QInputDialog::getText(this, tr("Create a new Set"), tr( |
|
705 "Input a set name:"), QLineEdit::Normal, QDir::home().dirName(), |
|
706 &ok); |
|
707 if (ok && !text.isEmpty()) |
|
708 { |
|
709 controller->CreateSet(text); |
|
710 } |
|
711 */ |
|
712 } |
|
713 |
|
714 void frmMain::on_actDelSet_triggered() |
|
715 { |
|
716 //not supported. |
|
717 QErrorMessage *errorMessageDialog = new QErrorMessage(this); |
|
718 errorMessageDialog->showMessage( |
|
719 tr( |
|
720 "The feature is not supported in this version.\r\n \ |
|
721 If you want to remove test set.\r\n \ |
|
722 Please delete them under {epoc root}\\winscw\\c\\TestFramework \ |
|
723 And restart Application")); |
|
724 return; |
|
725 /* |
|
726 * These function is not supported in this version. |
|
727 * Unless this function has been impelemented: |
|
728 * UIStore()->RemoveSet(setName); |
|
729 * |
|
730 QString setName = cboSetList->currentText(); |
|
731 QMessageBox msgBox(QMessageBox::Warning, tr("Delete a Set"), tr( |
|
732 "Do you really want to delete the set?"), 0, this); |
|
733 msgBox.addButton(tr("&Delete"), QMessageBox::AcceptRole); |
|
734 msgBox.addButton(tr("&Cancel"), QMessageBox::RejectRole); |
|
735 if (msgBox.exec() == QMessageBox::AcceptRole) |
|
736 { |
|
737 controller->DeleteSet(setName); |
|
738 } |
|
739 |
|
740 |
|
741 */ |
|
742 } |
|
743 |
|
744 void frmMain::on_actPause_triggered() |
|
745 { |
|
746 if (btnPauseCase->text() == "Pause") |
|
747 { |
|
748 controller->PauseCase(); |
|
749 btnPauseCase->setText(tr("Resume")); |
|
750 actPause->setText(tr("Resume")); |
|
751 } |
|
752 else |
|
753 { |
|
754 controller->ResumeCase(); |
|
755 btnPauseCase->setText(tr("Pause")); |
|
756 actPause->setText(tr("Pause")); |
|
757 } |
|
758 } |
|
759 |
|
760 void frmMain::on_actAbort_triggered() |
|
761 { |
|
762 controller->AbortCase(); |
|
763 } |
|
764 |
|
765 void frmMain::on_treeModuleList_itemClicked(QTreeWidgetItem* item, int /*column*/) |
|
766 { |
|
767 QString header = UNSELECTITEMHEADER; |
|
768 if(item->text(0).startsWith(UNSELECTITEMHEADER)) |
|
769 { |
|
770 header = SELECTITEMHEADER; |
|
771 } |
|
772 item->setText(0 , item->text(0).replace(0, 3, header)); |
|
773 for(int i=0;i<item->childCount();i++) |
|
774 { |
|
775 item->child(i)->setText(0, item->child(i)->text(0).replace(0, 3, header)); |
|
776 } |
|
777 } |
|
778 |
|
779 void frmMain::on_actAbout_triggered() |
|
780 { |
|
781 QString str = QtUIVersion; |
|
782 str.append("\r\n").append("STF version:"); |
|
783 |
|
784 str.append(QString::number(STIF_MAJOR_VERSION, 10)).append("."); |
|
785 str.append(QString::number(STIF_MINOR_VERSION, 10)).append("."); |
|
786 str.append(QString::number(STIF_BUILD_VERSION, 10)); |
|
787 str.append(" --").append(STIF_REL_DATE).append("\r\n"); |
|
788 str.append("---"); |
|
789 str.append("\r\nCopyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. "); |
|
790 |
|
791 QMessageBox::information(this, tr("About"), str); |
|
792 } |
|
793 |
|
794 void frmMain::on_actOpenFile_triggered() |
|
795 { |
|
796 QString fileName = QFileDialog::getOpenFileName(this, tr( |
|
797 "Select ini file"), tr("c:\\"), tr( |
|
798 "Ini Files (*.ini);;All Files (*)")); |
|
799 if (!fileName.isEmpty()) |
|
800 { |
|
801 controller->OpenEngineIniFile(fileName); |
|
802 this->loadModuleList(); |
|
803 } |
|
804 } |
|
805 |
|
806 void frmMain::on_actClearStatistics_triggered() |
|
807 { |
|
808 model->ClearCasesStatus(); |
|
809 } |