summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-07 13:21:13 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-07 13:21:13 +0000
commit4f92df8da1fc5ac5db18137a71287d73e39e48a4 (patch)
tree0bf87a58b398e4581234e0a3c1b17fe8ce6dd1ec
parentd9c78637f8e945f0482d5a68568c7e1c2d711996 (diff)
downloadchromium_src-4f92df8da1fc5ac5db18137a71287d73e39e48a4.zip
chromium_src-4f92df8da1fc5ac5db18137a71287d73e39e48a4.tar.gz
chromium_src-4f92df8da1fc5ac5db18137a71287d73e39e48a4.tar.bz2
[content shell] consolidate test configuration into a struct
BUG=171128 R=marja@chromium.org TEST=no functional change Review URL: https://codereview.chromium.org/12612002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186701 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/content_shell.gypi2
-rw-r--r--content/shell/shell_messages.h34
-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.cc2
-rw-r--r--content/shell/webkit_test_runner.cc29
-rw-r--r--content/shell/webkit_test_runner.h10
7 files changed, 84 insertions, 52 deletions
diff --git a/content/content_shell.gypi b/content/content_shell.gypi
index 4d32a21..91a0ee3 100644
--- a/content/content_shell.gypi
+++ b/content/content_shell.gypi
@@ -122,6 +122,8 @@
'shell/shell_resource_dispatcher_host_delegate.h',
'shell/shell_switches.cc',
'shell/shell_switches.h',
+ 'shell/shell_test_configuration.cc',
+ 'shell/shell_test_configuration.h',
'shell/shell_url_request_context_getter.cc',
'shell/shell_url_request_context_getter.h',
'shell/shell_web_contents_view_delegate_android.cc',
diff --git a/content/shell/shell_messages.h b/content/shell/shell_messages.h
index 1f86dac..ebd99e4 100644
--- a/content/shell/shell_messages.h
+++ b/content/shell/shell_messages.h
@@ -7,34 +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()
+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()
// Tells the renderer to reset all test runners.
IPC_MESSAGE_CONTROL0(ShellViewMsg_ResetAll)
@@ -49,7 +37,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_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..e29d407 100644
--- a/content/shell/webkit_test_controller.cc
+++ b/content/shell/webkit_test_controller.cc
@@ -416,7 +416,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..3c670ab 100644
--- a/content/shell/webkit_test_runner.cc
+++ b/content/shell/webkit_test_runner.cc
@@ -81,8 +81,6 @@ namespace content {
namespace {
-int kDefaultLayoutTestTimeoutMs = 30 * 1000;
-
void InvokeTaskHelper(void* context) {
WebTask* task = reinterpret_cast<WebTask*>(context);
task->run();
@@ -162,9 +160,6 @@ 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) {
}
@@ -431,7 +426,7 @@ bool WebKitTestRunner::isBeingDebugged() {
}
int WebKitTestRunner::layoutTestTimeout() {
- return layout_test_timeout_;
+ return test_config_.layout_test_timeout;
}
void WebKitTestRunner::closeRemainingWindows() {
@@ -457,7 +452,7 @@ void WebKitTestRunner::loadURLForFrame(const WebURL& url,
}
bool WebKitTestRunner::allowExternalPages() {
- return allow_external_pages_;
+ return test_config_.allow_external_pages;
}
void WebKitTestRunner::captureHistoryForWindow(
@@ -514,10 +509,6 @@ void WebKitTestRunner::Reset() {
// 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();
@@ -544,7 +535,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 +561,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,13 +575,8 @@ 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;
is_main_window_ = true;
setFocus(proxy_, true);
@@ -598,7 +584,8 @@ void WebKitTestRunner::OnSetTestConfiguration(
WebTestInterfaces* interfaces =
ShellRenderProcessObserver::GetInstance()->test_interfaces();
interfaces->setTestIsRunning(true);
- interfaces->configureForTestWithURL(params.test_url, enable_pixel_dumping_);
+ interfaces->configureForTestWithURL(params.test_url,
+ params.enable_pixel_dumping);
}
void WebKitTestRunner::OnSessionHistory(
diff --git a/content/shell/webkit_test_runner.h b/content/shell/webkit_test_runner.h
index e66f3eb..84e7617 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;
@@ -94,8 +94,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 +113,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_;