removed warnings; code cleaned up

master
Marc Wäckerlin 6 years ago
parent 7c7786eb04
commit a1c721f45d
  1. 97
      src/commands.hxx
  2. 8
      src/editor.hxx
  3. 8
      src/exceptions.hxx
  4. 4
      src/networkaccessmanager.hxx
  5. 4
      src/scriptfile.hxx
  6. 36
      src/testgui.hxx
  7. 20
      src/webpage.hxx
  8. 4
      src/webrunner.cxx

@ -105,7 +105,7 @@ class Logger {
};
class Command: public QObject {
Q_OBJECT;
Q_OBJECT
public:
Command(): _log(true), _line(-1), _indent(0) {}
virtual ~Command() {}
@ -119,7 +119,7 @@ class Command: public QObject {
log(QString(" FAILED[")+demangle(typeid(e).name())+"]: "+e.what());
throw e;
}
virtual int steps(Script* parent) {
virtual int steps(Script*) {
return 1;
}
void line(int linenr) {
@ -198,10 +198,11 @@ class Command: public QObject {
QStringList args = QStringList());
QStringList subCommandBlock(QStringList& in) {
QStringList commands;
int pos(-1);
std::string::size_type pos(std::string::npos);
while (in.size() && in[0].size() && in[0][0]==' '
&& pos<=(signed)in[0].toStdString().find_first_not_of(' ')) {
if (pos<0) pos=in[0].toStdString().find_first_not_of(' ');
&& (pos==std::string::npos ||
pos<=in[0].toStdString().find_first_not_of(' '))) {
if (pos==std::string::npos) pos=in[0].toStdString().find_first_not_of(' ');
commands += in.takeFirst().mid(pos);
}
return commands;
@ -252,7 +253,7 @@ class Command: public QObject {
for (int i=0; i<repeat; ++i) {
element = frame->findFirstElement(selector);
if (!element.isNull()) return element;
Q_FOREACH(QWebFrame* childFrame, frame->childFrames()) {
for (QWebFrame* childFrame: frame->childFrames()) {
element = find1(childFrame, selector, 1, 0);
if (!element.isNull()) return element;
}
@ -403,7 +404,7 @@ class Screenshot: public Command {
};
class RunDownload: public QObject {
Q_OBJECT;
Q_OBJECT
public:
RunDownload(QNetworkReply* reply, QString filename):
_reply(reply), _file(filename) {
@ -445,7 +446,7 @@ class RunDownload: public QObject {
-# test scripts, see @ref testscript. */
class Script: public QObject {
Q_OBJECT;
Q_OBJECT
Q_SIGNALS:
void logging(QString);
void progress(QString, int, int);
@ -486,17 +487,17 @@ class Script: public QObject {
}
public:
Script():
_step(0), _clicktype(JAVASCRIPT_CLICK), _command(0),
_screenshots(true), _defaultTimeout(20) {
_step(0), _clicktype(JAVASCRIPT_CLICK),
_screenshots(true), _command(0), _defaultTimeout(20) {
initPrototypes();
}
Script(const Script& o):
QObject(),
_step(0),
_prototypes(o._prototypes),
_step(0),
_script(o._script),
_command(0),
_screenshots(true) {
_screenshots(true),
_command(0) {
set(o);
}
QString syntax() const {
@ -861,7 +862,7 @@ class Script: public QObject {
void ignore(QStringList sigs = QStringList()) {
if (sigs.empty())
sigs<<"loadFinished"<<"loadStarted"<<"frameChanged"<<"titleChanged"<<"urlChanged";
Q_FOREACH(const QString& sig, sigs) {
for (const QString& sig: sigs) {
log("start ignoring: '"+sig+"'");
_ignore<<sig;
}
@ -869,7 +870,7 @@ class Script: public QObject {
void unignore(QStringList sigs = QStringList()) {
if (sigs.empty())
sigs<<"loadFinished"<<"loadStarted"<<"frameChanged"<<"titleChanged"<<"urlChanged";
Q_FOREACH(const QString& sig, sigs) {
for (const QString& sig: sigs) {
if (_ignore.contains(sig)) {
log("stop ignoring: '"+sig+"'");
_ignore.erase(_ignore.find(sig));
@ -1190,7 +1191,7 @@ class CommandContainer: public Command {
return countSteps(parent);
}
protected:
virtual int countSteps(Script* parent) const {
virtual int countSteps(Script*) const {
return _script->countSteps()+1;
}
std::shared_ptr<Script> _script;
@ -1580,7 +1581,7 @@ class Exists: public Command {
QString text(script->replacevars(_text));
QStringList notfound;
QWebElement firstelement(find(frame, selector, script->timeout()-1));
Q_FOREACH(QWebElement element, frame->findAllElements(selector)) {
for (QWebElement element: frame->findAllElements(selector)) {
if (text.isEmpty()) return true; // just find element
if (element.toOuterXml().indexOf(text)!=-1) return true;
if (element.toPlainText().indexOf(text)!=-1) return true;
@ -1636,7 +1637,7 @@ class Not: public Command {
QString text(script->replacevars(_text));
QWebElement firstelement(find(frame, selector,
mrw::max(mrw::min(script->timeout()/3, 10), 2)));
Q_FOREACH(QWebElement element, frame->findAllElements(selector)) {
for (QWebElement element: frame->findAllElements(selector)) {
if (text.isEmpty())
error(log, AssertionFailed("element must not exists: "+selector));
if (element.toOuterXml().indexOf(text)!=-1)
@ -1685,7 +1686,7 @@ class Execute: public Command {
QString command(script->replacevars(_command));
QStringList args;
QString scripttxt(script->replacevars(_script.join("\n")));
Q_FOREACH(QString arg, _args) args.push_back(script->replacevars(arg));
for (QString arg: _args) args.push_back(script->replacevars(arg));
QProcess exec;
exec.setProcessChannelMode(QProcess::MergedChannels);
exec.start(command, args);
@ -1699,14 +1700,14 @@ class Execute: public Command {
exec.closeWriteChannel();
if (!exec.waitForFinished(60000) && exec.state()!=QProcess::NotRunning)
error(log, ScriptNotFinished(command, args, scripttxt));
QString stdout(exec.readAllStandardOutput());
QString stderr(exec.readAllStandardError());
_result = stdout;
QString sout(exec.readAllStandardOutput());
QString serr(exec.readAllStandardError());
_result = sout;
log("result: "+(_result.size()?_result:"(void)"));
script->log(stdout);
script->log(sout);
if (exec.exitCode()!=0 || exec.exitStatus()!=QProcess::NormalExit)
error(log, ScriptExecutionFailed(command, args, scripttxt,
exec.exitCode(), stdout, stderr));
exec.exitCode(), sout, serr));
return true;
}
private:
@ -1716,7 +1717,7 @@ class Execute: public Command {
};
class Download: public Command {
Q_OBJECT;
Q_OBJECT
public:
QString tag() const {
return "download";
@ -2158,7 +2159,7 @@ class SetValue: public Command {
if (element.tagName()=="SELECT") {
// value is a comma seperated list of option values
QStringList values(commaSeparatedList(value));
Q_FOREACH(QWebElement option, element.findAll("option")) {
for (QWebElement option: element.findAll("option")) {
QString name(option.evaluateJavaScript("this.value").toString());
option.evaluateJavaScript
("this.selected="+QString(values.contains(name)?"true;":"false;"));
@ -2224,6 +2225,7 @@ class Function: public CommandContainer {
return runScript(log, parentCommand, _script, script, frame, _vars, args);
} catch (const Exception& x) {
error(log, FunctionCallFailed(_name, _vars, args, x));
return false; // never reached due to exception above
}
}
private:
@ -2342,7 +2344,7 @@ class If: public CommandContainer {
if (_cmp=="->") {
QWebElement firstelement(find(frame, selector,
mrw::max(mrw::min(script->timeout()/3, 10), 2)));
Q_FOREACH(QWebElement element, frame->findAllElements(selector)) {
for (QWebElement element: frame->findAllElements(selector)) {
if (value.isEmpty() || // just find element
element.toOuterXml().indexOf(value)!=-1 ||
element.toPlainText().indexOf(value)!=-1) {
@ -2449,7 +2451,7 @@ class While: public CommandContainer {
check = false;
QWebElement firstelement(find(frame, selector,
mrw::max(mrw::min(script->timeout()/3, 10), 2)));
Q_FOREACH(QWebElement element, frame->findAllElements(selector)) {
for (QWebElement element: frame->findAllElements(selector)) {
if (value.isEmpty() || // just find element
element.toOuterXml().indexOf(value)!=-1 ||
element.toPlainText().indexOf(value)!=-1) {
@ -2511,7 +2513,7 @@ class TestSuite: public Command {
cmd->_name = args;
return cmd;
}
bool execute(Script* script, QWebFrame* frame) {
bool execute(Script* script, QWebFrame*) {
Logger log(this, script);
script->testsuite(script->replacevars(_name));
return true;
@ -2540,7 +2542,7 @@ class TestCase: public Command {
cmd->_name = args;
return cmd;
}
bool execute(Script* script, QWebFrame* frame) {
bool execute(Script* script, QWebFrame*) {
Logger log(this, script);
script->testclass(script->replacevars(_name));
return true;
@ -2648,7 +2650,7 @@ class For: public CommandContainer {
" in the loop.\n\n"
"Without values, if there is a global variable with the same name as the"
" local variable the global variable is parsed as if it were the line after"
" the dash (->).\n\n";
" the dash (->).\n\n"
"If you quote the values, then quote all values with the same"
" quotes. If you need a comma within a value, you must quote.";
}
@ -2667,7 +2669,7 @@ class For: public CommandContainer {
}
bool execute(Script* script, QWebFrame* frame) {
Logger log(this, script);
Q_FOREACH(QString i, _vals.size()?_vals:commaSeparatedList(script->variable(_variable))) {
for (QString i: _vals.size()?_vals:commaSeparatedList(script->variable(_variable))) {
if (!runScript(log, this, _script, script, frame, QStringList()<<_variable, QStringList()<<i))
return false;
}
@ -2706,7 +2708,7 @@ class Echo: public Command {
cmd->_text = args;
return cmd;
}
bool execute(Script* script, QWebFrame* frame) {
bool execute(Script* script, QWebFrame*) {
Logger log(this, script);
log(script->replacevars(_text));
return true;
@ -2774,7 +2776,7 @@ class ClearCookies: public Command {
QString url(_url);
if (url.isEmpty()) url = frame->url().toString();
QNetworkCookieJar* cookies = frame->page()->networkAccessManager()->cookieJar();
Q_FOREACH(QNetworkCookie cookie, cookies->cookiesForUrl(url)) {
for (QNetworkCookie cookie: cookies->cookiesForUrl(url)) {
log("delete cookie "+cookie.name());
cookies->deleteCookie(cookie);
}
@ -2810,7 +2812,7 @@ class Include: public CommandContainer {
} catch (Exception& e) {
throw ParseIncludeFailed(cmd->_filename, e.what());
}
Q_FOREACH(QString key, cmd->_script->functions()) // copy new functions to parent
for (QString key: cmd->_script->functions()) // copy new functions to parent
script->function(key, cmd->_script->function(key));
return cmd;
}
@ -2820,6 +2822,7 @@ class Include: public CommandContainer {
return runScript(log, this, _script, script, frame);
} catch (Exception& e) {
error(log, ExecuteIncludeFailed(_filename, e.what()));
return false; // never reached due to exception above
}
}
private:
@ -2837,7 +2840,7 @@ class Case: public Command {
" <cmp1> <value1>\n"
" <command>\n"
" <command>\n"
" <cmp1> <value2>\n"
" <cmp2> <value2>\n"
" <command>\n"
" <command>\n"
" <...>\n"
@ -2873,7 +2876,7 @@ class Case: public Command {
}
QString command() const {
QString body;
Q_FOREACH(Condition condition, _conditions) {
for (Condition condition: _conditions) {
body += "\n "+condition.cmp+" "+condition.value+"\n "
+condition.script->print().join("\n ");
}
@ -2886,6 +2889,7 @@ class Case: public Command {
if (!args.size()) throw BadArgument(tag()+" requires a <variable> or <selector>");
cmd->_variable = args;
QStringList body(subCommandBlock(in));
if (!body.size()) throw BadArgument(tag()+" requires a body");
while (body.size()) {
++line;
QStringList parts(body.takeFirst().split(' '));
@ -2902,7 +2906,7 @@ class Case: public Command {
bool execute(Script* script, QWebFrame* frame) {
Logger log(this, script, false);
QString selector(script->replacevars(_variable));
Q_FOREACH(Condition condition, _conditions) {
for (Condition condition: _conditions) {
QString value(script->replacevars(condition.value));
bool check(false);
if (condition.cmp=="default") {
@ -2911,7 +2915,7 @@ class Case: public Command {
} else if (condition.cmp=="->") {
QWebElement firstelement(find(frame, selector,
mrw::max(mrw::min(script->timeout()/3, 10), 2)));
Q_FOREACH(QWebElement element, frame->findAllElements(selector)) {
for (QWebElement element: frame->findAllElements(selector)) {
if (value.isEmpty() || // just find element
element.toOuterXml().indexOf(value)!=-1 ||
element.toPlainText().indexOf(value)!=-1) {
@ -2948,7 +2952,7 @@ class Case: public Command {
return true;
}
private:
int countSteps(Script* parent) {
int countSteps(Script*) {
int res1(0);
for (auto condition: _conditions) {
int res2(condition.script->countSteps()+1);
@ -3031,7 +3035,7 @@ class Auth: public Command {
}
return cmd;
}
bool execute(Script* script, QWebFrame* frame) {
bool execute(Script* script, QWebFrame*) {
Logger log(this, script);
script->auth(_realm, _username, _password);
return true;
@ -3065,7 +3069,7 @@ class Ignore: public Command {
cmd->_signals = args.split(' ', QString::SkipEmptyParts);
return cmd;
}
bool execute(Script* script, QWebFrame* frame) {
bool execute(Script* script, QWebFrame*) {
Logger log(this, script);
script->ignore(_signals);
return true;
@ -3097,7 +3101,7 @@ class UnIgnore: public Command {
cmd->_signals = args.split(' ', QString::SkipEmptyParts);
return cmd;
}
bool execute(Script* script, QWebFrame* frame) {
bool execute(Script* script, QWebFrame*) {
Logger log(this, script);
script->unignore(_signals);
return true;
@ -3151,11 +3155,12 @@ inline Logger::Logger(Command* command, Script* script, bool showLines):
if (command) {
_previous = _script->command();
_script->command(command);
if (_command->log())
if (_command->log()) {
if (showLines)
_script->log("\\ "+_command->command(), _command);
else
_script->log("\\ "+_command->command().split('\n').first(), _command);
}
}
}
inline void Logger::operator()(QString txt) {
@ -3182,7 +3187,7 @@ inline std::shared_ptr<Script> Command::subParser(Script* parent, const QStringL
const QString& file,
int line, int indent) {
std::shared_ptr<Script> res(new Script);
Q_FOREACH(QString key, parent->functions()) // copy functions from parent
for (QString key: parent->functions()) // copy functions from parent
res->function(key, parent->function(key));
res->parse(in, file, line+1, indent+1);
return res;
@ -3216,7 +3221,7 @@ inline bool Command::runScript(Logger& log, Command* parentCommand,
disconnect(&scriptCopy, SIGNAL(logging(QString)),
parent, SLOT(parentlog(QString)));
parentCommand->_result = scriptCopy.result();
Q_FOREACH(QString key, scriptCopy.variables()) // copy new variables to parent
for (QString key: scriptCopy.variables()) // copy new variables to parent
if (!vars.contains(key)) parent->set(key, scriptCopy.variable(key));
parent->ignore(scriptCopy); // copy ignore list
if (parentCommand->_result.size())

@ -14,7 +14,7 @@
#include <iostream>
class Highlighter: public QSyntaxHighlighter {
Q_OBJECT;
Q_OBJECT
Q_SIGNALS:
void include(QString);
public:
@ -40,9 +40,9 @@ class Highlighter: public QSyntaxHighlighter {
include(m.captured(1));
}
for (auto e: _expressions) {
auto m(e.re.match(text));
for (int i(0); i<=m.lastCapturedIndex(); ++i) {
setFormat(m.capturedStart(i), m.capturedLength(i), e.fmt);
auto m2(e.re.match(text));
for (int i(0); i<=m2.lastCapturedIndex(); ++i) {
setFormat(m2.capturedStart(i), m2.capturedLength(i), e.fmt);
}
}
}

@ -224,10 +224,10 @@ class ScriptNotFinished: public ScriptFailed {
class ScriptExecutionFailed: public ScriptFailed {
public:
ScriptExecutionFailed(QString command, QStringList args, QString script,
int code, QString stdout, QString stderr):
int code, QString sout, QString serr):
ScriptFailed("failed with exit code "+QString::number(code)
+(stdout.size()?"; stdout=\""+stdout+"\"":"")
+(stderr.size()?"; stderr=\""+stderr+"\"":""),
+(sout.size()?"; sout=\""+sout+"\"":"")
+(serr.size()?"; serr=\""+serr+"\"":""),
command, args, script) {
}
};
@ -269,7 +269,7 @@ class CheckFailed: public TestFailed {
public:
CheckFailed(QString value1, char cmp, QString value2):
TestFailed(QString("check failed: %1 %2 %3")
.arg(value1).arg(cmp).arg(value1)) {
.arg(value1).arg(cmp).arg(value2)) {
}
};

@ -13,7 +13,7 @@
#include <QNetworkProxy>
class NetworkAccessManager: public QNetworkAccessManager {
Q_OBJECT;
Q_OBJECT
public:
NetworkAccessManager(QObject* parent = 0): QNetworkAccessManager(parent) {
//log(__PRETTY_FUNCTION__);
@ -224,7 +224,7 @@ class NetworkAccessManager: public QNetworkAccessManager {
//log(__PRETTY_FUNCTION__);
}
void sslErrorsLog(const QList<QSslError>& errors) {
Q_FOREACH(const QSslError& error, errors) {
for (const QSslError& error: errors) {
log("**** SSL-Error: "+error.errorString());
}
QNetworkReply* reply(dynamic_cast<QNetworkReply*>(QObject::sender()));

@ -5,7 +5,7 @@
#include <cassert>
class ScriptFile: public QDockWidget, protected Ui::ScriptFile {
Q_OBJECT;
Q_OBJECT
Q_SIGNALS:
void link(QString);
void include(QString);
@ -31,7 +31,7 @@ class ScriptFile: public QDockWidget, protected Ui::ScriptFile {
setWindowModified(false);
}
protected:
void closeEvent (QCloseEvent *event) {
void closeEvent (QCloseEvent*) {
close(this);
}
private:

@ -28,7 +28,7 @@
#include <mrw/stdext.hxx>
class TestGUI: public QMainWindow, protected Ui::TestGUI {
Q_OBJECT;
Q_OBJECT
public:
explicit TestGUI(QWidget *parent = 0,
QString url = QString(),
@ -59,15 +59,15 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI {
if (!url.isEmpty()) {
storeUrl(url);
}
TestWebPage* page(new TestWebPage(_web));
_web->setPage(page);
TestWebPage* pg(new TestWebPage(_web));
_web->setPage(pg);
_web->installEventFilter(this); // track mouse and keyboard
page->setForwardUnsupportedContent(true);
pg->setForwardUnsupportedContent(true);
_commands->setText(Script().commands(Script::HTML));
assert(connect(page, SIGNAL(uploadFile(QString)), SLOT(uploadFile(QString))));
assert(connect(page, SIGNAL(unsupportedContent(QNetworkReply*)),
assert(connect(pg, SIGNAL(uploadFile(QString)), SLOT(uploadFile(QString))));
assert(connect(pg, SIGNAL(unsupportedContent(QNetworkReply*)),
SLOT(unsupportedContent(QNetworkReply*))));
assert(connect(page, SIGNAL(downloadRequested(const QNetworkRequest&)),
assert(connect(pg, SIGNAL(downloadRequested(const QNetworkRequest&)),
SLOT(downloadRequested(const QNetworkRequest&))));
//assert(connect(_testscript, SIGNAL(include(QString)), SLOT(include(QString))));
assert(connect(_testscript, SIGNAL(link(QString)), SLOT(include(QString))));
@ -270,12 +270,12 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI {
_setupscriptstatus->setText(trUtf8("?"));
std::shared_ptr<xml::Node> testsuites(new xml::Node("testsuite"));
Script script;
TestWebPage page(0, true);
TestWebPage pg(0, true);
script.parse(_setupscript->toPlainText().split('\n'), "setup");
script.run(page.mainFrame(), testsuites, QString(), false);
script.run(pg.mainFrame(), testsuites, QString(), false);
_setupScript.cleanup();
_setupScript.parse(_setupscript->toPlainText().split('\n'), "setup");
_setupScript.run(page.mainFrame(), testsuites, QString(), false);
_setupScript.run(pg.mainFrame(), testsuites, QString(), false);
_setupscriptstatus->setText(trUtf8(""));
_setupscriptactive->setEnabled(true);
} catch (std::exception &x) {
@ -425,16 +425,15 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI {
// click on a select results in a value change
// find all selected options ...
QStringList v;
Q_FOREACH(QWebElement option,
_lastFocused.findAll("option")) {
for (QWebElement option: _lastFocused.findAll("option")) {
//! @bug QT does not support selected
if (option.evaluateJavaScript("this.selected").toBool())
v += value(option);
}
setValue(selected, v);
} else if (_lastFocused.tagName()=="TEXTAREA" ||
_lastFocused.tagName()=="INPUT" &&
_lastFocused.attribute("type")=="text") {
(_lastFocused.tagName()=="INPUT" &&
_lastFocused.attribute("type")=="text")) {
// user clickt in a text edit field, so not the klick
// is important, but the text that will be typed
_typing = true;
@ -543,8 +542,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI {
"selection.setBaseAndExtent(this, 0, this, 1);");
}
QWebElement focused(QMouseEvent* event = 0) {
Q_FOREACH(QWebElement element,
_web->page()->currentFrame()->findAllElements("*")) {
for (QWebElement element: _web->page()->currentFrame()->findAllElements("*")) {
if (element.hasFocus()) {
return element;
}
@ -579,11 +577,11 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI {
+"[name="+quote(element.attribute("name"))+"]";
} else {
QString res;
Q_FOREACH(QString attr, element.attributeNames()) {
for (QString attr: element.attributeNames()) {
if (attr=="id")
res = "#"+element.attribute("id")+res;
else if (attr=="class")
Q_FOREACH(QString c, element.attribute(attr).split(' ')) {
for (QString c: element.attribute(attr).split(' ')) {
if (!c.isEmpty()) res = '.'+c+res;
}
else if (element.attribute(attr).isEmpty())
@ -736,7 +734,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI {
QWebElementCollection forms(_web->page()->mainFrame()->documentElement()
.findAll("form"));
_forms->clear();
Q_FOREACH(const QWebElement &form, forms) {
for (const QWebElement &form: forms) {
addDomElement(form, _forms->invisibleRootItem());
}

@ -26,7 +26,7 @@ inline std::ostream& operator<<(std::ostream& o, const QString& s) {
#endif
class TestWebPage: public QWebPage {
Q_OBJECT;
Q_OBJECT
public:
TestWebPage(QObject* parent = 0, bool unattended = false):
QWebPage(parent),
@ -38,10 +38,16 @@ class TestWebPage: public QWebPage {
//settings()->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, true);
settings()->setAttribute(QWebSettings::LocalStorageEnabled, true);
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wterminate"
virtual ~TestWebPage() {
if (!_nextFile.isEmpty() && !std::uncaught_exception())
// will not call terminate(), because I check std::uncaught_exception()
throw LastFileNotUploaded(_nextFile);
}
#pragma GCC diagnostic pop
void setNextUploadFile(QString nextFile) {
if (!_unattended) throw NotUnattended();
if (!_nextFile.isEmpty()) throw LastFileNotUploaded(_nextFile);
@ -73,8 +79,7 @@ class TestWebPage: public QWebPage {
if (_unattended) {
return;
} else {
return;
//return QWebPage::javaScriptAlert(frame, msg);
return QWebPage::javaScriptAlert(frame, msg);
}
}
virtual bool javaScriptConfirm(QWebFrame* frame, const QString& msg) {
@ -82,8 +87,7 @@ class TestWebPage: public QWebPage {
if (_unattended) {
return true;
} else {
return true;
//return QWebPage::javaScriptConfirm(frame, msg);
return QWebPage::javaScriptConfirm(frame, msg);
}
}
virtual void javaScriptConsoleMessage(const QString& msg,
@ -92,8 +96,7 @@ class TestWebPage: public QWebPage {
if (_unattended) {
return;
} else {
return;
//return QWebPage::javaScriptConsoleMessage(msg, line, src);
return QWebPage::javaScriptConsoleMessage(msg, line, src);
}
}
virtual bool javaScriptPrompt(QWebFrame* frame, const QString& msg,
@ -102,8 +105,7 @@ class TestWebPage: public QWebPage {
if (_unattended) {
return true;
} else {
return true;
//return QWebPage::javaScriptPrompt(frame, msg, defaultValue, result);
return QWebPage::javaScriptPrompt(frame, msg, defaultValue, result);
}
}
private:

@ -56,7 +56,7 @@ QString format(QString txt, int indent = 2, int cpl = 80) {
QStringList res;
QStringList lines(txt.split('\n'));
QString ind(indent, ' ');
Q_FOREACH(QString line, lines) {
for (QString line: lines) {
line.insert(0, ind);
for (int pos(indent); line.size()-pos>cpl; ++pos) {
int pos2=line.lastIndexOf(' ', pos+cpl);
@ -152,7 +152,7 @@ int main(int argc, char *argv[]) try {
QString target(parser.value("target-path"));
p.resize(width, height);
std::shared_ptr<xml::Node> testsuites(new xml::Node("testsuites"));
Q_FOREACH(QString file, parser.positionalArguments()) {
for (QString file: parser.positionalArguments()) {
int expectedtestcases(-1);
xml::Node testsuite("testsuite");
testsuite.attr("name") = QFileInfo(file).baseName().toStdString();

Loading…
Cancel
Save