1
0
Fork 0
mirror of https://github.com/thoughtbot/capybara-webkit synced 2023-03-27 23:22:28 -04:00

Extract method

This commit is contained in:
Joe Ferris 2011-08-12 15:49:40 -04:00
parent 612028dc6f
commit d3b9b304f3
2 changed files with 14 additions and 8 deletions

View file

@ -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 {

View file

@ -33,5 +33,6 @@ class WebPage : public QWebPage {
QString m_userAgent;
bool m_loading;
QString getLastAttachedFileName();
void loadJavascript();
};