show test result as check mark or cross

master
Marc Wäckerlin 8 years ago
parent a8d954660a
commit f6518ea767
  1. 14
      src/commands.hxx
  2. 19
      src/testgui.hxx
  3. 120
      src/testgui.ui

@ -222,14 +222,14 @@ class Command: public QObject {
res += value.mid(start, m.capturedStart()-start);
value.remove(0, m.capturedEnd());
if (keepDelimiters && m.capturedLength()) res+=m.captured().mid(start).trimmed();
std::cout<<"REMOVE: \""<<m.captured()<<"\" 0 - "<<(m.capturedEnd()+start)
<<" start="<<start<<" pos="<<pos<<std::endl
<<"REMAINING: \""<<value<<"\""<<std::endl;
}
std::cout<<"FOUND"<<std::endl;
Q_FOREACH(QString tag, res) {
std::cout<<" - \""<<tag<<"\""<<std::endl;
// std::cout<<"REMOVE: \""<<m.captured()<<"\" 0 - "<<(m.capturedEnd()+start)
// <<" start="<<start<<" pos="<<pos<<std::endl
// <<"REMAINING: \""<<value<<"\""<<std::endl;
}
// std::cout<<"FOUND"<<std::endl;
// Q_FOREACH(QString tag, res) {
// std::cout<<" - \""<<tag<<"\""<<std::endl;
// }
return res;
}
QStringList commaSeparatedList(QString value) {

@ -45,6 +45,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI {
menuViews->addAction(_sourceDock->toggleViewAction());
menuViews->addAction(_executeDock->toggleViewAction());
_progress->hide();
_status->setCurrentIndex(STATUS_NONE);
QSettings settings("mrw", "webtester");
restoreGeometry(settings.value("geometry").toByteArray());
restoreState(settings.value("windowstate").toByteArray());
@ -80,20 +81,24 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI {
QString name(QFileDialog::getOpenFileName(this, tr("Open Test Script")));
if (name.isEmpty()) return;
loadFile(name);
_status->setCurrentIndex(STATUS_NONE);
}
void on__actionOpenSetupScript_triggered() {
QString name(QFileDialog::getOpenFileName(this, tr("Open Setup Script")));
if (name.isEmpty()) return;
loadSetup(name);
_status->setCurrentIndex(STATUS_NONE);
}
void on__actionRevertToSaved_triggered() {
loadFile(_filename);
_status->setCurrentIndex(STATUS_NONE);
}
void on__actionSaveAs_triggered() {
QString name(QFileDialog::getSaveFileName(this, tr("Save Test Script")));
if (name.isEmpty()) return;
_filename = name;
on__actionSave_triggered();
_status->setCurrentIndex(STATUS_NONE);
}
void on__actionSave_triggered() {
QFile file(_filename);
@ -113,6 +118,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI {
"Cannot write test script to file %1.")
.arg(_filename).arg(x.what()));
}
_status->setCurrentIndex(STATUS_NONE);
}
void on__actionClear_triggered() {
_testscript->clear();
@ -120,10 +126,12 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI {
_filename.clear();
_actionSave->setEnabled(false);
_actionRevertToSaved->setEnabled(false);
_status->setCurrentIndex(STATUS_NONE);
}
void on__run_clicked() {
_progress->reset();
_progress->show();
_status->setCurrentIndex(STATUS_RUNNING);
bool oldRecordState(_record->isChecked());
_record->setChecked(false);
_record->setEnabled(false);
@ -145,10 +153,9 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI {
script.parse(text.split('\n'), "script");
script.run(_web->page()->mainFrame(), testsuites, QString(),
_screenshots->isChecked());
_status->setCurrentIndex(STATUS_SUCCESS);
} catch (std::exception &x) {
QMessageBox::critical(this, tr("Script Failed"),
tr("Script failed with message:\n%1")
.arg(x.what()));
_status->setCurrentIndex(STATUS_ERROR);
}
_run->setEnabled(true);
_record->setEnabled(true);
@ -844,6 +851,12 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI {
URL_VIEW = 0,
PROGRESS_VIEW
};
enum RunStatus {
STATUS_NONE = 0,
STATUS_RUNNING,
STATUS_SUCCESS,
STATUS_ERROR
};
private:
QString _filename;
QWebElement _lastFocused; // cache for last focussed element

@ -434,11 +434,79 @@ this.dispatchEvent(evObj);</string>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>82</height>
<height>28</height>
</size>
</property>
</spacer>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QStackedWidget" name="_status">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="page_6"/>
<widget class="QWidget" name="page_5">
<layout class="QGridLayout" name="gridLayout_9">
<item row="0" column="0" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="label_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&lt;div style=&quot;font-size: xx-large&quot;&gt;⌛&lt;/div&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_3">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&lt;div style=&quot;font-size: xx-large; color: green&quot;&gt;✔&lt;/div&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_4">
<layout class="QGridLayout" name="gridLayout_8">
<item row="0" column="0" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&lt;div style=&quot;font-size: xx-large; color: red&quot;&gt;✘&lt;/div&gt;</string>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</item>
</layout>
@ -616,21 +684,33 @@ this.dispatchEvent(evObj);</string>
<property name="text">
<string>Open ...</string>
</property>
<property name="shortcut">
<string>Ctrl+O</string>
</property>
</action>
<action name="_actionSaveAs">
<property name="text">
<string>Save As ...</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+S</string>
</property>
</action>
<action name="_actionQuit">
<property name="text">
<string>Quit</string>
</property>
<property name="shortcut">
<string>Ctrl+Q</string>
</property>
</action>
<action name="_actionRun">
<property name="text">
<string>Run</string>
</property>
<property name="shortcut">
<string>Ctrl+R</string>
</property>
</action>
<action name="_actionRunLine">
<property name="text">
@ -660,6 +740,9 @@ this.dispatchEvent(evObj);</string>
<property name="text">
<string>Save</string>
</property>
<property name="shortcut">
<string>Ctrl+S</string>
</property>
</action>
<action name="_actionRevertToSaved">
<property name="enabled">
@ -668,6 +751,9 @@ this.dispatchEvent(evObj);</string>
<property name="text">
<string>Revert to saved</string>
</property>
<property name="shortcut">
<string>Ctrl+R</string>
</property>
</action>
<action name="_actionOpenSetupScript">
<property name="text">
@ -966,5 +1052,37 @@ this.dispatchEvent(evObj);</string>
</hint>
</hints>
</connection>
<connection>
<sender>_actionQuit</sender>
<signal>triggered()</signal>
<receiver>TestGUI</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>443</x>
<y>589</y>
</hint>
</hints>
</connection>
<connection>
<sender>_actionRun</sender>
<signal>triggered()</signal>
<receiver>_run</receiver>
<slot>click()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>299</x>
<y>90</y>
</hint>
</hints>
</connection>
</connections>
</ui>

Loading…
Cancel
Save