|
|
|
@ -10,6 +10,7 @@ |
|
|
|
|
#include <webpage.hxx> |
|
|
|
|
#include <editor.hxx> |
|
|
|
|
#include <commands.hxx> |
|
|
|
|
#include <scriptfile.hxx> |
|
|
|
|
#include <QMainWindow> |
|
|
|
|
#include <QSettings> |
|
|
|
|
#include <QWebFrame> |
|
|
|
@ -63,11 +64,12 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
|
_web->installEventFilter(this); // track mouse and keyboard
|
|
|
|
|
page->setForwardUnsupportedContent(true); |
|
|
|
|
_commands->setText(Script().commands(Script::HTML)); |
|
|
|
|
connect(page, SIGNAL(uploadFile(QString)), SLOT(uploadFile(QString))); |
|
|
|
|
connect(page, SIGNAL(unsupportedContent(QNetworkReply*)), |
|
|
|
|
SLOT(unsupportedContent(QNetworkReply*))); |
|
|
|
|
connect(page, SIGNAL(downloadRequested(const QNetworkRequest&)), |
|
|
|
|
SLOT(downloadRequested(const QNetworkRequest&))); |
|
|
|
|
assert(connect(page, SIGNAL(uploadFile(QString)), SLOT(uploadFile(QString)))); |
|
|
|
|
assert(connect(page, SIGNAL(unsupportedContent(QNetworkReply*)), |
|
|
|
|
SLOT(unsupportedContent(QNetworkReply*)))); |
|
|
|
|
assert(connect(page, SIGNAL(downloadRequested(const QNetworkRequest&)), |
|
|
|
|
SLOT(downloadRequested(const QNetworkRequest&)))); |
|
|
|
|
assert(connect(_testscript, SIGNAL(include(QString)), SLOT(include(QString)))); |
|
|
|
|
if (setupScript.size()) loadSetup(setupScript); |
|
|
|
|
if (scriptFile.size()) loadFile(scriptFile); |
|
|
|
|
} |
|
|
|
@ -338,6 +340,32 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
|
if (!vb) return; |
|
|
|
|
vb->setValue(vb->maximum()); |
|
|
|
|
} |
|
|
|
|
void include(QString name) { |
|
|
|
|
if (_testscripts.contains(name)) return; |
|
|
|
|
_testscripts[name] = new ScriptFile(this); |
|
|
|
|
assert(connect(_testscripts[name], SIGNAL(include(QString)), SLOT(include(QString)))); |
|
|
|
|
assert(connect(_testscripts[name], SIGNAL(close(ScriptFile*)), SLOT(remove(ScriptFile*)))); |
|
|
|
|
QFile file(name); |
|
|
|
|
try { |
|
|
|
|
if (!file.open(QIODevice::ReadOnly|QIODevice::Text)) |
|
|
|
|
throw std::runtime_error("file open failed"); |
|
|
|
|
_testscripts[name]->editor()->setPlainText(QString::fromUtf8(file.readAll())); |
|
|
|
|
if (file.error()!=QFileDevice::NoError) |
|
|
|
|
throw std::runtime_error("file read failed"); |
|
|
|
|
_testscripts[name]->name(name); |
|
|
|
|
tabifyDockWidget(_scriptDock, _testscripts[name]); |
|
|
|
|
QDockWidget* d(0); |
|
|
|
|
for (QWidget* w(QApplication::focusWidget()); w&&!(d=qobject_cast<QDockWidget*>(w)); |
|
|
|
|
w=qobject_cast<QWidget*>(w->parent())); |
|
|
|
|
if (d) d->raise(); |
|
|
|
|
} catch(const std::exception& x) { |
|
|
|
|
remove(_testscripts[name]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
void remove(ScriptFile* scriptfile) { |
|
|
|
|
_testscripts.remove(scriptfile->name()); |
|
|
|
|
delete scriptfile; |
|
|
|
|
} |
|
|
|
|
protected: |
|
|
|
|
void closeEvent(QCloseEvent* event) { |
|
|
|
|
QSettings settings("mrw", "webtester"); |
|
|
|
@ -900,6 +928,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
|
bool _typing; // user is typing
|
|
|
|
|
bool _inEventFilter; // actually handling event filter
|
|
|
|
|
Script _setupScript; |
|
|
|
|
QMap<QString, ScriptFile*> _testscripts; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
#endif // TESTGUI_HXX
|
|
|
|
|