test_accessibility_controller_client.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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_ACCESSIBILITY_TEST_ACCESSIBILITY_CONTROLLER_CLIENT_H_
  5. #define ASH_ACCESSIBILITY_TEST_ACCESSIBILITY_CONTROLLER_CLIENT_H_
  6. #include "ash/public/cpp/accessibility_controller_client.h"
  7. #include "ash/public/cpp/accessibility_controller_enums.h"
  8. #include "chromeos/ash/components/audio/sounds.h"
  9. #include "third_party/abseil-cpp/absl/types/optional.h"
  10. #include "ui/accessibility/ax_enums.mojom.h"
  11. namespace ash {
  12. // Implement AccessibilityControllerClient mojo interface to simulate chrome
  13. // behavior in tests. This breaks the ash/chrome dependency to allow testing ash
  14. // code in isolation.
  15. class TestAccessibilityControllerClient : public AccessibilityControllerClient {
  16. public:
  17. TestAccessibilityControllerClient();
  18. TestAccessibilityControllerClient(const TestAccessibilityControllerClient&) =
  19. delete;
  20. TestAccessibilityControllerClient& operator=(
  21. const TestAccessibilityControllerClient&) = delete;
  22. ~TestAccessibilityControllerClient();
  23. static constexpr base::TimeDelta kShutdownSoundDuration =
  24. base::Milliseconds(1000);
  25. // AccessibilityControllerClient:
  26. void TriggerAccessibilityAlert(AccessibilityAlert alert) override;
  27. void TriggerAccessibilityAlertWithMessage(
  28. const std::string& message) override;
  29. void PlayEarcon(Sound sound_key) override;
  30. base::TimeDelta PlayShutdownSound() override;
  31. void HandleAccessibilityGesture(ax::mojom::Gesture gesture,
  32. gfx::PointF location) override;
  33. bool ToggleDictation() override;
  34. void SilenceSpokenFeedback() override;
  35. void OnTwoFingerTouchStart() override;
  36. void OnTwoFingerTouchStop() override;
  37. bool ShouldToggleSpokenFeedbackViaTouch() const override;
  38. void PlaySpokenFeedbackToggleCountdown(int tick_count) override;
  39. void RequestSelectToSpeakStateChange() override;
  40. void RequestAutoclickScrollableBoundsForPoint(
  41. gfx::Point& point_in_screen) override;
  42. void MagnifierBoundsChanged(const gfx::Rect& bounds_in_screen) override;
  43. void OnSwitchAccessDisabled() override;
  44. void OnSelectToSpeakPanelAction(SelectToSpeakPanelAction action,
  45. double value) override;
  46. void SetA11yOverrideWindow(aura::Window* a11y_override_window) override;
  47. absl::optional<Sound> GetPlayedEarconAndReset();
  48. AccessibilityAlert last_a11y_alert() const { return last_a11y_alert_; }
  49. ax::mojom::Gesture last_a11y_gesture() const { return last_a11y_gesture_; }
  50. int select_to_speak_change_change_requests() const {
  51. return select_to_speak_state_change_requests_;
  52. }
  53. const std::string& last_alert_message() const { return last_alert_message_; }
  54. SelectToSpeakPanelAction last_select_to_speak_panel_action() const {
  55. return last_select_to_speak_panel_action_;
  56. }
  57. double last_select_to_speak_panel_action_value() const {
  58. return last_select_to_speak_panel_action_value_;
  59. }
  60. private:
  61. AccessibilityAlert last_a11y_alert_ = AccessibilityAlert::NONE;
  62. std::string last_alert_message_;
  63. absl::optional<Sound> sound_key_;
  64. bool is_dictation_active_ = false;
  65. SelectToSpeakPanelAction last_select_to_speak_panel_action_ =
  66. SelectToSpeakPanelAction::kNone;
  67. double last_select_to_speak_panel_action_value_ = 0.0;
  68. ax::mojom::Gesture last_a11y_gesture_ = ax::mojom::Gesture::kNone;
  69. int select_to_speak_state_change_requests_ = 0;
  70. };
  71. } // namespace ash
  72. #endif // ASH_ACCESSIBILITY_TEST_ACCESSIBILITY_CONTROLLER_CLIENT_H_