| 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/public/cpp/shell_window_ids.h" | 5 #include "ash/public/cpp/shell_window_ids.h" |
| 6 #include "ash/shell.h" | 6 #include "ash/shell.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 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 // Client area uses null cursor. | 560 // Client area uses null cursor. |
| 561 window_delegate.set_hittest_code(HTCLIENT); | 561 window_delegate.set_hittest_code(HTCLIENT); |
| 562 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, | 562 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, |
| 563 ui::EventTimeForNow(), 0, 0); | 563 ui::EventTimeForNow(), 0, 0); |
| 564 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move1); | 564 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move1); |
| 565 ASSERT_FALSE(details.dispatcher_destroyed); | 565 ASSERT_FALSE(details.dispatcher_destroyed); |
| 566 EXPECT_EQ(ui::kCursorNull, host->last_cursor().native_type()); | 566 EXPECT_EQ(ui::kCursorNull, host->last_cursor().native_type()); |
| 567 } | 567 } |
| 568 } | 568 } |
| 569 | 569 |
| 570 #if defined(OS_WIN) | 570 TEST_F(WindowManagerTest, TransformActivate) { |
| 571 #define MAYBE_TransformActivate DISABLED_TransformActivate | |
| 572 #else | |
| 573 #define MAYBE_TransformActivate TransformActivate | |
| 574 #endif | |
| 575 TEST_F(WindowManagerTest, MAYBE_TransformActivate) { | |
| 576 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 571 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
| 577 gfx::Size size = root_window->bounds().size(); | 572 gfx::Size size = root_window->bounds().size(); |
| 578 EXPECT_EQ(gfx::Rect(size).ToString(), | 573 EXPECT_EQ(gfx::Rect(size).ToString(), |
| 579 display::Screen::GetScreen() | 574 display::Screen::GetScreen() |
| 580 ->GetDisplayNearestPoint(gfx::Point()) | 575 ->GetDisplayNearestPoint(gfx::Point()) |
| 581 .bounds() | 576 .bounds() |
| 582 .ToString()); | 577 .ToString()); |
| 583 | 578 |
| 584 // Rotate it clock-wise 90 degrees. | 579 // Rotate it clock-wise 90 degrees. |
| 585 gfx::Transform transform; | 580 gfx::Transform transform; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 | 687 |
| 693 // f1 should get no events since it's out and f2 should get them. | 688 // f1 should get no events since it's out and f2 should get them. |
| 694 EXPECT_EQ(0, f1->num_key_events()); | 689 EXPECT_EQ(0, f1->num_key_events()); |
| 695 EXPECT_EQ(0, f1->num_mouse_events()); | 690 EXPECT_EQ(0, f1->num_mouse_events()); |
| 696 EXPECT_EQ(1, f2->num_key_events()); | 691 EXPECT_EQ(1, f2->num_key_events()); |
| 697 EXPECT_EQ(1, f2->num_mouse_events()); | 692 EXPECT_EQ(1, f2->num_mouse_events()); |
| 698 | 693 |
| 699 env_filter->RemoveHandler(f2.get()); | 694 env_filter->RemoveHandler(f2.get()); |
| 700 } | 695 } |
| 701 | 696 |
| 702 #if defined(OS_CHROMEOS) || defined(OS_WIN) | 697 // Touch visually hides the cursor. |
| 703 // Touch visually hides the cursor on ChromeOS and Windows | |
| 704 TEST_F(WindowManagerTest, UpdateCursorVisibility) { | 698 TEST_F(WindowManagerTest, UpdateCursorVisibility) { |
| 705 ui::test::EventGenerator& generator = GetEventGenerator(); | 699 ui::test::EventGenerator& generator = GetEventGenerator(); |
| 706 ::wm::CursorManager* cursor_manager = | 700 ::wm::CursorManager* cursor_manager = |
| 707 ash::Shell::GetInstance()->cursor_manager(); | 701 ash::Shell::GetInstance()->cursor_manager(); |
| 708 | 702 |
| 709 generator.MoveMouseTo(gfx::Point(0, 0)); | 703 generator.MoveMouseTo(gfx::Point(0, 0)); |
| 710 EXPECT_TRUE(cursor_manager->IsCursorVisible()); | 704 EXPECT_TRUE(cursor_manager->IsCursorVisible()); |
| 711 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); | 705 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); |
| 712 generator.PressTouch(); | 706 generator.PressTouch(); |
| 713 EXPECT_FALSE(cursor_manager->IsCursorVisible()); | 707 EXPECT_FALSE(cursor_manager->IsCursorVisible()); |
| 714 EXPECT_FALSE(cursor_manager->IsMouseEventsEnabled()); | 708 EXPECT_FALSE(cursor_manager->IsMouseEventsEnabled()); |
| 715 generator.MoveMouseTo(gfx::Point(0, 0)); | 709 generator.MoveMouseTo(gfx::Point(0, 0)); |
| 716 EXPECT_TRUE(cursor_manager->IsCursorVisible()); | 710 EXPECT_TRUE(cursor_manager->IsCursorVisible()); |
| 717 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); | 711 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); |
| 718 generator.ReleaseTouch(); | 712 generator.ReleaseTouch(); |
| 719 EXPECT_TRUE(cursor_manager->IsCursorVisible()); | 713 EXPECT_TRUE(cursor_manager->IsCursorVisible()); |
| 720 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); | 714 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); |
| 721 } | 715 } |
| 722 #endif // defined(OS_CHROMEOS) || defined(OS_WIN) | |
| 723 | 716 |
| 724 #if defined(OS_CHROMEOS) | 717 // Cursor is hidden on keypress. |
| 725 // ChromeOS is the only platform for which the cursor is hidden on keypress | |
| 726 // (crbug.com/304296). | |
| 727 TEST_F(WindowManagerTest, UpdateCursorVisibilityOnKeyEvent) { | 718 TEST_F(WindowManagerTest, UpdateCursorVisibilityOnKeyEvent) { |
| 728 ui::test::EventGenerator& generator = GetEventGenerator(); | 719 ui::test::EventGenerator& generator = GetEventGenerator(); |
| 729 ::wm::CursorManager* cursor_manager = | 720 ::wm::CursorManager* cursor_manager = |
| 730 ash::Shell::GetInstance()->cursor_manager(); | 721 ash::Shell::GetInstance()->cursor_manager(); |
| 731 | 722 |
| 732 // Pressing a key hides the cursor but does not disable mouse events. | 723 // Pressing a key hides the cursor but does not disable mouse events. |
| 733 generator.PressKey(ui::VKEY_A, ui::EF_NONE); | 724 generator.PressKey(ui::VKEY_A, ui::EF_NONE); |
| 734 EXPECT_FALSE(cursor_manager->IsCursorVisible()); | 725 EXPECT_FALSE(cursor_manager->IsCursorVisible()); |
| 735 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); | 726 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); |
| 736 // Moving mouse shows the cursor. | 727 // Moving mouse shows the cursor. |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 // Mouse move should show the cursor. | 827 // Mouse move should show the cursor. |
| 837 observer_a.reset(); | 828 observer_a.reset(); |
| 838 observer_b.reset(); | 829 observer_b.reset(); |
| 839 generator.MoveMouseTo(50, 50); | 830 generator.MoveMouseTo(50, 50); |
| 840 EXPECT_TRUE(observer_a.did_visibility_change()); | 831 EXPECT_TRUE(observer_a.did_visibility_change()); |
| 841 EXPECT_FALSE(observer_b.did_visibility_change()); | 832 EXPECT_FALSE(observer_b.did_visibility_change()); |
| 842 EXPECT_TRUE(observer_a.is_cursor_visible()); | 833 EXPECT_TRUE(observer_a.is_cursor_visible()); |
| 843 | 834 |
| 844 cursor_manager->RemoveObserver(&observer_a); | 835 cursor_manager->RemoveObserver(&observer_a); |
| 845 } | 836 } |
| 846 #endif // defined(OS_CHROMEOS) | |
| 847 | 837 |
| 848 } // namespace ash | 838 } // namespace ash |
| OLD | NEW |