Skip to content

Commit

Permalink
layout-tests: Move some test-setup related code into test_runner comp…
Browse files Browse the repository at this point in the history
…onent.

Move BlinkTestPlatformInitialize() and CheckLayoutSystemDeps() functions into
the test_runner component out of content, and use that from web_view test-runner
for mandoline.

BUG=531585

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

Cr-Commit-Position: refs/heads/master@{#352625}
  • Loading branch information
sadrulhc authored and Commit bot committed Oct 6, 2015
1 parent cdc9eea commit 1f7fa9f
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 48 deletions.
6 changes: 6 additions & 0 deletions components/test_runner/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
17 changes: 17 additions & 0 deletions components/test_runner/blink_test_platform_support.h
Original file line number Diff line number Diff line change
@@ -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_
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -25,7 +25,7 @@ const char kFontDirectory[] = DEVICE_SOURCE_ROOT_DIR "fonts/";

} // namespace

namespace content {
namespace test_runner {

bool CheckLayoutSystemDeps() {
return true;
Expand All @@ -39,4 +39,4 @@ bool BlinkTestPlatformInitialize() {
return true;
}

} // namespace content
} // namespace test_runner
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
// 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"
#include "base/logging.h"
#include "base/path_service.h"
#include "ui/gfx/test/fontconfig_util_linux.h"

namespace content {
namespace test_runner {

namespace {

Expand Down Expand Up @@ -67,4 +67,4 @@ bool BlinkTestPlatformInitialize() {
return true;
}

} // namespace content
} // namespace test_runner
Original file line number Diff line number Diff line change
Expand Up @@ -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 <AppKit/AppKit.h>
#include <Foundation/Foundation.h>

namespace content {
namespace test_runner {

namespace {

Expand Down Expand Up @@ -85,14 +84,15 @@ bool BlinkTestPlatformInitialize() {
}

// Add <app bundle's parent dir>/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
Original file line number Diff line number Diff line change
Expand Up @@ -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 <windows.h>
#include <iostream>
Expand All @@ -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) \
Expand All @@ -24,7 +23,7 @@
#define NONCLIENTMETRICS_SIZE_PRE_VISTA \
SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(NONCLIENTMETRICS, lfMessageFont)

namespace content {
namespace test_runner {

namespace {

Expand All @@ -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.
Expand Down Expand Up @@ -116,4 +116,4 @@ bool BlinkTestPlatformInitialize() {
return SetupFonts();
}

} // namespace content
} // namespace test_runner
6 changes: 6 additions & 0 deletions components/test_runner/test_runner.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
Expand All @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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_);
}
Expand Down
5 changes: 0 additions & 5 deletions content/content_shell.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
13 changes: 6 additions & 7 deletions content/shell/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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" ]
}
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions content/shell/app/DEPS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include_rules = [
"+components/test_runner",
]
15 changes: 0 additions & 15 deletions content/shell/app/blink_test_platform_support.h

This file was deleted.

8 changes: 4 additions & 4 deletions content/shell/app/shell_main_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -63,8 +63,8 @@
#endif // OS_MACOSX

#if defined(OS_WIN)
#include <initguid.h>
#include <windows.h>
#include <initguid.h>
#include "base/logging_win.h"
#include "components/crash/content/app/breakpad_win.h"
#include "content/shell/common/v8_breakpad_support_win.h"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 1f7fa9f

Please sign in to comment.