| OLD | NEW | 
 | (Empty) | 
|    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. |  | 
|    4  |  | 
|    5 #include "ui/display/chromeos/test/test_native_display_delegate.h" |  | 
|    6  |  | 
|    7 #include "base/bind.h" |  | 
|    8 #include "base/location.h" |  | 
|    9 #include "base/single_thread_task_runner.h" |  | 
|   10 #include "base/threading/thread_task_runner_handle.h" |  | 
|   11 #include "ui/display/chromeos/test/action_logger.h" |  | 
|   12 #include "ui/display/types/display_mode.h" |  | 
|   13  |  | 
|   14 namespace ui { |  | 
|   15 namespace test { |  | 
|   16  |  | 
|   17 TestNativeDisplayDelegate::TestNativeDisplayDelegate(ActionLogger* log) |  | 
|   18     : max_configurable_pixels_(0), |  | 
|   19       get_hdcp_expectation_(true), |  | 
|   20       set_hdcp_expectation_(true), |  | 
|   21       hdcp_state_(HDCP_STATE_UNDESIRED), |  | 
|   22       run_async_(false), |  | 
|   23       log_(log) { |  | 
|   24 } |  | 
|   25  |  | 
|   26 TestNativeDisplayDelegate::~TestNativeDisplayDelegate() { |  | 
|   27 } |  | 
|   28  |  | 
|   29 void TestNativeDisplayDelegate::Initialize() { |  | 
|   30   log_->AppendAction(kInitXRandR); |  | 
|   31 } |  | 
|   32  |  | 
|   33 void TestNativeDisplayDelegate::GrabServer() { |  | 
|   34   log_->AppendAction(kGrab); |  | 
|   35 } |  | 
|   36  |  | 
|   37 void TestNativeDisplayDelegate::UngrabServer() { |  | 
|   38   log_->AppendAction(kUngrab); |  | 
|   39 } |  | 
|   40  |  | 
|   41 void TestNativeDisplayDelegate::TakeDisplayControl( |  | 
|   42     const DisplayControlCallback& callback) { |  | 
|   43   log_->AppendAction(kTakeDisplayControl); |  | 
|   44   callback.Run(true); |  | 
|   45 } |  | 
|   46  |  | 
|   47 void TestNativeDisplayDelegate::RelinquishDisplayControl( |  | 
|   48     const DisplayControlCallback& callback) { |  | 
|   49   log_->AppendAction(kRelinquishDisplayControl); |  | 
|   50   callback.Run(true); |  | 
|   51 } |  | 
|   52  |  | 
|   53 void TestNativeDisplayDelegate::SyncWithServer() { |  | 
|   54   log_->AppendAction(kSync); |  | 
|   55 } |  | 
|   56  |  | 
|   57 void TestNativeDisplayDelegate::SetBackgroundColor(uint32_t color_argb) { |  | 
|   58   log_->AppendAction(GetBackgroundAction(color_argb)); |  | 
|   59 } |  | 
|   60  |  | 
|   61 void TestNativeDisplayDelegate::ForceDPMSOn() { |  | 
|   62   log_->AppendAction(kForceDPMS); |  | 
|   63 } |  | 
|   64  |  | 
|   65 void TestNativeDisplayDelegate::GetDisplays( |  | 
|   66     const GetDisplaysCallback& callback) { |  | 
|   67   if (run_async_) { |  | 
|   68     base::ThreadTaskRunnerHandle::Get()->PostTask( |  | 
|   69         FROM_HERE, base::Bind(callback, outputs_)); |  | 
|   70   } else { |  | 
|   71     callback.Run(outputs_); |  | 
|   72   } |  | 
|   73 } |  | 
|   74  |  | 
|   75 void TestNativeDisplayDelegate::AddMode(const DisplaySnapshot& output, |  | 
|   76                                         const DisplayMode* mode) { |  | 
|   77   log_->AppendAction(GetAddOutputModeAction(output, mode)); |  | 
|   78 } |  | 
|   79  |  | 
|   80 bool TestNativeDisplayDelegate::Configure(const DisplaySnapshot& output, |  | 
|   81                                           const DisplayMode* mode, |  | 
|   82                                           const gfx::Point& origin) { |  | 
|   83   log_->AppendAction(GetCrtcAction(output, mode, origin)); |  | 
|   84  |  | 
|   85   if (max_configurable_pixels_ == 0) |  | 
|   86     return true; |  | 
|   87  |  | 
|   88   if (!mode) |  | 
|   89     return false; |  | 
|   90  |  | 
|   91   return mode->size().GetArea() <= max_configurable_pixels_; |  | 
|   92 } |  | 
|   93  |  | 
|   94 void TestNativeDisplayDelegate::Configure(const DisplaySnapshot& output, |  | 
|   95                                           const DisplayMode* mode, |  | 
|   96                                           const gfx::Point& origin, |  | 
|   97                                           const ConfigureCallback& callback) { |  | 
|   98   bool result = Configure(output, mode, origin); |  | 
|   99   if (run_async_) { |  | 
|  100     base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |  | 
|  101                                                   base::Bind(callback, result)); |  | 
|  102   } else { |  | 
|  103     callback.Run(result); |  | 
|  104   } |  | 
|  105 } |  | 
|  106  |  | 
|  107 void TestNativeDisplayDelegate::CreateFrameBuffer(const gfx::Size& size) { |  | 
|  108   log_->AppendAction( |  | 
|  109       GetFramebufferAction(size, outputs_.size() >= 1 ? outputs_[0] : nullptr, |  | 
|  110                            outputs_.size() >= 2 ? outputs_[1] : nullptr)); |  | 
|  111 } |  | 
|  112  |  | 
|  113 void TestNativeDisplayDelegate::GetHDCPState( |  | 
|  114     const DisplaySnapshot& output, |  | 
|  115     const GetHDCPStateCallback& callback) { |  | 
|  116   callback.Run(get_hdcp_expectation_, hdcp_state_); |  | 
|  117 } |  | 
|  118  |  | 
|  119 void TestNativeDisplayDelegate::SetHDCPState( |  | 
|  120     const DisplaySnapshot& output, |  | 
|  121     HDCPState state, |  | 
|  122     const SetHDCPStateCallback& callback) { |  | 
|  123   log_->AppendAction(GetSetHDCPStateAction(output, state)); |  | 
|  124   callback.Run(set_hdcp_expectation_); |  | 
|  125 } |  | 
|  126  |  | 
|  127 std::vector<ui::ColorCalibrationProfile> |  | 
|  128 TestNativeDisplayDelegate::GetAvailableColorCalibrationProfiles( |  | 
|  129     const DisplaySnapshot& output) { |  | 
|  130   return std::vector<ui::ColorCalibrationProfile>(); |  | 
|  131 } |  | 
|  132  |  | 
|  133 bool TestNativeDisplayDelegate::SetColorCalibrationProfile( |  | 
|  134     const DisplaySnapshot& output, |  | 
|  135     ui::ColorCalibrationProfile new_profile) { |  | 
|  136   return false; |  | 
|  137 } |  | 
|  138  |  | 
|  139 bool TestNativeDisplayDelegate::SetColorCorrection( |  | 
|  140     const ui::DisplaySnapshot& output, |  | 
|  141     const std::vector<GammaRampRGBEntry>& degamma_lut, |  | 
|  142     const std::vector<GammaRampRGBEntry>& gamma_lut, |  | 
|  143     const std::vector<float>& correction_matrix) { |  | 
|  144   log_->AppendAction(SetColorCorrectionAction(output, degamma_lut, gamma_lut, |  | 
|  145                                               correction_matrix)); |  | 
|  146   return true; |  | 
|  147 } |  | 
|  148  |  | 
|  149 void TestNativeDisplayDelegate::AddObserver(NativeDisplayObserver* observer) { |  | 
|  150 } |  | 
|  151  |  | 
|  152 void TestNativeDisplayDelegate::RemoveObserver( |  | 
|  153     NativeDisplayObserver* observer) { |  | 
|  154 } |  | 
|  155  |  | 
|  156 display::FakeDisplayController* |  | 
|  157 TestNativeDisplayDelegate::GetFakeDisplayController() { |  | 
|  158   return nullptr; |  | 
|  159 } |  | 
|  160  |  | 
|  161 }  // namespace test |  | 
|  162 }  // namespace ui |  | 
| OLD | NEW |