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 bool TestNativeDisplayDelegate::TakeDisplayControl() {
40 log_
->AppendAction(kTakeDisplayControl
);
44 bool TestNativeDisplayDelegate::RelinquishDisplayControl() {
45 log_
->AppendAction(kRelinquishDisplayControl
);
49 void TestNativeDisplayDelegate::SyncWithServer() {
50 log_
->AppendAction(kSync
);
53 void TestNativeDisplayDelegate::SetBackgroundColor(uint32_t color_argb
) {
54 log_
->AppendAction(GetBackgroundAction(color_argb
));
57 void TestNativeDisplayDelegate::ForceDPMSOn() {
58 log_
->AppendAction(kForceDPMS
);
61 void TestNativeDisplayDelegate::GetDisplays(
62 const GetDisplaysCallback
& callback
) {
64 base::MessageLoop::current()->PostTask(FROM_HERE
,
65 base::Bind(callback
, outputs_
));
67 callback
.Run(outputs_
);
71 void TestNativeDisplayDelegate::AddMode(const DisplaySnapshot
& output
,
72 const DisplayMode
* mode
) {
73 log_
->AppendAction(GetAddOutputModeAction(output
, mode
));
76 bool TestNativeDisplayDelegate::Configure(const DisplaySnapshot
& output
,
77 const DisplayMode
* mode
,
78 const gfx::Point
& origin
) {
79 log_
->AppendAction(GetCrtcAction(output
, mode
, origin
));
81 if (max_configurable_pixels_
== 0)
87 return mode
->size().GetArea() <= max_configurable_pixels_
;
90 void TestNativeDisplayDelegate::Configure(const DisplaySnapshot
& output
,
91 const DisplayMode
* mode
,
92 const gfx::Point
& origin
,
93 const ConfigureCallback
& callback
) {
94 bool result
= Configure(output
, mode
, origin
);
96 base::MessageLoop::current()->PostTask(FROM_HERE
,
97 base::Bind(callback
, result
));
103 void TestNativeDisplayDelegate::CreateFrameBuffer(const gfx::Size
& size
) {
105 GetFramebufferAction(size
, outputs_
.size() >= 1 ? outputs_
[0] : NULL
,
106 outputs_
.size() >= 2 ? outputs_
[1] : NULL
));
109 void TestNativeDisplayDelegate::GetHDCPState(
110 const DisplaySnapshot
& output
,
111 const GetHDCPStateCallback
& callback
) {
112 callback
.Run(get_hdcp_expectation_
, hdcp_state_
);
115 void TestNativeDisplayDelegate::SetHDCPState(
116 const DisplaySnapshot
& output
,
118 const SetHDCPStateCallback
& callback
) {
119 log_
->AppendAction(GetSetHDCPStateAction(output
, state
));
120 callback
.Run(set_hdcp_expectation_
);
123 std::vector
<ui::ColorCalibrationProfile
>
124 TestNativeDisplayDelegate::GetAvailableColorCalibrationProfiles(
125 const DisplaySnapshot
& output
) {
126 return std::vector
<ui::ColorCalibrationProfile
>();
129 bool TestNativeDisplayDelegate::SetColorCalibrationProfile(
130 const DisplaySnapshot
& output
,
131 ui::ColorCalibrationProfile new_profile
) {
135 void TestNativeDisplayDelegate::AddObserver(NativeDisplayObserver
* observer
) {
138 void TestNativeDisplayDelegate::RemoveObserver(
139 NativeDisplayObserver
* observer
) {