Commit b57c818b authored by Liviu Tinta's avatar Liviu Tinta Committed by Commit Bot

Ignore native system mouse events during testing

A bunch of tests synthesize input events during testing, and this
ranges from unit-tests, interactive-ui-tests, telemetry tests etc.
During such tests, it is possible that chrome also receives unexpected
input events from the native system (e.g. if the window happens to show
up under the mouse cursor), causing unexpected failures (e.g. the
event-stream becomes invalid, or the tooltip shows up, etc.). Ignoring
all input events from the system during these tests should make these
tests more deterministic.

Bug: 766450, 883710
Change-Id: Ib7fccaf7a0495207cc9b097bfe25862cad302dc4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2176697Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarNavid Zolghadr <nzolghadr@chromium.org>
Commit-Queue: Liviu Tinta <liviutinta@chromium.org>
Cr-Commit-Position: refs/heads/master@{#771020}
parent 65ddabdf
...@@ -439,6 +439,12 @@ PlatformEventDispatcher* XEventDispatcher::GetPlatformEventDispatcher() { ...@@ -439,6 +439,12 @@ PlatformEventDispatcher* XEventDispatcher::GetPlatformEventDispatcher() {
void X11EventSource::ProcessXEvent(XEvent* xevent) { void X11EventSource::ProcessXEvent(XEvent* xevent) {
auto translated_event = ui::BuildEventFromXEvent(*xevent); auto translated_event = ui::BuildEventFromXEvent(*xevent);
// Ignore native platform-events only if they correspond to mouse events.
// Allow other types of events to still be handled
if (ui::PlatformEventSource::ShouldIgnoreNativePlatformEvents() &&
translated_event && translated_event->IsMouseEvent()) {
return;
}
if (translated_event && translated_event->type() != ET_UNKNOWN) { if (translated_event && translated_event->type() != ET_UNKNOWN) {
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
if (translated_event->IsLocatedEvent()) { if (translated_event->IsLocatedEvent()) {
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "ui/events/keyboard_hook.h" #include "ui/events/keyboard_hook.h"
#include "ui/events/keycodes/dom/dom_code.h" #include "ui/events/keycodes/dom/dom_code.h"
#include "ui/events/keycodes/dom/dom_keyboard_layout_map.h" #include "ui/events/keycodes/dom/dom_keyboard_layout_map.h"
#include "ui/events/platform/platform_event_source.h"
#include "ui/gfx/geometry/insets.h" #include "ui/gfx/geometry/insets.h"
#include "ui/gfx/geometry/vector2d.h" #include "ui/gfx/geometry/vector2d.h"
#include "ui/gfx/native_widget_types.h" #include "ui/gfx/native_widget_types.h"
...@@ -925,6 +926,9 @@ void DesktopWindowTreeHostWin::HandleNativeBlur(HWND focused_window) { ...@@ -925,6 +926,9 @@ void DesktopWindowTreeHostWin::HandleNativeBlur(HWND focused_window) {
} }
bool DesktopWindowTreeHostWin::HandleMouseEvent(ui::MouseEvent* event) { bool DesktopWindowTreeHostWin::HandleMouseEvent(ui::MouseEvent* event) {
// Ignore native platform events for test purposes
if (ui::PlatformEventSource::ShouldIgnoreNativePlatformEvents())
return true;
// Mouse events in occluded windows should be very rare. If this stat isn't // Mouse events in occluded windows should be very rare. If this stat isn't
// very close to 0, that would indicate that windows are incorrectly getting // very close to 0, that would indicate that windows are incorrectly getting
// marked occluded, or getting stuck in the occluded state. Event can cause // marked occluded, or getting stuck in the occluded state. Event can cause
......
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