File: spoken_feedback_browsertest.h

package info (click to toggle)
chromium 139.0.7258.138-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,120,676 kB
  • sloc: cpp: 35,100,869; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (117 lines) | stat: -rw-r--r-- 4,459 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_ASH_ACCESSIBILITY_SPOKEN_FEEDBACK_BROWSERTEST_H_
#define CHROME_BROWSER_ASH_ACCESSIBILITY_SPOKEN_FEEDBACK_BROWSERTEST_H_

#include "ash/public/cpp/accelerators.h"
#include "chrome/browser/ash/accessibility/accessibility_feature_browsertest.h"
#include "chrome/browser/ash/accessibility/accessibility_test_utils.h"
#include "chrome/browser/ash/accessibility/chromevox_test_utils.h"
#include "chrome/browser/ash/accessibility/speech_monitor.h"
#include "chrome/browser/extensions/api/braille_display_private/stub_braille_controller.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/events/keycodes/keyboard_codes_posix.h"

namespace ui::test {
class EventGenerator;
}

namespace ash {

using ::extensions::api::braille_display_private::StubBrailleController;

// Spoken feedback tests in both a logged in browser window and guest mode.
enum SpokenFeedbackTestVariant { kTestAsNormalUser, kTestAsGuestUser };

// A class used to define the parameters of a spoken feedback test case.
class SpokenFeedbackTestConfig {
 public:
  explicit SpokenFeedbackTestConfig(ManifestVersion manifest_version)
      : manifest_version_(manifest_version) {}

  SpokenFeedbackTestConfig(ManifestVersion manifest_version,
                           SpokenFeedbackTestVariant variant)
      : manifest_version_(manifest_version), variant_(variant) {}

  SpokenFeedbackTestConfig(ManifestVersion manifest_version,
                           SpokenFeedbackTestVariant variant,
                           bool tablet_mode)
      : manifest_version_(manifest_version),
        variant_(variant),
        tablet_mode_(tablet_mode) {}

  ManifestVersion manifest_version() const { return manifest_version_; }
  std::optional<SpokenFeedbackTestVariant> variant() const { return variant_; }
  std::optional<bool> tablet_mode() const { return tablet_mode_; }

 private:
  ManifestVersion manifest_version_;
  std::optional<SpokenFeedbackTestVariant> variant_;
  std::optional<bool> tablet_mode_;
};

// Spoken feedback tests only in a logged in user's window.
class LoggedInSpokenFeedbackTest
    : public AccessibilityFeatureBrowserTest,
      public ::testing::WithParamInterface<SpokenFeedbackTestConfig> {
 public:
  LoggedInSpokenFeedbackTest();

  LoggedInSpokenFeedbackTest(const LoggedInSpokenFeedbackTest&) = delete;
  LoggedInSpokenFeedbackTest& operator=(const LoggedInSpokenFeedbackTest&) =
      delete;

  ~LoggedInSpokenFeedbackTest() override;

  // AccessibilityFeatureBrowserTest:
  void SetUpInProcessBrowserTestFixture() override;
  void SetUpCommandLine(base::CommandLine* command_line) override;
  void SetUpOnMainThread() override;
  void TearDownOnMainThread() override;

  // Simulate key press event.
  void SendKeyPress(ui::KeyboardCode key);
  void SendKeyPressWithControl(ui::KeyboardCode key);
  void SendKeyPressWithControlAndAlt(ui::KeyboardCode key);
  void SendKeyPressWithControlAndShift(ui::KeyboardCode key);
  void SendKeyPressWithShift(ui::KeyboardCode key);
  void SendKeyPressWithAltAndShift(ui::KeyboardCode key);
  void SendKeyPressWithSearchAndShift(ui::KeyboardCode key);
  void SendKeyPressWithSearch(ui::KeyboardCode key);
  void SendKeyPressWithSearchAndControl(ui::KeyboardCode key);
  void SendKeyPressWithSearchAndControlAndShift(ui::KeyboardCode key);

  void SendStickyKeyCommand();

  void SendMouseMoveTo(const gfx::Point& location);
  void SetMouseSourceDeviceId(int id);

  bool PerformAcceleratorAction(AcceleratorAction action);

  void StablizeChromeVoxState();

  void PressRepeatedlyUntilUtterance(ui::KeyboardCode key,
                                     const std::string& expected_utterance);

  ui::test::EventGenerator* event_generator() { return event_generator_.get(); }

  ChromeVoxTestUtils* chromevox_test_utils() {
    return chromevox_test_utils_.get();
  }

  test::SpeechMonitor* sm() { return chromevox_test_utils()->sm(); }

 private:
  std::unique_ptr<ui::test::EventGenerator> event_generator_;
  std::unique_ptr<ChromeVoxTestUtils> chromevox_test_utils_;

  StubBrailleController braille_controller_;
  ui::ScopedAnimationDurationScaleMode animation_mode_;
  base::test::ScopedFeatureList scoped_feature_list_;
};

}  // namespace ash

#endif  // CHROME_BROWSER_ASH_ACCESSIBILITY_SPOKEN_FEEDBACK_BROWSERTEST_H_