summaryrefslogtreecommitdiffstats
path: root/WebKitTools/WebKitTestRunner/TestController.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-08-04 11:41:34 +0100
committerSteve Block <steveblock@google.com>2010-08-09 12:04:44 +0100
commitdb14019a23d96bc8a444b6576a5da8bd1cfbc8b0 (patch)
tree9f793c5b0f5e1f2aca8247158920e2c4bf962bbf /WebKitTools/WebKitTestRunner/TestController.cpp
parentbf916837aa84f1e4b00e6ed6268516c2acd27545 (diff)
downloadexternal_webkit-db14019a23d96bc8a444b6576a5da8bd1cfbc8b0.zip
external_webkit-db14019a23d96bc8a444b6576a5da8bd1cfbc8b0.tar.gz
external_webkit-db14019a23d96bc8a444b6576a5da8bd1cfbc8b0.tar.bz2
Merge WebKit at r64523 : Initial merge by git.
Change-Id: Ibb796c6802e757b1d9b40f58205cfbe4da95fcd4
Diffstat (limited to 'WebKitTools/WebKitTestRunner/TestController.cpp')
-rw-r--r--WebKitTools/WebKitTestRunner/TestController.cpp83
1 files changed, 67 insertions, 16 deletions
diff --git a/WebKitTools/WebKitTestRunner/TestController.cpp b/WebKitTools/WebKitTestRunner/TestController.cpp
index 4f8cd6b..93857a7 100644
--- a/WebKitTools/WebKitTestRunner/TestController.cpp
+++ b/WebKitTools/WebKitTestRunner/TestController.cpp
@@ -28,21 +28,62 @@
#include "PlatformWebView.h"
#include "TestInvocation.h"
#include <WebKit2/WKContextPrivate.h>
+#include <wtf/PassOwnPtr.h>
namespace WTR {
+static TestController* controller;
+
TestController& TestController::shared()
{
- static TestController& shared = *new TestController;
- return shared;
+ ASSERT(controller);
+ return *controller;
}
-TestController::TestController()
+TestController::TestController(int argc, const char* argv[])
: m_dumpPixels(false)
, m_verbose(false)
, m_printSeparators(false)
, m_usingServerMode(false)
{
+ initialize(argc, argv);
+ controller = this;
+ run();
+ controller = 0;
+}
+
+TestController::~TestController()
+{
+}
+
+static void closeOtherPage(WKPageRef page, const void* clientInfo)
+{
+ WKPageClose(page);
+ const PlatformWebView* view = static_cast<const PlatformWebView*>(clientInfo);
+ delete view;
+}
+
+static WKPageRef createOtherPage(WKPageRef oldPage, const void*)
+{
+ PlatformWebView* view = new PlatformWebView(WKPageGetPageNamespace(oldPage));
+ WKPageRef newPage = view->page();
+
+ view->resizeTo(800, 600);
+
+ WKPageUIClient otherPageUIClient = {
+ 0,
+ view,
+ createOtherPage,
+ 0,
+ closeOtherPage,
+ 0,
+ 0,
+ 0
+ };
+ WKPageSetPageUIClient(newPage, &otherPageUIClient);
+
+ WKRetain(newPage);
+ return newPage;
}
void TestController::initialize(int argc, const char* argv[])
@@ -75,21 +116,33 @@ void TestController::initialize(int argc, const char* argv[])
m_printSeparators = m_paths.size() > 1;
initializeInjectedBundlePath();
- initializeTestPluginPath();
+ initializeTestPluginDirectory();
m_context.adopt(WKContextCreateWithInjectedBundlePath(injectedBundlePath()));
- WKContextInjectedBundleClient injectedBundlePathClient = {
+ WKContextInjectedBundleClient injectedBundleClient = {
0,
this,
- _didReceiveMessageFromInjectedBundle
+ didReceiveMessageFromInjectedBundle
};
- WKContextSetInjectedBundleClient(m_context.get(), &injectedBundlePathClient);
+ WKContextSetInjectedBundleClient(m_context.get(), &injectedBundleClient);
- _WKContextSetAdditionalPluginPath(m_context.get(), testPluginPath());
+ _WKContextSetAdditionalPluginsDirectory(m_context.get(), testPluginDirectory());
m_pageNamespace.adopt(WKPageNamespaceCreate(m_context.get()));
- m_mainWebView = new PlatformWebView(m_pageNamespace.get());
+ m_mainWebView = adoptPtr(new PlatformWebView(m_pageNamespace.get()));
+
+ WKPageUIClient pageUIClient = {
+ 0,
+ this,
+ createOtherPage,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0
+ };
+ WKPageSetPageUIClient(m_mainWebView->page(), &pageUIClient);
}
void TestController::runTest(const char* test)
@@ -114,7 +167,7 @@ void TestController::runTestingServerLoop()
}
}
-bool TestController::run()
+void TestController::run()
{
if (m_usingServerMode)
runTestingServerLoop();
@@ -122,18 +175,16 @@ bool TestController::run()
for (size_t i = 0; i < m_paths.size(); ++i)
runTest(m_paths[i].c_str());
}
-
- return true;
}
-void TestController::_didReceiveMessageFromInjectedBundle(WKContextRef context, WKStringRef message, const void *clientInfo)
+void TestController::didReceiveMessageFromInjectedBundle(WKContextRef context, WKStringRef messageName, WKTypeRef messageBody, const void *clientInfo)
{
- static_cast<TestController*>(const_cast<void*>(clientInfo))->didReceiveMessageFromInjectedBundle(message);
+ static_cast<TestController*>(const_cast<void*>(clientInfo))->didReceiveMessageFromInjectedBundle(messageName, messageBody);
}
-void TestController::didReceiveMessageFromInjectedBundle(WKStringRef message)
+void TestController::didReceiveMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody)
{
- m_currentInvocation->didReceiveMessageFromInjectedBundle(message);
+ m_currentInvocation->didReceiveMessageFromInjectedBundle(messageName, messageBody);
}
} // namespace WTR