| 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/shell_test_api.h" | 8 #include "ash/test/shell_test_api.h" |
| 9 #include "ash/test/test_activation_delegate.h" | 9 #include "ash/test/test_activation_delegate.h" |
| 10 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 | 697 |
| 698 // f1 should get no events since it's out and f2 should get them. | 698 // f1 should get no events since it's out and f2 should get them. |
| 699 EXPECT_EQ(0, f1->num_key_events()); | 699 EXPECT_EQ(0, f1->num_key_events()); |
| 700 EXPECT_EQ(0, f1->num_mouse_events()); | 700 EXPECT_EQ(0, f1->num_mouse_events()); |
| 701 EXPECT_EQ(1, f2->num_key_events()); | 701 EXPECT_EQ(1, f2->num_key_events()); |
| 702 EXPECT_EQ(1, f2->num_mouse_events()); | 702 EXPECT_EQ(1, f2->num_mouse_events()); |
| 703 | 703 |
| 704 env_filter->RemoveHandler(f2.get()); | 704 env_filter->RemoveHandler(f2.get()); |
| 705 } | 705 } |
| 706 | 706 |
| 707 // A keypress and/or touch only hides the cursor on ChromeOS (crbug.com/304296). | 707 #if defined(OS_CHROMEOS) || defined(OS_WIN) |
| 708 #if defined(OS_CHROMEOS) | |
| 709 // We should show and hide the cursor in response to mouse and touch events as | 708 // We should show and hide the cursor in response to mouse and touch events as |
| 710 // requested. | 709 // requested. ChromeOS and Windows are the only platforms which hide the cursor |
| 710 // in response to touch (crbug.com/322250). |
| 711 TEST_F(WindowManagerTest, UpdateCursorVisibility) { | 711 TEST_F(WindowManagerTest, UpdateCursorVisibility) { |
| 712 aura::test::EventGenerator& generator = GetEventGenerator(); | 712 aura::test::EventGenerator& generator = GetEventGenerator(); |
| 713 views::corewm::CursorManager* cursor_manager = | 713 views::corewm::CursorManager* cursor_manager = |
| 714 ash::Shell::GetInstance()->cursor_manager(); | 714 ash::Shell::GetInstance()->cursor_manager(); |
| 715 | 715 |
| 716 generator.MoveMouseTo(gfx::Point(0, 0)); | 716 generator.MoveMouseTo(gfx::Point(0, 0)); |
| 717 EXPECT_TRUE(cursor_manager->IsCursorVisible()); | 717 EXPECT_TRUE(cursor_manager->IsCursorVisible()); |
| 718 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); | 718 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); |
| 719 generator.PressTouch(); | 719 generator.PressTouch(); |
| 720 EXPECT_FALSE(cursor_manager->IsCursorVisible()); | 720 EXPECT_FALSE(cursor_manager->IsCursorVisible()); |
| 721 EXPECT_FALSE(cursor_manager->IsMouseEventsEnabled()); | 721 EXPECT_FALSE(cursor_manager->IsMouseEventsEnabled()); |
| 722 generator.MoveMouseTo(gfx::Point(0, 0)); | 722 generator.MoveMouseTo(gfx::Point(0, 0)); |
| 723 EXPECT_TRUE(cursor_manager->IsCursorVisible()); | 723 EXPECT_TRUE(cursor_manager->IsCursorVisible()); |
| 724 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); | 724 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); |
| 725 generator.ReleaseTouch(); | 725 generator.ReleaseTouch(); |
| 726 EXPECT_TRUE(cursor_manager->IsCursorVisible()); | 726 EXPECT_TRUE(cursor_manager->IsCursorVisible()); |
| 727 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); | 727 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); |
| 728 } | 728 } |
| 729 #endif // defined(OS_CHROMEOS) || defined(OS_WIN) |
| 729 | 730 |
| 731 #if defined(OS_CHROMEOS) |
| 732 // ChromeOS is the only platform for which the cursor is hidden on both |
| 733 // touch and keypress (crbug.com/304296). |
| 730 TEST_F(WindowManagerTest, UpdateCursorVisibilityOnKeyEvent) { | 734 TEST_F(WindowManagerTest, UpdateCursorVisibilityOnKeyEvent) { |
| 731 aura::test::EventGenerator& generator = GetEventGenerator(); | 735 aura::test::EventGenerator& generator = GetEventGenerator(); |
| 732 views::corewm::CursorManager* cursor_manager = | 736 views::corewm::CursorManager* cursor_manager = |
| 733 ash::Shell::GetInstance()->cursor_manager(); | 737 ash::Shell::GetInstance()->cursor_manager(); |
| 734 | 738 |
| 735 // Pressing a key hides the cursor but does not disable mouse events. | 739 // Pressing a key hides the cursor but does not disable mouse events. |
| 736 generator.PressKey(ui::VKEY_A, ui::EF_NONE); | 740 generator.PressKey(ui::VKEY_A, ui::EF_NONE); |
| 737 EXPECT_FALSE(cursor_manager->IsCursorVisible()); | 741 EXPECT_FALSE(cursor_manager->IsCursorVisible()); |
| 738 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); | 742 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); |
| 739 // Moving mouse shows the cursor. | 743 // Moving mouse shows the cursor. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 EXPECT_FALSE(observer_a.is_cursor_visible()); | 807 EXPECT_FALSE(observer_a.is_cursor_visible()); |
| 804 | 808 |
| 805 // Mouse move should show the cursor. | 809 // Mouse move should show the cursor. |
| 806 observer_a.reset(); | 810 observer_a.reset(); |
| 807 observer_b.reset(); | 811 observer_b.reset(); |
| 808 generator.MoveMouseTo(50, 50); | 812 generator.MoveMouseTo(50, 50); |
| 809 EXPECT_TRUE(observer_a.did_visibility_change()); | 813 EXPECT_TRUE(observer_a.did_visibility_change()); |
| 810 EXPECT_FALSE(observer_b.did_visibility_change()); | 814 EXPECT_FALSE(observer_b.did_visibility_change()); |
| 811 EXPECT_TRUE(observer_a.is_cursor_visible()); | 815 EXPECT_TRUE(observer_a.is_cursor_visible()); |
| 812 } | 816 } |
| 813 #endif | 817 #endif // defined(OS_CHROMEOS) |
| 814 | 818 |
| 815 } // namespace ash | 819 } // namespace ash |
| OLD | NEW |