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. 17
      src/commands.hxx
  4. 15
      src/testgui.hxx
  5. 37
      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
* build-in-docker.sh: fixed build

@ -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)

@ -413,6 +413,7 @@ class Script: public QObject {
Q_OBJECT;
Q_SIGNALS:
void logging(QString);
void progress(QString, int, int);
public:
typedef std::pair<QString, QStringList> Signal;
enum ClickType {
@ -597,8 +598,10 @@ class Script: public QObject {
testsuite.attr("name") = "Unnamed Test Suite";
(*_testsuites)<<testsuite;
}
int retries(0), back(0);
for (auto cmd(_script.begin()); cmd!=_script.end(); ++cmd) {
int retries(0), back(0), step(0);
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");
try {
testcase.attr("classname") =
@ -628,6 +631,9 @@ class Script: public QObject {
_testsuites->last()<<testcase;
break; // test is successfully finished
}
progress(QString("%1:%2").arg((*cmd)->file()).arg((*cmd)->line()),
step, steps());
} catch (PossibleRetryLoad& e) {
_timer.stop();
// timeout may happen during load due to bad internet connection
@ -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()+" <value1> <cmp> <value2>\n"+
tag()+" <value1>\n"
tag()+" <value1> <cmp>\n"
" <command>"
"\n\n"
"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),
_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<xml::Node> 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());

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

Loading…
Cancel
Save