mirror of
https://github.com/thoughtbot/capybara-webkit
synced 2023-03-27 23:22:28 -04:00
Extract method
This commit is contained in:
parent
612028dc6f
commit
d3b9b304f3
2 changed files with 14 additions and 8 deletions
|
@ -5,6 +5,19 @@
|
|||
#include <iostream>
|
||||
|
||||
WebPage::WebPage(QObject *parent) : QWebPage(parent) {
|
||||
loadJavascript();
|
||||
|
||||
m_loading = false;
|
||||
|
||||
this->setNetworkAccessManager(new NetworkAccessManager());
|
||||
|
||||
connect(this, SIGNAL(loadStarted()), this, SLOT(loadStarted()));
|
||||
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool)));
|
||||
connect(this, SIGNAL(frameCreated(QWebFrame *)),
|
||||
this, SLOT(frameCreated(QWebFrame *)));
|
||||
}
|
||||
|
||||
void WebPage::loadJavascript() {
|
||||
QResource javascript(":/capybara.js");
|
||||
if (javascript.isCompressed()) {
|
||||
QByteArray uncompressedBytes(qUncompress(javascript.data(), javascript.size()));
|
||||
|
@ -15,14 +28,6 @@ WebPage::WebPage(QObject *parent) : QWebPage(parent) {
|
|||
javascriptString[javascript.size()] = 0;
|
||||
m_capybaraJavascript = javascriptString;
|
||||
}
|
||||
m_loading = false;
|
||||
|
||||
this->setNetworkAccessManager(new NetworkAccessManager());
|
||||
|
||||
connect(this, SIGNAL(loadStarted()), this, SLOT(loadStarted()));
|
||||
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool)));
|
||||
connect(this, SIGNAL(frameCreated(QWebFrame *)),
|
||||
this, SLOT(frameCreated(QWebFrame *)));
|
||||
}
|
||||
|
||||
QString WebPage::userAgentForUrl(const QUrl &url ) const {
|
||||
|
|
|
@ -33,5 +33,6 @@ class WebPage : public QWebPage {
|
|||
QString m_userAgent;
|
||||
bool m_loading;
|
||||
QString getLastAttachedFileName();
|
||||
void loadJavascript();
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue