first version of a script run progress bar

master
Marc Wäckerlin 8 years ago
parent d96747807a
commit 8b769b9483
  1. 18
      ChangeLog
  2. 2
      configure.ac
  3. 19
      src/commands.hxx
  4. 15
      src/testgui.hxx
  5. 99
      src/testgui.ui

@ -1,3 +1,21 @@
2016-06-08 09:07
* ax_init_standard_project.m4, bootstrap.sh,
resolve-rpmbuilddeps.sh, scripts/90wt-mode.wt,
scripts/makefile.am, scripts/wt-mode.el, src/commands.hxx,
src/exceptions.hxx: new commands: include, case and fail; new
emacs wt-mode for webtester files
2016-05-13 15:02
* bootstrap.sh, src/commands.hxx: if can have a variable test or a
content check
2016-05-11 09:07
* ChangeLog, src/testgui.hxx, src/webpage.hxx: fix text-selection
to exists feature; ignore javascript popups
2016-05-05 09:58 2016-05-05 09:58
* build-in-docker.sh: fixed build * build-in-docker.sh: fixed build

@ -9,7 +9,7 @@
# change this: # change this:
m4_define(x_package_name, webtester) # project's name m4_define(x_package_name, webtester) # project's name
m4_define(x_major, 2) # project's major version m4_define(x_major, 2) # project's major version
m4_define(x_minor, 1) # project's minor version m4_define(x_minor, 2) # project's minor version
# never edit this block: # never edit this block:
m4_include(ax_init_standard_project.m4) m4_include(ax_init_standard_project.m4)

@ -413,6 +413,7 @@ class Script: public QObject {
Q_OBJECT; Q_OBJECT;
Q_SIGNALS: Q_SIGNALS:
void logging(QString); void logging(QString);
void progress(QString, int, int);
public: public:
typedef std::pair<QString, QStringList> Signal; typedef std::pair<QString, QStringList> Signal;
enum ClickType { enum ClickType {
@ -597,8 +598,10 @@ class Script: public QObject {
testsuite.attr("name") = "Unnamed Test Suite"; testsuite.attr("name") = "Unnamed Test Suite";
(*_testsuites)<<testsuite; (*_testsuites)<<testsuite;
} }
int retries(0), back(0); int retries(0), back(0), step(0);
for (auto cmd(_script.begin()); cmd!=_script.end(); ++cmd) { for (auto cmd(_script.begin()); cmd!=_script.end(); ++cmd, ++step) {
progress(QString("%1:%2").arg((*cmd)->file()).arg((*cmd)->line()),
step, steps());
xml::Node testcase("testcase"); xml::Node testcase("testcase");
try { try {
testcase.attr("classname") = testcase.attr("classname") =
@ -628,7 +631,10 @@ class Script: public QObject {
_testsuites->last()<<testcase; _testsuites->last()<<testcase;
break; // test is successfully finished break; // test is successfully finished
} }
} catch (PossibleRetryLoad& e) { progress(QString("%1:%2").arg((*cmd)->file()).arg((*cmd)->line()),
step, steps());
} catch (PossibleRetryLoad& e) {
_timer.stop(); _timer.stop();
// timeout may happen during load due to bad internet connection // timeout may happen during load due to bad internet connection
if (screenshots) if (screenshots)
@ -646,11 +652,13 @@ class Script: public QObject {
QUrl url(frame->url()); QUrl url(frame->url());
if ((*cmd)->command()=="expect loadFinished true") { if ((*cmd)->command()=="expect loadFinished true") {
------cmd; ------cmd;
------step;
back += 3; back += 3;
_ignoreSignalsUntil = "loadStarted"; _ignoreSignalsUntil = "loadStarted";
frame->load(url); frame->load(url);
} else if ((*cmd)->command()=="expect loadStarted") { } else if ((*cmd)->command()=="expect loadStarted") {
----cmd; ----cmd;
----step;
back += 2; back += 2;
_ignoreSignalsUntil = "loadStarted"; _ignoreSignalsUntil = "loadStarted";
frame->page()->triggerAction(QWebPage::Stop); frame->page()->triggerAction(QWebPage::Stop);
@ -659,6 +667,7 @@ class Script: public QObject {
url2.remove("expect urlChanged"); url2.remove("expect urlChanged");
if (url2.size()) url=url2.trimmed(); if (url2.size()) url=url2.trimmed();
----cmd; ----cmd;
----step;
back += 2; back += 2;
_ignoreSignalsUntil = "loadStarted"; _ignoreSignalsUntil = "loadStarted";
frame->load(url); frame->load(url);
@ -667,6 +676,7 @@ class Script: public QObject {
url2.remove("expect load"); url2.remove("expect load");
if (url2.size()) url=url2.trimmed(); if (url2.size()) url=url2.trimmed();
----cmd; ----cmd;
----step;
back += 2; back += 2;
_ignoreSignalsUntil = "loadStarted"; _ignoreSignalsUntil = "loadStarted";
frame->load(url); frame->load(url);
@ -725,6 +735,7 @@ class Script: public QObject {
} }
removeSignals(frame); removeSignals(frame);
if (!_signals.empty()) throw UnhandledSignals(_signals); if (!_signals.empty()) throw UnhandledSignals(_signals);
progress("success", 0, 0);
return res; return res;
} }
Command* command() { Command* command() {
@ -2261,7 +2272,7 @@ class Check: public Command {
QString description() const { QString description() const {
return return
tag()+" <value1> <cmp> <value2>\n"+ tag()+" <value1> <cmp> <value2>\n"+
tag()+" <value1>\n" tag()+" <value1> <cmp>\n"
" <command>" " <command>"
"\n\n" "\n\n"
"Compares two values (you can use variables) or compares a value to the" "Compares two values (you can use variables) or compares a value to the"

@ -35,6 +35,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI {
_typing(false), _typing(false),
_inEventFilter(false) { _inEventFilter(false) {
setupUi(this); setupUi(this);
_progress->hide();
QSettings settings("mrw", "webtester"); QSettings settings("mrw", "webtester");
restoreGeometry(settings.value("geometry").toByteArray()); restoreGeometry(settings.value("geometry").toByteArray());
restoreState(settings.value("windowstate").toByteArray()); restoreState(settings.value("windowstate").toByteArray());
@ -112,6 +113,8 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI {
_actionRevertToSaved->setEnabled(false); _actionRevertToSaved->setEnabled(false);
} }
void on__run_clicked() { void on__run_clicked() {
_progress->reset();
_progress->show();
bool oldRecordState(_record->isChecked()); bool oldRecordState(_record->isChecked());
_record->setChecked(false); _record->setChecked(false);
_record->setEnabled(false); _record->setEnabled(false);
@ -119,6 +122,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI {
try { try {
Script script; Script script;
connect(&script, SIGNAL(logging(QString)), SLOT(logging(QString))); connect(&script, SIGNAL(logging(QString)), SLOT(logging(QString)));
connect(&script, SIGNAL(progress(QString, int, int)), SLOT(progress(QString, int, int)));
std::shared_ptr<xml::Node> testsuites(new xml::Node("testsuite")); std::shared_ptr<xml::Node> testsuites(new xml::Node("testsuite"));
if (_setupscriptactive->isEnabled() if (_setupscriptactive->isEnabled()
&& _setupscriptactive->isChecked()) { && _setupscriptactive->isChecked()) {
@ -140,6 +144,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI {
_run->setEnabled(true); _run->setEnabled(true);
_record->setEnabled(true); _record->setEnabled(true);
_record->setChecked(oldRecordState); _record->setChecked(oldRecordState);
_progress->hide();
} }
void on__focused_clicked() { void on__focused_clicked() {
enterText(true); enterText(true);
@ -165,13 +170,13 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI {
} }
void on__web_loadProgress(int progress) { void on__web_loadProgress(int progress) {
enterText(true); enterText(true);
_progress->setValue(progress); _webprogress->setValue(progress);
} }
void on__web_loadStarted() { void on__web_loadStarted() {
enterText(true); enterText(true);
if (_record->isChecked()) if (_record->isChecked())
appendCommand("expect "+map("loadStarted")); appendCommand("expect "+map("loadStarted"));
_progress->setValue(0); _webprogress->setValue(0);
_urlStack->setCurrentIndex(PROGRESS_VIEW); _urlStack->setCurrentIndex(PROGRESS_VIEW);
} }
void on__web_statusBarMessage(const QString&) { void on__web_statusBarMessage(const QString&) {
@ -281,6 +286,12 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI {
if (!vb) return; if (!vb) return;
vb->setValue(vb->maximum()); vb->setValue(vb->maximum());
} }
void progress(const QString& txt, int pos, int max) {
_progress->setFormat(QString("%1 — %p%").arg(txt));
_progress->setMinimum(0);
_progress->setMaximum(max);
_progress->setValue(pos);
}
void appendCommand(const QString& txt) { void appendCommand(const QString& txt) {
_testscript->appendPlainText(txt); _testscript->appendPlainText(txt);
QScrollBar *vb(_testscript->verticalScrollBar()); QScrollBar *vb(_testscript->verticalScrollBar());

@ -57,7 +57,7 @@
<widget class="QWidget" name="page_2"> <widget class="QWidget" name="page_2">
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<item> <item>
<widget class="QProgressBar" name="_progress"> <widget class="QProgressBar" name="_webprogress">
<property name="value"> <property name="value">
<number>24</number> <number>24</number>
</property> </property>
@ -91,7 +91,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>888</width> <width>888</width>
<height>22</height> <height>20</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuViews"> <widget class="QMenu" name="menuViews">
@ -398,47 +398,62 @@ this.dispatchEvent(evObj);</string>
<number>4</number> <number>4</number>
</attribute> </attribute>
<widget class="QWidget" name="dockWidgetContents_12"> <widget class="QWidget" name="dockWidgetContents_12">
<layout class="QGridLayout" name="gridLayout"> <layout class="QVBoxLayout" name="verticalLayout_9">
<item row="0" column="0" rowspan="4"> <item>
<widget class="QPlainTextEdit" name="_testscript"/> <layout class="QHBoxLayout" name="horizontalLayout_6">
</item> <item>
<item row="0" column="1"> <widget class="QPlainTextEdit" name="_testscript"/>
<widget class="QPushButton" name="_record"> </item>
<property name="text"> <item>
<string>Record</string> <layout class="QVBoxLayout" name="verticalLayout_8">
</property> <item>
<property name="checkable"> <widget class="QPushButton" name="_record">
<bool>true</bool> <property name="text">
</property> <string>Record</string>
<property name="checked"> </property>
<bool>false</bool> <property name="checkable">
</property> <bool>true</bool>
</widget> </property>
</item> <property name="checked">
<item row="1" column="1"> <bool>false</bool>
<widget class="QPushButton" name="_run"> </property>
<property name="text"> </widget>
<string>Run</string> </item>
</property> <item>
</widget> <widget class="QPushButton" name="_run">
</item> <property name="text">
<item row="3" column="1"> <string>Run</string>
<spacer name="verticalSpacer"> </property>
<property name="orientation"> </widget>
<enum>Qt::Vertical</enum> </item>
</property> <item>
<property name="sizeHint" stdset="0"> <widget class="QCheckBox" name="_screenshots">
<size> <property name="text">
<width>20</width> <string>Screenshots</string>
<height>82</height> </property>
</size> </widget>
</property> </item>
</spacer> <item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>82</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item> </item>
<item row="2" column="1"> <item>
<widget class="QCheckBox" name="_screenshots"> <widget class="QProgressBar" name="_progress">
<property name="text"> <property name="value">
<string>Screenshots</string> <number>24</number>
</property> </property>
</widget> </widget>
</item> </item>

Loading…
Cancel
Save