Chromium Code Reviews| Index: services/ui/ws/event_dispatcher_unittest.cc |
| diff --git a/services/ui/ws/event_dispatcher_unittest.cc b/services/ui/ws/event_dispatcher_unittest.cc |
| index 7888872d8b86c10b911f1d55f684311812d8f598..dbbcb72f41cf40ff66a54e1dbe5c15f8f5617236 100644 |
| --- a/services/ui/ws/event_dispatcher_unittest.cc |
| +++ b/services/ui/ws/event_dispatcher_unittest.cc |
| @@ -9,9 +9,12 @@ |
| #include <queue> |
| +#include "base/command_line.h" |
| #include "base/macros.h" |
| #include "base/memory/ptr_util.h" |
| #include "base/memory/weak_ptr.h" |
| +#include "base/run_loop.h" |
| +#include "base/test/scoped_task_environment.h" |
| #include "services/ui/common/accelerator_util.h" |
| #include "services/ui/ws/accelerator.h" |
| #include "services/ui/ws/event_dispatcher_delegate.h" |
| @@ -106,7 +109,7 @@ class TestEventDispatcherDelegate : public EventDispatcherDelegate { |
| private: |
| // EventDispatcherDelegate: |
| void OnAccelerator(uint32_t accelerator, |
| - const int64_t display_id, |
| + int64_t display_id, |
| const ui::Event& event, |
| AcceleratorPhase phase) override { |
| EXPECT_EQ(0u, last_accelerator_); |
| @@ -114,7 +117,7 @@ class TestEventDispatcherDelegate : public EventDispatcherDelegate { |
| last_accelerator_phase_ = phase; |
| } |
| ServerWindow* GetFocusedWindowForEventDispatcher( |
| - const int64_t display_id) override { |
| + int64_t display_id) override { |
| return focused_window_; |
| } |
| void SetNativeCapture(ServerWindow* window) override {} |
| @@ -128,10 +131,10 @@ class TestEventDispatcherDelegate : public EventDispatcherDelegate { |
| lost_capture_window_ = old_capture_window; |
| } |
| void OnMouseCursorLocationChanged(const gfx::Point& point, |
| - const int64_t display_id) override {} |
| + int64_t display_id) override {} |
| void DispatchInputEventToWindow(ServerWindow* target, |
| ClientSpecificId client_id, |
| - const int64_t display_id, |
| + int64_t display_id, |
| const ui::Event& event, |
| Accelerator* accelerator) override { |
| std::unique_ptr<DispatchedEventDetails> details(new DispatchedEventDetails); |
| @@ -141,6 +144,7 @@ class TestEventDispatcherDelegate : public EventDispatcherDelegate { |
| details->accelerator = accelerator; |
| dispatched_event_queue_.push(std::move(details)); |
| } |
| + void ProcessNextEventFromQueue() override {} |
| ClientSpecificId GetEventTargetClientId(const ServerWindow* window, |
| bool in_nonclient_area) override { |
| return in_nonclient_area ? kNonclientAreaId : kClientAreaId; |
| @@ -150,7 +154,7 @@ class TestEventDispatcherDelegate : public EventDispatcherDelegate { |
| return root_; |
| } |
| void OnEventTargetNotFound(const ui::Event& event, |
| - const int64_t display_id) override { |
| + int64_t display_id) override { |
| last_event_target_not_found_ = ui::Event::Clone(event); |
| } |
| @@ -198,39 +202,12 @@ void ExpectDispatchedEventDetailsMatches(const DispatchedEventDetails* details, |
| ASSERT_EQ(location, details->event->AsLocatedEvent()->location()); |
| } |
| -void RunMouseEventTests(EventDispatcher* dispatcher, |
| - TestEventDispatcherDelegate* dispatcher_delegate, |
| - MouseEventTest* tests, |
| - size_t test_count) { |
| - for (size_t i = 0; i < test_count; ++i) { |
| - const MouseEventTest& test = tests[i]; |
| - ASSERT_FALSE(dispatcher_delegate->has_queued_events()) |
| - << " unexpected queued events before running " << i; |
| - dispatcher->ProcessEvent(ui::PointerEvent(test.input_event), 0, |
| - EventDispatcher::AcceleratorMatchPhase::ANY); |
| - |
| - std::unique_ptr<DispatchedEventDetails> details = |
| - dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| - ASSERT_NO_FATAL_FAILURE(ExpectDispatchedEventDetailsMatches( |
| - details.get(), test.expected_target_window1, |
| - test.expected_root_location1, test.expected_location1)) |
| - << " details don't match " << i; |
| - details = dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| - ASSERT_NO_FATAL_FAILURE(ExpectDispatchedEventDetailsMatches( |
| - details.get(), test.expected_target_window2, |
| - test.expected_root_location2, test.expected_location2)) |
| - << " details2 don't match " << i; |
| - ASSERT_FALSE(dispatcher_delegate->has_queued_events()) |
| - << " unexpected queued events after running " << i; |
| - } |
| -} |
| - |
| } // namespace |
| // Test fixture for EventDispatcher with friend access to verify the internal |
| // state. Setup creates a TestServerWindowDelegate, a visible root ServerWindow, |
| // a TestEventDispatcher and the EventDispatcher for testing. |
| -class EventDispatcherTest : public testing::Test, |
| +class EventDispatcherTest : public testing::TestWithParam<bool>, |
| public TestEventDispatcherDelegate::Delegate { |
| public: |
| EventDispatcherTest() {} |
| @@ -242,6 +219,11 @@ class EventDispatcherTest : public testing::Test, |
| } |
| EventDispatcher* event_dispatcher() { return event_dispatcher_.get(); } |
| + void RunTasks(); |
| + void RunMouseEventTests(EventDispatcher* dispatcher, |
| + TestEventDispatcherDelegate* dispatcher_delegate, |
| + MouseEventTest* tests, |
| + size_t test_count); |
| bool AreAnyPointersDown() const; |
| // Deletes everything created during SetUp() |
| void ClearSetup(); |
| @@ -256,7 +238,7 @@ class EventDispatcherTest : public testing::Test, |
| ServerWindow* GetActiveSystemModalWindow() const; |
| protected: |
| - // testing::Test: |
| + // testing::TestWithParam<bool>: |
| void SetUp() override; |
| private: |
| @@ -270,9 +252,49 @@ class EventDispatcherTest : public testing::Test, |
| std::unique_ptr<TestEventDispatcherDelegate> test_event_dispatcher_delegate_; |
| std::unique_ptr<EventDispatcher> event_dispatcher_; |
| + base::test::ScopedTaskEnvironment scoped_task_environment_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(EventDispatcherTest); |
| }; |
| +void EventDispatcherTest::RunTasks() { |
|
sadrul
2017/06/07 20:16:04
Because you are calling this only after calling di
riajiang
2017/06/07 21:46:25
It's also used after SetMousePointerDisplayLocatio
|
| + bool enable_async_event_targeting = GetParam(); |
| + if (!enable_async_event_targeting) |
| + return; |
| + |
| + base::RunLoop runloop; |
| + runloop.RunUntilIdle(); |
| +} |
| + |
| +void EventDispatcherTest::RunMouseEventTests( |
| + EventDispatcher* dispatcher, |
| + TestEventDispatcherDelegate* dispatcher_delegate, |
| + MouseEventTest* tests, |
| + size_t test_count) { |
| + for (size_t i = 0; i < test_count; ++i) { |
| + const MouseEventTest& test = tests[i]; |
| + ASSERT_FALSE(dispatcher_delegate->has_queued_events()) |
| + << " unexpected queued events before running " << i; |
| + dispatcher->ProcessEvent(ui::PointerEvent(test.input_event), 0, |
| + EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| + |
| + std::unique_ptr<DispatchedEventDetails> details = |
| + dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| + ASSERT_NO_FATAL_FAILURE(ExpectDispatchedEventDetailsMatches( |
| + details.get(), test.expected_target_window1, |
| + test.expected_root_location1, test.expected_location1)) |
| + << " details don't match " << i; |
| + details = dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| + ASSERT_NO_FATAL_FAILURE(ExpectDispatchedEventDetailsMatches( |
| + details.get(), test.expected_target_window2, |
| + test.expected_root_location2, test.expected_location2)) |
| + << " details2 don't match " << i; |
| + ASSERT_FALSE(dispatcher_delegate->has_queued_events()) |
| + << " unexpected queued events after running " << i; |
| + } |
| +} |
| + |
| bool EventDispatcherTest::AreAnyPointersDown() const { |
| return EventDispatcherTestApi(event_dispatcher_.get()).AreAnyPointersDown(); |
| } |
| @@ -322,7 +344,12 @@ ServerWindow* EventDispatcherTest::GetActiveSystemModalWindow() const { |
| } |
| void EventDispatcherTest::SetUp() { |
| - testing::Test::SetUp(); |
| + bool enable_async_event_targeting = GetParam(); |
| + if (enable_async_event_targeting) { |
| + base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| + "enable-async-event-targeting"); |
| + } |
| + testing::TestWithParam<bool>::SetUp(); |
| window_delegate_ = base::MakeUnique<TestServerWindowDelegate>(); |
| root_window_ = |
| @@ -337,7 +364,7 @@ void EventDispatcherTest::SetUp() { |
| test_event_dispatcher_delegate_->set_root(root_window_.get()); |
| } |
| -TEST_F(EventDispatcherTest, ProcessEvent) { |
| +TEST_P(EventDispatcherTest, ProcessEvent) { |
| std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| @@ -349,6 +376,7 @@ TEST_F(EventDispatcherTest, ProcessEvent) { |
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| event_dispatcher()->ProcessEvent(ui_event, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| std::unique_ptr<DispatchedEventDetails> details = |
| test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| @@ -363,11 +391,12 @@ TEST_F(EventDispatcherTest, ProcessEvent) { |
| EXPECT_EQ(gfx::Point(10, 15), dispatched_event->location()); |
| } |
| -TEST_F(EventDispatcherTest, ProcessEventNoTarget) { |
| +TEST_P(EventDispatcherTest, ProcessEventNoTarget) { |
| // Send event without a target. |
| ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE); |
| event_dispatcher()->ProcessEvent(key, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| // Event wasn't dispatched to a target. |
| std::unique_ptr<DispatchedEventDetails> details = |
| @@ -382,7 +411,7 @@ TEST_F(EventDispatcherTest, ProcessEventNoTarget) { |
| EXPECT_EQ(ui::VKEY_A, event_out->AsKeyEvent()->key_code()); |
| } |
| -TEST_F(EventDispatcherTest, AcceleratorBasic) { |
| +TEST_P(EventDispatcherTest, AcceleratorBasic) { |
| ClearSetup(); |
| TestEventDispatcherDelegate event_dispatcher_delegate(nullptr); |
| EventDispatcher dispatcher(&event_dispatcher_delegate); |
| @@ -420,7 +449,7 @@ TEST_F(EventDispatcherTest, AcceleratorBasic) { |
| EXPECT_TRUE(dispatcher.AddAccelerator(accelerator_3, std::move(matcher))); |
| } |
| -TEST_F(EventDispatcherTest, EventMatching) { |
| +TEST_P(EventDispatcherTest, EventMatching) { |
| TestEventDispatcherDelegate* event_dispatcher_delegate = |
| test_event_dispatcher_delegate(); |
| EventDispatcher* dispatcher = event_dispatcher(); |
| @@ -432,6 +461,7 @@ TEST_F(EventDispatcherTest, EventMatching) { |
| ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN); |
| dispatcher->ProcessEvent(key, 0, EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| EXPECT_EQ(accelerator_1, |
| event_dispatcher_delegate->GetAndClearLastAccelerator()); |
| @@ -440,11 +470,13 @@ TEST_F(EventDispatcherTest, EventMatching) { |
| key = ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_W, |
| ui::EF_CONTROL_DOWN | ui::EF_NUM_LOCK_ON); |
| dispatcher->ProcessEvent(key, 0, EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| EXPECT_EQ(accelerator_1, |
| event_dispatcher_delegate->GetAndClearLastAccelerator()); |
| key = ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_NONE); |
| dispatcher->ProcessEvent(key, 0, EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| EXPECT_EQ(0u, event_dispatcher_delegate->GetAndClearLastAccelerator()); |
| uint32_t accelerator_2 = 2; |
| @@ -452,16 +484,18 @@ TEST_F(EventDispatcherTest, EventMatching) { |
| ui::mojom::kEventFlagNone); |
| dispatcher->AddAccelerator(accelerator_2, std::move(matcher)); |
| dispatcher->ProcessEvent(key, 0, EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| EXPECT_EQ(accelerator_2, |
| event_dispatcher_delegate->GetAndClearLastAccelerator()); |
| dispatcher->RemoveAccelerator(accelerator_2); |
| dispatcher->ProcessEvent(key, 0, EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| EXPECT_EQ(0u, event_dispatcher_delegate->GetAndClearLastAccelerator()); |
| } |
| // Tests that a post-target accelerator is not triggered by ProcessEvent. |
| -TEST_F(EventDispatcherTest, PostTargetAccelerator) { |
| +TEST_P(EventDispatcherTest, PostTargetAccelerator) { |
| TestEventDispatcherDelegate* event_dispatcher_delegate = |
| test_event_dispatcher_delegate(); |
| EventDispatcher* dispatcher = event_dispatcher(); |
| @@ -475,6 +509,7 @@ TEST_F(EventDispatcherTest, PostTargetAccelerator) { |
| ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN); |
| // The post-target accelerator should be fired if there is no focused window. |
| dispatcher->ProcessEvent(key, 0, EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| EXPECT_EQ(accelerator_1, |
| event_dispatcher_delegate->GetAndClearLastAccelerator()); |
| std::unique_ptr<DispatchedEventDetails> details = |
| @@ -487,6 +522,7 @@ TEST_F(EventDispatcherTest, PostTargetAccelerator) { |
| // With a focused window the event should be dispatched. |
| dispatcher->ProcessEvent(key, 0, EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| EXPECT_EQ(0u, event_dispatcher_delegate->GetAndClearLastAccelerator()); |
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| EXPECT_TRUE(details); |
| @@ -499,13 +535,14 @@ TEST_F(EventDispatcherTest, PostTargetAccelerator) { |
| // Post deletion there should be no accelerator |
| dispatcher->ProcessEvent(key, 0, EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| EXPECT_EQ(0u, event_dispatcher_delegate->GetAndClearLastAccelerator()); |
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| EXPECT_TRUE(details); |
| EXPECT_FALSE(details->accelerator); |
| } |
| -TEST_F(EventDispatcherTest, ProcessPost) { |
| +TEST_P(EventDispatcherTest, ProcessPost) { |
| TestEventDispatcherDelegate* event_dispatcher_delegate = |
| test_event_dispatcher_delegate(); |
| EventDispatcher* dispatcher = event_dispatcher(); |
| @@ -534,6 +571,7 @@ TEST_F(EventDispatcherTest, ProcessPost) { |
| // DispatchInputEventToWindow(). |
| ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN); |
| dispatcher->ProcessEvent(key, 0, EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| EXPECT_EQ(EventDispatcherDelegate::AcceleratorPhase::PRE, |
| event_dispatcher_delegate->last_accelerator_phase()); |
| EXPECT_EQ(pre_id, event_dispatcher_delegate->GetAndClearLastAccelerator()); |
| @@ -542,6 +580,7 @@ TEST_F(EventDispatcherTest, ProcessPost) { |
| // Dispatch for POST, which should trigger POST. |
| dispatcher->ProcessEvent(key, 0, |
| EventDispatcher::AcceleratorMatchPhase::POST_ONLY); |
| + RunTasks(); |
| std::unique_ptr<DispatchedEventDetails> details = |
| event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| ASSERT_TRUE(details); |
| @@ -549,7 +588,7 @@ TEST_F(EventDispatcherTest, ProcessPost) { |
| EXPECT_EQ(post_id, details->accelerator->id()); |
| } |
| -TEST_F(EventDispatcherTest, Capture) { |
| +TEST_P(EventDispatcherTest, Capture) { |
| ServerWindow* root = root_window(); |
| std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| @@ -592,7 +631,7 @@ TEST_F(EventDispatcherTest, Capture) { |
| tests, arraysize(tests)); |
| } |
| -TEST_F(EventDispatcherTest, CaptureMultipleMouseButtons) { |
| +TEST_P(EventDispatcherTest, CaptureMultipleMouseButtons) { |
| std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| @@ -635,7 +674,7 @@ TEST_F(EventDispatcherTest, CaptureMultipleMouseButtons) { |
| tests, arraysize(tests)); |
| } |
| -TEST_F(EventDispatcherTest, ClientAreaGoesToOwner) { |
| +TEST_P(EventDispatcherTest, ClientAreaGoesToOwner) { |
| std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| @@ -653,6 +692,7 @@ TEST_F(EventDispatcherTest, ClientAreaGoesToOwner) { |
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| dispatcher->ProcessEvent(press_event, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| // Events should target child and be in the non-client area. |
| std::unique_ptr<DispatchedEventDetails> details = |
| @@ -668,6 +708,7 @@ TEST_F(EventDispatcherTest, ClientAreaGoesToOwner) { |
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, 0)); |
| dispatcher->ProcessEvent(move_event, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| // Still same target. |
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| @@ -681,6 +722,7 @@ TEST_F(EventDispatcherTest, ClientAreaGoesToOwner) { |
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| dispatcher->ProcessEvent(release_event, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| // The event should not have been dispatched to the delegate. |
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| @@ -695,6 +737,7 @@ TEST_F(EventDispatcherTest, ClientAreaGoesToOwner) { |
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| dispatcher->ProcessEvent(press_event2, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| EXPECT_TRUE(event_dispatcher_delegate->has_queued_events()); |
| ASSERT_EQ(child.get(), details->window); |
| @@ -708,7 +751,7 @@ TEST_F(EventDispatcherTest, ClientAreaGoesToOwner) { |
| EXPECT_EQ(ui::ET_POINTER_DOWN, details->event->type()); |
| } |
| -TEST_F(EventDispatcherTest, AdditionalClientArea) { |
| +TEST_P(EventDispatcherTest, AdditionalClientArea) { |
| std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| @@ -726,6 +769,7 @@ TEST_F(EventDispatcherTest, AdditionalClientArea) { |
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| event_dispatcher()->ProcessEvent(press_event, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| // Events should target child and be in the client area. |
| std::unique_ptr<DispatchedEventDetails> details = |
| @@ -735,7 +779,7 @@ TEST_F(EventDispatcherTest, AdditionalClientArea) { |
| EXPECT_TRUE(details->IsClientArea()); |
| } |
| -TEST_F(EventDispatcherTest, HitTestMask) { |
| +TEST_P(EventDispatcherTest, HitTestMask) { |
| std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| @@ -748,6 +792,7 @@ TEST_F(EventDispatcherTest, HitTestMask) { |
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, 0)); |
| event_dispatcher()->ProcessEvent(move1, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| // Event went through the child window and hit the root. |
| std::unique_ptr<DispatchedEventDetails> details1 = |
| @@ -763,6 +808,7 @@ TEST_F(EventDispatcherTest, HitTestMask) { |
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, 0)); |
| event_dispatcher()->ProcessEvent(move2, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| // Mouse exits the root. |
| std::unique_ptr<DispatchedEventDetails> details2 = |
| @@ -776,7 +822,7 @@ TEST_F(EventDispatcherTest, HitTestMask) { |
| EXPECT_TRUE(details3->IsClientArea()); |
| } |
| -TEST_F(EventDispatcherTest, DontFocusOnSecondDown) { |
| +TEST_P(EventDispatcherTest, DontFocusOnSecondDown) { |
| std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3)); |
| std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4)); |
| @@ -794,6 +840,7 @@ TEST_F(EventDispatcherTest, DontFocusOnSecondDown) { |
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| dispatcher->ProcessEvent(press_event, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| std::unique_ptr<DispatchedEventDetails> details = |
| event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| @@ -808,13 +855,14 @@ TEST_F(EventDispatcherTest, DontFocusOnSecondDown) { |
| ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2))); |
| dispatcher->ProcessEvent(touch_event, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| EXPECT_EQ(child2.get(), details->window); |
| EXPECT_EQ(nullptr, event_dispatcher_delegate->GetAndClearLastFocusedWindow()); |
| } |
| -TEST_F(EventDispatcherTest, TwoPointersActive) { |
| +TEST_P(EventDispatcherTest, TwoPointersActive) { |
| std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3)); |
| std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4)); |
| @@ -832,6 +880,7 @@ TEST_F(EventDispatcherTest, TwoPointersActive) { |
| ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1))); |
| dispatcher->ProcessEvent(touch_event1, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| std::unique_ptr<DispatchedEventDetails> details = |
| event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| EXPECT_EQ(child1.get(), details->window); |
| @@ -842,6 +891,7 @@ TEST_F(EventDispatcherTest, TwoPointersActive) { |
| ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1))); |
| dispatcher->ProcessEvent(drag_event1, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| EXPECT_EQ(child1.get(), details->window); |
| @@ -851,6 +901,7 @@ TEST_F(EventDispatcherTest, TwoPointersActive) { |
| ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2))); |
| dispatcher->ProcessEvent(touch_event2, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| EXPECT_EQ(child2.get(), details->window); |
| @@ -860,12 +911,14 @@ TEST_F(EventDispatcherTest, TwoPointersActive) { |
| ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2))); |
| dispatcher->ProcessEvent(drag_event2, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| EXPECT_EQ(child2.get(), details->window); |
| // Drag again with id 1, child1 should continue to get it. |
| dispatcher->ProcessEvent(drag_event1, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| EXPECT_EQ(child1.get(), details->window); |
| @@ -875,6 +928,7 @@ TEST_F(EventDispatcherTest, TwoPointersActive) { |
| ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1))); |
| dispatcher->ProcessEvent(touch_release, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| EXPECT_EQ(child1.get(), details->window); |
| const ui::PointerEvent touch_event3(ui::TouchEvent( |
| @@ -882,11 +936,12 @@ TEST_F(EventDispatcherTest, TwoPointersActive) { |
| ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2))); |
| dispatcher->ProcessEvent(touch_event3, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| EXPECT_EQ(child2.get(), details->window); |
| } |
| -TEST_F(EventDispatcherTest, DestroyWindowWhileGettingEvents) { |
| +TEST_P(EventDispatcherTest, DestroyWindowWhileGettingEvents) { |
| std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| @@ -902,6 +957,7 @@ TEST_F(EventDispatcherTest, DestroyWindowWhileGettingEvents) { |
| ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1))); |
| dispatcher->ProcessEvent(touch_event1, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| std::unique_ptr<DispatchedEventDetails> details = |
| event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| @@ -915,11 +971,12 @@ TEST_F(EventDispatcherTest, DestroyWindowWhileGettingEvents) { |
| ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1))); |
| dispatcher->ProcessEvent(drag_event1, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| EXPECT_EQ(nullptr, details.get()); |
| } |
| -TEST_F(EventDispatcherTest, MouseInExtendedHitTestRegion) { |
| +TEST_P(EventDispatcherTest, MouseInExtendedHitTestRegion) { |
| ServerWindow* root = root_window(); |
| std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| @@ -936,6 +993,7 @@ TEST_F(EventDispatcherTest, MouseInExtendedHitTestRegion) { |
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| dispatcher->ProcessEvent(ui_event, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| std::unique_ptr<DispatchedEventDetails> details = |
| event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| ASSERT_EQ(root, details->window); |
| @@ -946,6 +1004,7 @@ TEST_F(EventDispatcherTest, MouseInExtendedHitTestRegion) { |
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| dispatcher->ProcessEvent(release_event, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| ASSERT_EQ(root, details->window); |
| @@ -956,6 +1015,7 @@ TEST_F(EventDispatcherTest, MouseInExtendedHitTestRegion) { |
| child->set_extended_hit_test_region(gfx::Insets(5, 5, 5, 5)); |
| dispatcher->ProcessEvent(ui_event, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| EXPECT_EQ(root, details->window); |
| EXPECT_EQ(ui::ET_POINTER_EXITED, details->event->type()); |
| @@ -971,7 +1031,7 @@ TEST_F(EventDispatcherTest, MouseInExtendedHitTestRegion) { |
| EXPECT_EQ(gfx::Point(-2, -1), details->event->AsPointerEvent()->location()); |
| } |
| -TEST_F(EventDispatcherTest, WheelWhileDown) { |
| +TEST_P(EventDispatcherTest, WheelWhileDown) { |
| std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3)); |
| std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4)); |
| @@ -1000,7 +1060,7 @@ TEST_F(EventDispatcherTest, WheelWhileDown) { |
| // Tests that when explicit capture has been set that all events go to the |
| // designated window, and that when capture is cleared, events find the |
| // appropriate target window. |
| -TEST_F(EventDispatcherTest, SetExplicitCapture) { |
| +TEST_P(EventDispatcherTest, SetExplicitCapture) { |
| ServerWindow* root = root_window(); |
| std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| @@ -1022,6 +1082,7 @@ TEST_F(EventDispatcherTest, SetExplicitCapture) { |
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| dispatcher->ProcessEvent(left_press_event, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| // Events should target child. |
| std::unique_ptr<DispatchedEventDetails> details = |
| @@ -1039,6 +1100,7 @@ TEST_F(EventDispatcherTest, SetExplicitCapture) { |
| ui::EF_RIGHT_MOUSE_BUTTON)); |
| dispatcher->ProcessEvent(right_press_event, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| EXPECT_TRUE(IsMouseButtonDown()); |
| @@ -1049,6 +1111,7 @@ TEST_F(EventDispatcherTest, SetExplicitCapture) { |
| ui::EF_LEFT_MOUSE_BUTTON)); |
| dispatcher->ProcessEvent(left_release_event, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| EXPECT_TRUE(IsMouseButtonDown()); |
| @@ -1058,6 +1121,7 @@ TEST_F(EventDispatcherTest, SetExplicitCapture) { |
| ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2))); |
| dispatcher->ProcessEvent(touch_event, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| EXPECT_TRUE(IsMouseButtonDown()); |
| @@ -1068,6 +1132,7 @@ TEST_F(EventDispatcherTest, SetExplicitCapture) { |
| ui::EF_RIGHT_MOUSE_BUTTON)); |
| dispatcher->ProcessEvent(move_event, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| EXPECT_TRUE(IsMouseButtonDown()); |
| @@ -1078,6 +1143,7 @@ TEST_F(EventDispatcherTest, SetExplicitCapture) { |
| ui::EF_RIGHT_MOUSE_BUTTON, ui::EF_RIGHT_MOUSE_BUTTON)); |
| dispatcher->ProcessEvent(right_release_event, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| EXPECT_FALSE(IsMouseButtonDown()); |
| } |
| @@ -1090,6 +1156,7 @@ TEST_F(EventDispatcherTest, SetExplicitCapture) { |
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| dispatcher->ProcessEvent(press_event, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| // Events should target the root. |
| std::unique_ptr<DispatchedEventDetails> details = |
| @@ -1102,7 +1169,7 @@ TEST_F(EventDispatcherTest, SetExplicitCapture) { |
| // This test verifies that explicit capture overrides and resets implicit |
| // capture. |
| -TEST_F(EventDispatcherTest, ExplicitCaptureOverridesImplicitCapture) { |
| +TEST_P(EventDispatcherTest, ExplicitCaptureOverridesImplicitCapture) { |
| ServerWindow* root = root_window(); |
| std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| @@ -1150,6 +1217,7 @@ TEST_F(EventDispatcherTest, ExplicitCaptureOverridesImplicitCapture) { |
| ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1))); |
| dispatcher->ProcessEvent(touch_event, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| } |
| std::unique_ptr<DispatchedEventDetails> details = |
| @@ -1183,6 +1251,7 @@ TEST_F(EventDispatcherTest, ExplicitCaptureOverridesImplicitCapture) { |
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| dispatcher->ProcessEvent(press_event, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| // Events should target the root. |
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| @@ -1193,7 +1262,7 @@ TEST_F(EventDispatcherTest, ExplicitCaptureOverridesImplicitCapture) { |
| // Tests that setting capture does delete active pointer targets for the capture |
| // window. |
| -TEST_F(EventDispatcherTest, CaptureUpdatesActivePointerTargets) { |
| +TEST_P(EventDispatcherTest, CaptureUpdatesActivePointerTargets) { |
| ServerWindow* root = root_window(); |
| root->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| @@ -1204,6 +1273,7 @@ TEST_F(EventDispatcherTest, CaptureUpdatesActivePointerTargets) { |
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| dispatcher->ProcessEvent(press_event, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| std::unique_ptr<DispatchedEventDetails> details = |
| test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| @@ -1216,6 +1286,7 @@ TEST_F(EventDispatcherTest, CaptureUpdatesActivePointerTargets) { |
| ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1))); |
| dispatcher->ProcessEvent(touch_event, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| } |
| ASSERT_TRUE(AreAnyPointersDown()); |
| @@ -1231,7 +1302,7 @@ TEST_F(EventDispatcherTest, CaptureUpdatesActivePointerTargets) { |
| // Tests that when explicit capture is changed, that the previous window with |
| // capture is no longer being observed. |
| -TEST_F(EventDispatcherTest, UpdatingCaptureStopsObservingPreviousCapture) { |
| +TEST_P(EventDispatcherTest, UpdatingCaptureStopsObservingPreviousCapture) { |
| std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3)); |
| std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4)); |
| @@ -1254,7 +1325,7 @@ TEST_F(EventDispatcherTest, UpdatingCaptureStopsObservingPreviousCapture) { |
| // Tests that destroying a window with explicit capture clears the capture |
| // state. |
| -TEST_F(EventDispatcherTest, DestroyingCaptureWindowRemovesExplicitCapture) { |
| +TEST_P(EventDispatcherTest, DestroyingCaptureWindowRemovesExplicitCapture) { |
| std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| child->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| @@ -1271,7 +1342,7 @@ TEST_F(EventDispatcherTest, DestroyingCaptureWindowRemovesExplicitCapture) { |
| // Tests that when |client_id| is set for a window performing capture, that this |
| // preference is used regardless of whether an event targets the client region. |
| -TEST_F(EventDispatcherTest, CaptureInNonClientAreaOverridesActualPoint) { |
| +TEST_P(EventDispatcherTest, CaptureInNonClientAreaOverridesActualPoint) { |
| ServerWindow* root = root_window(); |
| root->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| @@ -1287,6 +1358,7 @@ TEST_F(EventDispatcherTest, CaptureInNonClientAreaOverridesActualPoint) { |
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| event_dispatcher()->ProcessEvent(press_event, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| // Events should target child and be in the client area. |
| std::unique_ptr<DispatchedEventDetails> details = |
| @@ -1296,7 +1368,7 @@ TEST_F(EventDispatcherTest, CaptureInNonClientAreaOverridesActualPoint) { |
| EXPECT_TRUE(details->IsNonclientArea()); |
| } |
| -TEST_F(EventDispatcherTest, ProcessPointerEvents) { |
| +TEST_P(EventDispatcherTest, ProcessPointerEvents) { |
| std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| @@ -1308,6 +1380,7 @@ TEST_F(EventDispatcherTest, ProcessPointerEvents) { |
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| event_dispatcher()->ProcessEvent( |
| pointer_event, 0, EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| std::unique_ptr<DispatchedEventDetails> details = |
| test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| @@ -1330,6 +1403,7 @@ TEST_F(EventDispatcherTest, ProcessPointerEvents) { |
| touch_id))); |
| event_dispatcher()->ProcessEvent( |
| pointer_event, 0, EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| std::unique_ptr<DispatchedEventDetails> details = |
| test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| @@ -1346,7 +1420,7 @@ TEST_F(EventDispatcherTest, ProcessPointerEvents) { |
| } |
| } |
| -TEST_F(EventDispatcherTest, ResetClearsPointerDown) { |
| +TEST_P(EventDispatcherTest, ResetClearsPointerDown) { |
| std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| @@ -1358,6 +1432,7 @@ TEST_F(EventDispatcherTest, ResetClearsPointerDown) { |
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| event_dispatcher()->ProcessEvent(ui_event, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| std::unique_ptr<DispatchedEventDetails> details = |
| test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| @@ -1371,7 +1446,7 @@ TEST_F(EventDispatcherTest, ResetClearsPointerDown) { |
| EXPECT_FALSE(AreAnyPointersDown()); |
| } |
| -TEST_F(EventDispatcherTest, ResetClearsCapture) { |
| +TEST_P(EventDispatcherTest, ResetClearsCapture) { |
| ServerWindow* root = root_window(); |
| root->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| @@ -1385,7 +1460,7 @@ TEST_F(EventDispatcherTest, ResetClearsCapture) { |
| } |
| // Tests that events on a modal parent target the modal child. |
| -TEST_F(EventDispatcherTest, ModalWindowEventOnModalParent) { |
| +TEST_P(EventDispatcherTest, ModalWindowEventOnModalParent) { |
| std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); |
| std::unique_ptr<ServerWindow> w2 = CreateChildWindow(WindowId(1, 5)); |
| @@ -1402,6 +1477,7 @@ TEST_F(EventDispatcherTest, ModalWindowEventOnModalParent) { |
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| event_dispatcher()->ProcessEvent(mouse_pressed, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| std::unique_ptr<DispatchedEventDetails> details = |
| test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| @@ -1418,7 +1494,7 @@ TEST_F(EventDispatcherTest, ModalWindowEventOnModalParent) { |
| } |
| // Tests that events on a modal child target the modal child itself. |
| -TEST_F(EventDispatcherTest, ModalWindowEventOnModalChild) { |
| +TEST_P(EventDispatcherTest, ModalWindowEventOnModalChild) { |
| std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); |
| std::unique_ptr<ServerWindow> w2 = CreateChildWindow(WindowId(1, 5)); |
| @@ -1435,6 +1511,7 @@ TEST_F(EventDispatcherTest, ModalWindowEventOnModalChild) { |
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| event_dispatcher()->ProcessEvent(mouse_pressed, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| std::unique_ptr<DispatchedEventDetails> details = |
| test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| @@ -1452,7 +1529,7 @@ TEST_F(EventDispatcherTest, ModalWindowEventOnModalChild) { |
| // Tests that events on an unrelated window are not affected by the modal |
| // window. |
| -TEST_F(EventDispatcherTest, ModalWindowEventOnUnrelatedWindow) { |
| +TEST_P(EventDispatcherTest, ModalWindowEventOnUnrelatedWindow) { |
| std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); |
| std::unique_ptr<ServerWindow> w2 = CreateChildWindow(WindowId(1, 5)); |
| std::unique_ptr<ServerWindow> w3 = CreateChildWindow(WindowId(1, 6)); |
| @@ -1471,6 +1548,7 @@ TEST_F(EventDispatcherTest, ModalWindowEventOnUnrelatedWindow) { |
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| event_dispatcher()->ProcessEvent(mouse_pressed, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| std::unique_ptr<DispatchedEventDetails> details = |
| test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| @@ -1488,7 +1566,7 @@ TEST_F(EventDispatcherTest, ModalWindowEventOnUnrelatedWindow) { |
| // Tests that events events on a descendant of a modal parent target the modal |
| // child. |
| -TEST_F(EventDispatcherTest, ModalWindowEventOnDescendantOfModalParent) { |
| +TEST_P(EventDispatcherTest, ModalWindowEventOnDescendantOfModalParent) { |
| std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); |
| std::unique_ptr<ServerWindow> w11 = |
| CreateChildWindowWithParent(WindowId(1, 4), w1.get()); |
| @@ -1508,6 +1586,7 @@ TEST_F(EventDispatcherTest, ModalWindowEventOnDescendantOfModalParent) { |
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| event_dispatcher()->ProcessEvent(mouse_pressed, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| std::unique_ptr<DispatchedEventDetails> details = |
| test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| @@ -1524,7 +1603,7 @@ TEST_F(EventDispatcherTest, ModalWindowEventOnDescendantOfModalParent) { |
| } |
| // Tests that events on a system modal window target the modal window itself. |
| -TEST_F(EventDispatcherTest, ModalWindowEventOnSystemModal) { |
| +TEST_P(EventDispatcherTest, ModalWindowEventOnSystemModal) { |
| std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); |
| root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| @@ -1537,6 +1616,7 @@ TEST_F(EventDispatcherTest, ModalWindowEventOnSystemModal) { |
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| event_dispatcher()->ProcessEvent(mouse_pressed, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| std::unique_ptr<DispatchedEventDetails> details = |
| test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| @@ -1553,7 +1633,7 @@ TEST_F(EventDispatcherTest, ModalWindowEventOnSystemModal) { |
| } |
| // Tests that events outside of system modal window target the modal window. |
| -TEST_F(EventDispatcherTest, ModalWindowEventOutsideSystemModal) { |
| +TEST_P(EventDispatcherTest, ModalWindowEventOutsideSystemModal) { |
| std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); |
| root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| @@ -1567,6 +1647,7 @@ TEST_F(EventDispatcherTest, ModalWindowEventOutsideSystemModal) { |
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| event_dispatcher()->ProcessEvent(mouse_pressed, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| std::unique_ptr<DispatchedEventDetails> details = |
| test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| @@ -1583,7 +1664,7 @@ TEST_F(EventDispatcherTest, ModalWindowEventOutsideSystemModal) { |
| } |
| // Tests events on a sub-window of system modal window target the window itself. |
| -TEST_F(EventDispatcherTest, ModalWindowEventSubWindowSystemModal) { |
| +TEST_P(EventDispatcherTest, ModalWindowEventSubWindowSystemModal) { |
| std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); |
| w1->SetModalType(MODAL_TYPE_SYSTEM); |
| event_dispatcher()->AddSystemModalWindow(w1.get()); |
| @@ -1616,6 +1697,7 @@ TEST_F(EventDispatcherTest, ModalWindowEventSubWindowSystemModal) { |
| ui::ET_TOUCH_PRESSED, kTouchData[i].location, base::TimeTicks(), |
| ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0))), |
| 0, EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| std::unique_ptr<DispatchedEventDetails> details = |
| test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| ASSERT_TRUE(details) << " details is nullptr " << i; |
| @@ -1627,12 +1709,13 @@ TEST_F(EventDispatcherTest, ModalWindowEventSubWindowSystemModal) { |
| ui::ET_TOUCH_RELEASED, kTouchData[i].location, base::TimeTicks(), |
| ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0))), |
| 0, EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| } |
| } |
| // Tests that setting capture to a descendant of a modal parent fails. |
| -TEST_F(EventDispatcherTest, ModalWindowSetCaptureDescendantOfModalParent) { |
| +TEST_P(EventDispatcherTest, ModalWindowSetCaptureDescendantOfModalParent) { |
| std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); |
| std::unique_ptr<ServerWindow> w11 = |
| CreateChildWindowWithParent(WindowId(1, 4), w1.get()); |
| @@ -1651,7 +1734,7 @@ TEST_F(EventDispatcherTest, ModalWindowSetCaptureDescendantOfModalParent) { |
| } |
| // Tests that setting capture to a window unrelated to a modal parent works. |
| -TEST_F(EventDispatcherTest, ModalWindowSetCaptureUnrelatedWindow) { |
| +TEST_P(EventDispatcherTest, ModalWindowSetCaptureUnrelatedWindow) { |
| std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); |
| std::unique_ptr<ServerWindow> w2 = CreateChildWindow(WindowId(1, 4)); |
| std::unique_ptr<ServerWindow> w3 = CreateChildWindow(WindowId(1, 5)); |
| @@ -1669,7 +1752,7 @@ TEST_F(EventDispatcherTest, ModalWindowSetCaptureUnrelatedWindow) { |
| } |
| // Tests that setting capture fails when there is a system modal window. |
| -TEST_F(EventDispatcherTest, ModalWindowSystemSetCapture) { |
| +TEST_P(EventDispatcherTest, ModalWindowSystemSetCapture) { |
| std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); |
| std::unique_ptr<ServerWindow> w2 = CreateChildWindow(WindowId(1, 4)); |
| @@ -1684,7 +1767,7 @@ TEST_F(EventDispatcherTest, ModalWindowSystemSetCapture) { |
| } |
| // Tests having multiple system modal windows. |
| -TEST_F(EventDispatcherTest, ModalWindowMultipleSystemModals) { |
| +TEST_P(EventDispatcherTest, ModalWindowMultipleSystemModals) { |
| std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); |
| std::unique_ptr<ServerWindow> w2 = CreateChildWindow(WindowId(1, 4)); |
| std::unique_ptr<ServerWindow> w3 = CreateChildWindow(WindowId(1, 5)); |
| @@ -1726,7 +1809,7 @@ TEST_F(EventDispatcherTest, ModalWindowMultipleSystemModals) { |
| EXPECT_EQ(nullptr, GetActiveSystemModalWindow()); |
| } |
| -TEST_F(EventDispatcherTest, CaptureNotResetOnParentChange) { |
| +TEST_P(EventDispatcherTest, CaptureNotResetOnParentChange) { |
| std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); |
| w1->set_event_targeting_policy(mojom::EventTargetingPolicy::DESCENDANTS_ONLY); |
| std::unique_ptr<ServerWindow> w11 = |
| @@ -1746,6 +1829,7 @@ TEST_F(EventDispatcherTest, CaptureNotResetOnParentChange) { |
| event_dispatcher()->ProcessEvent(mouse_pressed, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| event_dispatcher()->SetCaptureWindow(w11.get(), kClientAreaId); |
| + RunTasks(); |
| std::unique_ptr<DispatchedEventDetails> details = |
| test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| @@ -1761,7 +1845,7 @@ TEST_F(EventDispatcherTest, CaptureNotResetOnParentChange) { |
| EventDispatcherTestApi(event_dispatcher()).capture_window()); |
| } |
| -TEST_F(EventDispatcherTest, ChangeCaptureFromClientToNonclient) { |
| +TEST_P(EventDispatcherTest, ChangeCaptureFromClientToNonclient) { |
| std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| event_dispatcher()->SetCaptureWindow(child.get(), kNonclientAreaId); |
| EXPECT_EQ(kNonclientAreaId, |
| @@ -1776,7 +1860,7 @@ TEST_F(EventDispatcherTest, ChangeCaptureFromClientToNonclient) { |
| EXPECT_EQ(kClientAreaId, event_dispatcher()->capture_window_client_id()); |
| } |
| -TEST_F(EventDispatcherTest, MoveMouseFromNoTargetToValidTarget) { |
| +TEST_P(EventDispatcherTest, MoveMouseFromNoTargetToValidTarget) { |
| ServerWindow* root = root_window(); |
| root->set_event_targeting_policy( |
| mojom::EventTargetingPolicy::DESCENDANTS_ONLY); |
| @@ -1802,7 +1886,7 @@ TEST_F(EventDispatcherTest, MoveMouseFromNoTargetToValidTarget) { |
| tests, arraysize(tests)); |
| } |
| -TEST_F(EventDispatcherTest, NoTargetToTargetWithMouseDown) { |
| +TEST_P(EventDispatcherTest, NoTargetToTargetWithMouseDown) { |
| ServerWindow* root = root_window(); |
| root->set_event_targeting_policy( |
| mojom::EventTargetingPolicy::DESCENDANTS_ONLY); |
| @@ -1835,7 +1919,7 @@ TEST_F(EventDispatcherTest, NoTargetToTargetWithMouseDown) { |
| tests, arraysize(tests)); |
| } |
| -TEST_F(EventDispatcherTest, DontSendExitToSameClientWhenCaptureChanges) { |
| +TEST_P(EventDispatcherTest, DontSendExitToSameClientWhenCaptureChanges) { |
| ServerWindow* root = root_window(); |
| root->set_event_targeting_policy( |
| mojom::EventTargetingPolicy::DESCENDANTS_ONLY); |
| @@ -1868,7 +1952,7 @@ TEST_F(EventDispatcherTest, DontSendExitToSameClientWhenCaptureChanges) { |
| EXPECT_FALSE(test_event_dispatcher_delegate()->has_queued_events()); |
| } |
| -TEST_F(EventDispatcherTest, MousePointerClearedOnDestroy) { |
| +TEST_P(EventDispatcherTest, MousePointerClearedOnDestroy) { |
| root_window()->set_event_targeting_policy( |
| mojom::EventTargetingPolicy::DESCENDANTS_ONLY); |
| std::unique_ptr<ServerWindow> c1 = CreateChildWindow(WindowId(1, 3)); |
| @@ -1877,12 +1961,13 @@ TEST_F(EventDispatcherTest, MousePointerClearedOnDestroy) { |
| c1->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| event_dispatcher()->SetMousePointerDisplayLocation(gfx::Point(15, 15), 0); |
| + RunTasks(); |
| EXPECT_EQ(c1.get(), event_dispatcher()->mouse_cursor_source_window()); |
| c1.reset(); |
| EXPECT_EQ(nullptr, event_dispatcher()->mouse_cursor_source_window()); |
| } |
| -TEST_F(EventDispatcherTest, LocationHonorsTransform) { |
| +TEST_P(EventDispatcherTest, LocationHonorsTransform) { |
| std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| gfx::Transform transform; |
| @@ -1898,6 +1983,7 @@ TEST_F(EventDispatcherTest, LocationHonorsTransform) { |
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| event_dispatcher()->ProcessEvent(ui_event, 0, |
| EventDispatcher::AcceleratorMatchPhase::ANY); |
| + RunTasks(); |
| std::unique_ptr<DispatchedEventDetails> details = |
| test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| @@ -1912,6 +1998,8 @@ TEST_F(EventDispatcherTest, LocationHonorsTransform) { |
| EXPECT_EQ(gfx::Point(5, 7), dispatched_event->location()); |
| } |
| +INSTANTIATE_TEST_CASE_P(/* no prefix */, EventDispatcherTest, testing::Bool()); |
| + |
| } // namespace test |
| } // namespace ws |
| } // namespace ui |