Remove shell_test_api.test-mojom
Instead, this CL exposes the existing ShellTestApi as
ash/public/cpp/test/shell_test_api.h.
Bug: 958216
Test: trybot
Change-Id: I12aaa0aeccc13dbf65dbf90cdd0671d8276eae20
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1610573
Commit-Queue: Jun Mukai <mukai@chromium.org>
Reviewed-by: Mitsuru Oshima <oshima@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#659584}
diff --git a/ash/BUILD.gn b/ash/BUILD.gn
index e24d2c4d..0d564ef 100644
--- a/ash/BUILD.gn
+++ b/ash/BUILD.gn
@@ -2118,6 +2118,7 @@
"metrics/user_metrics_recorder_test_api.h",
"mojo_test_interface_factory.cc",
"mojo_test_interface_factory.h",
+ "public/cpp/test/shell_test_api.h",
"rotator/screen_rotation_animator_test_api.cc",
"rotator/screen_rotation_animator_test_api.h",
"session/test_pref_service_provider.cc",
@@ -2135,7 +2136,6 @@
"shell/toplevel_window.cc",
"shell/toplevel_window.h",
"shell_test_api.cc",
- "shell_test_api.h",
"system/palette/palette_tray_test_api.cc",
"system/palette/palette_tray_test_api.h",
"system/power/power_button_controller_test_api.cc",
diff --git a/ash/accelerators/accelerator_controller_unittest.cc b/ash/accelerators/accelerator_controller_unittest.cc
index cc30e1c..2654e0d 100644
--- a/ash/accelerators/accelerator_controller_unittest.cc
+++ b/ash/accelerators/accelerator_controller_unittest.cc
@@ -23,11 +23,11 @@
#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/ash_switches.h"
#include "ash/public/cpp/shell_window_ids.h"
+#include "ash/public/cpp/test/shell_test_api.h"
#include "ash/public/interfaces/ime_info.mojom.h"
#include "ash/session/session_controller_impl.h"
#include "ash/session/test_session_controller_client.h"
#include "ash/shell.h"
-#include "ash/shell_test_api.h"
#include "ash/system/brightness_control_delegate.h"
#include "ash/system/keyboard_brightness_control_delegate.h"
#include "ash/system/power/power_button_controller_test_api.h"
diff --git a/ash/app_list/app_list_presenter_delegate_unittest.cc b/ash/app_list/app_list_presenter_delegate_unittest.cc
index dd6b339..01c18ca 100644
--- a/ash/app_list/app_list_presenter_delegate_unittest.cc
+++ b/ash/app_list/app_list_presenter_delegate_unittest.cc
@@ -27,6 +27,7 @@
#include "ash/public/cpp/shelf_model.h"
#include "ash/public/cpp/shelf_types.h"
#include "ash/public/cpp/shell_window_ids.h"
+#include "ash/public/cpp/test/shell_test_api.h"
#include "ash/public/interfaces/app_list_view.mojom.h"
#include "ash/root_window_controller.h"
#include "ash/shelf/shelf.h"
@@ -34,7 +35,6 @@
#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shelf/shelf_view.h"
#include "ash/shell.h"
-#include "ash/shell_test_api.h"
#include "ash/system/unified/unified_system_tray.h"
#include "ash/test/ash_test_base.h"
#include "ash/wallpaper/wallpaper_controller_test_api.h"
@@ -1813,8 +1813,7 @@
// Test backdrop exists for active non-fullscreen window in tablet mode.
TEST_F(AppListPresenterDelegateHomeLauncherTest, BackdropTest) {
- WorkspaceControllerTestApi test_helper(
- ShellTestApi(Shell::Get()).workspace_controller());
+ WorkspaceControllerTestApi test_helper(ShellTestApi().workspace_controller());
EnableTabletMode(true);
GetAppListTestHelper()->CheckVisibility(true);
EXPECT_FALSE(test_helper.GetBackdropWindow());
diff --git a/ash/display/screen_position_controller_unittest.cc b/ash/display/screen_position_controller_unittest.cc
index 2242c82..fc67cee 100644
--- a/ash/display/screen_position_controller_unittest.cc
+++ b/ash/display/screen_position_controller_unittest.cc
@@ -7,9 +7,9 @@
#include <memory>
#include "ash/public/cpp/shell_window_ids.h"
+#include "ash/public/cpp/test/shell_test_api.h"
#include "ash/screen_util.h"
#include "ash/shell.h"
-#include "ash/shell_test_api.h"
#include "ash/test/ash_test_base.h"
#include "ash/window_factory.h"
#include "base/run_loop.h"
@@ -30,8 +30,7 @@
namespace {
ScreenPositionController* GetScreenPositionController() {
- ShellTestApi test_api(Shell::Get());
- return test_api.screen_position_controller();
+ return ShellTestApi().screen_position_controller();
}
class ScreenPositionControllerTest : public AshTestBase {
diff --git a/ash/mojo_test_interface_factory.cc b/ash/mojo_test_interface_factory.cc
index 026e60d35..a1f8918 100644
--- a/ash/mojo_test_interface_factory.cc
+++ b/ash/mojo_test_interface_factory.cc
@@ -10,12 +10,10 @@
#include "ash/metrics/time_to_first_present_recorder_test_api.h"
#include "ash/public/interfaces/login_screen_test_api.test-mojom.h"
#include "ash/public/interfaces/shelf_test_api.test-mojom.h"
-#include "ash/public/interfaces/shell_test_api.test-mojom.h"
#include "ash/public/interfaces/status_area_widget_test_api.test-mojom.h"
#include "ash/public/interfaces/system_tray_test_api.test-mojom.h"
#include "ash/public/interfaces/time_to_first_present_recorder_test_api.test-mojom.h"
#include "ash/shelf/shelf_test_api.h"
-#include "ash/shell_test_api.h"
#include "ash/system/status_area_widget_test_api.h"
#include "ash/system/unified/unified_system_tray_test_api.h"
#include "base/bind.h"
@@ -37,10 +35,6 @@
ShelfTestApi::BindRequest(std::move(request));
}
-void BindShellTestApiOnMainThread(mojom::ShellTestApiRequest request) {
- ShellTestApi::BindRequest(std::move(request));
-}
-
void BindStatusAreaWidgetTestApiOnMainThread(
mojom::StatusAreaWidgetTestApiRequest request) {
StatusAreaWidgetTestApi::BindRequest(std::move(request));
@@ -65,8 +59,6 @@
main_thread_task_runner);
registry->AddInterface(base::Bind(&BindShelfTestApiOnMainThread),
main_thread_task_runner);
- registry->AddInterface(base::Bind(&BindShellTestApiOnMainThread),
- main_thread_task_runner);
registry->AddInterface(base::Bind(&BindStatusAreaWidgetTestApiOnMainThread),
main_thread_task_runner);
registry->AddInterface(base::Bind(&BindSystemTrayTestApiOnMainThread),
diff --git a/ash/public/cpp/test/shell_test_api.h b/ash/public/cpp/test/shell_test_api.h
new file mode 100644
index 0000000..43cf038
--- /dev/null
+++ b/ash/public/cpp/test/shell_test_api.h
@@ -0,0 +1,106 @@
+// Copyright 2019 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 ASH_PUBLIC_CPP_TEST_SHELL_TEST_API_H_
+#define ASH_PUBLIC_CPP_TEST_SHELL_TEST_API_H_
+
+#include <memory>
+
+#include "ash/ash_export.h"
+#include "ash/public/interfaces/app_list_view.mojom-forward.h"
+#include "base/callback_forward.h"
+#include "base/macros.h"
+
+class PrefService;
+
+namespace ash {
+class DragDropController;
+class MessageCenterController;
+class NativeCursorManagerAsh;
+class PowerPrefs;
+class ScreenPositionController;
+class Shell;
+class SystemGestureEventFilter;
+class WorkspaceController;
+
+enum class OverviewAnimationState : int32_t {
+ kEnterAnimationComplete,
+ kExitAnimationComplete,
+};
+
+// Accesses private data from a Shell for testing.
+class ASH_EXPORT ShellTestApi {
+ public:
+ ShellTestApi();
+ ~ShellTestApi();
+
+ MessageCenterController* message_center_controller();
+ SystemGestureEventFilter* system_gesture_event_filter();
+ WorkspaceController* workspace_controller();
+ ScreenPositionController* screen_position_controller();
+ NativeCursorManagerAsh* native_cursor_manager_ash();
+ DragDropController* drag_drop_controller();
+ PowerPrefs* power_prefs();
+
+ // Calls the private method.
+ void OnLocalStatePrefServiceInitialized(
+ std::unique_ptr<PrefService> pref_service);
+
+ // Resets |shell_->power_button_controller_| to hold a new object to simulate
+ // Chrome starting.
+ void ResetPowerButtonControllerForTest();
+
+ // Simulates a modal dialog being open.
+ void SimulateModalWindowOpenForTest(bool modal_window_open);
+
+ // Returns true if a system modal window is open (e.g. the Wi-Fi network
+ // password dialog).
+ bool IsSystemModalWindowOpen();
+
+ // Enables or disables the tablet mode window manager.
+ void EnableTabletModeWindowManager(bool enable);
+
+ // Enables the keyboard and associates it with the primary root window
+ // controller. In tablet mode, enables the virtual keyboard.
+ void EnableVirtualKeyboard();
+
+ // Fullscreens the active window, as if the user had pressed the hardware
+ // fullscreen button.
+ void ToggleFullscreen();
+
+ // Enters or exits overview mode.
+ void ToggleOverviewMode();
+
+ // Returns true if it is in overview selecting mode.
+ bool IsOverviewSelecting();
+
+ // Used to emulate display change when run in a desktop environment instead
+ // of on a device.
+ void AddRemoveDisplay();
+
+ // Runs the callback when the WindowTreeHost of the primary display is no
+ // longer holding pointer events. See
+ // |aura::WindowTreeHost::holding_pointer_moves_| for details.
+ void WaitForNoPointerHoldLock();
+
+ // Runs the callback when the compositor of the primary display has presented
+ // a frame on screen.
+ void WaitForNextFrame(base::OnceClosure closure);
+
+ // Runs the callback when the overview state becomes |state|.
+ void WaitForOverviewAnimationState(OverviewAnimationState state);
+
+ // Runs the callback when the launcher state becomes |state| after
+ // state transition animation.
+ void WaitForLauncherAnimationState(mojom::AppListViewState state);
+
+ private:
+ Shell* shell_; // not owned
+
+ DISALLOW_COPY_AND_ASSIGN(ShellTestApi);
+};
+
+} // namespace ash
+
+#endif // ASH_PUBLIC_CPP_TEST_SHELL_TEST_API_H_
diff --git a/ash/public/cpp/test_manifest.cc b/ash/public/cpp/test_manifest.cc
index 6bacb0f1e0..73c598d2 100644
--- a/ash/public/cpp/test_manifest.cc
+++ b/ash/public/cpp/test_manifest.cc
@@ -6,7 +6,6 @@
#include "ash/public/interfaces/login_screen_test_api.test-mojom.h"
#include "ash/public/interfaces/shelf_test_api.test-mojom.h"
-#include "ash/public/interfaces/shell_test_api.test-mojom.h"
#include "ash/public/interfaces/status_area_widget_test_api.test-mojom.h"
#include "ash/public/interfaces/system_tray_test_api.test-mojom.h"
#include "ash/public/interfaces/time_to_first_present_recorder_test_api.test-mojom.h"
@@ -19,11 +18,11 @@
static base::NoDestructor<service_manager::Manifest> manifest{
service_manager::ManifestBuilder()
.ExposeCapability(
- "test", service_manager::Manifest::InterfaceList<
- mojom::LoginScreenTestApi, mojom::ShelfTestApi,
- mojom::ShellTestApi, mojom::StatusAreaWidgetTestApi,
- mojom::SystemTrayTestApi,
- mojom::TimeToFirstPresentRecorderTestApi>())
+ "test",
+ service_manager::Manifest::InterfaceList<
+ mojom::LoginScreenTestApi, mojom::ShelfTestApi,
+ mojom::StatusAreaWidgetTestApi, mojom::SystemTrayTestApi,
+ mojom::TimeToFirstPresentRecorderTestApi>())
.Build()};
return *manifest;
}
diff --git a/ash/public/interfaces/BUILD.gn b/ash/public/interfaces/BUILD.gn
index 0678249..fe8d646f 100644
--- a/ash/public/interfaces/BUILD.gn
+++ b/ash/public/interfaces/BUILD.gn
@@ -98,7 +98,6 @@
sources = [
"login_screen_test_api.test-mojom",
"shelf_test_api.test-mojom",
- "shell_test_api.test-mojom",
"status_area_widget_test_api.test-mojom",
"system_tray_test_api.test-mojom",
"time_to_first_present_recorder_test_api.test-mojom",
diff --git a/ash/public/interfaces/shell_test_api.test-mojom b/ash/public/interfaces/shell_test_api.test-mojom
deleted file mode 100644
index 08fd6a2..0000000
--- a/ash/public/interfaces/shell_test_api.test-mojom
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright 2017 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.
-
-module ash.mojom;
-
-import "ash/public/interfaces/app_list_view.mojom";
-
-enum OverviewAnimationState {
- kEnterAnimationComplete,
- kExitAnimationComplete,
-};
-
-interface ShellTestApi {
- // Returns true if a system modal window is open (e.g. the Wi-Fi network
- // password dialog).
- IsSystemModalWindowOpen() => (bool visible);
-
- // Enables or disables the tablet mode window manager.
- EnableTabletModeWindowManager(bool enable);
-
- // Enables the keyboard and associates it with the primary root window
- // controller. In tablet mode, enables the virtual keyboard.
- EnableVirtualKeyboard() => ();
-
- // Fullscreens the active window, as if the user had pressed the hardware
- // fullscreen button.
- ToggleFullscreen() => ();
-
- // Enters or exits overview mode.
- ToggleOverviewMode() => ();
-
- // Returns true if it is in overview selecting mode.
- IsOverviewSelecting() => (bool is_selecting);
-
- // Used to emulate display change when run in a desktop environment instead
- // of on a device.
- AddRemoveDisplay();
-
- // Set the minimum velocity to cause fling gesture.
- SetMinFlingVelocity(float velocity);
-
- // Runs the callback when the WindowTreeHost of the primary display is no
- // longer holding pointer events. See
- // |aura::WindowTreeHost::holding_pointer_moves_| for details.
- WaitForNoPointerHoldLock() => ();
-
- // Runs the callback when the compositor of the primary display has presented
- // a frame on screen.
- WaitForNextFrame() => ();
-
- // Runs the callback when the overview state becomes |state|.
- WaitForOverviewAnimationState(OverviewAnimationState state) => ();
-
- // Runs the callback when the launcher state becomes |state| after
- // state transition animation.
- WaitForLauncherAnimationState(AppListViewState state) => ();
-};
diff --git a/ash/shelf/shelf_layout_manager_unittest.cc b/ash/shelf/shelf_layout_manager_unittest.cc
index 9dd3e81..cfbecbd 100644
--- a/ash/shelf/shelf_layout_manager_unittest.cc
+++ b/ash/shelf/shelf_layout_manager_unittest.cc
@@ -25,6 +25,7 @@
#include "ash/public/cpp/ash_switches.h"
#include "ash/public/cpp/immersive/immersive_fullscreen_controller_test_api.h"
#include "ash/public/cpp/shell_window_ids.h"
+#include "ash/public/cpp/test/shell_test_api.h"
#include "ash/public/cpp/window_properties.h"
#include "ash/root_window_controller.h"
#include "ash/screen_util.h"
@@ -36,7 +37,6 @@
#include "ash/shelf/shelf_view.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
-#include "ash/shell_test_api.h"
#include "ash/system/status_area_widget.h"
#include "ash/system/status_area_widget_test_helper.h"
#include "ash/system/unified/unified_system_tray.h"
diff --git a/ash/shelf/shelf_view_unittest.cc b/ash/shelf/shelf_view_unittest.cc
index fcc0e76..0907cc8c 100644
--- a/ash/shelf/shelf_view_unittest.cc
+++ b/ash/shelf/shelf_view_unittest.cc
@@ -38,7 +38,6 @@
#include "ash/shelf/shelf_view_test_api.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
-#include "ash/shell_test_api.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/system/status_area_widget.h"
#include "ash/test/ash_test_base.h"
diff --git a/ash/shell_test_api.cc b/ash/shell_test_api.cc
index aba234c..8d6fc06 100644
--- a/ash/shell_test_api.cc
+++ b/ash/shell_test_api.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 "ash/shell_test_api.h"
+#include "ash/public/cpp/test/shell_test_api.h"
#include <memory>
#include <utility>
@@ -72,10 +72,9 @@
// after executing the callback.
class OverviewAnimationStateWaiter : public OverviewObserver {
public:
- OverviewAnimationStateWaiter(
- mojom::OverviewAnimationState state,
- ShellTestApi::WaitForOverviewAnimationStateCallback callback)
- : state_(state), callback_(std::move(callback)) {
+ OverviewAnimationStateWaiter(OverviewAnimationState state,
+ base::OnceClosure closure)
+ : state_(state), closure_(std::move(closure)) {
Shell::Get()->overview_controller()->AddObserver(this);
}
~OverviewAnimationStateWaiter() override {
@@ -84,21 +83,21 @@
// OverviewObserver:
void OnOverviewModeStartingAnimationComplete(bool canceled) override {
- if (state_ == mojom::OverviewAnimationState::kEnterAnimationComplete) {
- std::move(callback_).Run();
+ if (state_ == OverviewAnimationState::kEnterAnimationComplete) {
+ std::move(closure_).Run();
delete this;
}
}
void OnOverviewModeEndingAnimationComplete(bool canceled) override {
- if (state_ == mojom::OverviewAnimationState::kExitAnimationComplete) {
- std::move(callback_).Run();
+ if (state_ == OverviewAnimationState::kExitAnimationComplete) {
+ std::move(closure_).Run();
delete this;
}
}
private:
- mojom::OverviewAnimationState state_;
- ShellTestApi::WaitForOverviewAnimationStateCallback callback_;
+ OverviewAnimationState state_;
+ base::OnceClosure closure_;
DISALLOW_COPY_AND_ASSIGN(OverviewAnimationStateWaiter);
};
@@ -107,10 +106,9 @@
// execute the callback. This self destruction upon completion.
class LauncherStateWaiter {
public:
- LauncherStateWaiter(
- ash::mojom::AppListViewState state,
- ShellTestApi::WaitForLauncherAnimationStateCallback callback)
- : target_state_(state), callback_(std::move(callback)) {
+ LauncherStateWaiter(ash::mojom::AppListViewState state,
+ base::OnceClosure closure)
+ : target_state_(state), closure_(std::move(closure)) {
Shell::Get()->app_list_controller()->SetStateTransitionAnimationCallback(
base::BindRepeating(&LauncherStateWaiter::OnStateChanged,
base::Unretained(this)));
@@ -122,28 +120,22 @@
void OnStateChanged(ash::mojom::AppListViewState state) {
if (target_state_ == state) {
- std::move(callback_).Run();
+ std::move(closure_).Run();
delete this;
}
}
private:
ash::mojom::AppListViewState target_state_;
- ShellTestApi::WaitForLauncherAnimationStateCallback callback_;
+ base::OnceClosure closure_;
DISALLOW_COPY_AND_ASSIGN(LauncherStateWaiter);
};
} // namespace
-ShellTestApi::ShellTestApi() : ShellTestApi(Shell::Get()) {}
-
-ShellTestApi::ShellTestApi(Shell* shell) : shell_(shell) {}
-
-// static
-void ShellTestApi::BindRequest(mojom::ShellTestApiRequest request) {
- mojo::MakeStrongBinding(std::make_unique<ShellTestApi>(), std::move(request));
-}
+ShellTestApi::ShellTestApi() : shell_(Shell::Get()) {}
+ShellTestApi::~ShellTestApi() = default;
MessageCenterController* ShellTestApi::message_center_controller() {
return shell_->message_center_controller_.get();
@@ -189,8 +181,8 @@
shell_->simulate_modal_window_open_for_test_ = modal_window_open;
}
-void ShellTestApi::IsSystemModalWindowOpen(IsSystemModalWindowOpenCallback cb) {
- std::move(cb).Run(Shell::IsSystemModalWindowOpen());
+bool ShellTestApi::IsSystemModalWindowOpen() {
+ return Shell::IsSystemModalWindowOpen();
}
void ShellTestApi::EnableTabletModeWindowManager(bool enable) {
@@ -198,80 +190,70 @@
shell_->tablet_mode_controller()->EnableTabletModeWindowManager(enable);
}
-void ShellTestApi::EnableVirtualKeyboard(EnableVirtualKeyboardCallback cb) {
+void ShellTestApi::EnableVirtualKeyboard() {
shell_->ash_keyboard_controller()->SetEnableFlag(
keyboard::mojom::KeyboardEnableFlag::kCommandLineEnabled);
- std::move(cb).Run();
}
-void ShellTestApi::ToggleFullscreen(ToggleFullscreenCallback cb) {
+void ShellTestApi::ToggleFullscreen() {
ash::accelerators::ToggleFullscreen();
- std::move(cb).Run();
}
-void ShellTestApi::ToggleOverviewMode(ToggleOverviewModeCallback cb) {
+void ShellTestApi::ToggleOverviewMode() {
shell_->overview_controller()->ToggleOverview();
- std::move(cb).Run();
}
-void ShellTestApi::IsOverviewSelecting(IsOverviewSelectingCallback callback) {
- std::move(callback).Run(shell_->overview_controller()->InOverviewSession());
+bool ShellTestApi::IsOverviewSelecting() {
+ return shell_->overview_controller()->InOverviewSession();
}
void ShellTestApi::AddRemoveDisplay() {
shell_->display_manager()->AddRemoveDisplay();
}
-void ShellTestApi::SetMinFlingVelocity(float velocity) {
- ui::GestureConfiguration::GetInstance()->set_min_fling_velocity(velocity);
-}
-
-void ShellTestApi::WaitForNoPointerHoldLock(
- WaitForNoPointerHoldLockCallback callback) {
+void ShellTestApi::WaitForNoPointerHoldLock() {
aura::WindowTreeHost* primary_host =
Shell::GetPrimaryRootWindowController()->GetHost();
if (primary_host->holding_pointer_moves())
PointerMoveLoopWaiter(primary_host).Wait();
- std::move(callback).Run();
}
-void ShellTestApi::WaitForNextFrame(WaitForNextFrameCallback callback) {
+void ShellTestApi::WaitForNextFrame(base::OnceClosure closure) {
Shell::GetPrimaryRootWindowController()
->GetHost()
->compositor()
->RequestPresentationTimeForNextFrame(base::BindOnce(
- [](WaitForNextFrameCallback callback,
+ [](base::OnceClosure closure,
const gfx::PresentationFeedback& feedback) {
- std::move(callback).Run();
+ std::move(closure).Run();
},
- std::move(callback)));
+ std::move(closure)));
}
-void ShellTestApi::WaitForOverviewAnimationState(
- mojom::OverviewAnimationState state,
- WaitForOverviewAnimationStateCallback callback) {
- auto* overview_controller = Shell::Get()->overview_controller();
- if (state == mojom::OverviewAnimationState::kEnterAnimationComplete &&
+void ShellTestApi::WaitForOverviewAnimationState(OverviewAnimationState state) {
+ auto* overview_controller = shell_->overview_controller();
+ if (state == OverviewAnimationState::kEnterAnimationComplete &&
overview_controller->InOverviewSession() &&
!overview_controller->IsInStartAnimation()) {
// If there is no animation applied, call the callback immediately.
- std::move(callback).Run();
return;
}
- if (state == mojom::OverviewAnimationState::kExitAnimationComplete &&
+ if (state == OverviewAnimationState::kExitAnimationComplete &&
!overview_controller->InOverviewSession() &&
!overview_controller->IsCompletingShutdownAnimations()) {
// If there is no animation applied, call the callback immediately.
- std::move(callback).Run();
return;
}
- new OverviewAnimationStateWaiter(state, std::move(callback));
+ base::RunLoop run_loop;
+ new OverviewAnimationStateWaiter(state, run_loop.QuitWhenIdleClosure());
+ run_loop.Run();
}
void ShellTestApi::WaitForLauncherAnimationState(
- ash::mojom::AppListViewState target_state,
- WaitForLauncherAnimationStateCallback callback) {
- new LauncherStateWaiter(target_state, std::move(callback));
+ ash::mojom::AppListViewState target_state) {
+ base::RunLoop run_loop;
+ new LauncherStateWaiter(target_state, run_loop.QuitWhenIdleClosure());
+ run_loop.Run();
}
} // namespace ash
diff --git a/ash/shell_test_api.h b/ash/shell_test_api.h
deleted file mode 100644
index 1f83fa9..0000000
--- a/ash/shell_test_api.h
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright (c) 2012 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 ASH_SHELL_TEST_API_H_
-#define ASH_SHELL_TEST_API_H_
-
-#include <memory>
-
-#include "ash/public/interfaces/shell_test_api.test-mojom.h"
-#include "base/macros.h"
-
-class PrefService;
-
-namespace ash {
-class DragDropController;
-class MessageCenterController;
-class NativeCursorManagerAsh;
-class PowerPrefs;
-class ScreenPositionController;
-class Shell;
-class SystemGestureEventFilter;
-class WorkspaceController;
-
-// Accesses private data from a Shell for testing.
-class ShellTestApi : public mojom::ShellTestApi {
- public:
- ShellTestApi();
- explicit ShellTestApi(Shell* shell);
-
- // Creates and binds an instance from a remote request (e.g. from chrome).
- static void BindRequest(mojom::ShellTestApiRequest request);
-
- MessageCenterController* message_center_controller();
- SystemGestureEventFilter* system_gesture_event_filter();
- WorkspaceController* workspace_controller();
- ScreenPositionController* screen_position_controller();
- NativeCursorManagerAsh* native_cursor_manager_ash();
- DragDropController* drag_drop_controller();
- PowerPrefs* power_prefs();
-
- // Calls the private method.
- void OnLocalStatePrefServiceInitialized(
- std::unique_ptr<PrefService> pref_service);
-
- // Resets |shell_->power_button_controller_| to hold a new object to simulate
- // Chrome starting.
- void ResetPowerButtonControllerForTest();
-
- // Simulates a modal dialog being open.
- void SimulateModalWindowOpenForTest(bool modal_window_open);
-
- // mojom::ShellTestApi:
- void IsSystemModalWindowOpen(IsSystemModalWindowOpenCallback cb) override;
- void EnableTabletModeWindowManager(bool enable) override;
- void EnableVirtualKeyboard(EnableVirtualKeyboardCallback cb) override;
- void ToggleFullscreen(ToggleFullscreenCallback cb) override;
- void ToggleOverviewMode(ToggleOverviewModeCallback cb) override;
- void IsOverviewSelecting(IsOverviewSelectingCallback callback) override;
- void AddRemoveDisplay() override;
- void SetMinFlingVelocity(float velocity) override;
- void WaitForNoPointerHoldLock(
- WaitForNoPointerHoldLockCallback callback) override;
- void WaitForNextFrame(WaitForNextFrameCallback callback) override;
- void WaitForOverviewAnimationState(
- mojom::OverviewAnimationState state,
- WaitForOverviewAnimationStateCallback callback) override;
- void WaitForLauncherAnimationState(
- ash::mojom::AppListViewState state,
- WaitForLauncherAnimationStateCallback callback) override;
-
- private:
- Shell* shell_; // not owned
-
- DISALLOW_COPY_AND_ASSIGN(ShellTestApi);
-};
-
-} // namespace ash
-
-#endif // ASH_SHELL_TEST_API_H_
diff --git a/ash/shell_unittest.cc b/ash/shell_unittest.cc
index 97a926c..ccbb16d 100644
--- a/ash/shell_unittest.cc
+++ b/ash/shell_unittest.cc
@@ -17,6 +17,7 @@
#include "ash/keyboard/ui/public/keyboard_switches.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/shell_window_ids.h"
+#include "ash/public/cpp/test/shell_test_api.h"
#include "ash/root_window_controller.h"
#include "ash/scoped_root_window_for_new_windows.h"
#include "ash/session/session_controller_impl.h"
@@ -24,7 +25,6 @@
#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shelf/shelf_widget.h"
-#include "ash/shell_test_api.h"
#include "ash/test/ash_test_base.h"
#include "ash/test/ash_test_helper.h"
#include "ash/test_shell_delegate.h"
@@ -556,7 +556,7 @@
TEST_F(ShellTest, TestPreTargetHandlerOrder) {
Shell* shell = Shell::Get();
ui::EventTargetTestApi test_api(shell);
- ShellTestApi shell_test_api(shell);
+ ShellTestApi shell_test_api;
ui::EventHandlerList handlers = test_api.GetPreTargetHandlers();
ui::EventHandlerList::const_iterator cursor_filter =
@@ -690,7 +690,7 @@
TEST_F(ShellLoginTest, DragAndDropDisabledBeforeLogin) {
DragDropController* drag_drop_controller =
- ShellTestApi(Shell::Get()).drag_drop_controller();
+ ShellTestApi().drag_drop_controller();
DragDropControllerTestApi drag_drop_controller_test_api(drag_drop_controller);
EXPECT_FALSE(drag_drop_controller_test_api.enabled());
diff --git a/ash/system/message_center/inactive_user_notification_blocker_unittest.cc b/ash/system/message_center/inactive_user_notification_blocker_unittest.cc
index aa655e5e..2f542d28 100644
--- a/ash/system/message_center/inactive_user_notification_blocker_unittest.cc
+++ b/ash/system/message_center/inactive_user_notification_blocker_unittest.cc
@@ -4,9 +4,9 @@
#include "ash/system/message_center/inactive_user_notification_blocker.h"
+#include "ash/public/cpp/test/shell_test_api.h"
#include "ash/session/test_session_controller_client.h"
#include "ash/shell.h"
-#include "ash/shell_test_api.h"
#include "ash/system/message_center/message_center_controller.h"
#include "ash/test/ash_test_base.h"
#include "base/macros.h"
diff --git a/ash/system/palette/palette_tray_unittest.cc b/ash/system/palette/palette_tray_unittest.cc
index 27c42436..f2d6953 100644
--- a/ash/system/palette/palette_tray_unittest.cc
+++ b/ash/system/palette/palette_tray_unittest.cc
@@ -19,7 +19,6 @@
#include "ash/session/session_controller_impl.h"
#include "ash/session/test_session_controller_client.h"
#include "ash/shell.h"
-#include "ash/shell_test_api.h"
#include "ash/system/palette/palette_tray_test_api.h"
#include "ash/system/palette/palette_utils.h"
#include "ash/system/palette/palette_welcome_bubble.h"
diff --git a/ash/system/palette/tools/create_note_unittest.cc b/ash/system/palette/tools/create_note_unittest.cc
index bd79e61..274000eaf 100644
--- a/ash/system/palette/tools/create_note_unittest.cc
+++ b/ash/system/palette/tools/create_note_unittest.cc
@@ -6,7 +6,6 @@
#include "ash/note_taking_controller.h"
#include "ash/shell.h"
-#include "ash/shell_test_api.h"
#include "ash/system/palette/mock_palette_tool_delegate.h"
#include "ash/system/palette/palette_ids.h"
#include "ash/system/palette/palette_tool.h"
diff --git a/ash/system/palette/tools/metalayer_unittest.cc b/ash/system/palette/tools/metalayer_unittest.cc
index 67cc204..a6db795b 100644
--- a/ash/system/palette/tools/metalayer_unittest.cc
+++ b/ash/system/palette/tools/metalayer_unittest.cc
@@ -8,7 +8,6 @@
#include "ash/highlighter/highlighter_controller_test_api.h"
#include "ash/public/interfaces/voice_interaction_controller.mojom.h"
#include "ash/shell.h"
-#include "ash/shell_test_api.h"
#include "ash/system/palette/mock_palette_tool_delegate.h"
#include "ash/system/palette/palette_ids.h"
#include "ash/system/palette/palette_tool.h"
diff --git a/ash/system/palette/tools/screenshot_unittest.cc b/ash/system/palette/tools/screenshot_unittest.cc
index 149d8a90..0ef288ee 100644
--- a/ash/system/palette/tools/screenshot_unittest.cc
+++ b/ash/system/palette/tools/screenshot_unittest.cc
@@ -5,7 +5,6 @@
#include <memory>
#include "ash/shell.h"
-#include "ash/shell_test_api.h"
#include "ash/system/palette/mock_palette_tool_delegate.h"
#include "ash/system/palette/palette_ids.h"
#include "ash/system/palette/palette_tool.h"
diff --git a/ash/system/power/power_button_test_base.cc b/ash/system/power/power_button_test_base.cc
index c405777..2c0f5ea 100644
--- a/ash/system/power/power_button_test_base.cc
+++ b/ash/system/power/power_button_test_base.cc
@@ -5,10 +5,10 @@
#include "ash/system/power/power_button_test_base.h"
#include "ash/public/cpp/ash_switches.h"
+#include "ash/public/cpp/test/shell_test_api.h"
#include "ash/session/session_controller_impl.h"
#include "ash/session/test_session_controller_client.h"
#include "ash/shell.h"
-#include "ash/shell_test_api.h"
#include "ash/system/power/power_button_controller.h"
#include "ash/system/power/power_button_controller_test_api.h"
#include "ash/wm/lock_state_controller.h"
diff --git a/ash/system/power/power_prefs_unittest.cc b/ash/system/power/power_prefs_unittest.cc
index 08127ea..7f4a8cb3 100644
--- a/ash/system/power/power_prefs_unittest.cc
+++ b/ash/system/power/power_prefs_unittest.cc
@@ -10,10 +10,10 @@
#include <vector>
#include "ash/public/cpp/ash_pref_names.h"
+#include "ash/public/cpp/test/shell_test_api.h"
#include "ash/session/session_controller_impl.h"
#include "ash/session/test_session_controller_client.h"
#include "ash/shell.h"
-#include "ash/shell_test_api.h"
#include "ash/test/ash_test_base.h"
#include "base/json/json_reader.h"
#include "base/macros.h"
@@ -187,7 +187,7 @@
NoSessionAshTestBase::SetUp();
power_policy_controller_ = chromeos::PowerPolicyController::Get();
- power_prefs_ = ShellTestApi(Shell::Get()).power_prefs();
+ power_prefs_ = ShellTestApi().power_prefs();
// Advance the clock an arbitrary amount of time so it won't report zero.
tick_clock_.Advance(base::TimeDelta::FromSeconds(1));
diff --git a/ash/wallpaper/wallpaper_controller_unittest.cc b/ash/wallpaper/wallpaper_controller_unittest.cc
index 9c227ec5..6056a0d 100644
--- a/ash/wallpaper/wallpaper_controller_unittest.cc
+++ b/ash/wallpaper/wallpaper_controller_unittest.cc
@@ -9,11 +9,11 @@
#include "ash/public/cpp/ash_switches.h"
#include "ash/public/cpp/shell_window_ids.h"
+#include "ash/public/cpp/test/shell_test_api.h"
#include "ash/root_window_controller.h"
#include "ash/session/session_controller_impl.h"
#include "ash/session/test_session_controller_client.h"
#include "ash/shell.h"
-#include "ash/shell_test_api.h"
#include "ash/test/ash_test_base.h"
#include "ash/wallpaper/wallpaper_controller_observer.h"
#include "ash/wallpaper/wallpaper_utils/wallpaper_resizer.h"
diff --git a/ash/wm/cursor_manager_test_api.cc b/ash/wm/cursor_manager_test_api.cc
index 019a202..f4410da 100644
--- a/ash/wm/cursor_manager_test_api.cc
+++ b/ash/wm/cursor_manager_test_api.cc
@@ -4,8 +4,8 @@
#include "ash/wm/cursor_manager_test_api.h"
+#include "ash/public/cpp/test/shell_test_api.h"
#include "ash/shell.h"
-#include "ash/shell_test_api.h"
#include "ash/wm/native_cursor_manager_ash.h"
#include "ui/base/cursor/image_cursors.h"
#include "ui/display/display.h"
@@ -29,11 +29,11 @@
display::Display::Rotation CursorManagerTestApi::GetCurrentCursorRotation()
const {
- return ShellTestApi(Shell::Get()).native_cursor_manager_ash()->GetRotation();
+ return ShellTestApi().native_cursor_manager_ash()->GetRotation();
}
float CursorManagerTestApi::GetCurrentCursorScale() const {
- return ShellTestApi(Shell::Get()).native_cursor_manager_ash()->GetScale();
+ return ShellTestApi().native_cursor_manager_ash()->GetScale();
}
} // namespace ash
diff --git a/ash/wm/system_gesture_event_filter_unittest.cc b/ash/wm/system_gesture_event_filter_unittest.cc
index 136ef55..e10938d 100644
--- a/ash/wm/system_gesture_event_filter_unittest.cc
+++ b/ash/wm/system_gesture_event_filter_unittest.cc
@@ -8,7 +8,6 @@
#include "ash/accelerators/accelerator_controller_impl.h"
#include "ash/shell.h"
-#include "ash/shell_test_api.h"
#include "ash/test/ash_test_base.h"
#include "ash/window_factory.h"
#include "ash/wm/window_positioning_utils.h"
diff --git a/ash/wm/tablet_mode/tablet_mode_window_manager_unittest.cc b/ash/wm/tablet_mode/tablet_mode_window_manager_unittest.cc
index 49eeeda5..47d22fb 100644
--- a/ash/wm/tablet_mode/tablet_mode_window_manager_unittest.cc
+++ b/ash/wm/tablet_mode/tablet_mode_window_manager_unittest.cc
@@ -8,6 +8,7 @@
#include "ash/public/cpp/ash_switches.h"
#include "ash/public/cpp/shelf_prefs.h"
+#include "ash/public/cpp/test/shell_test_api.h"
#include "ash/public/cpp/window_properties.h"
#include "ash/public/cpp/window_state_type.h"
#include "ash/root_window_controller.h"
@@ -16,7 +17,6 @@
#include "ash/session/test_session_controller_client.h"
#include "ash/shelf/shelf.h"
#include "ash/shell.h"
-#include "ash/shell_test_api.h"
#include "ash/test/ash_test_base.h"
#include "ash/wm/mru_window_tracker.h"
#include "ash/wm/overview/overview_controller.h"
diff --git a/ash/wm/workspace/multi_window_resize_controller_unittest.cc b/ash/wm/workspace/multi_window_resize_controller_unittest.cc
index 074d552d..9edb6f7 100644
--- a/ash/wm/workspace/multi_window_resize_controller_unittest.cc
+++ b/ash/wm/workspace/multi_window_resize_controller_unittest.cc
@@ -6,9 +6,9 @@
#include "ash/frame/non_client_frame_view_ash.h"
#include "ash/public/cpp/ash_constants.h"
+#include "ash/public/cpp/test/shell_test_api.h"
#include "ash/shelf/shelf_constants.h"
#include "ash/shell.h"
-#include "ash/shell_test_api.h"
#include "ash/test/ash_test_base.h"
#include "ash/wm/tablet_mode/tablet_mode_controller.h"
#include "ash/wm/window_state.h"
@@ -60,7 +60,7 @@
void SetUp() override {
AshTestBase::SetUp();
- WorkspaceController* wc = ShellTestApi(Shell::Get()).workspace_controller();
+ WorkspaceController* wc = ShellTestApi().workspace_controller();
WorkspaceEventHandler* event_handler =
WorkspaceControllerTestApi(wc).GetEventHandler();
resize_controller_ =
diff --git a/ash/wm/workspace/workspace_layout_manager_unittest.cc b/ash/wm/workspace/workspace_layout_manager_unittest.cc
index 22ef4e0..5b08381 100644
--- a/ash/wm/workspace/workspace_layout_manager_unittest.cc
+++ b/ash/wm/workspace/workspace_layout_manager_unittest.cc
@@ -19,6 +19,7 @@
#include "ash/public/cpp/app_list/app_list_features.h"
#include "ash/public/cpp/app_types.h"
#include "ash/public/cpp/shell_window_ids.h"
+#include "ash/public/cpp/test/shell_test_api.h"
#include "ash/public/cpp/window_properties.h"
#include "ash/root_window_controller.h"
#include "ash/screen_util.h"
@@ -29,7 +30,6 @@
#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shell.h"
#include "ash/shell_observer.h"
-#include "ash/shell_test_api.h"
#include "ash/system/unified/unified_system_tray.h"
#include "ash/test/ash_test_base.h"
#include "ash/wallpaper/wallpaper_controller_test_api.h"
@@ -1315,7 +1315,7 @@
}
TEST_F(WorkspaceLayoutManagerBackdropTest, BackdropTest) {
- WorkspaceController* wc = ShellTestApi(Shell::Get()).workspace_controller();
+ WorkspaceController* wc = ShellTestApi().workspace_controller();
WorkspaceControllerTestApi test_helper(wc);
std::unique_ptr<aura::Window> window1(
@@ -1475,7 +1475,7 @@
TEST_F(WorkspaceLayoutManagerBackdropTest,
DoNotShowBackdropDuringWallpaperPreview) {
- WorkspaceController* wc = ShellTestApi(Shell::Get()).workspace_controller();
+ WorkspaceController* wc = ShellTestApi().workspace_controller();
WorkspaceControllerTestApi test_helper(wc);
WallpaperControllerTestApi wallpaper_test_api(
Shell::Get()->wallpaper_controller());
@@ -1512,7 +1512,7 @@
}
TEST_F(WorkspaceLayoutManagerBackdropTest, SpokenFeedbackFullscreenBackground) {
- WorkspaceController* wc = ShellTestApi(Shell::Get()).workspace_controller();
+ WorkspaceController* wc = ShellTestApi().workspace_controller();
WorkspaceControllerTestApi test_helper(wc);
AccessibilityController* controller =
Shell::Get()->accessibility_controller();
@@ -1571,7 +1571,7 @@
// TODO(crbug.com/803286): The npot texture check failed on asan tests bot.
// TODO(crbug.com/838756): Very flaky on mash_ash_unittests.
TEST_F(WorkspaceLayoutManagerBackdropTest, DISABLED_OpenAppListInOverviewMode) {
- WorkspaceController* wc = ShellTestApi(Shell::Get()).workspace_controller();
+ WorkspaceController* wc = ShellTestApi().workspace_controller();
WorkspaceControllerTestApi test_helper(wc);
std::unique_ptr<aura::Window> window(
@@ -1596,7 +1596,7 @@
}
TEST_F(WorkspaceLayoutManagerBackdropTest, SpokenFeedbackForArc) {
- WorkspaceController* wc = ShellTestApi(Shell::Get()).workspace_controller();
+ WorkspaceController* wc = ShellTestApi().workspace_controller();
WorkspaceControllerTestApi test_helper(wc);
AccessibilityController* controller =
Shell::Get()->accessibility_controller();
@@ -2051,7 +2051,7 @@
TEST_F(WorkspaceLayoutManagerBackdropTest,
BackdropWindowIsNotReparentedFromAlwaysOnTopContainer) {
- WorkspaceController* wc = ShellTestApi(Shell::Get()).workspace_controller();
+ WorkspaceController* wc = ShellTestApi().workspace_controller();
WorkspaceControllerTestApi test_helper(wc);
RootWindowController* controller = Shell::GetPrimaryRootWindowController();
AlwaysOnTopController* always_on_top_controller =
diff --git a/ash/wm/workspace_controller_unittest.cc b/ash/wm/workspace_controller_unittest.cc
index 0394a68f..f18a36e 100644
--- a/ash/wm/workspace_controller_unittest.cc
+++ b/ash/wm/workspace_controller_unittest.cc
@@ -13,7 +13,6 @@
#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
-#include "ash/shell_test_api.h"
#include "ash/system/status_area_widget.h"
#include "ash/test/ash_test_base.h"
#include "ash/window_factory.h"
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
index 316d460..58d185e 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -5402,8 +5402,6 @@
"chromeos/policy/fake_device_cloud_policy_manager.h",
"chromeos/settings/device_settings_test_helper.cc",
"chromeos/settings/device_settings_test_helper.h",
- "ui/ash/ash_test_util.cc",
- "ui/ash/ash_test_util.h",
"ui/ash/tablet_mode_client_test_util.cc",
"ui/ash/tablet_mode_client_test_util.h",
]
diff --git a/chrome/browser/chromeos/file_manager/file_manager_browsertest_base.cc b/chrome/browser/chromeos/file_manager/file_manager_browsertest_base.cc
index 5bf78be3..f806b499 100644
--- a/chrome/browser/chromeos/file_manager/file_manager_browsertest_base.cc
+++ b/chrome/browser/chromeos/file_manager/file_manager_browsertest_base.cc
@@ -10,9 +10,7 @@
#include <memory>
#include <utility>
-#include "ash/public/interfaces/constants.mojom.h"
-#include "ash/public/interfaces/shell_test_api.test-mojom-test-utils.h"
-#include "ash/public/interfaces/shell_test_api.test-mojom.h"
+#include "ash/public/cpp/test/shell_test_api.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/containers/circular_deque.h"
@@ -2292,13 +2290,7 @@
void FileManagerBrowserTestBase::EnableVirtualKeyboard() {
CHECK(IsTabletModeTest());
-
- ash::mojom::ShellTestApiPtr shell_test_api;
- content::ServiceManagerConnection::GetForProcess()
- ->GetConnector()
- ->BindInterface(ash::mojom::kServiceName, &shell_test_api);
- ash::mojom::ShellTestApiAsyncWaiter waiter(shell_test_api.get());
- waiter.EnableVirtualKeyboard();
+ ash::ShellTestApi().EnableVirtualKeyboard();
}
} // namespace file_manager
diff --git a/chrome/browser/ui/ash/accelerator_commands_browsertest.cc b/chrome/browser/ui/ash/accelerator_commands_browsertest.cc
index e9e775c..a920c73 100644
--- a/chrome/browser/ui/ash/accelerator_commands_browsertest.cc
+++ b/chrome/browser/ui/ash/accelerator_commands_browsertest.cc
@@ -4,10 +4,8 @@
#include "ash/accelerators/accelerator_commands.h"
+#include "ash/public/cpp/test/shell_test_api.h"
#include "ash/public/cpp/window_properties.h"
-#include "ash/public/interfaces/constants.mojom.h"
-#include "ash/public/interfaces/shell_test_api.test-mojom-test-utils.h"
-#include "ash/public/interfaces/shell_test_api.test-mojom.h"
#include "base/command_line.h"
#include "base/macros.h"
#include "build/build_config.h"
@@ -54,12 +52,7 @@
// Tells Ash to toggle fullscreen as if the user had pressed the hardware
// fullscreen key.
void ToggleFullscreen() {
- ash::mojom::ShellTestApiPtr shell_test_api;
- content::ServiceManagerConnection::GetForProcess()
- ->GetConnector()
- ->BindInterface(ash::mojom::kServiceName, &shell_test_api);
- ash::mojom::ShellTestApiAsyncWaiter waiter(shell_test_api.get());
- waiter.ToggleFullscreen();
+ ash::ShellTestApi().ToggleFullscreen();
aura::test::WaitForAllChangesToComplete();
}
diff --git a/chrome/browser/ui/ash/ash_test_util.cc b/chrome/browser/ui/ash/ash_test_util.cc
deleted file mode 100644
index 7b799d3..0000000
--- a/chrome/browser/ui/ash/ash_test_util.cc
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2019 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 "chrome/browser/ui/ash/ash_test_util.h"
-
-#include "ash/public/interfaces/constants.mojom.h"
-#include "ash/public/interfaces/shell_test_api.test-mojom.h"
-#include "base/run_loop.h"
-#include "content/public/common/service_manager_connection.h"
-#include "services/service_manager/public/cpp/connector.h"
-#include "ui/aura/test/mus/change_completion_waiter.h"
-
-namespace test {
-
-ash::mojom::ShellTestApiPtr GetShellTestApi() {
- ash::mojom::ShellTestApiPtr shell_test_api;
- content::ServiceManagerConnection::GetForProcess()
- ->GetConnector()
- ->BindInterface(ash::mojom::kServiceName, &shell_test_api);
-
- return shell_test_api;
-}
-
-void WaitForNoPointerHoldLock(bool wait_for_changes) {
- ash::mojom::ShellTestApiPtr shell_test_api = GetShellTestApi();
-
- // Allow nestable tasks because this is called within a move loop.
- base::RunLoop run_loop(base::RunLoop::Type::kNestableTasksAllowed);
- shell_test_api->WaitForNoPointerHoldLock(run_loop.QuitClosure());
- run_loop.Run();
-
- if (wait_for_changes)
- aura::test::WaitForAllChangesToComplete();
-}
-
-void WaitForOverviewAnimationState(ash::mojom::OverviewAnimationState state) {
- ash::mojom::ShellTestApiPtr shell_test_api = GetShellTestApi();
-
- base::RunLoop run_loop;
- shell_test_api->WaitForOverviewAnimationState(state, run_loop.QuitClosure());
- run_loop.Run();
-}
-
-} // namespace test
diff --git a/chrome/browser/ui/ash/ash_test_util.h b/chrome/browser/ui/ash/ash_test_util.h
deleted file mode 100644
index 5e918fd..0000000
--- a/chrome/browser/ui/ash/ash_test_util.h
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2019 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 CHROME_BROWSER_UI_ASH_ASH_TEST_UTIL_H_
-#define CHROME_BROWSER_UI_ASH_ASH_TEST_UTIL_H_
-
-#include "ash/public/interfaces/shell_test_api.test-mojom-test-utils.h"
-#include "ash/public/interfaces/shell_test_api.test-mojom.h"
-
-namespace test {
-
-// Binds to ash service and returns a ShellTestApiPtr.
-ash::mojom::ShellTestApiPtr GetShellTestApi();
-
-// Waits until WindowTreeHost no longer holding pointer events.
-// If |wait_for_all_changes| is true, this also runs
-// aura::test::WaitForAllChangesToComplete().
-void WaitForNoPointerHoldLock(bool wait_for_changes = true);
-
-// Waits until the overview animation finishes and its state becomes |state|.
-void WaitForOverviewAnimationState(ash::mojom::OverviewAnimationState state);
-
-} // namespace test
-
-#endif // CHROME_BROWSER_UI_ASH_ASH_TEST_UTIL_H_
diff --git a/chrome/browser/ui/ash/drag_to_overview_interactive_uitest.cc b/chrome/browser/ui/ash/drag_to_overview_interactive_uitest.cc
index 5d7ac7c..13b4335 100644
--- a/chrome/browser/ui/ash/drag_to_overview_interactive_uitest.cc
+++ b/chrome/browser/ui/ash/drag_to_overview_interactive_uitest.cc
@@ -3,12 +3,12 @@
// found in the LICENSE file.
#include "ash/public/cpp/ash_switches.h"
+#include "ash/public/cpp/test/shell_test_api.h"
#include "base/bind.h"
#include "base/macros.h"
#include "base/run_loop.h"
#include "base/task/post_task.h"
#include "chrome/browser/chrome_notification_types.h"
-#include "chrome/browser/ui/ash/ash_test_util.h"
#include "chrome/browser/ui/ash/tablet_mode_client_test_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
@@ -30,14 +30,6 @@
namespace {
-bool IsOverviewSelecting() {
- ash::mojom::ShellTestApiPtr shell_test_api = test::GetShellTestApi();
- ash::mojom::ShellTestApiAsyncWaiter waiter(shell_test_api.get());
- bool is_selecting = false;
- waiter.IsOverviewSelecting(&is_selecting);
- return is_selecting;
-}
-
int GetDetachY(TabStrip* tab_strip) {
return std::max(TabDragController::kTouchVerticalDetachMagnetism,
TabDragController::kVerticalDetachMagnetism) +
@@ -48,11 +40,9 @@
// constructed.
class NextFrameWaiter {
public:
- NextFrameWaiter() : shell_test_api_(test::GetShellTestApi()) {
- shell_test_api_->WaitForNextFrame(base::BindOnce(
+ NextFrameWaiter() {
+ ash::ShellTestApi().WaitForNextFrame(base::BindOnce(
&NextFrameWaiter::OnFramePresented, base::Unretained(this)));
- // Flush to ensure the call has gone through.
- shell_test_api_.FlushForTesting();
}
~NextFrameWaiter() { EXPECT_TRUE(frame_presented_); }
@@ -72,7 +62,6 @@
run_loop_->Quit();
}
- ash::mojom::ShellTestApiPtr shell_test_api_;
bool frame_presented_ = false;
std::unique_ptr<base::RunLoop> run_loop_;
@@ -121,7 +110,7 @@
for (int i = 0; i < count; ++i) {
drag_position += delta;
- test::WaitForNoPointerHoldLock(/*wait_for_changes=*/false);
+ ash::ShellTestApi().WaitForNoPointerHoldLock();
NextFrameWaiter waiter;
ASSERT_TRUE(
ui_controls::SendMouseMove(drag_position.x(), drag_position.y()));
@@ -163,7 +152,7 @@
browser_screen_bounds.CenterPoint().x(),
browser_screen_bounds.y() + browser_view->GetTabStripHeight() / 2);
- test::WaitForNoPointerHoldLock();
+ ash::ShellTestApi().WaitForNoPointerHoldLock();
ASSERT_TRUE(
ui_test_utils::SendMouseMoveSync(start_position) &&
ui_test_utils::SendMouseEventsSync(ui_controls::LEFT, ui_controls::DOWN));
@@ -180,7 +169,7 @@
constexpr int kSteps = 20;
gfx::Vector2d delta(0, drag_length / kSteps);
ContinueDrag(start_position, delta, kSteps);
- EXPECT_TRUE(IsOverviewSelecting());
+ EXPECT_TRUE(ash::ShellTestApi().IsOverviewSelecting());
}
IN_PROC_BROWSER_TEST_F(DragToOverviewTest, DragTab) {
@@ -195,7 +184,7 @@
gfx::Point drag_position(ui_test_utils::GetCenterInScreenCoordinates(
browser_view->tabstrip()->tab_at(0)));
- test::WaitForNoPointerHoldLock();
+ ash::ShellTestApi().WaitForNoPointerHoldLock();
ASSERT_TRUE(
ui_test_utils::SendMouseMoveSync(drag_position) &&
ui_test_utils::SendMouseEventsSync(ui_controls::LEFT, ui_controls::DOWN));
@@ -210,7 +199,7 @@
gfx::Vector2d delta(0, drag_length / kSteps);
// Drag tab far enough to detach.
- test::WaitForNoPointerHoldLock();
+ ash::ShellTestApi().WaitForNoPointerHoldLock();
drag_position.Offset(0, GetDetachY(browser_view->tabstrip()));
ui_controls::SendMouseMoveNotifyWhenDone(
drag_position.x(), drag_position.y(),
diff --git a/chrome/browser/ui/ash/launcher_animations_interactive_uitest.cc b/chrome/browser/ui/ash/launcher_animations_interactive_uitest.cc
index f171b2c..ad2ae58 100644
--- a/chrome/browser/ui/ash/launcher_animations_interactive_uitest.cc
+++ b/chrome/browser/ui/ash/launcher_animations_interactive_uitest.cc
@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "ash/public/cpp/test/shell_test_api.h"
#include "ash/public/interfaces/app_list_view.mojom.h"
#include "base/bind.h"
#include "base/macros.h"
#include "base/run_loop.h"
#include "base/task/post_task.h"
#include "chrome/browser/ui/app_list/test/chrome_app_list_test_support.h"
-#include "chrome/browser/ui/ash/ash_test_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
@@ -59,30 +59,22 @@
// use the 1st browser window regardless of number of windows created.
BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser());
aura::Window* browser_window = browser_view->GetWidget()->GetNativeWindow();
- ash::mojom::ShellTestApiPtr shell_test_api = test::GetShellTestApi();
- {
- base::RunLoop waiter;
- shell_test_api->WaitForLauncherAnimationState(
- ash::mojom::AppListViewState::kFullscreenAllApps, waiter.QuitClosure());
- ui_controls::SendKeyPress(browser_window, ui::VKEY_BROWSER_SEARCH,
- /*control=*/false,
- /*shift=*/true,
- /*alt=*/false,
- /* command = */ false);
- waiter.Run();
- }
- {
- base::RunLoop waiter;
- shell_test_api->WaitForLauncherAnimationState(
- ash::mojom::AppListViewState::kClosed, waiter.QuitClosure());
- ui_controls::SendKeyPress(browser_window, ui::VKEY_BROWSER_SEARCH,
- /*control=*/false,
- /*shift=*/true,
- /*alt=*/false,
- /* command = */ false);
+ ash::ShellTestApi shell_test_api;
+ ui_controls::SendKeyPress(browser_window, ui::VKEY_BROWSER_SEARCH,
+ /*control=*/false,
+ /*shift=*/true,
+ /*alt=*/false,
+ /* command = */ false);
+ shell_test_api.WaitForLauncherAnimationState(
+ ash::mojom::AppListViewState::kFullscreenAllApps);
- waiter.Run();
- }
+ ui_controls::SendKeyPress(browser_window, ui::VKEY_BROWSER_SEARCH,
+ /*control=*/false,
+ /*shift=*/true,
+ /*alt=*/false,
+ /* command = */ false);
+ shell_test_api.WaitForLauncherAnimationState(
+ ash::mojom::AppListViewState::kClosed);
}
IN_PROC_BROWSER_TEST_F(LauncherAnimationsTest, Peeking) {
@@ -91,29 +83,22 @@
// use the 1st browser window regardless of number of windows created.
BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser());
aura::Window* browser_window = browser_view->GetWidget()->GetNativeWindow();
- ash::mojom::ShellTestApiPtr shell_test_api = test::GetShellTestApi();
- {
- base::RunLoop waiter;
- shell_test_api->WaitForLauncherAnimationState(
- ash::mojom::AppListViewState::kPeeking, waiter.QuitClosure());
- ui_controls::SendKeyPress(browser_window, ui::VKEY_BROWSER_SEARCH,
- /*control=*/false,
- /*shift=*/false,
- /*alt=*/false,
- /* command = */ false);
- waiter.Run();
- }
- {
- base::RunLoop waiter;
- shell_test_api->WaitForLauncherAnimationState(
- ash::mojom::AppListViewState::kClosed, waiter.QuitClosure());
- ui_controls::SendKeyPress(browser_window, ui::VKEY_BROWSER_SEARCH,
- /*control=*/false,
- /*shift=*/false,
- /*alt=*/false,
- /* command = */ false);
- waiter.Run();
- }
+ ash::ShellTestApi shell_test_api;
+ ui_controls::SendKeyPress(browser_window, ui::VKEY_BROWSER_SEARCH,
+ /*control=*/false,
+ /*shift=*/false,
+ /*alt=*/false,
+ /* command = */ false);
+ shell_test_api.WaitForLauncherAnimationState(
+ ash::mojom::AppListViewState::kPeeking);
+
+ ui_controls::SendKeyPress(browser_window, ui::VKEY_BROWSER_SEARCH,
+ /*control=*/false,
+ /*shift=*/false,
+ /*alt=*/false,
+ /* command = */ false);
+ shell_test_api.WaitForLauncherAnimationState(
+ ash::mojom::AppListViewState::kClosed);
}
IN_PROC_BROWSER_TEST_F(LauncherAnimationsTest, Half) {
@@ -122,44 +107,34 @@
// use the 1st browser window regardless of number of windows created.
BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser());
aura::Window* browser_window = browser_view->GetWidget()->GetNativeWindow();
- ash::mojom::ShellTestApiPtr shell_test_api = test::GetShellTestApi();
- {
- // Hit the search key; it should switch to kPeeking state.
- base::RunLoop waiter;
- shell_test_api->WaitForLauncherAnimationState(
- ash::mojom::AppListViewState::kPeeking, waiter.QuitClosure());
- ui_controls::SendKeyPress(browser_window, ui::VKEY_BROWSER_SEARCH,
- /*control=*/false,
- /*shift=*/false,
- /*alt=*/false,
- /* command = */ false);
- waiter.Run();
- }
- {
- // Type some query in the launcher; it should show search results in kHalf
- // state.
- base::RunLoop waiter;
- shell_test_api->WaitForLauncherAnimationState(
- ash::mojom::AppListViewState::kHalf, waiter.QuitClosure());
- ui_controls::SendKeyPress(browser_window, ui::VKEY_A,
- /*control=*/false,
- /*shift=*/false,
- /*alt=*/false,
- /* command = */ false);
- waiter.Run();
- }
- {
- // Search key to close the launcher.
- base::RunLoop waiter;
- shell_test_api->WaitForLauncherAnimationState(
- ash::mojom::AppListViewState::kClosed, waiter.QuitClosure());
- ui_controls::SendKeyPress(browser_window, ui::VKEY_BROWSER_SEARCH,
- /*control=*/false,
- /*shift=*/false,
- /*alt=*/false,
- /* command = */ false);
- waiter.Run();
- }
+ ash::ShellTestApi shell_test_api;
+ // Hit the search key; it should switch to kPeeking state.
+ ui_controls::SendKeyPress(browser_window, ui::VKEY_BROWSER_SEARCH,
+ /*control=*/false,
+ /*shift=*/false,
+ /*alt=*/false,
+ /* command = */ false);
+ shell_test_api.WaitForLauncherAnimationState(
+ ash::mojom::AppListViewState::kPeeking);
+
+ // Type some query in the launcher; it should show search results in kHalf
+ // state.
+ ui_controls::SendKeyPress(browser_window, ui::VKEY_A,
+ /*control=*/false,
+ /*shift=*/false,
+ /*alt=*/false,
+ /* command = */ false);
+ shell_test_api.WaitForLauncherAnimationState(
+ ash::mojom::AppListViewState::kHalf);
+
+ // Search key to close the launcher.
+ ui_controls::SendKeyPress(browser_window, ui::VKEY_BROWSER_SEARCH,
+ /*control=*/false,
+ /*shift=*/false,
+ /*alt=*/false,
+ /* command = */ false);
+ shell_test_api.WaitForLauncherAnimationState(
+ ash::mojom::AppListViewState::kClosed);
}
IN_PROC_BROWSER_TEST_F(LauncherAnimationsTest, FullscreenSearch) {
@@ -168,54 +143,41 @@
// use the 1st browser window regardless of number of windows created.
BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser());
aura::Window* browser_window = browser_view->GetWidget()->GetNativeWindow();
- ash::mojom::ShellTestApiPtr shell_test_api = test::GetShellTestApi();
- {
- // Hit the search key; it should switch to the kPeeking state.
- base::RunLoop waiter;
- shell_test_api->WaitForLauncherAnimationState(
- ash::mojom::AppListViewState::kPeeking, waiter.QuitClosure());
- ui_controls::SendKeyPress(browser_window, ui::VKEY_BROWSER_SEARCH,
- /*control=*/false,
- /*shift=*/false,
- /*alt=*/false,
- /* command = */ false);
- waiter.Run();
- }
- {
- // Type some query; it should show the search results in the kHalf state.
- base::RunLoop waiter;
- shell_test_api->WaitForLauncherAnimationState(
- ash::mojom::AppListViewState::kHalf, waiter.QuitClosure());
- ui_controls::SendKeyPress(browser_window, ui::VKEY_A,
- /*control=*/false,
- /*shift=*/false,
- /*alt=*/false,
- /* command = */ false);
- waiter.Run();
- }
- {
- // Shift+search key; it should expand to fullscreen with search results
- // (i.e. kFullscreenSearch state).
- base::RunLoop waiter;
- shell_test_api->WaitForLauncherAnimationState(
- ash::mojom::AppListViewState::kFullscreenSearch, waiter.QuitClosure());
- ui_controls::SendKeyPress(browser_window, ui::VKEY_BROWSER_SEARCH,
- /*control=*/false,
- /*shift=*/true,
- /*alt=*/false,
- /* command = */ false);
- waiter.Run();
- }
- {
- // Search key to close the launcher.
- base::RunLoop waiter;
- shell_test_api->WaitForLauncherAnimationState(
- ash::mojom::AppListViewState::kClosed, waiter.QuitClosure());
- ui_controls::SendKeyPress(browser_window, ui::VKEY_BROWSER_SEARCH,
- /*control=*/false,
- /*shift=*/false,
- /*alt=*/false,
- /* command = */ false);
- waiter.Run();
- }
+ ash::ShellTestApi shell_test_api;
+ // Hit the search key; it should switch to the kPeeking state.
+ ui_controls::SendKeyPress(browser_window, ui::VKEY_BROWSER_SEARCH,
+ /*control=*/false,
+ /*shift=*/false,
+ /*alt=*/false,
+ /* command = */ false);
+ shell_test_api.WaitForLauncherAnimationState(
+ ash::mojom::AppListViewState::kPeeking);
+
+ // Type some query; it should show the search results in the kHalf state.
+ ui_controls::SendKeyPress(browser_window, ui::VKEY_A,
+ /*control=*/false,
+ /*shift=*/false,
+ /*alt=*/false,
+ /* command = */ false);
+ shell_test_api.WaitForLauncherAnimationState(
+ ash::mojom::AppListViewState::kHalf);
+
+ // Shift+search key; it should expand to fullscreen with search results
+ // (i.e. kFullscreenSearch state).
+ ui_controls::SendKeyPress(browser_window, ui::VKEY_BROWSER_SEARCH,
+ /*control=*/false,
+ /*shift=*/true,
+ /*alt=*/false,
+ /* command = */ false);
+ shell_test_api.WaitForLauncherAnimationState(
+ ash::mojom::AppListViewState::kFullscreenSearch);
+
+ // Search key to close the launcher.
+ ui_controls::SendKeyPress(browser_window, ui::VKEY_BROWSER_SEARCH,
+ /*control=*/false,
+ /*shift=*/false,
+ /*alt=*/false,
+ /* command = */ false);
+ shell_test_api.WaitForLauncherAnimationState(
+ ash::mojom::AppListViewState::kClosed);
}
diff --git a/chrome/browser/ui/ash/launcher_drag_interactive_uitest.cc b/chrome/browser/ui/ash/launcher_drag_interactive_uitest.cc
index e2fec830..601add7 100644
--- a/chrome/browser/ui/ash/launcher_drag_interactive_uitest.cc
+++ b/chrome/browser/ui/ash/launcher_drag_interactive_uitest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "ash/public/cpp/app_list/app_list_config.h"
+#include "ash/public/cpp/test/shell_test_api.h"
#include "ash/public/interfaces/app_list_view.mojom.h"
#include "ash/shelf/shelf_constants.h"
#include "base/macros.h"
@@ -10,7 +11,6 @@
#include "base/strings/stringprintf.h"
#include "base/task/post_task.h"
#include "chrome/browser/ui/app_list/test/chrome_app_list_test_support.h"
-#include "chrome/browser/ui/ash/ash_test_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/test/base/perf/drag_event_generator.h"
@@ -60,11 +60,7 @@
IN_PROC_BROWSER_TEST_F(LauncherDragTest, Open) {
BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser());
aura::Window* browser_window = browser_view->GetWidget()->GetNativeWindow();
- ash::mojom::ShellTestApiPtr shell_test_api = test::GetShellTestApi();
-
- base::RunLoop waiter;
- shell_test_api->WaitForLauncherAnimationState(
- ash::mojom::AppListViewState::kFullscreenAllApps, waiter.QuitClosure());
+ ash::ShellTestApi shell_test_api;
gfx::Rect display_bounds = GetDisplayBounds(browser_window);
gfx::Point start_point =
@@ -78,29 +74,22 @@
/*touch=*/true);
generator.Wait();
- waiter.Run();
+ shell_test_api.WaitForLauncherAnimationState(
+ ash::mojom::AppListViewState::kFullscreenAllApps);
}
// Drag to close the launcher.
IN_PROC_BROWSER_TEST_F(LauncherDragTest, Close) {
BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser());
aura::Window* browser_window = browser_view->GetWidget()->GetNativeWindow();
- ash::mojom::ShellTestApiPtr shell_test_api = test::GetShellTestApi();
- {
- base::RunLoop waiter;
- shell_test_api->WaitForLauncherAnimationState(
- ash::mojom::AppListViewState::kFullscreenAllApps, waiter.QuitClosure());
- ui_controls::SendKeyPress(browser_window, ui::VKEY_BROWSER_SEARCH,
- /*control=*/false,
- /*shift=*/true,
- /*alt=*/false,
- /*command=*/false);
- waiter.Run();
- }
-
- base::RunLoop waiter;
- shell_test_api->WaitForLauncherAnimationState(
- ash::mojom::AppListViewState::kClosed, waiter.QuitClosure());
+ ash::ShellTestApi shell_test_api;
+ ui_controls::SendKeyPress(browser_window, ui::VKEY_BROWSER_SEARCH,
+ /*control=*/false,
+ /*shift=*/true,
+ /*alt=*/false,
+ /*command=*/false);
+ shell_test_api.WaitForLauncherAnimationState(
+ ash::mojom::AppListViewState::kFullscreenAllApps);
gfx::Rect display_bounds = GetDisplayBounds(browser_window);
gfx::Point start_point = gfx::Point(display_bounds.width() / 4, 10);
@@ -112,5 +101,6 @@
/*touch=*/true);
generator.Wait();
- waiter.Run();
+ shell_test_api.WaitForLauncherAnimationState(
+ ash::mojom::AppListViewState::kClosed);
}
diff --git a/chrome/browser/ui/ash/overview_animations_interactive_uitest.cc b/chrome/browser/ui/ash/overview_animations_interactive_uitest.cc
index f07e045..404bc617 100644
--- a/chrome/browser/ui/ash/overview_animations_interactive_uitest.cc
+++ b/chrome/browser/ui/ash/overview_animations_interactive_uitest.cc
@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "ash/public/cpp/test/shell_test_api.h"
#include "base/macros.h"
#include "base/run_loop.h"
#include "base/task/post_task.h"
-#include "chrome/browser/ui/ash/ash_test_util.h"
#include "chrome/browser/ui/ash/tablet_mode_client_test_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
@@ -83,15 +83,15 @@
/*shift=*/false,
/*alt=*/false,
/*command=*/false);
- test::WaitForOverviewAnimationState(
- ash::mojom::OverviewAnimationState::kEnterAnimationComplete);
+ ash::ShellTestApi().WaitForOverviewAnimationState(
+ ash::OverviewAnimationState::kEnterAnimationComplete);
ui_controls::SendKeyPress(browser_window, ui::VKEY_MEDIA_LAUNCH_APP1,
/*control=*/false,
/*shift=*/false,
/*alt=*/false,
/*command=*/false);
- test::WaitForOverviewAnimationState(
- ash::mojom::OverviewAnimationState::kExitAnimationComplete);
+ ash::ShellTestApi().WaitForOverviewAnimationState(
+ ash::OverviewAnimationState::kExitAnimationComplete);
}
INSTANTIATE_TEST_SUITE_P(,
diff --git a/chrome/browser/ui/ash/overview_window_drag_interactive_uitest.cc b/chrome/browser/ui/ash/overview_window_drag_interactive_uitest.cc
index 4f56217..05b009e3 100644
--- a/chrome/browser/ui/ash/overview_window_drag_interactive_uitest.cc
+++ b/chrome/browser/ui/ash/overview_window_drag_interactive_uitest.cc
@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "ash/public/cpp/test/shell_test_api.h"
#include "ash/public/cpp/window_properties.h"
#include "ash/public/cpp/window_state_type.h"
#include "base/macros.h"
#include "base/run_loop.h"
#include "base/task/post_task.h"
#include "chrome/browser/chrome_notification_types.h"
-#include "chrome/browser/ui/ash/ash_test_util.h"
#include "chrome/browser/ui/ash/tablet_mode_client_test_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
@@ -132,8 +132,8 @@
/*shift=*/false,
/*alt=*/false,
/*command=*/false);
- test::WaitForOverviewAnimationState(
- ash::mojom::OverviewAnimationState::kEnterAnimationComplete);
+ ash::ShellTestApi().WaitForOverviewAnimationState(
+ ash::OverviewAnimationState::kEnterAnimationComplete);
gfx::Size display_size = GetDisplaySize(browser_window);
gfx::Point start_point = GetStartLocation(display_size);
gfx::Point end_point(start_point);
@@ -155,8 +155,8 @@
/*shift=*/false,
/*alt=*/false,
/*command=*/false);
- test::WaitForOverviewAnimationState(
- ash::mojom::OverviewAnimationState::kEnterAnimationComplete);
+ ash::ShellTestApi().WaitForOverviewAnimationState(
+ ash::OverviewAnimationState::kEnterAnimationComplete);
content::WindowedNotificationObserver waiter(
chrome::NOTIFICATION_BROWSER_CLOSED,
@@ -185,8 +185,8 @@
/*shift=*/false,
/*alt=*/false,
/*command=*/false);
- test::WaitForOverviewAnimationState(
- ash::mojom::OverviewAnimationState::kEnterAnimationComplete);
+ ash::ShellTestApi().WaitForOverviewAnimationState(
+ ash::OverviewAnimationState::kEnterAnimationComplete);
gfx::Point start_point = GetStartLocation(GetDisplaySize(browser_window));
gfx::Point end_point(start_point);
diff --git a/chrome/browser/ui/ash/screen_rotation_interactive_uitest.cc b/chrome/browser/ui/ash/screen_rotation_interactive_uitest.cc
index 87d9b02f..e12b763 100644
--- a/chrome/browser/ui/ash/screen_rotation_interactive_uitest.cc
+++ b/chrome/browser/ui/ash/screen_rotation_interactive_uitest.cc
@@ -9,7 +9,6 @@
#include "base/macros.h"
#include "base/run_loop.h"
#include "base/task/post_task.h"
-#include "chrome/browser/ui/ash/ash_test_util.h"
#include "chrome/browser/ui/ash/tablet_mode_client_test_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
diff --git a/chrome/browser/ui/ash/split_view_interactive_uitest.cc b/chrome/browser/ui/ash/split_view_interactive_uitest.cc
index 69e9791..d01c2e9 100644
--- a/chrome/browser/ui/ash/split_view_interactive_uitest.cc
+++ b/chrome/browser/ui/ash/split_view_interactive_uitest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "ash/public/cpp/ash_switches.h"
+#include "ash/public/cpp/test/shell_test_api.h"
#include "ash/shell.h"
#include "ash/wm/splitview/split_view_controller.h"
#include "base/macros.h"
@@ -10,7 +11,6 @@
#include "base/system/sys_info.h"
#include "base/task/post_task.h"
#include "base/test/bind_test_util.h"
-#include "chrome/browser/ui/ash/ash_test_util.h"
#include "chrome/browser/ui/ash/tablet_mode_client_test_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
@@ -66,7 +66,7 @@
run_loop_->Run();
EXPECT_FALSE(waiting_for_frame_);
}
- test::WaitForNoPointerHoldLock();
+ ash::ShellTestApi().WaitForNoPointerHoldLock();
} while (waiting_for_frame_);
}
@@ -130,7 +130,7 @@
shell->split_view_controller()->SnapWindow(browser_widget->GetNativeWindow(),
ash::SplitViewController::RIGHT);
- test::WaitForNoPointerHoldLock();
+ ash::ShellTestApi().WaitForNoPointerHoldLock();
const gfx::Size display_size =
display::Screen::GetScreen()->GetPrimaryDisplay().bounds().size();
diff --git a/chrome/browser/ui/ash/tablet_mode_client_test_util.cc b/chrome/browser/ui/ash/tablet_mode_client_test_util.cc
index 94f5945..be9ce68 100644
--- a/chrome/browser/ui/ash/tablet_mode_client_test_util.cc
+++ b/chrome/browser/ui/ash/tablet_mode_client_test_util.cc
@@ -2,8 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ash/public/interfaces/constants.mojom.h"
-#include "ash/public/interfaces/shell_test_api.test-mojom.h"
+#include "ash/public/cpp/test/shell_test_api.h"
#include "base/run_loop.h"
#include "chrome/browser/ui/ash/tablet_mode_client.h"
#include "chrome/browser/ui/ash/tablet_mode_client_observer.h"
@@ -50,11 +49,7 @@
void SetAndWaitForTabletMode(bool enabled) {
ASSERT_NE(enabled, TabletModeClient::Get()->tablet_mode_enabled());
- ash::mojom::ShellTestApiPtr shell_test_api;
- content::ServiceManagerConnection::GetForProcess()
- ->GetConnector()
- ->BindInterface(ash::mojom::kServiceName, &shell_test_api);
- shell_test_api->EnableTabletModeWindowManager(enabled);
+ ash::ShellTestApi().EnableTabletModeWindowManager(enabled);
TestTabletModeClientObserver observer(enabled);
observer.run_loop()->Run();
diff --git a/chrome/browser/ui/ash/tablet_mode_transition_interactive_uitest.cc b/chrome/browser/ui/ash/tablet_mode_transition_interactive_uitest.cc
index b0a90e0c..72e2e49 100644
--- a/chrome/browser/ui/ash/tablet_mode_transition_interactive_uitest.cc
+++ b/chrome/browser/ui/ash/tablet_mode_transition_interactive_uitest.cc
@@ -6,7 +6,6 @@
#include "base/macros.h"
#include "base/run_loop.h"
#include "base/task/post_task.h"
-#include "chrome/browser/ui/ash/ash_test_util.h"
#include "chrome/browser/ui/ash/tablet_mode_client_test_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash_browsertest.cc b/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash_browsertest.cc
index 6583755..e433ab9 100644
--- a/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash_browsertest.cc
+++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash_browsertest.cc
@@ -14,8 +14,6 @@
#include "ash/public/cpp/window_properties.h"
#include "ash/public/interfaces/constants.mojom.h"
#include "ash/public/interfaces/shelf_test_api.test-mojom-test-utils.h"
-#include "ash/public/interfaces/shelf_test_api.test-mojom.h"
-#include "ash/public/interfaces/shell_test_api.test-mojom-test-utils.h"
#include "ash/public/interfaces/window_pin_type.mojom.h"
#include "ash/shell.h" // mash-ok
#include "ash/wm/overview/overview_controller.h" // mash-ok
diff --git a/chrome/browser/ui/views/frame/immersive_mode_controller_ash_browsertest.cc b/chrome/browser/ui/views/frame/immersive_mode_controller_ash_browsertest.cc
index 7f025a7..6566b65 100644
--- a/chrome/browser/ui/views/frame/immersive_mode_controller_ash_browsertest.cc
+++ b/chrome/browser/ui/views/frame/immersive_mode_controller_ash_browsertest.cc
@@ -4,8 +4,6 @@
#include "ash/public/cpp/caption_buttons/frame_caption_button_container_view.h"
#include "ash/public/cpp/immersive/immersive_fullscreen_controller_test_api.h"
-#include "ash/public/interfaces/constants.mojom.h"
-#include "ash/public/interfaces/shell_test_api.test-mojom.h"
#include "base/macros.h"
#include "base/test/test_mock_time_task_runner.h"
#include "chrome/browser/extensions/extension_browsertest.h"
diff --git a/chrome/browser/ui/views/select_file_dialog_extension_browsertest.cc b/chrome/browser/ui/views/select_file_dialog_extension_browsertest.cc
index a85863b..03bfe52 100644
--- a/chrome/browser/ui/views/select_file_dialog_extension_browsertest.cc
+++ b/chrome/browser/ui/views/select_file_dialog_extension_browsertest.cc
@@ -7,9 +7,7 @@
#include <memory>
#include "ash/keyboard/ui/public/keyboard_switches.h"
-#include "ash/public/interfaces/constants.mojom.h"
-#include "ash/public/interfaces/shell_test_api.test-mojom-test-utils.h"
-#include "ash/public/interfaces/shell_test_api.test-mojom.h"
+#include "ash/public/cpp/test/shell_test_api.h"
#include "base/bind_helpers.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
@@ -464,12 +462,7 @@
test::SetAndWaitForTabletMode(true);
// Enable the virtual keyboard.
- ash::mojom::ShellTestApiPtr shell_test_api;
- content::ServiceManagerConnection::GetForProcess()
- ->GetConnector()
- ->BindInterface(ash::mojom::kServiceName, &shell_test_api);
- ash::mojom::ShellTestApiAsyncWaiter waiter(shell_test_api.get());
- waiter.EnableVirtualKeyboard();
+ ash::ShellTestApi().EnableVirtualKeyboard();
auto* client = ChromeKeyboardControllerClient::Get();
EXPECT_FALSE(client->is_keyboard_visible());
diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc
index d6af447..8134079e 100644
--- a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc
+++ b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc
@@ -70,10 +70,8 @@
#if defined(OS_CHROMEOS)
#include "ash/public/cpp/ash_switches.h"
#include "ash/public/cpp/immersive/immersive_fullscreen_controller_test_api.h"
+#include "ash/public/cpp/test/shell_test_api.h"
#include "ash/public/cpp/window_properties.h"
-#include "ash/public/interfaces/constants.mojom.h"
-#include "ash/public/interfaces/shell_test_api.test-mojom-test-utils.h"
-#include "ash/public/interfaces/shell_test_api.test-mojom.h"
#include "ash/shell.h"
#include "ash/wm/splitview/split_view_controller.h"
#include "ash/wm/window_state.h"
@@ -425,7 +423,8 @@
root_ = browser()->window()->GetNativeWindow()->GetRootWindow();
// Disable flings which might otherwise inadvertently be generated from
// tests' touch events.
- SetMinFlingVelocity(std::numeric_limits<float>::max());
+ ui::GestureConfiguration::GetInstance()->set_min_fling_velocity(
+ std::numeric_limits<float>::max());
aura::test::WaitForAllChangesToComplete();
#endif
#if defined(OS_MACOSX)
@@ -442,18 +441,6 @@
}
#if defined(OS_CHROMEOS)
- void SetMinFlingVelocity(float velocity) {
- ui::GestureConfiguration::GetInstance()->set_min_fling_velocity(velocity);
- ash::mojom::ShellTestApiPtr shell_test_api;
- content::ServiceManagerConnection::GetForProcess()
- ->GetConnector()
- ->BindInterface(ash::mojom::kServiceName, &shell_test_api);
- shell_test_api->SetMinFlingVelocity(velocity);
- shell_test_api.FlushForTesting();
- }
-#endif
-
-#if defined(OS_CHROMEOS)
bool SendTouchEventsSync(int action, int id, const gfx::Point& location) {
base::RunLoop run_loop(base::RunLoop::Type::kNestableTasksAllowed);
if (!ui_controls::SendTouchEventsNotifyWhenDone(
@@ -2795,11 +2782,7 @@
ASSERT_EQ(2u, browser_list->size());
// Switching display mode should cancel the drag operation.
- ash::mojom::ShellTestApiPtr shell_test_api;
- content::ServiceManagerConnection::GetForProcess()
- ->GetConnector()
- ->BindInterface(ash::mojom::kServiceName, &shell_test_api);
- shell_test_api->AddRemoveDisplay();
+ ash::ShellTestApi().AddRemoveDisplay();
}
// Invoked from the nested run loop.
@@ -3075,7 +3058,7 @@
// Reduce the minimum fling velocity for this specific test case to cause the
// fling-down gesture in the middle of tab-dragging. This should end up with
// minimizing the window. See https://crbug.com/902897 for the details.
- SetMinFlingVelocity(1);
+ ui::GestureConfiguration::GetInstance()->set_min_fling_velocity(1);
TabStrip* tab_strip = GetTabStripForBrowser(browser());
const gfx::Point tab_0_center =
@@ -3107,7 +3090,7 @@
IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTestTouch,
FlingOnStartingDrag) {
- SetMinFlingVelocity(1);
+ ui::GestureConfiguration::GetInstance()->set_min_fling_velocity(1);
AddTabAndResetBrowser(browser());
TabStrip* tab_strip = GetTabStripForBrowser(browser());
const gfx::Point tab_0_center =
diff --git a/chrome/browser/ui/webui/chromeos/system_web_dialog_browsertest.cc b/chrome/browser/ui/webui/chromeos/system_web_dialog_browsertest.cc
index 4069512d..4ba517b 100644
--- a/chrome/browser/ui/webui/chromeos/system_web_dialog_browsertest.cc
+++ b/chrome/browser/ui/webui/chromeos/system_web_dialog_browsertest.cc
@@ -4,9 +4,7 @@
#include "chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h"
-#include "ash/public/interfaces/constants.mojom.h"
-#include "ash/public/interfaces/shell_test_api.test-mojom-test-utils.h"
-#include "ash/public/interfaces/shell_test_api.test-mojom.h"
+#include "ash/public/cpp/test/shell_test_api.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/chromeos/login/login_manager_test.h"
#include "chrome/browser/chromeos/login/startup_utils.h"
@@ -42,15 +40,7 @@
// Wait for window visibility to stabilize.
aura::test::WaitForAllChangesToComplete();
- // Connect to the ash test interface.
- ash::mojom::ShellTestApiPtr shell_test_api;
- content::ServiceManagerConnection::GetForProcess()
- ->GetConnector()
- ->BindInterface(ash::mojom::kServiceName, &shell_test_api);
- ash::mojom::ShellTestApiAsyncWaiter waiter(shell_test_api.get());
- bool modal_open = false;
- waiter.IsSystemModalWindowOpen(&modal_open);
- return modal_open;
+ return ash::ShellTestApi().IsSystemModalWindowOpen();
}
class MockSystemWebDialog : public SystemWebDialogDelegate {
diff --git a/components/exo/client_controlled_shell_surface_unittest.cc b/components/exo/client_controlled_shell_surface_unittest.cc
index 2f338db..f10d190 100644
--- a/components/exo/client_controlled_shell_surface_unittest.cc
+++ b/components/exo/client_controlled_shell_surface_unittest.cc
@@ -10,10 +10,10 @@
#include "ash/frame/wide_frame_view.h"
#include "ash/public/cpp/caption_buttons/caption_button_model.h"
#include "ash/public/cpp/caption_buttons/frame_caption_button_container_view.h"
+#include "ash/public/cpp/test/shell_test_api.h"
#include "ash/public/cpp/window_properties.h"
#include "ash/public/interfaces/window_pin_type.mojom.h"
#include "ash/shell.h"
-#include "ash/shell_test_api.h"
#include "ash/system/unified/unified_system_tray.h"
#include "ash/wm/drag_window_resizer.h"
#include "ash/wm/overview/overview_controller.h"
@@ -65,8 +65,7 @@
using ClientControlledShellSurfaceTest = test::ExoTestBase;
bool HasBackdrop() {
- ash::WorkspaceController* wc =
- ash::ShellTestApi(ash::Shell::Get()).workspace_controller();
+ ash::WorkspaceController* wc = ash::ShellTestApi().workspace_controller();
return !!ash::WorkspaceControllerTestApi(wc).GetBackdropWindow();
}
diff --git a/components/exo/shell_surface_unittest.cc b/components/exo/shell_surface_unittest.cc
index df5f52a..43df35f1 100644
--- a/components/exo/shell_surface_unittest.cc
+++ b/components/exo/shell_surface_unittest.cc
@@ -7,8 +7,8 @@
#include "ash/accessibility/accessibility_delegate.h"
#include "ash/frame/non_client_frame_view_ash.h"
#include "ash/public/cpp/shell_window_ids.h"
+#include "ash/public/cpp/test/shell_test_api.h"
#include "ash/shell.h"
-#include "ash/shell_test_api.h"
#include "ash/wm/window_state.h"
#include "ash/wm/wm_event.h"
#include "ash/wm/workspace/workspace_window_resizer.h"
@@ -46,8 +46,7 @@
using ShellSurfaceTest = test::ExoTestBase;
bool HasBackdrop() {
- ash::WorkspaceController* wc =
- ash::ShellTestApi(ash::Shell::Get()).workspace_controller();
+ ash::WorkspaceController* wc = ash::ShellTestApi().workspace_controller();
return !!ash::WorkspaceControllerTestApi(wc).GetBackdropWindow();
}