summaryrefslogtreecommitdiffstats
path: root/webkit/tools/test_shell
diff options
context:
space:
mode:
authorojan@google.com <ojan@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-30 23:09:37 +0000
committerojan@google.com <ojan@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-30 23:09:37 +0000
commitb9a0b1b39c5bcf551178cab7a2aa5f24d5afc929 (patch)
treed59dbb65ae4d905230a9c3a112f7302fb531096e /webkit/tools/test_shell
parent3c85b8003597b96007ed2e6a98007bb6f3c0ddb2 (diff)
downloadchromium_src-b9a0b1b39c5bcf551178cab7a2aa5f24d5afc929.zip
chromium_src-b9a0b1b39c5bcf551178cab7a2aa5f24d5afc929.tar.gz
chromium_src-b9a0b1b39c5bcf551178cab7a2aa5f24d5afc929.tar.bz2
Enable running webkit tests in parallel and make it use
the number of cpus as the default number of test_shells to spawn. This involved ignoring focus/blur messages and mocking out the clipboard. The test_shell window still sometimes seems to get focus, so there's still a bit more work to do, but the tests seem to all pass. We still default to 1 test_shell at a time. Once I get this committed, I'll try multiple. I just don't want to have to rollback this whole thing. Review URL: http://codereview.chromium.org/56040 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12821 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools/test_shell')
-rw-r--r--webkit/tools/test_shell/SConscript1
-rw-r--r--webkit/tools/test_shell/mac/webwidget_host.mm6
-rw-r--r--webkit/tools/test_shell/mock_webclipboard_impl.cc66
-rw-r--r--webkit/tools/test_shell/mock_webclipboard_impl.h38
-rw-r--r--webkit/tools/test_shell/test_shell.gyp2
-rw-r--r--webkit/tools/test_shell/test_shell.vcproj8
-rw-r--r--webkit/tools/test_shell/test_shell_tests.vcproj8
-rw-r--r--webkit/tools/test_shell/test_shell_webkit_init.h16
-rw-r--r--webkit/tools/test_shell/webwidget_host_gtk.cc11
-rw-r--r--webkit/tools/test_shell/webwidget_host_win.cc6
10 files changed, 158 insertions, 4 deletions
diff --git a/webkit/tools/test_shell/SConscript b/webkit/tools/test_shell/SConscript
index 385c583..afd0b60 100644
--- a/webkit/tools/test_shell/SConscript
+++ b/webkit/tools/test_shell/SConscript
@@ -115,6 +115,7 @@ env_lib.SConscript([
input_files = [
'event_sending_controller.cc',
'layout_test_controller.cc',
+ 'mock_webclipboard_impl.cc',
'simple_resource_loader_bridge.cc',
# This file is only used by test_shell/test_shell_tests. It should
diff --git a/webkit/tools/test_shell/mac/webwidget_host.mm b/webkit/tools/test_shell/mac/webwidget_host.mm
index 41b47b5..f992141 100644
--- a/webkit/tools/test_shell/mac/webwidget_host.mm
+++ b/webkit/tools/test_shell/mac/webwidget_host.mm
@@ -13,6 +13,7 @@
#include "third_party/WebKit/WebKit/chromium/public/mac/WebInputEventFactory.h"
#include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h"
#include "webkit/glue/webwidget.h"
+#include "webkit/tools/test_shell/test_shell.h"
using WebKit::WebInputEvent;
using WebKit::WebInputEventFactory;
@@ -248,7 +249,10 @@ void WebWidgetHost::KeyEvent(NSEvent *event) {
}
void WebWidgetHost::SetFocus(bool enable) {
- webwidget_->SetFocus(enable);
+ // Ignore focus calls in layout test mode so that tests don't mess with each
+ // other's focus when running in parallel.
+ if (!TestShell::layout_test_mode())
+ webwidget_->SetFocus(enable);
}
void WebWidgetHost::TrackMouseLeave(bool track) {
diff --git a/webkit/tools/test_shell/mock_webclipboard_impl.cc b/webkit/tools/test_shell/mock_webclipboard_impl.cc
new file mode 100644
index 0000000..305eabf
--- /dev/null
+++ b/webkit/tools/test_shell/mock_webclipboard_impl.cc
@@ -0,0 +1,66 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
+// source code is governed by a BSD-style license that can be found in the
+// LICENSE file.
+
+#include "webkit/tools/test_shell/mock_webclipboard_impl.h"
+
+#include "base/clipboard.h"
+#include "base/logging.h"
+#include "base/string_util.h"
+#include "net/base/escape.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebImage.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebURL.h"
+#include "webkit/glue/webclipboard_impl.h"
+#include "webkit/glue/webkit_glue.h"
+
+using WebKit::WebString;
+using WebKit::WebURL;
+
+bool MockWebClipboardImpl::isFormatAvailable(Format format) {
+ switch (format) {
+ case FormatHTML:
+ return !m_htmlText.isEmpty();
+
+ case FormatSmartPaste:
+ return m_writeSmartPaste;
+
+ default:
+ NOTREACHED();
+ return false;
+ }
+ return true;
+}
+
+WebKit::WebString MockWebClipboardImpl::readPlainText() {
+ return m_plainText;
+}
+
+WebKit::WebString MockWebClipboardImpl::readHTML(WebKit::WebURL* url) {
+ return m_htmlText;
+}
+
+void MockWebClipboardImpl::writeHTML(
+ const WebKit::WebString& htmlText, const WebKit::WebURL& url,
+ const WebKit::WebString& plainText, bool writeSmartPaste) {
+ m_htmlText = htmlText;
+ m_plainText = plainText;
+ m_writeSmartPaste = writeSmartPaste;
+}
+
+void MockWebClipboardImpl::writeURL(
+ const WebKit::WebURL& url, const WebKit::WebString& title) {
+ m_htmlText = UTF8ToUTF16(
+ webkit_glue::WebClipboardImpl::URLToMarkup(url, title));
+ m_plainText = UTF8ToUTF16(url.spec());
+ m_writeSmartPaste = false;
+}
+
+void MockWebClipboardImpl::writeImage(const WebKit::WebImage& image,
+ const WebKit::WebURL& url, const WebKit::WebString& title) {
+ if (!image.isNull()) {
+ m_htmlText = UTF8ToUTF16(
+ webkit_glue::WebClipboardImpl::URLToImageMarkup(url, title));
+ m_plainText = m_htmlText;
+ m_writeSmartPaste = false;
+ }
+}
diff --git a/webkit/tools/test_shell/mock_webclipboard_impl.h b/webkit/tools/test_shell/mock_webclipboard_impl.h
new file mode 100644
index 0000000..6420244
--- /dev/null
+++ b/webkit/tools/test_shell/mock_webclipboard_impl.h
@@ -0,0 +1,38 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
+// source code is governed by a BSD-style license that can be found in the
+// LICENSE file.
+//
+// This file mocks out just enough of the WebClipboard API for running the
+// webkit tests. This is so we can run webkit tests without them sharing a
+// clipboard, which allows for running them in parallel and having the tests
+// not interact with actual user actions.
+
+#ifndef WEBKIT_TOOLS_TEST_SHELL_MOCK_WEBCLIPBOARD_IMPL_H_
+#define WEBKIT_TOOLS_TEST_SHELL_MOCK_WEBCLIPBOARD_IMPL_H_
+
+#include "third_party/WebKit/WebKit/chromium/public/WebClipboard.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
+
+class MockWebClipboardImpl : public WebKit::WebClipboard {
+ public:
+ virtual bool isFormatAvailable(WebKit::WebClipboard::Format);
+
+ virtual WebKit::WebString readPlainText();
+ virtual WebKit::WebString readHTML(WebKit::WebURL*);
+
+ virtual void writeHTML(
+ const WebKit::WebString& htmlText, const WebKit::WebURL&,
+ const WebKit::WebString& plainText, bool writeSmartPaste);
+ virtual void writeURL(
+ const WebKit::WebURL&, const WebKit::WebString& title);
+ virtual void writeImage(
+ const WebKit::WebImage&, const WebKit::WebURL&,
+ const WebKit::WebString& title);
+
+ private:
+ WebKit::WebString m_plainText;
+ WebKit::WebString m_htmlText;
+ bool m_writeSmartPaste;
+};
+
+#endif // WEBKIT_TOOLS_TEST_SHELL_MOCK_WEBCLIPBOARD_IMPL_H_
diff --git a/webkit/tools/test_shell/test_shell.gyp b/webkit/tools/test_shell/test_shell.gyp
index 5c3094f..e6f3a1e 100644
--- a/webkit/tools/test_shell/test_shell.gyp
+++ b/webkit/tools/test_shell/test_shell.gyp
@@ -40,6 +40,8 @@
'foreground_helper.h',
'layout_test_controller.cc',
'layout_test_controller.h',
+ 'mock_webclipboard_impl.cc',
+ 'mock_webclipboard_impl.h',
'resource.h',
'simple_resource_loader_bridge.cc',
'simple_resource_loader_bridge.h',
diff --git a/webkit/tools/test_shell/test_shell.vcproj b/webkit/tools/test_shell/test_shell.vcproj
index 8ced6eb..b4d6410 100644
--- a/webkit/tools/test_shell/test_shell.vcproj
+++ b/webkit/tools/test_shell/test_shell.vcproj
@@ -242,6 +242,14 @@
>
</File>
<File
+ RelativePath=".\mock_webclipboard_impl.cc"
+ >
+ </File>
+ <File
+ RelativePath=".\mock_webclipboard_impl.h"
+ >
+ </File>
+ <File
RelativePath="..\..\glue\simple_clipboard_impl.cc"
>
</File>
diff --git a/webkit/tools/test_shell/test_shell_tests.vcproj b/webkit/tools/test_shell/test_shell_tests.vcproj
index ac9db53..4311ba6 100644
--- a/webkit/tools/test_shell/test_shell_tests.vcproj
+++ b/webkit/tools/test_shell/test_shell_tests.vcproj
@@ -183,6 +183,14 @@
>
</File>
<File
+ RelativePath=".\mock_webclipboard_impl.cc"
+ >
+ </File>
+ <File
+ RelativePath=".\mock_webclipboard_impl.h"
+ >
+ </File>
+ <File
RelativePath="$(OutDir)\obj\global_intermediate\net\net_resources.rc"
>
</File>
diff --git a/webkit/tools/test_shell/test_shell_webkit_init.h b/webkit/tools/test_shell/test_shell_webkit_init.h
index b0ae2d2..6a87100 100644
--- a/webkit/tools/test_shell/test_shell_webkit_init.h
+++ b/webkit/tools/test_shell/test_shell_webkit_init.h
@@ -11,10 +11,12 @@
#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
#include "third_party/WebKit/WebKit/chromium/public/WebURL.h"
#include "webkit/glue/simple_webmimeregistry_impl.h"
+#include "webkit/glue/webclipboard_impl.h"
#include "webkit/glue/webkit_glue.h"
#include "webkit/glue/webkitclient_impl.h"
#include "webkit/extensions/v8/gears_extension.h"
#include "webkit/extensions/v8/interval_extension.h"
+#include "webkit/tools/test_shell/mock_webclipboard_impl.h"
#include "webkit/tools/test_shell/simple_resource_loader_bridge.h"
#include "v8/include/v8.h"
@@ -40,6 +42,19 @@ class TestShellWebKitInit : public webkit_glue::WebKitClientImpl {
virtual WebKit::WebMimeRegistry* mimeRegistry() {
return &mime_registry_;
}
+
+ WebKit::WebClipboard* clipboard() {
+ if (!clipboard_.get()) {
+ // Mock out clipboard calls in layout test mode so that tests don't mess
+ // with each other's copies/pastes when running in parallel.
+ if (TestShell::layout_test_mode()) {
+ clipboard_.reset(new MockWebClipboardImpl());
+ } else {
+ clipboard_.reset(new webkit_glue::WebClipboardImpl());
+ }
+ }
+ return clipboard_.get();
+ }
virtual WebKit::WebSandboxSupport* sandboxSupport() {
return NULL;
@@ -93,6 +108,7 @@ class TestShellWebKitInit : public webkit_glue::WebKitClientImpl {
private:
webkit_glue::SimpleWebMimeRegistryImpl mime_registry_;
+ scoped_ptr<WebKit::WebClipboard> clipboard_;
};
#endif // WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_WEBKIT_INIT_H_
diff --git a/webkit/tools/test_shell/webwidget_host_gtk.cc b/webkit/tools/test_shell/webwidget_host_gtk.cc
index 90194c5..599d580 100644
--- a/webkit/tools/test_shell/webwidget_host_gtk.cc
+++ b/webkit/tools/test_shell/webwidget_host_gtk.cc
@@ -15,6 +15,7 @@
#include "third_party/WebKit/WebKit/chromium/public/gtk/WebInputEventFactory.h"
#include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h"
#include "webkit/glue/webwidget.h"
+#include "webkit/tools/test_shell/test_shell.h"
using WebKit::WebInputEventFactory;
using WebKit::WebKeyboardEvent;
@@ -178,7 +179,10 @@ class WebWidgetHostGtkWidget {
static gboolean HandleFocusIn(GtkWidget* widget,
GdkEventFocus* focus,
WebWidgetHost* host) {
- host->webwidget()->SetFocus(true);
+ // Ignore focus calls in layout test mode so that tests don't mess with each
+ // other's focus when running in parallel.
+ if (!TestShell::layout_test_mode())
+ host->webwidget()->SetFocus(true);
return FALSE;
}
@@ -186,7 +190,10 @@ class WebWidgetHostGtkWidget {
static gboolean HandleFocusOut(GtkWidget* widget,
GdkEventFocus* focus,
WebWidgetHost* host) {
- host->webwidget()->SetFocus(false);
+ // Ignore focus calls in layout test mode so that tests don't mess with each
+ // other's focus when running in parallel.
+ if (!TestShell::layout_test_mode())
+ host->webwidget()->SetFocus(false);
return FALSE;
}
diff --git a/webkit/tools/test_shell/webwidget_host_win.cc b/webkit/tools/test_shell/webwidget_host_win.cc
index 76a5973..8ea5ca0 100644
--- a/webkit/tools/test_shell/webwidget_host_win.cc
+++ b/webkit/tools/test_shell/webwidget_host_win.cc
@@ -12,6 +12,7 @@
#include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h"
#include "third_party/WebKit/WebKit/chromium/public/win/WebInputEventFactory.h"
#include "webkit/glue/webwidget.h"
+#include "webkit/tools/test_shell/test_shell.h"
using WebKit::WebInputEvent;
using WebKit::WebInputEventFactory;
@@ -322,7 +323,10 @@ void WebWidgetHost::CaptureLostEvent() {
}
void WebWidgetHost::SetFocus(bool enable) {
- webwidget_->SetFocus(enable);
+ // Ignore focus calls in layout test mode so that tests don't mess with each
+ // other's focus when running in parallel.
+ if (!TestShell::layout_test_mode())
+ webwidget_->SetFocus(enable);
}
void WebWidgetHost::TrackMouseLeave(bool track) {