Skip to content

Commit

Permalink
Moves ash content specific tests into ash_content_unittests
Browse files Browse the repository at this point in the history
The vast majority of the tests don't need content, so having to build
content all the time is a drain (especially on windows).

BUG=641026
TEST=test only changes
R=jamescook@chromium.org, dpranke@chromium.org

Review-Url: https://codereview.chromium.org/2296973002
Cr-Commit-Position: refs/heads/master@{#415743}
  • Loading branch information
sky authored and Commit bot committed Aug 31, 2016
1 parent f629859 commit 72f7f7e
Show file tree
Hide file tree
Showing 30 changed files with 554 additions and 136 deletions.
1 change: 1 addition & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ group("both_gn_and_gyp") {

if (use_aura) {
deps += [
"//ash:ash_content_unittests",
"//ash:ash_shell_with_content",
"//ash:ash_unittests",
"//ui/app_list:app_list_unittests",
Expand Down
171 changes: 122 additions & 49 deletions ash/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -184,24 +184,26 @@ component("ash_with_content") {
]
}

# TODO(msw): Move support code with content deps to test_support_with_content.
static_library("test_support") {
# Internal target consumed by |test_support_with_content| and
# |test_support_without_content|. This target contains all the test support
# files, with the exception of an implementation of AshTestEnvironment.
# Consumers of ash should use one of |test_support_with_content| or
# |test_support_without_content|.
static_library("test_support_common") {
testonly = true
visibility = [ ":*" ]
sources = gypi_values.ash_test_support_sources
configs += [ "//build/config:precompiled_headers" ]

public_deps = [
":ash",
]
deps = [
":test_support_with_content", # TODO(beng): reverse this direction.
"//ash/resources",
"//base:i18n",
"//base/test:test_support",
"//components/signin/core/account_id",
"//components/user_manager:user_manager",
"//content/public/browser",
"//content/test:test_support",
"//device/bluetooth",
"//skia",
"//testing/gtest",
Expand Down Expand Up @@ -241,13 +243,35 @@ static_library("test_support") {
}
}

static_library("test_support_without_content") {
testonly = true
sources = [
"test/ash_test_environment_default.cc",
]

public_deps = [
":test_support_common",
]

deps = [
"//base",
"//skia",
]
}

static_library("test_support_with_content") {
testonly = true
sources = gypi_values.ash_test_support_with_content_sources
sources += [
"test/ash_test_environment_content.cc",
"test/ash_test_environment_content.h",
]
configs += [ "//build/config:precompiled_headers" ]

deps = [
public_deps = [
":ash_with_content",
":test_support_common",
"//content/public/browser",
"//content/test:test_support",
"//skia",
]
Expand All @@ -258,15 +282,15 @@ static_library("interactive_ui_test_support") {
configs += [ "//build/config:precompiled_headers" ]
public_deps = [
":ash",
":test_support",
":test_support_without_content",
]
sources = [
"test/ash_interactive_ui_test_base.cc",
"test/ash_interactive_ui_test_base.h",
]
deps = [
":ash",
":test_support",
":test_support_with_content",
"//base",
"//skia",
"//testing/gtest",
Expand All @@ -283,7 +307,7 @@ static_library("ash_shell_lib") {
deps = [
":ash",
":ash_with_content",
":test_support",
":test_support_without_content",
"//ash/common/strings",
"//ash/resources",
"//base",
Expand Down Expand Up @@ -342,15 +366,76 @@ static_library("ash_shell_lib_with_content") {
}
}

test("ash_unittests") {
sources = gypi_values.ash_unittests_sources
configs += [ "//build/config:precompiled_headers" ]
# This target is intended for tests that use content. In general very few tests
# need or use content and should be placed in |ash_unittests| instead.
test("ash_content_unittests") {
sources = [
"content/display/screen_orientation_controller_chromeos_unittest.cc",
"content/keyboard_overlay/keyboard_overlay_delegate_unittest.cc",
"content/keyboard_overlay/keyboard_overlay_view_unittest.cc",
"test/ash_unittests.cc",
]
configs += [
"//build/config:precompiled_headers",
"//build/config/compiler:no_size_t_to_int_warning",
]

deps = [
":ash",
":ash_with_content",
":test_support",
":test_support_with_content",
"//base",
"//base/test:test_support",
"//components/signin/core/account_id",
"//components/user_manager",
"//content/public/browser",
"//content/test:test_support",
"//mojo/edk/system",
"//skia",
"//testing/gtest",
"//ui/aura",
"//ui/aura:test_support",
"//ui/message_center",
"//ui/message_center:test_support",
"//ui/views",
"//ui/views:test_support",
"//ui/views/controls/webview:test_support",
"//ui/web_dialogs:test_support",
]

data_deps = [
"//ash/common/strings:ash_test_strings",
"//ash/resources:ash_test_resources_100_percent",
"//ash/resources:ash_test_resources_200_percent",
]

if (is_chromeos) {
deps += [
"//chromeos",
"//chromeos:power_manager_proto",
"//chromeos:test_support_without_gmock",
"//components/quirks",
"//device/bluetooth",
"//net:net",
"//ui/chromeos",
"//ui/display",
"//ui/display:test_support",
"//ui/display:test_util",
]
}
}

test("ash_unittests") {
sources = gypi_values.ash_unittests_sources
sources += [ "test/ash_test_environment_default.cc" ]
configs += [
"//build/config:precompiled_headers",
"//build/config/compiler:no_size_t_to_int_warning",
]

deps = [
":ash",
":test_support_without_content",
"//ash/autoclick/common:autoclick",
"//ash/common/strings",
"//ash/resources",
Expand All @@ -359,10 +444,9 @@ test("ash_unittests") {
"//base/test:test_support",
"//components/signin/core/account_id",
"//components/user_manager",
"//content/public/browser",
"//content/test:test_support",
"//mojo/edk/system",
"//skia",
"//testing/gmock",
"//testing/gtest",
"//third_party/icu",
"//ui/accessibility",
Expand All @@ -382,15 +466,12 @@ test("ash_unittests") {
"//ui/gfx",
"//ui/gfx/geometry",
"//ui/keyboard",
"//ui/keyboard:keyboard_with_content",
"//ui/message_center",
"//ui/message_center:test_support",
"//ui/resources",
"//ui/strings",
"//ui/views",
"//ui/views:test_support",
"//ui/views/controls/webview:test_support",
"//ui/web_dialogs:test_support",
"//ui/wm",
"//ui/wm:test_support",
"//url",
Expand All @@ -402,36 +483,10 @@ test("ash_unittests") {
"//ash/resources:ash_test_resources_200_percent",
]

if (!is_chromeos) {
sources -= [
# TODO(zork): fix this test to build on Windows. See: crosbug.com/26906
"focus_cycler_unittest.cc",

# All tests for multiple displays: not supported on Windows Ash.
"wm/drag_window_resizer_unittest.cc",

# Talks to ChromeOS system services.
"wm/lock_state_controller_unittest.cc",

# Maximize mode is only available on Chrome OS.
"wm/maximize_mode/maximize_mode_controller_unittest.cc",
"wm/maximize_mode/maximize_mode_window_manager_unittest.cc",

# Can't resize on Windows Ash. http://crbug.com/165962
"autoclick/autoclick_unittest.cc",
"magnifier/magnification_controller_unittest.cc",
"magnifier/partial_magnification_controller_unittest.cc",
"sticky_keys/sticky_keys_overlay_unittest.cc",
"virtual_keyboard_controller_unittest.cc",
"wm/workspace/workspace_window_resizer_unittest.cc",
]
}

configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]

if (!use_x11) {
sources -= [ "host/ash_window_tree_host_x11_unittest.cc" ]
}

if (is_chromeos) {
sources += [ "first_run/first_run_helper_unittest.cc" ]
deps += [
Expand All @@ -450,18 +505,36 @@ test("ash_unittests") {
sources -= [
"accelerators/magnifier_key_scroller_unittest.cc",
"accelerators/spoken_feedback_toggler_unittest.cc",

# Can't resize on Windows Ash. http://crbug.com/165962
"autoclick/autoclick_unittest.cc",
"display/resolution_notification_controller_unittest.cc",

# TODO(zork): fix this test to build on Windows. See: crosbug.com/26906
"focus_cycler_unittest.cc",
"magnifier/magnification_controller_unittest.cc",
"magnifier/partial_magnification_controller_unittest.cc",
"sticky_keys/sticky_keys_overlay_unittest.cc",
"sticky_keys/sticky_keys_unittest.cc",
"touch/touchscreen_util_unittest.cc",
"virtual_keyboard_controller_unittest.cc",

# All tests for multiple displays: not supported on Windows Ash.
"wm/drag_window_resizer_unittest.cc",

# Talks to ChromeOS system services.
"wm/lock_state_controller_unittest.cc",

# Maximize mode is only available on Chrome OS.
"wm/maximize_mode/maximize_mode_controller_unittest.cc",
"wm/maximize_mode/maximize_mode_window_manager_unittest.cc",
"wm/workspace/workspace_window_resizer_unittest.cc",
]
}

if (!use_x11 || !is_chromeos) {
sources -= [ "touch/touch_transformer_controller_unittest.cc" ]
}

if (!is_chromeos) {
sources -= [ "sticky_keys/sticky_keys_unittest.cc" ]
}
}

executable("ash_shell_with_content") {
Expand Down
4 changes: 1 addition & 3 deletions ash/ash.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,7 @@
'test/ash_md_test_base.h',
'test/ash_test_base.cc',
'test/ash_test_base.h',
'test/ash_test_environment.h',
'test/ash_test_helper.cc',
'test/ash_test_helper.h',
'test/ash_test_views_delegate.cc',
Expand Down Expand Up @@ -987,9 +988,6 @@
'common/wm/overview/cleanup_animation_observer_unittest.cc',
'common/wm/workspace/workspace_event_handler_test_helper.cc',
'common/wm/workspace/workspace_event_handler_test_helper.h',
'content/display/screen_orientation_controller_chromeos_unittest.cc',
'content/keyboard_overlay/keyboard_overlay_delegate_unittest.cc',
'content/keyboard_overlay/keyboard_overlay_view_unittest.cc',
'dip_unittest.cc',
'display/cursor_window_controller_unittest.cc',
'display/display_change_observer_chromeos_unittest.cc',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "ash/display/display_manager.h"
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
#include "ash/test/ash_test_environment_content.h"
#include "ash/test/ash_test_helper.h"
#include "ash/test/content/test_shell_content_state.h"
#include "ash/test/display_manager_test_api.h"
Expand Down Expand Up @@ -108,8 +109,10 @@ class ScreenOrientationControllerTest : public test::AshTestBase {
~ScreenOrientationControllerTest() override;

content::ScreenOrientationDelegate* delegate() {
return ash_test_helper()
->test_shell_content_state()
test::AshTestEnvironmentContent* test_environment_content =
static_cast<test::AshTestEnvironmentContent*>(
ash_test_helper()->ash_test_environment());
return test_environment_content->test_shell_content_state()
->screen_orientation_delegate();
}

Expand Down
2 changes: 1 addition & 1 deletion ash/mus/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ source_set("unittests") {
":lib",
":resources",
"//ash",
"//ash:test_support",
"//ash:test_support_without_content",
"//ash/public/interfaces",
"//base",
"//base/test:test_config",
Expand Down
12 changes: 8 additions & 4 deletions ash/test/DEPS
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
include_rules = [
"+content/public/test/web_contents_tester.h",
"+content/public/test/test_browser_thread_bundle.h",
"+content/public/test/test_browser_context.h",
# In general files in this directory should not depend upon content.
"+mojo/edk",
"+win8/viewer",
]

specific_include_rules = {
# ash_test_environment_content is only compiled with content.
"ash_test_environment_content\.*": [
"+content/public/browser/browser_thread.h",
"+content/public/test/web_contents_tester.h",
"+content/public/test/test_browser_thread_bundle.h",
"+content/public/test/test_browser_context.h",
],
"ash_test_helper\.cc": [
"+ash/host",
"+content/public/browser/browser_thread.h",
],
"mirror_window_test_api\.cc": [
"+ash/host"
Expand Down
6 changes: 4 additions & 2 deletions ash/test/ash_test_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "ash/ime/input_method_event_handler.h"
#include "ash/shell.h"
#include "ash/shell/toplevel_window.h"
#include "ash/test/ash_test_environment.h"
#include "ash/test/ash_test_helper.h"
#include "ash/test/display_manager_test_api.h"
#include "ash/test/test_session_state_delegate.h"
Expand Down Expand Up @@ -102,10 +103,11 @@ AshTestBase::AshTestBase()
gfx::InitializeThreadedX11();
#endif

thread_bundle_.reset(new content::TestBrowserThreadBundle);
ash_test_environment_ = AshTestEnvironment::Create();

// Must initialize |ash_test_helper_| here because some tests rely on
// AshTestBase methods before they call AshTestBase::SetUp().
ash_test_helper_.reset(new AshTestHelper(base::MessageLoopForUI::current()));
ash_test_helper_.reset(new AshTestHelper(ash_test_environment_.get()));
}

AshTestBase::~AshTestBase() {
Expand Down
Loading

0 comments on commit 72f7f7e

Please sign in to comment.