Commit 01aa82f1 authored by Maksim Sisov's avatar Maksim Sisov Committed by Commit Bot

ozone/linux: add ui controls helper interface

This CL adds a helper interface for ui controls that will be used
by Ozone/Linux (maybe by others as well in the future) when
interactive_ui_tests are run.

We need a way to send emulated events through platform specific
methods. For example, XSendEvent in case of X11 and libei library
in case of Wayland (though, this library is under development and
we need to figure out short term and long term solution. Probably,
the short term solution will be injecting ui::Events directly
into Ozone/Wayland and the long term one is libei).

In this CL, ui_test_support is added for Ozone. views is the only
component allowed to depend on that. Also, a factory to create
OzoneUIControlsTestHelper is added. Actually, the factory methods
are generated the same way as the methods for pixmap factory or
ozone platform factory. Also, stub is added so that it's clear
if the platform doesn't support OzoneUIControlsTestHelper or
doesn't have it implemented.

Please note that in order to generate the factory methods, I had
to make platform_object.h public. Alternatively, it might be
moved into a separate source_set so that ozone gn targets that
need that can depend on that directly.

More details at https://docs.google.com/document/d/1K3zyatrNrlm7XRzkZ2I9tJqVh5dNbT3obcw-JW9SUE4

Actual implementation for Ozone/X11 (at least this one) will be
added in a follow up cl.

Bug: 1134495
Change-Id: Ia7753b9f0fc329799d4ada638dcae02bac604405
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2445110
Commit-Queue: Maksim Sisov (GMT+3) <msisov@igalia.com>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarRobert Kroeger <rjkroege@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814181}
parent 9f8e1c61
...@@ -24,6 +24,10 @@ ...@@ -24,6 +24,10 @@
#if defined(USE_X11) #if defined(USE_X11)
#include "ui/views/test/test_desktop_screen_x11.h" #include "ui/views/test/test_desktop_screen_x11.h"
#endif // defined(USE_X11) #endif // defined(USE_X11)
#if defined(OS_LINUX) && defined(USE_OZONE)
#include "ui/views/test/test_desktop_screen_ozone.h"
#endif // defined(OS_LINUX) && defined(USE_OZONE)
#endif #endif
namespace { namespace {
...@@ -98,6 +102,11 @@ ViewEventTestBase::ViewEventTestBase() { ...@@ -98,6 +102,11 @@ ViewEventTestBase::ViewEventTestBase() {
if (!features::IsUsingOzonePlatform()) if (!features::IsUsingOzonePlatform())
views::test::TestDesktopScreenX11::GetInstance(); views::test::TestDesktopScreenX11::GetInstance();
#endif // defined(USE_X11) #endif // defined(USE_X11)
#if !defined(OS_CHROMEOS) && defined(OS_LINUX) && defined(USE_OZONE)
if (!display::Screen::GetScreen())
display::Screen::SetScreenInstance(
views::test::TestDesktopScreenOzone::GetInstance());
#endif
if (!display::Screen::GetScreen()) if (!display::Screen::GetScreen())
screen_.reset(views::CreateDesktopScreen()); screen_.reset(views::CreateDesktopScreen());
#endif #endif
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#if defined(USE_OZONE) && defined(OS_LINUX) && !defined(OS_CHROMEOS) #if defined(USE_OZONE) && defined(OS_LINUX) && !defined(OS_CHROMEOS)
#include "ui/base/ui_base_features.h" #include "ui/base/ui_base_features.h"
#include "ui/ozone/public/ozone_platform.h" #include "ui/ozone/public/ozone_platform.h"
#include "ui/views/test/ui_controls_factory_desktop_aura_ozone.h"
#endif #endif
#if defined(USE_X11) #if defined(USE_X11)
#include "ui/views/test/ui_controls_factory_desktop_aurax11.h" #include "ui/views/test/ui_controls_factory_desktop_aurax11.h"
...@@ -59,14 +60,23 @@ class InteractiveUITestSuite : public ChromeTestSuite { ...@@ -59,14 +60,23 @@ class InteractiveUITestSuite : public ChromeTestSuite {
ui::OzonePlatform::InitParams params; ui::OzonePlatform::InitParams params;
params.single_process = true; params.single_process = true;
ui::OzonePlatform::InitializeForUI(params); ui::OzonePlatform::InitializeForUI(params);
} else
#endif #if !BUILDFLAG(IS_LACROS)
{ // TODO(1134495): when ozone/wayland implements ui controls test helper,
#if defined(USE_X11) // make lacros also use the ui controls created below.
//
// ui controls implementation for Ozone desktop.
ui_controls::InstallUIControlsAura( ui_controls::InstallUIControlsAura(
views::test::CreateUIControlsDesktopAura()); views::test::CreateUIControlsDesktopAuraOzone());
return;
#endif #endif
} }
#endif
#if defined(USE_X11)
DCHECK(!features::IsUsingOzonePlatform());
ui_controls::InstallUIControlsAura(
views::test::CreateUIControlsDesktopAura());
#endif
#else #else
ui_controls::EnableUIControls(); ui_controls::EnableUIControls();
#endif #endif
......
...@@ -21,6 +21,10 @@ ozone_platform_deps = ozone_external_platform_deps ...@@ -21,6 +21,10 @@ ozone_platform_deps = ozone_external_platform_deps
# Extra dependencies to pull into ozone_unittests for built platforms. # Extra dependencies to pull into ozone_unittests for built platforms.
ozone_platform_test_deps = ozone_external_platform_test_deps ozone_platform_test_deps = ozone_external_platform_test_deps
# Extra dependencies to pull into ui_test_support for built platforms.
ozone_platform_ui_test_support_deps =
ozone_external_platform_ui_test_support_deps
if (ozone_platform_windows) { if (ozone_platform_windows) {
ozone_platforms += [ "windows" ] ozone_platforms += [ "windows" ]
ozone_platform_deps += [ "platform/windows" ] ozone_platform_deps += [ "platform/windows" ]
...@@ -63,6 +67,8 @@ platform_list_h_file = "$target_gen_dir/platform_list.h" ...@@ -63,6 +67,8 @@ platform_list_h_file = "$target_gen_dir/platform_list.h"
platform_list_txt_file = "$target_gen_dir/platform_list.txt" platform_list_txt_file = "$target_gen_dir/platform_list.txt"
constructor_list_cc_file = "$target_gen_dir/constructor_list.cc" constructor_list_cc_file = "$target_gen_dir/constructor_list.cc"
test_constructor_list_cc_file = "$target_gen_dir/test_constructor_list.cc"
component("ozone_base") { component("ozone_base") {
sources = [ sources = [
"public/gl_ozone.h", "public/gl_ozone.h",
...@@ -147,7 +153,6 @@ source_set("platform") { ...@@ -147,7 +153,6 @@ source_set("platform") {
"common/stub_client_native_pixmap_factory.cc", "common/stub_client_native_pixmap_factory.cc",
"common/stub_client_native_pixmap_factory.h", "common/stub_client_native_pixmap_factory.h",
"platform_constructor_list.h", "platform_constructor_list.h",
"platform_object.h",
"platform_object_internal.h", "platform_object_internal.h",
"platform_selection.cc", "platform_selection.cc",
"platform_selection.h", "platform_selection.h",
...@@ -160,6 +165,7 @@ source_set("platform") { ...@@ -160,6 +165,7 @@ source_set("platform") {
] ]
public = [ public = [
"platform_object.h",
"public/client_native_pixmap_factory_ozone.h", "public/client_native_pixmap_factory_ozone.h",
"public/ozone_gpu_test_helper.h", "public/ozone_gpu_test_helper.h",
"public/ozone_platform.h", "public/ozone_platform.h",
...@@ -232,6 +238,33 @@ source_set("test_support_internal") { ...@@ -232,6 +238,33 @@ source_set("test_support_internal") {
public_deps = [ "//base/test:test_support" ] public_deps = [ "//base/test:test_support" ]
} }
static_library("ui_test_support") {
visibility = []
visibility = [ "//ui/views:test_support" ]
testonly = true
sources = [
"common/test/stub_ozone_ui_controls_test_helper.cc",
"common/test/stub_ozone_ui_controls_test_helper.h",
"public/ozone_ui_controls_test_helper.cc",
test_constructor_list_cc_file,
]
public = [ "public/ozone_ui_controls_test_helper.h" ]
deps = [
":generate_test_support_constructor_list",
":ozone",
"//ui/base:test_support",
"//ui/events:events_base",
]
deps += ozone_platform_ui_test_support_deps
allow_circular_includes_from = ozone_platform_ui_test_support_deps
}
static_library("test_support") { static_library("test_support") {
visibility = [] visibility = []
visibility = [ visibility = [
...@@ -283,6 +316,24 @@ action("generate_constructor_list") { ...@@ -283,6 +316,24 @@ action("generate_constructor_list") {
deps = [ ":generate_ozone_platform_list" ] deps = [ ":generate_ozone_platform_list" ]
} }
action("generate_test_support_constructor_list") {
script = "generate_constructor_list.py"
inputs = [ platform_list_txt_file ]
outputs = [ test_constructor_list_cc_file ]
args = [
"--platform_list=" + rebase_path(platform_list_txt_file, root_build_dir),
"--output_cc=" + rebase_path(test_constructor_list_cc_file, root_build_dir),
"--namespace=ui",
"--typename=OzoneUIControlsTestHelper",
"--include=\"ui/ozone/public/ozone_ui_controls_test_helper.h\"",
"--include=\"ui/ozone/public/ozone_platform.h\"",
]
deps = [ ":generate_ozone_platform_list" ]
}
test("ozone_unittests") { test("ozone_unittests") {
deps = [ ":test_support" ] deps = [ ":test_support" ]
......
// Copyright 2020 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 "ui/ozone/common/test/stub_ozone_ui_controls_test_helper.h"
#include "base/logging.h"
#include "base/notreached.h"
namespace ui {
namespace {
OzoneUIControlsTestHelper* PrintErrorAndReturnNullptr() {
NOTREACHED()
<< "Notimplemented or not supported by the underlaying platform.";
return nullptr;
}
} // namespace
OzoneUIControlsTestHelper* CreateOzoneUIControlsTestHelperX11() {
return PrintErrorAndReturnNullptr();
}
OzoneUIControlsTestHelper* CreateOzoneUIControlsTestHelperWayland() {
return PrintErrorAndReturnNullptr();
}
OzoneUIControlsTestHelper* CreateOzoneUIControlsTestHelperWindows() {
return PrintErrorAndReturnNullptr();
}
OzoneUIControlsTestHelper* CreateOzoneUIControlsTestHelperDrm() {
return PrintErrorAndReturnNullptr();
}
OzoneUIControlsTestHelper* CreateOzoneUIControlsTestHelperScenic() {
return PrintErrorAndReturnNullptr();
}
OzoneUIControlsTestHelper* CreateOzoneUIControlsTestHelperHeadless() {
return PrintErrorAndReturnNullptr();
}
OzoneUIControlsTestHelper* CreateOzoneUIControlsTestHelperCast() {
return PrintErrorAndReturnNullptr();
}
} // namespace ui
// Copyright 2020 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 UI_OZONE_COMMON_TEST_STUB_OZONE_UI_CONTROLS_TEST_HELPER_H_
#define UI_OZONE_COMMON_TEST_STUB_OZONE_UI_CONTROLS_TEST_HELPER_H_
namespace ui {
class OzoneUIControlsTestHelper;
OzoneUIControlsTestHelper* CreateOzoneUIControlsTestHelperX11();
OzoneUIControlsTestHelper* CreateOzoneUIControlsTestHelperWayland();
OzoneUIControlsTestHelper* CreateOzoneUIControlsTestHelperWindows();
OzoneUIControlsTestHelper* CreateOzoneUIControlsTestHelperDrm();
OzoneUIControlsTestHelper* CreateOzoneUIControlsTestHelperScenic();
OzoneUIControlsTestHelper* CreateOzoneUIControlsTestHelperHeadless();
OzoneUIControlsTestHelper* CreateOzoneUIControlsTestHelperCast();
} // namespace ui
#endif // UI_OZONE_COMMON_TEST_STUB_OZONE_UI_CONTROLS_TEST_HELPER_H_
...@@ -17,3 +17,8 @@ ozone_external_platform_deps = [] ...@@ -17,3 +17,8 @@ ozone_external_platform_deps = []
# so that they get included into ozone_unittests. # so that they get included into ozone_unittests.
# ozone_external_platform_test_deps = [ "platform/foo1:foo1_unitests", ... ] # ozone_external_platform_test_deps = [ "platform/foo1:foo1_unitests", ... ]
ozone_external_platform_test_deps = [] ozone_external_platform_test_deps = []
# If a platform has test support files for ui, the corresponding source_set can
# be listed here so that they get included into ui_test_support.
# ozone_external_platform_ui_test_support_deps = [ "platform/foo1:ui_test_support", ... ]
ozone_external_platform_ui_test_support_deps = []
include_rules = [ include_rules = [
"+mojo/public", "+mojo/public",
"+ui/base/cursor/mojom/cursor_type.mojom-forward.h", "+ui/base/cursor/mojom/cursor_type.mojom-forward.h",
"+ui/base/test/ui_controls.h",
] ]
// Copyright 2020 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 "ui/ozone/public/ozone_ui_controls_test_helper.h"
#include "ui/ozone/platform_object.h"
#include "base/logging.h"
namespace ui {
std::unique_ptr<OzoneUIControlsTestHelper> CreateOzoneUIControlsTestHelper() {
return PlatformObject<OzoneUIControlsTestHelper>::Create();
}
} // namespace ui
// Copyright 2020 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 UI_OZONE_PUBLIC_OZONE_UI_CONTROLS_TEST_HELPER_H_
#define UI_OZONE_PUBLIC_OZONE_UI_CONTROLS_TEST_HELPER_H_
#include <memory>
#include "base/callback_forward.h"
#include "base/component_export.h"
#include "ui/base/test/ui_controls.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/gfx/native_widget_types.h"
namespace gfx {
class Point;
}
namespace ui {
class OzoneUIControlsTestHelper {
public:
virtual ~OzoneUIControlsTestHelper() = default;
// Returns current button down mask.
virtual unsigned ButtonDownMask() const = 0;
// Sends key press event and executes |closure| when done.
virtual void SendKeyPressEvent(gfx::AcceleratedWidget widget,
ui::KeyboardCode key,
bool control,
bool shift,
bool alt,
bool command,
base::OnceClosure closure) = 0;
// Sends mouse motion notify event and executes |closure| when done.
virtual void SendMouseMotionNotifyEvent(gfx::AcceleratedWidget widget,
const gfx::Point& mouse_loc,
const gfx::Point& mouse_root_loc,
base::OnceClosure closure) = 0;
// Sends mouse event and executes |closure| when done.
virtual void SendMouseEvent(gfx::AcceleratedWidget widget,
ui_controls::MouseButton type,
int button_state,
int accelerator_state,
const gfx::Point& mouse_loc,
const gfx::Point& mouse_root_loc,
base::OnceClosure closure) = 0;
// Executes closure after all pending ui events are sent.
virtual void RunClosureAfterAllPendingUIEvents(base::OnceClosure closure) = 0;
};
COMPONENT_EXPORT(OZONE)
std::unique_ptr<OzoneUIControlsTestHelper> CreateOzoneUIControlsTestHelper();
} // namespace ui
#endif // UI_OZONE_PUBLIC_OZONE_UI_CONTROLS_TEST_HELPER_H_
...@@ -1022,6 +1022,16 @@ source_set("test_support") { ...@@ -1022,6 +1022,16 @@ source_set("test_support") {
if (ozone_platform_x11) { if (ozone_platform_x11) {
deps += [ "//ui/base/x" ] deps += [ "//ui/base/x" ]
} }
if (use_ozone && is_desktop_linux) {
sources += [
"test/test_desktop_screen_ozone.cc",
"test/test_desktop_screen_ozone.h",
"test/ui_controls_factory_desktop_aura_ozone.cc",
"test/ui_controls_factory_desktop_aura_ozone.h",
]
deps += [ "//ui/ozone:ui_test_support" ]
}
} }
test("views_unittests") { test("views_unittests") {
......
// Copyright 2020 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 "ui/views/test/test_desktop_screen_ozone.h"
#include <memory>
#include "base/memory/singleton.h"
namespace views {
namespace test {
TestDesktopScreenOzone* TestDesktopScreenOzone::GetInstance() {
return base::Singleton<TestDesktopScreenOzone>::get();
}
gfx::Point TestDesktopScreenOzone::GetCursorScreenPoint() {
return cursor_screen_point_;
}
TestDesktopScreenOzone::TestDesktopScreenOzone() = default;
TestDesktopScreenOzone::~TestDesktopScreenOzone() = default;
} // namespace test
} // namespace views
// Copyright 2020 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 UI_VIEWS_TEST_TEST_DESKTOP_SCREEN_OZONE_H_
#define UI_VIEWS_TEST_TEST_DESKTOP_SCREEN_OZONE_H_
#include "ui/gfx/geometry/point.h"
#include "ui/views/widget/desktop_aura/desktop_screen_ozone.h"
namespace base {
template <typename T>
struct DefaultSingletonTraits;
}
namespace views {
namespace test {
// Replaces the screen instance in Linux/Ozone (non-ChromeOS) tests. Allows
// aura tests to manually set the cursor screen point to be reported
// by GetCursorScreenPoint(). Needed because of a limitation in the
// X11 protocol that restricts us from warping the pointer with the
// mouse button held down.
class TestDesktopScreenOzone : public views::DesktopScreenOzone {
public:
TestDesktopScreenOzone(const TestDesktopScreenOzone&) = delete;
TestDesktopScreenOzone& operator=(const TestDesktopScreenOzone&) = delete;
static TestDesktopScreenOzone* GetInstance();
// DesktopScreenOzone:
gfx::Point GetCursorScreenPoint() override;
void set_cursor_screen_point(const gfx::Point& point) {
cursor_screen_point_ = point;
}
private:
friend struct base::DefaultSingletonTraits<TestDesktopScreenOzone>;
TestDesktopScreenOzone();
~TestDesktopScreenOzone() override;
gfx::Point cursor_screen_point_;
};
} // namespace test
} // namespace views
#endif // UI_VIEWS_TEST_TEST_DESKTOP_SCREEN_OZONE_H_
// Copyright 2020 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 "ui/views/test/ui_controls_factory_desktop_aura_ozone.h"
#include <memory>
#include <utility>
#include <vector>
#include "base/bind.h"
#include "base/check_op.h"
#include "base/location.h"
#include "base/macros.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/env.h"
#include "ui/aura/test/aura_test_utils.h"
#include "ui/aura/test/ui_controls_factory_aura.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/base/test/ui_controls_aura.h"
#include "ui/ozone/public/ozone_ui_controls_test_helper.h"
#include "ui/views/test/test_desktop_screen_ozone.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_linux.h"
namespace views {
namespace test {
namespace {
using ui_controls::DOWN;
using ui_controls::LEFT;
using ui_controls::MIDDLE;
using ui_controls::MouseButton;
using ui_controls::RIGHT;
using ui_controls::UIControlsAura;
using ui_controls::UP;
class UIControlsDesktopOzone : public UIControlsAura {
public:
UIControlsDesktopOzone()
: ozone_ui_controls_test_helper_(ui::CreateOzoneUIControlsTestHelper()) {
DCHECK(ozone_ui_controls_test_helper_)
<< "The test suite cannot be run without OzoneUIControlsTestHelper.";
}
~UIControlsDesktopOzone() override = default;
bool SendKeyPress(gfx::NativeWindow window,
ui::KeyboardCode key,
bool control,
bool shift,
bool alt,
bool command) override {
DCHECK(!command); // No command key on Aura
return SendKeyPressNotifyWhenDone(window, key, control, shift, alt, command,
base::OnceClosure());
}
bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window,
ui::KeyboardCode key,
bool control,
bool shift,
bool alt,
bool command,
base::OnceClosure closure) override {
DCHECK(!command); // No command key on Aura
aura::WindowTreeHost* host = window->GetHost();
ozone_ui_controls_test_helper_->SendKeyPressEvent(
host->GetAcceleratedWidget(), key, control, shift, alt, command,
std::move(closure));
return true;
}
bool SendMouseMove(int screen_x, int screen_y) override {
return SendMouseMoveNotifyWhenDone(screen_x, screen_y, base::OnceClosure());
}
bool SendMouseMoveNotifyWhenDone(int screen_x,
int screen_y,
base::OnceClosure closure) override {
gfx::Point screen_location(screen_x, screen_y);
gfx::Point root_location = screen_location;
aura::Window* root_window = RootWindowForPoint(screen_location);
aura::client::ScreenPositionClient* screen_position_client =
aura::client::GetScreenPositionClient(root_window);
if (screen_position_client) {
screen_position_client->ConvertPointFromScreen(root_window,
&root_location);
}
aura::WindowTreeHost* host = root_window->GetHost();
gfx::Point root_current_location =
aura::test::QueryLatestMousePositionRequestInHost(host);
host->ConvertPixelsToDIP(&root_current_location);
auto* screen = views::test::TestDesktopScreenOzone::GetInstance();
DCHECK_EQ(screen, display::Screen::GetScreen());
screen->set_cursor_screen_point(gfx::Point(screen_x, screen_y));
if (root_location != root_current_location &&
ozone_ui_controls_test_helper_->ButtonDownMask() == 0) {
// Move the cursor because EnterNotify/LeaveNotify are generated with the
// current mouse position as a result of XGrabPointer()
root_window->MoveCursorTo(root_location);
} else {
gfx::Point screen_point(root_location);
host->ConvertDIPToScreenInPixels(&screen_point);
ozone_ui_controls_test_helper_->SendMouseMotionNotifyEvent(
host->GetAcceleratedWidget(), root_location, screen_point,
std::move(closure));
}
ozone_ui_controls_test_helper_->RunClosureAfterAllPendingUIEvents(
std::move(closure));
return true;
}
bool SendMouseEvents(MouseButton type,
int button_state,
int accelerator_state) override {
return SendMouseEventsNotifyWhenDone(
type, button_state, base::OnceClosure(), accelerator_state);
}
bool SendMouseEventsNotifyWhenDone(MouseButton type,
int button_state,
base::OnceClosure closure,
int accelerator_state) override {
gfx::Point mouse_loc = aura::Env::GetInstance()->last_mouse_location();
aura::Window* root_window = RootWindowForPoint(mouse_loc);
aura::client::ScreenPositionClient* screen_position_client =
aura::client::GetScreenPositionClient(root_window);
if (screen_position_client)
screen_position_client->ConvertPointFromScreen(root_window, &mouse_loc);
// x11::ButtonEvent xevent;
gfx::Point mouse_root_loc = mouse_loc;
root_window->GetHost()->ConvertDIPToScreenInPixels(&mouse_root_loc);
ozone_ui_controls_test_helper_->SendMouseEvent(
root_window->GetHost()->GetAcceleratedWidget(), type, button_state,
accelerator_state, mouse_loc, mouse_root_loc, std::move(closure));
return true;
}
bool SendMouseClick(MouseButton type) override {
return SendMouseEvents(type, UP | DOWN, ui_controls::kNoAccelerator);
}
private:
aura::Window* RootWindowForPoint(const gfx::Point& point) {
// Most interactive_ui_tests run inside of the aura_test_helper
// environment. This means that we can't rely on display::Screen and several
// other things to work properly. Therefore we hack around this by
// iterating across the windows owned DesktopWindowTreeHostLinux since this
// doesn't rely on having a DesktopScreenX11.
std::vector<aura::Window*> windows =
DesktopWindowTreeHostLinux::GetAllOpenWindows();
const auto i =
std::find_if(windows.cbegin(), windows.cend(), [point](auto* window) {
return window->GetBoundsInScreen().Contains(point) ||
window->HasCapture();
});
DCHECK(i != windows.cend()) << "Couldn't find RW for " << point.ToString()
<< " among " << windows.size() << " RWs.";
return (*i)->GetRootWindow();
}
std::unique_ptr<ui::OzoneUIControlsTestHelper> ozone_ui_controls_test_helper_;
DISALLOW_COPY_AND_ASSIGN(UIControlsDesktopOzone);
};
} // namespace
UIControlsAura* CreateUIControlsDesktopAuraOzone() {
return new UIControlsDesktopOzone();
}
} // namespace test
} // namespace views
// Copyright 2020 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 UI_VIEWS_TEST_UI_CONTROLS_FACTORY_DESKTOP_AURA_OZONE_H_
#define UI_VIEWS_TEST_UI_CONTROLS_FACTORY_DESKTOP_AURA_OZONE_H_
namespace ui_controls {
class UIControlsAura;
}
namespace views {
namespace test {
ui_controls::UIControlsAura* CreateUIControlsDesktopAuraOzone();
} // namespace test
} // namespace views
#endif // UI_VIEWS_TEST_UI_CONTROLS_FACTORY_DESKTOP_AURA_OZONE_H_
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