improve expect load; fix views menu; improve function call error display

master
Marc Wäckerlin 8 years ago
parent 8b769b9483
commit 006a5a2e6e
  1. 44
      src/commands.hxx
  2. 9
      src/testgui.hxx
  3. 14
      src/testgui.ui

@ -845,11 +845,16 @@ class Script: public QObject {
return _clicktype;
}
QString replacevars(QString txt) {
for(QMap<QString, QString>::iterator it(_variables.begin());
it!=_variables.end(); ++it)
for (QMap<QString, QString>::iterator it(_variables.begin());
it!=_variables.end(); ++it)
txt.replace(it.key(), it.value(), Qt::CaseSensitive);
return txt;
}
QStringList replacevars(QStringList txts) {
for (QStringList::iterator txt(txts.begin()); txt!=txts.end(); ++txt)
*txt = replacevars(*txt);
return txts;
}
QString insertvars(QString txt) {
QMapIterator<LenString, LenString> it(_rvariables);
it.toBack();
@ -1113,7 +1118,7 @@ class Expect: public Command {
"There is a short hand:\n"
" - load <url>\n"
" stands for the three signals:\n"
" - loadStarted\n"
" - loadStarted (optional)\n"
" - urlChanged <url>\n"
" - loadFinished true";
}
@ -1130,24 +1135,22 @@ class Expect: public Command {
}
bool execute(Script* script, QWebFrame*) {
Logger log(this, script);
QList<Signal> sigs;
QStringList args(script->replacevars(_signal._args));
Script::Signal lastsignal(script->getSignal());
if (_signal._signal=="load") { // special signal load
sigs += Signal("loadStarted");
sigs += Signal("urlChanged", _signal._args);
sigs += Signal("loadFinished", "true");
if (lastsignal.first=="loadStarted") {
log("ignore loadStarted");
lastsignal = script->getSignal(); // ignore optional loadStarted
}
if (lastsignal.first!="urlChanged" || (args.size() && lastsignal.second!=args))
throw WrongSignal("urlChanged", args, lastsignal);
lastsignal = script->getSignal();
args=QStringList("true");
if (lastsignal.first!="loadFinished" || (lastsignal.second!=args))
throw WrongSignal("loadFinished", args, lastsignal);
} else {
sigs += _signal;
}
Q_FOREACH(Signal signal, sigs) {
QStringList args;
Q_FOREACH(QString arg, signal._args)
args.push_back(script->replacevars(arg));
Script::Signal lastsignal(script->getSignal());
QStringList lastargs;
Q_FOREACH(QString arg, lastsignal.second)
lastargs.push_back(script->replacevars(arg));
if (lastsignal.first!=signal._signal || (args.size() && args!=lastargs))
throw WrongSignal(signal._signal, args, lastsignal);
if (lastsignal.first!=_signal._signal || (args.size() && lastsignal.second!=args))
throw WrongSignal(_signal._signal, args, lastsignal);
}
return true;
}
@ -2084,7 +2087,8 @@ class Call: public Command {
}
bool execute(Script* script, QWebFrame* frame) {
Logger log(this, script);
return script->function(_name)->call(this, _args, script, frame);
return script->function(_name)->call(this, script->replacevars(_args),
script, frame);
}
public:
QString _name;

@ -35,6 +35,15 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI {
_typing(false),
_inEventFilter(false) {
setupUi(this);
menuViews->addAction(_scriptDock->toggleViewAction());
menuViews->addAction(_setupScriptDock->toggleViewAction());
menuViews->addAction(_scriptCommandsDock->toggleViewAction());
menuViews->addAction(_domDock->toggleViewAction());
menuViews->addAction(_linksDock->toggleViewAction());
menuViews->addAction(_formsDock->toggleViewAction());
menuViews->addAction(_logDock->toggleViewAction());
menuViews->addAction(_sourceDock->toggleViewAction());
menuViews->addAction(_executeDock->toggleViewAction());
_progress->hide();
QSettings settings("mrw", "webtester");
restoreGeometry(settings.value("geometry").toByteArray());

@ -98,13 +98,6 @@
<property name="title">
<string>Views</string>
</property>
<addaction name="_actionTestScript"/>
<addaction name="_actionDOMTree"/>
<addaction name="_actionLinks"/>
<addaction name="_actionForms"/>
<addaction name="_actionHTMLSouce"/>
<addaction name="_actionExecuteJavaScript"/>
<addaction name="_actionLog"/>
</widget>
<widget class="QMenu" name="menuFile">
<property name="title">
@ -475,7 +468,7 @@ this.dispatchEvent(evObj);</string>
</layout>
</widget>
</widget>
<widget class="QDockWidget" name="dockWidget">
<widget class="QDockWidget" name="_setupScriptDock">
<property name="windowTitle">
<string>Setup Script</string>
</property>
@ -534,7 +527,7 @@ this.dispatchEvent(evObj);</string>
</layout>
</widget>
</widget>
<widget class="QDockWidget" name="dockWidget_2">
<widget class="QDockWidget" name="_scriptCommandsDock">
<property name="windowTitle">
<string>Script Commands</string>
</property>
@ -653,6 +646,9 @@ this.dispatchEvent(evObj);</string>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>Log</string>
</property>

Loading…
Cancel
Save