summaryrefslogtreecommitdiffstats
path: root/WebKitTools/DumpRenderTree/qt
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:05:15 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:05:15 -0800
commit1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353 (patch)
tree4457a7306ea5acb43fe05bfe0973b1f7faf97ba2 /WebKitTools/DumpRenderTree/qt
parent9364f22aed35e1a1e9d07c121510f80be3ab0502 (diff)
downloadexternal_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.zip
external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.tar.gz
external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.tar.bz2
Code drop from //branches/cupcake/...@124589
Diffstat (limited to 'WebKitTools/DumpRenderTree/qt')
-rw-r--r--WebKitTools/DumpRenderTree/qt/DumpRenderTree.cpp66
-rw-r--r--WebKitTools/DumpRenderTree/qt/DumpRenderTree.h3
-rw-r--r--WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro4
-rw-r--r--WebKitTools/DumpRenderTree/qt/jsobjects.cpp13
-rw-r--r--WebKitTools/DumpRenderTree/qt/jsobjects.h3
-rw-r--r--WebKitTools/DumpRenderTree/qt/main.cpp11
-rw-r--r--WebKitTools/DumpRenderTree/qt/testplugin.cpp46
-rw-r--r--WebKitTools/DumpRenderTree/qt/testplugin.h19
8 files changed, 92 insertions, 73 deletions
diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.cpp b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.cpp
index 5df8a38..07075ba 100644
--- a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.cpp
+++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved.
* Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -29,6 +30,7 @@
#include "DumpRenderTree.h"
#include "jsobjects.h"
+#include "testplugin.h"
#include <QDir>
#include <QFile>
@@ -46,8 +48,10 @@
#include <unistd.h>
#include <qdebug.h>
+
extern void qt_drt_run(bool b);
extern void qt_dump_set_accepts_editing(bool b);
+extern void qt_dump_frame_loader(bool b);
namespace WebCore {
@@ -61,10 +65,10 @@ class WebPage : public QWebPage {
public:
WebPage(QWidget *parent, DumpRenderTree *drt);
- QWebPage *createWindow();
+ QWebPage *createWindow(QWebPage::WebWindowType);
void javaScriptAlert(QWebFrame *frame, const QString& message);
- void javaScriptConsoleMessage(const QString& message, unsigned int lineNumber, const QString& sourceID);
+ void javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID);
bool javaScriptConfirm(QWebFrame *frame, const QString& msg);
bool javaScriptPrompt(QWebFrame *frame, const QString& msg, const QString& defaultValue, QString* result);
@@ -85,11 +89,13 @@ WebPage::WebPage(QWidget *parent, DumpRenderTree *drt)
settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true);
settings()->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true);
settings()->setAttribute(QWebSettings::LinksIncludedInFocusChain, false);
- connect(this, SIGNAL(geometryChangeRequest(const QRect &)),
+ connect(this, SIGNAL(geometryChangeRequested(const QRect &)),
this, SLOT(setViewGeometry(const QRect & )));
+
+ setPluginFactory(new TestPlugin(this));
}
-QWebPage *WebPage::createWindow()
+QWebPage *WebPage::createWindow(QWebPage::WebWindowType)
{
return m_drt->createWindow();
}
@@ -99,7 +105,7 @@ void WebPage::javaScriptAlert(QWebFrame *frame, const QString& message)
fprintf(stdout, "ALERT: %s\n", message.toUtf8().constData());
}
-void WebPage::javaScriptConsoleMessage(const QString& message, unsigned int lineNumber, const QString&)
+void WebPage::javaScriptConsoleMessage(const QString& message, int lineNumber, const QString&)
{
fprintf (stdout, "CONSOLE MESSAGE: line %d: %s\n", lineNumber, message.toUtf8().constData());
}
@@ -130,9 +136,11 @@ DumpRenderTree::DumpRenderTree()
view->setPage(m_page);
connect(m_page, SIGNAL(frameCreated(QWebFrame *)), this, SLOT(connectFrame(QWebFrame *)));
connectFrame(m_page->mainFrame());
-
- m_page->mainFrame()->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- m_page->mainFrame()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+
+ connect(m_page, SIGNAL(loadFinished(bool)), m_controller, SLOT(maybeDump(bool)));
+
+ m_page->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
+ m_page->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
connect(m_page->mainFrame(), SIGNAL(titleChanged(const QString&)),
SLOT(titleChanged(const QString&)));
@@ -168,7 +176,16 @@ void DumpRenderTree::open()
void DumpRenderTree::open(const QUrl& url)
{
+ // W3C SVG tests expect to be 480x360
+ bool isW3CTest = url.toString().contains("svg/W3C-SVG-1.1");
+ int width = isW3CTest ? 480 : maxViewWidth;
+ int height = isW3CTest ? 360 : maxViewHeight;
+ m_page->view()->resize(QSize(width, height));
+ m_page->setViewportSize(QSize(width, height));
+
resetJSObjects();
+
+ qt_dump_frame_loader(url.toString().contains("loading/"));
m_page->mainFrame()->load(url);
}
@@ -181,8 +198,14 @@ void DumpRenderTree::readStdin(int /* socket */)
//fprintf(stderr, "\n opening %s\n", line.constData());
if (line.isEmpty())
quit();
- QFileInfo fi(line);
- open(QUrl::fromLocalFile(fi.absoluteFilePath()));
+
+ if (line.startsWith("http:") || line.startsWith("https:"))
+ open(QUrl(line));
+ else {
+ QFileInfo fi(line);
+ open(QUrl::fromLocalFile(fi.absoluteFilePath()));
+ }
+
fflush(stdout);
}
@@ -198,9 +221,9 @@ void DumpRenderTree::initJSObjects()
{
QWebFrame *frame = qobject_cast<QWebFrame*>(sender());
Q_ASSERT(frame);
- frame->addToJSWindowObject(QLatin1String("layoutTestController"), m_controller);
- frame->addToJSWindowObject(QLatin1String("eventSender"), m_eventSender);
- frame->addToJSWindowObject(QLatin1String("textInputController"), m_textInputController);
+ frame->addToJavaScriptWindowObject(QLatin1String("layoutTestController"), m_controller);
+ frame->addToJavaScriptWindowObject(QLatin1String("eventSender"), m_eventSender);
+ frame->addToJavaScriptWindowObject(QLatin1String("textInputController"), m_textInputController);
}
@@ -213,11 +236,11 @@ QString DumpRenderTree::dumpFramesAsText(QWebFrame* frame)
QWebFrame *parent = qobject_cast<QWebFrame *>(frame->parent());
if (parent) {
result.append(QLatin1String("\n--------\nFrame: '"));
- result.append(frame->name());
+ result.append(frame->frameName());
result.append(QLatin1String("'\n--------\n"));
}
- result.append(frame->innerText());
+ result.append(frame->toPlainText());
result.append(QLatin1String("\n"));
if (m_controller->shouldDumpChildrenAsText()) {
@@ -236,7 +259,7 @@ void DumpRenderTree::dump()
//fprintf(stderr, " Dumping\n");
if (!m_notifier) {
// Dump markup in single file mode...
- QString markup = frame->markup();
+ QString markup = frame->toHtml();
fprintf(stdout, "Source:\n\n%s\n", markup.toUtf8().constData());
}
@@ -257,6 +280,10 @@ void DumpRenderTree::dump()
fflush(stdout);
+ fprintf(stderr, "#EOF\n");
+
+ fflush(stderr);
+
if (!m_notifier) {
// Exit now in single file mode...
quit();
@@ -271,14 +298,9 @@ void DumpRenderTree::titleChanged(const QString &s)
void DumpRenderTree::connectFrame(QWebFrame *frame)
{
- connect(frame, SIGNAL(cleared()), this, SLOT(initJSObjects()));
+ connect(frame, SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(initJSObjects()));
connect(frame, SIGNAL(provisionalLoad()),
layoutTestController(), SLOT(provisionalLoad()));
-
- if (frame == m_page->mainFrame()) {
- connect(frame, SIGNAL(loadDone(bool)),
- layoutTestController(), SLOT(maybeDump(bool)));
- }
}
QWebPage *DumpRenderTree::createWindow()
diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.h b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.h
index b939fad..a46cccb 100644
--- a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.h
+++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.h
@@ -33,8 +33,11 @@
#include <QObject>
#include <QTextStream>
#include <QSocketNotifier>
+
+QT_BEGIN_NAMESPACE
class QUrl;
class QFile;
+QT_END_NAMESPACE
class QWebPage;
class QWebFrame;
diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro
index 8c3dbbf..08f1ab7 100644
--- a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro
+++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro
@@ -16,3 +16,7 @@ SOURCES = DumpRenderTree.cpp main.cpp jsobjects.cpp testplugin.cpp
unix:!mac {
QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR
}
+
+qt-port:lessThan(QT_MINOR_VERSION, 4) {
+ DEFINES += QT_BEGIN_NAMESPACE="" QT_END_NAMESPACE=""
+}
diff --git a/WebKitTools/DumpRenderTree/qt/jsobjects.cpp b/WebKitTools/DumpRenderTree/qt/jsobjects.cpp
index 78a93fe..98603ad 100644
--- a/WebKitTools/DumpRenderTree/qt/jsobjects.cpp
+++ b/WebKitTools/DumpRenderTree/qt/jsobjects.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006 Trolltech ASA
+ * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -35,6 +35,7 @@
#include "DumpRenderTree.h"
extern void qt_dump_editing_callbacks(bool b);
+extern void qt_dump_resource_load_callbacks(bool b);
LayoutTestController::LayoutTestController(WebCore::DumpRenderTree *drt)
: QObject()
@@ -58,14 +59,11 @@ void LayoutTestController::reset()
}
m_topLoadingFrame = 0;
qt_dump_editing_callbacks(false);
+ qt_dump_resource_load_callbacks(false);
}
void LayoutTestController::maybeDump(bool ok)
{
- QWebFrame *frame = qobject_cast<QWebFrame*>(sender());
- if (frame != m_topLoadingFrame)
- return;
-
m_topLoadingFrame = 0;
if (!shouldWaitUntilDone()) {
@@ -109,6 +107,11 @@ void LayoutTestController::dumpEditingCallbacks()
qt_dump_editing_callbacks(true);
}
+void LayoutTestController::dumpResourceLoadCallbacks()
+{
+ qt_dump_resource_load_callbacks(true);
+}
+
void LayoutTestController::queueReload()
{
//qDebug() << ">>>queueReload";
diff --git a/WebKitTools/DumpRenderTree/qt/jsobjects.h b/WebKitTools/DumpRenderTree/qt/jsobjects.h
index 511e857..4ee6439 100644
--- a/WebKitTools/DumpRenderTree/qt/jsobjects.h
+++ b/WebKitTools/DumpRenderTree/qt/jsobjects.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006 Trolltech ASA
+ * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -68,6 +68,7 @@ public slots:
void waitUntilDone();
void notifyDone();
void dumpEditingCallbacks();
+ void dumpResourceLoadCallbacks();
void queueReload();
void provisionalLoad();
void setCloseRemainingWindowsWhenComplete(bool=false) {}
diff --git a/WebKitTools/DumpRenderTree/qt/main.cpp b/WebKitTools/DumpRenderTree/qt/main.cpp
index dd4c0e9..8c4bc9c 100644
--- a/WebKitTools/DumpRenderTree/qt/main.cpp
+++ b/WebKitTools/DumpRenderTree/qt/main.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
- * Copyright (C) 2007 Trolltech ASA
+ * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -28,7 +28,6 @@
*/
#include "DumpRenderTree.h"
-#include "testplugin.h"
#include <qstringlist.h>
#include <qapplication.h>
@@ -49,10 +48,6 @@
#include <execinfo.h>
#endif
-#if QT_VERSION < 0x040400
-Q_IMPORT_PLUGIN(testplugin)
-#endif
-
void messageHandler(QtMsgType type, const char *message)
{
if (type == QtCriticalMsg) {
@@ -162,7 +157,9 @@ int main(int argc, char* argv[])
dumper.open();
} else {
if (!args.last().startsWith("/")
- && !args.last().startsWith("file:")) {
+ && !args.last().startsWith("file:")
+ && !args.last().startsWith("http:")
+ && !args.last().startsWith("https:")) {
QString path = QDir::currentPath();
if (!path.endsWith('/'))
path.append('/');
diff --git a/WebKitTools/DumpRenderTree/qt/testplugin.cpp b/WebKitTools/DumpRenderTree/qt/testplugin.cpp
index 27558c9..54431e9 100644
--- a/WebKitTools/DumpRenderTree/qt/testplugin.cpp
+++ b/WebKitTools/DumpRenderTree/qt/testplugin.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007 Trolltech ASA
+ * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,10 +27,8 @@
*/
#include "testplugin.h"
-#if QT_VERSION < 0x040400
-
TestPlugin::TestPlugin(QObject *parent)
- : QWebObjectPlugin(parent)
+ : QWebPluginFactory(parent)
{
}
@@ -38,34 +36,32 @@ TestPlugin::~TestPlugin()
{
}
-QStringList TestPlugin::keys() const
+QList<QWebPluginFactory::Plugin> TestPlugin::plugins() const
{
- return QStringList(QLatin1String("testplugin"));
-}
+ QWebPluginFactory::Plugin plugin;
-QString TestPlugin::descriptionForKey(const QString &) const
-{
- return QLatin1String("testdescription");
-}
+ plugin.name = "testplugin";
+ plugin.description = "testdescription";
+ MimeType mimeType;
+ mimeType.name = "testtype";
+ mimeType.fileExtensions.append("testsuffixes");
+ plugin.mimeTypes.append(mimeType);
-QStringList TestPlugin::mimetypesForKey(const QString &) const
-{
- return QStringList(QLatin1String("testtype"));
-}
+ plugin.name = "testplugin2";
+ plugin.description = "testdescription2";
+ mimeType.name = "testtype2";
+ mimeType.fileExtensions.append("testsuffixes2");
+ mimeType.fileExtensions.append("testsuffixes3");
+ plugin.mimeTypes.append(mimeType);
-QStringList TestPlugin::extensionsForMimetype(const QString &) const
-{
- return QStringList(QLatin1String("testsuffixes"));
+ return QList<QWebPluginFactory::Plugin>() << plugin;
}
-QObject *TestPlugin::create(QWebObjectPluginConnector *,
- const QUrl &,
- const QString &,
- const QStringList &,
- const QStringList &) const
+QObject *TestPlugin::create(const QString &mimeType,
+ const QUrl &url,
+ const QStringList &argumentNames,
+ const QStringList &argumentValues) const
{
return 0;
}
-Q_EXPORT_PLUGIN2(testplugin, TestPlugin)
-#endif
diff --git a/WebKitTools/DumpRenderTree/qt/testplugin.h b/WebKitTools/DumpRenderTree/qt/testplugin.h
index e305069..3d8a28c 100644
--- a/WebKitTools/DumpRenderTree/qt/testplugin.h
+++ b/WebKitTools/DumpRenderTree/qt/testplugin.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007 Trolltech ASA
+ * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -25,28 +25,21 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <qglobal.h>
-#if QT_VERSION < 0x040400
-#define QT_STATICPLUGIN
-#include <qwebobjectplugin.h>
+#include <qwebpluginfactory.h>
-class TestPlugin : public QWebObjectPlugin
+class TestPlugin : public QWebPluginFactory
{
public:
explicit TestPlugin(QObject *parent = 0);
virtual ~TestPlugin();
- virtual QStringList keys() const;
+ virtual QList<Plugin> plugins() const;
- virtual QString descriptionForKey(const QString &key) const;
- virtual QStringList mimetypesForKey(const QString &key) const;
- virtual QStringList extensionsForMimetype(const QString &mimeType) const;
- virtual QObject *create(QWebObjectPluginConnector *connector,
+ virtual QObject *create(const QString &mimeType,
const QUrl &url,
- const QString &mimeType,
const QStringList &argumentNames,
const QStringList &argumentValues) const;
+
};
-#endif