| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chromeos/display/output_configurator.h" | 5 #include "ui/display/chromeos/output_configurator.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <cstdarg> | 8 #include <cstdarg> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 17 #include "chromeos/display/native_display_delegate.h" | |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 #include "ui/display/chromeos/native_display_delegate.h" |
| 19 | 19 |
| 20 namespace chromeos { | 20 namespace ui { |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 // Strings returned by TestNativeDisplayDelegate::GetActionsAndClear() to | 24 // Strings returned by TestNativeDisplayDelegate::GetActionsAndClear() to |
| 25 // describe various actions that were performed. | 25 // describe various actions that were performed. |
| 26 const char kInitXRandR[] = "init"; | 26 const char kInitXRandR[] = "init"; |
| 27 const char kGrab[] = "grab"; | 27 const char kGrab[] = "grab"; |
| 28 const char kUngrab[] = "ungrab"; | 28 const char kUngrab[] = "ungrab"; |
| 29 const char kSync[] = "sync"; | 29 const char kSync[] = "sync"; |
| 30 const char kForceDPMS[] = "dpms"; | 30 const char kForceDPMS[] = "dpms"; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 45 return base::StringPrintf("add_mode(output=%lu,mode=%lu)", output, mode); | 45 return base::StringPrintf("add_mode(output=%lu,mode=%lu)", output, mode); |
| 46 } | 46 } |
| 47 | 47 |
| 48 // Returns a string describing a TestNativeDisplayDelegate::Configure() | 48 // Returns a string describing a TestNativeDisplayDelegate::Configure() |
| 49 // call. | 49 // call. |
| 50 std::string GetCrtcAction(RRCrtc crtc, | 50 std::string GetCrtcAction(RRCrtc crtc, |
| 51 int x, | 51 int x, |
| 52 int y, | 52 int y, |
| 53 RRMode mode, | 53 RRMode mode, |
| 54 RROutput output) { | 54 RROutput output) { |
| 55 return base::StringPrintf("crtc(crtc=%lu,x=%d,y=%d,mode=%lu,output=%lu)", | 55 return base::StringPrintf( |
| 56 crtc, x, y, mode, output); | 56 "crtc(crtc=%lu,x=%d,y=%d,mode=%lu,output=%lu)", crtc, x, y, mode, output); |
| 57 } | 57 } |
| 58 | 58 |
| 59 // Returns a string describing a TestNativeDisplayDelegate::CreateFramebuffer() | 59 // Returns a string describing a TestNativeDisplayDelegate::CreateFramebuffer() |
| 60 // call. | 60 // call. |
| 61 std::string GetFramebufferAction(int width, | 61 std::string GetFramebufferAction(int width, |
| 62 int height, | 62 int height, |
| 63 RRCrtc crtc1, | 63 RRCrtc crtc1, |
| 64 RRCrtc crtc2) { | 64 RRCrtc crtc2) { |
| 65 return base::StringPrintf( | 65 return base::StringPrintf( |
| 66 "framebuffer(width=%d,height=%d,crtc1=%lu,crtc2=%lu)", | 66 "framebuffer(width=%d,height=%d,crtc1=%lu,crtc2=%lu)", |
| 67 width, height, crtc1, crtc2); | 67 width, |
| 68 height, |
| 69 crtc1, |
| 70 crtc2); |
| 68 } | 71 } |
| 69 | 72 |
| 70 // Returns a string describing a TestNativeDisplayDelegate::ConfigureCTM() call. | 73 // Returns a string describing a TestNativeDisplayDelegate::ConfigureCTM() call. |
| 71 std::string GetCTMAction( | 74 std::string GetCTMAction( |
| 72 int device_id, | 75 int device_id, |
| 73 const OutputConfigurator::CoordinateTransformation& ctm) { | 76 const OutputConfigurator::CoordinateTransformation& ctm) { |
| 74 return base::StringPrintf("ctm(id=%d,transform=(%f,%f,%f,%f))", device_id, | 77 return base::StringPrintf("ctm(id=%d,transform=(%f,%f,%f,%f))", |
| 75 ctm.x_scale, ctm.x_offset, ctm.y_scale, ctm.y_offset); | 78 device_id, |
| 79 ctm.x_scale, |
| 80 ctm.x_offset, |
| 81 ctm.y_scale, |
| 82 ctm.y_offset); |
| 76 } | 83 } |
| 77 | 84 |
| 78 // Returns a string describing a TestNativeDisplayDelegate::SetHDCPState() call. | 85 // Returns a string describing a TestNativeDisplayDelegate::SetHDCPState() call. |
| 79 std::string GetSetHDCPStateAction(RROutput id, ui::HDCPState state) { | 86 std::string GetSetHDCPStateAction(RROutput id, HDCPState state) { |
| 80 return base::StringPrintf("set_hdcp(id=%lu,state=%d)", id, state); | 87 return base::StringPrintf("set_hdcp(id=%lu,state=%d)", id, state); |
| 81 } | 88 } |
| 82 | 89 |
| 83 // Joins a sequence of strings describing actions (e.g. kScreenDim) such | 90 // Joins a sequence of strings describing actions (e.g. kScreenDim) such |
| 84 // that they can be compared against a string returned by | 91 // that they can be compared against a string returned by |
| 85 // ActionLogger::GetActionsAndClear(). The list of actions must be | 92 // ActionLogger::GetActionsAndClear(). The list of actions must be |
| 86 // terminated by a NULL pointer. | 93 // terminated by a NULL pointer. |
| 87 std::string JoinActions(const char* action, ...) { | 94 std::string JoinActions(const char* action, ...) { |
| 88 std::string actions; | 95 std::string actions; |
| 89 | 96 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 std::map<int, OutputConfigurator::CoordinateTransformation> ctms_; | 159 std::map<int, OutputConfigurator::CoordinateTransformation> ctms_; |
| 153 | 160 |
| 154 DISALLOW_COPY_AND_ASSIGN(TestTouchscreenDelegate); | 161 DISALLOW_COPY_AND_ASSIGN(TestTouchscreenDelegate); |
| 155 }; | 162 }; |
| 156 | 163 |
| 157 class TestNativeDisplayDelegate : public NativeDisplayDelegate { | 164 class TestNativeDisplayDelegate : public NativeDisplayDelegate { |
| 158 public: | 165 public: |
| 159 // Ownership of |log| remains with the caller. | 166 // Ownership of |log| remains with the caller. |
| 160 explicit TestNativeDisplayDelegate(ActionLogger* log) | 167 explicit TestNativeDisplayDelegate(ActionLogger* log) |
| 161 : max_configurable_pixels_(0), | 168 : max_configurable_pixels_(0), |
| 162 hdcp_state_(ui::HDCP_STATE_UNDESIRED), | 169 hdcp_state_(HDCP_STATE_UNDESIRED), |
| 163 log_(log) {} | 170 log_(log) {} |
| 164 virtual ~TestNativeDisplayDelegate() {} | 171 virtual ~TestNativeDisplayDelegate() {} |
| 165 | 172 |
| 166 const std::vector<OutputConfigurator::OutputSnapshot>& outputs() const { | 173 const std::vector<OutputConfigurator::OutputSnapshot>& outputs() const { |
| 167 return outputs_; | 174 return outputs_; |
| 168 } | 175 } |
| 169 void set_outputs( | 176 void set_outputs( |
| 170 const std::vector<OutputConfigurator::OutputSnapshot>& outputs) { | 177 const std::vector<OutputConfigurator::OutputSnapshot>& outputs) { |
| 171 outputs_ = outputs; | 178 outputs_ = outputs; |
| 172 } | 179 } |
| 173 | 180 |
| 174 void set_max_configurable_pixels(int pixels) { | 181 void set_max_configurable_pixels(int pixels) { |
| 175 max_configurable_pixels_ = pixels; | 182 max_configurable_pixels_ = pixels; |
| 176 } | 183 } |
| 177 | 184 |
| 178 void set_hdcp_state(ui::HDCPState state) { hdcp_state_ = state; } | 185 void set_hdcp_state(HDCPState state) { hdcp_state_ = state; } |
| 179 | 186 |
| 180 // OutputConfigurator::Delegate overrides: | 187 // OutputConfigurator::Delegate overrides: |
| 181 virtual void Initialize() OVERRIDE { | 188 virtual void Initialize() OVERRIDE { log_->AppendAction(kInitXRandR); } |
| 182 log_->AppendAction(kInitXRandR); | |
| 183 } | |
| 184 virtual void GrabServer() OVERRIDE { log_->AppendAction(kGrab); } | 189 virtual void GrabServer() OVERRIDE { log_->AppendAction(kGrab); } |
| 185 virtual void UngrabServer() OVERRIDE { log_->AppendAction(kUngrab); } | 190 virtual void UngrabServer() OVERRIDE { log_->AppendAction(kUngrab); } |
| 186 virtual void SyncWithServer() OVERRIDE { log_->AppendAction(kSync); } | 191 virtual void SyncWithServer() OVERRIDE { log_->AppendAction(kSync); } |
| 187 virtual void SetBackgroundColor(uint32 color_argb) OVERRIDE { | 192 virtual void SetBackgroundColor(uint32 color_argb) OVERRIDE { |
| 188 log_->AppendAction(GetBackgroundAction(color_argb)); | 193 log_->AppendAction(GetBackgroundAction(color_argb)); |
| 189 } | 194 } |
| 190 virtual void ForceDPMSOn() OVERRIDE { log_->AppendAction(kForceDPMS); } | 195 virtual void ForceDPMSOn() OVERRIDE { log_->AppendAction(kForceDPMS); } |
| 191 virtual std::vector<OutputConfigurator::OutputSnapshot> GetOutputs() | 196 virtual std::vector<OutputConfigurator::OutputSnapshot> GetOutputs() |
| 192 OVERRIDE { | 197 OVERRIDE { |
| 193 return outputs_; | 198 return outputs_; |
| 194 } | 199 } |
| 195 virtual void AddMode(const OutputConfigurator::OutputSnapshot& output, | 200 virtual void AddMode(const OutputConfigurator::OutputSnapshot& output, |
| 196 RRMode mode) OVERRIDE { | 201 RRMode mode) OVERRIDE { |
| 197 log_->AppendAction(GetAddOutputModeAction(output.output, mode)); | 202 log_->AppendAction(GetAddOutputModeAction(output.output, mode)); |
| 198 } | 203 } |
| 199 virtual bool Configure(const OutputConfigurator::OutputSnapshot& output, | 204 virtual bool Configure(const OutputConfigurator::OutputSnapshot& output, |
| 200 RRMode mode, | 205 RRMode mode, |
| 201 int x, | 206 int x, |
| 202 int y) OVERRIDE { | 207 int y) OVERRIDE { |
| 203 log_->AppendAction(GetCrtcAction(output.crtc, x, y, mode, output.output)); | 208 log_->AppendAction(GetCrtcAction(output.crtc, x, y, mode, output.output)); |
| 204 | 209 |
| 205 if (max_configurable_pixels_ == 0) | 210 if (max_configurable_pixels_ == 0) |
| 206 return true; | 211 return true; |
| 207 | 212 |
| 208 OutputConfigurator::OutputSnapshot* snapshot = GetOutputFromId( | 213 OutputConfigurator::OutputSnapshot* snapshot = |
| 209 output.output); | 214 GetOutputFromId(output.output); |
| 210 if (!snapshot) | 215 if (!snapshot) |
| 211 return false; | 216 return false; |
| 212 | 217 |
| 213 const OutputConfigurator::ModeInfo* mode_info = | 218 const OutputConfigurator::ModeInfo* mode_info = |
| 214 OutputConfigurator::GetModeInfo(*snapshot, mode); | 219 OutputConfigurator::GetModeInfo(*snapshot, mode); |
| 215 if (!mode_info) | 220 if (!mode_info) |
| 216 return false; | 221 return false; |
| 217 | 222 |
| 218 return mode_info->width * mode_info->height <= max_configurable_pixels_; | 223 return mode_info->width * mode_info->height <= max_configurable_pixels_; |
| 219 | |
| 220 } | 224 } |
| 221 virtual void CreateFrameBuffer( | 225 virtual void CreateFrameBuffer( |
| 222 int width, | 226 int width, |
| 223 int height, | 227 int height, |
| 224 const std::vector<OutputConfigurator::OutputSnapshot>& outputs) OVERRIDE { | 228 const std::vector<OutputConfigurator::OutputSnapshot>& outputs) OVERRIDE { |
| 225 log_->AppendAction( | 229 log_->AppendAction( |
| 226 GetFramebufferAction(width, | 230 GetFramebufferAction(width, |
| 227 height, | 231 height, |
| 228 outputs.size() >= 1 ? outputs[0].crtc : 0, | 232 outputs.size() >= 1 ? outputs[0].crtc : 0, |
| 229 outputs.size() >= 2 ? outputs[1].crtc : 0)); | 233 outputs.size() >= 2 ? outputs[1].crtc : 0)); |
| 230 } | 234 } |
| 231 virtual bool GetHDCPState(const OutputConfigurator::OutputSnapshot& output, | 235 virtual bool GetHDCPState(const OutputConfigurator::OutputSnapshot& output, |
| 232 ui::HDCPState* state) OVERRIDE { | 236 HDCPState* state) OVERRIDE { |
| 233 *state = hdcp_state_; | 237 *state = hdcp_state_; |
| 234 return true; | 238 return true; |
| 235 } | 239 } |
| 236 | 240 |
| 237 virtual bool SetHDCPState(const OutputConfigurator::OutputSnapshot& output, | 241 virtual bool SetHDCPState(const OutputConfigurator::OutputSnapshot& output, |
| 238 ui::HDCPState state) OVERRIDE { | 242 HDCPState state) OVERRIDE { |
| 239 log_->AppendAction(GetSetHDCPStateAction(output.output, state)); | 243 log_->AppendAction(GetSetHDCPStateAction(output.output, state)); |
| 240 return true; | 244 return true; |
| 241 } | 245 } |
| 242 | 246 |
| 243 virtual void AddObserver(NativeDisplayObserver* observer) OVERRIDE {} | 247 virtual void AddObserver(NativeDisplayObserver* observer) OVERRIDE {} |
| 244 | 248 |
| 245 virtual void RemoveObserver(NativeDisplayObserver* observer) OVERRIDE {} | 249 virtual void RemoveObserver(NativeDisplayObserver* observer) OVERRIDE {} |
| 246 | 250 |
| 247 private: | 251 private: |
| 248 OutputConfigurator::OutputSnapshot* GetOutputFromId(RROutput output_id) { | 252 OutputConfigurator::OutputSnapshot* GetOutputFromId(RROutput output_id) { |
| 249 for (unsigned int i = 0; i < outputs_.size(); i++) { | 253 for (unsigned int i = 0; i < outputs_.size(); i++) { |
| 250 if (outputs_[i].output == output_id) | 254 if (outputs_[i].output == output_id) |
| 251 return &outputs_[i]; | 255 return &outputs_[i]; |
| 252 } | 256 } |
| 253 return NULL; | 257 return NULL; |
| 254 } | 258 } |
| 255 | 259 |
| 256 // Outputs to be returned by GetOutputs(). | 260 // Outputs to be returned by GetOutputs(). |
| 257 std::vector<OutputConfigurator::OutputSnapshot> outputs_; | 261 std::vector<OutputConfigurator::OutputSnapshot> outputs_; |
| 258 | 262 |
| 259 // |max_configurable_pixels_| represents the maximum number of pixels that | 263 // |max_configurable_pixels_| represents the maximum number of pixels that |
| 260 // Configure will support. Tests can use this to force Configure | 264 // Configure will support. Tests can use this to force Configure |
| 261 // to fail if attempting to set a resolution that is higher than what | 265 // to fail if attempting to set a resolution that is higher than what |
| 262 // a device might support under a given circumstance. | 266 // a device might support under a given circumstance. |
| 263 // A value of 0 means that no limit is enforced and Configure will | 267 // A value of 0 means that no limit is enforced and Configure will |
| 264 // return success regardless of the resolution. | 268 // return success regardless of the resolution. |
| 265 int max_configurable_pixels_; | 269 int max_configurable_pixels_; |
| 266 | 270 |
| 267 // Result value of GetHDCPState(). | 271 // Result value of GetHDCPState(). |
| 268 ui::HDCPState hdcp_state_; | 272 HDCPState hdcp_state_; |
| 269 | 273 |
| 270 ActionLogger* log_; // Not owned. | 274 ActionLogger* log_; // Not owned. |
| 271 | 275 |
| 272 DISALLOW_COPY_AND_ASSIGN(TestNativeDisplayDelegate); | 276 DISALLOW_COPY_AND_ASSIGN(TestNativeDisplayDelegate); |
| 273 }; | 277 }; |
| 274 | 278 |
| 275 class TestObserver : public OutputConfigurator::Observer { | 279 class TestObserver : public OutputConfigurator::Observer { |
| 276 public: | 280 public: |
| 277 explicit TestObserver(OutputConfigurator* configurator) | 281 explicit TestObserver(OutputConfigurator* configurator) |
| 278 : configurator_(configurator) { | 282 : configurator_(configurator) { |
| 279 Reset(); | 283 Reset(); |
| 280 configurator_->AddObserver(this); | 284 configurator_->AddObserver(this); |
| 281 } | 285 } |
| 282 virtual ~TestObserver() { | 286 virtual ~TestObserver() { configurator_->RemoveObserver(this); } |
| 283 configurator_->RemoveObserver(this); | |
| 284 } | |
| 285 | 287 |
| 286 int num_changes() const { return num_changes_; } | 288 int num_changes() const { return num_changes_; } |
| 287 int num_failures() const { return num_failures_; } | 289 int num_failures() const { return num_failures_; } |
| 288 const std::vector<OutputConfigurator::OutputSnapshot>& latest_outputs() | 290 const std::vector<OutputConfigurator::OutputSnapshot>& latest_outputs() |
| 289 const { | 291 const { |
| 290 return latest_outputs_; | 292 return latest_outputs_; |
| 291 } | 293 } |
| 292 ui::OutputState latest_failed_state() const { return latest_failed_state_; } | 294 OutputState latest_failed_state() const { return latest_failed_state_; } |
| 293 | 295 |
| 294 void Reset() { | 296 void Reset() { |
| 295 num_changes_ = 0; | 297 num_changes_ = 0; |
| 296 num_failures_ = 0; | 298 num_failures_ = 0; |
| 297 latest_outputs_.clear(); | 299 latest_outputs_.clear(); |
| 298 latest_failed_state_ = ui::OUTPUT_STATE_INVALID; | 300 latest_failed_state_ = OUTPUT_STATE_INVALID; |
| 299 } | 301 } |
| 300 | 302 |
| 301 // OutputConfigurator::Observer overrides: | 303 // OutputConfigurator::Observer overrides: |
| 302 virtual void OnDisplayModeChanged( | 304 virtual void OnDisplayModeChanged( |
| 303 const std::vector<OutputConfigurator::OutputSnapshot>& outputs) OVERRIDE { | 305 const std::vector<OutputConfigurator::OutputSnapshot>& outputs) OVERRIDE { |
| 304 num_changes_++; | 306 num_changes_++; |
| 305 latest_outputs_ = outputs; | 307 latest_outputs_ = outputs; |
| 306 } | 308 } |
| 307 | 309 |
| 308 virtual void OnDisplayModeChangeFailed(ui::OutputState failed_new_state) | 310 virtual void OnDisplayModeChangeFailed(OutputState failed_new_state) |
| 309 OVERRIDE { | 311 OVERRIDE { |
| 310 num_failures_++; | 312 num_failures_++; |
| 311 latest_failed_state_ = failed_new_state; | 313 latest_failed_state_ = failed_new_state; |
| 312 } | 314 } |
| 313 | 315 |
| 314 private: | 316 private: |
| 315 OutputConfigurator* configurator_; // Not owned. | 317 OutputConfigurator* configurator_; // Not owned. |
| 316 | 318 |
| 317 // Number of times that OnDisplayMode*() has been called. | 319 // Number of times that OnDisplayMode*() has been called. |
| 318 int num_changes_; | 320 int num_changes_; |
| 319 int num_failures_; | 321 int num_failures_; |
| 320 | 322 |
| 321 // Parameters most recently passed to OnDisplayMode*(). | 323 // Parameters most recently passed to OnDisplayMode*(). |
| 322 std::vector<OutputConfigurator::OutputSnapshot> latest_outputs_; | 324 std::vector<OutputConfigurator::OutputSnapshot> latest_outputs_; |
| 323 ui::OutputState latest_failed_state_; | 325 OutputState latest_failed_state_; |
| 324 | 326 |
| 325 DISALLOW_COPY_AND_ASSIGN(TestObserver); | 327 DISALLOW_COPY_AND_ASSIGN(TestObserver); |
| 326 }; | 328 }; |
| 327 | 329 |
| 328 class TestStateController : public OutputConfigurator::StateController { | 330 class TestStateController : public OutputConfigurator::StateController { |
| 329 public: | 331 public: |
| 330 TestStateController() : state_(ui::OUTPUT_STATE_DUAL_EXTENDED) {} | 332 TestStateController() : state_(OUTPUT_STATE_DUAL_EXTENDED) {} |
| 331 virtual ~TestStateController() {} | 333 virtual ~TestStateController() {} |
| 332 | 334 |
| 333 void set_state(ui::OutputState state) { state_ = state; } | 335 void set_state(OutputState state) { state_ = state; } |
| 334 | 336 |
| 335 // OutputConfigurator::StateController overrides: | 337 // OutputConfigurator::StateController overrides: |
| 336 virtual ui::OutputState GetStateForDisplayIds( | 338 virtual OutputState GetStateForDisplayIds( |
| 337 const std::vector<int64>& outputs) const OVERRIDE { | 339 const std::vector<int64>& outputs) const OVERRIDE { |
| 338 return state_; | 340 return state_; |
| 339 } | 341 } |
| 340 virtual bool GetResolutionForDisplayId( | 342 virtual bool GetResolutionForDisplayId(int64 display_id, |
| 341 int64 display_id, | 343 int* width, |
| 342 int *width, | 344 int* height) const OVERRIDE { |
| 343 int *height) const OVERRIDE { | |
| 344 return false; | 345 return false; |
| 345 } | 346 } |
| 346 | 347 |
| 347 private: | 348 private: |
| 348 ui::OutputState state_; | 349 OutputState state_; |
| 349 | 350 |
| 350 DISALLOW_COPY_AND_ASSIGN(TestStateController); | 351 DISALLOW_COPY_AND_ASSIGN(TestStateController); |
| 351 }; | 352 }; |
| 352 | 353 |
| 353 class TestMirroringController | 354 class TestMirroringController |
| 354 : public OutputConfigurator::SoftwareMirroringController { | 355 : public OutputConfigurator::SoftwareMirroringController { |
| 355 public: | 356 public: |
| 356 TestMirroringController() : software_mirroring_enabled_(false) {} | 357 TestMirroringController() : software_mirroring_enabled_(false) {} |
| 357 virtual ~TestMirroringController() {} | 358 virtual ~TestMirroringController() {} |
| 358 | 359 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 375 // Predefined modes that can be used by outputs. | 376 // Predefined modes that can be used by outputs. |
| 376 static const RRMode kSmallModeId; | 377 static const RRMode kSmallModeId; |
| 377 static const int kSmallModeWidth; | 378 static const int kSmallModeWidth; |
| 378 static const int kSmallModeHeight; | 379 static const int kSmallModeHeight; |
| 379 | 380 |
| 380 static const RRMode kBigModeId; | 381 static const RRMode kBigModeId; |
| 381 static const int kBigModeWidth; | 382 static const int kBigModeWidth; |
| 382 static const int kBigModeHeight; | 383 static const int kBigModeHeight; |
| 383 | 384 |
| 384 OutputConfiguratorTest() | 385 OutputConfiguratorTest() |
| 385 : observer_(&configurator_), | 386 : observer_(&configurator_), test_api_(&configurator_) {} |
| 386 test_api_(&configurator_) { | |
| 387 } | |
| 388 virtual ~OutputConfiguratorTest() {} | 387 virtual ~OutputConfiguratorTest() {} |
| 389 | 388 |
| 390 virtual void SetUp() OVERRIDE { | 389 virtual void SetUp() OVERRIDE { |
| 391 log_.reset(new ActionLogger()); | 390 log_.reset(new ActionLogger()); |
| 392 | 391 |
| 393 native_display_delegate_ = new TestNativeDisplayDelegate(log_.get()); | 392 native_display_delegate_ = new TestNativeDisplayDelegate(log_.get()); |
| 394 configurator_.SetNativeDisplayDelegateForTesting( | 393 configurator_.SetNativeDisplayDelegateForTesting( |
| 395 scoped_ptr<NativeDisplayDelegate>(native_display_delegate_)); | 394 scoped_ptr<NativeDisplayDelegate>(native_display_delegate_)); |
| 396 | 395 |
| 397 touchscreen_delegate_ = new TestTouchscreenDelegate(log_.get()); | 396 touchscreen_delegate_ = new TestTouchscreenDelegate(log_.get()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 408 | 407 |
| 409 OutputConfigurator::ModeInfo big_mode_info; | 408 OutputConfigurator::ModeInfo big_mode_info; |
| 410 big_mode_info.width = kBigModeWidth; | 409 big_mode_info.width = kBigModeWidth; |
| 411 big_mode_info.height = kBigModeHeight; | 410 big_mode_info.height = kBigModeHeight; |
| 412 | 411 |
| 413 OutputConfigurator::OutputSnapshot* o = &outputs_[0]; | 412 OutputConfigurator::OutputSnapshot* o = &outputs_[0]; |
| 414 o->output = 1; | 413 o->output = 1; |
| 415 o->crtc = 10; | 414 o->crtc = 10; |
| 416 o->current_mode = kSmallModeId; | 415 o->current_mode = kSmallModeId; |
| 417 o->native_mode = kSmallModeId; | 416 o->native_mode = kSmallModeId; |
| 418 o->type = ui::OUTPUT_TYPE_INTERNAL; | 417 o->type = OUTPUT_TYPE_INTERNAL; |
| 419 o->is_aspect_preserving_scaling = true; | 418 o->is_aspect_preserving_scaling = true; |
| 420 o->mode_infos[kSmallModeId] = small_mode_info; | 419 o->mode_infos[kSmallModeId] = small_mode_info; |
| 421 o->has_display_id = true; | 420 o->has_display_id = true; |
| 422 o->display_id = 123; | 421 o->display_id = 123; |
| 423 o->index = 0; | 422 o->index = 0; |
| 424 | 423 |
| 425 o = &outputs_[1]; | 424 o = &outputs_[1]; |
| 426 o->output = 2; | 425 o->output = 2; |
| 427 o->crtc = 11; | 426 o->crtc = 11; |
| 428 o->current_mode = kBigModeId; | 427 o->current_mode = kBigModeId; |
| 429 o->native_mode = kBigModeId; | 428 o->native_mode = kBigModeId; |
| 430 o->type = ui::OUTPUT_TYPE_HDMI; | 429 o->type = OUTPUT_TYPE_HDMI; |
| 431 o->is_aspect_preserving_scaling = true; | 430 o->is_aspect_preserving_scaling = true; |
| 432 o->mode_infos[kSmallModeId] = small_mode_info; | 431 o->mode_infos[kSmallModeId] = small_mode_info; |
| 433 o->mode_infos[kBigModeId] = big_mode_info; | 432 o->mode_infos[kBigModeId] = big_mode_info; |
| 434 o->has_display_id = true; | 433 o->has_display_id = true; |
| 435 o->display_id = 456; | 434 o->display_id = 456; |
| 436 o->index = 1; | 435 o->index = 1; |
| 437 | 436 |
| 438 UpdateOutputs(2, false); | 437 UpdateOutputs(2, false); |
| 439 } | 438 } |
| 440 | 439 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 log_->GetActionsAndClear()); | 478 log_->GetActionsAndClear()); |
| 480 } | 479 } |
| 481 | 480 |
| 482 base::MessageLoop message_loop_; | 481 base::MessageLoop message_loop_; |
| 483 TestStateController state_controller_; | 482 TestStateController state_controller_; |
| 484 TestMirroringController mirroring_controller_; | 483 TestMirroringController mirroring_controller_; |
| 485 OutputConfigurator configurator_; | 484 OutputConfigurator configurator_; |
| 486 TestObserver observer_; | 485 TestObserver observer_; |
| 487 scoped_ptr<ActionLogger> log_; | 486 scoped_ptr<ActionLogger> log_; |
| 488 TestNativeDisplayDelegate* native_display_delegate_; // not owned | 487 TestNativeDisplayDelegate* native_display_delegate_; // not owned |
| 489 TestTouchscreenDelegate* touchscreen_delegate_; // not owned | 488 TestTouchscreenDelegate* touchscreen_delegate_; // not owned |
| 490 OutputConfigurator::TestApi test_api_; | 489 OutputConfigurator::TestApi test_api_; |
| 491 | 490 |
| 492 OutputConfigurator::OutputSnapshot outputs_[2]; | 491 OutputConfigurator::OutputSnapshot outputs_[2]; |
| 493 | 492 |
| 494 private: | 493 private: |
| 495 DISALLOW_COPY_AND_ASSIGN(OutputConfiguratorTest); | 494 DISALLOW_COPY_AND_ASSIGN(OutputConfiguratorTest); |
| 496 }; | 495 }; |
| 497 | 496 |
| 498 const RRMode OutputConfiguratorTest::kSmallModeId = 20; | 497 const RRMode OutputConfiguratorTest::kSmallModeId = 20; |
| 499 const int OutputConfiguratorTest::kSmallModeWidth = 1366; | 498 const int OutputConfiguratorTest::kSmallModeWidth = 1366; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 524 output.mode_infos[20] = OutputConfigurator::ModeInfo(1024, 768, true, 60.0); | 523 output.mode_infos[20] = OutputConfigurator::ModeInfo(1024, 768, true, 60.0); |
| 525 // Mixed. | 524 // Mixed. |
| 526 output.mode_infos[21] = OutputConfigurator::ModeInfo(1024, 600, true, 60.0); | 525 output.mode_infos[21] = OutputConfigurator::ModeInfo(1024, 600, true, 60.0); |
| 527 output.mode_infos[22] = OutputConfigurator::ModeInfo(1024, 600, false, 40.0); | 526 output.mode_infos[22] = OutputConfigurator::ModeInfo(1024, 600, false, 40.0); |
| 528 output.mode_infos[23] = OutputConfigurator::ModeInfo(1024, 600, false, 50.0); | 527 output.mode_infos[23] = OutputConfigurator::ModeInfo(1024, 600, false, 50.0); |
| 529 // Just one interlaced mode. | 528 // Just one interlaced mode. |
| 530 output.mode_infos[24] = OutputConfigurator::ModeInfo(640, 480, true, 60.0); | 529 output.mode_infos[24] = OutputConfigurator::ModeInfo(640, 480, true, 60.0); |
| 531 // Refresh rate not available. | 530 // Refresh rate not available. |
| 532 output.mode_infos[25] = OutputConfigurator::ModeInfo(320, 200, false, 0.0); | 531 output.mode_infos[25] = OutputConfigurator::ModeInfo(320, 200, false, 0.0); |
| 533 | 532 |
| 534 EXPECT_EQ(11u, OutputConfigurator::FindOutputModeMatchingSize(output, | 533 EXPECT_EQ(11u, |
| 535 1920, 1200)); | 534 OutputConfigurator::FindOutputModeMatchingSize(output, 1920, 1200)); |
| 536 | 535 |
| 537 // Should pick highest refresh rate. | 536 // Should pick highest refresh rate. |
| 538 EXPECT_EQ(13u, OutputConfigurator::FindOutputModeMatchingSize(output, | 537 EXPECT_EQ(13u, |
| 539 1920, 1080)); | 538 OutputConfigurator::FindOutputModeMatchingSize(output, 1920, 1080)); |
| 540 | 539 |
| 541 // Should pick non-interlaced mode. | 540 // Should pick non-interlaced mode. |
| 542 EXPECT_EQ(17u, OutputConfigurator::FindOutputModeMatchingSize(output, | 541 EXPECT_EQ(17u, |
| 543 1280, 720)); | 542 OutputConfigurator::FindOutputModeMatchingSize(output, 1280, 720)); |
| 544 | 543 |
| 545 // Interlaced only. Should pick one with the highest refresh rate in | 544 // Interlaced only. Should pick one with the highest refresh rate in |
| 546 // interlaced mode. | 545 // interlaced mode. |
| 547 EXPECT_EQ(20u, OutputConfigurator::FindOutputModeMatchingSize(output, | 546 EXPECT_EQ(20u, |
| 548 1024, 768)); | 547 OutputConfigurator::FindOutputModeMatchingSize(output, 1024, 768)); |
| 549 | 548 |
| 550 // Mixed: Should pick one with the highest refresh rate in | 549 // Mixed: Should pick one with the highest refresh rate in |
| 551 // interlaced mode. | 550 // interlaced mode. |
| 552 EXPECT_EQ(23u, OutputConfigurator::FindOutputModeMatchingSize(output, | 551 EXPECT_EQ(23u, |
| 553 1024, 600)); | 552 OutputConfigurator::FindOutputModeMatchingSize(output, 1024, 600)); |
| 554 | 553 |
| 555 // Just one interlaced mode. | 554 // Just one interlaced mode. |
| 556 EXPECT_EQ(24u, OutputConfigurator::FindOutputModeMatchingSize(output, | 555 EXPECT_EQ(24u, |
| 557 640, 480)); | 556 OutputConfigurator::FindOutputModeMatchingSize(output, 640, 480)); |
| 558 | 557 |
| 559 // Refresh rate not available. | 558 // Refresh rate not available. |
| 560 EXPECT_EQ(25u, OutputConfigurator::FindOutputModeMatchingSize(output, | 559 EXPECT_EQ(25u, |
| 561 320, 200)); | 560 OutputConfigurator::FindOutputModeMatchingSize(output, 320, 200)); |
| 562 | 561 |
| 563 // No mode found. | 562 // No mode found. |
| 564 EXPECT_EQ(0u, OutputConfigurator::FindOutputModeMatchingSize(output, | 563 EXPECT_EQ(0u, |
| 565 1440, 900)); | 564 OutputConfigurator::FindOutputModeMatchingSize(output, 1440, 900)); |
| 566 } | 565 } |
| 567 | 566 |
| 568 TEST_F(OutputConfiguratorTest, ConnectSecondOutput) { | 567 TEST_F(OutputConfiguratorTest, ConnectSecondOutput) { |
| 569 InitWithSingleOutput(); | 568 InitWithSingleOutput(); |
| 570 | 569 |
| 571 // Connect a second output and check that the configurator enters | 570 // Connect a second output and check that the configurator enters |
| 572 // extended mode. | 571 // extended mode. |
| 573 observer_.Reset(); | 572 observer_.Reset(); |
| 574 state_controller_.set_state(ui::OUTPUT_STATE_DUAL_EXTENDED); | 573 state_controller_.set_state(OUTPUT_STATE_DUAL_EXTENDED); |
| 575 UpdateOutputs(2, true); | 574 UpdateOutputs(2, true); |
| 576 const int kDualHeight = | 575 const int kDualHeight = |
| 577 kSmallModeHeight + OutputConfigurator::kVerticalGap + kBigModeHeight; | 576 kSmallModeHeight + OutputConfigurator::kVerticalGap + kBigModeHeight; |
| 578 EXPECT_EQ( | 577 EXPECT_EQ( |
| 579 JoinActions( | 578 JoinActions( |
| 580 kGrab, | 579 kGrab, |
| 581 GetFramebufferAction( | 580 GetFramebufferAction( |
| 582 kBigModeWidth, kDualHeight, outputs_[0].crtc, outputs_[1].crtc) | 581 kBigModeWidth, kDualHeight, outputs_[0].crtc, outputs_[1].crtc) |
| 583 .c_str(), | 582 .c_str(), |
| 584 GetCrtcAction( | 583 GetCrtcAction( |
| 585 outputs_[0].crtc, 0, 0, kSmallModeId, outputs_[0].output).c_str(), | 584 outputs_[0].crtc, 0, 0, kSmallModeId, outputs_[0].output).c_str(), |
| 586 GetCrtcAction(outputs_[1].crtc, | 585 GetCrtcAction(outputs_[1].crtc, |
| 587 0, | 586 0, |
| 588 kSmallModeHeight + OutputConfigurator::kVerticalGap, | 587 kSmallModeHeight + OutputConfigurator::kVerticalGap, |
| 589 kBigModeId, | 588 kBigModeId, |
| 590 outputs_[1].output).c_str(), | 589 outputs_[1].output).c_str(), |
| 591 kUngrab, | 590 kUngrab, |
| 592 NULL), | 591 NULL), |
| 593 log_->GetActionsAndClear()); | 592 log_->GetActionsAndClear()); |
| 594 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); | 593 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); |
| 595 EXPECT_EQ(1, observer_.num_changes()); | 594 EXPECT_EQ(1, observer_.num_changes()); |
| 596 | 595 |
| 597 observer_.Reset(); | 596 observer_.Reset(); |
| 598 EXPECT_TRUE(configurator_.SetDisplayMode(ui::OUTPUT_STATE_DUAL_MIRROR)); | 597 EXPECT_TRUE(configurator_.SetDisplayMode(OUTPUT_STATE_DUAL_MIRROR)); |
| 599 EXPECT_EQ( | 598 EXPECT_EQ( |
| 600 JoinActions( | 599 JoinActions( |
| 601 kGrab, | 600 kGrab, |
| 602 GetFramebufferAction(kSmallModeWidth, | 601 GetFramebufferAction(kSmallModeWidth, |
| 603 kSmallModeHeight, | 602 kSmallModeHeight, |
| 604 outputs_[0].crtc, | 603 outputs_[0].crtc, |
| 605 outputs_[1].crtc).c_str(), | 604 outputs_[1].crtc).c_str(), |
| 606 GetCrtcAction( | 605 GetCrtcAction( |
| 607 outputs_[0].crtc, 0, 0, kSmallModeId, outputs_[0].output).c_str(), | 606 outputs_[0].crtc, 0, 0, kSmallModeId, outputs_[0].output).c_str(), |
| 608 GetCrtcAction( | 607 GetCrtcAction( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 624 GetCrtcAction( | 623 GetCrtcAction( |
| 625 outputs_[0].crtc, 0, 0, kSmallModeId, outputs_[0].output).c_str(), | 624 outputs_[0].crtc, 0, 0, kSmallModeId, outputs_[0].output).c_str(), |
| 626 kUngrab, | 625 kUngrab, |
| 627 NULL), | 626 NULL), |
| 628 log_->GetActionsAndClear()); | 627 log_->GetActionsAndClear()); |
| 629 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); | 628 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); |
| 630 EXPECT_EQ(1, observer_.num_changes()); | 629 EXPECT_EQ(1, observer_.num_changes()); |
| 631 | 630 |
| 632 // Get rid of shared modes to force software mirroring. | 631 // Get rid of shared modes to force software mirroring. |
| 633 outputs_[1].mode_infos.erase(kSmallModeId); | 632 outputs_[1].mode_infos.erase(kSmallModeId); |
| 634 state_controller_.set_state(ui::OUTPUT_STATE_DUAL_EXTENDED); | 633 state_controller_.set_state(OUTPUT_STATE_DUAL_EXTENDED); |
| 635 UpdateOutputs(2, true); | 634 UpdateOutputs(2, true); |
| 636 EXPECT_EQ( | 635 EXPECT_EQ( |
| 637 JoinActions( | 636 JoinActions( |
| 638 kGrab, | 637 kGrab, |
| 639 GetFramebufferAction( | 638 GetFramebufferAction( |
| 640 kBigModeWidth, kDualHeight, outputs_[0].crtc, outputs_[1].crtc) | 639 kBigModeWidth, kDualHeight, outputs_[0].crtc, outputs_[1].crtc) |
| 641 .c_str(), | 640 .c_str(), |
| 642 GetCrtcAction( | 641 GetCrtcAction( |
| 643 outputs_[0].crtc, 0, 0, kSmallModeId, outputs_[0].output).c_str(), | 642 outputs_[0].crtc, 0, 0, kSmallModeId, outputs_[0].output).c_str(), |
| 644 GetCrtcAction(outputs_[1].crtc, | 643 GetCrtcAction(outputs_[1].crtc, |
| 645 0, | 644 0, |
| 646 kSmallModeHeight + OutputConfigurator::kVerticalGap, | 645 kSmallModeHeight + OutputConfigurator::kVerticalGap, |
| 647 kBigModeId, | 646 kBigModeId, |
| 648 outputs_[1].output).c_str(), | 647 outputs_[1].output).c_str(), |
| 649 kUngrab, | 648 kUngrab, |
| 650 NULL), | 649 NULL), |
| 651 log_->GetActionsAndClear()); | 650 log_->GetActionsAndClear()); |
| 652 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); | 651 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); |
| 653 | 652 |
| 654 observer_.Reset(); | 653 observer_.Reset(); |
| 655 EXPECT_TRUE(configurator_.SetDisplayMode(ui::OUTPUT_STATE_DUAL_MIRROR)); | 654 EXPECT_TRUE(configurator_.SetDisplayMode(OUTPUT_STATE_DUAL_MIRROR)); |
| 656 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear()); | 655 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear()); |
| 657 EXPECT_EQ(ui::OUTPUT_STATE_DUAL_EXTENDED, configurator_.output_state()); | 656 EXPECT_EQ(OUTPUT_STATE_DUAL_EXTENDED, configurator_.output_state()); |
| 658 EXPECT_TRUE(mirroring_controller_.software_mirroring_enabled()); | 657 EXPECT_TRUE(mirroring_controller_.software_mirroring_enabled()); |
| 659 EXPECT_EQ(1, observer_.num_changes()); | 658 EXPECT_EQ(1, observer_.num_changes()); |
| 660 | 659 |
| 661 // Setting OUTPUT_STATE_DUAL_MIRROR should try to reconfigure. | 660 // Setting OUTPUT_STATE_DUAL_MIRROR should try to reconfigure. |
| 662 observer_.Reset(); | 661 observer_.Reset(); |
| 663 EXPECT_TRUE(configurator_.SetDisplayMode(ui::OUTPUT_STATE_DUAL_EXTENDED)); | 662 EXPECT_TRUE(configurator_.SetDisplayMode(OUTPUT_STATE_DUAL_EXTENDED)); |
| 664 EXPECT_EQ(JoinActions(NULL), log_->GetActionsAndClear()); | 663 EXPECT_EQ(JoinActions(NULL), log_->GetActionsAndClear()); |
| 665 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); | 664 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); |
| 666 EXPECT_EQ(1, observer_.num_changes()); | 665 EXPECT_EQ(1, observer_.num_changes()); |
| 667 | 666 |
| 668 // Set back to software mirror mode. | 667 // Set back to software mirror mode. |
| 669 observer_.Reset(); | 668 observer_.Reset(); |
| 670 EXPECT_TRUE(configurator_.SetDisplayMode(ui::OUTPUT_STATE_DUAL_MIRROR)); | 669 EXPECT_TRUE(configurator_.SetDisplayMode(OUTPUT_STATE_DUAL_MIRROR)); |
| 671 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear()); | 670 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear()); |
| 672 EXPECT_EQ(ui::OUTPUT_STATE_DUAL_EXTENDED, configurator_.output_state()); | 671 EXPECT_EQ(OUTPUT_STATE_DUAL_EXTENDED, configurator_.output_state()); |
| 673 EXPECT_TRUE(mirroring_controller_.software_mirroring_enabled()); | 672 EXPECT_TRUE(mirroring_controller_.software_mirroring_enabled()); |
| 674 EXPECT_EQ(1, observer_.num_changes()); | 673 EXPECT_EQ(1, observer_.num_changes()); |
| 675 | 674 |
| 676 // Disconnect the second output. | 675 // Disconnect the second output. |
| 677 observer_.Reset(); | 676 observer_.Reset(); |
| 678 UpdateOutputs(1, true); | 677 UpdateOutputs(1, true); |
| 679 EXPECT_EQ( | 678 EXPECT_EQ( |
| 680 JoinActions( | 679 JoinActions( |
| 681 kGrab, | 680 kGrab, |
| 682 GetFramebufferAction( | 681 GetFramebufferAction( |
| 683 kSmallModeWidth, kSmallModeHeight, outputs_[0].crtc, 0).c_str(), | 682 kSmallModeWidth, kSmallModeHeight, outputs_[0].crtc, 0).c_str(), |
| 684 GetCrtcAction( | 683 GetCrtcAction( |
| 685 outputs_[0].crtc, 0, 0, kSmallModeId, outputs_[0].output).c_str(), | 684 outputs_[0].crtc, 0, 0, kSmallModeId, outputs_[0].output).c_str(), |
| 686 kUngrab, | 685 kUngrab, |
| 687 NULL), | 686 NULL), |
| 688 log_->GetActionsAndClear()); | 687 log_->GetActionsAndClear()); |
| 689 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); | 688 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); |
| 690 EXPECT_EQ(1, observer_.num_changes()); | 689 EXPECT_EQ(1, observer_.num_changes()); |
| 691 } | 690 } |
| 692 | 691 |
| 693 TEST_F(OutputConfiguratorTest, SetDisplayPower) { | 692 TEST_F(OutputConfiguratorTest, SetDisplayPower) { |
| 694 InitWithSingleOutput(); | 693 InitWithSingleOutput(); |
| 695 | 694 |
| 696 state_controller_.set_state(ui::OUTPUT_STATE_DUAL_MIRROR); | 695 state_controller_.set_state(OUTPUT_STATE_DUAL_MIRROR); |
| 697 observer_.Reset(); | 696 observer_.Reset(); |
| 698 UpdateOutputs(2, true); | 697 UpdateOutputs(2, true); |
| 699 EXPECT_EQ( | 698 EXPECT_EQ( |
| 700 JoinActions( | 699 JoinActions( |
| 701 kGrab, | 700 kGrab, |
| 702 GetFramebufferAction(kSmallModeWidth, | 701 GetFramebufferAction(kSmallModeWidth, |
| 703 kSmallModeHeight, | 702 kSmallModeHeight, |
| 704 outputs_[0].crtc, | 703 outputs_[0].crtc, |
| 705 outputs_[1].crtc).c_str(), | 704 outputs_[1].crtc).c_str(), |
| 706 GetCrtcAction( | 705 GetCrtcAction( |
| 707 outputs_[0].crtc, 0, 0, kSmallModeId, outputs_[0].output).c_str(), | 706 outputs_[0].crtc, 0, 0, kSmallModeId, outputs_[0].output).c_str(), |
| 708 GetCrtcAction( | 707 GetCrtcAction( |
| 709 outputs_[1].crtc, 0, 0, kSmallModeId, outputs_[1].output).c_str(), | 708 outputs_[1].crtc, 0, 0, kSmallModeId, outputs_[1].output).c_str(), |
| 710 kUngrab, | 709 kUngrab, |
| 711 NULL), | 710 NULL), |
| 712 log_->GetActionsAndClear()); | 711 log_->GetActionsAndClear()); |
| 713 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); | 712 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); |
| 714 EXPECT_EQ(1, observer_.num_changes()); | 713 EXPECT_EQ(1, observer_.num_changes()); |
| 715 | 714 |
| 716 // Turning off the internal display should switch the external display to | 715 // Turning off the internal display should switch the external display to |
| 717 // its native mode. | 716 // its native mode. |
| 718 observer_.Reset(); | 717 observer_.Reset(); |
| 719 configurator_.SetDisplayPower(DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, | 718 configurator_.SetDisplayPower( |
| 720 OutputConfigurator::kSetDisplayPowerNoFlags); | 719 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, |
| 720 OutputConfigurator::kSetDisplayPowerNoFlags); |
| 721 EXPECT_EQ( | 721 EXPECT_EQ( |
| 722 JoinActions( | 722 JoinActions( |
| 723 kGrab, | 723 kGrab, |
| 724 GetFramebufferAction( | 724 GetFramebufferAction( |
| 725 kBigModeWidth, kBigModeHeight, outputs_[0].crtc, outputs_[1].crtc) | 725 kBigModeWidth, kBigModeHeight, outputs_[0].crtc, outputs_[1].crtc) |
| 726 .c_str(), | 726 .c_str(), |
| 727 GetCrtcAction(outputs_[0].crtc, 0, 0, 0, outputs_[0].output).c_str(), | 727 GetCrtcAction(outputs_[0].crtc, 0, 0, 0, outputs_[0].output).c_str(), |
| 728 GetCrtcAction(outputs_[1].crtc, 0, 0, kBigModeId, outputs_[1].output) | 728 GetCrtcAction(outputs_[1].crtc, 0, 0, kBigModeId, outputs_[1].output) |
| 729 .c_str(), | 729 .c_str(), |
| 730 kForceDPMS, | 730 kForceDPMS, |
| 731 kUngrab, | 731 kUngrab, |
| 732 NULL), | 732 NULL), |
| 733 log_->GetActionsAndClear()); | 733 log_->GetActionsAndClear()); |
| 734 EXPECT_EQ(ui::OUTPUT_STATE_SINGLE, configurator_.output_state()); | 734 EXPECT_EQ(OUTPUT_STATE_SINGLE, configurator_.output_state()); |
| 735 EXPECT_EQ(1, observer_.num_changes()); | 735 EXPECT_EQ(1, observer_.num_changes()); |
| 736 | 736 |
| 737 // When all displays are turned off, the framebuffer should switch back | 737 // When all displays are turned off, the framebuffer should switch back |
| 738 // to the mirrored size. | 738 // to the mirrored size. |
| 739 observer_.Reset(); | 739 observer_.Reset(); |
| 740 configurator_.SetDisplayPower(DISPLAY_POWER_ALL_OFF, | 740 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, |
| 741 OutputConfigurator::kSetDisplayPowerNoFlags); | 741 OutputConfigurator::kSetDisplayPowerNoFlags); |
| 742 EXPECT_EQ( | 742 EXPECT_EQ( |
| 743 JoinActions( | 743 JoinActions( |
| 744 kGrab, | 744 kGrab, |
| 745 GetFramebufferAction(kSmallModeWidth, | 745 GetFramebufferAction(kSmallModeWidth, |
| 746 kSmallModeHeight, | 746 kSmallModeHeight, |
| 747 outputs_[0].crtc, | 747 outputs_[0].crtc, |
| 748 outputs_[1].crtc).c_str(), | 748 outputs_[1].crtc).c_str(), |
| 749 GetCrtcAction(outputs_[0].crtc, 0, 0, 0, outputs_[0].output).c_str(), | 749 GetCrtcAction(outputs_[0].crtc, 0, 0, 0, outputs_[0].output).c_str(), |
| 750 GetCrtcAction(outputs_[1].crtc, 0, 0, 0, outputs_[1].output).c_str(), | 750 GetCrtcAction(outputs_[1].crtc, 0, 0, 0, outputs_[1].output).c_str(), |
| 751 kUngrab, | 751 kUngrab, |
| 752 NULL), | 752 NULL), |
| 753 log_->GetActionsAndClear()); | 753 log_->GetActionsAndClear()); |
| 754 EXPECT_EQ(ui::OUTPUT_STATE_DUAL_MIRROR, configurator_.output_state()); | 754 EXPECT_EQ(OUTPUT_STATE_DUAL_MIRROR, configurator_.output_state()); |
| 755 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); | 755 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); |
| 756 EXPECT_EQ(1, observer_.num_changes()); | 756 EXPECT_EQ(1, observer_.num_changes()); |
| 757 | 757 |
| 758 // Turn all displays on and check that mirroring is still used. | 758 // Turn all displays on and check that mirroring is still used. |
| 759 observer_.Reset(); | 759 observer_.Reset(); |
| 760 configurator_.SetDisplayPower(DISPLAY_POWER_ALL_ON, | 760 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, |
| 761 OutputConfigurator::kSetDisplayPowerNoFlags); | 761 OutputConfigurator::kSetDisplayPowerNoFlags); |
| 762 EXPECT_EQ( | 762 EXPECT_EQ( |
| 763 JoinActions( | 763 JoinActions( |
| 764 kGrab, | 764 kGrab, |
| 765 GetFramebufferAction(kSmallModeWidth, | 765 GetFramebufferAction(kSmallModeWidth, |
| 766 kSmallModeHeight, | 766 kSmallModeHeight, |
| 767 outputs_[0].crtc, | 767 outputs_[0].crtc, |
| 768 outputs_[1].crtc).c_str(), | 768 outputs_[1].crtc).c_str(), |
| 769 GetCrtcAction( | 769 GetCrtcAction( |
| 770 outputs_[0].crtc, 0, 0, kSmallModeId, outputs_[0].output).c_str(), | 770 outputs_[0].crtc, 0, 0, kSmallModeId, outputs_[0].output).c_str(), |
| 771 GetCrtcAction( | 771 GetCrtcAction( |
| 772 outputs_[1].crtc, 0, 0, kSmallModeId, outputs_[1].output).c_str(), | 772 outputs_[1].crtc, 0, 0, kSmallModeId, outputs_[1].output).c_str(), |
| 773 kForceDPMS, | 773 kForceDPMS, |
| 774 kUngrab, | 774 kUngrab, |
| 775 NULL), | 775 NULL), |
| 776 log_->GetActionsAndClear()); | 776 log_->GetActionsAndClear()); |
| 777 EXPECT_EQ(ui::OUTPUT_STATE_DUAL_MIRROR, configurator_.output_state()); | 777 EXPECT_EQ(OUTPUT_STATE_DUAL_MIRROR, configurator_.output_state()); |
| 778 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); | 778 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); |
| 779 EXPECT_EQ(1, observer_.num_changes()); | 779 EXPECT_EQ(1, observer_.num_changes()); |
| 780 | 780 |
| 781 // Get rid of shared modes to force software mirroring. | 781 // Get rid of shared modes to force software mirroring. |
| 782 outputs_[1].mode_infos.erase(kSmallModeId); | 782 outputs_[1].mode_infos.erase(kSmallModeId); |
| 783 state_controller_.set_state(ui::OUTPUT_STATE_DUAL_MIRROR); | 783 state_controller_.set_state(OUTPUT_STATE_DUAL_MIRROR); |
| 784 observer_.Reset(); | 784 observer_.Reset(); |
| 785 UpdateOutputs(2, true); | 785 UpdateOutputs(2, true); |
| 786 const int kDualHeight = | 786 const int kDualHeight = |
| 787 kSmallModeHeight + OutputConfigurator::kVerticalGap + kBigModeHeight; | 787 kSmallModeHeight + OutputConfigurator::kVerticalGap + kBigModeHeight; |
| 788 EXPECT_EQ( | 788 EXPECT_EQ( |
| 789 JoinActions( | 789 JoinActions( |
| 790 kGrab, | 790 kGrab, |
| 791 GetFramebufferAction( | 791 GetFramebufferAction( |
| 792 kBigModeWidth, kDualHeight, outputs_[0].crtc, outputs_[1].crtc) | 792 kBigModeWidth, kDualHeight, outputs_[0].crtc, outputs_[1].crtc) |
| 793 .c_str(), | 793 .c_str(), |
| 794 GetCrtcAction( | 794 GetCrtcAction( |
| 795 outputs_[0].crtc, 0, 0, kSmallModeId, outputs_[0].output).c_str(), | 795 outputs_[0].crtc, 0, 0, kSmallModeId, outputs_[0].output).c_str(), |
| 796 GetCrtcAction(outputs_[1].crtc, | 796 GetCrtcAction(outputs_[1].crtc, |
| 797 0, | 797 0, |
| 798 kSmallModeHeight + OutputConfigurator::kVerticalGap, | 798 kSmallModeHeight + OutputConfigurator::kVerticalGap, |
| 799 kBigModeId, | 799 kBigModeId, |
| 800 outputs_[1].output).c_str(), | 800 outputs_[1].output).c_str(), |
| 801 kUngrab, | 801 kUngrab, |
| 802 NULL), | 802 NULL), |
| 803 log_->GetActionsAndClear()); | 803 log_->GetActionsAndClear()); |
| 804 EXPECT_EQ(ui::OUTPUT_STATE_DUAL_EXTENDED, configurator_.output_state()); | 804 EXPECT_EQ(OUTPUT_STATE_DUAL_EXTENDED, configurator_.output_state()); |
| 805 EXPECT_TRUE(mirroring_controller_.software_mirroring_enabled()); | 805 EXPECT_TRUE(mirroring_controller_.software_mirroring_enabled()); |
| 806 EXPECT_EQ(1, observer_.num_changes()); | 806 EXPECT_EQ(1, observer_.num_changes()); |
| 807 | 807 |
| 808 // Turning off the internal display should switch the external display to | 808 // Turning off the internal display should switch the external display to |
| 809 // its native mode. | 809 // its native mode. |
| 810 observer_.Reset(); | 810 observer_.Reset(); |
| 811 configurator_.SetDisplayPower(DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, | 811 configurator_.SetDisplayPower( |
| 812 OutputConfigurator::kSetDisplayPowerNoFlags); | 812 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, |
| 813 OutputConfigurator::kSetDisplayPowerNoFlags); |
| 813 EXPECT_EQ( | 814 EXPECT_EQ( |
| 814 JoinActions( | 815 JoinActions( |
| 815 kGrab, | 816 kGrab, |
| 816 GetFramebufferAction( | 817 GetFramebufferAction( |
| 817 kBigModeWidth, kBigModeHeight, outputs_[0].crtc, outputs_[1].crtc) | 818 kBigModeWidth, kBigModeHeight, outputs_[0].crtc, outputs_[1].crtc) |
| 818 .c_str(), | 819 .c_str(), |
| 819 GetCrtcAction(outputs_[0].crtc, 0, 0, 0, outputs_[0].output).c_str(), | 820 GetCrtcAction(outputs_[0].crtc, 0, 0, 0, outputs_[0].output).c_str(), |
| 820 GetCrtcAction(outputs_[1].crtc, 0, 0, kBigModeId, outputs_[1].output) | 821 GetCrtcAction(outputs_[1].crtc, 0, 0, kBigModeId, outputs_[1].output) |
| 821 .c_str(), | 822 .c_str(), |
| 822 kForceDPMS, | 823 kForceDPMS, |
| 823 kUngrab, | 824 kUngrab, |
| 824 NULL), | 825 NULL), |
| 825 log_->GetActionsAndClear()); | 826 log_->GetActionsAndClear()); |
| 826 EXPECT_EQ(ui::OUTPUT_STATE_SINGLE, configurator_.output_state()); | 827 EXPECT_EQ(OUTPUT_STATE_SINGLE, configurator_.output_state()); |
| 827 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); | 828 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); |
| 828 EXPECT_EQ(1, observer_.num_changes()); | 829 EXPECT_EQ(1, observer_.num_changes()); |
| 829 | 830 |
| 830 // When all displays are turned off, the framebuffer should switch back | 831 // When all displays are turned off, the framebuffer should switch back |
| 831 // to the extended + software mirroring. | 832 // to the extended + software mirroring. |
| 832 observer_.Reset(); | 833 observer_.Reset(); |
| 833 configurator_.SetDisplayPower(DISPLAY_POWER_ALL_OFF, | 834 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, |
| 834 OutputConfigurator::kSetDisplayPowerNoFlags); | 835 OutputConfigurator::kSetDisplayPowerNoFlags); |
| 835 EXPECT_EQ( | 836 EXPECT_EQ( |
| 836 JoinActions( | 837 JoinActions( |
| 837 kGrab, | 838 kGrab, |
| 838 GetFramebufferAction( | 839 GetFramebufferAction( |
| 839 kBigModeWidth, kDualHeight, outputs_[0].crtc, outputs_[1].crtc) | 840 kBigModeWidth, kDualHeight, outputs_[0].crtc, outputs_[1].crtc) |
| 840 .c_str(), | 841 .c_str(), |
| 841 GetCrtcAction(outputs_[0].crtc, 0, 0, 0, outputs_[0].output).c_str(), | 842 GetCrtcAction(outputs_[0].crtc, 0, 0, 0, outputs_[0].output).c_str(), |
| 842 GetCrtcAction(outputs_[1].crtc, | 843 GetCrtcAction(outputs_[1].crtc, |
| 843 0, | 844 0, |
| 844 kSmallModeHeight + OutputConfigurator::kVerticalGap, | 845 kSmallModeHeight + OutputConfigurator::kVerticalGap, |
| 845 0, | 846 0, |
| 846 outputs_[1].output).c_str(), | 847 outputs_[1].output).c_str(), |
| 847 kUngrab, | 848 kUngrab, |
| 848 NULL), | 849 NULL), |
| 849 log_->GetActionsAndClear()); | 850 log_->GetActionsAndClear()); |
| 850 EXPECT_EQ(ui::OUTPUT_STATE_DUAL_EXTENDED, configurator_.output_state()); | 851 EXPECT_EQ(OUTPUT_STATE_DUAL_EXTENDED, configurator_.output_state()); |
| 851 EXPECT_TRUE(mirroring_controller_.software_mirroring_enabled()); | 852 EXPECT_TRUE(mirroring_controller_.software_mirroring_enabled()); |
| 852 EXPECT_EQ(1, observer_.num_changes()); | 853 EXPECT_EQ(1, observer_.num_changes()); |
| 853 | 854 |
| 854 // Turn all displays on and check that mirroring is still used. | 855 // Turn all displays on and check that mirroring is still used. |
| 855 observer_.Reset(); | 856 observer_.Reset(); |
| 856 configurator_.SetDisplayPower(DISPLAY_POWER_ALL_ON, | 857 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, |
| 857 OutputConfigurator::kSetDisplayPowerNoFlags); | 858 OutputConfigurator::kSetDisplayPowerNoFlags); |
| 858 EXPECT_EQ( | 859 EXPECT_EQ( |
| 859 JoinActions( | 860 JoinActions( |
| 860 kGrab, | 861 kGrab, |
| 861 GetFramebufferAction( | 862 GetFramebufferAction( |
| 862 kBigModeWidth, kDualHeight, outputs_[0].crtc, outputs_[1].crtc) | 863 kBigModeWidth, kDualHeight, outputs_[0].crtc, outputs_[1].crtc) |
| 863 .c_str(), | 864 .c_str(), |
| 864 GetCrtcAction( | 865 GetCrtcAction( |
| 865 outputs_[0].crtc, 0, 0, kSmallModeId, outputs_[0].output).c_str(), | 866 outputs_[0].crtc, 0, 0, kSmallModeId, outputs_[0].output).c_str(), |
| 866 GetCrtcAction(outputs_[1].crtc, | 867 GetCrtcAction(outputs_[1].crtc, |
| 867 0, | 868 0, |
| 868 kSmallModeHeight + OutputConfigurator::kVerticalGap, | 869 kSmallModeHeight + OutputConfigurator::kVerticalGap, |
| 869 kBigModeId, | 870 kBigModeId, |
| 870 outputs_[1].output).c_str(), | 871 outputs_[1].output).c_str(), |
| 871 kForceDPMS, | 872 kForceDPMS, |
| 872 kUngrab, | 873 kUngrab, |
| 873 NULL), | 874 NULL), |
| 874 log_->GetActionsAndClear()); | 875 log_->GetActionsAndClear()); |
| 875 EXPECT_EQ(ui::OUTPUT_STATE_DUAL_EXTENDED, configurator_.output_state()); | 876 EXPECT_EQ(OUTPUT_STATE_DUAL_EXTENDED, configurator_.output_state()); |
| 876 EXPECT_TRUE(mirroring_controller_.software_mirroring_enabled()); | 877 EXPECT_TRUE(mirroring_controller_.software_mirroring_enabled()); |
| 877 EXPECT_EQ(1, observer_.num_changes()); | 878 EXPECT_EQ(1, observer_.num_changes()); |
| 878 } | 879 } |
| 879 | 880 |
| 880 TEST_F(OutputConfiguratorTest, SuspendAndResume) { | 881 TEST_F(OutputConfiguratorTest, SuspendAndResume) { |
| 881 InitWithSingleOutput(); | 882 InitWithSingleOutput(); |
| 882 | 883 |
| 883 // No preparation is needed before suspending when the display is already | 884 // No preparation is needed before suspending when the display is already |
| 884 // on. The configurator should still reprobe on resume in case a display | 885 // on. The configurator should still reprobe on resume in case a display |
| 885 // was connected while suspended. | 886 // was connected while suspended. |
| 886 configurator_.SuspendDisplays(); | 887 configurator_.SuspendDisplays(); |
| 887 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 888 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 888 configurator_.ResumeDisplays(); | 889 configurator_.ResumeDisplays(); |
| 889 EXPECT_EQ( | 890 EXPECT_EQ( |
| 890 JoinActions( | 891 JoinActions( |
| 891 kGrab, | 892 kGrab, |
| 892 GetFramebufferAction( | 893 GetFramebufferAction( |
| 893 kSmallModeWidth, kSmallModeHeight, outputs_[0].crtc, 0).c_str(), | 894 kSmallModeWidth, kSmallModeHeight, outputs_[0].crtc, 0).c_str(), |
| 894 GetCrtcAction( | 895 GetCrtcAction( |
| 895 outputs_[0].crtc, 0, 0, kSmallModeId, outputs_[0].output).c_str(), | 896 outputs_[0].crtc, 0, 0, kSmallModeId, outputs_[0].output).c_str(), |
| 896 kForceDPMS, | 897 kForceDPMS, |
| 897 kUngrab, | 898 kUngrab, |
| 898 NULL), | 899 NULL), |
| 899 log_->GetActionsAndClear()); | 900 log_->GetActionsAndClear()); |
| 900 | 901 |
| 901 // Now turn the display off before suspending and check that the | 902 // Now turn the display off before suspending and check that the |
| 902 // configurator turns it back on and syncs with the server. | 903 // configurator turns it back on and syncs with the server. |
| 903 configurator_.SetDisplayPower(DISPLAY_POWER_ALL_OFF, | 904 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, |
| 904 OutputConfigurator::kSetDisplayPowerNoFlags); | 905 OutputConfigurator::kSetDisplayPowerNoFlags); |
| 905 EXPECT_EQ( | 906 EXPECT_EQ( |
| 906 JoinActions( | 907 JoinActions( |
| 907 kGrab, | 908 kGrab, |
| 908 GetFramebufferAction( | 909 GetFramebufferAction( |
| 909 kSmallModeWidth, kSmallModeHeight, outputs_[0].crtc, 0).c_str(), | 910 kSmallModeWidth, kSmallModeHeight, outputs_[0].crtc, 0).c_str(), |
| 910 GetCrtcAction(outputs_[0].crtc, 0, 0, 0, outputs_[0].output).c_str(), | 911 GetCrtcAction(outputs_[0].crtc, 0, 0, 0, outputs_[0].output).c_str(), |
| 911 kUngrab, | 912 kUngrab, |
| 912 NULL), | 913 NULL), |
| 913 log_->GetActionsAndClear()); | 914 log_->GetActionsAndClear()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 934 kSmallModeWidth, kSmallModeHeight, outputs_[0].crtc, 0).c_str(), | 935 kSmallModeWidth, kSmallModeHeight, outputs_[0].crtc, 0).c_str(), |
| 935 GetCrtcAction( | 936 GetCrtcAction( |
| 936 outputs_[0].crtc, 0, 0, kSmallModeId, outputs_[0].output).c_str(), | 937 outputs_[0].crtc, 0, 0, kSmallModeId, outputs_[0].output).c_str(), |
| 937 kForceDPMS, | 938 kForceDPMS, |
| 938 kUngrab, | 939 kUngrab, |
| 939 NULL), | 940 NULL), |
| 940 log_->GetActionsAndClear()); | 941 log_->GetActionsAndClear()); |
| 941 | 942 |
| 942 // If a second, external display is connected, the displays shouldn't be | 943 // If a second, external display is connected, the displays shouldn't be |
| 943 // powered back on before suspending. | 944 // powered back on before suspending. |
| 944 state_controller_.set_state(ui::OUTPUT_STATE_DUAL_MIRROR); | 945 state_controller_.set_state(OUTPUT_STATE_DUAL_MIRROR); |
| 945 UpdateOutputs(2, true); | 946 UpdateOutputs(2, true); |
| 946 EXPECT_EQ( | 947 EXPECT_EQ( |
| 947 JoinActions( | 948 JoinActions( |
| 948 kGrab, | 949 kGrab, |
| 949 GetFramebufferAction(kSmallModeWidth, | 950 GetFramebufferAction(kSmallModeWidth, |
| 950 kSmallModeHeight, | 951 kSmallModeHeight, |
| 951 outputs_[0].crtc, | 952 outputs_[0].crtc, |
| 952 outputs_[1].crtc).c_str(), | 953 outputs_[1].crtc).c_str(), |
| 953 GetCrtcAction( | 954 GetCrtcAction( |
| 954 outputs_[0].crtc, 0, 0, kSmallModeId, outputs_[0].output).c_str(), | 955 outputs_[0].crtc, 0, 0, kSmallModeId, outputs_[0].output).c_str(), |
| 955 GetCrtcAction( | 956 GetCrtcAction( |
| 956 outputs_[1].crtc, 0, 0, kSmallModeId, outputs_[1].output).c_str(), | 957 outputs_[1].crtc, 0, 0, kSmallModeId, outputs_[1].output).c_str(), |
| 957 kUngrab, | 958 kUngrab, |
| 958 NULL), | 959 NULL), |
| 959 log_->GetActionsAndClear()); | 960 log_->GetActionsAndClear()); |
| 960 | 961 |
| 961 configurator_.SetDisplayPower(DISPLAY_POWER_ALL_OFF, | 962 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, |
| 962 OutputConfigurator::kSetDisplayPowerNoFlags); | 963 OutputConfigurator::kSetDisplayPowerNoFlags); |
| 963 EXPECT_EQ( | 964 EXPECT_EQ( |
| 964 JoinActions( | 965 JoinActions( |
| 965 kGrab, | 966 kGrab, |
| 966 GetFramebufferAction(kSmallModeWidth, | 967 GetFramebufferAction(kSmallModeWidth, |
| 967 kSmallModeHeight, | 968 kSmallModeHeight, |
| 968 outputs_[0].crtc, | 969 outputs_[0].crtc, |
| 969 outputs_[1].crtc).c_str(), | 970 outputs_[1].crtc).c_str(), |
| 970 GetCrtcAction(outputs_[0].crtc, 0, 0, 0, outputs_[0].output).c_str(), | 971 GetCrtcAction(outputs_[0].crtc, 0, 0, 0, outputs_[0].output).c_str(), |
| 971 GetCrtcAction(outputs_[1].crtc, 0, 0, 0, outputs_[1].output).c_str(), | 972 GetCrtcAction(outputs_[1].crtc, 0, 0, 0, outputs_[1].output).c_str(), |
| (...skipping 24 matching lines...) Expand all Loading... |
| 996 UpdateOutputs(0, false); | 997 UpdateOutputs(0, false); |
| 997 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 998 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 998 configurator_.Init(false); | 999 configurator_.Init(false); |
| 999 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1000 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1000 configurator_.ForceInitialConfigure(0); | 1001 configurator_.ForceInitialConfigure(0); |
| 1001 EXPECT_EQ(JoinActions(kGrab, kInitXRandR, kForceDPMS, kUngrab, NULL), | 1002 EXPECT_EQ(JoinActions(kGrab, kInitXRandR, kForceDPMS, kUngrab, NULL), |
| 1002 log_->GetActionsAndClear()); | 1003 log_->GetActionsAndClear()); |
| 1003 | 1004 |
| 1004 // Not much should happen when the display power state is changed while | 1005 // Not much should happen when the display power state is changed while |
| 1005 // no displays are connected. | 1006 // no displays are connected. |
| 1006 configurator_.SetDisplayPower(DISPLAY_POWER_ALL_OFF, | 1007 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, |
| 1007 OutputConfigurator::kSetDisplayPowerNoFlags); | 1008 OutputConfigurator::kSetDisplayPowerNoFlags); |
| 1008 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear()); | 1009 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear()); |
| 1009 configurator_.SetDisplayPower(DISPLAY_POWER_ALL_ON, | 1010 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, |
| 1010 OutputConfigurator::kSetDisplayPowerNoFlags); | 1011 OutputConfigurator::kSetDisplayPowerNoFlags); |
| 1011 EXPECT_EQ(JoinActions(kGrab, kForceDPMS, kUngrab, NULL), | 1012 EXPECT_EQ(JoinActions(kGrab, kForceDPMS, kUngrab, NULL), |
| 1012 log_->GetActionsAndClear()); | 1013 log_->GetActionsAndClear()); |
| 1013 | 1014 |
| 1014 // Connect an external display and check that it's configured correctly. | 1015 // Connect an external display and check that it's configured correctly. |
| 1015 outputs_[0] = outputs_[1]; | 1016 outputs_[0] = outputs_[1]; |
| 1016 UpdateOutputs(1, true); | 1017 UpdateOutputs(1, true); |
| 1017 EXPECT_EQ( | 1018 EXPECT_EQ( |
| 1018 JoinActions( | 1019 JoinActions( |
| 1019 kGrab, | 1020 kGrab, |
| 1020 GetFramebufferAction( | 1021 GetFramebufferAction( |
| 1021 kBigModeWidth, kBigModeHeight, outputs_[0].crtc, 0).c_str(), | 1022 kBigModeWidth, kBigModeHeight, outputs_[0].crtc, 0).c_str(), |
| 1022 GetCrtcAction(outputs_[0].crtc, 0, 0, kBigModeId, outputs_[0].output) | 1023 GetCrtcAction(outputs_[0].crtc, 0, 0, kBigModeId, outputs_[0].output) |
| 1023 .c_str(), | 1024 .c_str(), |
| 1024 kUngrab, | 1025 kUngrab, |
| 1025 NULL), | 1026 NULL), |
| 1026 log_->GetActionsAndClear()); | 1027 log_->GetActionsAndClear()); |
| 1027 } | 1028 } |
| 1028 | 1029 |
| 1029 TEST_F(OutputConfiguratorTest, StartWithTwoOutputs) { | 1030 TEST_F(OutputConfiguratorTest, StartWithTwoOutputs) { |
| 1030 UpdateOutputs(2, false); | 1031 UpdateOutputs(2, false); |
| 1031 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1032 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1032 configurator_.Init(false); | 1033 configurator_.Init(false); |
| 1033 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1034 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1034 | 1035 |
| 1035 state_controller_.set_state(ui::OUTPUT_STATE_DUAL_MIRROR); | 1036 state_controller_.set_state(OUTPUT_STATE_DUAL_MIRROR); |
| 1036 configurator_.ForceInitialConfigure(0); | 1037 configurator_.ForceInitialConfigure(0); |
| 1037 EXPECT_EQ( | 1038 EXPECT_EQ( |
| 1038 JoinActions( | 1039 JoinActions( |
| 1039 kGrab, | 1040 kGrab, |
| 1040 kInitXRandR, | 1041 kInitXRandR, |
| 1041 GetFramebufferAction(kSmallModeWidth, | 1042 GetFramebufferAction(kSmallModeWidth, |
| 1042 kSmallModeHeight, | 1043 kSmallModeHeight, |
| 1043 outputs_[0].crtc, | 1044 outputs_[0].crtc, |
| 1044 outputs_[1].crtc).c_str(), | 1045 outputs_[1].crtc).c_str(), |
| 1045 GetCrtcAction( | 1046 GetCrtcAction( |
| 1046 outputs_[0].crtc, 0, 0, kSmallModeId, outputs_[0].output).c_str(), | 1047 outputs_[0].crtc, 0, 0, kSmallModeId, outputs_[0].output).c_str(), |
| 1047 GetCrtcAction( | 1048 GetCrtcAction( |
| 1048 outputs_[1].crtc, 0, 0, kSmallModeId, outputs_[1].output).c_str(), | 1049 outputs_[1].crtc, 0, 0, kSmallModeId, outputs_[1].output).c_str(), |
| 1049 kForceDPMS, | 1050 kForceDPMS, |
| 1050 kUngrab, | 1051 kUngrab, |
| 1051 NULL), | 1052 NULL), |
| 1052 log_->GetActionsAndClear()); | 1053 log_->GetActionsAndClear()); |
| 1053 } | 1054 } |
| 1054 | 1055 |
| 1055 TEST_F(OutputConfiguratorTest, InvalidOutputStates) { | 1056 TEST_F(OutputConfiguratorTest, InvalidOutputStates) { |
| 1056 UpdateOutputs(0, false); | 1057 UpdateOutputs(0, false); |
| 1057 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1058 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1058 configurator_.Init(false); | 1059 configurator_.Init(false); |
| 1059 configurator_.ForceInitialConfigure(0); | 1060 configurator_.ForceInitialConfigure(0); |
| 1060 observer_.Reset(); | 1061 observer_.Reset(); |
| 1061 EXPECT_TRUE(configurator_.SetDisplayMode(ui::OUTPUT_STATE_HEADLESS)); | 1062 EXPECT_TRUE(configurator_.SetDisplayMode(OUTPUT_STATE_HEADLESS)); |
| 1062 EXPECT_FALSE(configurator_.SetDisplayMode(ui::OUTPUT_STATE_SINGLE)); | 1063 EXPECT_FALSE(configurator_.SetDisplayMode(OUTPUT_STATE_SINGLE)); |
| 1063 EXPECT_FALSE(configurator_.SetDisplayMode(ui::OUTPUT_STATE_DUAL_MIRROR)); | 1064 EXPECT_FALSE(configurator_.SetDisplayMode(OUTPUT_STATE_DUAL_MIRROR)); |
| 1064 EXPECT_FALSE(configurator_.SetDisplayMode(ui::OUTPUT_STATE_DUAL_EXTENDED)); | 1065 EXPECT_FALSE(configurator_.SetDisplayMode(OUTPUT_STATE_DUAL_EXTENDED)); |
| 1065 EXPECT_EQ(1, observer_.num_changes()); | 1066 EXPECT_EQ(1, observer_.num_changes()); |
| 1066 EXPECT_EQ(3, observer_.num_failures()); | 1067 EXPECT_EQ(3, observer_.num_failures()); |
| 1067 | 1068 |
| 1068 UpdateOutputs(1, true); | 1069 UpdateOutputs(1, true); |
| 1069 observer_.Reset(); | 1070 observer_.Reset(); |
| 1070 EXPECT_FALSE(configurator_.SetDisplayMode(ui::OUTPUT_STATE_HEADLESS)); | 1071 EXPECT_FALSE(configurator_.SetDisplayMode(OUTPUT_STATE_HEADLESS)); |
| 1071 EXPECT_TRUE(configurator_.SetDisplayMode(ui::OUTPUT_STATE_SINGLE)); | 1072 EXPECT_TRUE(configurator_.SetDisplayMode(OUTPUT_STATE_SINGLE)); |
| 1072 EXPECT_FALSE(configurator_.SetDisplayMode(ui::OUTPUT_STATE_DUAL_MIRROR)); | 1073 EXPECT_FALSE(configurator_.SetDisplayMode(OUTPUT_STATE_DUAL_MIRROR)); |
| 1073 EXPECT_FALSE(configurator_.SetDisplayMode(ui::OUTPUT_STATE_DUAL_EXTENDED)); | 1074 EXPECT_FALSE(configurator_.SetDisplayMode(OUTPUT_STATE_DUAL_EXTENDED)); |
| 1074 EXPECT_EQ(1, observer_.num_changes()); | 1075 EXPECT_EQ(1, observer_.num_changes()); |
| 1075 EXPECT_EQ(3, observer_.num_failures()); | 1076 EXPECT_EQ(3, observer_.num_failures()); |
| 1076 | 1077 |
| 1077 state_controller_.set_state(ui::OUTPUT_STATE_DUAL_EXTENDED); | 1078 state_controller_.set_state(OUTPUT_STATE_DUAL_EXTENDED); |
| 1078 UpdateOutputs(2, true); | 1079 UpdateOutputs(2, true); |
| 1079 observer_.Reset(); | 1080 observer_.Reset(); |
| 1080 EXPECT_FALSE(configurator_.SetDisplayMode(ui::OUTPUT_STATE_HEADLESS)); | 1081 EXPECT_FALSE(configurator_.SetDisplayMode(OUTPUT_STATE_HEADLESS)); |
| 1081 EXPECT_FALSE(configurator_.SetDisplayMode(ui::OUTPUT_STATE_SINGLE)); | 1082 EXPECT_FALSE(configurator_.SetDisplayMode(OUTPUT_STATE_SINGLE)); |
| 1082 EXPECT_TRUE(configurator_.SetDisplayMode(ui::OUTPUT_STATE_DUAL_MIRROR)); | 1083 EXPECT_TRUE(configurator_.SetDisplayMode(OUTPUT_STATE_DUAL_MIRROR)); |
| 1083 EXPECT_TRUE(configurator_.SetDisplayMode(ui::OUTPUT_STATE_DUAL_EXTENDED)); | 1084 EXPECT_TRUE(configurator_.SetDisplayMode(OUTPUT_STATE_DUAL_EXTENDED)); |
| 1084 EXPECT_EQ(2, observer_.num_changes()); | 1085 EXPECT_EQ(2, observer_.num_changes()); |
| 1085 EXPECT_EQ(2, observer_.num_failures()); | 1086 EXPECT_EQ(2, observer_.num_failures()); |
| 1086 } | 1087 } |
| 1087 | 1088 |
| 1088 TEST_F(OutputConfiguratorTest, GetOutputStateForDisplaysWithoutId) { | 1089 TEST_F(OutputConfiguratorTest, GetOutputStateForDisplaysWithoutId) { |
| 1089 outputs_[0].has_display_id = false; | 1090 outputs_[0].has_display_id = false; |
| 1090 UpdateOutputs(2, false); | 1091 UpdateOutputs(2, false); |
| 1091 configurator_.Init(false); | 1092 configurator_.Init(false); |
| 1092 state_controller_.set_state(ui::OUTPUT_STATE_DUAL_MIRROR); | 1093 state_controller_.set_state(OUTPUT_STATE_DUAL_MIRROR); |
| 1093 configurator_.ForceInitialConfigure(0); | 1094 configurator_.ForceInitialConfigure(0); |
| 1094 EXPECT_EQ(ui::OUTPUT_STATE_DUAL_EXTENDED, configurator_.output_state()); | 1095 EXPECT_EQ(OUTPUT_STATE_DUAL_EXTENDED, configurator_.output_state()); |
| 1095 } | 1096 } |
| 1096 | 1097 |
| 1097 TEST_F(OutputConfiguratorTest, GetOutputStateForDisplaysWithId) { | 1098 TEST_F(OutputConfiguratorTest, GetOutputStateForDisplaysWithId) { |
| 1098 outputs_[0].has_display_id = true; | 1099 outputs_[0].has_display_id = true; |
| 1099 UpdateOutputs(2, false); | 1100 UpdateOutputs(2, false); |
| 1100 configurator_.Init(false); | 1101 configurator_.Init(false); |
| 1101 state_controller_.set_state(ui::OUTPUT_STATE_DUAL_MIRROR); | 1102 state_controller_.set_state(OUTPUT_STATE_DUAL_MIRROR); |
| 1102 configurator_.ForceInitialConfigure(0); | 1103 configurator_.ForceInitialConfigure(0); |
| 1103 EXPECT_EQ(ui::OUTPUT_STATE_DUAL_MIRROR, configurator_.output_state()); | 1104 EXPECT_EQ(OUTPUT_STATE_DUAL_MIRROR, configurator_.output_state()); |
| 1104 } | 1105 } |
| 1105 | 1106 |
| 1106 TEST_F(OutputConfiguratorTest, UpdateCachedOutputsEvenAfterFailure) { | 1107 TEST_F(OutputConfiguratorTest, UpdateCachedOutputsEvenAfterFailure) { |
| 1107 InitWithSingleOutput(); | 1108 InitWithSingleOutput(); |
| 1108 const std::vector<OutputConfigurator::OutputSnapshot>* cached = | 1109 const std::vector<OutputConfigurator::OutputSnapshot>* cached = |
| 1109 &configurator_.cached_outputs(); | 1110 &configurator_.cached_outputs(); |
| 1110 ASSERT_EQ(static_cast<size_t>(1), cached->size()); | 1111 ASSERT_EQ(static_cast<size_t>(1), cached->size()); |
| 1111 EXPECT_EQ(outputs_[0].current_mode, (*cached)[0].current_mode); | 1112 EXPECT_EQ(outputs_[0].current_mode, (*cached)[0].current_mode); |
| 1112 | 1113 |
| 1113 // After connecting a second output, check that it shows up in | 1114 // After connecting a second output, check that it shows up in |
| 1114 // |cached_outputs_| even if an invalid state is requested. | 1115 // |cached_outputs_| even if an invalid state is requested. |
| 1115 state_controller_.set_state(ui::OUTPUT_STATE_SINGLE); | 1116 state_controller_.set_state(OUTPUT_STATE_SINGLE); |
| 1116 UpdateOutputs(2, true); | 1117 UpdateOutputs(2, true); |
| 1117 cached = &configurator_.cached_outputs(); | 1118 cached = &configurator_.cached_outputs(); |
| 1118 ASSERT_EQ(static_cast<size_t>(2), cached->size()); | 1119 ASSERT_EQ(static_cast<size_t>(2), cached->size()); |
| 1119 EXPECT_EQ(outputs_[0].current_mode, (*cached)[0].current_mode); | 1120 EXPECT_EQ(outputs_[0].current_mode, (*cached)[0].current_mode); |
| 1120 EXPECT_EQ(outputs_[1].current_mode, (*cached)[1].current_mode); | 1121 EXPECT_EQ(outputs_[1].current_mode, (*cached)[1].current_mode); |
| 1121 } | 1122 } |
| 1122 | 1123 |
| 1123 TEST_F(OutputConfiguratorTest, PanelFitting) { | 1124 TEST_F(OutputConfiguratorTest, PanelFitting) { |
| 1124 // Configure the internal display to support only the big mode and the | 1125 // Configure the internal display to support only the big mode and the |
| 1125 // external display to support only the small mode. | 1126 // external display to support only the small mode. |
| 1126 outputs_[0].current_mode = kBigModeId; | 1127 outputs_[0].current_mode = kBigModeId; |
| 1127 outputs_[0].native_mode = kBigModeId; | 1128 outputs_[0].native_mode = kBigModeId; |
| 1128 outputs_[0].mode_infos.clear(); | 1129 outputs_[0].mode_infos.clear(); |
| 1129 outputs_[0].mode_infos[kBigModeId] = OutputConfigurator::ModeInfo( | 1130 outputs_[0].mode_infos[kBigModeId] = |
| 1130 kBigModeWidth, kBigModeHeight, false, 60.0); | 1131 OutputConfigurator::ModeInfo(kBigModeWidth, kBigModeHeight, false, 60.0); |
| 1131 | 1132 |
| 1132 outputs_[1].current_mode = kSmallModeId; | 1133 outputs_[1].current_mode = kSmallModeId; |
| 1133 outputs_[1].native_mode = kSmallModeId; | 1134 outputs_[1].native_mode = kSmallModeId; |
| 1134 outputs_[1].mode_infos.clear(); | 1135 outputs_[1].mode_infos.clear(); |
| 1135 outputs_[1].mode_infos[kSmallModeId] = OutputConfigurator::ModeInfo( | 1136 outputs_[1].mode_infos[kSmallModeId] = OutputConfigurator::ModeInfo( |
| 1136 kSmallModeWidth, kSmallModeHeight, false, 60.0); | 1137 kSmallModeWidth, kSmallModeHeight, false, 60.0); |
| 1137 | 1138 |
| 1138 // The small mode should be added to the internal output when requesting | 1139 // The small mode should be added to the internal output when requesting |
| 1139 // mirrored mode. | 1140 // mirrored mode. |
| 1140 UpdateOutputs(2, false); | 1141 UpdateOutputs(2, false); |
| 1141 state_controller_.set_state(ui::OUTPUT_STATE_DUAL_MIRROR); | 1142 state_controller_.set_state(OUTPUT_STATE_DUAL_MIRROR); |
| 1142 configurator_.Init(true /* is_panel_fitting_enabled */); | 1143 configurator_.Init(true /* is_panel_fitting_enabled */); |
| 1143 configurator_.ForceInitialConfigure(0); | 1144 configurator_.ForceInitialConfigure(0); |
| 1144 EXPECT_EQ(ui::OUTPUT_STATE_DUAL_MIRROR, configurator_.output_state()); | 1145 EXPECT_EQ(OUTPUT_STATE_DUAL_MIRROR, configurator_.output_state()); |
| 1145 EXPECT_EQ( | 1146 EXPECT_EQ( |
| 1146 JoinActions( | 1147 JoinActions( |
| 1147 kGrab, | 1148 kGrab, |
| 1148 kInitXRandR, | 1149 kInitXRandR, |
| 1149 GetAddOutputModeAction(outputs_[0].output, kSmallModeId).c_str(), | 1150 GetAddOutputModeAction(outputs_[0].output, kSmallModeId).c_str(), |
| 1150 GetFramebufferAction(kSmallModeWidth, | 1151 GetFramebufferAction(kSmallModeWidth, |
| 1151 kSmallModeHeight, | 1152 kSmallModeHeight, |
| 1152 outputs_[0].crtc, | 1153 outputs_[0].crtc, |
| 1153 outputs_[1].crtc).c_str(), | 1154 outputs_[1].crtc).c_str(), |
| 1154 GetCrtcAction( | 1155 GetCrtcAction( |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1184 | 1185 |
| 1185 OutputConfigurator::OutputProtectionClientId id = | 1186 OutputConfigurator::OutputProtectionClientId id = |
| 1186 configurator_.RegisterOutputProtectionClient(); | 1187 configurator_.RegisterOutputProtectionClient(); |
| 1187 EXPECT_NE(0u, id); | 1188 EXPECT_NE(0u, id); |
| 1188 | 1189 |
| 1189 // One output. | 1190 // One output. |
| 1190 UpdateOutputs(1, true); | 1191 UpdateOutputs(1, true); |
| 1191 EXPECT_NE(kNoActions, log_->GetActionsAndClear()); | 1192 EXPECT_NE(kNoActions, log_->GetActionsAndClear()); |
| 1192 uint32_t link_mask = 0; | 1193 uint32_t link_mask = 0; |
| 1193 uint32_t protection_mask = 0; | 1194 uint32_t protection_mask = 0; |
| 1194 EXPECT_TRUE(configurator_.QueryOutputProtectionStatus(id, | 1195 EXPECT_TRUE(configurator_.QueryOutputProtectionStatus( |
| 1195 outputs_[0].display_id, | 1196 id, outputs_[0].display_id, &link_mask, &protection_mask)); |
| 1196 &link_mask, | 1197 EXPECT_EQ(static_cast<uint32_t>(OUTPUT_TYPE_INTERNAL), link_mask); |
| 1197 &protection_mask)); | 1198 EXPECT_EQ(static_cast<uint32_t>(OUTPUT_PROTECTION_METHOD_NONE), |
| 1198 EXPECT_EQ(static_cast<uint32_t>(ui::OUTPUT_TYPE_INTERNAL), link_mask); | |
| 1199 EXPECT_EQ(static_cast<uint32_t>(ui::OUTPUT_PROTECTION_METHOD_NONE), | |
| 1200 protection_mask); | 1199 protection_mask); |
| 1201 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1200 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1202 | 1201 |
| 1203 // Two outputs. | 1202 // Two outputs. |
| 1204 UpdateOutputs(2, true); | 1203 UpdateOutputs(2, true); |
| 1205 EXPECT_NE(kNoActions, log_->GetActionsAndClear()); | 1204 EXPECT_NE(kNoActions, log_->GetActionsAndClear()); |
| 1206 EXPECT_TRUE(configurator_.QueryOutputProtectionStatus(id, | 1205 EXPECT_TRUE(configurator_.QueryOutputProtectionStatus( |
| 1207 outputs_[1].display_id, | 1206 id, outputs_[1].display_id, &link_mask, &protection_mask)); |
| 1208 &link_mask, | 1207 EXPECT_EQ(static_cast<uint32_t>(OUTPUT_TYPE_HDMI), link_mask); |
| 1209 &protection_mask)); | 1208 EXPECT_EQ(static_cast<uint32_t>(OUTPUT_PROTECTION_METHOD_NONE), |
| 1210 EXPECT_EQ(static_cast<uint32_t>(ui::OUTPUT_TYPE_HDMI), link_mask); | |
| 1211 EXPECT_EQ(static_cast<uint32_t>(ui::OUTPUT_PROTECTION_METHOD_NONE), | |
| 1212 protection_mask); | 1209 protection_mask); |
| 1213 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1210 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1214 | 1211 |
| 1215 EXPECT_TRUE(configurator_.EnableOutputProtection( | 1212 EXPECT_TRUE(configurator_.EnableOutputProtection( |
| 1216 id, outputs_[1].display_id, ui::OUTPUT_PROTECTION_METHOD_HDCP)); | 1213 id, outputs_[1].display_id, OUTPUT_PROTECTION_METHOD_HDCP)); |
| 1217 EXPECT_EQ(GetSetHDCPStateAction(outputs_[1].output, ui::HDCP_STATE_DESIRED), | 1214 EXPECT_EQ(GetSetHDCPStateAction(outputs_[1].output, HDCP_STATE_DESIRED), |
| 1218 log_->GetActionsAndClear()); | 1215 log_->GetActionsAndClear()); |
| 1219 | 1216 |
| 1220 // Enable protection. | 1217 // Enable protection. |
| 1221 native_display_delegate_->set_hdcp_state(ui::HDCP_STATE_ENABLED); | 1218 native_display_delegate_->set_hdcp_state(HDCP_STATE_ENABLED); |
| 1222 EXPECT_TRUE(configurator_.QueryOutputProtectionStatus(id, | 1219 EXPECT_TRUE(configurator_.QueryOutputProtectionStatus( |
| 1223 outputs_[1].display_id, | 1220 id, outputs_[1].display_id, &link_mask, &protection_mask)); |
| 1224 &link_mask, | 1221 EXPECT_EQ(static_cast<uint32_t>(OUTPUT_TYPE_HDMI), link_mask); |
| 1225 &protection_mask)); | 1222 EXPECT_EQ(static_cast<uint32_t>(OUTPUT_PROTECTION_METHOD_HDCP), |
| 1226 EXPECT_EQ(static_cast<uint32_t>(ui::OUTPUT_TYPE_HDMI), link_mask); | |
| 1227 EXPECT_EQ(static_cast<uint32_t>(ui::OUTPUT_PROTECTION_METHOD_HDCP), | |
| 1228 protection_mask); | 1223 protection_mask); |
| 1229 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1224 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1230 | 1225 |
| 1231 // Protections should be disabled after unregister. | 1226 // Protections should be disabled after unregister. |
| 1232 configurator_.UnregisterOutputProtectionClient(id); | 1227 configurator_.UnregisterOutputProtectionClient(id); |
| 1233 EXPECT_EQ(GetSetHDCPStateAction(outputs_[1].output, ui::HDCP_STATE_UNDESIRED), | 1228 EXPECT_EQ(GetSetHDCPStateAction(outputs_[1].output, HDCP_STATE_UNDESIRED), |
| 1234 log_->GetActionsAndClear()); | 1229 log_->GetActionsAndClear()); |
| 1235 } | 1230 } |
| 1236 | 1231 |
| 1237 TEST_F(OutputConfiguratorTest, OutputProtectionTwoClients) { | 1232 TEST_F(OutputConfiguratorTest, OutputProtectionTwoClients) { |
| 1238 OutputConfigurator::OutputProtectionClientId client1 = | 1233 OutputConfigurator::OutputProtectionClientId client1 = |
| 1239 configurator_.RegisterOutputProtectionClient(); | 1234 configurator_.RegisterOutputProtectionClient(); |
| 1240 OutputConfigurator::OutputProtectionClientId client2 = | 1235 OutputConfigurator::OutputProtectionClientId client2 = |
| 1241 configurator_.RegisterOutputProtectionClient(); | 1236 configurator_.RegisterOutputProtectionClient(); |
| 1242 EXPECT_NE(client1, client2); | 1237 EXPECT_NE(client1, client2); |
| 1243 | 1238 |
| 1244 configurator_.Init(false); | 1239 configurator_.Init(false); |
| 1245 configurator_.ForceInitialConfigure(0); | 1240 configurator_.ForceInitialConfigure(0); |
| 1246 UpdateOutputs(2, true); | 1241 UpdateOutputs(2, true); |
| 1247 EXPECT_NE(kNoActions, log_->GetActionsAndClear()); | 1242 EXPECT_NE(kNoActions, log_->GetActionsAndClear()); |
| 1248 | 1243 |
| 1249 // Clients never know state enableness for methods that they didn't request. | 1244 // Clients never know state enableness for methods that they didn't request. |
| 1250 EXPECT_TRUE(configurator_.EnableOutputProtection( | 1245 EXPECT_TRUE(configurator_.EnableOutputProtection( |
| 1251 client1, outputs_[1].display_id, ui::OUTPUT_PROTECTION_METHOD_HDCP)); | 1246 client1, outputs_[1].display_id, OUTPUT_PROTECTION_METHOD_HDCP)); |
| 1252 EXPECT_EQ( | 1247 EXPECT_EQ( |
| 1253 GetSetHDCPStateAction(outputs_[1].output, ui::HDCP_STATE_DESIRED).c_str(), | 1248 GetSetHDCPStateAction(outputs_[1].output, HDCP_STATE_DESIRED).c_str(), |
| 1254 log_->GetActionsAndClear()); | 1249 log_->GetActionsAndClear()); |
| 1255 native_display_delegate_->set_hdcp_state(ui::HDCP_STATE_ENABLED); | 1250 native_display_delegate_->set_hdcp_state(HDCP_STATE_ENABLED); |
| 1256 | 1251 |
| 1257 uint32_t link_mask = 0; | 1252 uint32_t link_mask = 0; |
| 1258 uint32_t protection_mask = 0; | 1253 uint32_t protection_mask = 0; |
| 1259 EXPECT_TRUE(configurator_.QueryOutputProtectionStatus(client1, | 1254 EXPECT_TRUE(configurator_.QueryOutputProtectionStatus( |
| 1260 outputs_[1].display_id, | 1255 client1, outputs_[1].display_id, &link_mask, &protection_mask)); |
| 1261 &link_mask, | 1256 EXPECT_EQ(static_cast<uint32_t>(OUTPUT_TYPE_HDMI), link_mask); |
| 1262 &protection_mask)); | 1257 EXPECT_EQ(OUTPUT_PROTECTION_METHOD_HDCP, protection_mask); |
| 1263 EXPECT_EQ(static_cast<uint32_t>(ui::OUTPUT_TYPE_HDMI), link_mask); | |
| 1264 EXPECT_EQ(ui::OUTPUT_PROTECTION_METHOD_HDCP, protection_mask); | |
| 1265 | 1258 |
| 1266 EXPECT_TRUE(configurator_.QueryOutputProtectionStatus(client2, | 1259 EXPECT_TRUE(configurator_.QueryOutputProtectionStatus( |
| 1267 outputs_[1].display_id, | 1260 client2, outputs_[1].display_id, &link_mask, &protection_mask)); |
| 1268 &link_mask, | 1261 EXPECT_EQ(static_cast<uint32_t>(OUTPUT_TYPE_HDMI), link_mask); |
| 1269 &protection_mask)); | 1262 EXPECT_EQ(OUTPUT_PROTECTION_METHOD_NONE, protection_mask); |
| 1270 EXPECT_EQ(static_cast<uint32_t>(ui::OUTPUT_TYPE_HDMI), link_mask); | |
| 1271 EXPECT_EQ(ui::OUTPUT_PROTECTION_METHOD_NONE, protection_mask); | |
| 1272 | 1263 |
| 1273 // Protections will be disabled only if no more clients request them. | 1264 // Protections will be disabled only if no more clients request them. |
| 1274 EXPECT_TRUE(configurator_.EnableOutputProtection( | 1265 EXPECT_TRUE(configurator_.EnableOutputProtection( |
| 1275 client2, outputs_[1].display_id, ui::OUTPUT_PROTECTION_METHOD_NONE)); | 1266 client2, outputs_[1].display_id, OUTPUT_PROTECTION_METHOD_NONE)); |
| 1276 EXPECT_EQ( | 1267 EXPECT_EQ( |
| 1277 GetSetHDCPStateAction(outputs_[1].output, ui::HDCP_STATE_DESIRED).c_str(), | 1268 GetSetHDCPStateAction(outputs_[1].output, HDCP_STATE_DESIRED).c_str(), |
| 1278 log_->GetActionsAndClear()); | 1269 log_->GetActionsAndClear()); |
| 1279 EXPECT_TRUE(configurator_.EnableOutputProtection( | 1270 EXPECT_TRUE(configurator_.EnableOutputProtection( |
| 1280 client1, outputs_[1].display_id, ui::OUTPUT_PROTECTION_METHOD_NONE)); | 1271 client1, outputs_[1].display_id, OUTPUT_PROTECTION_METHOD_NONE)); |
| 1281 EXPECT_EQ(GetSetHDCPStateAction(outputs_[1].output, ui::HDCP_STATE_UNDESIRED) | 1272 EXPECT_EQ( |
| 1282 .c_str(), | 1273 GetSetHDCPStateAction(outputs_[1].output, HDCP_STATE_UNDESIRED).c_str(), |
| 1283 log_->GetActionsAndClear()); | 1274 log_->GetActionsAndClear()); |
| 1284 } | 1275 } |
| 1285 | 1276 |
| 1286 TEST_F(OutputConfiguratorTest, CTMForMultiScreens) { | 1277 TEST_F(OutputConfiguratorTest, CTMForMultiScreens) { |
| 1287 outputs_[0].touch_device_id = 1; | 1278 outputs_[0].touch_device_id = 1; |
| 1288 outputs_[1].touch_device_id = 2; | 1279 outputs_[1].touch_device_id = 2; |
| 1289 | 1280 |
| 1290 UpdateOutputs(2, false); | 1281 UpdateOutputs(2, false); |
| 1291 configurator_.Init(false); | 1282 configurator_.Init(false); |
| 1292 state_controller_.set_state(ui::OUTPUT_STATE_DUAL_EXTENDED); | 1283 state_controller_.set_state(OUTPUT_STATE_DUAL_EXTENDED); |
| 1293 configurator_.ForceInitialConfigure(0); | 1284 configurator_.ForceInitialConfigure(0); |
| 1294 | 1285 |
| 1295 const int kDualHeight = | 1286 const int kDualHeight = |
| 1296 kSmallModeHeight + OutputConfigurator::kVerticalGap + kBigModeHeight; | 1287 kSmallModeHeight + OutputConfigurator::kVerticalGap + kBigModeHeight; |
| 1297 const int kDualWidth = kBigModeWidth; | 1288 const int kDualWidth = kBigModeWidth; |
| 1298 | 1289 |
| 1299 OutputConfigurator::CoordinateTransformation ctm1 = | 1290 OutputConfigurator::CoordinateTransformation ctm1 = |
| 1300 touchscreen_delegate_->GetCTM(1); | 1291 touchscreen_delegate_->GetCTM(1); |
| 1301 OutputConfigurator::CoordinateTransformation ctm2 = | 1292 OutputConfigurator::CoordinateTransformation ctm2 = |
| 1302 touchscreen_delegate_->GetCTM(2); | 1293 touchscreen_delegate_->GetCTM(2); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1322 // also the mode that we are requesting the output_configurator | 1313 // also the mode that we are requesting the output_configurator |
| 1323 // to choose. The test will be setup so that this mode will fail | 1314 // to choose. The test will be setup so that this mode will fail |
| 1324 // and it will have to choose the next best option. | 1315 // and it will have to choose the next best option. |
| 1325 const int kFirstMode = 11; | 1316 const int kFirstMode = 11; |
| 1326 | 1317 |
| 1327 // Give the mode_info lists a few reasonable modes. | 1318 // Give the mode_info lists a few reasonable modes. |
| 1328 for (unsigned int i = 0; i < arraysize(outputs_); i++) { | 1319 for (unsigned int i = 0; i < arraysize(outputs_); i++) { |
| 1329 outputs_[i].mode_infos.clear(); | 1320 outputs_[i].mode_infos.clear(); |
| 1330 | 1321 |
| 1331 int current_mode = kFirstMode; | 1322 int current_mode = kFirstMode; |
| 1332 outputs_[i].mode_infos[current_mode++] = OutputConfigurator::ModeInfo( | 1323 outputs_[i].mode_infos[current_mode++] = |
| 1333 2560, 1600, false, 60.0); | 1324 OutputConfigurator::ModeInfo(2560, 1600, false, 60.0); |
| 1334 outputs_[i].mode_infos[current_mode++] = OutputConfigurator::ModeInfo( | 1325 outputs_[i].mode_infos[current_mode++] = |
| 1335 1024, 768, false, 60.0); | 1326 OutputConfigurator::ModeInfo(1024, 768, false, 60.0); |
| 1336 outputs_[i].mode_infos[current_mode++] = OutputConfigurator::ModeInfo( | 1327 outputs_[i].mode_infos[current_mode++] = |
| 1337 1280, 720, false, 60.0); | 1328 OutputConfigurator::ModeInfo(1280, 720, false, 60.0); |
| 1338 outputs_[i].mode_infos[current_mode++] = OutputConfigurator::ModeInfo( | 1329 outputs_[i].mode_infos[current_mode++] = |
| 1339 1920, 1080, false, 60.0); | 1330 OutputConfigurator::ModeInfo(1920, 1080, false, 60.0); |
| 1340 outputs_[i].mode_infos[current_mode++] = OutputConfigurator::ModeInfo( | 1331 outputs_[i].mode_infos[current_mode++] = |
| 1341 1920, 1080, false, 40.0); | 1332 OutputConfigurator::ModeInfo(1920, 1080, false, 40.0); |
| 1342 | 1333 |
| 1343 outputs_[i].current_mode = kFirstMode; | 1334 outputs_[i].current_mode = kFirstMode; |
| 1344 outputs_[i].native_mode = kFirstMode; | 1335 outputs_[i].native_mode = kFirstMode; |
| 1345 } | 1336 } |
| 1346 | 1337 |
| 1347 configurator_.Init(false); | 1338 configurator_.Init(false); |
| 1348 | 1339 |
| 1349 // First test simply fails in OUTPUT_STATE_SINGLE mode. This is probably | 1340 // First test simply fails in OUTPUT_STATE_SINGLE mode. This is probably |
| 1350 // unrealistic but the want to make sure any assumptions don't | 1341 // unrealistic but the want to make sure any assumptions don't |
| 1351 // creep in. | 1342 // creep in. |
| 1352 native_display_delegate_->set_max_configurable_pixels( | 1343 native_display_delegate_->set_max_configurable_pixels( |
| 1353 outputs_[0].mode_infos[kFirstMode + 2].width * | 1344 outputs_[0].mode_infos[kFirstMode + 2].width * |
| 1354 outputs_[0].mode_infos[kFirstMode + 2].height); | 1345 outputs_[0].mode_infos[kFirstMode + 2].height); |
| 1355 state_controller_.set_state(ui::OUTPUT_STATE_SINGLE); | 1346 state_controller_.set_state(OUTPUT_STATE_SINGLE); |
| 1356 UpdateOutputs(1, true); | 1347 UpdateOutputs(1, true); |
| 1357 | 1348 |
| 1358 EXPECT_EQ( | 1349 EXPECT_EQ( |
| 1359 JoinActions( | 1350 JoinActions( |
| 1360 kGrab, | 1351 kGrab, |
| 1361 GetFramebufferAction(2560, 1600, outputs_[0].crtc, 0).c_str(), | 1352 GetFramebufferAction(2560, 1600, outputs_[0].crtc, 0).c_str(), |
| 1362 GetCrtcAction(outputs_[0].crtc, 0, 0, kFirstMode, outputs_[0].output) | 1353 GetCrtcAction(outputs_[0].crtc, 0, 0, kFirstMode, outputs_[0].output) |
| 1363 .c_str(), | 1354 .c_str(), |
| 1364 GetCrtcAction( | 1355 GetCrtcAction( |
| 1365 outputs_[0].crtc, 0, 0, kFirstMode + 3, outputs_[0].output) | 1356 outputs_[0].crtc, 0, 0, kFirstMode + 3, outputs_[0].output) |
| 1366 .c_str(), | 1357 .c_str(), |
| 1367 GetCrtcAction( | 1358 GetCrtcAction( |
| 1368 outputs_[0].crtc, 0, 0, kFirstMode + 2, outputs_[0].output) | 1359 outputs_[0].crtc, 0, 0, kFirstMode + 2, outputs_[0].output) |
| 1369 .c_str(), | 1360 .c_str(), |
| 1370 kUngrab, | 1361 kUngrab, |
| 1371 NULL), | 1362 NULL), |
| 1372 log_->GetActionsAndClear()); | 1363 log_->GetActionsAndClear()); |
| 1373 | 1364 |
| 1374 // This test should attempt to configure a mirror mode that will not succeed | 1365 // This test should attempt to configure a mirror mode that will not succeed |
| 1375 // and should end up in extended mode. | 1366 // and should end up in extended mode. |
| 1376 native_display_delegate_->set_max_configurable_pixels( | 1367 native_display_delegate_->set_max_configurable_pixels( |
| 1377 outputs_[0].mode_infos[kFirstMode + 3].width * | 1368 outputs_[0].mode_infos[kFirstMode + 3].width * |
| 1378 outputs_[0].mode_infos[kFirstMode + 3].height); | 1369 outputs_[0].mode_infos[kFirstMode + 3].height); |
| 1379 state_controller_.set_state(ui::OUTPUT_STATE_DUAL_MIRROR); | 1370 state_controller_.set_state(OUTPUT_STATE_DUAL_MIRROR); |
| 1380 UpdateOutputs(2, true); | 1371 UpdateOutputs(2, true); |
| 1381 | 1372 |
| 1382 EXPECT_EQ( | 1373 EXPECT_EQ( |
| 1383 JoinActions( | 1374 JoinActions( |
| 1384 kGrab, | 1375 kGrab, |
| 1385 GetFramebufferAction(outputs_[0].mode_infos[kFirstMode].width, | 1376 GetFramebufferAction(outputs_[0].mode_infos[kFirstMode].width, |
| 1386 outputs_[0].mode_infos[kFirstMode].height, | 1377 outputs_[0].mode_infos[kFirstMode].height, |
| 1387 outputs_[0].crtc, | 1378 outputs_[0].crtc, |
| 1388 outputs_[1].crtc).c_str(), | 1379 outputs_[1].crtc).c_str(), |
| 1389 GetCrtcAction(outputs_[0].crtc, 0, 0, kFirstMode, outputs_[0].output) | 1380 GetCrtcAction(outputs_[0].crtc, 0, 0, kFirstMode, outputs_[0].output) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1424 0, | 1415 0, |
| 1425 outputs_[1].mode_infos[kFirstMode].height + | 1416 outputs_[1].mode_infos[kFirstMode].height + |
| 1426 OutputConfigurator::kVerticalGap, | 1417 OutputConfigurator::kVerticalGap, |
| 1427 kFirstMode + 3, | 1418 kFirstMode + 3, |
| 1428 outputs_[1].output).c_str(), | 1419 outputs_[1].output).c_str(), |
| 1429 kUngrab, | 1420 kUngrab, |
| 1430 NULL), | 1421 NULL), |
| 1431 log_->GetActionsAndClear()); | 1422 log_->GetActionsAndClear()); |
| 1432 } | 1423 } |
| 1433 | 1424 |
| 1434 } // namespace chromeos | 1425 } // namespace ui |
| OLD | NEW |