1 // Copyright 2014 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.
5 #include "ui/display/chromeos/test/test_native_display_delegate.h"
8 #include "base/message_loop/message_loop.h"
9 #include "ui/display/chromeos/test/action_logger.h"
10 #include "ui/display/types/display_mode.h"
15 TestNativeDisplayDelegate::TestNativeDisplayDelegate(ActionLogger
* log
)
16 : max_configurable_pixels_(0),
17 get_hdcp_expectation_(true),
18 set_hdcp_expectation_(true),
19 hdcp_state_(HDCP_STATE_UNDESIRED
),
24 TestNativeDisplayDelegate::~TestNativeDisplayDelegate() {
27 void TestNativeDisplayDelegate::Initialize() {
28 log_
->AppendAction(kInitXRandR
);
31 void TestNativeDisplayDelegate::GrabServer() {
32 log_
->AppendAction(kGrab
);
35 void TestNativeDisplayDelegate::UngrabServer() {
36 log_
->AppendAction(kUngrab
);
39 void TestNativeDisplayDelegate::TakeDisplayControl(
40 const DisplayControlCallback
& callback
) {
41 log_
->AppendAction(kTakeDisplayControl
);
45 void TestNativeDisplayDelegate::RelinquishDisplayControl(
46 const DisplayControlCallback
& callback
) {
47 log_
->AppendAction(kRelinquishDisplayControl
);
51 void TestNativeDisplayDelegate::SyncWithServer() {
52 log_
->AppendAction(kSync
);
55 void TestNativeDisplayDelegate::SetBackgroundColor(uint32_t color_argb
) {
56 log_
->AppendAction(GetBackgroundAction(color_argb
));
59 void TestNativeDisplayDelegate::ForceDPMSOn() {
60 log_
->AppendAction(kForceDPMS
);
63 void TestNativeDisplayDelegate::GetDisplays(
64 const GetDisplaysCallback
& callback
) {
66 base::MessageLoop::current()->PostTask(FROM_HERE
,
67 base::Bind(callback
, outputs_
));
69 callback
.Run(outputs_
);
73 void TestNativeDisplayDelegate::AddMode(const DisplaySnapshot
& output
,
74 const DisplayMode
* mode
) {
75 log_
->AppendAction(GetAddOutputModeAction(output
, mode
));
78 bool TestNativeDisplayDelegate::Configure(const DisplaySnapshot
& output
,
79 const DisplayMode
* mode
,
80 const gfx::Point
& origin
) {
81 log_
->AppendAction(GetCrtcAction(output
, mode
, origin
));
83 if (max_configurable_pixels_
== 0)
89 return mode
->size().GetArea() <= max_configurable_pixels_
;
92 void TestNativeDisplayDelegate::Configure(const DisplaySnapshot
& output
,
93 const DisplayMode
* mode
,
94 const gfx::Point
& origin
,
95 const ConfigureCallback
& callback
) {
96 bool result
= Configure(output
, mode
, origin
);
98 base::MessageLoop::current()->PostTask(FROM_HERE
,
99 base::Bind(callback
, result
));
101 callback
.Run(result
);
105 void TestNativeDisplayDelegate::CreateFrameBuffer(const gfx::Size
& size
) {
107 GetFramebufferAction(size
, outputs_
.size() >= 1 ? outputs_
[0] : NULL
,
108 outputs_
.size() >= 2 ? outputs_
[1] : NULL
));
111 void TestNativeDisplayDelegate::GetHDCPState(
112 const DisplaySnapshot
& output
,
113 const GetHDCPStateCallback
& callback
) {
114 callback
.Run(get_hdcp_expectation_
, hdcp_state_
);
117 void TestNativeDisplayDelegate::SetHDCPState(
118 const DisplaySnapshot
& output
,
120 const SetHDCPStateCallback
& callback
) {
121 log_
->AppendAction(GetSetHDCPStateAction(output
, state
));
122 callback
.Run(set_hdcp_expectation_
);
125 std::vector
<ui::ColorCalibrationProfile
>
126 TestNativeDisplayDelegate::GetAvailableColorCalibrationProfiles(
127 const DisplaySnapshot
& output
) {
128 return std::vector
<ui::ColorCalibrationProfile
>();
131 bool TestNativeDisplayDelegate::SetColorCalibrationProfile(
132 const DisplaySnapshot
& output
,
133 ui::ColorCalibrationProfile new_profile
) {
137 bool TestNativeDisplayDelegate::SetGammaRamp(
138 const ui::DisplaySnapshot
& output
,
139 const std::vector
<GammaRampRGBEntry
>& lut
) {
140 log_
->AppendAction(SetGammaRampAction(output
, lut
));
144 void TestNativeDisplayDelegate::AddObserver(NativeDisplayObserver
* observer
) {
147 void TestNativeDisplayDelegate::RemoveObserver(
148 NativeDisplayObserver
* observer
) {