power_button_controller_test_api.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // Copyright 2017 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. #ifndef ASH_SYSTEM_POWER_POWER_BUTTON_CONTROLLER_TEST_API_H_
  5. #define ASH_SYSTEM_POWER_POWER_BUTTON_CONTROLLER_TEST_API_H_
  6. #include "ash/system/power/power_button_controller.h"
  7. namespace base {
  8. class TickClock;
  9. } // namespace base
  10. namespace ui {
  11. class KeyEvent;
  12. } // namespace ui
  13. namespace gfx {
  14. class Rect;
  15. } // namespace gfx
  16. namespace ash {
  17. class PowerButtonMenuView;
  18. class PowerButtonScreenshotController;
  19. // Helper class used by tests to access PowerButtonController's internal state.
  20. class PowerButtonControllerTestApi {
  21. public:
  22. explicit PowerButtonControllerTestApi(PowerButtonController* controller);
  23. PowerButtonControllerTestApi(const PowerButtonControllerTestApi&) = delete;
  24. PowerButtonControllerTestApi& operator=(const PowerButtonControllerTestApi&) =
  25. delete;
  26. ~PowerButtonControllerTestApi();
  27. // Returns true when |controller_->pre_shutdown_timer_| is running.
  28. bool PreShutdownTimerIsRunning() const;
  29. // If |controller_->pre_shutdown_timer_| is running, stops it, runs its task,
  30. // and returns true. Otherwise, returns false.
  31. [[nodiscard]] bool TriggerPreShutdownTimeout();
  32. // Returns true when |power_button_menu_timer_| is running.
  33. bool PowerButtonMenuTimerIsRunning() const;
  34. // If |controller_->power_button_menu_timer_| is running, stops it, runs its
  35. // task, and returns true. Otherwise, returns false.
  36. [[nodiscard]] bool TriggerPowerButtonMenuTimeout();
  37. // Sends |event| to |controller_->display_controller_|.
  38. void SendKeyEvent(ui::KeyEvent* event);
  39. // Gets the bounds of the menu view in screen.
  40. gfx::Rect GetMenuBoundsInScreen() const;
  41. // Gets the PowerButtonMenuView of the |controller_|'s menu, which is used by
  42. // GetMenuBoundsInScreen.
  43. PowerButtonMenuView* GetPowerButtonMenuView() const;
  44. // True if the menu is opened.
  45. bool IsMenuOpened() const;
  46. // True if |controller_|'s menu has a sign out item.
  47. bool MenuHasSignOutItem() const;
  48. // True if |controller_|'s menu has a lock screen item.
  49. bool MenuHasLockScreenItem() const;
  50. // True if |controller_|'s menu has a feedback item.
  51. bool MenuHasFeedbackItem() const;
  52. PowerButtonScreenshotController* GetScreenshotController();
  53. void SetPowerButtonType(PowerButtonController::ButtonType button_type);
  54. void SetTickClock(const base::TickClock* tick_clock);
  55. void SetShowMenuAnimationDone(bool show_menu_animation_done);
  56. // Gets |show_menu_animation_done_| of |controller_|.
  57. bool ShowMenuAnimationDone() const;
  58. private:
  59. PowerButtonController* controller_; // Not owned.
  60. };
  61. } // namespace ash
  62. #endif // ASH_SYSTEM_POWER_POWER_BUTTON_CONTROLLER_TEST_API_H_