File: test_native_display_delegate.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (165 lines) | stat: -rw-r--r-- 6,043 bytes parent folder | download | duplicates (5)
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_DISPLAY_MANAGER_TEST_TEST_NATIVE_DISPLAY_DELEGATE_H_
#define UI_DISPLAY_MANAGER_TEST_TEST_NATIVE_DISPLAY_DELEGATE_H_

#include <stdint.h>

#include <vector>

#include "base/containers/flat_map.h"
#include "base/memory/raw_ptr.h"
#include "base/observer_list.h"
#include "ui/display/manager/test/action_logger.h"
#include "ui/display/manager/test/action_logger_util.h"
#include "ui/display/types/display_constants.h"
#include "ui/display/types/native_display_delegate.h"

namespace display {

class ActionLogger;
class DisplaySnapshot;
class NativeDisplayObserver;

namespace test {

constexpr char kTestModesetStr[] = "test-modeset";
constexpr char kCommitModesetStr[] = "commit-modeset";
constexpr char kSeamlessModesetStr[] = "seamless-modeset";
constexpr char kModesetOutcomeFailure[] = "outcome: failure";
constexpr char kModesetOutcomeSuccess[] = "outcome: success";

class TestNativeDisplayDelegate : public NativeDisplayDelegate {
 public:
  // Ownership of |log| remains with the caller.
  explicit TestNativeDisplayDelegate(ActionLogger* log);

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

  ~TestNativeDisplayDelegate() override;

  void set_max_configurable_pixels(int pixels) {
    max_configurable_pixels_ = pixels;
  }

  void set_system_bandwidth_limit(int bandwidth_limit) {
    system_bandwidth_limit_ = bandwidth_limit;
  }

  void set_get_hdcp_state_expectation(bool success) {
    get_hdcp_expectation_ = success;
  }

  void set_set_hdcp_state_expectation(bool success) {
    set_hdcp_expectation_ = success;
  }

  HDCPState hdcp_state() const { return hdcp_state_; }
  void set_hdcp_state(HDCPState state) { hdcp_state_ = state; }

  ContentProtectionMethod content_protection_method() const {
    return content_protection_method_;
  }
  void set_content_protection_method(
      ContentProtectionMethod protection_method) {
    content_protection_method_ = protection_method;
  }

  void set_run_async(bool run_async) { run_async_ = run_async; }

  const std::vector<raw_ptr<DisplaySnapshot, VectorExperimental>> GetOutputs()
      const;

  // Sets and takes ownership of the provided |outputs|.
  void SetOutputs(std::vector<std::unique_ptr<DisplaySnapshot>> outputs);

  // NativeDisplayDelegate overrides:
  void Initialize() override;
  void TakeDisplayControl(DisplayControlCallback callback) override;
  void RelinquishDisplayControl(DisplayControlCallback callback) override;
  void GetDisplays(GetDisplaysCallback callback) override;
  void Configure(
      const std::vector<display::DisplayConfigurationParams>& config_requests,
      ConfigureCallback callback,
      display::ModesetFlags modeset_flags) override;
  void SetHdcpKeyProp(int64_t display_id,
                      const std::string& key,
                      SetHdcpKeyPropCallback callback) override;
  void GetHDCPState(const DisplaySnapshot& output,
                    GetHDCPStateCallback callback) override;
  void SetHDCPState(const DisplaySnapshot& output,
                    HDCPState state,
                    ContentProtectionMethod protection_method,
                    SetHDCPStateCallback callback) override;
  void SetColorTemperatureAdjustment(
      int64_t display_id,
      const ColorTemperatureAdjustment& cta) override;
  void SetColorCalibration(int64_t display_id,
                           const ColorCalibration& calibration) override;
  void SetGammaAdjustment(int64_t display_id,
                          const GammaAdjustment& gamma) override;
  void SetPrivacyScreen(int64_t display_id,
                        bool enabled,
                        SetPrivacyScreenCallback callback) override;
  void GetSeamlessRefreshRates(
      int64_t display_id,
      GetSeamlessRefreshRatesCallback callback) const override;

  void AddObserver(NativeDisplayObserver* observer) override;
  void RemoveObserver(NativeDisplayObserver* observer) override;
  FakeDisplayController* GetFakeDisplayController() override;

 private:
  bool Configure(
      const display::DisplayConfigurationParams& display_config_params);

  void DoSetHDCPState(int64_t display_id,
                      HDCPState state,
                      ContentProtectionMethod protection_method,
                      SetHDCPStateCallback callback);

  bool IsConfigurationWithinSystemBandwidth(
      const std::vector<display::DisplayConfigurationParams>& config_requests);
  void SaveCurrentConfigSystemBandwidth(
      const std::vector<display::DisplayConfigurationParams>& config_requests);

  // Outputs to be returned by GetDisplays().
  std::vector<std::unique_ptr<DisplaySnapshot>> outputs_;
  // Outputs which are scheduled for deletion after the next invalidation.
  std::vector<std::unique_ptr<DisplaySnapshot>> cached_outputs_;

  // |max_configurable_pixels_| represents the maximum number of pixels that
  // Configure will support.  Tests can use this to force Configure
  // to fail if attempting to set a resolution that is higher than what
  // a device might support under a given circumstance.
  // A value of 0 means that no limit is enforced and Configure will
  // return success regardless of the resolution.
  int max_configurable_pixels_;

  int system_bandwidth_limit_ = 0;
  base::flat_map<int64_t, int> display_id_to_used_system_bw_;

  bool get_hdcp_expectation_;
  bool set_hdcp_expectation_;

  // Result value of GetHDCPState().
  HDCPState hdcp_state_;
  ContentProtectionMethod content_protection_method_;

  // If true, the callbacks are posted on the message loop.
  bool run_async_;

  raw_ptr<ActionLogger, DanglingUntriaged> log_;  // Not owned.

  base::ObserverList<NativeDisplayObserver>::Unchecked observers_;
};

}  // namespace test

}  // namespace display

#endif  // UI_DISPLAY_MANAGER_TEST_TEST_NATIVE_DISPLAY_DELEGATE_H_