diff options
Diffstat (limited to 'WebKitTools/QtTestBrowser')
-rw-r--r-- | WebKitTools/QtTestBrowser/launcherwindow.cpp | 17 | ||||
-rw-r--r-- | WebKitTools/QtTestBrowser/launcherwindow.h | 5 | ||||
-rw-r--r-- | WebKitTools/QtTestBrowser/main.cpp | 35 | ||||
-rw-r--r-- | WebKitTools/QtTestBrowser/urlloader.cpp | 21 | ||||
-rw-r--r-- | WebKitTools/QtTestBrowser/urlloader.h | 7 | ||||
-rw-r--r-- | WebKitTools/QtTestBrowser/utils.cpp | 4 | ||||
-rw-r--r-- | WebKitTools/QtTestBrowser/webview.cpp | 4 | ||||
-rw-r--r-- | WebKitTools/QtTestBrowser/webview.h | 2 |
8 files changed, 54 insertions, 41 deletions
diff --git a/WebKitTools/QtTestBrowser/launcherwindow.cpp b/WebKitTools/QtTestBrowser/launcherwindow.cpp index 65bcee7..df29f11 100644 --- a/WebKitTools/QtTestBrowser/launcherwindow.cpp +++ b/WebKitTools/QtTestBrowser/launcherwindow.cpp @@ -41,9 +41,7 @@ LauncherWindow::LauncherWindow(WindowOptions* data, QGraphicsScene* sharedScene) , m_view(0) , m_inspector(0) , m_formatMenuAction(0) -#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) , m_zoomAnimation(0) -#endif { if (data) m_windowOptions = *data; @@ -91,6 +89,9 @@ void LauncherWindow::init() m_inspector->hide(); connect(this, SIGNAL(destroyed()), m_inspector, SLOT(deleteLater())); + if (m_windowOptions.remoteInspectorPort) + page()->setProperty("_q_webInspectorServerPort", m_windowOptions.remoteInspectorPort); + // the zoom values are chosen to be like in Mozilla Firefox 3 if (!m_zoomLevels.count()) { m_zoomLevels << 30 << 50 << 67 << 80 << 90; @@ -134,9 +135,7 @@ void LauncherWindow::initializeView() if (url.isValid()) page()->mainFrame()->load(url); -#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) m_touchMocking = false; -#endif } void LauncherWindow::applyPrefs() @@ -240,11 +239,9 @@ void LauncherWindow::createChrome() toggleFrameFlattening->setCheckable(true); toggleFrameFlattening->setChecked(settings->testAttribute(QWebSettings::FrameFlatteningEnabled)); -#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) QAction* touchMockAction = toolsMenu->addAction("Toggle touch mocking", this, SLOT(setTouchMocking(bool))); touchMockAction->setCheckable(true); touchMockAction->setShortcut(QKeySequence(Qt::CTRL | Qt::ALT | Qt::Key_T)); -#endif toolsMenu->addSeparator(); @@ -406,7 +403,6 @@ void LauncherWindow::grabZoomKeys(bool grab) #endif } -#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) void LauncherWindow::sendTouchEvent() { if (m_touchPoints.isEmpty()) @@ -430,7 +426,6 @@ void LauncherWindow::sendTouchEvent() if (m_touchPoints.size() > 1 && m_touchPoints[1].state() == Qt::TouchPointReleased) m_touchPoints.removeAt(1); } -#endif // QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) bool LauncherWindow::eventFilter(QObject* obj, QEvent* event) { @@ -446,7 +441,6 @@ bool LauncherWindow::eventFilter(QObject* obj, QEvent* event) } } -#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) if (!m_touchMocking) return QObject::eventFilter(obj, event); @@ -508,7 +502,6 @@ bool LauncherWindow::eventFilter(QObject* obj, QEvent* event) m_touchPoints.last().setState(Qt::TouchPointStationary); } } -#endif // QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) return false; } @@ -546,7 +539,6 @@ void LauncherWindow::zoomAnimationFinished() void LauncherWindow::applyZoom() { -#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) if (isGraphicsBased() && page()->settings()->testAttribute(QWebSettings::TiledBackingStoreEnabled)) { QGraphicsWebView* view = static_cast<WebViewGraphicsBased*>(m_view)->graphicsWebView(); view->setTiledBackingStoreFrozen(true); @@ -564,7 +556,6 @@ void LauncherWindow::applyZoom() m_zoomAnimation->start(); return; } -#endif page()->mainFrame()->setZoomFactor(qreal(m_currentZoom) / 100.0); } @@ -674,9 +665,7 @@ void LauncherWindow::selectElements() void LauncherWindow::setTouchMocking(bool on) { -#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) m_touchMocking = on; -#endif } void LauncherWindow::toggleWebView(bool graphicsBased) diff --git a/WebKitTools/QtTestBrowser/launcherwindow.h b/WebKitTools/QtTestBrowser/launcherwindow.h index d3b7f8e..84dedaa 100644 --- a/WebKitTools/QtTestBrowser/launcherwindow.h +++ b/WebKitTools/QtTestBrowser/launcherwindow.h @@ -110,6 +110,7 @@ public: bool useQGLWidgetViewport; #endif QUrl inspectorUrl; + quint16 remoteInspectorPort; }; class LauncherWindow : public MainWindow { @@ -122,9 +123,7 @@ public: virtual void keyPressEvent(QKeyEvent* event); void grabZoomKeys(bool grab); -#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) void sendTouchEvent(); -#endif bool eventFilter(QObject* obj, QEvent* event); @@ -199,11 +198,9 @@ private: QAction* m_formatMenuAction; -#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) QPropertyAnimation* m_zoomAnimation; QList<QTouchEvent::TouchPoint> m_touchPoints; bool m_touchMocking; -#endif }; #endif diff --git a/WebKitTools/QtTestBrowser/main.cpp b/WebKitTools/QtTestBrowser/main.cpp index ec864e9..41471fa 100644 --- a/WebKitTools/QtTestBrowser/main.cpp +++ b/WebKitTools/QtTestBrowser/main.cpp @@ -54,6 +54,8 @@ public: LauncherApplication(int& argc, char** argv); QStringList urls() const { return m_urls; } bool isRobotized() const { return m_isRobotized; } + int robotTimeout() const { return m_robotTimeoutSeconds; } + int robotExtraTime() const { return m_robotExtraTimeSeconds; } private: void handleUserOptions(); @@ -61,6 +63,8 @@ private: private: bool m_isRobotized; + int m_robotTimeoutSeconds; + int m_robotExtraTimeSeconds; QStringList m_urls; }; @@ -78,6 +82,8 @@ void LauncherApplication::applyDefaultSettings() LauncherApplication::LauncherApplication(int& argc, char** argv) : QApplication(argc, argv, QApplication::GuiServer) , m_isRobotized(false) + , m_robotTimeoutSeconds(0) + , m_robotExtraTimeSeconds(0) { // To allow QWebInspector's configuration persistence setOrganizationName("Nokia"); @@ -115,6 +121,8 @@ void LauncherApplication::handleUserOptions() << "[-cache-webview]" << "[-show-fps]" << "[-r list]" + << "[-robot-timeout seconds]" + << "[-robot-extra-time seconds]" << "[-inspector-url location]" << "[-tiled-backing-store]" << "[-resizes-to-contents]" @@ -180,6 +188,11 @@ void LauncherApplication::handleUserOptions() if (inspectorUrlIndex != -1) windowOptions.inspectorUrl = takeOptionValue(&args, inspectorUrlIndex); + QString remoteInspectorPortArg("-remote-inspector-port"); + int remoteInspectorPortIndex = args.indexOf(remoteInspectorPortArg); + if (remoteInspectorPortIndex != -1) + windowOptions.remoteInspectorPort = takeOptionValue(&args, remoteInspectorPortIndex).toInt(); + int robotIndex = args.indexOf("-r"); if (robotIndex != -1) { QString listFile = takeOptionValue(&args, robotIndex); @@ -190,11 +203,18 @@ void LauncherApplication::handleUserOptions() m_isRobotized = true; m_urls = QStringList(listFile); - return; + } else { + int lastArg = args.lastIndexOf(QRegExp("^-.*")); + m_urls = (lastArg != -1) ? args.mid(++lastArg) : args.mid(1); } - int lastArg = args.lastIndexOf(QRegExp("^-.*")); - m_urls = (lastArg != -1) ? args.mid(++lastArg) : args.mid(1); + int robotTimeoutIndex = args.indexOf("-robot-timeout"); + if (robotTimeoutIndex != -1) + m_robotTimeoutSeconds = takeOptionValue(&args, robotTimeoutIndex).toInt(); + + int robotExtraTimeIndex = args.indexOf("-robot-extra-time"); + if (robotExtraTimeIndex != -1) + m_robotExtraTimeSeconds = takeOptionValue(&args, robotExtraTimeIndex).toInt(); } @@ -204,8 +224,7 @@ int main(int argc, char **argv) if (app.isRobotized()) { LauncherWindow* window = new LauncherWindow(); - UrlLoader loader(window->page()->mainFrame(), app.urls().at(0)); - QObject::connect(window->page()->mainFrame(), SIGNAL(loadFinished(bool)), &loader, SLOT(loadNext())); + UrlLoader loader(window->page()->mainFrame(), app.urls().at(0), app.robotTimeout(), app.robotExtraTime()); loader.loadNext(); window->show(); return launcherMain(app); @@ -214,9 +233,9 @@ int main(int argc, char **argv) QStringList urls = app.urls(); if (urls.isEmpty()) { - QString defaultUrl = QString("file://%1/%2").arg(QDir::homePath()).arg(QLatin1String("index.html")); - if (QDir(defaultUrl).exists()) - urls.append(defaultUrl); + QString defaultIndexFile = QString("%1/%2").arg(QDir::homePath()).arg(QLatin1String("index.html")); + if (QFile(defaultIndexFile).exists()) + urls.append(QString("file://") + defaultIndexFile); else urls.append(""); } diff --git a/WebKitTools/QtTestBrowser/urlloader.cpp b/WebKitTools/QtTestBrowser/urlloader.cpp index 630ead6..abe9902 100644 --- a/WebKitTools/QtTestBrowser/urlloader.cpp +++ b/WebKitTools/QtTestBrowser/urlloader.cpp @@ -31,16 +31,31 @@ #include <QFile> #include <QDebug> -UrlLoader::UrlLoader(QWebFrame* frame, const QString& inputFileName) +UrlLoader::UrlLoader(QWebFrame* frame, const QString& inputFileName, int timeoutSeconds, int extraTimeSeconds) : m_frame(frame) , m_stdOut(stdout) , m_loaded(0) { - init(inputFileName); + if (timeoutSeconds) { + m_timeoutTimer.setInterval(timeoutSeconds * 1000); + m_timeoutTimer.setSingleShot(true); + connect(frame, SIGNAL(loadStarted()), &m_timeoutTimer, SLOT(start())); + connect(&m_timeoutTimer, SIGNAL(timeout()), this, SLOT(loadNext())); + } + if (extraTimeSeconds) { + m_extraTimeTimer.setInterval(extraTimeSeconds * 1000); + m_extraTimeTimer.setSingleShot(true); + connect(frame, SIGNAL(loadFinished(bool)), &m_extraTimeTimer, SLOT(start())); + connect(&m_extraTimeTimer, SIGNAL(timeout()), this, SLOT(loadNext())); + } else + connect(frame, SIGNAL(loadFinished(bool)), this, SLOT(loadNext())); + loadUrlList(inputFileName); } void UrlLoader::loadNext() { + m_timeoutTimer.stop(); + m_extraTimeTimer.stop(); QString qstr; if (getUrl(qstr)) { QUrl url(qstr, QUrl::StrictMode); @@ -53,7 +68,7 @@ void UrlLoader::loadNext() disconnect(m_frame, 0, this, 0); } -void UrlLoader::init(const QString& inputFileName) +void UrlLoader::loadUrlList(const QString& inputFileName) { QFile inputFile(inputFileName); if (inputFile.open(QIODevice::ReadOnly | QIODevice::Text)) { diff --git a/WebKitTools/QtTestBrowser/urlloader.h b/WebKitTools/QtTestBrowser/urlloader.h index ed14adc..e2a6d87 100644 --- a/WebKitTools/QtTestBrowser/urlloader.h +++ b/WebKitTools/QtTestBrowser/urlloader.h @@ -32,19 +32,20 @@ #include "qwebframe.h" #include <QTextStream> +#include <QTimer> #include <QVector> class UrlLoader : public QObject { Q_OBJECT public: - UrlLoader(QWebFrame* frame, const QString& inputFileName); + UrlLoader(QWebFrame* frame, const QString& inputFileName, int timeoutSeconds, int extraTimeSeconds); public slots: void loadNext(); private: - void init(const QString& inputFileName); + void loadUrlList(const QString& inputFileName); bool getUrl(QString& qstr); private: @@ -53,6 +54,8 @@ private: QWebFrame* m_frame; QTextStream m_stdOut; int m_loaded; + QTimer m_timeoutTimer; + QTimer m_extraTimeTimer; }; #endif diff --git a/WebKitTools/QtTestBrowser/utils.cpp b/WebKitTools/QtTestBrowser/utils.cpp index 2d45dd0..567c989 100644 --- a/WebKitTools/QtTestBrowser/utils.cpp +++ b/WebKitTools/QtTestBrowser/utils.cpp @@ -82,11 +82,7 @@ QUrl urlFromUserInput(const QString& string) if (fi.exists() && fi.isRelative()) input = fi.absoluteFilePath(); -#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) return QUrl::fromUserInput(input); -#else - return QUrl(input); -#endif } diff --git a/WebKitTools/QtTestBrowser/webview.cpp b/WebKitTools/QtTestBrowser/webview.cpp index d8d89a9..242daf6 100644 --- a/WebKitTools/QtTestBrowser/webview.cpp +++ b/WebKitTools/QtTestBrowser/webview.cpp @@ -151,7 +151,6 @@ void WebViewGraphicsBased::updateFrameRate() void WebViewGraphicsBased::animatedFlip() { -#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) QSizeF center = graphicsWebView()->boundingRect().size() / 2; QPointF centerPoint = QPointF(center.width(), center.height()); graphicsWebView()->setTransformOriginPoint(centerPoint); @@ -165,12 +164,10 @@ void WebViewGraphicsBased::animatedFlip() animation->setEndValue(rotation + 180 - (rotation % 180)); animation->start(QAbstractAnimation::DeleteWhenStopped); -#endif } void WebViewGraphicsBased::animatedYFlip() { -#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) if (!m_machine) { m_machine = new QStateMachine(this); @@ -202,7 +199,6 @@ void WebViewGraphicsBased::animatedYFlip() } m_machine->start(); -#endif } void WebViewGraphicsBased::paintEvent(QPaintEvent* event) diff --git a/WebKitTools/QtTestBrowser/webview.h b/WebKitTools/QtTestBrowser/webview.h index aadf85c..e34d081 100644 --- a/WebKitTools/QtTestBrowser/webview.h +++ b/WebKitTools/QtTestBrowser/webview.h @@ -117,13 +117,11 @@ private: inline void WebViewGraphicsBased::setYRotation(qreal angle) { -#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) QRectF r = graphicsWebView()->boundingRect(); graphicsWebView()->setTransform(QTransform() .translate(r.width() / 2, r.height() / 2) .rotate(angle, Qt::YAxis) .translate(-r.width() / 2, -r.height() / 2)); -#endif m_yRotation = angle; } |