Index: ui/aura/window_event_dispatcher_unittest.cc |
diff --git a/ui/aura/window_event_dispatcher_unittest.cc b/ui/aura/window_event_dispatcher_unittest.cc |
index b13935272fd4e1a5af37c23f3b60980292fb508e..3d4e153ca6ed61cb3eca7b448e3b23c377f4c875 100644 |
--- a/ui/aura/window_event_dispatcher_unittest.cc |
+++ b/ui/aura/window_event_dispatcher_unittest.cc |
@@ -165,6 +165,38 @@ TEST_P(WindowEventDispatcherTest, RepostEvent) { |
EXPECT_TRUE(Env::GetInstance()->is_touch_down()); |
} |
+// Check that we correctly track whether any touch devices are down in response |
+// to touch press and release events with two WindowTreeHost. |
+TEST_P(WindowEventDispatcherTest, TouchDownState) { |
+ std::unique_ptr<WindowTreeHost> second_host( |
+ WindowTreeHost::Create(gfx::Rect(20, 30, 100, 50))); |
+ second_host->InitHost(); |
+ second_host->window()->Show(); |
+ |
+ ui::TouchEvent touch_pressed_event1( |
+ ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), ui::EventTimeForNow(), |
+ ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1)); |
+ ui::TouchEvent touch_pressed_event2( |
+ ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), ui::EventTimeForNow(), |
+ ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2)); |
+ ui::TouchEvent touch_released_event1( |
+ ui::ET_TOUCH_RELEASED, gfx::Point(10, 10), ui::EventTimeForNow(), |
+ ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1)); |
+ ui::TouchEvent touch_released_event2( |
+ ui::ET_TOUCH_RELEASED, gfx::Point(10, 10), ui::EventTimeForNow(), |
+ ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2)); |
+ |
+ EXPECT_FALSE(Env::GetInstance()->is_touch_down()); |
+ host()->dispatcher()->OnEventFromSource(&touch_pressed_event1); |
+ EXPECT_TRUE(Env::GetInstance()->is_touch_down()); |
+ second_host->dispatcher()->OnEventFromSource(&touch_pressed_event2); |
+ EXPECT_TRUE(Env::GetInstance()->is_touch_down()); |
+ host()->dispatcher()->OnEventFromSource(&touch_released_event1); |
+ EXPECT_TRUE(Env::GetInstance()->is_touch_down()); |
+ second_host->dispatcher()->OnEventFromSource(&touch_released_event2); |
+ EXPECT_FALSE(Env::GetInstance()->is_touch_down()); |
+} |
+ |
// Check that we correctly track the state of the mouse buttons in response to |
// button press and release events. |
TEST_P(WindowEventDispatcherTest, MouseButtonState) { |