Commit 746754c5 authored by jochen's avatar jochen Committed by Commit bot

Turn test runner library into an actual component

The main motivation is to enforce correct layering and dependencies

BUG=478250
R=jam@chromium.org

Review URL: https://codereview.chromium.org/1169493003

Cr-Commit-Position: refs/heads/master@{#333065}
parent c9fc4811
......@@ -8,8 +8,11 @@ if (is_android) {
import("//build/config/android/config.gni")
}
static_library("test_runner") {
component("test_runner") {
testonly = true
defines = [ "TEST_RUNNER_IMPLEMENTATION" ]
sources = [
"accessibility_controller.cc",
"accessibility_controller.h",
......@@ -61,6 +64,7 @@ static_library("test_runner") {
"test_preferences.h",
"test_runner.cc",
"test_runner.h",
"test_runner_export.h",
"text_input_controller.cc",
"text_input_controller.h",
"web_ax_object_proxy.cc",
......@@ -84,14 +88,16 @@ static_library("test_runner") {
deps = [
":resources",
"//base",
"//base:base_static",
"//cc",
"//gin",
"//gpu",
"//skia",
"//third_party/WebKit/public:blink",
"//ui/events:dom_keycode_converter",
"//ui/events:events_base",
"//ui/gfx",
"//ui/gfx/geometry",
"//url",
"//v8",
#'copy_test_netscape_plugin', TODO(GYP)
......
......@@ -5,14 +5,17 @@
#ifndef COMPONENTS_TEST_RUNNER_APP_BANNER_CLIENT_H_
#define COMPONENTS_TEST_RUNNER_APP_BANNER_CLIENT_H_
#include "base/compiler_specific.h"
#include "base/id_map.h"
#include "components/test_runner/test_runner_export.h"
#include "third_party/WebKit/public/platform/modules/app_banner/WebAppBannerClient.h"
namespace test_runner {
// Test app banner client that holds on to callbacks and allows the test runner
// to resolve them.
class AppBannerClient : public blink::WebAppBannerClient {
class TEST_RUNNER_EXPORT AppBannerClient
: public NON_EXPORTED_BASE(blink::WebAppBannerClient) {
public:
AppBannerClient();
virtual ~AppBannerClient();
......
......@@ -8,6 +8,7 @@
#include <map>
#include "base/memory/weak_ptr.h"
#include "components/test_runner/test_runner_export.h"
#include "third_party/WebKit/public/platform/WebGamepads.h"
namespace blink {
......@@ -19,7 +20,8 @@ namespace test_runner {
class WebTestDelegate;
class GamepadController : public base::SupportsWeakPtr<GamepadController> {
class TEST_RUNNER_EXPORT GamepadController
: public base::SupportsWeakPtr<GamepadController> {
public:
static base::WeakPtr<GamepadController> Create(WebTestDelegate* delegate);
~GamepadController();
......
......@@ -5,7 +5,9 @@
#ifndef COMPONENTS_TEST_RUNNER_MOCK_SCREEN_ORIENTATION_CLIENT_H_
#define COMPONENTS_TEST_RUNNER_MOCK_SCREEN_ORIENTATION_CLIENT_H_
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "components/test_runner/test_runner_export.h"
#include "third_party/WebKit/public/platform/WebLockOrientationCallback.h"
#include "third_party/WebKit/public/platform/WebScreenOrientationClient.h"
#include "third_party/WebKit/public/platform/WebScreenOrientationLockType.h"
......@@ -17,7 +19,8 @@ class WebLocalFrame;
namespace test_runner {
class MockScreenOrientationClient : public blink::WebScreenOrientationClient {
class TEST_RUNNER_EXPORT MockScreenOrientationClient
: public NON_EXPORTED_BASE(blink::WebScreenOrientationClient) {
public:
explicit MockScreenOrientationClient();
virtual ~MockScreenOrientationClient();
......
......@@ -7,6 +7,8 @@
#include <string>
#include "components/test_runner/test_runner_export.h"
namespace test_runner {
inline bool IsASCIIAlpha(char ch) {
......@@ -17,7 +19,7 @@ inline bool IsNotASCIIAlpha(char ch) {
return !IsASCIIAlpha(ch);
}
std::string NormalizeLayoutTestURL(const std::string& url);
TEST_RUNNER_EXPORT std::string NormalizeLayoutTestURL(const std::string& url);
} // namespace test_runner
......
......@@ -5,6 +5,7 @@
#ifndef COMPONENTS_TEST_RUNNER_TEST_PREFERENCES_H_
#define COMPONENTS_TEST_RUNNER_TEST_PREFERENCES_H_
#include "components/test_runner/test_runner_export.h"
#include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/WebKit/public/platform/WebURL.h"
#include "third_party/WebKit/public/web/WebSettings.h"
......@@ -15,7 +16,7 @@ class WebView;
namespace test_runner {
struct TestPreferences {
struct TEST_RUNNER_EXPORT TestPreferences {
int default_font_size;
int minimum_font_size;
bool dom_paste_allowed;
......
......@@ -1781,6 +1781,11 @@ bool TestRunner::ShouldGeneratePixelResults() {
return generate_pixel_results_;
}
bool TestRunner::ShouldStayOnPageAfterHandlingBeforeUnload() const {
return should_stay_on_page_after_handling_before_unload_;
}
void TestRunner::setShouldGeneratePixelResults(bool value) {
generate_pixel_results_ = value;
}
......@@ -1885,10 +1890,6 @@ bool TestRunner::isPrinting() const {
return is_printing_;
}
bool TestRunner::shouldStayOnPageAfterHandlingBeforeUnload() const {
return should_stay_on_page_after_handling_before_unload_;
}
bool TestRunner::shouldWaitUntilExternalURLLoad() const {
return wait_until_external_url_load_;
}
......
......@@ -3,25 +3,33 @@
# found in the LICENSE file.
{
'variables': {
# This turns on e.g. the filename-based detection of which
# platforms to include source files on (e.g. files ending in
# _mac.h or _mac.cc are only compiled on MacOSX).
'chromium_code': 1,
},
'targets': [
{
# GN version: //components/test_runner:test_runner
'target_name': 'test_runner',
'type': 'static_library',
'variables': {
'chromium_code': 1,
},
'type': '<(component)',
'defines': [
'TEST_RUNNER_IMPLEMENTATION',
],
'dependencies': [
'resources',
'../../base/base.gyp:base',
'../../base/base.gyp:base_static',
'../../cc/cc.gyp:cc',
'../../gin/gin.gyp:gin',
'../../gpu/gpu.gyp:gpu',
'../../skia/skia.gyp:skia',
'../../third_party/WebKit/public/blink.gyp:blink',
'../../ui/events/events.gyp:dom_keycode_converter',
'../../ui/events/events.gyp:events_base',
'../../ui/gfx/gfx.gyp:gfx',
'../../ui/gfx/gfx.gyp:gfx_geometry',
'../../url/url.gyp:url_lib',
'../../v8/tools/gyp/v8.gyp:v8',
],
'include_dirs': [
......@@ -77,6 +85,7 @@
'test_plugin.h',
'test_runner.cc',
'test_runner.h',
'test_runner_export.h',
'test_preferences.cc',
'test_preferences.h',
'text_input_controller.cc',
......@@ -173,9 +182,6 @@
# GN version: //components/test_runner:layout_test_helper
'target_name': 'layout_test_helper',
'type': 'executable',
'variables': {
'chromium_code': 1,
},
'sources': [
'helper/layout_test_helper_mac.mm',
'helper/layout_test_helper_win.cc',
......
......@@ -12,6 +12,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "components/test_runner/test_runner_export.h"
#include "components/test_runner/web_task.h"
#include "components/test_runner/web_test_runner.h"
#include "v8/include/v8.h"
......@@ -65,6 +66,7 @@ class TestRunner : public WebTestRunner,
// WebTestRunner implementation.
bool ShouldGeneratePixelResults() override;
bool ShouldStayOnPageAfterHandlingBeforeUnload() const override;
bool ShouldDumpAsAudio() const override;
void GetAudioData(std::vector<unsigned char>* buffer_view) const override;
bool ShouldDumpBackForwardList() const override;
......@@ -105,7 +107,6 @@ class TestRunner : public WebTestRunner,
bool shouldDumpStatusCallbacks() const;
bool shouldDumpProgressFinishedCallback() const;
bool shouldDumpSpellCheckCallbacks() const;
bool shouldStayOnPageAfterHandlingBeforeUnload() const;
bool shouldWaitUntilExternalURLLoad() const;
const std::set<std::string>* httpHeadersToClear() const;
void setTopLoadingFrame(blink::WebFrame*, bool);
......
// Copyright 2015 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 COMPONENTS_TEST_RUNNER_TEST_RUNNER_EXPORT_H_
#define COMPONENTS_TEST_RUNNER_TEST_RUNNER_EXPORT_H_
#if defined(COMPONENT_BUILD)
#if defined(WIN32)
#if defined(TEST_RUNNER_IMPLEMENTATION)
#define TEST_RUNNER_EXPORT __declspec(dllexport)
#else
#define TEST_RUNNER_EXPORT __declspec(dllimport)
#endif // defined(TEST_RUNNER_IMPLEMENTATION)
#else // defined(WIN32)
#if defined(TEST_RUNNER_IMPLEMENTATION)
#define TEST_RUNNER_EXPORT __attribute__((visibility("default")))
#else
#define TEST_RUNNER_EXPORT
#endif
#endif
#else // defined(COMPONENT_BUILD)
#define TEST_RUNNER_EXPORT
#endif
#endif // COMPONENTS_TEST_RUNNER_TEST_RUNNER_EXPORT_H_
......@@ -7,10 +7,10 @@
#include "base/basictypes.h"
#include "components/test_runner/mock_screen_orientation_client.h"
#include "components/test_runner/test_interfaces.h"
#include "components/test_runner/test_runner.h"
#include "components/test_runner/web_test_delegate.h"
#include "components/test_runner/web_test_interfaces.h"
#include "components/test_runner/web_test_proxy.h"
#include "components/test_runner/web_test_runner.h"
#include "third_party/WebKit/public/platform/WebString.h"
namespace test_runner {
......@@ -145,20 +145,20 @@ class WebFrameTestProxy : public Base {
}
virtual void runModalAlertDialog(const blink::WebString& message) {
base_proxy_->delegate_->PrintMessage(std::string("ALERT: ") +
message.utf8().data() + "\n");
base_proxy_->GetDelegate()->PrintMessage(std::string("ALERT: ") +
message.utf8().data() + "\n");
}
virtual bool runModalConfirmDialog(const blink::WebString& message) {
base_proxy_->delegate_->PrintMessage(std::string("CONFIRM: ") +
message.utf8().data() + "\n");
base_proxy_->GetDelegate()->PrintMessage(std::string("CONFIRM: ") +
message.utf8().data() + "\n");
return true;
}
virtual bool runModalPromptDialog(const blink::WebString& message,
const blink::WebString& default_value,
blink::WebString*) {
base_proxy_->delegate_->PrintMessage(
base_proxy_->GetDelegate()->PrintMessage(
std::string("PROMPT: ") + message.utf8().data() + ", default text: " +
default_value.utf8().data() + "\n");
return true;
......@@ -166,10 +166,11 @@ class WebFrameTestProxy : public Base {
virtual bool runModalBeforeUnloadDialog(bool is_reload,
const blink::WebString& message) {
base_proxy_->delegate_->PrintMessage(std::string("CONFIRM NAVIGATION: ") +
message.utf8().data() + "\n");
return !base_proxy_->test_interfaces_->GetTestRunner()
->shouldStayOnPageAfterHandlingBeforeUnload();
base_proxy_->GetDelegate()->PrintMessage(
std::string("CONFIRM NAVIGATION: ") + message.utf8().data() + "\n");
return !base_proxy_->GetInterfaces()
->TestRunner()
->ShouldStayOnPageAfterHandlingBeforeUnload();
}
virtual void showContextMenu(
......
......@@ -86,4 +86,8 @@ WebTestInterfaces::CreateAppBannerClient() {
return client.Pass();
}
AppBannerClient* WebTestInterfaces::GetAppBannerClient() {
return interfaces_->GetAppBannerClient();
}
} // namespace test_runner
......@@ -6,6 +6,7 @@
#define COMPONENTS_TEST_RUNNER_WEB_TEST_INTERFACES_H_
#include "base/memory/scoped_ptr.h"
#include "components/test_runner/test_runner_export.h"
namespace blink {
class WebAppBannerClient;
......@@ -24,12 +25,13 @@ class WebView;
namespace test_runner {
class AppBannerClient;
class TestInterfaces;
class WebTestDelegate;
class WebTestProxyBase;
class WebTestRunner;
class WebTestInterfaces {
class TEST_RUNNER_EXPORT WebTestInterfaces {
public:
WebTestInterfaces();
~WebTestInterfaces();
......@@ -56,6 +58,7 @@ class WebTestInterfaces {
blink::WebAudioDevice* CreateAudioDevice(double sample_rate);
scoped_ptr<blink::WebAppBannerClient> CreateAppBannerClient();
AppBannerClient* GetAppBannerClient();
TestInterfaces* GetTestInterfaces();
......
......@@ -379,7 +379,8 @@ std::string DumpAllBackForwardLists(TestInterfaces* interfaces,
}
WebTestProxyBase::WebTestProxyBase()
: test_interfaces_(NULL),
: web_test_interfaces_(NULL),
test_interfaces_(NULL),
delegate_(NULL),
web_widget_(NULL),
spellcheck_(new SpellCheckClient(this)),
......@@ -392,10 +393,15 @@ WebTestProxyBase::~WebTestProxyBase() {
}
void WebTestProxyBase::SetInterfaces(WebTestInterfaces* interfaces) {
web_test_interfaces_ = interfaces;
test_interfaces_ = interfaces->GetTestInterfaces();
test_interfaces_->WindowOpened(this);
}
WebTestInterfaces* WebTestProxyBase::GetInterfaces() {
return web_test_interfaces_;
}
void WebTestProxyBase::SetDelegate(WebTestDelegate* delegate) {
delegate_ = delegate;
spellcheck_->SetDelegate(delegate);
......@@ -403,6 +409,10 @@ void WebTestProxyBase::SetDelegate(WebTestDelegate* delegate) {
speech_recognizer_->SetDelegate(delegate);
}
WebTestDelegate* WebTestProxyBase::GetDelegate() {
return delegate_;
}
blink::WebView* WebTestProxyBase::GetWebView() const {
DCHECK(web_widget_);
// TestRunner does not support popup widgets. So |web_widget|_ is always a
......
......@@ -12,6 +12,7 @@
#include "base/basictypes.h"
#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
#include "components/test_runner/test_runner_export.h"
#include "components/test_runner/web_task.h"
#include "third_party/WebKit/public/platform/WebImage.h"
#include "third_party/WebKit/public/platform/WebRect.h"
......@@ -88,10 +89,12 @@ class WebTestInterfaces;
// when it requires a behavior to be different from the usual, it will call
// WebTestProxyBase that implements the expected behavior.
// See WebTestProxy class comments for more information.
class WebTestProxyBase {
class TEST_RUNNER_EXPORT WebTestProxyBase {
public:
void SetInterfaces(WebTestInterfaces* interfaces);
WebTestInterfaces* GetInterfaces();
void SetDelegate(WebTestDelegate* delegate);
WebTestDelegate* GetDelegate();
void set_widget(blink::WebWidget* widget) { web_widget_ = widget; }
void Reset();
......@@ -247,6 +250,7 @@ class WebTestProxyBase {
blink::WebWidget* web_widget() const { return web_widget_; }
WebTestInterfaces* web_test_interfaces_;
TestInterfaces* test_interfaces_;
WebTestDelegate* delegate_;
blink::WebWidget* web_widget_;
......
......@@ -35,6 +35,8 @@ class WebTestRunner {
// Returns true if WebTestProxy::capturePixels should be invoked after
// capturing text results.
virtual bool ShouldGeneratePixelResults() = 0;
virtual bool ShouldStayOnPageAfterHandlingBeforeUnload() const = 0;
};
} // namespace test_runner
......
......@@ -681,8 +681,7 @@ void BlinkTestRunner::ResolveBeforeInstallPromptPromise(
int request_id, const std::string& platform) {
test_runner::WebTestInterfaces* interfaces =
LayoutTestRenderProcessObserver::GetInstance()->test_interfaces();
interfaces->GetTestInterfaces()->GetAppBannerClient()->ResolvePromise(
request_id, platform);
interfaces->GetAppBannerClient()->ResolvePromise(request_id, platform);
}
blink::WebPlugin* BlinkTestRunner::CreatePluginPlaceholder(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment