|
|
@ -14,6 +14,7 @@ |
|
|
|
#include <QWebFrame> |
|
|
|
#include <QWebFrame> |
|
|
|
#include <QWebElement> |
|
|
|
#include <QWebElement> |
|
|
|
#include <QFileDialog> |
|
|
|
#include <QFileDialog> |
|
|
|
|
|
|
|
#include <QScrollBar> |
|
|
|
#include <QFile> |
|
|
|
#include <QFile> |
|
|
|
#include <QMessageBox> |
|
|
|
#include <QMessageBox> |
|
|
|
#include <ui_testgui.h> |
|
|
|
#include <ui_testgui.h> |
|
|
@ -49,7 +50,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
void on__load_clicked() { |
|
|
|
void on__load_clicked() { |
|
|
|
enterText(true); |
|
|
|
enterText(true); |
|
|
|
if (_record->isChecked()) |
|
|
|
if (_record->isChecked()) |
|
|
|
_testscript->appendPlainText("load "+_url->text()); |
|
|
|
appendCommand("load "+_url->text()); |
|
|
|
_web->load(_url->text()); |
|
|
|
_web->load(_url->text()); |
|
|
|
} |
|
|
|
} |
|
|
|
void on__abort_clicked() { |
|
|
|
void on__abort_clicked() { |
|
|
@ -109,6 +110,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
} |
|
|
|
} |
|
|
|
void on__actionClear_triggered() { |
|
|
|
void on__actionClear_triggered() { |
|
|
|
_testscript->clear(); |
|
|
|
_testscript->clear(); |
|
|
|
|
|
|
|
_log->clear(); |
|
|
|
_filename.clear(); |
|
|
|
_filename.clear(); |
|
|
|
_actionSave->setEnabled(false); |
|
|
|
_actionSave->setEnabled(false); |
|
|
|
_actionRevertToSaved->setEnabled(false); |
|
|
|
_actionRevertToSaved->setEnabled(false); |
|
|
@ -171,7 +173,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
void on__web_linkClicked(const QUrl& url) { |
|
|
|
void on__web_linkClicked(const QUrl& url) { |
|
|
|
enterText(true); |
|
|
|
enterText(true); |
|
|
|
if (_record->isChecked()) |
|
|
|
if (_record->isChecked()) |
|
|
|
_testscript->appendPlainText("load "+url.url()); |
|
|
|
appendCommand("load "+url.url()); |
|
|
|
} |
|
|
|
} |
|
|
|
void on__web_loadProgress(int progress) { |
|
|
|
void on__web_loadProgress(int progress) { |
|
|
|
enterText(true); |
|
|
|
enterText(true); |
|
|
@ -180,7 +182,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
void on__web_loadStarted() { |
|
|
|
void on__web_loadStarted() { |
|
|
|
enterText(true); |
|
|
|
enterText(true); |
|
|
|
if (_record->isChecked()) |
|
|
|
if (_record->isChecked()) |
|
|
|
_testscript->appendPlainText("expect loadStarted"); |
|
|
|
appendCommand("expect loadStarted"); |
|
|
|
_progress->setValue(0); |
|
|
|
_progress->setValue(0); |
|
|
|
_urlStack->setCurrentIndex(PROGRESS_VIEW); |
|
|
|
_urlStack->setCurrentIndex(PROGRESS_VIEW); |
|
|
|
} |
|
|
|
} |
|
|
@ -193,7 +195,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
void on__web_urlChanged(const QUrl& url) { |
|
|
|
void on__web_urlChanged(const QUrl& url) { |
|
|
|
enterText(true); |
|
|
|
enterText(true); |
|
|
|
if (_record->isChecked()) |
|
|
|
if (_record->isChecked()) |
|
|
|
_testscript->appendPlainText("expect urlChanged "+url.url()); |
|
|
|
appendCommand("expect urlChanged "+url.url()); |
|
|
|
} |
|
|
|
} |
|
|
|
void on__web_selectionChanged() { |
|
|
|
void on__web_selectionChanged() { |
|
|
|
_source->setPlainText(_web->hasSelection() |
|
|
|
_source->setPlainText(_web->hasSelection() |
|
|
@ -203,7 +205,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
void on__web_loadFinished(bool ok) { |
|
|
|
void on__web_loadFinished(bool ok) { |
|
|
|
enterText(true); |
|
|
|
enterText(true); |
|
|
|
if (_record->isChecked()) |
|
|
|
if (_record->isChecked()) |
|
|
|
_testscript->appendPlainText("expect loadFinished " |
|
|
|
appendCommand("expect loadFinished " |
|
|
|
+QString(ok?"true":"false")); |
|
|
|
+QString(ok?"true":"false")); |
|
|
|
_urlStack->setCurrentIndex(URL_VIEW); |
|
|
|
_urlStack->setCurrentIndex(URL_VIEW); |
|
|
|
on__web_selectionChanged(); |
|
|
|
on__web_selectionChanged(); |
|
|
@ -222,7 +224,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
void uploadFile(QString filename) { |
|
|
|
void uploadFile(QString filename) { |
|
|
|
enterText(true); |
|
|
|
enterText(true); |
|
|
|
if (_record->isChecked()) |
|
|
|
if (_record->isChecked()) |
|
|
|
_testscript->appendPlainText("upload "+filename); |
|
|
|
appendCommand("upload "+filename); |
|
|
|
} |
|
|
|
} |
|
|
|
void unsupportedContent(QNetworkReply* reply) { |
|
|
|
void unsupportedContent(QNetworkReply* reply) { |
|
|
|
if (!_record->isChecked()) return; |
|
|
|
if (!_record->isChecked()) return; |
|
|
@ -245,10 +247,19 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
} |
|
|
|
} |
|
|
|
void downloadRequested(const QNetworkRequest&) { |
|
|
|
void downloadRequested(const QNetworkRequest&) { |
|
|
|
if (_record->isChecked()) |
|
|
|
if (_record->isChecked()) |
|
|
|
_testscript->appendPlainText("download2"); |
|
|
|
appendCommand("download2"); |
|
|
|
} |
|
|
|
} |
|
|
|
void logging(QString txt) { |
|
|
|
void logging(const QString& txt) { |
|
|
|
_log->appendPlainText(txt); |
|
|
|
_log->appendPlainText(txt); |
|
|
|
|
|
|
|
QScrollBar *vb(_log->verticalScrollBar()); |
|
|
|
|
|
|
|
if (!vb) return; |
|
|
|
|
|
|
|
vb->setValue(vb->maximum()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void appendCommand(const QString& txt) { |
|
|
|
|
|
|
|
_testscript->appendPlainText(txt); |
|
|
|
|
|
|
|
QScrollBar *vb(_testscript->verticalScrollBar()); |
|
|
|
|
|
|
|
if (!vb) return; |
|
|
|
|
|
|
|
vb->setValue(vb->maximum()); |
|
|
|
} |
|
|
|
} |
|
|
|
protected: |
|
|
|
protected: |
|
|
|
void closeEvent(QCloseEvent* event) { |
|
|
|
void closeEvent(QCloseEvent* event) { |
|
|
@ -301,16 +312,16 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
.match(selected)); |
|
|
|
.match(selected)); |
|
|
|
if (mooCombo.hasMatch()) { |
|
|
|
if (mooCombo.hasMatch()) { |
|
|
|
// special treatment for moo tools combobox (e.g. used in joomla)
|
|
|
|
// special treatment for moo tools combobox (e.g. used in joomla)
|
|
|
|
_testscript->appendPlainText("click "+mooCombo.captured(1)+">a"); |
|
|
|
appendCommand("click "+mooCombo.captured(1)+">a"); |
|
|
|
_testscript->appendPlainText("sleep 1"); |
|
|
|
appendCommand("sleep 1"); |
|
|
|
} else if (mooComboItem.hasMatch()) { |
|
|
|
} else if (mooComboItem.hasMatch()) { |
|
|
|
// special treatment for item in moo tools combobox
|
|
|
|
// special treatment for item in moo tools combobox
|
|
|
|
_testscript->appendPlainText |
|
|
|
appendCommand |
|
|
|
("click li.active-result[data-option-array-index=\"" |
|
|
|
("click li.active-result[data-option-array-index=\"" |
|
|
|
+element.attribute("data-option-array-index")+"\"]"); |
|
|
|
+element.attribute("data-option-array-index")+"\"]"); |
|
|
|
_testscript->appendPlainText("sleep 1"); |
|
|
|
appendCommand("sleep 1"); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
_testscript->appendPlainText("click "+selected); |
|
|
|
appendCommand("click "+selected); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} break; |
|
|
|
} break; |
|
|
@ -425,7 +436,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
} |
|
|
|
} |
|
|
|
void store(const QString& selector, QString code) { |
|
|
|
void store(const QString& selector, QString code) { |
|
|
|
if (_record->isChecked()) |
|
|
|
if (_record->isChecked()) |
|
|
|
_testscript->appendPlainText("do "+selector+"\n " |
|
|
|
appendCommand("do "+selector+"\n " |
|
|
|
+code.replace("\n", "\\n")); |
|
|
|
+code.replace("\n", "\\n")); |
|
|
|
} |
|
|
|
} |
|
|
|
void execute(const QString& selector, const QString& code) { |
|
|
|
void execute(const QString& selector, const QString& code) { |
|
|
|