| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/shell.h" | 5 #include "ash/shell.h" |
| 6 #include "ash/shell_window_ids.h" | 6 #include "ash/shell_window_ids.h" |
| 7 #include "ash/test/ash_test_base.h" | 7 #include "ash/test/ash_test_base.h" |
| 8 #include "ash/test/test_activation_delegate.h" | 8 #include "ash/test/test_activation_delegate.h" |
| 9 #include "ash/wm/window_util.h" | 9 #include "ash/wm/window_util.h" |
| 10 #include "ui/aura/client/cursor_client_observer.h" | 10 #include "ui/aura/client/cursor_client_observer.h" |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 | 506 |
| 507 aura::WindowTreeHost* host = root_window->GetHost(); | 507 aura::WindowTreeHost* host = root_window->GetHost(); |
| 508 ui::EventProcessor* dispatcher = host->event_processor(); | 508 ui::EventProcessor* dispatcher = host->event_processor(); |
| 509 | 509 |
| 510 // Cursor starts as a pointer (set during Shell::Init()). | 510 // Cursor starts as a pointer (set during Shell::Init()). |
| 511 EXPECT_EQ(ui::kCursorPointer, host->last_cursor().native_type()); | 511 EXPECT_EQ(ui::kCursorPointer, host->last_cursor().native_type()); |
| 512 | 512 |
| 513 { | 513 { |
| 514 // Resize edges and corners show proper cursors. | 514 // Resize edges and corners show proper cursors. |
| 515 window_delegate.set_hittest_code(HTBOTTOM); | 515 window_delegate.set_hittest_code(HTBOTTOM); |
| 516 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, | 516 ui::MouseEvent move1( |
| 517 ui::EventTimeForNow(), 0, 0); | 517 ui::ET_MOUSE_MOVED, point1, point1, ui::EventTimeForNow(), 0, 0, |
| 518 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 518 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move1); | 519 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move1); |
| 519 ASSERT_FALSE(details.dispatcher_destroyed); | 520 ASSERT_FALSE(details.dispatcher_destroyed); |
| 520 EXPECT_EQ(ui::kCursorSouthResize, host->last_cursor().native_type()); | 521 EXPECT_EQ(ui::kCursorSouthResize, host->last_cursor().native_type()); |
| 521 } | 522 } |
| 522 | 523 |
| 523 { | 524 { |
| 524 window_delegate.set_hittest_code(HTBOTTOMLEFT); | 525 window_delegate.set_hittest_code(HTBOTTOMLEFT); |
| 525 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, | 526 ui::MouseEvent move2( |
| 526 ui::EventTimeForNow(), 0, 0); | 527 ui::ET_MOUSE_MOVED, point2, point2, ui::EventTimeForNow(), 0, 0, |
| 528 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 527 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move2); | 529 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move2); |
| 528 ASSERT_FALSE(details.dispatcher_destroyed); | 530 ASSERT_FALSE(details.dispatcher_destroyed); |
| 529 EXPECT_EQ(ui::kCursorSouthWestResize, host->last_cursor().native_type()); | 531 EXPECT_EQ(ui::kCursorSouthWestResize, host->last_cursor().native_type()); |
| 530 } | 532 } |
| 531 | 533 |
| 532 { | 534 { |
| 533 window_delegate.set_hittest_code(HTBOTTOMRIGHT); | 535 window_delegate.set_hittest_code(HTBOTTOMRIGHT); |
| 534 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, | 536 ui::MouseEvent move1( |
| 535 ui::EventTimeForNow(), 0, 0); | 537 ui::ET_MOUSE_MOVED, point1, point1, ui::EventTimeForNow(), 0, 0, |
| 538 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 536 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move1); | 539 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move1); |
| 537 ASSERT_FALSE(details.dispatcher_destroyed); | 540 ASSERT_FALSE(details.dispatcher_destroyed); |
| 538 EXPECT_EQ(ui::kCursorSouthEastResize, host->last_cursor().native_type()); | 541 EXPECT_EQ(ui::kCursorSouthEastResize, host->last_cursor().native_type()); |
| 539 } | 542 } |
| 540 | 543 |
| 541 { | 544 { |
| 542 window_delegate.set_hittest_code(HTLEFT); | 545 window_delegate.set_hittest_code(HTLEFT); |
| 543 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, | 546 ui::MouseEvent move2( |
| 544 ui::EventTimeForNow(), 0, 0); | 547 ui::ET_MOUSE_MOVED, point2, point2, ui::EventTimeForNow(), 0, 0, |
| 548 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 545 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move2); | 549 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move2); |
| 546 ASSERT_FALSE(details.dispatcher_destroyed); | 550 ASSERT_FALSE(details.dispatcher_destroyed); |
| 547 EXPECT_EQ(ui::kCursorWestResize, host->last_cursor().native_type()); | 551 EXPECT_EQ(ui::kCursorWestResize, host->last_cursor().native_type()); |
| 548 } | 552 } |
| 549 | 553 |
| 550 { | 554 { |
| 551 window_delegate.set_hittest_code(HTRIGHT); | 555 window_delegate.set_hittest_code(HTRIGHT); |
| 552 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, | 556 ui::MouseEvent move1( |
| 553 ui::EventTimeForNow(), 0, 0); | 557 ui::ET_MOUSE_MOVED, point1, point1, ui::EventTimeForNow(), 0, 0, |
| 558 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 554 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move1); | 559 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move1); |
| 555 ASSERT_FALSE(details.dispatcher_destroyed); | 560 ASSERT_FALSE(details.dispatcher_destroyed); |
| 556 EXPECT_EQ(ui::kCursorEastResize, host->last_cursor().native_type()); | 561 EXPECT_EQ(ui::kCursorEastResize, host->last_cursor().native_type()); |
| 557 } | 562 } |
| 558 | 563 |
| 559 { | 564 { |
| 560 window_delegate.set_hittest_code(HTTOP); | 565 window_delegate.set_hittest_code(HTTOP); |
| 561 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, | 566 ui::MouseEvent move2( |
| 562 ui::EventTimeForNow(), 0, 0); | 567 ui::ET_MOUSE_MOVED, point2, point2, ui::EventTimeForNow(), 0, 0, |
| 568 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 563 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move2); | 569 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move2); |
| 564 ASSERT_FALSE(details.dispatcher_destroyed); | 570 ASSERT_FALSE(details.dispatcher_destroyed); |
| 565 EXPECT_EQ(ui::kCursorNorthResize, host->last_cursor().native_type()); | 571 EXPECT_EQ(ui::kCursorNorthResize, host->last_cursor().native_type()); |
| 566 } | 572 } |
| 567 | 573 |
| 568 { | 574 { |
| 569 window_delegate.set_hittest_code(HTTOPLEFT); | 575 window_delegate.set_hittest_code(HTTOPLEFT); |
| 570 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, | 576 ui::MouseEvent move1( |
| 571 ui::EventTimeForNow(), 0, 0); | 577 ui::ET_MOUSE_MOVED, point1, point1, ui::EventTimeForNow(), 0, 0, |
| 578 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 572 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move1); | 579 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move1); |
| 573 ASSERT_FALSE(details.dispatcher_destroyed); | 580 ASSERT_FALSE(details.dispatcher_destroyed); |
| 574 EXPECT_EQ(ui::kCursorNorthWestResize, host->last_cursor().native_type()); | 581 EXPECT_EQ(ui::kCursorNorthWestResize, host->last_cursor().native_type()); |
| 575 } | 582 } |
| 576 | 583 |
| 577 { | 584 { |
| 578 window_delegate.set_hittest_code(HTTOPRIGHT); | 585 window_delegate.set_hittest_code(HTTOPRIGHT); |
| 579 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, | 586 ui::MouseEvent move2( |
| 580 ui::EventTimeForNow(), 0, 0); | 587 ui::ET_MOUSE_MOVED, point2, point2, ui::EventTimeForNow(), 0, 0, |
| 588 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 581 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move2); | 589 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move2); |
| 582 ASSERT_FALSE(details.dispatcher_destroyed); | 590 ASSERT_FALSE(details.dispatcher_destroyed); |
| 583 EXPECT_EQ(ui::kCursorNorthEastResize, host->last_cursor().native_type()); | 591 EXPECT_EQ(ui::kCursorNorthEastResize, host->last_cursor().native_type()); |
| 584 } | 592 } |
| 585 | 593 |
| 586 { | 594 { |
| 587 // Client area uses null cursor. | 595 // Client area uses null cursor. |
| 588 window_delegate.set_hittest_code(HTCLIENT); | 596 window_delegate.set_hittest_code(HTCLIENT); |
| 589 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, | 597 ui::MouseEvent move1( |
| 590 ui::EventTimeForNow(), 0, 0); | 598 ui::ET_MOUSE_MOVED, point1, point1, ui::EventTimeForNow(), 0, 0, |
| 599 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 591 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move1); | 600 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move1); |
| 592 ASSERT_FALSE(details.dispatcher_destroyed); | 601 ASSERT_FALSE(details.dispatcher_destroyed); |
| 593 EXPECT_EQ(ui::kCursorNull, host->last_cursor().native_type()); | 602 EXPECT_EQ(ui::kCursorNull, host->last_cursor().native_type()); |
| 594 } | 603 } |
| 595 } | 604 } |
| 596 | 605 |
| 597 #if defined(OS_WIN) | 606 #if defined(OS_WIN) |
| 598 #define MAYBE_TransformActivate DISABLED_TransformActivate | 607 #define MAYBE_TransformActivate DISABLED_TransformActivate |
| 599 #else | 608 #else |
| 600 #define MAYBE_TransformActivate TransformActivate | 609 #define MAYBE_TransformActivate TransformActivate |
| (...skipping 13 matching lines...) Expand all Loading... |
| 614 | 623 |
| 615 test::TestActivationDelegate d1; | 624 test::TestActivationDelegate d1; |
| 616 aura::test::TestWindowDelegate wd; | 625 aura::test::TestWindowDelegate wd; |
| 617 scoped_ptr<aura::Window> w1( | 626 scoped_ptr<aura::Window> w1( |
| 618 CreateTestWindowInShellWithDelegate(&wd, 1, gfx::Rect(0, 15, 50, 50))); | 627 CreateTestWindowInShellWithDelegate(&wd, 1, gfx::Rect(0, 15, 50, 50))); |
| 619 d1.SetWindow(w1.get()); | 628 d1.SetWindow(w1.get()); |
| 620 w1->Show(); | 629 w1->Show(); |
| 621 | 630 |
| 622 gfx::Point miss_point(5, 5); | 631 gfx::Point miss_point(5, 5); |
| 623 transform.TransformPoint(&miss_point); | 632 transform.TransformPoint(&miss_point); |
| 624 ui::MouseEvent mouseev1(ui::ET_MOUSE_PRESSED, miss_point, miss_point, | 633 ui::MouseEvent mouseev1( |
| 625 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, | 634 ui::ET_MOUSE_PRESSED, miss_point, miss_point, ui::EventTimeForNow(), |
| 626 ui::EF_LEFT_MOUSE_BUTTON); | 635 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 636 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 627 ui::EventProcessor* dispatcher = root_window->GetHost()->event_processor(); | 637 ui::EventProcessor* dispatcher = root_window->GetHost()->event_processor(); |
| 628 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&mouseev1); | 638 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&mouseev1); |
| 629 ASSERT_FALSE(details.dispatcher_destroyed); | 639 ASSERT_FALSE(details.dispatcher_destroyed); |
| 630 EXPECT_EQ(NULL, aura::client::GetFocusClient(w1.get())->GetFocusedWindow()); | 640 EXPECT_EQ(NULL, aura::client::GetFocusClient(w1.get())->GetFocusedWindow()); |
| 631 ui::MouseEvent mouseup(ui::ET_MOUSE_RELEASED, miss_point, miss_point, | 641 ui::MouseEvent mouseup( |
| 632 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, | 642 ui::ET_MOUSE_RELEASED, miss_point, miss_point, ui::EventTimeForNow(), |
| 633 ui::EF_LEFT_MOUSE_BUTTON); | 643 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 644 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 634 details = dispatcher->OnEventFromSource(&mouseup); | 645 details = dispatcher->OnEventFromSource(&mouseup); |
| 635 ASSERT_FALSE(details.dispatcher_destroyed); | 646 ASSERT_FALSE(details.dispatcher_destroyed); |
| 636 | 647 |
| 637 gfx::Point hit_point(5, 15); | 648 gfx::Point hit_point(5, 15); |
| 638 transform.TransformPoint(&hit_point); | 649 transform.TransformPoint(&hit_point); |
| 639 ui::MouseEvent mouseev2(ui::ET_MOUSE_PRESSED, hit_point, hit_point, | 650 ui::MouseEvent mouseev2( |
| 640 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, | 651 ui::ET_MOUSE_PRESSED, hit_point, hit_point, ui::EventTimeForNow(), |
| 641 ui::EF_LEFT_MOUSE_BUTTON); | 652 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 653 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 642 details = dispatcher->OnEventFromSource(&mouseev2); | 654 details = dispatcher->OnEventFromSource(&mouseev2); |
| 643 ASSERT_FALSE(details.dispatcher_destroyed); | 655 ASSERT_FALSE(details.dispatcher_destroyed); |
| 644 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); | 656 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
| 645 EXPECT_EQ(w1.get(), | 657 EXPECT_EQ(w1.get(), |
| 646 aura::client::GetFocusClient(w1.get())->GetFocusedWindow()); | 658 aura::client::GetFocusClient(w1.get())->GetFocusedWindow()); |
| 647 } | 659 } |
| 648 | 660 |
| 649 TEST_F(WindowManagerTest, AdditionalFilters) { | 661 TEST_F(WindowManagerTest, AdditionalFilters) { |
| 650 // The IME event filter interferes with the basic key event propagation we | 662 // The IME event filter interferes with the basic key event propagation we |
| 651 // attempt to do here, so we disable it. | 663 // attempt to do here, so we disable it. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 665 ::wm::CompoundEventFilter* env_filter = | 677 ::wm::CompoundEventFilter* env_filter = |
| 666 Shell::GetInstance()->env_filter(); | 678 Shell::GetInstance()->env_filter(); |
| 667 env_filter->AddHandler(f1.get()); | 679 env_filter->AddHandler(f1.get()); |
| 668 env_filter->AddHandler(f2.get()); | 680 env_filter->AddHandler(f2.get()); |
| 669 | 681 |
| 670 // Dispatches mouse and keyboard events. | 682 // Dispatches mouse and keyboard events. |
| 671 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE); | 683 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE); |
| 672 ui::EventProcessor* dispatcher = root_window->GetHost()->event_processor(); | 684 ui::EventProcessor* dispatcher = root_window->GetHost()->event_processor(); |
| 673 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&key_event); | 685 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&key_event); |
| 674 ASSERT_FALSE(details.dispatcher_destroyed); | 686 ASSERT_FALSE(details.dispatcher_destroyed); |
| 675 ui::MouseEvent mouse_pressed(ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), | 687 ui::MouseEvent mouse_pressed( |
| 676 gfx::Point(0, 0), ui::EventTimeForNow(), 0, 0); | 688 ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), gfx::Point(0, 0), |
| 689 ui::EventTimeForNow(), 0, 0, |
| 690 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 677 details = dispatcher->OnEventFromSource(&mouse_pressed); | 691 details = dispatcher->OnEventFromSource(&mouse_pressed); |
| 678 ASSERT_FALSE(details.dispatcher_destroyed); | 692 ASSERT_FALSE(details.dispatcher_destroyed); |
| 679 | 693 |
| 680 // Both filters should get the events. | 694 // Both filters should get the events. |
| 681 EXPECT_EQ(1, f1->num_key_events()); | 695 EXPECT_EQ(1, f1->num_key_events()); |
| 682 EXPECT_EQ(1, f1->num_mouse_events()); | 696 EXPECT_EQ(1, f1->num_mouse_events()); |
| 683 EXPECT_EQ(1, f2->num_key_events()); | 697 EXPECT_EQ(1, f2->num_key_events()); |
| 684 EXPECT_EQ(1, f2->num_mouse_events()); | 698 EXPECT_EQ(1, f2->num_mouse_events()); |
| 685 | 699 |
| 686 f1->Reset(); | 700 f1->Reset(); |
| 687 f2->Reset(); | 701 f2->Reset(); |
| 688 | 702 |
| 689 // Makes f1 consume events. | 703 // Makes f1 consume events. |
| 690 f1->set_key_event_handling_result(ui::ER_CONSUMED); | 704 f1->set_key_event_handling_result(ui::ER_CONSUMED); |
| 691 f1->set_mouse_event_handling_result(ui::ER_CONSUMED); | 705 f1->set_mouse_event_handling_result(ui::ER_CONSUMED); |
| 692 | 706 |
| 693 // Dispatches events. | 707 // Dispatches events. |
| 694 details = dispatcher->OnEventFromSource(&key_event); | 708 details = dispatcher->OnEventFromSource(&key_event); |
| 695 ASSERT_FALSE(details.dispatcher_destroyed); | 709 ASSERT_FALSE(details.dispatcher_destroyed); |
| 696 ui::MouseEvent mouse_released(ui::ET_MOUSE_RELEASED, gfx::Point(0, 0), | 710 ui::MouseEvent mouse_released( |
| 697 gfx::Point(0, 0), ui::EventTimeForNow(), 0, 0); | 711 ui::ET_MOUSE_RELEASED, gfx::Point(0, 0), gfx::Point(0, 0), |
| 712 ui::EventTimeForNow(), 0, 0, |
| 713 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 698 details = dispatcher->OnEventFromSource(&mouse_released); | 714 details = dispatcher->OnEventFromSource(&mouse_released); |
| 699 ASSERT_FALSE(details.dispatcher_destroyed); | 715 ASSERT_FALSE(details.dispatcher_destroyed); |
| 700 | 716 |
| 701 // f1 should still get the events but f2 no longer gets them. | 717 // f1 should still get the events but f2 no longer gets them. |
| 702 EXPECT_EQ(1, f1->num_key_events()); | 718 EXPECT_EQ(1, f1->num_key_events()); |
| 703 EXPECT_EQ(1, f1->num_mouse_events()); | 719 EXPECT_EQ(1, f1->num_mouse_events()); |
| 704 EXPECT_EQ(0, f2->num_key_events()); | 720 EXPECT_EQ(0, f2->num_key_events()); |
| 705 EXPECT_EQ(0, f2->num_mouse_events()); | 721 EXPECT_EQ(0, f2->num_mouse_events()); |
| 706 | 722 |
| 707 f1->Reset(); | 723 f1->Reset(); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 generator.MoveMouseTo(50, 50); | 866 generator.MoveMouseTo(50, 50); |
| 851 EXPECT_TRUE(observer_a.did_visibility_change()); | 867 EXPECT_TRUE(observer_a.did_visibility_change()); |
| 852 EXPECT_FALSE(observer_b.did_visibility_change()); | 868 EXPECT_FALSE(observer_b.did_visibility_change()); |
| 853 EXPECT_TRUE(observer_a.is_cursor_visible()); | 869 EXPECT_TRUE(observer_a.is_cursor_visible()); |
| 854 | 870 |
| 855 cursor_manager->RemoveObserver(&observer_a); | 871 cursor_manager->RemoveObserver(&observer_a); |
| 856 } | 872 } |
| 857 #endif // defined(OS_CHROMEOS) | 873 #endif // defined(OS_CHROMEOS) |
| 858 | 874 |
| 859 } // namespace ash | 875 } // namespace ash |
| OLD | NEW |