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/activation_controller.h" | 10 #include "ash/wm/activation_controller.h" |
11 #include "ash/wm/cursor_manager.h" | |
12 #include "ash/wm/window_util.h" | 11 #include "ash/wm/window_util.h" |
13 #include "ui/aura/client/activation_client.h" | 12 #include "ui/aura/client/activation_client.h" |
14 #include "ui/aura/client/activation_delegate.h" | 13 #include "ui/aura/client/activation_delegate.h" |
15 #include "ui/aura/client/focus_client.h" | 14 #include "ui/aura/client/focus_client.h" |
16 #include "ui/aura/env.h" | 15 #include "ui/aura/env.h" |
17 #include "ui/aura/root_window.h" | 16 #include "ui/aura/root_window.h" |
18 #include "ui/aura/test/aura_test_base.h" | 17 #include "ui/aura/test/aura_test_base.h" |
19 #include "ui/aura/test/event_generator.h" | 18 #include "ui/aura/test/event_generator.h" |
20 #include "ui/aura/test/test_event_handler.h" | 19 #include "ui/aura/test/test_event_handler.h" |
21 #include "ui/aura/test/test_window_delegate.h" | 20 #include "ui/aura/test/test_window_delegate.h" |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 EXPECT_EQ(1, f2->num_key_events()); | 635 EXPECT_EQ(1, f2->num_key_events()); |
637 EXPECT_EQ(1, f2->num_mouse_events()); | 636 EXPECT_EQ(1, f2->num_mouse_events()); |
638 | 637 |
639 env_filter->RemoveHandler(f2.get()); | 638 env_filter->RemoveHandler(f2.get()); |
640 } | 639 } |
641 | 640 |
642 // We should show and hide the cursor in response to mouse and touch events as | 641 // We should show and hide the cursor in response to mouse and touch events as |
643 // requested. | 642 // requested. |
644 TEST_F(WindowManagerTest, UpdateCursorVisibility) { | 643 TEST_F(WindowManagerTest, UpdateCursorVisibility) { |
645 aura::test::EventGenerator& generator = GetEventGenerator(); | 644 aura::test::EventGenerator& generator = GetEventGenerator(); |
646 ash::CursorManager* cursor_manager = | 645 views::corewm::CursorManager* cursor_manager = |
647 ash::Shell::GetInstance()->cursor_manager(); | 646 ash::Shell::GetInstance()->cursor_manager(); |
648 | 647 |
649 generator.MoveMouseTo(gfx::Point(0, 0)); | 648 generator.MoveMouseTo(gfx::Point(0, 0)); |
650 EXPECT_TRUE(cursor_manager->IsCursorVisible()); | 649 EXPECT_TRUE(cursor_manager->IsCursorVisible()); |
651 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); | 650 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); |
652 generator.PressTouch(); | 651 generator.PressTouch(); |
653 EXPECT_FALSE(cursor_manager->IsCursorVisible()); | 652 EXPECT_FALSE(cursor_manager->IsCursorVisible()); |
654 EXPECT_FALSE(cursor_manager->IsMouseEventsEnabled()); | 653 EXPECT_FALSE(cursor_manager->IsMouseEventsEnabled()); |
655 generator.MoveMouseTo(gfx::Point(0, 0)); | 654 generator.MoveMouseTo(gfx::Point(0, 0)); |
656 EXPECT_TRUE(cursor_manager->IsCursorVisible()); | 655 EXPECT_TRUE(cursor_manager->IsCursorVisible()); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 generator.MoveMouseTo(gfx::Point(0, 0)); | 687 generator.MoveMouseTo(gfx::Point(0, 0)); |
689 EXPECT_TRUE(cursor_manager->IsCursorVisible()); | 688 EXPECT_TRUE(cursor_manager->IsCursorVisible()); |
690 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); | 689 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); |
691 generator.ReleaseTouch(); | 690 generator.ReleaseTouch(); |
692 EXPECT_TRUE(cursor_manager->IsCursorVisible()); | 691 EXPECT_TRUE(cursor_manager->IsCursorVisible()); |
693 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); | 692 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); |
694 } | 693 } |
695 | 694 |
696 TEST_F(WindowManagerTest, UpdateCursorVisibilityOnKeyEvent) { | 695 TEST_F(WindowManagerTest, UpdateCursorVisibilityOnKeyEvent) { |
697 aura::test::EventGenerator& generator = GetEventGenerator(); | 696 aura::test::EventGenerator& generator = GetEventGenerator(); |
698 ash::CursorManager* cursor_manager = | 697 views::corewm::CursorManager* cursor_manager = |
699 ash::Shell::GetInstance()->cursor_manager(); | 698 ash::Shell::GetInstance()->cursor_manager(); |
700 | 699 |
701 // Pressing a key hides the cursor but does not disable mouse events. | 700 // Pressing a key hides the cursor but does not disable mouse events. |
702 generator.PressKey(ui::VKEY_A, ui::EF_NONE); | 701 generator.PressKey(ui::VKEY_A, ui::EF_NONE); |
703 EXPECT_FALSE(cursor_manager->IsCursorVisible()); | 702 EXPECT_FALSE(cursor_manager->IsCursorVisible()); |
704 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); | 703 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); |
705 // Moving mouse shows the cursor. | 704 // Moving mouse shows the cursor. |
706 generator.MoveMouseTo(gfx::Point(0, 0)); | 705 generator.MoveMouseTo(gfx::Point(0, 0)); |
707 EXPECT_TRUE(cursor_manager->IsCursorVisible()); | 706 EXPECT_TRUE(cursor_manager->IsCursorVisible()); |
708 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); | 707 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); |
709 // Releasing a key also hides the cursor but does not disable mouse events. | 708 // Releasing a key also hides the cursor but does not disable mouse events. |
710 generator.ReleaseKey(ui::VKEY_A, ui::EF_NONE); | 709 generator.ReleaseKey(ui::VKEY_A, ui::EF_NONE); |
711 EXPECT_FALSE(cursor_manager->IsCursorVisible()); | 710 EXPECT_FALSE(cursor_manager->IsCursorVisible()); |
712 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); | 711 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); |
713 // Moving mouse shows the cursor again. | 712 // Moving mouse shows the cursor again. |
714 generator.MoveMouseTo(gfx::Point(0, 0)); | 713 generator.MoveMouseTo(gfx::Point(0, 0)); |
715 EXPECT_TRUE(cursor_manager->IsCursorVisible()); | 714 EXPECT_TRUE(cursor_manager->IsCursorVisible()); |
716 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); | 715 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); |
717 } | 716 } |
718 | 717 |
719 } // namespace ash | 718 } // namespace ash |
OLD | NEW |