diff --git a/components/test_runner/BUILD.gn b/components/test_runner/BUILD.gn index f23698d2da5e67..fec5ecd721ce52 100644 --- a/components/test_runner/BUILD.gn +++ b/components/test_runner/BUILD.gn @@ -18,6 +18,11 @@ component("test_runner") { "accessibility_controller.h", "app_banner_client.cc", "app_banner_client.h", + "blink_test_platform_support.h", + "blink_test_platform_support_android.cc", + "blink_test_platform_support_linux.cc", + "blink_test_platform_support_mac.mm", + "blink_test_platform_support_win.cc", "event_sender.cc", "event_sender.h", "gamepad_controller.cc", @@ -101,6 +106,7 @@ component("test_runner") { "//ui/events:dom_keycode_converter", "//ui/events:events_base", "//ui/gfx", + "//ui/gfx:test_support", "//ui/gfx/geometry", "//url", "//v8", diff --git a/components/test_runner/blink_test_platform_support.h b/components/test_runner/blink_test_platform_support.h new file mode 100644 index 00000000000000..e397f1ee948672 --- /dev/null +++ b/components/test_runner/blink_test_platform_support.h @@ -0,0 +1,17 @@ +// Copyright 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 COMPONENTS_TEST_RUNNER_BLINK_TEST_PLATFORM_SUPPORT_H_ +#define COMPONENTS_TEST_RUNNER_BLINK_TEST_PLATFORM_SUPPORT_H_ + +#include "components/test_runner/test_runner_export.h" + +namespace test_runner { + +bool TEST_RUNNER_EXPORT CheckLayoutSystemDeps(); +bool TEST_RUNNER_EXPORT BlinkTestPlatformInitialize(); + +} // namespace test_runner + +#endif // COMPONENTS_TEST_RUNNER_BLINK_TEST_PLATFORM_SUPPORT_H_ diff --git a/content/shell/app/blink_test_platform_support_android.cc b/components/test_runner/blink_test_platform_support_android.cc similarity index 91% rename from content/shell/app/blink_test_platform_support_android.cc rename to components/test_runner/blink_test_platform_support_android.cc index 90ff93f3d70ce6..b9685ea5b6f430 100644 --- a/content/shell/app/blink_test_platform_support_android.cc +++ b/components/test_runner/blink_test_platform_support_android.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/shell/app/blink_test_platform_support.h" +#include "components/test_runner/blink_test_platform_support.h" #include "third_party/skia/include/ports/SkFontMgr_android.h" @@ -25,7 +25,7 @@ const char kFontDirectory[] = DEVICE_SOURCE_ROOT_DIR "fonts/"; } // namespace -namespace content { +namespace test_runner { bool CheckLayoutSystemDeps() { return true; @@ -39,4 +39,4 @@ bool BlinkTestPlatformInitialize() { return true; } -} // namespace content +} // namespace test_runner diff --git a/content/shell/app/blink_test_platform_support_linux.cc b/components/test_runner/blink_test_platform_support_linux.cc similarity index 94% rename from content/shell/app/blink_test_platform_support_linux.cc rename to components/test_runner/blink_test_platform_support_linux.cc index 7bf64c96cdb04d..402fd68392807f 100644 --- a/content/shell/app/blink_test_platform_support_linux.cc +++ b/components/test_runner/blink_test_platform_support_linux.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/shell/app/blink_test_platform_support.h" +#include "components/test_runner/blink_test_platform_support.h" #include "base/files/file_path.h" #include "base/files/file_util.h" @@ -10,7 +10,7 @@ #include "base/path_service.h" #include "ui/gfx/test/fontconfig_util_linux.h" -namespace content { +namespace test_runner { namespace { @@ -67,4 +67,4 @@ bool BlinkTestPlatformInitialize() { return true; } -} // namespace content +} // namespace test_runner diff --git a/content/shell/app/blink_test_platform_support_mac.mm b/components/test_runner/blink_test_platform_support_mac.mm similarity index 92% rename from content/shell/app/blink_test_platform_support_mac.mm rename to components/test_runner/blink_test_platform_support_mac.mm index 467a86a6c6c85f..e0150d67ebeaa1 100644 --- a/content/shell/app/blink_test_platform_support_mac.mm +++ b/components/test_runner/blink_test_platform_support_mac.mm @@ -6,13 +6,12 @@ #include "base/logging.h" #include "base/mac/bundle_locations.h" #include "base/path_service.h" -#include "content/public/common/content_switches.h" -#include "content/shell/app/blink_test_platform_support.h" +#include "components/test_runner/blink_test_platform_support.h" #include #include -namespace content { +namespace test_runner { namespace { @@ -85,14 +84,15 @@ bool BlinkTestPlatformInitialize() { } // Add /plugins to the plugin path so we can load - // test plugins. + // test npapi plugins (soon to be removed). + const char kExtraPluginDir[] = "extra-plugin-dir"; base::FilePath plugins_dir; PathService::Get(base::DIR_EXE, &plugins_dir); plugins_dir = plugins_dir.AppendASCII("../../../plugins"); base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); - command_line.AppendSwitchPath(switches::kExtraPluginDir, plugins_dir); + command_line.AppendSwitchPath(kExtraPluginDir, plugins_dir); return true; } -} // namespace +} // namespace test_runner diff --git a/content/shell/app/blink_test_platform_support_win.cc b/components/test_runner/blink_test_platform_support_win.cc similarity index 94% rename from content/shell/app/blink_test_platform_support_win.cc rename to components/test_runner/blink_test_platform_support_win.cc index d61223271f0387..f76500b6c544be 100644 --- a/content/shell/app/blink_test_platform_support_win.cc +++ b/components/test_runner/blink_test_platform_support_win.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/shell/app/blink_test_platform_support.h" +#include "components/test_runner/blink_test_platform_support.h" #include #include @@ -15,7 +15,6 @@ #include "base/logging.h" #include "base/path_service.h" #include "base/strings/utf_string_conversions.h" -#include "content/shell/common/shell_switches.h" #include "ui/gfx/win/direct_write.h" #define SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(struct_name, member) \ @@ -24,7 +23,7 @@ #define NONCLIENTMETRICS_SIZE_PRE_VISTA \ SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(NONCLIENTMETRICS, lfMessageFont) -namespace content { +namespace test_runner { namespace { @@ -42,9 +41,10 @@ bool SetupFonts() { // 2. For DirectWrite rendering by appending a command line flag that tells // the sandbox policy/warmup to grant access to the given path. if (gfx::win::ShouldUseDirectWrite()) { + const char kRegisterFontFiles[] = "register-font-files"; // DirectWrite sandbox registration. base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); - command_line.AppendSwitchASCII(switches::kRegisterFontFiles, + command_line.AppendSwitchASCII(kRegisterFontFiles, base::WideToUTF8(font_path.value())); } else { // GDI registration. @@ -116,4 +116,4 @@ bool BlinkTestPlatformInitialize() { return SetupFonts(); } -} // namespace content +} // namespace test_runner diff --git a/components/test_runner/test_runner.gyp b/components/test_runner/test_runner.gyp index 30ffa758b1695b..36e166d335815a 100644 --- a/components/test_runner/test_runner.gyp +++ b/components/test_runner/test_runner.gyp @@ -32,6 +32,7 @@ '../../ui/events/events.gyp:events_base', '../../ui/gfx/gfx.gyp:gfx', '../../ui/gfx/gfx.gyp:gfx_geometry', + '../../ui/gfx/gfx.gyp:gfx_test_support', '../../url/url.gyp:url_lib', '../../v8/tools/gyp/v8.gyp:v8', ], @@ -44,6 +45,11 @@ 'accessibility_controller.h', 'app_banner_client.cc', 'app_banner_client.h', + 'blink_test_platform_support.h', + 'blink_test_platform_support_android.cc', + 'blink_test_platform_support_linux.cc', + 'blink_test_platform_support_mac.mm', + 'blink_test_platform_support_win.cc', 'event_sender.cc', 'event_sender.h', 'gamepad_controller.cc', diff --git a/components/web_view/test_runner/test_runner_application_delegate.cc b/components/web_view/test_runner/test_runner_application_delegate.cc index 556ccdee68ec82..24d2c517fd485a 100644 --- a/components/web_view/test_runner/test_runner_application_delegate.cc +++ b/components/web_view/test_runner/test_runner_application_delegate.cc @@ -19,6 +19,7 @@ #include "components/mus/public/cpp/view.h" #include "components/mus/public/cpp/view_tree_connection.h" #include "components/mus/public/cpp/view_tree_host_factory.h" +#include "components/test_runner/blink_test_platform_support.h" #include "mojo/application/public/cpp/application_connection.h" #include "mojo/application/public/cpp/application_impl.h" #include "mojo/converters/geometry/geometry_type_converters.h" @@ -61,6 +62,9 @@ void TestRunnerApplicationDelegate::Terminate() { // mojo::ApplicationDelegate implementation: void TestRunnerApplicationDelegate::Initialize(mojo::ApplicationImpl* app) { + if (!test_runner::BlinkTestPlatformInitialize()) { + NOTREACHED() << "Test environment could not be properly set up for blink."; + } app_ = app; mus::CreateSingleViewTreeHost(app_, this, &host_); } diff --git a/content/content_shell.gypi b/content/content_shell.gypi index dccb0740a54248..fb1aff5fb13f78 100644 --- a/content/content_shell.gypi +++ b/content/content_shell.gypi @@ -88,11 +88,6 @@ 'shell/android/shell_jni_registrar.h', 'shell/android/shell_manager.cc', 'shell/android/shell_manager.h', - 'shell/app/blink_test_platform_support.h', - 'shell/app/blink_test_platform_support_android.cc', - 'shell/app/blink_test_platform_support_linux.cc', - 'shell/app/blink_test_platform_support_mac.mm', - 'shell/app/blink_test_platform_support_win.cc', 'shell/app/paths_mac.h', 'shell/app/paths_mac.mm', 'shell/app/shell_crash_reporter_client.cc', diff --git a/content/shell/BUILD.gn b/content/shell/BUILD.gn index 5e4fb6e09f229e..a49204fa46fe48 100644 --- a/content/shell/BUILD.gn +++ b/content/shell/BUILD.gn @@ -28,11 +28,6 @@ static_library("content_shell_lib") { "android/shell_jni_registrar.h", "android/shell_manager.cc", "android/shell_manager.h", - "app/blink_test_platform_support.h", - "app/blink_test_platform_support_android.cc", - "app/blink_test_platform_support_linux.cc", - "app/blink_test_platform_support_mac.mm", - "app/blink_test_platform_support_win.cc", "app/paths_mac.h", "app/paths_mac.mm", "app/shell_crash_reporter_client.cc", @@ -261,7 +256,9 @@ static_library("content_shell_lib") { if (use_x11) { # Some tests rely on this tool at runtime. Note: it might be better if # the tests that needed it had this as a dep instead of adding it here. - data_deps = [ "//tools/xdisplaycheck" ] + data_deps = [ + "//tools/xdisplaycheck", + ] deps += [ "//ui/events/devices" ] } @@ -436,7 +433,9 @@ if (!is_android && !is_mac) { if (is_android) { # Some tests rely on this tool. It might be nicer if these tests relied on # image diff rather than having content shell depend on it. - data_deps = [ "//tools/imagediff($host_toolchain)" ] + data_deps = [ + "//tools/imagediff($host_toolchain)", + ] } } } else { diff --git a/content/shell/app/DEPS b/content/shell/app/DEPS new file mode 100644 index 00000000000000..9d9b0fb100e3d8 --- /dev/null +++ b/content/shell/app/DEPS @@ -0,0 +1,3 @@ +include_rules = [ + "+components/test_runner", +] diff --git a/content/shell/app/blink_test_platform_support.h b/content/shell/app/blink_test_platform_support.h deleted file mode 100644 index 15da3ae8a7ae92..00000000000000 --- a/content/shell/app/blink_test_platform_support.h +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 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_APP_BLINK_TEST_PLATFORM_SUPPORT_H_ -#define CONTENT_SHELL_APP_BLINK_TEST_PLATFORM_SUPPORT_H_ - -namespace content { - -bool CheckLayoutSystemDeps(); -bool BlinkTestPlatformInitialize(); - -} // namespace content - -#endif // CONTENT_SHELL_APP_BLINK_TEST_PLATFORM_SUPPORT_H_ diff --git a/content/shell/app/shell_main_delegate.cc b/content/shell/app/shell_main_delegate.cc index 24525e8c8a3df4..fb0432013d6bff 100644 --- a/content/shell/app/shell_main_delegate.cc +++ b/content/shell/app/shell_main_delegate.cc @@ -14,12 +14,12 @@ #include "base/path_service.h" #include "build/build_config.h" #include "cc/base/switches.h" +#include "components/test_runner/blink_test_platform_support.h" #include "content/common/content_constants_internal.h" #include "content/public/browser/browser_main_runner.h" #include "content/public/common/content_switches.h" #include "content/public/common/url_constants.h" #include "content/public/test/layouttest_support.h" -#include "content/shell/app/blink_test_platform_support.h" #include "content/shell/app/shell_crash_reporter_client.h" #include "content/shell/browser/layout_test/layout_test_browser_main.h" #include "content/shell/browser/layout_test/layout_test_content_browser_client.h" @@ -63,8 +63,8 @@ #endif // OS_MACOSX #if defined(OS_WIN) -#include #include +#include #include "base/logging_win.h" #include "components/crash/content/app/breakpad_win.h" #include "content/shell/common/v8_breakpad_support_win.h" @@ -140,7 +140,7 @@ bool ShellMainDelegate::BasicStartupComplete(int* exit_code) { // If CheckLayoutSystemDeps succeeds, we don't exit early. Instead we // continue and try to load the fonts in BlinkTestPlatformInitialize // below, and then try to bring up the rest of the content module. - if (!CheckLayoutSystemDeps()) { + if (!test_runner::CheckLayoutSystemDeps()) { if (exit_code) *exit_code = 1; return true; @@ -199,7 +199,7 @@ bool ShellMainDelegate::BasicStartupComplete(int* exit_code) { media::RemoveProprietaryMediaTypesAndCodecsForTests(); #endif - if (!BlinkTestPlatformInitialize()) { + if (!test_runner::BlinkTestPlatformInitialize()) { if (exit_code) *exit_code = 1; return true;