From 8b769b948366f990b9c17e62e8a4a0e4d8c1958d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=A4ckerlin?= Date: Tue, 1 Nov 2016 15:46:18 +0000 Subject: [PATCH] first version of a script run progress bar --- ChangeLog | 18 +++++++++ configure.ac | 2 +- src/commands.hxx | 19 ++++++++-- src/testgui.hxx | 15 +++++++- src/testgui.ui | 99 ++++++++++++++++++++++++++++-------------------- 5 files changed, 104 insertions(+), 49 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9bba8a8..7fd9cc6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 * build-in-docker.sh: fixed build diff --git a/configure.ac b/configure.ac index f8abefc..cb1288c 100644 --- a/configure.ac +++ b/configure.ac @@ -9,7 +9,7 @@ # change this: m4_define(x_package_name, webtester) # project's name 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: m4_include(ax_init_standard_project.m4) diff --git a/src/commands.hxx b/src/commands.hxx index 2cb2a93..a844a5f 100644 --- a/src/commands.hxx +++ b/src/commands.hxx @@ -413,6 +413,7 @@ class Script: public QObject { Q_OBJECT; Q_SIGNALS: void logging(QString); + void progress(QString, int, int); public: typedef std::pair Signal; enum ClickType { @@ -597,8 +598,10 @@ class Script: public QObject { testsuite.attr("name") = "Unnamed Test Suite"; (*_testsuites)<file()).arg((*cmd)->line()), + step, steps()); xml::Node testcase("testcase"); try { testcase.attr("classname") = @@ -628,7 +631,10 @@ class Script: public QObject { _testsuites->last()<file()).arg((*cmd)->line()), + step, steps()); + + } catch (PossibleRetryLoad& e) { _timer.stop(); // timeout may happen during load due to bad internet connection if (screenshots) @@ -646,11 +652,13 @@ class Script: public QObject { QUrl url(frame->url()); if ((*cmd)->command()=="expect loadFinished true") { ------cmd; + ------step; back += 3; _ignoreSignalsUntil = "loadStarted"; frame->load(url); } else if ((*cmd)->command()=="expect loadStarted") { ----cmd; + ----step; back += 2; _ignoreSignalsUntil = "loadStarted"; frame->page()->triggerAction(QWebPage::Stop); @@ -659,6 +667,7 @@ class Script: public QObject { url2.remove("expect urlChanged"); if (url2.size()) url=url2.trimmed(); ----cmd; + ----step; back += 2; _ignoreSignalsUntil = "loadStarted"; frame->load(url); @@ -667,6 +676,7 @@ class Script: public QObject { url2.remove("expect load"); if (url2.size()) url=url2.trimmed(); ----cmd; + ----step; back += 2; _ignoreSignalsUntil = "loadStarted"; frame->load(url); @@ -725,6 +735,7 @@ class Script: public QObject { } removeSignals(frame); if (!_signals.empty()) throw UnhandledSignals(_signals); + progress("success", 0, 0); return res; } Command* command() { @@ -2261,7 +2272,7 @@ class Check: public Command { QString description() const { return tag()+" \n"+ - tag()+" \n" + tag()+" \n" " " "\n\n" "Compares two values (you can use variables) or compares a value to the" diff --git a/src/testgui.hxx b/src/testgui.hxx index 250a55e..1af4377 100644 --- a/src/testgui.hxx +++ b/src/testgui.hxx @@ -35,6 +35,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { _typing(false), _inEventFilter(false) { setupUi(this); + _progress->hide(); QSettings settings("mrw", "webtester"); restoreGeometry(settings.value("geometry").toByteArray()); restoreState(settings.value("windowstate").toByteArray()); @@ -112,6 +113,8 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { _actionRevertToSaved->setEnabled(false); } void on__run_clicked() { + _progress->reset(); + _progress->show(); bool oldRecordState(_record->isChecked()); _record->setChecked(false); _record->setEnabled(false); @@ -119,6 +122,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { try { Script script; connect(&script, SIGNAL(logging(QString)), SLOT(logging(QString))); + connect(&script, SIGNAL(progress(QString, int, int)), SLOT(progress(QString, int, int))); std::shared_ptr testsuites(new xml::Node("testsuite")); if (_setupscriptactive->isEnabled() && _setupscriptactive->isChecked()) { @@ -140,6 +144,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { _run->setEnabled(true); _record->setEnabled(true); _record->setChecked(oldRecordState); + _progress->hide(); } void on__focused_clicked() { enterText(true); @@ -165,13 +170,13 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { } void on__web_loadProgress(int progress) { enterText(true); - _progress->setValue(progress); + _webprogress->setValue(progress); } void on__web_loadStarted() { enterText(true); if (_record->isChecked()) appendCommand("expect "+map("loadStarted")); - _progress->setValue(0); + _webprogress->setValue(0); _urlStack->setCurrentIndex(PROGRESS_VIEW); } void on__web_statusBarMessage(const QString&) { @@ -281,6 +286,12 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { if (!vb) return; 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) { _testscript->appendPlainText(txt); QScrollBar *vb(_testscript->verticalScrollBar()); diff --git a/src/testgui.ui b/src/testgui.ui index 79ca45b..b45b637 100644 --- a/src/testgui.ui +++ b/src/testgui.ui @@ -57,7 +57,7 @@ - + 24 @@ -91,7 +91,7 @@ 0 0 888 - 22 + 20 @@ -398,47 +398,62 @@ this.dispatchEvent(evObj); 4 - - - - - - - - Record - - - true - - - false - - - - - - - Run - - - - - - - Qt::Vertical - - - - 20 - 82 - - - + + + + + + + + + + + + Record + + + true + + + false + + + + + + + Run + + + + + + + Screenshots + + + + + + + Qt::Vertical + + + + 20 + 82 + + + + + + + - - - - Screenshots + + + + 24