Commit bfa0cad2 authored by Jun Mukai's avatar Jun Mukai Committed by Commit Bot

Fix UIControls for interactive_ui_tests w/ Mash

It seems UIControlsAsh is still used for interactive_ui_tests,
which isn't the case with Mash. Thus I changed the installation
of UIControls for this, meaning:
- do not install the UIControlsAsh on Main of interactive_ui_tests
- create and install UIControlsOzone during PreRunTestOnMainThread.
  This needs to be here since it needs a window tree host.
- fix the positioning logic in UIControlsOzone -- it creates the
  location in root_window's coordinate, which is actually intended
  to be display's coordinate.

BUG=883523
TEST=no breakage on existing tests

Change-Id: I62b1aea1a28deee4dd1d6da377574af8fddef5ed
Reviewed-on: https://chromium-review.googlesource.com/1228942
Commit-Queue: Jun Mukai <mukai@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592252}
parent 5fec81e8
...@@ -2386,6 +2386,7 @@ static_library("interactive_ui_test_support") { ...@@ -2386,6 +2386,7 @@ static_library("interactive_ui_test_support") {
"//testing/gtest", "//testing/gtest",
"//ui/aura", "//ui/aura",
"//ui/base", "//ui/base",
"//ui/base:test_support",
"//ui/gl:test_support", "//ui/gl:test_support",
] ]
} }
......
...@@ -4,11 +4,13 @@ ...@@ -4,11 +4,13 @@
#include "ash/test/ash_interactive_ui_test_base.h" #include "ash/test/ash_interactive_ui_test_base.h"
#include "ash/test/ui_controls_factory_ash.h"
#include "base/lazy_instance.h" #include "base/lazy_instance.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "mojo/core/embedder/embedder.h" #include "mojo/core/embedder/embedder.h"
#include "ui/aura/env.h" #include "ui/aura/env.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/base/test/ui_controls_aura.h"
#include "ui/base/ui_base_paths.h" #include "ui/base/ui_base_paths.h"
#include "ui/gl/test/gl_surface_test_support.h" #include "ui/gl/test/gl_surface_test_support.h"
...@@ -49,6 +51,7 @@ void AshInteractiveUITestBase::SetUp() { ...@@ -49,6 +51,7 @@ void AshInteractiveUITestBase::SetUp() {
ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath(
resources_pack_path, ui::SCALE_FACTOR_NONE); resources_pack_path, ui::SCALE_FACTOR_NONE);
env_ = aura::Env::CreateInstance(); env_ = aura::Env::CreateInstance();
ui_controls::InstallUIControlsAura(test::CreateAshUIControls());
AshTestBase::SetUp(); AshTestBase::SetUp();
} }
......
...@@ -88,8 +88,13 @@ ...@@ -88,8 +88,13 @@
#endif #endif
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "ash/test/ui_controls_factory_ash.h"
#include "chrome/browser/chromeos/input_method/input_method_configuration.h" #include "chrome/browser/chromeos/input_method/input_method_configuration.h"
#include "chrome/test/base/default_ash_event_generator_delegate.h" #include "chrome/test/base/default_ash_event_generator_delegate.h"
#include "ui/aura/test/ui_controls_factory_aura.h"
#include "ui/aura/window.h"
#include "ui/base/test/ui_controls.h"
#include "ui/base/ui_base_features.h"
#include "ui/events/test/event_generator.h" #include "ui/events/test/event_generator.h"
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
...@@ -481,6 +486,16 @@ void InProcessBrowserTest::PreRunTestOnMainThread() { ...@@ -481,6 +486,16 @@ void InProcessBrowserTest::PreRunTestOnMainThread() {
SetInitialWebContents(tab); SetInitialWebContents(tab);
} }
#if defined(OS_CHROMEOS)
if (features::IsUsingWindowService()) {
aura::WindowTreeHost* host =
browser_ ? browser_->window()->GetNativeWindow()->GetHost() : nullptr;
ui_controls::InstallUIControlsAura(aura::test::CreateUIControlsAura(host));
} else {
ui_controls::InstallUIControlsAura(ash::test::CreateAshUIControls());
}
#endif
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
// Do not use the real StorageMonitor for tests, which introduces another // Do not use the real StorageMonitor for tests, which introduces another
// source of variability and potential slowness. // source of variability and potential slowness.
......
...@@ -20,10 +20,6 @@ ...@@ -20,10 +20,6 @@
#endif #endif
#endif #endif
#if defined(OS_CHROMEOS)
#include "ash/test/ui_controls_factory_ash.h"
#endif
#if defined(OS_WIN) #if defined(OS_WIN)
#include "base/win/scoped_com_initializer.h" #include "base/win/scoped_com_initializer.h"
#include "chrome/test/base/always_on_top_window_killer_win.h" #include "chrome/test/base/always_on_top_window_killer_win.h"
...@@ -47,7 +43,8 @@ class InteractiveUITestSuite : public ChromeTestSuite { ...@@ -47,7 +43,8 @@ class InteractiveUITestSuite : public ChromeTestSuite {
ui_controls::EnableUIControls(); ui_controls::EnableUIControls();
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
ui_controls::InstallUIControlsAura(ash::test::CreateAshUIControls()); // Do not InstallUIControlsAura in ChromeOS, it will be installed in
// InProcessBrowserTest::PreRunTestOnMainThread().
#elif defined(USE_AURA) #elif defined(USE_AURA)
#if defined(OS_WIN) #if defined(OS_WIN)
com_initializer_.reset(new base::win::ScopedCOMInitializer()); com_initializer_.reset(new base::win::ScopedCOMInitializer());
......
...@@ -20,6 +20,14 @@ ...@@ -20,6 +20,14 @@
#include "ui/views/view.h" #include "ui/views/view.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
#if defined(OS_CHROMEOS)
#include "ash/test/ui_controls_factory_ash.h"
#include "ui/aura/test/ui_controls_factory_aura.h"
#include "ui/aura/window.h"
#include "ui/base/test/ui_controls_aura.h"
#include "ui/base/ui_base_features.h"
#endif
namespace { namespace {
// View subclass that allows you to specify the preferred size. // View subclass that allows you to specify the preferred size.
...@@ -94,6 +102,13 @@ void ViewEventTestBase::SetUp() { ...@@ -94,6 +102,13 @@ void ViewEventTestBase::SetUp() {
gfx::NativeWindow context = platform_part_->GetContext(); gfx::NativeWindow context = platform_part_->GetContext();
window_ = views::Widget::CreateWindowWithContext(this, context); window_ = views::Widget::CreateWindowWithContext(this, context);
window_->Show(); window_->Show();
#if defined(OS_CHROMEOS)
ui_controls::InstallUIControlsAura(
features::IsUsingWindowService()
? aura::test::CreateUIControlsAura(
window_->GetNativeWindow()->GetHost())
: ash::test::CreateAshUIControls());
#endif
} }
void ViewEventTestBase::TearDown() { void ViewEventTestBase::TearDown() {
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "services/service_manager/public/cpp/connector.h" #include "services/service_manager/public/cpp/connector.h"
#include "services/ws/public/mojom/constants.mojom.h" #include "services/ws/public/mojom/constants.mojom.h"
#include "services/ws/public/mojom/event_injector.mojom.h" #include "services/ws/public/mojom/event_injector.mojom.h"
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/env.h" #include "ui/aura/env.h"
#include "ui/aura/mus/window_tree_client.h" #include "ui/aura/mus/window_tree_client.h"
#include "ui/aura/test/aura_test_utils.h" #include "ui/aura/test/aura_test_utils.h"
...@@ -19,6 +18,8 @@ ...@@ -19,6 +18,8 @@
#include "ui/aura/test/ui_controls_factory_aura.h" #include "ui/aura/test/ui_controls_factory_aura.h"
#include "ui/aura/window_tree_host.h" #include "ui/aura/window_tree_host.h"
#include "ui/base/test/ui_controls_aura.h" #include "ui/base/test/ui_controls_aura.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/events/event_utils.h" #include "ui/events/event_utils.h"
#include "ui/events/test/events_test_utils.h" #include "ui/events/test/events_test_utils.h"
...@@ -122,15 +123,17 @@ class UIControlsOzone : public ui_controls::UIControlsAura { ...@@ -122,15 +123,17 @@ class UIControlsOzone : public ui_controls::UIControlsAura {
bool SendMouseMoveNotifyWhenDone(long screen_x, bool SendMouseMoveNotifyWhenDone(long screen_x,
long screen_y, long screen_y,
base::OnceClosure closure) override { base::OnceClosure closure) override {
gfx::Point root_location(screen_x, screen_y); // The location needs to be in display's coordinate.
aura::client::ScreenPositionClient* screen_position_client = gfx::Point display_location(screen_x, screen_y);
aura::client::GetScreenPositionClient(host_->window()); display::Display display;
if (screen_position_client) { if (!display::Screen::GetScreen()->GetDisplayWithDisplayId(
screen_position_client->ConvertPointFromScreen(host_->window(), host_->GetDisplayId(), &display)) {
&root_location); LOG(ERROR) << "Failed to see the display for " << host_->GetDisplayId();
return false;
} }
display_location -= display.bounds().OffsetFromOrigin();
gfx::Point host_location = root_location; gfx::Point host_location = display_location;
host_->ConvertDIPToPixels(&host_location); host_->ConvertDIPToPixels(&host_location);
ui::EventType event_type; ui::EventType event_type;
...@@ -155,15 +158,17 @@ class UIControlsOzone : public ui_controls::UIControlsAura { ...@@ -155,15 +158,17 @@ class UIControlsOzone : public ui_controls::UIControlsAura {
int button_state, int button_state,
base::OnceClosure closure, base::OnceClosure closure,
int accelerator_state) override { int accelerator_state) override {
gfx::Point root_location = host_->window()->env()->last_mouse_location(); // The location needs to be in display's coordinate.
aura::client::ScreenPositionClient* screen_position_client = gfx::Point display_location = host_->window()->env()->last_mouse_location();
aura::client::GetScreenPositionClient(host_->window()); display::Display display;
if (screen_position_client) { if (!display::Screen::GetScreen()->GetDisplayWithDisplayId(
screen_position_client->ConvertPointFromScreen(host_->window(), host_->GetDisplayId(), &display)) {
&root_location); LOG(ERROR) << "Failed to see the display for " << host_->GetDisplayId();
return false;
} }
display_location -= display.bounds().OffsetFromOrigin();
gfx::Point host_location = root_location; gfx::Point host_location = display_location;
host_->ConvertDIPToPixels(&host_location); host_->ConvertDIPToPixels(&host_location);
int changed_button_flag = 0; int changed_button_flag = 0;
......
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