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