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

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

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

@ -35,6 +35,15 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI {
_typing(false), _typing(false),
_inEventFilter(false) { _inEventFilter(false) {
setupUi(this); 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(); _progress->hide();
QSettings settings("mrw", "webtester"); QSettings settings("mrw", "webtester");
restoreGeometry(settings.value("geometry").toByteArray()); restoreGeometry(settings.value("geometry").toByteArray());

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

Loading…
Cancel
Save