| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "services/ui/ws/event_dispatcher.h" | 5 #include "services/ui/ws/event_dispatcher.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <queue> | 10 #include <queue> |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 ServerWindow* lost_capture_window() { return lost_capture_window_; } | 99 ServerWindow* lost_capture_window() { return lost_capture_window_; } |
| 100 | 100 |
| 101 // EventDispatcherDelegate: | 101 // EventDispatcherDelegate: |
| 102 void SetFocusedWindowFromEventDispatcher(ServerWindow* window) override { | 102 void SetFocusedWindowFromEventDispatcher(ServerWindow* window) override { |
| 103 focused_window_ = window; | 103 focused_window_ = window; |
| 104 } | 104 } |
| 105 | 105 |
| 106 private: | 106 private: |
| 107 // EventDispatcherDelegate: | 107 // EventDispatcherDelegate: |
| 108 void OnAccelerator(uint32_t accelerator, | 108 void OnAccelerator(uint32_t accelerator, |
| 109 const int64_t display_id, |
| 109 const ui::Event& event, | 110 const ui::Event& event, |
| 110 AcceleratorPhase phase) override { | 111 AcceleratorPhase phase) override { |
| 111 EXPECT_EQ(0u, last_accelerator_); | 112 EXPECT_EQ(0u, last_accelerator_); |
| 112 last_accelerator_ = accelerator; | 113 last_accelerator_ = accelerator; |
| 113 last_accelerator_phase_ = phase; | 114 last_accelerator_phase_ = phase; |
| 114 } | 115 } |
| 115 ServerWindow* GetFocusedWindowForEventDispatcher() override { | 116 ServerWindow* GetFocusedWindowForEventDispatcher( |
| 117 const int64_t display_id) override { |
| 116 return focused_window_; | 118 return focused_window_; |
| 117 } | 119 } |
| 118 void SetNativeCapture(ServerWindow* window) override {} | 120 void SetNativeCapture(ServerWindow* window) override {} |
| 119 void ReleaseNativeCapture() override { | 121 void ReleaseNativeCapture() override { |
| 120 if (delegate_) | 122 if (delegate_) |
| 121 delegate_->ReleaseCapture(); | 123 delegate_->ReleaseCapture(); |
| 122 } | 124 } |
| 123 void UpdateNativeCursorFromDispatcher() override {} | 125 void UpdateNativeCursorFromDispatcher() override {} |
| 124 void OnCaptureChanged(ServerWindow* new_capture_window, | 126 void OnCaptureChanged(ServerWindow* new_capture_window, |
| 125 ServerWindow* old_capture_window) override { | 127 ServerWindow* old_capture_window) override { |
| 126 lost_capture_window_ = old_capture_window; | 128 lost_capture_window_ = old_capture_window; |
| 127 } | 129 } |
| 128 void OnMouseCursorLocationChanged(const gfx::Point& point) override {} | 130 void OnMouseCursorLocationChanged(const gfx::Point& point, |
| 131 const int64_t display_id) override {} |
| 129 void DispatchInputEventToWindow(ServerWindow* target, | 132 void DispatchInputEventToWindow(ServerWindow* target, |
| 130 ClientSpecificId client_id, | 133 ClientSpecificId client_id, |
| 134 const int64_t display_id, |
| 131 const ui::Event& event, | 135 const ui::Event& event, |
| 132 Accelerator* accelerator) override { | 136 Accelerator* accelerator) override { |
| 133 std::unique_ptr<DispatchedEventDetails> details(new DispatchedEventDetails); | 137 std::unique_ptr<DispatchedEventDetails> details(new DispatchedEventDetails); |
| 134 details->window = target; | 138 details->window = target; |
| 135 details->client_id = client_id; | 139 details->client_id = client_id; |
| 136 details->event = ui::Event::Clone(event); | 140 details->event = ui::Event::Clone(event); |
| 137 details->accelerator = accelerator; | 141 details->accelerator = accelerator; |
| 138 dispatched_event_queue_.push(std::move(details)); | 142 dispatched_event_queue_.push(std::move(details)); |
| 139 } | 143 } |
| 140 ClientSpecificId GetEventTargetClientId(const ServerWindow* window, | 144 ClientSpecificId GetEventTargetClientId(const ServerWindow* window, |
| 141 bool in_nonclient_area) override { | 145 bool in_nonclient_area) override { |
| 142 return in_nonclient_area ? kNonclientAreaId : kClientAreaId; | 146 return in_nonclient_area ? kNonclientAreaId : kClientAreaId; |
| 143 } | 147 } |
| 144 ServerWindow* GetRootWindowContaining(gfx::Point* location) override { | 148 ServerWindow* GetRootWindowContaining(gfx::Point* location_in_display, |
| 149 int64_t* display_id) override { |
| 145 return root_; | 150 return root_; |
| 146 } | 151 } |
| 147 void OnEventTargetNotFound(const ui::Event& event) override { | 152 void OnEventTargetNotFound(const ui::Event& event, |
| 153 const int64_t display_id) override { |
| 148 last_event_target_not_found_ = ui::Event::Clone(event); | 154 last_event_target_not_found_ = ui::Event::Clone(event); |
| 149 } | 155 } |
| 150 | 156 |
| 151 Delegate* delegate_; | 157 Delegate* delegate_; |
| 152 ServerWindow* focused_window_; | 158 ServerWindow* focused_window_; |
| 153 ServerWindow* lost_capture_window_; | 159 ServerWindow* lost_capture_window_; |
| 154 uint32_t last_accelerator_; | 160 uint32_t last_accelerator_; |
| 155 AcceleratorPhase last_accelerator_phase_ = AcceleratorPhase::POST; | 161 AcceleratorPhase last_accelerator_phase_ = AcceleratorPhase::POST; |
| 156 std::queue<std::unique_ptr<DispatchedEventDetails>> dispatched_event_queue_; | 162 std::queue<std::unique_ptr<DispatchedEventDetails>> dispatched_event_queue_; |
| 157 ServerWindow* root_ = nullptr; | 163 ServerWindow* root_ = nullptr; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 } | 199 } |
| 194 | 200 |
| 195 void RunMouseEventTests(EventDispatcher* dispatcher, | 201 void RunMouseEventTests(EventDispatcher* dispatcher, |
| 196 TestEventDispatcherDelegate* dispatcher_delegate, | 202 TestEventDispatcherDelegate* dispatcher_delegate, |
| 197 MouseEventTest* tests, | 203 MouseEventTest* tests, |
| 198 size_t test_count) { | 204 size_t test_count) { |
| 199 for (size_t i = 0; i < test_count; ++i) { | 205 for (size_t i = 0; i < test_count; ++i) { |
| 200 const MouseEventTest& test = tests[i]; | 206 const MouseEventTest& test = tests[i]; |
| 201 ASSERT_FALSE(dispatcher_delegate->has_queued_events()) | 207 ASSERT_FALSE(dispatcher_delegate->has_queued_events()) |
| 202 << " unexpected queued events before running " << i; | 208 << " unexpected queued events before running " << i; |
| 203 dispatcher->ProcessEvent(ui::PointerEvent(test.input_event), | 209 dispatcher->ProcessEvent(ui::PointerEvent(test.input_event), 0, |
| 204 EventDispatcher::AcceleratorMatchPhase::ANY); | 210 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 205 | 211 |
| 206 std::unique_ptr<DispatchedEventDetails> details = | 212 std::unique_ptr<DispatchedEventDetails> details = |
| 207 dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 213 dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 208 ASSERT_NO_FATAL_FAILURE(ExpectDispatchedEventDetailsMatches( | 214 ASSERT_NO_FATAL_FAILURE(ExpectDispatchedEventDetailsMatches( |
| 209 details.get(), test.expected_target_window1, | 215 details.get(), test.expected_target_window1, |
| 210 test.expected_root_location1, test.expected_location1)) | 216 test.expected_root_location1, test.expected_location1)) |
| 211 << " details don't match " << i; | 217 << " details don't match " << i; |
| 212 details = dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 218 details = dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 213 ASSERT_NO_FATAL_FAILURE(ExpectDispatchedEventDetailsMatches( | 219 ASSERT_NO_FATAL_FAILURE(ExpectDispatchedEventDetailsMatches( |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 TEST_F(EventDispatcherTest, ProcessEvent) { | 340 TEST_F(EventDispatcherTest, ProcessEvent) { |
| 335 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 341 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 336 | 342 |
| 337 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 343 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 338 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 344 child->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 339 | 345 |
| 340 // Send event that is over child. | 346 // Send event that is over child. |
| 341 const ui::PointerEvent ui_event(ui::MouseEvent( | 347 const ui::PointerEvent ui_event(ui::MouseEvent( |
| 342 ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), gfx::Point(20, 25), | 348 ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), gfx::Point(20, 25), |
| 343 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 349 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 344 event_dispatcher()->ProcessEvent(ui_event, | 350 event_dispatcher()->ProcessEvent(ui_event, 0, |
| 345 EventDispatcher::AcceleratorMatchPhase::ANY); | 351 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 346 | 352 |
| 347 std::unique_ptr<DispatchedEventDetails> details = | 353 std::unique_ptr<DispatchedEventDetails> details = |
| 348 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 354 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 349 ASSERT_TRUE(details); | 355 ASSERT_TRUE(details); |
| 350 ASSERT_EQ(child.get(), details->window); | 356 ASSERT_EQ(child.get(), details->window); |
| 351 | 357 |
| 352 ASSERT_TRUE(details->event); | 358 ASSERT_TRUE(details->event); |
| 353 ASSERT_TRUE(details->event->IsPointerEvent()); | 359 ASSERT_TRUE(details->event->IsPointerEvent()); |
| 354 | 360 |
| 355 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); | 361 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); |
| 356 EXPECT_EQ(gfx::Point(20, 25), dispatched_event->root_location()); | 362 EXPECT_EQ(gfx::Point(20, 25), dispatched_event->root_location()); |
| 357 EXPECT_EQ(gfx::Point(10, 15), dispatched_event->location()); | 363 EXPECT_EQ(gfx::Point(10, 15), dispatched_event->location()); |
| 358 } | 364 } |
| 359 | 365 |
| 360 TEST_F(EventDispatcherTest, ProcessEventNoTarget) { | 366 TEST_F(EventDispatcherTest, ProcessEventNoTarget) { |
| 361 // Send event without a target. | 367 // Send event without a target. |
| 362 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE); | 368 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE); |
| 363 event_dispatcher()->ProcessEvent(key, | 369 event_dispatcher()->ProcessEvent(key, 0, |
| 364 EventDispatcher::AcceleratorMatchPhase::ANY); | 370 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 365 | 371 |
| 366 // Event wasn't dispatched to a target. | 372 // Event wasn't dispatched to a target. |
| 367 std::unique_ptr<DispatchedEventDetails> details = | 373 std::unique_ptr<DispatchedEventDetails> details = |
| 368 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 374 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 369 EXPECT_FALSE(details); | 375 EXPECT_FALSE(details); |
| 370 | 376 |
| 371 // Delegate was informed that there wasn't a target. | 377 // Delegate was informed that there wasn't a target. |
| 372 ui::Event* event_out = | 378 ui::Event* event_out = |
| 373 test_event_dispatcher_delegate()->last_event_target_not_found(); | 379 test_event_dispatcher_delegate()->last_event_target_not_found(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 TestEventDispatcherDelegate* event_dispatcher_delegate = | 424 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 419 test_event_dispatcher_delegate(); | 425 test_event_dispatcher_delegate(); |
| 420 EventDispatcher* dispatcher = event_dispatcher(); | 426 EventDispatcher* dispatcher = event_dispatcher(); |
| 421 | 427 |
| 422 mojom::EventMatcherPtr matcher = ui::CreateKeyMatcher( | 428 mojom::EventMatcherPtr matcher = ui::CreateKeyMatcher( |
| 423 ui::mojom::KeyboardCode::W, ui::mojom::kEventFlagControlDown); | 429 ui::mojom::KeyboardCode::W, ui::mojom::kEventFlagControlDown); |
| 424 uint32_t accelerator_1 = 1; | 430 uint32_t accelerator_1 = 1; |
| 425 dispatcher->AddAccelerator(accelerator_1, std::move(matcher)); | 431 dispatcher->AddAccelerator(accelerator_1, std::move(matcher)); |
| 426 | 432 |
| 427 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN); | 433 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN); |
| 428 dispatcher->ProcessEvent(key, EventDispatcher::AcceleratorMatchPhase::ANY); | 434 dispatcher->ProcessEvent(key, 0, EventDispatcher::AcceleratorMatchPhase::ANY); |
| 429 EXPECT_EQ(accelerator_1, | 435 EXPECT_EQ(accelerator_1, |
| 430 event_dispatcher_delegate->GetAndClearLastAccelerator()); | 436 event_dispatcher_delegate->GetAndClearLastAccelerator()); |
| 431 | 437 |
| 432 // EF_NUM_LOCK_ON should be ignored since CreateKeyMatcher defaults to | 438 // EF_NUM_LOCK_ON should be ignored since CreateKeyMatcher defaults to |
| 433 // ignoring. | 439 // ignoring. |
| 434 key = ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_W, | 440 key = ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_W, |
| 435 ui::EF_CONTROL_DOWN | ui::EF_NUM_LOCK_ON); | 441 ui::EF_CONTROL_DOWN | ui::EF_NUM_LOCK_ON); |
| 436 dispatcher->ProcessEvent(key, EventDispatcher::AcceleratorMatchPhase::ANY); | 442 dispatcher->ProcessEvent(key, 0, EventDispatcher::AcceleratorMatchPhase::ANY); |
| 437 EXPECT_EQ(accelerator_1, | 443 EXPECT_EQ(accelerator_1, |
| 438 event_dispatcher_delegate->GetAndClearLastAccelerator()); | 444 event_dispatcher_delegate->GetAndClearLastAccelerator()); |
| 439 | 445 |
| 440 key = ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_NONE); | 446 key = ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_NONE); |
| 441 dispatcher->ProcessEvent(key, EventDispatcher::AcceleratorMatchPhase::ANY); | 447 dispatcher->ProcessEvent(key, 0, EventDispatcher::AcceleratorMatchPhase::ANY); |
| 442 EXPECT_EQ(0u, event_dispatcher_delegate->GetAndClearLastAccelerator()); | 448 EXPECT_EQ(0u, event_dispatcher_delegate->GetAndClearLastAccelerator()); |
| 443 | 449 |
| 444 uint32_t accelerator_2 = 2; | 450 uint32_t accelerator_2 = 2; |
| 445 matcher = ui::CreateKeyMatcher(ui::mojom::KeyboardCode::W, | 451 matcher = ui::CreateKeyMatcher(ui::mojom::KeyboardCode::W, |
| 446 ui::mojom::kEventFlagNone); | 452 ui::mojom::kEventFlagNone); |
| 447 dispatcher->AddAccelerator(accelerator_2, std::move(matcher)); | 453 dispatcher->AddAccelerator(accelerator_2, std::move(matcher)); |
| 448 dispatcher->ProcessEvent(key, EventDispatcher::AcceleratorMatchPhase::ANY); | 454 dispatcher->ProcessEvent(key, 0, EventDispatcher::AcceleratorMatchPhase::ANY); |
| 449 EXPECT_EQ(accelerator_2, | 455 EXPECT_EQ(accelerator_2, |
| 450 event_dispatcher_delegate->GetAndClearLastAccelerator()); | 456 event_dispatcher_delegate->GetAndClearLastAccelerator()); |
| 451 | 457 |
| 452 dispatcher->RemoveAccelerator(accelerator_2); | 458 dispatcher->RemoveAccelerator(accelerator_2); |
| 453 dispatcher->ProcessEvent(key, EventDispatcher::AcceleratorMatchPhase::ANY); | 459 dispatcher->ProcessEvent(key, 0, EventDispatcher::AcceleratorMatchPhase::ANY); |
| 454 EXPECT_EQ(0u, event_dispatcher_delegate->GetAndClearLastAccelerator()); | 460 EXPECT_EQ(0u, event_dispatcher_delegate->GetAndClearLastAccelerator()); |
| 455 } | 461 } |
| 456 | 462 |
| 457 // Tests that a post-target accelerator is not triggered by ProcessEvent. | 463 // Tests that a post-target accelerator is not triggered by ProcessEvent. |
| 458 TEST_F(EventDispatcherTest, PostTargetAccelerator) { | 464 TEST_F(EventDispatcherTest, PostTargetAccelerator) { |
| 459 TestEventDispatcherDelegate* event_dispatcher_delegate = | 465 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 460 test_event_dispatcher_delegate(); | 466 test_event_dispatcher_delegate(); |
| 461 EventDispatcher* dispatcher = event_dispatcher(); | 467 EventDispatcher* dispatcher = event_dispatcher(); |
| 462 | 468 |
| 463 mojom::EventMatcherPtr matcher = ui::CreateKeyMatcher( | 469 mojom::EventMatcherPtr matcher = ui::CreateKeyMatcher( |
| 464 ui::mojom::KeyboardCode::W, ui::mojom::kEventFlagControlDown); | 470 ui::mojom::KeyboardCode::W, ui::mojom::kEventFlagControlDown); |
| 465 matcher->accelerator_phase = ui::mojom::AcceleratorPhase::POST_TARGET; | 471 matcher->accelerator_phase = ui::mojom::AcceleratorPhase::POST_TARGET; |
| 466 uint32_t accelerator_1 = 1; | 472 uint32_t accelerator_1 = 1; |
| 467 dispatcher->AddAccelerator(accelerator_1, std::move(matcher)); | 473 dispatcher->AddAccelerator(accelerator_1, std::move(matcher)); |
| 468 | 474 |
| 469 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN); | 475 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN); |
| 470 // The post-target accelerator should be fired if there is no focused window. | 476 // The post-target accelerator should be fired if there is no focused window. |
| 471 dispatcher->ProcessEvent(key, EventDispatcher::AcceleratorMatchPhase::ANY); | 477 dispatcher->ProcessEvent(key, 0, EventDispatcher::AcceleratorMatchPhase::ANY); |
| 472 EXPECT_EQ(accelerator_1, | 478 EXPECT_EQ(accelerator_1, |
| 473 event_dispatcher_delegate->GetAndClearLastAccelerator()); | 479 event_dispatcher_delegate->GetAndClearLastAccelerator()); |
| 474 std::unique_ptr<DispatchedEventDetails> details = | 480 std::unique_ptr<DispatchedEventDetails> details = |
| 475 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 481 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 476 EXPECT_FALSE(details); | 482 EXPECT_FALSE(details); |
| 477 | 483 |
| 478 // Set focused window for EventDispatcher dispatches key events. | 484 // Set focused window for EventDispatcher dispatches key events. |
| 479 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 485 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 480 event_dispatcher_delegate->SetFocusedWindowFromEventDispatcher(child.get()); | 486 event_dispatcher_delegate->SetFocusedWindowFromEventDispatcher(child.get()); |
| 481 | 487 |
| 482 // With a focused window the event should be dispatched. | 488 // With a focused window the event should be dispatched. |
| 483 dispatcher->ProcessEvent(key, EventDispatcher::AcceleratorMatchPhase::ANY); | 489 dispatcher->ProcessEvent(key, 0, EventDispatcher::AcceleratorMatchPhase::ANY); |
| 484 EXPECT_EQ(0u, event_dispatcher_delegate->GetAndClearLastAccelerator()); | 490 EXPECT_EQ(0u, event_dispatcher_delegate->GetAndClearLastAccelerator()); |
| 485 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 491 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 486 EXPECT_TRUE(details); | 492 EXPECT_TRUE(details); |
| 487 EXPECT_TRUE(details->accelerator); | 493 EXPECT_TRUE(details->accelerator); |
| 488 | 494 |
| 489 base::WeakPtr<Accelerator> accelerator_weak_ptr = | 495 base::WeakPtr<Accelerator> accelerator_weak_ptr = |
| 490 details->accelerator->GetWeakPtr(); | 496 details->accelerator->GetWeakPtr(); |
| 491 dispatcher->RemoveAccelerator(accelerator_1); | 497 dispatcher->RemoveAccelerator(accelerator_1); |
| 492 EXPECT_FALSE(accelerator_weak_ptr); | 498 EXPECT_FALSE(accelerator_weak_ptr); |
| 493 | 499 |
| 494 // Post deletion there should be no accelerator | 500 // Post deletion there should be no accelerator |
| 495 dispatcher->ProcessEvent(key, EventDispatcher::AcceleratorMatchPhase::ANY); | 501 dispatcher->ProcessEvent(key, 0, EventDispatcher::AcceleratorMatchPhase::ANY); |
| 496 EXPECT_EQ(0u, event_dispatcher_delegate->GetAndClearLastAccelerator()); | 502 EXPECT_EQ(0u, event_dispatcher_delegate->GetAndClearLastAccelerator()); |
| 497 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 503 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 498 EXPECT_TRUE(details); | 504 EXPECT_TRUE(details); |
| 499 EXPECT_FALSE(details->accelerator); | 505 EXPECT_FALSE(details->accelerator); |
| 500 } | 506 } |
| 501 | 507 |
| 502 TEST_F(EventDispatcherTest, ProcessPost) { | 508 TEST_F(EventDispatcherTest, ProcessPost) { |
| 503 TestEventDispatcherDelegate* event_dispatcher_delegate = | 509 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 504 test_event_dispatcher_delegate(); | 510 test_event_dispatcher_delegate(); |
| 505 EventDispatcher* dispatcher = event_dispatcher(); | 511 EventDispatcher* dispatcher = event_dispatcher(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 520 dispatcher->AddAccelerator(post_id, std::move(matcher)); | 526 dispatcher->AddAccelerator(post_id, std::move(matcher)); |
| 521 } | 527 } |
| 522 | 528 |
| 523 // Set focused window for EventDispatcher dispatches key events. | 529 // Set focused window for EventDispatcher dispatches key events. |
| 524 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 530 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 525 event_dispatcher_delegate->SetFocusedWindowFromEventDispatcher(child.get()); | 531 event_dispatcher_delegate->SetFocusedWindowFromEventDispatcher(child.get()); |
| 526 | 532 |
| 527 // Dispatch for ANY, which should trigger PRE and not call | 533 // Dispatch for ANY, which should trigger PRE and not call |
| 528 // DispatchInputEventToWindow(). | 534 // DispatchInputEventToWindow(). |
| 529 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN); | 535 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN); |
| 530 dispatcher->ProcessEvent(key, EventDispatcher::AcceleratorMatchPhase::ANY); | 536 dispatcher->ProcessEvent(key, 0, EventDispatcher::AcceleratorMatchPhase::ANY); |
| 531 EXPECT_EQ(EventDispatcherDelegate::AcceleratorPhase::PRE, | 537 EXPECT_EQ(EventDispatcherDelegate::AcceleratorPhase::PRE, |
| 532 event_dispatcher_delegate->last_accelerator_phase()); | 538 event_dispatcher_delegate->last_accelerator_phase()); |
| 533 EXPECT_EQ(pre_id, event_dispatcher_delegate->GetAndClearLastAccelerator()); | 539 EXPECT_EQ(pre_id, event_dispatcher_delegate->GetAndClearLastAccelerator()); |
| 534 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 540 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 535 | 541 |
| 536 // Dispatch for POST, which should trigger POST. | 542 // Dispatch for POST, which should trigger POST. |
| 537 dispatcher->ProcessEvent(key, | 543 dispatcher->ProcessEvent(key, 0, |
| 538 EventDispatcher::AcceleratorMatchPhase::POST_ONLY); | 544 EventDispatcher::AcceleratorMatchPhase::POST_ONLY); |
| 539 std::unique_ptr<DispatchedEventDetails> details = | 545 std::unique_ptr<DispatchedEventDetails> details = |
| 540 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 546 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 541 ASSERT_TRUE(details); | 547 ASSERT_TRUE(details); |
| 542 ASSERT_TRUE(details->accelerator); | 548 ASSERT_TRUE(details->accelerator); |
| 543 EXPECT_EQ(post_id, details->accelerator->id()); | 549 EXPECT_EQ(post_id, details->accelerator->id()); |
| 544 } | 550 } |
| 545 | 551 |
| 546 TEST_F(EventDispatcherTest, Capture) { | 552 TEST_F(EventDispatcherTest, Capture) { |
| 547 ServerWindow* root = root_window(); | 553 ServerWindow* root = root_window(); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 child->SetClientArea(gfx::Insets(5, 5, 5, 5), std::vector<gfx::Rect>()); | 644 child->SetClientArea(gfx::Insets(5, 5, 5, 5), std::vector<gfx::Rect>()); |
| 639 | 645 |
| 640 TestEventDispatcherDelegate* event_dispatcher_delegate = | 646 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 641 test_event_dispatcher_delegate(); | 647 test_event_dispatcher_delegate(); |
| 642 EventDispatcher* dispatcher = event_dispatcher(); | 648 EventDispatcher* dispatcher = event_dispatcher(); |
| 643 | 649 |
| 644 // Start move loop by sending mouse event over non-client area. | 650 // Start move loop by sending mouse event over non-client area. |
| 645 const ui::PointerEvent press_event(ui::MouseEvent( | 651 const ui::PointerEvent press_event(ui::MouseEvent( |
| 646 ui::ET_MOUSE_PRESSED, gfx::Point(12, 12), gfx::Point(12, 12), | 652 ui::ET_MOUSE_PRESSED, gfx::Point(12, 12), gfx::Point(12, 12), |
| 647 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 653 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 648 dispatcher->ProcessEvent(press_event, | 654 dispatcher->ProcessEvent(press_event, 0, |
| 649 EventDispatcher::AcceleratorMatchPhase::ANY); | 655 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 650 | 656 |
| 651 // Events should target child and be in the non-client area. | 657 // Events should target child and be in the non-client area. |
| 652 std::unique_ptr<DispatchedEventDetails> details = | 658 std::unique_ptr<DispatchedEventDetails> details = |
| 653 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 659 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 654 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 660 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 655 ASSERT_TRUE(details); | 661 ASSERT_TRUE(details); |
| 656 ASSERT_EQ(child.get(), details->window); | 662 ASSERT_EQ(child.get(), details->window); |
| 657 EXPECT_TRUE(details->IsNonclientArea()); | 663 EXPECT_TRUE(details->IsNonclientArea()); |
| 658 | 664 |
| 659 // Move the mouse 5,6 pixels and target is the same. | 665 // Move the mouse 5,6 pixels and target is the same. |
| 660 const ui::PointerEvent move_event( | 666 const ui::PointerEvent move_event( |
| 661 ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(17, 18), gfx::Point(17, 18), | 667 ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(17, 18), gfx::Point(17, 18), |
| 662 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, 0)); | 668 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, 0)); |
| 663 dispatcher->ProcessEvent(move_event, | 669 dispatcher->ProcessEvent(move_event, 0, |
| 664 EventDispatcher::AcceleratorMatchPhase::ANY); | 670 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 665 | 671 |
| 666 // Still same target. | 672 // Still same target. |
| 667 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 673 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 668 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 674 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 669 ASSERT_EQ(child.get(), details->window); | 675 ASSERT_EQ(child.get(), details->window); |
| 670 EXPECT_TRUE(details->IsNonclientArea()); | 676 EXPECT_TRUE(details->IsNonclientArea()); |
| 671 | 677 |
| 672 // Release the mouse. | 678 // Release the mouse. |
| 673 const ui::PointerEvent release_event(ui::MouseEvent( | 679 const ui::PointerEvent release_event(ui::MouseEvent( |
| 674 ui::ET_MOUSE_RELEASED, gfx::Point(17, 18), gfx::Point(17, 18), | 680 ui::ET_MOUSE_RELEASED, gfx::Point(17, 18), gfx::Point(17, 18), |
| 675 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 681 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 676 dispatcher->ProcessEvent(release_event, | 682 dispatcher->ProcessEvent(release_event, 0, |
| 677 EventDispatcher::AcceleratorMatchPhase::ANY); | 683 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 678 | 684 |
| 679 // The event should not have been dispatched to the delegate. | 685 // The event should not have been dispatched to the delegate. |
| 680 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 686 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 681 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 687 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 682 ASSERT_EQ(child.get(), details->window); | 688 ASSERT_EQ(child.get(), details->window); |
| 683 EXPECT_TRUE(details->IsNonclientArea()); | 689 EXPECT_TRUE(details->IsNonclientArea()); |
| 684 | 690 |
| 685 // Press in the client area and verify target/client area. The non-client area | 691 // Press in the client area and verify target/client area. The non-client area |
| 686 // should get an exit first. | 692 // should get an exit first. |
| 687 const ui::PointerEvent press_event2(ui::MouseEvent( | 693 const ui::PointerEvent press_event2(ui::MouseEvent( |
| 688 ui::ET_MOUSE_PRESSED, gfx::Point(21, 22), gfx::Point(21, 22), | 694 ui::ET_MOUSE_PRESSED, gfx::Point(21, 22), gfx::Point(21, 22), |
| 689 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 695 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 690 dispatcher->ProcessEvent(press_event2, | 696 dispatcher->ProcessEvent(press_event2, 0, |
| 691 EventDispatcher::AcceleratorMatchPhase::ANY); | 697 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 692 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 698 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 693 EXPECT_TRUE(event_dispatcher_delegate->has_queued_events()); | 699 EXPECT_TRUE(event_dispatcher_delegate->has_queued_events()); |
| 694 ASSERT_EQ(child.get(), details->window); | 700 ASSERT_EQ(child.get(), details->window); |
| 695 EXPECT_TRUE(details->IsNonclientArea()); | 701 EXPECT_TRUE(details->IsNonclientArea()); |
| 696 EXPECT_EQ(ui::ET_POINTER_EXITED, details->event->type()); | 702 EXPECT_EQ(ui::ET_POINTER_EXITED, details->event->type()); |
| 697 | 703 |
| 698 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 704 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 699 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 705 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 700 ASSERT_EQ(child.get(), details->window); | 706 ASSERT_EQ(child.get(), details->window); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 711 std::vector<gfx::Rect> additional_client_areas; | 717 std::vector<gfx::Rect> additional_client_areas; |
| 712 additional_client_areas.push_back(gfx::Rect(18, 0, 2, 2)); | 718 additional_client_areas.push_back(gfx::Rect(18, 0, 2, 2)); |
| 713 child->SetClientArea(gfx::Insets(5, 5, 5, 5), additional_client_areas); | 719 child->SetClientArea(gfx::Insets(5, 5, 5, 5), additional_client_areas); |
| 714 | 720 |
| 715 TestEventDispatcherDelegate* event_dispatcher_delegate = | 721 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 716 test_event_dispatcher_delegate(); | 722 test_event_dispatcher_delegate(); |
| 717 // Press in the additional client area, it should go to the child. | 723 // Press in the additional client area, it should go to the child. |
| 718 const ui::PointerEvent press_event(ui::MouseEvent( | 724 const ui::PointerEvent press_event(ui::MouseEvent( |
| 719 ui::ET_MOUSE_PRESSED, gfx::Point(28, 11), gfx::Point(28, 11), | 725 ui::ET_MOUSE_PRESSED, gfx::Point(28, 11), gfx::Point(28, 11), |
| 720 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 726 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 721 event_dispatcher()->ProcessEvent(press_event, | 727 event_dispatcher()->ProcessEvent(press_event, 0, |
| 722 EventDispatcher::AcceleratorMatchPhase::ANY); | 728 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 723 | 729 |
| 724 // Events should target child and be in the client area. | 730 // Events should target child and be in the client area. |
| 725 std::unique_ptr<DispatchedEventDetails> details = | 731 std::unique_ptr<DispatchedEventDetails> details = |
| 726 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 732 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 727 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 733 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 728 ASSERT_EQ(child.get(), details->window); | 734 ASSERT_EQ(child.get(), details->window); |
| 729 EXPECT_TRUE(details->IsClientArea()); | 735 EXPECT_TRUE(details->IsClientArea()); |
| 730 } | 736 } |
| 731 | 737 |
| 732 TEST_F(EventDispatcherTest, HitTestMask) { | 738 TEST_F(EventDispatcherTest, HitTestMask) { |
| 733 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 739 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 734 | 740 |
| 735 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 741 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 736 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 742 child->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 737 child->SetHitTestMask(gfx::Rect(2, 2, 16, 16)); | 743 child->SetHitTestMask(gfx::Rect(2, 2, 16, 16)); |
| 738 | 744 |
| 739 // Move in the masked area. | 745 // Move in the masked area. |
| 740 const ui::PointerEvent move1(ui::MouseEvent( | 746 const ui::PointerEvent move1(ui::MouseEvent( |
| 741 ui::ET_MOUSE_MOVED, gfx::Point(11, 11), gfx::Point(11, 11), | 747 ui::ET_MOUSE_MOVED, gfx::Point(11, 11), gfx::Point(11, 11), |
| 742 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, 0)); | 748 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, 0)); |
| 743 event_dispatcher()->ProcessEvent(move1, | 749 event_dispatcher()->ProcessEvent(move1, 0, |
| 744 EventDispatcher::AcceleratorMatchPhase::ANY); | 750 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 745 | 751 |
| 746 // Event went through the child window and hit the root. | 752 // Event went through the child window and hit the root. |
| 747 std::unique_ptr<DispatchedEventDetails> details1 = | 753 std::unique_ptr<DispatchedEventDetails> details1 = |
| 748 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 754 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 749 EXPECT_EQ(root_window(), details1->window); | 755 EXPECT_EQ(root_window(), details1->window); |
| 750 EXPECT_TRUE(details1->IsClientArea()); | 756 EXPECT_TRUE(details1->IsClientArea()); |
| 751 | 757 |
| 752 child->ClearHitTestMask(); | 758 child->ClearHitTestMask(); |
| 753 | 759 |
| 754 // Move right in the same part of the window. | 760 // Move right in the same part of the window. |
| 755 const ui::PointerEvent move2(ui::MouseEvent( | 761 const ui::PointerEvent move2(ui::MouseEvent( |
| 756 ui::ET_MOUSE_MOVED, gfx::Point(11, 12), gfx::Point(11, 12), | 762 ui::ET_MOUSE_MOVED, gfx::Point(11, 12), gfx::Point(11, 12), |
| 757 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, 0)); | 763 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, 0)); |
| 758 event_dispatcher()->ProcessEvent(move2, | 764 event_dispatcher()->ProcessEvent(move2, 0, |
| 759 EventDispatcher::AcceleratorMatchPhase::ANY); | 765 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 760 | 766 |
| 761 // Mouse exits the root. | 767 // Mouse exits the root. |
| 762 std::unique_ptr<DispatchedEventDetails> details2 = | 768 std::unique_ptr<DispatchedEventDetails> details2 = |
| 763 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 769 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 764 EXPECT_EQ(ui::ET_POINTER_EXITED, details2->event->type()); | 770 EXPECT_EQ(ui::ET_POINTER_EXITED, details2->event->type()); |
| 765 | 771 |
| 766 // Mouse hits the child. | 772 // Mouse hits the child. |
| 767 std::unique_ptr<DispatchedEventDetails> details3 = | 773 std::unique_ptr<DispatchedEventDetails> details3 = |
| 768 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 774 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 779 child2->SetBounds(gfx::Rect(50, 51, 11, 12)); | 785 child2->SetBounds(gfx::Rect(50, 51, 11, 12)); |
| 780 | 786 |
| 781 TestEventDispatcherDelegate* event_dispatcher_delegate = | 787 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 782 test_event_dispatcher_delegate(); | 788 test_event_dispatcher_delegate(); |
| 783 EventDispatcher* dispatcher = event_dispatcher(); | 789 EventDispatcher* dispatcher = event_dispatcher(); |
| 784 | 790 |
| 785 // Press on child1. First press event should change focus. | 791 // Press on child1. First press event should change focus. |
| 786 const ui::PointerEvent press_event(ui::MouseEvent( | 792 const ui::PointerEvent press_event(ui::MouseEvent( |
| 787 ui::ET_MOUSE_PRESSED, gfx::Point(12, 12), gfx::Point(12, 12), | 793 ui::ET_MOUSE_PRESSED, gfx::Point(12, 12), gfx::Point(12, 12), |
| 788 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 794 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 789 dispatcher->ProcessEvent(press_event, | 795 dispatcher->ProcessEvent(press_event, 0, |
| 790 EventDispatcher::AcceleratorMatchPhase::ANY); | 796 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 791 std::unique_ptr<DispatchedEventDetails> details = | 797 std::unique_ptr<DispatchedEventDetails> details = |
| 792 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 798 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 793 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 799 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 794 EXPECT_EQ(child1.get(), details->window); | 800 EXPECT_EQ(child1.get(), details->window); |
| 795 EXPECT_EQ(child1.get(), | 801 EXPECT_EQ(child1.get(), |
| 796 event_dispatcher_delegate->GetAndClearLastFocusedWindow()); | 802 event_dispatcher_delegate->GetAndClearLastFocusedWindow()); |
| 797 | 803 |
| 798 // Press (with a different pointer id) on child2. Event should go to child2, | 804 // Press (with a different pointer id) on child2. Event should go to child2, |
| 799 // but focus should not change. | 805 // but focus should not change. |
| 800 const ui::PointerEvent touch_event(ui::TouchEvent( | 806 const ui::PointerEvent touch_event(ui::TouchEvent( |
| 801 ui::ET_TOUCH_PRESSED, gfx::Point(53, 54), base::TimeTicks(), | 807 ui::ET_TOUCH_PRESSED, gfx::Point(53, 54), base::TimeTicks(), |
| 802 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2))); | 808 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2))); |
| 803 dispatcher->ProcessEvent(touch_event, | 809 dispatcher->ProcessEvent(touch_event, 0, |
| 804 EventDispatcher::AcceleratorMatchPhase::ANY); | 810 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 805 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 811 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 806 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 812 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 807 EXPECT_EQ(child2.get(), details->window); | 813 EXPECT_EQ(child2.get(), details->window); |
| 808 EXPECT_EQ(nullptr, event_dispatcher_delegate->GetAndClearLastFocusedWindow()); | 814 EXPECT_EQ(nullptr, event_dispatcher_delegate->GetAndClearLastFocusedWindow()); |
| 809 } | 815 } |
| 810 | 816 |
| 811 TEST_F(EventDispatcherTest, TwoPointersActive) { | 817 TEST_F(EventDispatcherTest, TwoPointersActive) { |
| 812 std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3)); | 818 std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3)); |
| 813 std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4)); | 819 std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4)); |
| 814 | 820 |
| 815 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 821 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 816 child1->SetBounds(gfx::Rect(10, 10, 20, 20)); | 822 child1->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 817 child2->SetBounds(gfx::Rect(50, 51, 11, 12)); | 823 child2->SetBounds(gfx::Rect(50, 51, 11, 12)); |
| 818 | 824 |
| 819 TestEventDispatcherDelegate* event_dispatcher_delegate = | 825 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 820 test_event_dispatcher_delegate(); | 826 test_event_dispatcher_delegate(); |
| 821 EventDispatcher* dispatcher = event_dispatcher(); | 827 EventDispatcher* dispatcher = event_dispatcher(); |
| 822 | 828 |
| 823 // Press on child1. | 829 // Press on child1. |
| 824 const ui::PointerEvent touch_event1(ui::TouchEvent( | 830 const ui::PointerEvent touch_event1(ui::TouchEvent( |
| 825 ui::ET_TOUCH_PRESSED, gfx::Point(12, 13), base::TimeTicks(), | 831 ui::ET_TOUCH_PRESSED, gfx::Point(12, 13), base::TimeTicks(), |
| 826 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1))); | 832 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1))); |
| 827 dispatcher->ProcessEvent(touch_event1, | 833 dispatcher->ProcessEvent(touch_event1, 0, |
| 828 EventDispatcher::AcceleratorMatchPhase::ANY); | 834 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 829 std::unique_ptr<DispatchedEventDetails> details = | 835 std::unique_ptr<DispatchedEventDetails> details = |
| 830 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 836 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 831 EXPECT_EQ(child1.get(), details->window); | 837 EXPECT_EQ(child1.get(), details->window); |
| 832 | 838 |
| 833 // Drag over child2, child1 should get the drag. | 839 // Drag over child2, child1 should get the drag. |
| 834 const ui::PointerEvent drag_event1(ui::TouchEvent( | 840 const ui::PointerEvent drag_event1(ui::TouchEvent( |
| 835 ui::ET_TOUCH_MOVED, gfx::Point(53, 54), base::TimeTicks(), | 841 ui::ET_TOUCH_MOVED, gfx::Point(53, 54), base::TimeTicks(), |
| 836 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1))); | 842 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1))); |
| 837 dispatcher->ProcessEvent(drag_event1, | 843 dispatcher->ProcessEvent(drag_event1, 0, |
| 838 EventDispatcher::AcceleratorMatchPhase::ANY); | 844 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 839 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 845 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 840 EXPECT_EQ(child1.get(), details->window); | 846 EXPECT_EQ(child1.get(), details->window); |
| 841 | 847 |
| 842 // Press on child2 with a different touch id. | 848 // Press on child2 with a different touch id. |
| 843 const ui::PointerEvent touch_event2(ui::TouchEvent( | 849 const ui::PointerEvent touch_event2(ui::TouchEvent( |
| 844 ui::ET_TOUCH_PRESSED, gfx::Point(54, 55), base::TimeTicks(), | 850 ui::ET_TOUCH_PRESSED, gfx::Point(54, 55), base::TimeTicks(), |
| 845 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2))); | 851 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2))); |
| 846 dispatcher->ProcessEvent(touch_event2, | 852 dispatcher->ProcessEvent(touch_event2, 0, |
| 847 EventDispatcher::AcceleratorMatchPhase::ANY); | 853 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 848 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 854 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 849 EXPECT_EQ(child2.get(), details->window); | 855 EXPECT_EQ(child2.get(), details->window); |
| 850 | 856 |
| 851 // Drag over child1 with id 2, child2 should continue to get the drag. | 857 // Drag over child1 with id 2, child2 should continue to get the drag. |
| 852 const ui::PointerEvent drag_event2(ui::TouchEvent( | 858 const ui::PointerEvent drag_event2(ui::TouchEvent( |
| 853 ui::ET_TOUCH_MOVED, gfx::Point(13, 14), base::TimeTicks(), | 859 ui::ET_TOUCH_MOVED, gfx::Point(13, 14), base::TimeTicks(), |
| 854 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2))); | 860 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2))); |
| 855 dispatcher->ProcessEvent(drag_event2, | 861 dispatcher->ProcessEvent(drag_event2, 0, |
| 856 EventDispatcher::AcceleratorMatchPhase::ANY); | 862 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 857 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 863 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 858 EXPECT_EQ(child2.get(), details->window); | 864 EXPECT_EQ(child2.get(), details->window); |
| 859 | 865 |
| 860 // Drag again with id 1, child1 should continue to get it. | 866 // Drag again with id 1, child1 should continue to get it. |
| 861 dispatcher->ProcessEvent(drag_event1, | 867 dispatcher->ProcessEvent(drag_event1, 0, |
| 862 EventDispatcher::AcceleratorMatchPhase::ANY); | 868 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 863 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 869 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 864 EXPECT_EQ(child1.get(), details->window); | 870 EXPECT_EQ(child1.get(), details->window); |
| 865 | 871 |
| 866 // Release touch id 1, and click on 2. 2 should get it. | 872 // Release touch id 1, and click on 2. 2 should get it. |
| 867 const ui::PointerEvent touch_release(ui::TouchEvent( | 873 const ui::PointerEvent touch_release(ui::TouchEvent( |
| 868 ui::ET_TOUCH_RELEASED, gfx::Point(54, 55), base::TimeTicks(), | 874 ui::ET_TOUCH_RELEASED, gfx::Point(54, 55), base::TimeTicks(), |
| 869 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1))); | 875 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1))); |
| 870 dispatcher->ProcessEvent(touch_release, | 876 dispatcher->ProcessEvent(touch_release, 0, |
| 871 EventDispatcher::AcceleratorMatchPhase::ANY); | 877 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 872 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 878 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 873 EXPECT_EQ(child1.get(), details->window); | 879 EXPECT_EQ(child1.get(), details->window); |
| 874 const ui::PointerEvent touch_event3(ui::TouchEvent( | 880 const ui::PointerEvent touch_event3(ui::TouchEvent( |
| 875 ui::ET_TOUCH_PRESSED, gfx::Point(54, 55), base::TimeTicks(), | 881 ui::ET_TOUCH_PRESSED, gfx::Point(54, 55), base::TimeTicks(), |
| 876 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2))); | 882 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2))); |
| 877 dispatcher->ProcessEvent(touch_event3, | 883 dispatcher->ProcessEvent(touch_event3, 0, |
| 878 EventDispatcher::AcceleratorMatchPhase::ANY); | 884 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 879 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 885 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 880 EXPECT_EQ(child2.get(), details->window); | 886 EXPECT_EQ(child2.get(), details->window); |
| 881 } | 887 } |
| 882 | 888 |
| 883 TEST_F(EventDispatcherTest, DestroyWindowWhileGettingEvents) { | 889 TEST_F(EventDispatcherTest, DestroyWindowWhileGettingEvents) { |
| 884 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 890 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 885 | 891 |
| 886 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 892 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 887 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 893 child->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 888 | 894 |
| 889 TestEventDispatcherDelegate* event_dispatcher_delegate = | 895 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 890 test_event_dispatcher_delegate(); | 896 test_event_dispatcher_delegate(); |
| 891 EventDispatcher* dispatcher = event_dispatcher(); | 897 EventDispatcher* dispatcher = event_dispatcher(); |
| 892 | 898 |
| 893 // Press on child. | 899 // Press on child. |
| 894 const ui::PointerEvent touch_event1(ui::TouchEvent( | 900 const ui::PointerEvent touch_event1(ui::TouchEvent( |
| 895 ui::ET_TOUCH_PRESSED, gfx::Point(12, 13), base::TimeTicks(), | 901 ui::ET_TOUCH_PRESSED, gfx::Point(12, 13), base::TimeTicks(), |
| 896 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1))); | 902 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1))); |
| 897 dispatcher->ProcessEvent(touch_event1, | 903 dispatcher->ProcessEvent(touch_event1, 0, |
| 898 EventDispatcher::AcceleratorMatchPhase::ANY); | 904 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 899 std::unique_ptr<DispatchedEventDetails> details = | 905 std::unique_ptr<DispatchedEventDetails> details = |
| 900 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 906 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 901 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 907 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 902 EXPECT_EQ(child.get(), details->window); | 908 EXPECT_EQ(child.get(), details->window); |
| 903 | 909 |
| 904 // Delete child, and continue the drag. Event should not be dispatched. | 910 // Delete child, and continue the drag. Event should not be dispatched. |
| 905 child.reset(); | 911 child.reset(); |
| 906 | 912 |
| 907 const ui::PointerEvent drag_event1(ui::TouchEvent( | 913 const ui::PointerEvent drag_event1(ui::TouchEvent( |
| 908 ui::ET_TOUCH_MOVED, gfx::Point(53, 54), base::TimeTicks(), | 914 ui::ET_TOUCH_MOVED, gfx::Point(53, 54), base::TimeTicks(), |
| 909 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1))); | 915 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1))); |
| 910 dispatcher->ProcessEvent(drag_event1, | 916 dispatcher->ProcessEvent(drag_event1, 0, |
| 911 EventDispatcher::AcceleratorMatchPhase::ANY); | 917 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 912 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 918 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 913 EXPECT_EQ(nullptr, details.get()); | 919 EXPECT_EQ(nullptr, details.get()); |
| 914 } | 920 } |
| 915 | 921 |
| 916 TEST_F(EventDispatcherTest, MouseInExtendedHitTestRegion) { | 922 TEST_F(EventDispatcherTest, MouseInExtendedHitTestRegion) { |
| 917 ServerWindow* root = root_window(); | 923 ServerWindow* root = root_window(); |
| 918 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 924 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 919 | 925 |
| 920 root->SetBounds(gfx::Rect(0, 0, 100, 100)); | 926 root->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 921 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 927 child->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 922 | 928 |
| 923 TestEventDispatcherDelegate* event_dispatcher_delegate = | 929 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 924 test_event_dispatcher_delegate(); | 930 test_event_dispatcher_delegate(); |
| 925 EventDispatcher* dispatcher = event_dispatcher(); | 931 EventDispatcher* dispatcher = event_dispatcher(); |
| 926 | 932 |
| 927 // Send event that is not over child. | 933 // Send event that is not over child. |
| 928 const ui::PointerEvent ui_event(ui::MouseEvent( | 934 const ui::PointerEvent ui_event(ui::MouseEvent( |
| 929 ui::ET_MOUSE_PRESSED, gfx::Point(8, 9), gfx::Point(8, 9), | 935 ui::ET_MOUSE_PRESSED, gfx::Point(8, 9), gfx::Point(8, 9), |
| 930 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 936 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 931 dispatcher->ProcessEvent(ui_event, | 937 dispatcher->ProcessEvent(ui_event, 0, |
| 932 EventDispatcher::AcceleratorMatchPhase::ANY); | 938 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 933 std::unique_ptr<DispatchedEventDetails> details = | 939 std::unique_ptr<DispatchedEventDetails> details = |
| 934 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 940 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 935 ASSERT_EQ(root, details->window); | 941 ASSERT_EQ(root, details->window); |
| 936 | 942 |
| 937 // Release the mouse. | 943 // Release the mouse. |
| 938 const ui::PointerEvent release_event(ui::MouseEvent( | 944 const ui::PointerEvent release_event(ui::MouseEvent( |
| 939 ui::ET_MOUSE_RELEASED, gfx::Point(8, 9), gfx::Point(8, 9), | 945 ui::ET_MOUSE_RELEASED, gfx::Point(8, 9), gfx::Point(8, 9), |
| 940 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 946 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 941 dispatcher->ProcessEvent(release_event, | 947 dispatcher->ProcessEvent(release_event, 0, |
| 942 EventDispatcher::AcceleratorMatchPhase::ANY); | 948 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 943 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 949 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 944 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 950 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 945 ASSERT_EQ(root, details->window); | 951 ASSERT_EQ(root, details->window); |
| 946 EXPECT_TRUE(details->IsClientArea()); | 952 EXPECT_TRUE(details->IsClientArea()); |
| 947 | 953 |
| 948 // Change the extended hit test region and send event in extended hit test | 954 // Change the extended hit test region and send event in extended hit test |
| 949 // region. Should result in exit for root, followed by press for child. | 955 // region. Should result in exit for root, followed by press for child. |
| 950 child->set_extended_hit_test_region(gfx::Insets(5, 5, 5, 5)); | 956 child->set_extended_hit_test_region(gfx::Insets(5, 5, 5, 5)); |
| 951 dispatcher->ProcessEvent(ui_event, | 957 dispatcher->ProcessEvent(ui_event, 0, |
| 952 EventDispatcher::AcceleratorMatchPhase::ANY); | 958 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 953 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 959 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 954 EXPECT_EQ(root, details->window); | 960 EXPECT_EQ(root, details->window); |
| 955 EXPECT_EQ(ui::ET_POINTER_EXITED, details->event->type()); | 961 EXPECT_EQ(ui::ET_POINTER_EXITED, details->event->type()); |
| 956 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 962 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 957 ASSERT_TRUE(details); | 963 ASSERT_TRUE(details); |
| 958 | 964 |
| 959 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 965 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 960 EXPECT_TRUE(details->IsNonclientArea()); | 966 EXPECT_TRUE(details->IsNonclientArea()); |
| 961 ASSERT_EQ(child.get(), details->window); | 967 ASSERT_EQ(child.get(), details->window); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 | 1013 |
| 1008 { | 1014 { |
| 1009 // Send all pointer events to the child. | 1015 // Send all pointer events to the child. |
| 1010 dispatcher->SetCaptureWindow(child.get(), kClientAreaId); | 1016 dispatcher->SetCaptureWindow(child.get(), kClientAreaId); |
| 1011 | 1017 |
| 1012 // The mouse press should go to the child even though its outside its | 1018 // The mouse press should go to the child even though its outside its |
| 1013 // bounds. | 1019 // bounds. |
| 1014 const ui::PointerEvent left_press_event(ui::MouseEvent( | 1020 const ui::PointerEvent left_press_event(ui::MouseEvent( |
| 1015 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), | 1021 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), |
| 1016 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1022 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1017 dispatcher->ProcessEvent(left_press_event, | 1023 dispatcher->ProcessEvent(left_press_event, 0, |
| 1018 EventDispatcher::AcceleratorMatchPhase::ANY); | 1024 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1019 | 1025 |
| 1020 // Events should target child. | 1026 // Events should target child. |
| 1021 std::unique_ptr<DispatchedEventDetails> details = | 1027 std::unique_ptr<DispatchedEventDetails> details = |
| 1022 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 1028 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 1023 | 1029 |
| 1024 ASSERT_TRUE(details); | 1030 ASSERT_TRUE(details); |
| 1025 ASSERT_EQ(child.get(), details->window); | 1031 ASSERT_EQ(child.get(), details->window); |
| 1026 EXPECT_TRUE(details->IsClientArea()); | 1032 EXPECT_TRUE(details->IsClientArea()); |
| 1027 EXPECT_TRUE(IsMouseButtonDown()); | 1033 EXPECT_TRUE(IsMouseButtonDown()); |
| 1028 | 1034 |
| 1029 // The mouse down state should update while capture is set. | 1035 // The mouse down state should update while capture is set. |
| 1030 const ui::PointerEvent right_press_event(ui::MouseEvent( | 1036 const ui::PointerEvent right_press_event(ui::MouseEvent( |
| 1031 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), | 1037 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), |
| 1032 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, | 1038 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, |
| 1033 ui::EF_RIGHT_MOUSE_BUTTON)); | 1039 ui::EF_RIGHT_MOUSE_BUTTON)); |
| 1034 dispatcher->ProcessEvent(right_press_event, | 1040 dispatcher->ProcessEvent(right_press_event, 0, |
| 1035 EventDispatcher::AcceleratorMatchPhase::ANY); | 1041 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1036 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 1042 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 1037 EXPECT_TRUE(IsMouseButtonDown()); | 1043 EXPECT_TRUE(IsMouseButtonDown()); |
| 1038 | 1044 |
| 1039 // One button released should not clear mouse down | 1045 // One button released should not clear mouse down |
| 1040 const ui::PointerEvent left_release_event(ui::MouseEvent( | 1046 const ui::PointerEvent left_release_event(ui::MouseEvent( |
| 1041 ui::ET_MOUSE_RELEASED, gfx::Point(5, 5), gfx::Point(5, 5), | 1047 ui::ET_MOUSE_RELEASED, gfx::Point(5, 5), gfx::Point(5, 5), |
| 1042 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, | 1048 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, |
| 1043 ui::EF_LEFT_MOUSE_BUTTON)); | 1049 ui::EF_LEFT_MOUSE_BUTTON)); |
| 1044 dispatcher->ProcessEvent(left_release_event, | 1050 dispatcher->ProcessEvent(left_release_event, 0, |
| 1045 EventDispatcher::AcceleratorMatchPhase::ANY); | 1051 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1046 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 1052 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 1047 EXPECT_TRUE(IsMouseButtonDown()); | 1053 EXPECT_TRUE(IsMouseButtonDown()); |
| 1048 | 1054 |
| 1049 // Touch Event while mouse is down should not affect state. | 1055 // Touch Event while mouse is down should not affect state. |
| 1050 const ui::PointerEvent touch_event(ui::TouchEvent( | 1056 const ui::PointerEvent touch_event(ui::TouchEvent( |
| 1051 ui::ET_TOUCH_PRESSED, gfx::Point(15, 15), base::TimeTicks(), | 1057 ui::ET_TOUCH_PRESSED, gfx::Point(15, 15), base::TimeTicks(), |
| 1052 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2))); | 1058 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2))); |
| 1053 dispatcher->ProcessEvent(touch_event, | 1059 dispatcher->ProcessEvent(touch_event, 0, |
| 1054 EventDispatcher::AcceleratorMatchPhase::ANY); | 1060 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1055 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 1061 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 1056 EXPECT_TRUE(IsMouseButtonDown()); | 1062 EXPECT_TRUE(IsMouseButtonDown()); |
| 1057 | 1063 |
| 1058 // Move event should not affect down | 1064 // Move event should not affect down |
| 1059 const ui::PointerEvent move_event( | 1065 const ui::PointerEvent move_event( |
| 1060 ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(15, 5), gfx::Point(15, 5), | 1066 ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(15, 5), gfx::Point(15, 5), |
| 1061 base::TimeTicks(), ui::EF_RIGHT_MOUSE_BUTTON, | 1067 base::TimeTicks(), ui::EF_RIGHT_MOUSE_BUTTON, |
| 1062 ui::EF_RIGHT_MOUSE_BUTTON)); | 1068 ui::EF_RIGHT_MOUSE_BUTTON)); |
| 1063 dispatcher->ProcessEvent(move_event, | 1069 dispatcher->ProcessEvent(move_event, 0, |
| 1064 EventDispatcher::AcceleratorMatchPhase::ANY); | 1070 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1065 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 1071 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 1066 EXPECT_TRUE(IsMouseButtonDown()); | 1072 EXPECT_TRUE(IsMouseButtonDown()); |
| 1067 | 1073 |
| 1068 // All mouse buttons up should clear mouse down. | 1074 // All mouse buttons up should clear mouse down. |
| 1069 const ui::PointerEvent right_release_event( | 1075 const ui::PointerEvent right_release_event( |
| 1070 ui::MouseEvent(ui::ET_MOUSE_RELEASED, gfx::Point(5, 5), | 1076 ui::MouseEvent(ui::ET_MOUSE_RELEASED, gfx::Point(5, 5), |
| 1071 gfx::Point(5, 5), base::TimeTicks(), | 1077 gfx::Point(5, 5), base::TimeTicks(), |
| 1072 ui::EF_RIGHT_MOUSE_BUTTON, ui::EF_RIGHT_MOUSE_BUTTON)); | 1078 ui::EF_RIGHT_MOUSE_BUTTON, ui::EF_RIGHT_MOUSE_BUTTON)); |
| 1073 dispatcher->ProcessEvent(right_release_event, | 1079 dispatcher->ProcessEvent(right_release_event, 0, |
| 1074 EventDispatcher::AcceleratorMatchPhase::ANY); | 1080 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1075 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 1081 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 1076 EXPECT_FALSE(IsMouseButtonDown()); | 1082 EXPECT_FALSE(IsMouseButtonDown()); |
| 1077 } | 1083 } |
| 1078 | 1084 |
| 1079 { | 1085 { |
| 1080 // Releasing capture and sending the same event will go to the root. | 1086 // Releasing capture and sending the same event will go to the root. |
| 1081 dispatcher->SetCaptureWindow(nullptr, kClientAreaId); | 1087 dispatcher->SetCaptureWindow(nullptr, kClientAreaId); |
| 1082 const ui::PointerEvent press_event(ui::MouseEvent( | 1088 const ui::PointerEvent press_event(ui::MouseEvent( |
| 1083 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), | 1089 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), |
| 1084 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1090 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1085 dispatcher->ProcessEvent(press_event, | 1091 dispatcher->ProcessEvent(press_event, 0, |
| 1086 EventDispatcher::AcceleratorMatchPhase::ANY); | 1092 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1087 | 1093 |
| 1088 // Events should target the root. | 1094 // Events should target the root. |
| 1089 std::unique_ptr<DispatchedEventDetails> details = | 1095 std::unique_ptr<DispatchedEventDetails> details = |
| 1090 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 1096 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 1091 | 1097 |
| 1092 ASSERT_TRUE(details); | 1098 ASSERT_TRUE(details); |
| 1093 ASSERT_EQ(root, details->window); | 1099 ASSERT_EQ(root, details->window); |
| 1094 } | 1100 } |
| 1095 } | 1101 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 | 1141 |
| 1136 }; | 1142 }; |
| 1137 RunMouseEventTests(dispatcher, event_dispatcher_delegate, tests, | 1143 RunMouseEventTests(dispatcher, event_dispatcher_delegate, tests, |
| 1138 arraysize(tests)); | 1144 arraysize(tests)); |
| 1139 | 1145 |
| 1140 // Add a second pointer target to the child. | 1146 // Add a second pointer target to the child. |
| 1141 { | 1147 { |
| 1142 const ui::PointerEvent touch_event(ui::TouchEvent( | 1148 const ui::PointerEvent touch_event(ui::TouchEvent( |
| 1143 ui::ET_TOUCH_PRESSED, gfx::Point(12, 13), base::TimeTicks(), | 1149 ui::ET_TOUCH_PRESSED, gfx::Point(12, 13), base::TimeTicks(), |
| 1144 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1))); | 1150 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1))); |
| 1145 dispatcher->ProcessEvent(touch_event, | 1151 dispatcher->ProcessEvent(touch_event, 0, |
| 1146 EventDispatcher::AcceleratorMatchPhase::ANY); | 1152 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1147 } | 1153 } |
| 1148 | 1154 |
| 1149 std::unique_ptr<DispatchedEventDetails> details = | 1155 std::unique_ptr<DispatchedEventDetails> details = |
| 1150 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 1156 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 1151 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 1157 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 1152 EXPECT_EQ(child.get(), details->window); | 1158 EXPECT_EQ(child.get(), details->window); |
| 1153 | 1159 |
| 1154 // Verify that no window has explicit capture and hence we did indeed do | 1160 // Verify that no window has explicit capture and hence we did indeed do |
| 1155 // implicit capture. | 1161 // implicit capture. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1168 | 1174 |
| 1169 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 1175 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 1170 ASSERT_TRUE(details); | 1176 ASSERT_TRUE(details); |
| 1171 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 1177 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 1172 EXPECT_EQ(child.get(), details->window); | 1178 EXPECT_EQ(child.get(), details->window); |
| 1173 EXPECT_EQ(ui::ET_POINTER_EXITED, details->event->type()); | 1179 EXPECT_EQ(ui::ET_POINTER_EXITED, details->event->type()); |
| 1174 | 1180 |
| 1175 const ui::PointerEvent press_event(ui::MouseEvent( | 1181 const ui::PointerEvent press_event(ui::MouseEvent( |
| 1176 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), | 1182 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), |
| 1177 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1183 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1178 dispatcher->ProcessEvent(press_event, | 1184 dispatcher->ProcessEvent(press_event, 0, |
| 1179 EventDispatcher::AcceleratorMatchPhase::ANY); | 1185 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1180 | 1186 |
| 1181 // Events should target the root. | 1187 // Events should target the root. |
| 1182 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 1188 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 1183 ASSERT_TRUE(details); | 1189 ASSERT_TRUE(details); |
| 1184 ASSERT_EQ(root, details->window); | 1190 ASSERT_EQ(root, details->window); |
| 1185 ASSERT_TRUE(details->IsNonclientArea()); | 1191 ASSERT_TRUE(details->IsNonclientArea()); |
| 1186 } | 1192 } |
| 1187 | 1193 |
| 1188 // Tests that setting capture does delete active pointer targets for the capture | 1194 // Tests that setting capture does delete active pointer targets for the capture |
| 1189 // window. | 1195 // window. |
| 1190 TEST_F(EventDispatcherTest, CaptureUpdatesActivePointerTargets) { | 1196 TEST_F(EventDispatcherTest, CaptureUpdatesActivePointerTargets) { |
| 1191 ServerWindow* root = root_window(); | 1197 ServerWindow* root = root_window(); |
| 1192 root->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1198 root->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1193 | 1199 |
| 1194 EventDispatcher* dispatcher = event_dispatcher(); | 1200 EventDispatcher* dispatcher = event_dispatcher(); |
| 1195 { | 1201 { |
| 1196 const ui::PointerEvent press_event(ui::MouseEvent( | 1202 const ui::PointerEvent press_event(ui::MouseEvent( |
| 1197 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), | 1203 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), |
| 1198 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1204 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1199 dispatcher->ProcessEvent(press_event, | 1205 dispatcher->ProcessEvent(press_event, 0, |
| 1200 EventDispatcher::AcceleratorMatchPhase::ANY); | 1206 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1201 | 1207 |
| 1202 std::unique_ptr<DispatchedEventDetails> details = | 1208 std::unique_ptr<DispatchedEventDetails> details = |
| 1203 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1209 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1204 ASSERT_TRUE(details); | 1210 ASSERT_TRUE(details); |
| 1205 ASSERT_EQ(root, details->window); | 1211 ASSERT_EQ(root, details->window); |
| 1206 } | 1212 } |
| 1207 { | 1213 { |
| 1208 const ui::PointerEvent touch_event(ui::TouchEvent( | 1214 const ui::PointerEvent touch_event(ui::TouchEvent( |
| 1209 ui::ET_TOUCH_PRESSED, gfx::Point(12, 13), base::TimeTicks(), | 1215 ui::ET_TOUCH_PRESSED, gfx::Point(12, 13), base::TimeTicks(), |
| 1210 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1))); | 1216 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1))); |
| 1211 dispatcher->ProcessEvent(touch_event, | 1217 dispatcher->ProcessEvent(touch_event, 0, |
| 1212 EventDispatcher::AcceleratorMatchPhase::ANY); | 1218 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1213 } | 1219 } |
| 1214 | 1220 |
| 1215 ASSERT_TRUE(AreAnyPointersDown()); | 1221 ASSERT_TRUE(AreAnyPointersDown()); |
| 1216 ASSERT_TRUE(IsWindowPointerTarget(root)); | 1222 ASSERT_TRUE(IsWindowPointerTarget(root)); |
| 1217 EXPECT_EQ(2, NumberPointerTargetsForWindow(root)); | 1223 EXPECT_EQ(2, NumberPointerTargetsForWindow(root)); |
| 1218 | 1224 |
| 1219 // Setting the capture should clear the implicit pointers for the specified | 1225 // Setting the capture should clear the implicit pointers for the specified |
| 1220 // window. | 1226 // window. |
| 1221 dispatcher->SetCaptureWindow(root, kNonclientAreaId); | 1227 dispatcher->SetCaptureWindow(root, kNonclientAreaId); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1272 root->SetClientArea(gfx::Insets(5, 5, 5, 5), std::vector<gfx::Rect>()); | 1278 root->SetClientArea(gfx::Insets(5, 5, 5, 5), std::vector<gfx::Rect>()); |
| 1273 EventDispatcher* dispatcher = event_dispatcher(); | 1279 EventDispatcher* dispatcher = event_dispatcher(); |
| 1274 dispatcher->SetCaptureWindow(root, kNonclientAreaId); | 1280 dispatcher->SetCaptureWindow(root, kNonclientAreaId); |
| 1275 | 1281 |
| 1276 TestEventDispatcherDelegate* event_dispatcher_delegate = | 1282 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 1277 test_event_dispatcher_delegate(); | 1283 test_event_dispatcher_delegate(); |
| 1278 // Press in the client area, it should be marked as non client. | 1284 // Press in the client area, it should be marked as non client. |
| 1279 const ui::PointerEvent press_event(ui::MouseEvent( | 1285 const ui::PointerEvent press_event(ui::MouseEvent( |
| 1280 ui::ET_MOUSE_PRESSED, gfx::Point(6, 6), gfx::Point(6, 6), | 1286 ui::ET_MOUSE_PRESSED, gfx::Point(6, 6), gfx::Point(6, 6), |
| 1281 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1287 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1282 event_dispatcher()->ProcessEvent(press_event, | 1288 event_dispatcher()->ProcessEvent(press_event, 0, |
| 1283 EventDispatcher::AcceleratorMatchPhase::ANY); | 1289 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1284 | 1290 |
| 1285 // Events should target child and be in the client area. | 1291 // Events should target child and be in the client area. |
| 1286 std::unique_ptr<DispatchedEventDetails> details = | 1292 std::unique_ptr<DispatchedEventDetails> details = |
| 1287 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 1293 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 1288 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 1294 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 1289 ASSERT_EQ(root, details->window); | 1295 ASSERT_EQ(root, details->window); |
| 1290 EXPECT_TRUE(details->IsNonclientArea()); | 1296 EXPECT_TRUE(details->IsNonclientArea()); |
| 1291 } | 1297 } |
| 1292 | 1298 |
| 1293 TEST_F(EventDispatcherTest, ProcessPointerEvents) { | 1299 TEST_F(EventDispatcherTest, ProcessPointerEvents) { |
| 1294 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 1300 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 1295 | 1301 |
| 1296 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1302 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1297 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 1303 child->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 1298 | 1304 |
| 1299 { | 1305 { |
| 1300 const ui::PointerEvent pointer_event(ui::MouseEvent( | 1306 const ui::PointerEvent pointer_event(ui::MouseEvent( |
| 1301 ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), gfx::Point(20, 25), | 1307 ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), gfx::Point(20, 25), |
| 1302 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1308 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1303 event_dispatcher()->ProcessEvent( | 1309 event_dispatcher()->ProcessEvent( |
| 1304 pointer_event, EventDispatcher::AcceleratorMatchPhase::ANY); | 1310 pointer_event, 0, EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1305 | 1311 |
| 1306 std::unique_ptr<DispatchedEventDetails> details = | 1312 std::unique_ptr<DispatchedEventDetails> details = |
| 1307 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1313 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1308 ASSERT_TRUE(details); | 1314 ASSERT_TRUE(details); |
| 1309 ASSERT_EQ(child.get(), details->window); | 1315 ASSERT_EQ(child.get(), details->window); |
| 1310 | 1316 |
| 1311 ASSERT_TRUE(details->event); | 1317 ASSERT_TRUE(details->event); |
| 1312 ASSERT_TRUE(details->event->IsPointerEvent()); | 1318 ASSERT_TRUE(details->event->IsPointerEvent()); |
| 1313 | 1319 |
| 1314 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); | 1320 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); |
| 1315 EXPECT_EQ(gfx::Point(20, 25), dispatched_event->root_location()); | 1321 EXPECT_EQ(gfx::Point(20, 25), dispatched_event->root_location()); |
| 1316 EXPECT_EQ(gfx::Point(10, 15), dispatched_event->location()); | 1322 EXPECT_EQ(gfx::Point(10, 15), dispatched_event->location()); |
| 1317 } | 1323 } |
| 1318 | 1324 |
| 1319 { | 1325 { |
| 1320 const int touch_id = 3; | 1326 const int touch_id = 3; |
| 1321 const ui::PointerEvent pointer_event(ui::TouchEvent( | 1327 const ui::PointerEvent pointer_event(ui::TouchEvent( |
| 1322 ui::ET_TOUCH_RELEASED, gfx::Point(25, 20), base::TimeTicks(), | 1328 ui::ET_TOUCH_RELEASED, gfx::Point(25, 20), base::TimeTicks(), |
| 1323 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, | 1329 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, |
| 1324 touch_id))); | 1330 touch_id))); |
| 1325 event_dispatcher()->ProcessEvent( | 1331 event_dispatcher()->ProcessEvent( |
| 1326 pointer_event, EventDispatcher::AcceleratorMatchPhase::ANY); | 1332 pointer_event, 0, EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1327 | 1333 |
| 1328 std::unique_ptr<DispatchedEventDetails> details = | 1334 std::unique_ptr<DispatchedEventDetails> details = |
| 1329 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1335 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1330 ASSERT_TRUE(details); | 1336 ASSERT_TRUE(details); |
| 1331 ASSERT_EQ(child.get(), details->window); | 1337 ASSERT_EQ(child.get(), details->window); |
| 1332 | 1338 |
| 1333 ASSERT_TRUE(details->event); | 1339 ASSERT_TRUE(details->event); |
| 1334 ASSERT_TRUE(details->event->IsPointerEvent()); | 1340 ASSERT_TRUE(details->event->IsPointerEvent()); |
| 1335 | 1341 |
| 1336 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); | 1342 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); |
| 1337 EXPECT_EQ(gfx::Point(25, 20), dispatched_event->root_location()); | 1343 EXPECT_EQ(gfx::Point(25, 20), dispatched_event->root_location()); |
| 1338 EXPECT_EQ(gfx::Point(15, 10), dispatched_event->location()); | 1344 EXPECT_EQ(gfx::Point(15, 10), dispatched_event->location()); |
| 1339 EXPECT_EQ(touch_id, dispatched_event->pointer_details().id); | 1345 EXPECT_EQ(touch_id, dispatched_event->pointer_details().id); |
| 1340 } | 1346 } |
| 1341 } | 1347 } |
| 1342 | 1348 |
| 1343 TEST_F(EventDispatcherTest, ResetClearsPointerDown) { | 1349 TEST_F(EventDispatcherTest, ResetClearsPointerDown) { |
| 1344 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 1350 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 1345 | 1351 |
| 1346 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1352 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1347 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 1353 child->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 1348 | 1354 |
| 1349 // Send event that is over child. | 1355 // Send event that is over child. |
| 1350 const ui::PointerEvent ui_event(ui::MouseEvent( | 1356 const ui::PointerEvent ui_event(ui::MouseEvent( |
| 1351 ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), gfx::Point(20, 25), | 1357 ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), gfx::Point(20, 25), |
| 1352 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1358 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1353 event_dispatcher()->ProcessEvent(ui_event, | 1359 event_dispatcher()->ProcessEvent(ui_event, 0, |
| 1354 EventDispatcher::AcceleratorMatchPhase::ANY); | 1360 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1355 | 1361 |
| 1356 std::unique_ptr<DispatchedEventDetails> details = | 1362 std::unique_ptr<DispatchedEventDetails> details = |
| 1357 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1363 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1358 ASSERT_TRUE(details); | 1364 ASSERT_TRUE(details); |
| 1359 ASSERT_EQ(child.get(), details->window); | 1365 ASSERT_EQ(child.get(), details->window); |
| 1360 | 1366 |
| 1361 EXPECT_TRUE(AreAnyPointersDown()); | 1367 EXPECT_TRUE(AreAnyPointersDown()); |
| 1362 | 1368 |
| 1363 event_dispatcher()->Reset(); | 1369 event_dispatcher()->Reset(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1387 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); | 1393 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); |
| 1388 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); | 1394 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); |
| 1389 | 1395 |
| 1390 w1->AddTransientWindow(w2.get()); | 1396 w1->AddTransientWindow(w2.get()); |
| 1391 w2->SetModalType(MODAL_TYPE_WINDOW); | 1397 w2->SetModalType(MODAL_TYPE_WINDOW); |
| 1392 | 1398 |
| 1393 // Send event that is over |w1|. | 1399 // Send event that is over |w1|. |
| 1394 const ui::PointerEvent mouse_pressed(ui::MouseEvent( | 1400 const ui::PointerEvent mouse_pressed(ui::MouseEvent( |
| 1395 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), | 1401 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), |
| 1396 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1402 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1397 event_dispatcher()->ProcessEvent(mouse_pressed, | 1403 event_dispatcher()->ProcessEvent(mouse_pressed, 0, |
| 1398 EventDispatcher::AcceleratorMatchPhase::ANY); | 1404 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1399 | 1405 |
| 1400 std::unique_ptr<DispatchedEventDetails> details = | 1406 std::unique_ptr<DispatchedEventDetails> details = |
| 1401 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1407 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1402 ASSERT_TRUE(details); | 1408 ASSERT_TRUE(details); |
| 1403 EXPECT_EQ(w2.get(), details->window); | 1409 EXPECT_EQ(w2.get(), details->window); |
| 1404 EXPECT_TRUE(details->IsNonclientArea()); | 1410 EXPECT_TRUE(details->IsNonclientArea()); |
| 1405 | 1411 |
| 1406 ASSERT_TRUE(details->event); | 1412 ASSERT_TRUE(details->event); |
| 1407 ASSERT_TRUE(details->event->IsPointerEvent()); | 1413 ASSERT_TRUE(details->event->IsPointerEvent()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1420 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); | 1426 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); |
| 1421 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); | 1427 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); |
| 1422 | 1428 |
| 1423 w1->AddTransientWindow(w2.get()); | 1429 w1->AddTransientWindow(w2.get()); |
| 1424 w2->SetModalType(MODAL_TYPE_WINDOW); | 1430 w2->SetModalType(MODAL_TYPE_WINDOW); |
| 1425 | 1431 |
| 1426 // Send event that is over |w2|. | 1432 // Send event that is over |w2|. |
| 1427 const ui::PointerEvent mouse_pressed(ui::MouseEvent( | 1433 const ui::PointerEvent mouse_pressed(ui::MouseEvent( |
| 1428 ui::ET_MOUSE_PRESSED, gfx::Point(55, 15), gfx::Point(55, 15), | 1434 ui::ET_MOUSE_PRESSED, gfx::Point(55, 15), gfx::Point(55, 15), |
| 1429 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1435 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1430 event_dispatcher()->ProcessEvent(mouse_pressed, | 1436 event_dispatcher()->ProcessEvent(mouse_pressed, 0, |
| 1431 EventDispatcher::AcceleratorMatchPhase::ANY); | 1437 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1432 | 1438 |
| 1433 std::unique_ptr<DispatchedEventDetails> details = | 1439 std::unique_ptr<DispatchedEventDetails> details = |
| 1434 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1440 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1435 ASSERT_TRUE(details); | 1441 ASSERT_TRUE(details); |
| 1436 EXPECT_EQ(w2.get(), details->window); | 1442 EXPECT_EQ(w2.get(), details->window); |
| 1437 EXPECT_TRUE(details->IsClientArea()); | 1443 EXPECT_TRUE(details->IsClientArea()); |
| 1438 | 1444 |
| 1439 ASSERT_TRUE(details->event); | 1445 ASSERT_TRUE(details->event); |
| 1440 ASSERT_TRUE(details->event->IsPointerEvent()); | 1446 ASSERT_TRUE(details->event->IsPointerEvent()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1456 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); | 1462 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); |
| 1457 w3->SetBounds(gfx::Rect(70, 10, 10, 10)); | 1463 w3->SetBounds(gfx::Rect(70, 10, 10, 10)); |
| 1458 | 1464 |
| 1459 w1->AddTransientWindow(w2.get()); | 1465 w1->AddTransientWindow(w2.get()); |
| 1460 w2->SetModalType(MODAL_TYPE_WINDOW); | 1466 w2->SetModalType(MODAL_TYPE_WINDOW); |
| 1461 | 1467 |
| 1462 // Send event that is over |w3|. | 1468 // Send event that is over |w3|. |
| 1463 const ui::PointerEvent mouse_pressed(ui::MouseEvent( | 1469 const ui::PointerEvent mouse_pressed(ui::MouseEvent( |
| 1464 ui::ET_MOUSE_PRESSED, gfx::Point(75, 15), gfx::Point(75, 15), | 1470 ui::ET_MOUSE_PRESSED, gfx::Point(75, 15), gfx::Point(75, 15), |
| 1465 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1471 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1466 event_dispatcher()->ProcessEvent(mouse_pressed, | 1472 event_dispatcher()->ProcessEvent(mouse_pressed, 0, |
| 1467 EventDispatcher::AcceleratorMatchPhase::ANY); | 1473 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1468 | 1474 |
| 1469 std::unique_ptr<DispatchedEventDetails> details = | 1475 std::unique_ptr<DispatchedEventDetails> details = |
| 1470 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1476 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1471 ASSERT_TRUE(details); | 1477 ASSERT_TRUE(details); |
| 1472 EXPECT_EQ(w3.get(), details->window); | 1478 EXPECT_EQ(w3.get(), details->window); |
| 1473 EXPECT_TRUE(details->IsClientArea()); | 1479 EXPECT_TRUE(details->IsClientArea()); |
| 1474 | 1480 |
| 1475 ASSERT_TRUE(details->event); | 1481 ASSERT_TRUE(details->event); |
| 1476 ASSERT_TRUE(details->event->IsPointerEvent()); | 1482 ASSERT_TRUE(details->event->IsPointerEvent()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1493 w11->SetBounds(gfx::Rect(10, 10, 10, 10)); | 1499 w11->SetBounds(gfx::Rect(10, 10, 10, 10)); |
| 1494 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); | 1500 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); |
| 1495 | 1501 |
| 1496 w1->AddTransientWindow(w2.get()); | 1502 w1->AddTransientWindow(w2.get()); |
| 1497 w2->SetModalType(MODAL_TYPE_WINDOW); | 1503 w2->SetModalType(MODAL_TYPE_WINDOW); |
| 1498 | 1504 |
| 1499 // Send event that is over |w11|. | 1505 // Send event that is over |w11|. |
| 1500 const ui::PointerEvent mouse_pressed(ui::MouseEvent( | 1506 const ui::PointerEvent mouse_pressed(ui::MouseEvent( |
| 1501 ui::ET_MOUSE_PRESSED, gfx::Point(25, 25), gfx::Point(25, 25), | 1507 ui::ET_MOUSE_PRESSED, gfx::Point(25, 25), gfx::Point(25, 25), |
| 1502 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1508 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1503 event_dispatcher()->ProcessEvent(mouse_pressed, | 1509 event_dispatcher()->ProcessEvent(mouse_pressed, 0, |
| 1504 EventDispatcher::AcceleratorMatchPhase::ANY); | 1510 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1505 | 1511 |
| 1506 std::unique_ptr<DispatchedEventDetails> details = | 1512 std::unique_ptr<DispatchedEventDetails> details = |
| 1507 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1513 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1508 ASSERT_TRUE(details); | 1514 ASSERT_TRUE(details); |
| 1509 EXPECT_EQ(w2.get(), details->window); | 1515 EXPECT_EQ(w2.get(), details->window); |
| 1510 EXPECT_TRUE(details->IsNonclientArea()); | 1516 EXPECT_TRUE(details->IsNonclientArea()); |
| 1511 | 1517 |
| 1512 ASSERT_TRUE(details->event); | 1518 ASSERT_TRUE(details->event); |
| 1513 ASSERT_TRUE(details->event->IsPointerEvent()); | 1519 ASSERT_TRUE(details->event->IsPointerEvent()); |
| 1514 | 1520 |
| 1515 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); | 1521 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); |
| 1516 EXPECT_EQ(gfx::Point(25, 25), dispatched_event->root_location()); | 1522 EXPECT_EQ(gfx::Point(25, 25), dispatched_event->root_location()); |
| 1517 EXPECT_EQ(gfx::Point(-25, 15), dispatched_event->location()); | 1523 EXPECT_EQ(gfx::Point(-25, 15), dispatched_event->location()); |
| 1518 } | 1524 } |
| 1519 | 1525 |
| 1520 // Tests that events on a system modal window target the modal window itself. | 1526 // Tests that events on a system modal window target the modal window itself. |
| 1521 TEST_F(EventDispatcherTest, ModalWindowEventOnSystemModal) { | 1527 TEST_F(EventDispatcherTest, ModalWindowEventOnSystemModal) { |
| 1522 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); | 1528 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); |
| 1523 | 1529 |
| 1524 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1530 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1525 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); | 1531 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); |
| 1526 w1->SetModalType(MODAL_TYPE_SYSTEM); | 1532 w1->SetModalType(MODAL_TYPE_SYSTEM); |
| 1527 | 1533 |
| 1528 // Send event that is over |w1|. | 1534 // Send event that is over |w1|. |
| 1529 const ui::PointerEvent mouse_pressed(ui::MouseEvent( | 1535 const ui::PointerEvent mouse_pressed(ui::MouseEvent( |
| 1530 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), | 1536 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), |
| 1531 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1537 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1532 event_dispatcher()->ProcessEvent(mouse_pressed, | 1538 event_dispatcher()->ProcessEvent(mouse_pressed, 0, |
| 1533 EventDispatcher::AcceleratorMatchPhase::ANY); | 1539 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1534 | 1540 |
| 1535 std::unique_ptr<DispatchedEventDetails> details = | 1541 std::unique_ptr<DispatchedEventDetails> details = |
| 1536 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1542 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1537 ASSERT_TRUE(details); | 1543 ASSERT_TRUE(details); |
| 1538 EXPECT_EQ(w1.get(), details->window); | 1544 EXPECT_EQ(w1.get(), details->window); |
| 1539 EXPECT_TRUE(details->IsClientArea()); | 1545 EXPECT_TRUE(details->IsClientArea()); |
| 1540 | 1546 |
| 1541 ASSERT_TRUE(details->event); | 1547 ASSERT_TRUE(details->event); |
| 1542 ASSERT_TRUE(details->event->IsPointerEvent()); | 1548 ASSERT_TRUE(details->event->IsPointerEvent()); |
| 1543 | 1549 |
| 1544 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); | 1550 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); |
| 1545 EXPECT_EQ(gfx::Point(15, 15), dispatched_event->root_location()); | 1551 EXPECT_EQ(gfx::Point(15, 15), dispatched_event->root_location()); |
| 1546 EXPECT_EQ(gfx::Point(5, 5), dispatched_event->location()); | 1552 EXPECT_EQ(gfx::Point(5, 5), dispatched_event->location()); |
| 1547 } | 1553 } |
| 1548 | 1554 |
| 1549 // Tests that events outside of system modal window target the modal window. | 1555 // Tests that events outside of system modal window target the modal window. |
| 1550 TEST_F(EventDispatcherTest, ModalWindowEventOutsideSystemModal) { | 1556 TEST_F(EventDispatcherTest, ModalWindowEventOutsideSystemModal) { |
| 1551 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); | 1557 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); |
| 1552 | 1558 |
| 1553 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1559 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1554 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); | 1560 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); |
| 1555 w1->SetModalType(MODAL_TYPE_SYSTEM); | 1561 w1->SetModalType(MODAL_TYPE_SYSTEM); |
| 1556 event_dispatcher()->AddSystemModalWindow(w1.get()); | 1562 event_dispatcher()->AddSystemModalWindow(w1.get()); |
| 1557 | 1563 |
| 1558 // Send event that is over |w1|. | 1564 // Send event that is over |w1|. |
| 1559 const ui::PointerEvent mouse_pressed(ui::MouseEvent( | 1565 const ui::PointerEvent mouse_pressed(ui::MouseEvent( |
| 1560 ui::ET_MOUSE_PRESSED, gfx::Point(45, 15), gfx::Point(45, 15), | 1566 ui::ET_MOUSE_PRESSED, gfx::Point(45, 15), gfx::Point(45, 15), |
| 1561 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1567 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1562 event_dispatcher()->ProcessEvent(mouse_pressed, | 1568 event_dispatcher()->ProcessEvent(mouse_pressed, 0, |
| 1563 EventDispatcher::AcceleratorMatchPhase::ANY); | 1569 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1564 | 1570 |
| 1565 std::unique_ptr<DispatchedEventDetails> details = | 1571 std::unique_ptr<DispatchedEventDetails> details = |
| 1566 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1572 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1567 ASSERT_TRUE(details); | 1573 ASSERT_TRUE(details); |
| 1568 EXPECT_EQ(w1.get(), details->window); | 1574 EXPECT_EQ(w1.get(), details->window); |
| 1569 EXPECT_TRUE(details->IsNonclientArea()); | 1575 EXPECT_TRUE(details->IsNonclientArea()); |
| 1570 | 1576 |
| 1571 ASSERT_TRUE(details->event); | 1577 ASSERT_TRUE(details->event); |
| 1572 ASSERT_TRUE(details->event->IsPointerEvent()); | 1578 ASSERT_TRUE(details->event->IsPointerEvent()); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1602 // Touch on |w3| should go to |w1|. | 1608 // Touch on |w3| should go to |w1|. |
| 1603 {gfx::Point(11, 31), w1.get()}, | 1609 {gfx::Point(11, 31), w1.get()}, |
| 1604 }; | 1610 }; |
| 1605 | 1611 |
| 1606 for (size_t i = 0; i < arraysize(kTouchData); i++) { | 1612 for (size_t i = 0; i < arraysize(kTouchData); i++) { |
| 1607 // Send touch press and check that the expected target receives it. | 1613 // Send touch press and check that the expected target receives it. |
| 1608 event_dispatcher()->ProcessEvent( | 1614 event_dispatcher()->ProcessEvent( |
| 1609 ui::PointerEvent(ui::TouchEvent( | 1615 ui::PointerEvent(ui::TouchEvent( |
| 1610 ui::ET_TOUCH_PRESSED, kTouchData[i].location, base::TimeTicks(), | 1616 ui::ET_TOUCH_PRESSED, kTouchData[i].location, base::TimeTicks(), |
| 1611 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0))), | 1617 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0))), |
| 1612 EventDispatcher::AcceleratorMatchPhase::ANY); | 1618 0, EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1613 std::unique_ptr<DispatchedEventDetails> details = | 1619 std::unique_ptr<DispatchedEventDetails> details = |
| 1614 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1620 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1615 ASSERT_TRUE(details) << " details is nullptr " << i; | 1621 ASSERT_TRUE(details) << " details is nullptr " << i; |
| 1616 EXPECT_EQ(kTouchData[i].expected_target, details->window); | 1622 EXPECT_EQ(kTouchData[i].expected_target, details->window); |
| 1617 | 1623 |
| 1618 // Release touch. | 1624 // Release touch. |
| 1619 event_dispatcher()->ProcessEvent( | 1625 event_dispatcher()->ProcessEvent( |
| 1620 ui::PointerEvent(ui::TouchEvent( | 1626 ui::PointerEvent(ui::TouchEvent( |
| 1621 ui::ET_TOUCH_RELEASED, kTouchData[i].location, base::TimeTicks(), | 1627 ui::ET_TOUCH_RELEASED, kTouchData[i].location, base::TimeTicks(), |
| 1622 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0))), | 1628 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0))), |
| 1623 EventDispatcher::AcceleratorMatchPhase::ANY); | 1629 0, EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1624 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1630 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1625 } | 1631 } |
| 1626 } | 1632 } |
| 1627 | 1633 |
| 1628 // Tests that setting capture to a descendant of a modal parent fails. | 1634 // Tests that setting capture to a descendant of a modal parent fails. |
| 1629 TEST_F(EventDispatcherTest, ModalWindowSetCaptureDescendantOfModalParent) { | 1635 TEST_F(EventDispatcherTest, ModalWindowSetCaptureDescendantOfModalParent) { |
| 1630 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); | 1636 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); |
| 1631 std::unique_ptr<ServerWindow> w11 = | 1637 std::unique_ptr<ServerWindow> w11 = |
| 1632 CreateChildWindowWithParent(WindowId(1, 4), w1.get()); | 1638 CreateChildWindowWithParent(WindowId(1, 4), w1.get()); |
| 1633 std::unique_ptr<ServerWindow> w2 = CreateChildWindow(WindowId(1, 5)); | 1639 std::unique_ptr<ServerWindow> w2 = CreateChildWindow(WindowId(1, 5)); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1730 | 1736 |
| 1731 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1737 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1732 w1->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1738 w1->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1733 w11->SetBounds(gfx::Rect(10, 10, 10, 10)); | 1739 w11->SetBounds(gfx::Rect(10, 10, 10, 10)); |
| 1734 w2->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1740 w2->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1735 | 1741 |
| 1736 // Send event that is over |w11|. | 1742 // Send event that is over |w11|. |
| 1737 const ui::PointerEvent mouse_pressed(ui::MouseEvent( | 1743 const ui::PointerEvent mouse_pressed(ui::MouseEvent( |
| 1738 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), | 1744 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), |
| 1739 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1745 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1740 event_dispatcher()->ProcessEvent(mouse_pressed, | 1746 event_dispatcher()->ProcessEvent(mouse_pressed, 0, |
| 1741 EventDispatcher::AcceleratorMatchPhase::ANY); | 1747 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1742 event_dispatcher()->SetCaptureWindow(w11.get(), kClientAreaId); | 1748 event_dispatcher()->SetCaptureWindow(w11.get(), kClientAreaId); |
| 1743 | 1749 |
| 1744 std::unique_ptr<DispatchedEventDetails> details = | 1750 std::unique_ptr<DispatchedEventDetails> details = |
| 1745 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1751 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1746 ASSERT_TRUE(details); | 1752 ASSERT_TRUE(details); |
| 1747 EXPECT_EQ(w11.get(), details->window); | 1753 EXPECT_EQ(w11.get(), details->window); |
| 1748 EXPECT_TRUE(details->IsClientArea()); | 1754 EXPECT_TRUE(details->IsClientArea()); |
| 1749 | 1755 |
| 1750 // Move |w11| to |w2| and verify the mouse is still down, and |w11| has | 1756 // Move |w11| to |w2| and verify the mouse is still down, and |w11| has |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1863 } | 1869 } |
| 1864 | 1870 |
| 1865 TEST_F(EventDispatcherTest, MousePointerClearedOnDestroy) { | 1871 TEST_F(EventDispatcherTest, MousePointerClearedOnDestroy) { |
| 1866 root_window()->set_event_targeting_policy( | 1872 root_window()->set_event_targeting_policy( |
| 1867 mojom::EventTargetingPolicy::DESCENDANTS_ONLY); | 1873 mojom::EventTargetingPolicy::DESCENDANTS_ONLY); |
| 1868 std::unique_ptr<ServerWindow> c1 = CreateChildWindow(WindowId(1, 3)); | 1874 std::unique_ptr<ServerWindow> c1 = CreateChildWindow(WindowId(1, 3)); |
| 1869 | 1875 |
| 1870 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1876 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1871 c1->SetBounds(gfx::Rect(10, 10, 20, 20)); | 1877 c1->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 1872 | 1878 |
| 1873 event_dispatcher()->SetMousePointerScreenLocation(gfx::Point(15, 15)); | 1879 event_dispatcher()->SetMousePointerDisplayLocation(gfx::Point(15, 15), 0); |
| 1874 EXPECT_EQ(c1.get(), event_dispatcher()->mouse_cursor_source_window()); | 1880 EXPECT_EQ(c1.get(), event_dispatcher()->mouse_cursor_source_window()); |
| 1875 c1.reset(); | 1881 c1.reset(); |
| 1876 EXPECT_EQ(nullptr, event_dispatcher()->mouse_cursor_source_window()); | 1882 EXPECT_EQ(nullptr, event_dispatcher()->mouse_cursor_source_window()); |
| 1877 } | 1883 } |
| 1878 | 1884 |
| 1879 } // namespace test | 1885 } // namespace test |
| 1880 } // namespace ws | 1886 } // namespace ws |
| 1881 } // namespace ui | 1887 } // namespace ui |
| OLD | NEW |