Commit 1d4927a6 authored by Jun Mukai's avatar Jun Mukai Committed by Commit Bot

stabilize CheckHostedAppMenuClickable test

HostedAppAshInteractiveUITest.MenuButtonClickable is flaky with
SingleProcessMash, and I think it could be the case of unstable
mouse location. When mouse move events occur during the test,
then the last mouse location could change and then further
mouse clicks occur on an unexpected location.

UIControlsFactoryOzone can remember the last specified location
and can use the remembered location for clicks. This will
stabilize the HostedAppAshInteractiveUITest.MenuButtonClickable,
and I hope others will get benefits.

BUG=890953
TEST=locally interactive_ui_tests --enable-features=SingleProcessMash

Change-Id: I3542a5a961dd4e7e8819e924d1d0c170c4dfaff1
Reviewed-on: https://chromium-review.googlesource.com/c/1255607
Commit-Queue: Jun Mukai <mukai@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596034}
parent 5ab46f4e
......@@ -6,6 +6,7 @@
#include "base/location.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/optional.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "services/service_manager/public/cpp/connector.h"
......@@ -135,6 +136,7 @@ class UIControlsOzone : public ui_controls::UIControlsAura {
gfx::Point host_location = display_location;
host_->ConvertDIPToPixels(&host_location);
last_mouse_location_ = host_location;
ui::EventType event_type;
......@@ -158,8 +160,13 @@ class UIControlsOzone : public ui_controls::UIControlsAura {
int button_state,
base::OnceClosure closure,
int accelerator_state) override {
gfx::Point host_location;
if (last_mouse_location_.has_value()) {
host_location = last_mouse_location_.value();
} else {
// The location needs to be in display's coordinate.
gfx::Point display_location = host_->window()->env()->last_mouse_location();
gfx::Point display_location =
host_->window()->env()->last_mouse_location();
display::Display display;
if (!display::Screen::GetScreen()->GetDisplayWithDisplayId(
host_->GetDisplayId(), &display)) {
......@@ -168,8 +175,9 @@ class UIControlsOzone : public ui_controls::UIControlsAura {
}
display_location -= display.bounds().OffsetFromOrigin();
gfx::Point host_location = display_location;
host_location = display_location;
host_->ConvertDIPToPixels(&host_location);
}
int changed_button_flag = 0;
......@@ -316,6 +324,11 @@ class UIControlsOzone : public ui_controls::UIControlsAura {
WindowTreeHost* host_;
ws::mojom::EventInjectorPtr event_injector_;
// The mouse location for the last SendMouseEventsNotifyWhenDone call. This is
// used rather than Env::last_mouse_location() as Env::last_mouse_location()
// is updated asynchronously with mus.
base::Optional<gfx::Point> last_mouse_location_;
// Mask of the mouse buttons currently down. This is static as it needs to
// track the state globally for all displays. A UIControlsOzone instance is
// created for each display host.
......
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