| 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 e6d241bc1ab362652e6fb40315328f48ee3767db..b1eab7ef7cddf4d05eb92e36d92335d682e0cd27 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"
|
| @@ -192,39 +195,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),
|
| - 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() {}
|
| @@ -236,6 +212,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();
|
| @@ -250,7 +231,7 @@ class EventDispatcherTest : public testing::Test,
|
| ServerWindow* GetActiveSystemModalWindow() const;
|
|
|
| protected:
|
| - // testing::Test:
|
| + // testing::TestWithParam<bool>:
|
| void SetUp() override;
|
|
|
| private:
|
| @@ -264,9 +245,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() {
|
| + 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),
|
| + 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();
|
| }
|
| @@ -316,7 +337,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_ =
|
| @@ -331,7 +357,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));
|
| @@ -343,6 +369,7 @@ TEST_F(EventDispatcherTest, ProcessEvent) {
|
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
|
| event_dispatcher()->ProcessEvent(ui_event,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
|
|
| std::unique_ptr<DispatchedEventDetails> details =
|
| test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
|
| @@ -357,11 +384,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,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
|
|
| // Event wasn't dispatched to a target.
|
| std::unique_ptr<DispatchedEventDetails> details =
|
| @@ -376,7 +404,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);
|
| @@ -414,7 +442,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();
|
| @@ -426,6 +454,7 @@ TEST_F(EventDispatcherTest, EventMatching) {
|
|
|
| ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN);
|
| dispatcher->ProcessEvent(key, EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
| EXPECT_EQ(accelerator_1,
|
| event_dispatcher_delegate->GetAndClearLastAccelerator());
|
|
|
| @@ -434,11 +463,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, 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, EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
| EXPECT_EQ(0u, event_dispatcher_delegate->GetAndClearLastAccelerator());
|
|
|
| uint32_t accelerator_2 = 2;
|
| @@ -446,16 +477,18 @@ TEST_F(EventDispatcherTest, EventMatching) {
|
| ui::mojom::kEventFlagNone);
|
| dispatcher->AddAccelerator(accelerator_2, std::move(matcher));
|
| dispatcher->ProcessEvent(key, EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
| EXPECT_EQ(accelerator_2,
|
| event_dispatcher_delegate->GetAndClearLastAccelerator());
|
|
|
| dispatcher->RemoveAccelerator(accelerator_2);
|
| dispatcher->ProcessEvent(key, 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();
|
| @@ -469,6 +502,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, EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
| EXPECT_EQ(accelerator_1,
|
| event_dispatcher_delegate->GetAndClearLastAccelerator());
|
| std::unique_ptr<DispatchedEventDetails> details =
|
| @@ -481,6 +515,7 @@ TEST_F(EventDispatcherTest, PostTargetAccelerator) {
|
|
|
| // With a focused window the event should be dispatched.
|
| dispatcher->ProcessEvent(key, EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
| EXPECT_EQ(0u, event_dispatcher_delegate->GetAndClearLastAccelerator());
|
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
|
| EXPECT_TRUE(details);
|
| @@ -493,13 +528,14 @@ TEST_F(EventDispatcherTest, PostTargetAccelerator) {
|
|
|
| // Post deletion there should be no accelerator
|
| dispatcher->ProcessEvent(key, 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();
|
| @@ -528,6 +564,7 @@ TEST_F(EventDispatcherTest, ProcessPost) {
|
| // DispatchInputEventToWindow().
|
| ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN);
|
| dispatcher->ProcessEvent(key, EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
| EXPECT_EQ(EventDispatcherDelegate::AcceleratorPhase::PRE,
|
| event_dispatcher_delegate->last_accelerator_phase());
|
| EXPECT_EQ(pre_id, event_dispatcher_delegate->GetAndClearLastAccelerator());
|
| @@ -536,6 +573,7 @@ TEST_F(EventDispatcherTest, ProcessPost) {
|
| // Dispatch for POST, which should trigger POST.
|
| dispatcher->ProcessEvent(key,
|
| EventDispatcher::AcceleratorMatchPhase::POST_ONLY);
|
| + RunTasks();
|
| std::unique_ptr<DispatchedEventDetails> details =
|
| event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
|
| ASSERT_TRUE(details);
|
| @@ -543,7 +581,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));
|
|
|
| @@ -586,7 +624,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));
|
| @@ -629,7 +667,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));
|
| @@ -647,6 +685,7 @@ TEST_F(EventDispatcherTest, ClientAreaGoesToOwner) {
|
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
|
| dispatcher->ProcessEvent(press_event,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
|
|
| // Events should target child and be in the non-client area.
|
| std::unique_ptr<DispatchedEventDetails> details =
|
| @@ -662,6 +701,7 @@ TEST_F(EventDispatcherTest, ClientAreaGoesToOwner) {
|
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, 0));
|
| dispatcher->ProcessEvent(move_event,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
|
|
| // Still same target.
|
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
|
| @@ -675,6 +715,7 @@ TEST_F(EventDispatcherTest, ClientAreaGoesToOwner) {
|
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
|
| dispatcher->ProcessEvent(release_event,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
|
|
| // The event should not have been dispatched to the delegate.
|
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
|
| @@ -689,6 +730,7 @@ TEST_F(EventDispatcherTest, ClientAreaGoesToOwner) {
|
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
|
| dispatcher->ProcessEvent(press_event2,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
|
| EXPECT_TRUE(event_dispatcher_delegate->has_queued_events());
|
| ASSERT_EQ(child.get(), details->window);
|
| @@ -702,7 +744,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));
|
| @@ -720,6 +762,7 @@ TEST_F(EventDispatcherTest, AdditionalClientArea) {
|
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
|
| event_dispatcher()->ProcessEvent(press_event,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
|
|
| // Events should target child and be in the client area.
|
| std::unique_ptr<DispatchedEventDetails> details =
|
| @@ -729,7 +772,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));
|
| @@ -742,6 +785,7 @@ TEST_F(EventDispatcherTest, HitTestMask) {
|
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, 0));
|
| event_dispatcher()->ProcessEvent(move1,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
|
|
| // Event went through the child window and hit the root.
|
| std::unique_ptr<DispatchedEventDetails> details1 =
|
| @@ -757,6 +801,7 @@ TEST_F(EventDispatcherTest, HitTestMask) {
|
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, 0));
|
| event_dispatcher()->ProcessEvent(move2,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
|
|
| // Mouse exits the root.
|
| std::unique_ptr<DispatchedEventDetails> details2 =
|
| @@ -770,7 +815,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));
|
|
|
| @@ -788,6 +833,7 @@ TEST_F(EventDispatcherTest, DontFocusOnSecondDown) {
|
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
|
| dispatcher->ProcessEvent(press_event,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
| std::unique_ptr<DispatchedEventDetails> details =
|
| event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
|
| EXPECT_FALSE(event_dispatcher_delegate->has_queued_events());
|
| @@ -802,13 +848,14 @@ TEST_F(EventDispatcherTest, DontFocusOnSecondDown) {
|
| ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2)));
|
| dispatcher->ProcessEvent(touch_event,
|
| 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));
|
|
|
| @@ -826,6 +873,7 @@ TEST_F(EventDispatcherTest, TwoPointersActive) {
|
| ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1)));
|
| dispatcher->ProcessEvent(touch_event1,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
| std::unique_ptr<DispatchedEventDetails> details =
|
| event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
|
| EXPECT_EQ(child1.get(), details->window);
|
| @@ -836,6 +884,7 @@ TEST_F(EventDispatcherTest, TwoPointersActive) {
|
| ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1)));
|
| dispatcher->ProcessEvent(drag_event1,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
|
| EXPECT_EQ(child1.get(), details->window);
|
|
|
| @@ -845,6 +894,7 @@ TEST_F(EventDispatcherTest, TwoPointersActive) {
|
| ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2)));
|
| dispatcher->ProcessEvent(touch_event2,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
|
| EXPECT_EQ(child2.get(), details->window);
|
|
|
| @@ -854,12 +904,14 @@ TEST_F(EventDispatcherTest, TwoPointersActive) {
|
| ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2)));
|
| dispatcher->ProcessEvent(drag_event2,
|
| 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,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
|
| EXPECT_EQ(child1.get(), details->window);
|
|
|
| @@ -869,6 +921,7 @@ TEST_F(EventDispatcherTest, TwoPointersActive) {
|
| ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1)));
|
| dispatcher->ProcessEvent(touch_release,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
|
| EXPECT_EQ(child1.get(), details->window);
|
| const ui::PointerEvent touch_event3(ui::TouchEvent(
|
| @@ -876,11 +929,12 @@ TEST_F(EventDispatcherTest, TwoPointersActive) {
|
| ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2)));
|
| dispatcher->ProcessEvent(touch_event3,
|
| 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));
|
| @@ -896,6 +950,7 @@ TEST_F(EventDispatcherTest, DestroyWindowWhileGettingEvents) {
|
| ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1)));
|
| dispatcher->ProcessEvent(touch_event1,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
| std::unique_ptr<DispatchedEventDetails> details =
|
| event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
|
| EXPECT_FALSE(event_dispatcher_delegate->has_queued_events());
|
| @@ -909,11 +964,12 @@ TEST_F(EventDispatcherTest, DestroyWindowWhileGettingEvents) {
|
| ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1)));
|
| dispatcher->ProcessEvent(drag_event1,
|
| 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));
|
|
|
| @@ -930,6 +986,7 @@ TEST_F(EventDispatcherTest, MouseInExtendedHitTestRegion) {
|
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
|
| dispatcher->ProcessEvent(ui_event,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
| std::unique_ptr<DispatchedEventDetails> details =
|
| event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
|
| ASSERT_EQ(root, details->window);
|
| @@ -940,6 +997,7 @@ TEST_F(EventDispatcherTest, MouseInExtendedHitTestRegion) {
|
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
|
| dispatcher->ProcessEvent(release_event,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
|
| EXPECT_FALSE(event_dispatcher_delegate->has_queued_events());
|
| ASSERT_EQ(root, details->window);
|
| @@ -950,6 +1008,7 @@ TEST_F(EventDispatcherTest, MouseInExtendedHitTestRegion) {
|
| child->set_extended_hit_test_region(gfx::Insets(5, 5, 5, 5));
|
| dispatcher->ProcessEvent(ui_event,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
|
| EXPECT_EQ(root, details->window);
|
| EXPECT_EQ(ui::ET_POINTER_EXITED, details->event->type());
|
| @@ -965,7 +1024,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));
|
|
|
| @@ -994,7 +1053,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));
|
|
|
| @@ -1016,6 +1075,7 @@ TEST_F(EventDispatcherTest, SetExplicitCapture) {
|
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
|
| dispatcher->ProcessEvent(left_press_event,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
|
|
| // Events should target child.
|
| std::unique_ptr<DispatchedEventDetails> details =
|
| @@ -1033,6 +1093,7 @@ TEST_F(EventDispatcherTest, SetExplicitCapture) {
|
| ui::EF_RIGHT_MOUSE_BUTTON));
|
| dispatcher->ProcessEvent(right_press_event,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
|
| EXPECT_TRUE(IsMouseButtonDown());
|
|
|
| @@ -1043,6 +1104,7 @@ TEST_F(EventDispatcherTest, SetExplicitCapture) {
|
| ui::EF_LEFT_MOUSE_BUTTON));
|
| dispatcher->ProcessEvent(left_release_event,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
|
| EXPECT_TRUE(IsMouseButtonDown());
|
|
|
| @@ -1052,6 +1114,7 @@ TEST_F(EventDispatcherTest, SetExplicitCapture) {
|
| ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2)));
|
| dispatcher->ProcessEvent(touch_event,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
|
| EXPECT_TRUE(IsMouseButtonDown());
|
|
|
| @@ -1062,6 +1125,7 @@ TEST_F(EventDispatcherTest, SetExplicitCapture) {
|
| ui::EF_RIGHT_MOUSE_BUTTON));
|
| dispatcher->ProcessEvent(move_event,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
|
| EXPECT_TRUE(IsMouseButtonDown());
|
|
|
| @@ -1072,6 +1136,7 @@ TEST_F(EventDispatcherTest, SetExplicitCapture) {
|
| ui::EF_RIGHT_MOUSE_BUTTON, ui::EF_RIGHT_MOUSE_BUTTON));
|
| dispatcher->ProcessEvent(right_release_event,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
|
| EXPECT_FALSE(IsMouseButtonDown());
|
| }
|
| @@ -1084,6 +1149,7 @@ TEST_F(EventDispatcherTest, SetExplicitCapture) {
|
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
|
| dispatcher->ProcessEvent(press_event,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
|
|
| // Events should target the root.
|
| std::unique_ptr<DispatchedEventDetails> details =
|
| @@ -1096,7 +1162,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));
|
|
|
| @@ -1144,6 +1210,7 @@ TEST_F(EventDispatcherTest, ExplicitCaptureOverridesImplicitCapture) {
|
| ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1)));
|
| dispatcher->ProcessEvent(touch_event,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
| }
|
|
|
| std::unique_ptr<DispatchedEventDetails> details =
|
| @@ -1177,6 +1244,7 @@ TEST_F(EventDispatcherTest, ExplicitCaptureOverridesImplicitCapture) {
|
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
|
| dispatcher->ProcessEvent(press_event,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
|
|
| // Events should target the root.
|
| details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
|
| @@ -1187,7 +1255,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));
|
|
|
| @@ -1198,6 +1266,7 @@ TEST_F(EventDispatcherTest, CaptureUpdatesActivePointerTargets) {
|
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
|
| dispatcher->ProcessEvent(press_event,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
|
|
| std::unique_ptr<DispatchedEventDetails> details =
|
| test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
|
| @@ -1210,6 +1279,7 @@ TEST_F(EventDispatcherTest, CaptureUpdatesActivePointerTargets) {
|
| ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1)));
|
| dispatcher->ProcessEvent(touch_event,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
| }
|
|
|
| ASSERT_TRUE(AreAnyPointersDown());
|
| @@ -1225,7 +1295,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));
|
|
|
| @@ -1248,7 +1318,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));
|
|
|
| @@ -1265,7 +1335,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));
|
|
|
| @@ -1281,6 +1351,7 @@ TEST_F(EventDispatcherTest, CaptureInNonClientAreaOverridesActualPoint) {
|
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
|
| event_dispatcher()->ProcessEvent(press_event,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
|
|
| // Events should target child and be in the client area.
|
| std::unique_ptr<DispatchedEventDetails> details =
|
| @@ -1290,7 +1361,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));
|
| @@ -1302,6 +1373,7 @@ TEST_F(EventDispatcherTest, ProcessPointerEvents) {
|
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
|
| event_dispatcher()->ProcessEvent(
|
| pointer_event, EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
|
|
| std::unique_ptr<DispatchedEventDetails> details =
|
| test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
|
| @@ -1324,6 +1396,7 @@ TEST_F(EventDispatcherTest, ProcessPointerEvents) {
|
| touch_id)));
|
| event_dispatcher()->ProcessEvent(
|
| pointer_event, EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
|
|
| std::unique_ptr<DispatchedEventDetails> details =
|
| test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
|
| @@ -1340,7 +1413,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));
|
| @@ -1352,6 +1425,7 @@ TEST_F(EventDispatcherTest, ResetClearsPointerDown) {
|
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
|
| event_dispatcher()->ProcessEvent(ui_event,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
|
|
| std::unique_ptr<DispatchedEventDetails> details =
|
| test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
|
| @@ -1365,7 +1439,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));
|
|
|
| @@ -1379,7 +1453,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));
|
|
|
| @@ -1396,6 +1470,7 @@ TEST_F(EventDispatcherTest, ModalWindowEventOnModalParent) {
|
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
|
| event_dispatcher()->ProcessEvent(mouse_pressed,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
|
|
| std::unique_ptr<DispatchedEventDetails> details =
|
| test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
|
| @@ -1412,7 +1487,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));
|
|
|
| @@ -1429,6 +1504,7 @@ TEST_F(EventDispatcherTest, ModalWindowEventOnModalChild) {
|
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
|
| event_dispatcher()->ProcessEvent(mouse_pressed,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
|
|
| std::unique_ptr<DispatchedEventDetails> details =
|
| test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
|
| @@ -1446,7 +1522,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));
|
| @@ -1465,6 +1541,7 @@ TEST_F(EventDispatcherTest, ModalWindowEventOnUnrelatedWindow) {
|
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
|
| event_dispatcher()->ProcessEvent(mouse_pressed,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
|
|
| std::unique_ptr<DispatchedEventDetails> details =
|
| test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
|
| @@ -1482,7 +1559,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());
|
| @@ -1502,6 +1579,7 @@ TEST_F(EventDispatcherTest, ModalWindowEventOnDescendantOfModalParent) {
|
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
|
| event_dispatcher()->ProcessEvent(mouse_pressed,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
|
|
| std::unique_ptr<DispatchedEventDetails> details =
|
| test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
|
| @@ -1518,7 +1596,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));
|
| @@ -1531,6 +1609,7 @@ TEST_F(EventDispatcherTest, ModalWindowEventOnSystemModal) {
|
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
|
| event_dispatcher()->ProcessEvent(mouse_pressed,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
|
|
| std::unique_ptr<DispatchedEventDetails> details =
|
| test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
|
| @@ -1547,7 +1626,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));
|
| @@ -1561,6 +1640,7 @@ TEST_F(EventDispatcherTest, ModalWindowEventOutsideSystemModal) {
|
| base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
|
| event_dispatcher()->ProcessEvent(mouse_pressed,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
|
|
| std::unique_ptr<DispatchedEventDetails> details =
|
| test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
|
| @@ -1577,7 +1657,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());
|
| @@ -1610,6 +1690,7 @@ TEST_F(EventDispatcherTest, ModalWindowEventSubWindowSystemModal) {
|
| ui::ET_TOUCH_PRESSED, kTouchData[i].location, base::TimeTicks(),
|
| ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0))),
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| + RunTasks();
|
| std::unique_ptr<DispatchedEventDetails> details =
|
| test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
|
| ASSERT_TRUE(details) << " details is nullptr " << i;
|
| @@ -1621,12 +1702,13 @@ TEST_F(EventDispatcherTest, ModalWindowEventSubWindowSystemModal) {
|
| ui::ET_TOUCH_RELEASED, kTouchData[i].location, base::TimeTicks(),
|
| ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 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());
|
| @@ -1645,7 +1727,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));
|
| @@ -1663,7 +1745,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));
|
|
|
| @@ -1678,7 +1760,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));
|
| @@ -1720,7 +1802,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 =
|
| @@ -1740,6 +1822,7 @@ TEST_F(EventDispatcherTest, CaptureNotResetOnParentChange) {
|
| event_dispatcher()->ProcessEvent(mouse_pressed,
|
| EventDispatcher::AcceleratorMatchPhase::ANY);
|
| event_dispatcher()->SetCaptureWindow(w11.get(), kClientAreaId);
|
| + RunTasks();
|
|
|
| std::unique_ptr<DispatchedEventDetails> details =
|
| test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
|
| @@ -1755,7 +1838,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,
|
| @@ -1770,7 +1853,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);
|
| @@ -1796,7 +1879,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);
|
| @@ -1829,7 +1912,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);
|
| @@ -1862,7 +1945,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));
|
| @@ -1871,11 +1954,14 @@ TEST_F(EventDispatcherTest, MousePointerClearedOnDestroy) {
|
| c1->SetBounds(gfx::Rect(10, 10, 20, 20));
|
|
|
| event_dispatcher()->SetMousePointerScreenLocation(gfx::Point(15, 15));
|
| + RunTasks();
|
| EXPECT_EQ(c1.get(), event_dispatcher()->mouse_cursor_source_window());
|
| c1.reset();
|
| EXPECT_EQ(nullptr, event_dispatcher()->mouse_cursor_source_window());
|
| }
|
|
|
| +INSTANTIATE_TEST_CASE_P(/* no prefix */, EventDispatcherTest, testing::Bool());
|
| +
|
| } // namespace test
|
| } // namespace ws
|
| } // namespace ui
|
|
|