summaryrefslogtreecommitdiffstats
path: root/content/shell
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-07 08:44:26 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-07 08:44:26 +0000
commit0bfe175a16a50b9a38e4fbcd23737a54544872a3 (patch)
treef09915ef08246ac013fa3bbcdafd1df049c5abfe /content/shell
parentf53da3970187a0ac5592b849ea44c5e2e8a0470b (diff)
downloadchromium_src-0bfe175a16a50b9a38e4fbcd23737a54544872a3.zip
chromium_src-0bfe175a16a50b9a38e4fbcd23737a54544872a3.tar.gz
chromium_src-0bfe175a16a50b9a38e4fbcd23737a54544872a3.tar.bz2
[content shell] eliminate the pause between reset and starting a new test
When receiving the configuration for the next test, we don't immediately set the config but wait for the render view to navigate to the next test. Only then, reset all test interfaces, and apply the new config BUG=171128 R=marja@chromium.org Review URL: https://codereview.chromium.org/12597002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186654 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/shell')
-rw-r--r--content/shell/shell_messages.h37
-rw-r--r--content/shell/shell_render_process_observer.cc25
-rw-r--r--content/shell/shell_render_process_observer.h5
-rw-r--r--content/shell/shell_test_configuration.cc16
-rw-r--r--content/shell/shell_test_configuration.h43
-rw-r--r--content/shell/webkit_test_controller.cc3
-rw-r--r--content/shell/webkit_test_runner.cc70
-rw-r--r--content/shell/webkit_test_runner.h15
8 files changed, 119 insertions, 95 deletions
diff --git a/content/shell/shell_messages.h b/content/shell/shell_messages.h
index 1f86dac..d725d70 100644
--- a/content/shell/shell_messages.h
+++ b/content/shell/shell_messages.h
@@ -7,37 +7,22 @@
#include <vector>
#include "content/public/common/common_param_traits.h"
+#include "content/shell/shell_test_configuration.h"
#include "ipc/ipc_message_macros.h"
#include "ipc/ipc_platform_file.h"
#include "third_party/skia/include/core/SkBitmap.h"
#define IPC_MESSAGE_START ShellMsgStart
-IPC_STRUCT_BEGIN(ShellViewMsg_SetTestConfiguration_Params)
- // The current working directory.
- IPC_STRUCT_MEMBER(base::FilePath, current_working_directory)
-
- // The temporary directory of the system.
- IPC_STRUCT_MEMBER(base::FilePath, temp_path)
-
- // The URL of the current layout test.
- IPC_STRUCT_MEMBER(GURL, test_url)
-
- // True if pixel tests are enabled.
- IPC_STRUCT_MEMBER(bool, enable_pixel_dumping)
-
- // The layout test timeout in milliseconds.
- IPC_STRUCT_MEMBER(int, layout_test_timeout)
-
- // True if tests can open external URLs
- IPC_STRUCT_MEMBER(bool, allow_external_pages)
-
- // The expected MD5 hash of the pixel results.
- IPC_STRUCT_MEMBER(std::string, expected_pixel_hash)
-IPC_STRUCT_END()
-
-// Tells the renderer to reset all test runners.
-IPC_MESSAGE_CONTROL0(ShellViewMsg_ResetAll)
+IPC_STRUCT_TRAITS_BEGIN(content::ShellTestConfiguration)
+IPC_STRUCT_TRAITS_MEMBER(current_working_directory)
+IPC_STRUCT_TRAITS_MEMBER(temp_path)
+IPC_STRUCT_TRAITS_MEMBER(test_url)
+IPC_STRUCT_TRAITS_MEMBER(enable_pixel_dumping)
+IPC_STRUCT_TRAITS_MEMBER(layout_test_timeout)
+IPC_STRUCT_TRAITS_MEMBER(allow_external_pages)
+IPC_STRUCT_TRAITS_MEMBER(expected_pixel_hash)
+IPC_STRUCT_TRAITS_END()
// Sets the path to the WebKit checkout.
IPC_MESSAGE_CONTROL1(ShellViewMsg_SetWebKitSourceDir,
@@ -49,7 +34,7 @@ IPC_MESSAGE_CONTROL1(ShellViewMsg_LoadHyphenDictionary,
// Sets the initial configuration to use for layout tests.
IPC_MESSAGE_ROUTED1(ShellViewMsg_SetTestConfiguration,
- ShellViewMsg_SetTestConfiguration_Params)
+ content::ShellTestConfiguration)
// Pushes a snapshot of the current session history from the browser process.
// This includes only information about those RenderViews that are in the
diff --git a/content/shell/shell_render_process_observer.cc b/content/shell/shell_render_process_observer.cc
index 4692f83..1ea8471 100644
--- a/content/shell/shell_render_process_observer.cc
+++ b/content/shell/shell_render_process_observer.cc
@@ -14,15 +14,11 @@
#include "content/shell/shell_switches.h"
#include "content/shell/webkit_test_runner.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebTestingSupport.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
#include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestInterfaces.h"
#include "webkit/glue/webkit_glue.h"
#include "webkit/support/gc_extension.h"
-using WebKit::WebFrame;
using WebKit::WebRuntimeFeatures;
-using WebKit::WebTestingSupport;
using WebTestRunner::WebTestDelegate;
using WebTestRunner::WebTestInterfaces;
@@ -38,9 +34,7 @@ ShellRenderProcessObserver* ShellRenderProcessObserver::GetInstance() {
}
ShellRenderProcessObserver::ShellRenderProcessObserver()
- : main_render_view_(NULL),
- main_test_runner_(NULL),
- test_delegate_(NULL) {
+ : test_delegate_(NULL) {
CHECK(!g_instance);
g_instance = this;
RenderThread::Get()->AddObserver(this);
@@ -70,13 +64,6 @@ void ShellRenderProcessObserver::SetTestDelegate(WebTestDelegate* delegate) {
void ShellRenderProcessObserver::SetMainWindow(RenderView* view) {
WebKitTestRunner* test_runner = WebKitTestRunner::Get(view);
test_interfaces_->setWebView(view->GetWebView(), test_runner->proxy());
- main_render_view_ = view;
- main_test_runner_ = test_runner;
-}
-
-void ShellRenderProcessObserver::BindTestRunnersToWindow(WebFrame* frame) {
- WebTestingSupport::injectInternalsObject(frame);
- test_interfaces_->bindTo(frame);
}
void ShellRenderProcessObserver::WebKitInitialized() {
@@ -95,7 +82,6 @@ bool ShellRenderProcessObserver::OnControlMessageReceived(
const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(ShellRenderProcessObserver, message)
- IPC_MESSAGE_HANDLER(ShellViewMsg_ResetAll, OnResetAll)
IPC_MESSAGE_HANDLER(ShellViewMsg_SetWebKitSourceDir, OnSetWebKitSourceDir)
IPC_MESSAGE_HANDLER(ShellViewMsg_LoadHyphenDictionary,
OnLoadHyphenDictionary)
@@ -105,15 +91,6 @@ bool ShellRenderProcessObserver::OnControlMessageReceived(
return handled;
}
-void ShellRenderProcessObserver::OnResetAll() {
- test_interfaces_->resetAll();
- if (main_render_view_) {
- main_test_runner_->Reset();
- WebTestingSupport::resetInternalsObject(
- main_render_view_->GetWebView()->mainFrame());
- }
-}
-
void ShellRenderProcessObserver::OnSetWebKitSourceDir(
const base::FilePath& webkit_source_dir) {
webkit_source_dir_ = webkit_source_dir;
diff --git a/content/shell/shell_render_process_observer.h b/content/shell/shell_render_process_observer.h
index 8c8a34d..f86c068 100644
--- a/content/shell/shell_render_process_observer.h
+++ b/content/shell/shell_render_process_observer.h
@@ -35,7 +35,6 @@ class ShellRenderProcessObserver : public RenderProcessObserver {
void SetTestDelegate(WebTestRunner::WebTestDelegate* delegate);
void SetMainWindow(RenderView* view);
- void BindTestRunnersToWindow(WebKit::WebFrame* frame);
// RenderProcessObserver implementation.
virtual void WebKitInitialized() OVERRIDE;
@@ -47,17 +46,13 @@ class ShellRenderProcessObserver : public RenderProcessObserver {
WebTestRunner::WebTestInterfaces* test_interfaces() const {
return test_interfaces_.get();
}
- WebKitTestRunner* main_test_runner() const { return main_test_runner_; }
const base::FilePath& webkit_source_dir() const { return webkit_source_dir_; }
private:
// Message handlers.
- void OnResetAll();
void OnSetWebKitSourceDir(const base::FilePath& webkit_source_dir);
void OnLoadHyphenDictionary(const IPC::PlatformFileForTransit& dict_file);
- RenderView* main_render_view_;
- WebKitTestRunner* main_test_runner_;
WebTestRunner::WebTestDelegate* test_delegate_;
scoped_ptr<WebTestRunner::WebTestInterfaces> test_interfaces_;
diff --git a/content/shell/shell_test_configuration.cc b/content/shell/shell_test_configuration.cc
new file mode 100644
index 0000000..6caff2e
--- /dev/null
+++ b/content/shell/shell_test_configuration.cc
@@ -0,0 +1,16 @@
+// Copyright (c) 2013 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 "content/shell/shell_test_configuration.h"
+
+namespace content {
+
+ShellTestConfiguration::ShellTestConfiguration()
+ : enable_pixel_dumping(true),
+ layout_test_timeout(30 * 1000),
+ allow_external_pages(false) {}
+
+ShellTestConfiguration::~ShellTestConfiguration() {}
+
+} // namespace content
diff --git a/content/shell/shell_test_configuration.h b/content/shell/shell_test_configuration.h
new file mode 100644
index 0000000..d47211f
--- /dev/null
+++ b/content/shell/shell_test_configuration.h
@@ -0,0 +1,43 @@
+// Copyright (c) 2013 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.
+
+#ifndef CONTENT_SHELL_SHELL_TEST_CONFIGURATION_H_
+#define CONTENT_SHELL_SHELL_TEST_CONFIGURATION_H_
+
+#include <string>
+
+#include "base/files/file_path.h"
+#include "googleurl/src/gurl.h"
+
+namespace content {
+
+struct ShellTestConfiguration {
+ ShellTestConfiguration();
+ ~ShellTestConfiguration();
+
+ // The current working directory.
+ base::FilePath current_working_directory;
+
+ // The temporary directory of the system.
+ base::FilePath temp_path;
+
+ // The URL of the current layout test.
+ GURL test_url;
+
+ // True if pixel tests are enabled.
+ bool enable_pixel_dumping;
+
+ // The layout test timeout in milliseconds.
+ int layout_test_timeout;
+
+ // True if tests can open external URLs
+ bool allow_external_pages;
+
+ // The expected MD5 hash of the pixel results.
+ std::string expected_pixel_hash;
+};
+
+} // namespace content
+
+#endif // CONTENT_SHELL_SHELL_TEST_CONFIGURATION_H_
diff --git a/content/shell/webkit_test_controller.cc b/content/shell/webkit_test_controller.cc
index 1a5acb5..f6a2b51 100644
--- a/content/shell/webkit_test_controller.cc
+++ b/content/shell/webkit_test_controller.cc
@@ -264,7 +264,6 @@ bool WebKitTestController::ResetAfterLayoutTest() {
prefs_ = webkit_glue::WebPreferences();
should_override_prefs_ = false;
watchdog_.Cancel();
- Send(new ShellViewMsg_ResetAll);
return true;
}
@@ -416,7 +415,7 @@ void WebKitTestController::DiscardMainWindow() {
void WebKitTestController::SendTestConfiguration() {
RenderViewHost* render_view_host =
main_window_->web_contents()->GetRenderViewHost();
- ShellViewMsg_SetTestConfiguration_Params params;
+ ShellTestConfiguration params;
params.current_working_directory = current_working_directory_;
params.temp_path = temp_path_;
params.test_url = test_url_;
diff --git a/content/shell/webkit_test_runner.cc b/content/shell/webkit_test_runner.cc
index fc662bb..f63b20f 100644
--- a/content/shell/webkit_test_runner.cc
+++ b/content/shell/webkit_test_runner.cc
@@ -45,6 +45,7 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebTestingSupport.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
#include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/WebTask.h"
#include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestInterfaces.h"
@@ -68,6 +69,7 @@ using WebKit::WebHistoryItem;
using WebKit::WebRect;
using WebKit::WebSize;
using WebKit::WebString;
+using WebKit::WebTestingSupport;
using WebKit::WebURL;
using WebKit::WebURLError;
using WebKit::WebVector;
@@ -81,8 +83,6 @@ namespace content {
namespace {
-int kDefaultLayoutTestTimeoutMs = 30 * 1000;
-
void InvokeTaskHelper(void* context) {
WebTask* task = reinterpret_cast<WebTask*>(context);
task->run();
@@ -162,10 +162,9 @@ WebKitTestRunner::WebKitTestRunner(RenderView* render_view)
RenderViewObserverTracker<WebKitTestRunner>(render_view),
proxy_(NULL),
focused_view_(NULL),
- enable_pixel_dumping_(true),
- layout_test_timeout_(kDefaultLayoutTestTimeoutMs),
- allow_external_pages_(false),
- is_main_window_(false) {
+ is_main_window_(false),
+ reset_on_next_navigation_(false),
+ test_is_running_(false) {
}
WebKitTestRunner::~WebKitTestRunner() {
@@ -403,11 +402,12 @@ void WebKitTestRunner::setLocale(const std::string& locale) {
}
void WebKitTestRunner::testFinished() {
- if (!is_main_window_)
+ if (!is_main_window_ || !test_is_running_)
return;
WebTestInterfaces* interfaces =
ShellRenderProcessObserver::GetInstance()->test_interfaces();
interfaces->setTestIsRunning(false);
+ test_is_running_ = false;
if (interfaces->testRunner()->shouldDumpBackForwardList()) {
SyncNavigationStateVisitor visitor;
RenderView::ForEach(&visitor);
@@ -418,11 +418,12 @@ void WebKitTestRunner::testFinished() {
}
void WebKitTestRunner::testTimedOut() {
- if (!is_main_window_)
+ if (!is_main_window_ || !test_is_running_)
return;
WebTestInterfaces* interfaces =
ShellRenderProcessObserver::GetInstance()->test_interfaces();
interfaces->setTestIsRunning(false);
+ test_is_running_ = false;
Send(new ShellViewHostMsg_TestFinished(routing_id(), true));
}
@@ -431,7 +432,7 @@ bool WebKitTestRunner::isBeingDebugged() {
}
int WebKitTestRunner::layoutTestTimeout() {
- return layout_test_timeout_;
+ return test_config_.layout_test_timeout;
}
void WebKitTestRunner::closeRemainingWindows() {
@@ -457,7 +458,7 @@ void WebKitTestRunner::loadURLForFrame(const WebURL& url,
}
bool WebKitTestRunner::allowExternalPages() {
- return allow_external_pages_;
+ return test_config_.allow_external_pages;
}
void WebKitTestRunner::captureHistoryForWindow(
@@ -493,7 +494,8 @@ void WebKitTestRunner::captureHistoryForWindow(
// RenderViewObserver --------------------------------------------------------
void WebKitTestRunner::DidClearWindowObject(WebFrame* frame) {
- ShellRenderProcessObserver::GetInstance()->BindTestRunnersToWindow(frame);
+ WebTestingSupport::injectInternalsObject(frame);
+ ShellRenderProcessObserver::GetInstance()->test_interfaces()->bindTo(frame);
}
bool WebKitTestRunner::OnMessageReceived(const IPC::Message& message) {
@@ -508,19 +510,36 @@ bool WebKitTestRunner::OnMessageReceived(const IPC::Message& message) {
return handled;
}
+void WebKitTestRunner::Navigate(const GURL& url) {
+ if (!reset_on_next_navigation_)
+ return;
+
+ reset_on_next_navigation_ = false;
+ Reset();
+
+ WebTestInterfaces* interfaces =
+ ShellRenderProcessObserver::GetInstance()->test_interfaces();
+ interfaces->configureForTestWithURL(test_config_.test_url,
+ test_config_.enable_pixel_dumping);
+ interfaces->setTestIsRunning(true);
+ test_is_running_ = true;
+}
+
// Public methods - -----------------------------------------------------------
void WebKitTestRunner::Reset() {
+ ShellRenderProcessObserver::GetInstance()->test_interfaces()->resetAll();
// The proxy_ is always non-NULL, it is set right after construction.
proxy_->reset();
prefs_.reset();
- enable_pixel_dumping_ = true;
- layout_test_timeout_ = kDefaultLayoutTestTimeoutMs;
- allow_external_pages_ = false;
- expected_pixel_hash_ = std::string();
routing_ids_.clear();
session_histories_.clear();
current_entry_indexes_.clear();
+ // This overrides the WebPreferences, so we have to reset them again.
+ WebTestingSupport::resetInternalsObject(
+ render_view()->GetWebView()->mainFrame());
+ render_view()->SetWebkitPreferences(render_view()->GetWebkitPreferences());
+ setFocus(proxy_, true);
}
// Private methods -----------------------------------------------------------
@@ -544,7 +563,7 @@ void WebKitTestRunner::CaptureDump() {
Send(
new ShellViewHostMsg_TextDump(routing_id(), proxy()->captureTree(false)));
- if (enable_pixel_dumping_ &&
+ if (test_config_.enable_pixel_dumping &&
interfaces->testRunner()->shouldGeneratePixelResults()) {
SkBitmap snapshot;
CopyCanvasToBitmap(proxy()->capturePixels(), &snapshot);
@@ -570,7 +589,7 @@ void WebKitTestRunner::CaptureDump() {
#endif
std::string actual_pixel_hash = base::MD5DigestToBase16(digest);
- if (actual_pixel_hash == expected_pixel_hash_) {
+ if (actual_pixel_hash == test_config_.expected_pixel_hash) {
SkBitmap empty_image;
Send(new ShellViewHostMsg_ImageDump(
routing_id(), actual_pixel_hash, empty_image));
@@ -584,21 +603,10 @@ void WebKitTestRunner::CaptureDump() {
}
void WebKitTestRunner::OnSetTestConfiguration(
- const ShellViewMsg_SetTestConfiguration_Params& params) {
- current_working_directory_ = params.current_working_directory;
- temp_path_ = params.temp_path;
- enable_pixel_dumping_ = params.enable_pixel_dumping;
- layout_test_timeout_ = params.layout_test_timeout;
- allow_external_pages_ = params.allow_external_pages;
- expected_pixel_hash_ = params.expected_pixel_hash;
+ const ShellTestConfiguration& params) {
+ test_config_ = params;
+ reset_on_next_navigation_ = true;
is_main_window_ = true;
-
- setFocus(proxy_, true);
-
- WebTestInterfaces* interfaces =
- ShellRenderProcessObserver::GetInstance()->test_interfaces();
- interfaces->setTestIsRunning(true);
- interfaces->configureForTestWithURL(params.test_url, enable_pixel_dumping_);
}
void WebKitTestRunner::OnSessionHistory(
diff --git a/content/shell/webkit_test_runner.h b/content/shell/webkit_test_runner.h
index e66f3eb..84adb5f 100644
--- a/content/shell/webkit_test_runner.h
+++ b/content/shell/webkit_test_runner.h
@@ -11,12 +11,12 @@
#include "base/memory/scoped_ptr.h"
#include "content/public/renderer/render_view_observer.h"
#include "content/public/renderer/render_view_observer_tracker.h"
+#include "content/shell/shell_test_configuration.h"
#include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/WebPreferences.h"
#include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h"
#include "v8/include/v8.h"
class SkCanvas;
-struct ShellViewMsg_SetTestConfiguration_Params;
namespace WebKit {
struct WebRect;
@@ -39,6 +39,7 @@ class WebKitTestRunner : public RenderViewObserver,
// RenderViewObserver implementation.
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
virtual void DidClearWindowObject(WebKit::WebFrame* frame) OVERRIDE;
+ virtual void Navigate(const GURL& url) OVERRIDE;
// WebTestDelegate implementation.
virtual void clearEditCommand();
@@ -94,8 +95,7 @@ class WebKitTestRunner : public RenderViewObserver,
private:
// Message handlers.
- void OnSetTestConfiguration(
- const ShellViewMsg_SetTestConfiguration_Params& params);
+ void OnSetTestConfiguration(const ShellTestConfiguration& params);
void OnSessionHistory(
const std::vector<int>& routing_ids,
const std::vector<std::vector<std::string> >& session_histories,
@@ -114,10 +114,7 @@ class WebKitTestRunner : public RenderViewObserver,
::WebTestRunner::WebPreferences prefs_;
- bool enable_pixel_dumping_;
- int layout_test_timeout_;
- bool allow_external_pages_;
- std::string expected_pixel_hash_;
+ ShellTestConfiguration test_config_;
std::vector<int> routing_ids_;
std::vector<std::vector<std::string> > session_histories_;
@@ -125,6 +122,10 @@ class WebKitTestRunner : public RenderViewObserver,
bool is_main_window_;
+ bool reset_on_next_navigation_;
+
+ bool test_is_running_;
+
DISALLOW_COPY_AND_ASSIGN(WebKitTestRunner);
};