Chromium Code Reviews| 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> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "services/ui/common/event_matcher_util.h" | 14 #include "services/ui/common/accelerator_util.h" |
| 15 #include "services/ui/ws/accelerator.h" | 15 #include "services/ui/ws/accelerator.h" |
| 16 #include "services/ui/ws/event_dispatcher_delegate.h" | 16 #include "services/ui/ws/event_dispatcher_delegate.h" |
| 17 #include "services/ui/ws/server_window.h" | 17 #include "services/ui/ws/server_window.h" |
| 18 #include "services/ui/ws/server_window_compositor_frame_sink_manager_test_api.h" | 18 #include "services/ui/ws/server_window_compositor_frame_sink_manager_test_api.h" |
| 19 #include "services/ui/ws/test_server_window_delegate.h" | 19 #include "services/ui/ws/test_server_window_delegate.h" |
| 20 #include "services/ui/ws/test_utils.h" | 20 #include "services/ui/ws/test_utils.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 22 #include "ui/events/event.h" | 22 #include "ui/events/event.h" |
| 23 | 23 |
| 24 namespace ui { | 24 namespace ui { |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 378 } | 378 } |
| 379 | 379 |
| 380 TEST_F(EventDispatcherTest, AcceleratorBasic) { | 380 TEST_F(EventDispatcherTest, AcceleratorBasic) { |
| 381 ClearSetup(); | 381 ClearSetup(); |
| 382 TestEventDispatcherDelegate event_dispatcher_delegate(nullptr); | 382 TestEventDispatcherDelegate event_dispatcher_delegate(nullptr); |
| 383 EventDispatcher dispatcher(&event_dispatcher_delegate); | 383 EventDispatcher dispatcher(&event_dispatcher_delegate); |
| 384 | 384 |
| 385 uint32_t accelerator_1 = 1; | 385 uint32_t accelerator_1 = 1; |
| 386 mojom::EventMatcherPtr matcher = ui::CreateKeyMatcher( | 386 mojom::EventMatcherPtr matcher = ui::CreateKeyMatcher( |
| 387 ui::mojom::KeyboardCode::W, ui::mojom::kEventFlagControlDown); | 387 ui::mojom::KeyboardCode::W, ui::mojom::kEventFlagControlDown); |
| 388 EXPECT_TRUE(dispatcher.AddAccelerator(accelerator_1, std::move(matcher))); | 388 |
| 389 std::vector<ui::mojom::AcceleratorTransportPtr> accelerators_1; | |
|
mfomitchev
2016/11/29 17:37:27
These three lines could be combined into one. This
thanhph
2016/11/29 19:06:41
Done, really nice. I changed other files as well.
| |
| 390 accelerators_1 = | |
| 391 ash::mus::AddAcceleratorHelper(accelerator_1, std::move(matcher)); | |
| 392 EXPECT_TRUE(dispatcher.AddAccelerators(std::move(accelerators_1))); | |
| 389 | 393 |
| 390 uint32_t accelerator_2 = 2; | 394 uint32_t accelerator_2 = 2; |
| 391 matcher = ui::CreateKeyMatcher(ui::mojom::KeyboardCode::N, | 395 matcher = ui::CreateKeyMatcher(ui::mojom::KeyboardCode::N, |
| 392 ui::mojom::kEventFlagNone); | 396 ui::mojom::kEventFlagNone); |
| 393 EXPECT_TRUE(dispatcher.AddAccelerator(accelerator_2, std::move(matcher))); | 397 |
| 398 std::vector<ui::mojom::AcceleratorTransportPtr> accelerators_2; | |
| 399 accelerators_2 = | |
| 400 ash::mus::AddAcceleratorHelper(accelerator_2, std::move(matcher)); | |
| 401 EXPECT_TRUE(dispatcher.AddAccelerators(std::move(accelerators_2))); | |
| 394 | 402 |
| 395 // Attempting to add a new accelerator with the same id should fail. | 403 // Attempting to add a new accelerator with the same id should fail. |
| 396 matcher = ui::CreateKeyMatcher(ui::mojom::KeyboardCode::T, | 404 matcher = ui::CreateKeyMatcher(ui::mojom::KeyboardCode::T, |
| 397 ui::mojom::kEventFlagNone); | 405 ui::mojom::kEventFlagNone); |
| 398 EXPECT_FALSE(dispatcher.AddAccelerator(accelerator_2, std::move(matcher))); | 406 std::vector<ui::mojom::AcceleratorTransportPtr> accelerators_3; |
| 407 accelerators_3 = | |
| 408 ash::mus::AddAcceleratorHelper(accelerator_2, std::move(matcher)); | |
| 409 EXPECT_FALSE(dispatcher.AddAccelerators(std::move(accelerators_3))); | |
| 399 | 410 |
| 400 // Adding the accelerator with the same id should succeed once the existing | 411 // Adding the accelerator with the same id should succeed once the existing |
| 401 // accelerator is removed. | 412 // accelerator is removed. |
| 402 dispatcher.RemoveAccelerator(accelerator_2); | 413 dispatcher.RemoveAccelerator(accelerator_2); |
| 403 matcher = ui::CreateKeyMatcher(ui::mojom::KeyboardCode::T, | 414 matcher = ui::CreateKeyMatcher(ui::mojom::KeyboardCode::T, |
| 404 ui::mojom::kEventFlagNone); | 415 ui::mojom::kEventFlagNone); |
| 405 EXPECT_TRUE(dispatcher.AddAccelerator(accelerator_2, std::move(matcher))); | 416 std::vector<ui::mojom::AcceleratorTransportPtr> accelerators_4; |
| 417 accelerators_4 = | |
| 418 ash::mus::AddAcceleratorHelper(accelerator_2, std::move(matcher)); | |
| 419 EXPECT_TRUE(dispatcher.AddAccelerators(std::move(accelerators_4))); | |
| 406 | 420 |
| 407 // Attempting to add an accelerator with the same matcher should fail. | 421 // Attempting to add an accelerator with the same matcher should fail. |
| 408 uint32_t accelerator_3 = 3; | 422 uint32_t accelerator_3 = 3; |
| 409 matcher = ui::CreateKeyMatcher(ui::mojom::KeyboardCode::T, | 423 matcher = ui::CreateKeyMatcher(ui::mojom::KeyboardCode::T, |
| 410 ui::mojom::kEventFlagNone); | 424 ui::mojom::kEventFlagNone); |
| 411 EXPECT_FALSE(dispatcher.AddAccelerator(accelerator_3, std::move(matcher))); | 425 std::vector<ui::mojom::AcceleratorTransportPtr> accelerators_5; |
| 426 accelerators_5 = | |
| 427 ash::mus::AddAcceleratorHelper(accelerator_3, std::move(matcher)); | |
| 428 EXPECT_FALSE(dispatcher.AddAccelerators(std::move(accelerators_5))); | |
| 412 | 429 |
| 413 matcher = ui::CreateKeyMatcher(ui::mojom::KeyboardCode::T, | 430 matcher = ui::CreateKeyMatcher(ui::mojom::KeyboardCode::T, |
| 414 ui::mojom::kEventFlagControlDown); | 431 ui::mojom::kEventFlagControlDown); |
| 415 EXPECT_TRUE(dispatcher.AddAccelerator(accelerator_3, std::move(matcher))); | 432 std::vector<ui::mojom::AcceleratorTransportPtr> accelerators_6; |
| 433 accelerators_6 = | |
| 434 ash::mus::AddAcceleratorHelper(accelerator_3, std::move(matcher)); | |
| 435 EXPECT_TRUE(dispatcher.AddAccelerators(std::move(accelerators_6))); | |
| 436 } | |
| 437 | |
| 438 TEST_F(EventDispatcherTest, AddAccelerators) { | |
| 439 ClearSetup(); | |
| 440 TestEventDispatcherDelegate event_dispatcher_delegate(nullptr); | |
| 441 EventDispatcher dispatcher(&event_dispatcher_delegate); | |
| 442 | |
| 443 std::vector<ui::mojom::AcceleratorTransportPtr> accelerators; | |
| 444 | |
| 445 uint32_t accelerator_1 = 1; | |
| 446 mojom::EventMatcherPtr matcher = ui::CreateKeyMatcher( | |
| 447 ui::mojom::KeyboardCode::W, ui::mojom::kEventFlagControlDown); | |
| 448 | |
| 449 std::vector<ui::mojom::AcceleratorTransportPtr> accelerators_1; | |
|
mfomitchev
2016/11/29 18:23:15
We shouldn't create a vector just to take it's las
thanhph
2016/11/29 19:06:41
I use one-liner to add the back of the newly creat
mfomitchev
2016/11/29 19:21:19
I think adding a helper for constructing a single
thanhph
2016/11/29 20:36:45
Done, this is cleaner. Thanks!
| |
| 450 accelerators_1 = | |
| 451 ash::mus::AddAcceleratorHelper(accelerator_1, std::move(matcher)); | |
| 452 accelerators.push_back(std::move(accelerators_1.back())); | |
| 453 | |
| 454 uint32_t accelerator_2 = 2; | |
| 455 matcher = ui::CreateKeyMatcher(ui::mojom::KeyboardCode::N, | |
| 456 ui::mojom::kEventFlagNone); | |
| 457 | |
| 458 std::vector<ui::mojom::AcceleratorTransportPtr> accelerators_2; | |
| 459 accelerators_2 = | |
| 460 ash::mus::AddAcceleratorHelper(accelerator_2, std::move(matcher)); | |
| 461 accelerators.push_back(std::move(accelerators_2.back())); | |
| 462 | |
| 463 uint32_t accelerator_3 = 3; | |
| 464 matcher = ui::CreateKeyMatcher(ui::mojom::KeyboardCode::T, | |
| 465 ui::mojom::kEventFlagNone); | |
| 466 std::vector<ui::mojom::AcceleratorTransportPtr> accelerators_3; | |
| 467 accelerators_3 = | |
| 468 ash::mus::AddAcceleratorHelper(accelerator_3, std::move(matcher)); | |
| 469 accelerators.push_back(std::move(accelerators_3.back())); | |
| 470 | |
| 471 // Adding all accelerators with the different ids should pass. | |
| 472 EXPECT_TRUE(dispatcher.AddAccelerators(std::move(accelerators))); | |
| 473 | |
| 474 accelerators.clear(); | |
| 475 | |
| 476 matcher = ui::CreateKeyMatcher(ui::mojom::KeyboardCode::W, | |
| 477 ui::mojom::kEventFlagControlDown); | |
| 478 accelerators_1 = | |
| 479 ash::mus::AddAcceleratorHelper(accelerator_1, std::move(matcher)); | |
| 480 accelerators.push_back(std::move(accelerators_1.back())); | |
| 481 | |
| 482 matcher = ui::CreateKeyMatcher(ui::mojom::KeyboardCode::W, | |
| 483 ui::mojom::kEventFlagControlDown); | |
| 484 accelerators_2 = | |
| 485 ash::mus::AddAcceleratorHelper(accelerator_2, std::move(matcher)); | |
| 486 accelerators.push_back(std::move(accelerators_2.back())); | |
| 487 | |
| 488 matcher = ui::CreateKeyMatcher(ui::mojom::KeyboardCode::T, | |
| 489 ui::mojom::kEventFlagNone); | |
| 490 accelerators_3 = | |
| 491 ash::mus::AddAcceleratorHelper(accelerator_1, std::move(matcher)); | |
| 492 accelerators.push_back(std::move(accelerators_3.back())); | |
| 493 | |
| 494 // Adding accelerators with the duplicated id should fail. | |
| 495 EXPECT_FALSE(dispatcher.AddAccelerators(std::move(accelerators))); | |
|
mfomitchev
2016/11/29 18:23:15
We should also test the case where some ids/matche
thanhph
2016/11/29 19:06:41
accelerators_1 and accelerators_3 already have the
mfomitchev
2016/11/29 19:21:19
All three ids are dups here, right?
We need a test
thanhph
2016/11/29 20:36:45
Done, thanks!
| |
| 416 } | 496 } |
| 417 | 497 |
| 418 TEST_F(EventDispatcherTest, EventMatching) { | 498 TEST_F(EventDispatcherTest, EventMatching) { |
| 419 TestEventDispatcherDelegate* event_dispatcher_delegate = | 499 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 420 test_event_dispatcher_delegate(); | 500 test_event_dispatcher_delegate(); |
| 421 EventDispatcher* dispatcher = event_dispatcher(); | 501 EventDispatcher* dispatcher = event_dispatcher(); |
| 422 | 502 |
| 423 mojom::EventMatcherPtr matcher = ui::CreateKeyMatcher( | 503 mojom::EventMatcherPtr matcher = ui::CreateKeyMatcher( |
| 424 ui::mojom::KeyboardCode::W, ui::mojom::kEventFlagControlDown); | 504 ui::mojom::KeyboardCode::W, ui::mojom::kEventFlagControlDown); |
| 425 uint32_t accelerator_1 = 1; | 505 uint32_t accelerator_1 = 1; |
| 426 dispatcher->AddAccelerator(accelerator_1, std::move(matcher)); | 506 std::vector<ui::mojom::AcceleratorTransportPtr> accelerators_1; |
| 507 accelerators_1 = | |
| 508 ash::mus::AddAcceleratorHelper(accelerator_1, std::move(matcher)); | |
| 509 dispatcher->AddAccelerators(std::move(accelerators_1)); | |
| 427 | 510 |
| 428 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN); | 511 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN); |
| 429 dispatcher->ProcessEvent(key, EventDispatcher::AcceleratorMatchPhase::ANY); | 512 dispatcher->ProcessEvent(key, EventDispatcher::AcceleratorMatchPhase::ANY); |
| 430 EXPECT_EQ(accelerator_1, | 513 EXPECT_EQ(accelerator_1, |
| 431 event_dispatcher_delegate->GetAndClearLastAccelerator()); | 514 event_dispatcher_delegate->GetAndClearLastAccelerator()); |
| 432 | 515 |
| 433 // EF_NUM_LOCK_ON should be ignored since CreateKeyMatcher defaults to | 516 // EF_NUM_LOCK_ON should be ignored since CreateKeyMatcher defaults to |
| 434 // ignoring. | 517 // ignoring. |
| 435 key = ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_W, | 518 key = ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_W, |
| 436 ui::EF_CONTROL_DOWN | ui::EF_NUM_LOCK_ON); | 519 ui::EF_CONTROL_DOWN | ui::EF_NUM_LOCK_ON); |
| 437 dispatcher->ProcessEvent(key, EventDispatcher::AcceleratorMatchPhase::ANY); | 520 dispatcher->ProcessEvent(key, EventDispatcher::AcceleratorMatchPhase::ANY); |
| 438 EXPECT_EQ(accelerator_1, | 521 EXPECT_EQ(accelerator_1, |
| 439 event_dispatcher_delegate->GetAndClearLastAccelerator()); | 522 event_dispatcher_delegate->GetAndClearLastAccelerator()); |
| 440 | 523 |
| 441 key = ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_NONE); | 524 key = ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_NONE); |
| 442 dispatcher->ProcessEvent(key, EventDispatcher::AcceleratorMatchPhase::ANY); | 525 dispatcher->ProcessEvent(key, EventDispatcher::AcceleratorMatchPhase::ANY); |
| 443 EXPECT_EQ(0u, event_dispatcher_delegate->GetAndClearLastAccelerator()); | 526 EXPECT_EQ(0u, event_dispatcher_delegate->GetAndClearLastAccelerator()); |
| 444 | 527 |
| 445 uint32_t accelerator_2 = 2; | 528 uint32_t accelerator_2 = 2; |
| 446 matcher = ui::CreateKeyMatcher(ui::mojom::KeyboardCode::W, | 529 matcher = ui::CreateKeyMatcher(ui::mojom::KeyboardCode::W, |
| 447 ui::mojom::kEventFlagNone); | 530 ui::mojom::kEventFlagNone); |
| 448 dispatcher->AddAccelerator(accelerator_2, std::move(matcher)); | 531 std::vector<ui::mojom::AcceleratorTransportPtr> accelerators_2; |
| 532 accelerators_2 = | |
| 533 ash::mus::AddAcceleratorHelper(accelerator_2, std::move(matcher)); | |
| 534 dispatcher->AddAccelerators(std::move(accelerators_2)); | |
| 449 dispatcher->ProcessEvent(key, EventDispatcher::AcceleratorMatchPhase::ANY); | 535 dispatcher->ProcessEvent(key, EventDispatcher::AcceleratorMatchPhase::ANY); |
| 450 EXPECT_EQ(accelerator_2, | 536 EXPECT_EQ(accelerator_2, |
| 451 event_dispatcher_delegate->GetAndClearLastAccelerator()); | 537 event_dispatcher_delegate->GetAndClearLastAccelerator()); |
| 452 | 538 |
| 453 dispatcher->RemoveAccelerator(accelerator_2); | 539 dispatcher->RemoveAccelerator(accelerator_2); |
| 454 dispatcher->ProcessEvent(key, EventDispatcher::AcceleratorMatchPhase::ANY); | 540 dispatcher->ProcessEvent(key, EventDispatcher::AcceleratorMatchPhase::ANY); |
| 455 EXPECT_EQ(0u, event_dispatcher_delegate->GetAndClearLastAccelerator()); | 541 EXPECT_EQ(0u, event_dispatcher_delegate->GetAndClearLastAccelerator()); |
| 456 } | 542 } |
| 457 | 543 |
| 458 // Tests that a post-target accelerator is not triggered by ProcessEvent. | 544 // Tests that a post-target accelerator is not triggered by ProcessEvent. |
| 459 TEST_F(EventDispatcherTest, PostTargetAccelerator) { | 545 TEST_F(EventDispatcherTest, PostTargetAccelerator) { |
| 460 TestEventDispatcherDelegate* event_dispatcher_delegate = | 546 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 461 test_event_dispatcher_delegate(); | 547 test_event_dispatcher_delegate(); |
| 462 EventDispatcher* dispatcher = event_dispatcher(); | 548 EventDispatcher* dispatcher = event_dispatcher(); |
| 463 | 549 |
| 464 mojom::EventMatcherPtr matcher = ui::CreateKeyMatcher( | 550 mojom::EventMatcherPtr matcher = ui::CreateKeyMatcher( |
| 465 ui::mojom::KeyboardCode::W, ui::mojom::kEventFlagControlDown); | 551 ui::mojom::KeyboardCode::W, ui::mojom::kEventFlagControlDown); |
| 466 matcher->accelerator_phase = ui::mojom::AcceleratorPhase::POST_TARGET; | 552 matcher->accelerator_phase = ui::mojom::AcceleratorPhase::POST_TARGET; |
| 467 uint32_t accelerator_1 = 1; | 553 uint32_t accelerator_1 = 1; |
| 468 dispatcher->AddAccelerator(accelerator_1, std::move(matcher)); | 554 std::vector<ui::mojom::AcceleratorTransportPtr> accelerators_1; |
| 555 accelerators_1 = | |
| 556 ash::mus::AddAcceleratorHelper(accelerator_1, std::move(matcher)); | |
| 557 | |
| 558 dispatcher->AddAccelerators(std::move(accelerators_1)); | |
| 469 | 559 |
| 470 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN); | 560 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN); |
| 471 // The post-target accelerator should be fired if there is no focused window. | 561 // The post-target accelerator should be fired if there is no focused window. |
| 472 dispatcher->ProcessEvent(key, EventDispatcher::AcceleratorMatchPhase::ANY); | 562 dispatcher->ProcessEvent(key, EventDispatcher::AcceleratorMatchPhase::ANY); |
| 473 EXPECT_EQ(accelerator_1, | 563 EXPECT_EQ(accelerator_1, |
| 474 event_dispatcher_delegate->GetAndClearLastAccelerator()); | 564 event_dispatcher_delegate->GetAndClearLastAccelerator()); |
| 475 std::unique_ptr<DispatchedEventDetails> details = | 565 std::unique_ptr<DispatchedEventDetails> details = |
| 476 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 566 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 477 EXPECT_FALSE(details); | 567 EXPECT_FALSE(details); |
| 478 | 568 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 503 TEST_F(EventDispatcherTest, ProcessPost) { | 593 TEST_F(EventDispatcherTest, ProcessPost) { |
| 504 TestEventDispatcherDelegate* event_dispatcher_delegate = | 594 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 505 test_event_dispatcher_delegate(); | 595 test_event_dispatcher_delegate(); |
| 506 EventDispatcher* dispatcher = event_dispatcher(); | 596 EventDispatcher* dispatcher = event_dispatcher(); |
| 507 | 597 |
| 508 uint32_t pre_id = 1; | 598 uint32_t pre_id = 1; |
| 509 { | 599 { |
| 510 mojom::EventMatcherPtr matcher = ui::CreateKeyMatcher( | 600 mojom::EventMatcherPtr matcher = ui::CreateKeyMatcher( |
| 511 ui::mojom::KeyboardCode::W, ui::mojom::kEventFlagControlDown); | 601 ui::mojom::KeyboardCode::W, ui::mojom::kEventFlagControlDown); |
| 512 matcher->accelerator_phase = ui::mojom::AcceleratorPhase::PRE_TARGET; | 602 matcher->accelerator_phase = ui::mojom::AcceleratorPhase::PRE_TARGET; |
| 513 dispatcher->AddAccelerator(pre_id, std::move(matcher)); | 603 |
| 604 std::vector<ui::mojom::AcceleratorTransportPtr> accelerators_1; | |
| 605 accelerators_1 = ash::mus::AddAcceleratorHelper(pre_id, std::move(matcher)); | |
| 606 | |
| 607 dispatcher->AddAccelerators(std::move(accelerators_1)); | |
| 514 } | 608 } |
| 515 | 609 |
| 516 uint32_t post_id = 2; | 610 uint32_t post_id = 2; |
| 517 { | 611 { |
| 518 mojom::EventMatcherPtr matcher = ui::CreateKeyMatcher( | 612 mojom::EventMatcherPtr matcher = ui::CreateKeyMatcher( |
| 519 ui::mojom::KeyboardCode::W, ui::mojom::kEventFlagControlDown); | 613 ui::mojom::KeyboardCode::W, ui::mojom::kEventFlagControlDown); |
| 520 matcher->accelerator_phase = ui::mojom::AcceleratorPhase::POST_TARGET; | 614 matcher->accelerator_phase = ui::mojom::AcceleratorPhase::POST_TARGET; |
| 521 dispatcher->AddAccelerator(post_id, std::move(matcher)); | 615 |
| 616 std::vector<ui::mojom::AcceleratorTransportPtr> accelerators_2; | |
| 617 accelerators_2 = | |
| 618 ash::mus::AddAcceleratorHelper(post_id, std::move(matcher)); | |
| 619 | |
| 620 dispatcher->AddAccelerators(std::move(accelerators_2)); | |
| 522 } | 621 } |
| 523 | 622 |
| 524 // Set focused window for EventDispatcher dispatches key events. | 623 // Set focused window for EventDispatcher dispatches key events. |
| 525 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 624 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 526 event_dispatcher_delegate->SetFocusedWindowFromEventDispatcher(child.get()); | 625 event_dispatcher_delegate->SetFocusedWindowFromEventDispatcher(child.get()); |
| 527 | 626 |
| 528 // Dispatch for ANY, which should trigger PRE and not call | 627 // Dispatch for ANY, which should trigger PRE and not call |
| 529 // DispatchInputEventToWindow(). | 628 // DispatchInputEventToWindow(). |
| 530 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN); | 629 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN); |
| 531 dispatcher->ProcessEvent(key, EventDispatcher::AcceleratorMatchPhase::ANY); | 630 dispatcher->ProcessEvent(key, EventDispatcher::AcceleratorMatchPhase::ANY); |
| (...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1705 // The delegate can decide if it really wants to forward the event or not. | 1804 // The delegate can decide if it really wants to forward the event or not. |
| 1706 EXPECT_EQ(child.get(), | 1805 EXPECT_EQ(child.get(), |
| 1707 test_event_dispatcher_delegate()->lost_capture_window()); | 1806 test_event_dispatcher_delegate()->lost_capture_window()); |
| 1708 EXPECT_EQ(child.get(), event_dispatcher()->capture_window()); | 1807 EXPECT_EQ(child.get(), event_dispatcher()->capture_window()); |
| 1709 EXPECT_EQ(kClientAreaId, event_dispatcher()->capture_window_client_id()); | 1808 EXPECT_EQ(kClientAreaId, event_dispatcher()->capture_window_client_id()); |
| 1710 } | 1809 } |
| 1711 | 1810 |
| 1712 } // namespace test | 1811 } // namespace test |
| 1713 } // namespace ws | 1812 } // namespace ws |
| 1714 } // namespace ui | 1813 } // namespace ui |
| OLD | NEW |