Correctly track texture cleared state for sharing
[chromium-blink-merge.git] / ui / display / chromeos / test / test_native_display_delegate.cc
blob0da2e1190f1ab0c6853dfb7aee1e81190924073d
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 hdcp_state_(HDCP_STATE_UNDESIRED),
18 run_async_(false),
19 log_(log) {
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);
39 return true;
42 bool TestNativeDisplayDelegate::RelinquishDisplayControl() {
43 log_->AppendAction(kRelinquishDisplayControl);
44 return true;
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) {
61 if (run_async_) {
62 base::MessageLoop::current()->PostTask(FROM_HERE,
63 base::Bind(callback, outputs_));
64 } else {
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)
80 return true;
82 if (!mode)
83 return false;
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);
93 if (run_async_) {
94 base::MessageLoop::current()->PostTask(FROM_HERE,
95 base::Bind(callback, result));
96 } else {
97 callback.Run(result);
101 void TestNativeDisplayDelegate::CreateFrameBuffer(const gfx::Size& size) {
102 log_->AppendAction(
103 GetFramebufferAction(size, outputs_.size() >= 1 ? outputs_[0] : NULL,
104 outputs_.size() >= 2 ? outputs_[1] : NULL));
107 bool TestNativeDisplayDelegate::GetHDCPState(const DisplaySnapshot& output,
108 HDCPState* state) {
109 *state = hdcp_state_;
110 return true;
113 bool TestNativeDisplayDelegate::SetHDCPState(const DisplaySnapshot& output,
114 HDCPState state) {
115 log_->AppendAction(GetSetHDCPStateAction(output, state));
116 return true;
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) {
128 return false;
131 void TestNativeDisplayDelegate::AddObserver(NativeDisplayObserver* observer) {
134 void TestNativeDisplayDelegate::RemoveObserver(
135 NativeDisplayObserver* observer) {
138 } // namespace test
139 } // namespace ui