Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / ui / display / chromeos / test / test_native_display_delegate.cc
blobf1b0101f0b2ef4868623966485d087992e6e6016
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"
7 #include "base/bind.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"
12 namespace ui {
13 namespace test {
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),
20 run_async_(false),
21 log_(log) {
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);
41 return true;
44 bool TestNativeDisplayDelegate::RelinquishDisplayControl() {
45 log_->AppendAction(kRelinquishDisplayControl);
46 return true;
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) {
63 if (run_async_) {
64 base::MessageLoop::current()->PostTask(FROM_HERE,
65 base::Bind(callback, outputs_));
66 } else {
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)
82 return true;
84 if (!mode)
85 return false;
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);
95 if (run_async_) {
96 base::MessageLoop::current()->PostTask(FROM_HERE,
97 base::Bind(callback, result));
98 } else {
99 callback.Run(result);
103 void TestNativeDisplayDelegate::CreateFrameBuffer(const gfx::Size& size) {
104 log_->AppendAction(
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,
117 HDCPState state,
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) {
132 return false;
135 void TestNativeDisplayDelegate::AddObserver(NativeDisplayObserver* observer) {
138 void TestNativeDisplayDelegate::RemoveObserver(
139 NativeDisplayObserver* observer) {
142 } // namespace test
143 } // namespace ui