cursor_manager_chromeos_unittest.cc 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright 2021 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "ash/shell.h"
  5. #include "ash/test/ash_test_base.h"
  6. #include "ui/wm/core/cursor_manager.h"
  7. namespace ash {
  8. using CursorManagerChromeosTest = AshTestBase;
  9. // Verifies the cursor's visibility after receiving key commands.
  10. TEST_F(CursorManagerChromeosTest, VerifyVisibilityAfterKeyCommands) {
  11. auto* cursor_manager = Shell::Get()->cursor_manager();
  12. ASSERT_TRUE(cursor_manager->IsCursorVisible());
  13. // Pressing the normal key should hide the cursor.
  14. PressAndReleaseKey(ui::KeyboardCode::VKEY_C);
  15. EXPECT_FALSE(cursor_manager->IsCursorVisible());
  16. // Move the mouse and the cursor should show.
  17. GetEventGenerator()->MoveMouseBy(/*x=*/1, /*y=*/1);
  18. EXPECT_TRUE(cursor_manager->IsCursorVisible());
  19. // The command key commands should not hide the cursor.
  20. PressAndReleaseKey(ui::KeyboardCode::VKEY_C, ui::EF_COMMAND_DOWN);
  21. EXPECT_TRUE(cursor_manager->IsCursorVisible());
  22. // The alt key commands should not hide the cursor.
  23. PressAndReleaseKey(ui::KeyboardCode::VKEY_C, ui::EF_ALT_DOWN);
  24. EXPECT_TRUE(cursor_manager->IsCursorVisible());
  25. // The control key commands should not hide the cursor.
  26. PressAndReleaseKey(ui::KeyboardCode::VKEY_C, ui::EF_CONTROL_DOWN);
  27. EXPECT_TRUE(cursor_manager->IsCursorVisible());
  28. }
  29. } // namespace ash