| 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 752 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  763       ash::Shell::GetInstance()->cursor_manager(); |  763       ash::Shell::GetInstance()->cursor_manager(); | 
|  764  |  764  | 
|  765   // Pressing a key hides the cursor but does not disable mouse events. |  765   // Pressing a key hides the cursor but does not disable mouse events. | 
|  766   generator.PressKey(ui::VKEY_A, ui::EF_NONE); |  766   generator.PressKey(ui::VKEY_A, ui::EF_NONE); | 
|  767   EXPECT_FALSE(cursor_manager->IsCursorVisible()); |  767   EXPECT_FALSE(cursor_manager->IsCursorVisible()); | 
|  768   EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); |  768   EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); | 
|  769   // Moving mouse shows the cursor. |  769   // Moving mouse shows the cursor. | 
|  770   generator.MoveMouseTo(gfx::Point(0, 0)); |  770   generator.MoveMouseTo(gfx::Point(0, 0)); | 
|  771   EXPECT_TRUE(cursor_manager->IsCursorVisible()); |  771   EXPECT_TRUE(cursor_manager->IsCursorVisible()); | 
|  772   EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); |  772   EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); | 
|  773   // Releasing a key also hides the cursor but does not disable mouse events. |  773   // Releasing a key does does not hide the cursor and does not disable mouse | 
 |  774   // events. | 
|  774   generator.ReleaseKey(ui::VKEY_A, ui::EF_NONE); |  775   generator.ReleaseKey(ui::VKEY_A, ui::EF_NONE); | 
|  775   EXPECT_FALSE(cursor_manager->IsCursorVisible()); |  | 
|  776   EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); |  | 
|  777   // Moving mouse shows the cursor again. |  | 
|  778   generator.MoveMouseTo(gfx::Point(0, 0)); |  | 
|  779   EXPECT_TRUE(cursor_manager->IsCursorVisible()); |  776   EXPECT_TRUE(cursor_manager->IsCursorVisible()); | 
|  780   EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); |  777   EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); | 
|  781 } |  778 } | 
|  782  |  779  | 
 |  780 // Test that pressing an accelerator does not hide the cursor. | 
 |  781 TEST_F(WindowManagerTest, UpdateCursorVisibilityAccelerator) { | 
 |  782   ui::test::EventGenerator& generator = GetEventGenerator(); | 
 |  783   ::wm::CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager(); | 
 |  784  | 
 |  785   ASSERT_TRUE(cursor_manager->IsCursorVisible()); | 
 |  786  | 
 |  787   // Press Ctrl+A, release A first. | 
 |  788   generator.PressKey(ui::VKEY_CONTROL, ui::EF_CONTROL_DOWN); | 
 |  789   generator.PressKey(ui::VKEY_A, ui::EF_CONTROL_DOWN); | 
 |  790   generator.ReleaseKey(ui::VKEY_A, ui::EF_CONTROL_DOWN); | 
 |  791   generator.ReleaseKey(ui::VKEY_CONTROL, ui::EF_NONE); | 
 |  792   EXPECT_TRUE(cursor_manager->IsCursorVisible()); | 
 |  793  | 
 |  794   // Press Ctrl+A, release Ctrl first. | 
 |  795   generator.PressKey(ui::VKEY_CONTROL, ui::EF_CONTROL_DOWN); | 
 |  796   generator.PressKey(ui::VKEY_A, ui::EF_CONTROL_DOWN); | 
 |  797   generator.ReleaseKey(ui::VKEY_CONTROL, ui::EF_NONE); | 
 |  798   generator.ReleaseKey(ui::VKEY_A, ui::EF_NONE); | 
 |  799   EXPECT_TRUE(cursor_manager->IsCursorVisible()); | 
 |  800 } | 
 |  801  | 
|  783 TEST_F(WindowManagerTest, TestCursorClientObserver) { |  802 TEST_F(WindowManagerTest, TestCursorClientObserver) { | 
|  784   ui::test::EventGenerator& generator = GetEventGenerator(); |  803   ui::test::EventGenerator& generator = GetEventGenerator(); | 
|  785   ::wm::CursorManager* cursor_manager = |  804   ::wm::CursorManager* cursor_manager = | 
|  786       ash::Shell::GetInstance()->cursor_manager(); |  805       ash::Shell::GetInstance()->cursor_manager(); | 
|  787  |  806  | 
|  788   scoped_ptr<aura::Window> w1(CreateTestWindowInShell( |  807   scoped_ptr<aura::Window> w1(CreateTestWindowInShell( | 
|  789       SK_ColorWHITE, -1, gfx::Rect(0, 0, 100, 100))); |  808       SK_ColorWHITE, -1, gfx::Rect(0, 0, 100, 100))); | 
|  790   wm::ActivateWindow(w1.get()); |  809   wm::ActivateWindow(w1.get()); | 
|  791  |  810  | 
|  792   // Add two observers. Both should have OnCursorVisibilityChanged() |  811   // Add two observers. Both should have OnCursorVisibilityChanged() | 
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  838   generator.MoveMouseTo(50, 50); |  857   generator.MoveMouseTo(50, 50); | 
|  839   EXPECT_TRUE(observer_a.did_visibility_change()); |  858   EXPECT_TRUE(observer_a.did_visibility_change()); | 
|  840   EXPECT_FALSE(observer_b.did_visibility_change()); |  859   EXPECT_FALSE(observer_b.did_visibility_change()); | 
|  841   EXPECT_TRUE(observer_a.is_cursor_visible()); |  860   EXPECT_TRUE(observer_a.is_cursor_visible()); | 
|  842  |  861  | 
|  843   cursor_manager->RemoveObserver(&observer_a); |  862   cursor_manager->RemoveObserver(&observer_a); | 
|  844 } |  863 } | 
|  845 #endif  // defined(OS_CHROMEOS) |  864 #endif  // defined(OS_CHROMEOS) | 
|  846  |  865  | 
|  847 }  // namespace ash |  866 }  // namespace ash | 
| OLD | NEW |