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 hdcp_state_(HDCP_STATE_UNDESIRED
),
22 TestNativeDisplayDelegate::~TestNativeDisplayDelegate() {
25 void TestNativeDisplayDelegate::Initialize() {
26 log_
->AppendAction(kInitXRandR
);
29 void TestNativeDisplayDelegate::GrabServer() {
30 log_
->AppendAction(kGrab
);
33 void TestNativeDisplayDelegate::UngrabServer() {
34 log_
->AppendAction(kUngrab
);
37 bool TestNativeDisplayDelegate::TakeDisplayControl() {
38 log_
->AppendAction(kTakeDisplayControl
);
42 bool TestNativeDisplayDelegate::RelinquishDisplayControl() {
43 log_
->AppendAction(kRelinquishDisplayControl
);
47 void TestNativeDisplayDelegate::SyncWithServer() {
48 log_
->AppendAction(kSync
);
51 void TestNativeDisplayDelegate::SetBackgroundColor(uint32_t color_argb
) {
52 log_
->AppendAction(GetBackgroundAction(color_argb
));
55 void TestNativeDisplayDelegate::ForceDPMSOn() {
56 log_
->AppendAction(kForceDPMS
);
59 void TestNativeDisplayDelegate::GetDisplays(
60 const GetDisplaysCallback
& callback
) {
62 base::MessageLoop::current()->PostTask(FROM_HERE
,
63 base::Bind(callback
, outputs_
));
65 callback
.Run(outputs_
);
69 void TestNativeDisplayDelegate::AddMode(const DisplaySnapshot
& output
,
70 const DisplayMode
* mode
) {
71 log_
->AppendAction(GetAddOutputModeAction(output
, mode
));
74 bool TestNativeDisplayDelegate::Configure(const DisplaySnapshot
& output
,
75 const DisplayMode
* mode
,
76 const gfx::Point
& origin
) {
77 log_
->AppendAction(GetCrtcAction(output
, mode
, origin
));
79 if (max_configurable_pixels_
== 0)
85 return mode
->size().GetArea() <= max_configurable_pixels_
;
88 void TestNativeDisplayDelegate::Configure(const DisplaySnapshot
& output
,
89 const DisplayMode
* mode
,
90 const gfx::Point
& origin
,
91 const ConfigureCallback
& callback
) {
92 bool result
= Configure(output
, mode
, origin
);
94 base::MessageLoop::current()->PostTask(FROM_HERE
,
95 base::Bind(callback
, result
));
101 void TestNativeDisplayDelegate::CreateFrameBuffer(const gfx::Size
& size
) {
103 GetFramebufferAction(size
, outputs_
.size() >= 1 ? outputs_
[0] : NULL
,
104 outputs_
.size() >= 2 ? outputs_
[1] : NULL
));
107 bool TestNativeDisplayDelegate::GetHDCPState(const DisplaySnapshot
& output
,
109 *state
= hdcp_state_
;
113 bool TestNativeDisplayDelegate::SetHDCPState(const DisplaySnapshot
& output
,
115 log_
->AppendAction(GetSetHDCPStateAction(output
, state
));
119 std::vector
<ui::ColorCalibrationProfile
>
120 TestNativeDisplayDelegate::GetAvailableColorCalibrationProfiles(
121 const DisplaySnapshot
& output
) {
122 return std::vector
<ui::ColorCalibrationProfile
>();
125 bool TestNativeDisplayDelegate::SetColorCalibrationProfile(
126 const DisplaySnapshot
& output
,
127 ui::ColorCalibrationProfile new_profile
) {
131 void TestNativeDisplayDelegate::AddObserver(NativeDisplayObserver
* observer
) {
134 void TestNativeDisplayDelegate::RemoveObserver(
135 NativeDisplayObserver
* observer
) {