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..a952d694dba183523a574c5162c01562ba1834da 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" |
@@ -137,6 +140,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; |
@@ -192,39 +196,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 +213,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 +232,7 @@ class EventDispatcherTest : public testing::Test, |
ServerWindow* GetActiveSystemModalWindow() const; |
protected: |
- // testing::Test: |
+ // testing::TestWithParam<bool>: |
void SetUp() override; |
private: |
@@ -264,9 +246,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 +338,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 +358,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 +370,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 +385,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 +405,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 +443,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 +455,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 +464,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 +478,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 +503,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 +516,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 +529,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 +565,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 +574,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 +582,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 +625,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 +668,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 +686,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 +702,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 +716,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 +731,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 +745,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 +763,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 +773,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 +786,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 +802,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 +816,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 +834,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 +849,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 +874,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 +885,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 +895,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 +905,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 +922,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 +930,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 +951,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 +965,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 +987,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 +998,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 +1009,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 +1025,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 +1054,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 +1076,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 +1094,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 +1105,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 +1115,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 +1126,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 +1137,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 +1150,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 +1163,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 +1211,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 +1245,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 +1256,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 +1267,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 +1280,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 +1296,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 +1319,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 +1336,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 +1352,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 +1362,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 +1374,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 +1397,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 +1414,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 +1426,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 +1440,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 +1454,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 +1471,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 +1488,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 +1505,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 +1523,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 +1542,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 +1560,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 +1580,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 +1597,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 +1610,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 +1627,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 +1641,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 +1658,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 +1691,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 +1703,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 +1728,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 +1746,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 +1761,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 +1803,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 +1823,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 +1839,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 +1854,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 +1880,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 +1913,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 +1946,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 +1955,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 |