Commit 5f0e686f authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Use the configured screen position client by default for Aura in tests.

This will allow enabling a previously disabled test for Windows.

Bug: none
Change-Id: I58a0a62db1228e303de71519914a6b744711ce97
Reviewed-on: https://chromium-review.googlesource.com/c/1338945
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611281}
parent d8b6d2b8
...@@ -635,8 +635,7 @@ IN_PROC_BROWSER_TEST_P(ImmersiveModeBrowserViewTest, ...@@ -635,8 +635,7 @@ IN_PROC_BROWSER_TEST_P(ImmersiveModeBrowserViewTest,
ui::test::EventGenerator event_generator(window->GetRootWindow()); ui::test::EventGenerator event_generator(window->GetRootWindow());
gfx::Size button_size = gfx::Size button_size =
ash::GetAshLayoutSize(ash::AshLayoutSize::kBrowserCaptionMaximized); ash::GetAshLayoutSize(ash::AshLayoutSize::kBrowserCaptionMaximized);
gfx::Point point_in_restore_button( gfx::Point point_in_restore_button(window->GetBoundsInScreen().top_right());
window->GetBoundsInRootWindow().top_right());
point_in_restore_button.Offset(-2 * button_size.width(), point_in_restore_button.Offset(-2 * button_size.width(),
button_size.height() / 2); button_size.height() / 2);
......
...@@ -28,14 +28,13 @@ ...@@ -28,14 +28,13 @@
namespace { namespace {
// Get the bounds of the browser shortcut item in the root window space. // Get the bounds of the browser shortcut item in screen space.
gfx::Rect GetChromeIconBoundsForRootWindow(aura::Window* root) { gfx::Rect GetChromeIconBoundsInScreen(aura::Window* root) {
ash::ShelfView* shelf_view = ash::ShelfView* shelf_view =
ash::Shelf::ForWindow(root)->GetShelfViewForTesting(); ash::Shelf::ForWindow(root)->GetShelfViewForTesting();
const views::ViewModel* view_model = shelf_view->view_model_for_test(); const views::ViewModel* view_model = shelf_view->view_model_for_test();
EXPECT_EQ(3, view_model->view_size()); EXPECT_EQ(3, view_model->view_size());
gfx::Rect bounds = view_model->view_at(2)->GetBoundsInScreen(); gfx::Rect bounds = view_model->view_at(2)->GetBoundsInScreen();
wm::ConvertRectFromScreen(root, &bounds);
return bounds; return bounds;
} }
...@@ -45,13 +44,13 @@ void EnsureShelfInitialization() { ...@@ -45,13 +44,13 @@ void EnsureShelfInitialization() {
ash::ShelfView* shelf_view = ash::ShelfView* shelf_view =
ash::Shelf::ForWindow(root)->GetShelfViewForTesting(); ash::Shelf::ForWindow(root)->GetShelfViewForTesting();
ash::ShelfViewTestAPI(shelf_view).RunMessageLoopUntilAnimationsDone(); ash::ShelfViewTestAPI(shelf_view).RunMessageLoopUntilAnimationsDone();
ASSERT_GT(GetChromeIconBoundsForRootWindow(root).height(), 0); ASSERT_GT(GetChromeIconBoundsInScreen(root).height(), 0);
} }
// Launch a new browser window by left-clicking the browser shortcut item. // Launch a new browser window by left-clicking the browser shortcut item.
void OpenBrowserUsingShelfOnRootWindow(aura::Window* root) { void OpenBrowserUsingShelfOnRootWindow(aura::Window* root) {
ui::test::EventGenerator generator(root); ui::test::EventGenerator generator(root);
gfx::Point center = GetChromeIconBoundsForRootWindow(root).CenterPoint(); gfx::Point center = GetChromeIconBoundsInScreen(root).CenterPoint();
generator.MoveMouseTo(center); generator.MoveMouseTo(center);
generator.ClickLeftButton(); generator.ClickLeftButton();
// Ash notifies Chrome that the browser shortcut item was selected. // Ash notifies Chrome that the browser shortcut item was selected.
...@@ -63,7 +62,7 @@ void OpenBrowserUsingShelfOnRootWindow(aura::Window* root) { ...@@ -63,7 +62,7 @@ void OpenBrowserUsingShelfOnRootWindow(aura::Window* root) {
// Launch a new browser window by clicking the "New window" context menu item. // Launch a new browser window by clicking the "New window" context menu item.
void OpenBrowserUsingContextMenuOnRootWindow(aura::Window* root) { void OpenBrowserUsingContextMenuOnRootWindow(aura::Window* root) {
ui::test::EventGenerator generator(root); ui::test::EventGenerator generator(root);
gfx::Point chrome_icon = GetChromeIconBoundsForRootWindow(root).CenterPoint(); gfx::Point chrome_icon = GetChromeIconBoundsInScreen(root).CenterPoint();
generator.MoveMouseTo(chrome_icon); generator.MoveMouseTo(chrome_icon);
generator.PressRightButton(); generator.PressRightButton();
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "chromecast/graphics/accessibility/partial_magnification_controller.h" #include "chromecast/graphics/accessibility/partial_magnification_controller.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/test/aura_test_base.h" #include "ui/aura/test/aura_test_base.h"
#include "ui/aura/test/default_event_generator_delegate.h"
#include "ui/aura/test/test_window_delegate.h" #include "ui/aura/test/test_window_delegate.h"
#include "ui/display/manager/display_manager.h" #include "ui/display/manager/display_manager.h"
#include "ui/events/test/event_generator.h" #include "ui/events/test/event_generator.h"
...@@ -32,25 +31,6 @@ class CastTestWindowDelegate : public aura::test::TestWindowDelegate { ...@@ -32,25 +31,6 @@ class CastTestWindowDelegate : public aura::test::TestWindowDelegate {
DISALLOW_COPY_AND_ASSIGN(CastTestWindowDelegate); DISALLOW_COPY_AND_ASSIGN(CastTestWindowDelegate);
}; };
class TestEventGeneratorDelegate
: public aura::test::DefaultEventGeneratorDelegate {
public:
explicit TestEventGeneratorDelegate(aura::Window* root_window)
: DefaultEventGeneratorDelegate(root_window), root_window_(root_window) {}
~TestEventGeneratorDelegate() override = default;
// aura::test::DefaultEventGeneratorDelegate:
aura::client::ScreenPositionClient* GetScreenPositionClient(
const aura::Window* window) const override {
return aura::client::GetScreenPositionClient(root_window_);
}
private:
aura::Window* root_window_;
DISALLOW_COPY_AND_ASSIGN(TestEventGeneratorDelegate);
};
// Wrapper for PartialMagnificationController that exposes internal state to // Wrapper for PartialMagnificationController that exposes internal state to
// test functions. // test functions.
class PartialMagnificationControllerTestApi { class PartialMagnificationControllerTestApi {
...@@ -109,8 +89,8 @@ class PartialMagnificationControllerTest : public aura::test::AuraTestBase { ...@@ -109,8 +89,8 @@ class PartialMagnificationControllerTest : public aura::test::AuraTestBase {
ui::test::EventGenerator& GetEventGenerator() { ui::test::EventGenerator& GetEventGenerator() {
if (!event_generator_) { if (!event_generator_) {
event_generator_ = std::make_unique<ui::test::EventGenerator>( event_generator_ =
std::make_unique<TestEventGeneratorDelegate>(root_window())); std::make_unique<ui::test::EventGenerator>(root_window());
} }
return *event_generator_.get(); return *event_generator_.get();
} }
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/test/aura_test_base.h" #include "ui/aura/test/aura_test_base.h"
#include "ui/aura/test/default_event_generator_delegate.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/events/test/event_generator.h" #include "ui/events/test/event_generator.h"
#include "ui/wm/core/default_screen_position_client.h" #include "ui/wm/core/default_screen_position_client.h"
...@@ -35,25 +34,6 @@ constexpr int kNumSteps = 5; ...@@ -35,25 +34,6 @@ constexpr int kNumSteps = 5;
} // namespace } // namespace
class TestEventGeneratorDelegate
: public aura::test::DefaultEventGeneratorDelegate {
public:
explicit TestEventGeneratorDelegate(aura::Window* root_window)
: DefaultEventGeneratorDelegate(root_window), root_window_(root_window) {}
~TestEventGeneratorDelegate() override = default;
// aura::test::DefaultEventGeneratorDelegate:
aura::client::ScreenPositionClient* GetScreenPositionClient(
const aura::Window* window) const override {
return aura::client::GetScreenPositionClient(root_window_);
}
private:
aura::Window* root_window_;
DISALLOW_COPY_AND_ASSIGN(TestEventGeneratorDelegate);
};
class MockCastGestureHandler : public CastGestureHandler { class MockCastGestureHandler : public CastGestureHandler {
public: public:
~MockCastGestureHandler() override = default; ~MockCastGestureHandler() override = default;
...@@ -148,8 +128,8 @@ class SideSwipeDetectorTest : public aura::test::AuraTestBase { ...@@ -148,8 +128,8 @@ class SideSwipeDetectorTest : public aura::test::AuraTestBase {
ui::test::EventGenerator& GetEventGenerator() { ui::test::EventGenerator& GetEventGenerator() {
if (!event_generator_) { if (!event_generator_) {
event_generator_ = std::make_unique<ui::test::EventGenerator>( event_generator_ =
std::make_unique<TestEventGeneratorDelegate>(root_window())); std::make_unique<ui::test::EventGenerator>(root_window());
} }
return *event_generator_.get(); return *event_generator_.get();
} }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "ui/aura/test/default_event_generator_delegate.h" #include "ui/aura/test/default_event_generator_delegate.h"
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h" #include "ui/aura/window_tree_host.h"
...@@ -22,7 +23,7 @@ ui::EventTarget* DefaultEventGeneratorDelegate::GetTargetAt( ...@@ -22,7 +23,7 @@ ui::EventTarget* DefaultEventGeneratorDelegate::GetTargetAt(
client::ScreenPositionClient* client::ScreenPositionClient*
DefaultEventGeneratorDelegate::GetScreenPositionClient( DefaultEventGeneratorDelegate::GetScreenPositionClient(
const Window* window) const { const Window* window) const {
return nullptr; return client::GetScreenPositionClient(root_window_);
} }
} // namespace test } // namespace test
......
...@@ -1177,7 +1177,8 @@ TEST_F(WidgetTestInteractive, TouchSelectionQuickMenuIsNotActivated) { ...@@ -1177,7 +1177,8 @@ TEST_F(WidgetTestInteractive, TouchSelectionQuickMenuIsNotActivated) {
RunPendingMessages(); RunPendingMessages();
ui::test::EventGenerator generator(GetRootWindow(widget)); ui::test::EventGenerator generator(GetRootWindow(widget));
generator.GestureTapAt(gfx::Point(10, 10)); generator.GestureTapAt(textfield->GetBoundsInScreen().origin() +
gfx::Vector2d(10, 10));
ShowQuickMenuImmediately(static_cast<TouchSelectionControllerImpl*>( ShowQuickMenuImmediately(static_cast<TouchSelectionControllerImpl*>(
textfield_test_api.touch_selection_controller())); textfield_test_api.touch_selection_controller()));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment