| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "ui/display/chromeos/display_configurator.h" | 5 #include "ui/display/chromeos/display_configurator.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "ui/display/chromeos/test/action_logger_util.h" | 16 #include "ui/display/chromeos/test/action_logger_util.h" |
| 17 #include "ui/display/chromeos/test/test_display_snapshot.h" | |
| 18 #include "ui/display/chromeos/test/test_native_display_delegate.h" | 17 #include "ui/display/chromeos/test/test_native_display_delegate.h" |
| 18 #include "ui/display/fake_display_snapshot.h" |
| 19 #include "ui/display/util/display_util.h" | 19 #include "ui/display/util/display_util.h" |
| 20 | 20 |
| 21 namespace ui { | 21 namespace ui { |
| 22 namespace test { | 22 namespace test { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 int64_t kDisplayIds[3] = {123, 456, 789}; |
| 27 |
| 28 std::unique_ptr<ui::DisplayMode> MakeDisplayMode(int width, |
| 29 int height, |
| 30 bool is_interlaced, |
| 31 float refresh_rate) { |
| 32 return base::MakeUnique<ui::DisplayMode>(gfx::Size(width, height), |
| 33 is_interlaced, refresh_rate); |
| 34 } |
| 35 |
| 26 class TestObserver : public DisplayConfigurator::Observer { | 36 class TestObserver : public DisplayConfigurator::Observer { |
| 27 public: | 37 public: |
| 28 explicit TestObserver(DisplayConfigurator* configurator) | 38 explicit TestObserver(DisplayConfigurator* configurator) |
| 29 : configurator_(configurator) { | 39 : configurator_(configurator) { |
| 30 Reset(); | 40 Reset(); |
| 31 configurator_->AddObserver(this); | 41 configurator_->AddObserver(this); |
| 32 } | 42 } |
| 33 ~TestObserver() override { configurator_->RemoveObserver(this); } | 43 ~TestObserver() override { configurator_->RemoveObserver(this); } |
| 34 | 44 |
| 35 int num_changes() const { return num_changes_; } | 45 int num_changes() const { return num_changes_; } |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 void SetUp() override { | 152 void SetUp() override { |
| 143 log_.reset(new ActionLogger()); | 153 log_.reset(new ActionLogger()); |
| 144 | 154 |
| 145 native_display_delegate_ = new TestNativeDisplayDelegate(log_.get()); | 155 native_display_delegate_ = new TestNativeDisplayDelegate(log_.get()); |
| 146 configurator_.SetDelegateForTesting( | 156 configurator_.SetDelegateForTesting( |
| 147 std::unique_ptr<NativeDisplayDelegate>(native_display_delegate_)); | 157 std::unique_ptr<NativeDisplayDelegate>(native_display_delegate_)); |
| 148 | 158 |
| 149 configurator_.set_state_controller(&state_controller_); | 159 configurator_.set_state_controller(&state_controller_); |
| 150 configurator_.set_mirroring_controller(&mirroring_controller_); | 160 configurator_.set_mirroring_controller(&mirroring_controller_); |
| 151 | 161 |
| 152 std::vector<std::unique_ptr<const DisplayMode>> modes; | 162 outputs_[0] = display::FakeDisplaySnapshot::Builder() |
| 153 modes.push_back(small_mode_.Clone()); | 163 .SetId(kDisplayIds[0]) |
| 164 .SetNativeMode(small_mode_.Clone()) |
| 165 .SetCurrentMode(small_mode_.Clone()) |
| 166 .SetType(DISPLAY_CONNECTION_TYPE_INTERNAL) |
| 167 .SetIsAspectPerservingScaling(true) |
| 168 .Build(); |
| 154 | 169 |
| 155 TestDisplaySnapshot* o = &outputs_[0]; | 170 outputs_[1] = display::FakeDisplaySnapshot::Builder() |
| 156 o->set_current_mode(modes.front().get()); | 171 .SetId(kDisplayIds[1]) |
| 157 o->set_native_mode(modes.front().get()); | 172 .SetNativeMode(big_mode_.Clone()) |
| 158 o->set_modes(std::move(modes)); | 173 .SetCurrentMode(big_mode_.Clone()) |
| 159 o->set_type(DISPLAY_CONNECTION_TYPE_INTERNAL); | 174 .AddMode(small_mode_.Clone()) |
| 160 o->set_is_aspect_preserving_scaling(true); | 175 .SetType(DISPLAY_CONNECTION_TYPE_HDMI) |
| 161 o->set_display_id(123); | 176 .SetIsAspectPerservingScaling(true) |
| 177 .Build(); |
| 162 | 178 |
| 163 modes.clear(); | 179 outputs_[2] = display::FakeDisplaySnapshot::Builder() |
| 164 modes.push_back(small_mode_.Clone()); | 180 .SetId(kDisplayIds[2]) |
| 165 modes.push_back(big_mode_.Clone()); | 181 .SetNativeMode(small_mode_.Clone()) |
| 166 o = &outputs_[1]; | 182 .SetCurrentMode(small_mode_.Clone()) |
| 167 o->set_current_mode(modes.back().get()); | 183 .SetType(DISPLAY_CONNECTION_TYPE_HDMI) |
| 168 o->set_native_mode(modes.back().get()); | 184 .SetIsAspectPerservingScaling(true) |
| 169 o->set_modes(std::move(modes)); | 185 .Build(); |
| 170 o->set_type(DISPLAY_CONNECTION_TYPE_HDMI); | |
| 171 o->set_is_aspect_preserving_scaling(true); | |
| 172 o->set_display_id(456); | |
| 173 | |
| 174 modes.clear(); | |
| 175 modes.push_back(small_mode_.Clone()); | |
| 176 o = &outputs_[2]; | |
| 177 o->set_current_mode(modes.back().get()); | |
| 178 o->set_native_mode(modes.back().get()); | |
| 179 o->set_modes(std::move(modes)); | |
| 180 o->set_type(DISPLAY_CONNECTION_TYPE_HDMI); | |
| 181 o->set_is_aspect_preserving_scaling(true); | |
| 182 o->set_display_id(789); | |
| 183 | 186 |
| 184 UpdateOutputs(2, false); | 187 UpdateOutputs(2, false); |
| 185 } | 188 } |
| 186 | 189 |
| 187 void OnConfiguredCallback(bool status) { | 190 void OnConfiguredCallback(bool status) { |
| 188 callback_result_ = (status ? CALLBACK_SUCCESS : CALLBACK_FAILURE); | 191 callback_result_ = (status ? CALLBACK_SUCCESS : CALLBACK_FAILURE); |
| 189 } | 192 } |
| 190 | 193 |
| 191 void OnDisplayControlUpdated(bool status) { | 194 void OnDisplayControlUpdated(bool status) { |
| 192 display_control_result_ = (status ? CALLBACK_SUCCESS : CALLBACK_FAILURE); | 195 display_control_result_ = (status ? CALLBACK_SUCCESS : CALLBACK_FAILURE); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 210 protected: | 213 protected: |
| 211 // Configures |native_display_delegate_| to return the first |num_outputs| | 214 // Configures |native_display_delegate_| to return the first |num_outputs| |
| 212 // entries from | 215 // entries from |
| 213 // |outputs_|. If |send_events| is true, also sends screen-change and | 216 // |outputs_|. If |send_events| is true, also sends screen-change and |
| 214 // output-change events to |configurator_| and triggers the configure | 217 // output-change events to |configurator_| and triggers the configure |
| 215 // timeout if one was scheduled. | 218 // timeout if one was scheduled. |
| 216 void UpdateOutputs(size_t num_outputs, bool send_events) { | 219 void UpdateOutputs(size_t num_outputs, bool send_events) { |
| 217 ASSERT_LE(num_outputs, arraysize(outputs_)); | 220 ASSERT_LE(num_outputs, arraysize(outputs_)); |
| 218 std::vector<DisplaySnapshot*> outputs; | 221 std::vector<DisplaySnapshot*> outputs; |
| 219 for (size_t i = 0; i < num_outputs; ++i) | 222 for (size_t i = 0; i < num_outputs; ++i) |
| 220 outputs.push_back(&outputs_[i]); | 223 outputs.push_back(outputs_[i].get()); |
| 221 native_display_delegate_->set_outputs(outputs); | 224 native_display_delegate_->set_outputs(outputs); |
| 222 | 225 |
| 223 if (send_events) { | 226 if (send_events) { |
| 224 configurator_.OnConfigurationChanged(); | 227 configurator_.OnConfigurationChanged(); |
| 225 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); | 228 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); |
| 226 } | 229 } |
| 227 } | 230 } |
| 228 | 231 |
| 229 void Init(bool panel_fitting_enabled) { | 232 void Init(bool panel_fitting_enabled) { |
| 230 configurator_.Init(nullptr, panel_fitting_enabled); | 233 configurator_.Init(nullptr, panel_fitting_enabled); |
| 231 } | 234 } |
| 232 | 235 |
| 233 // Initializes |configurator_| with a single internal display. | 236 // Initializes |configurator_| with a single internal display. |
| 234 void InitWithSingleOutput() { | 237 void InitWithSingleOutput() { |
| 235 UpdateOutputs(1, false); | 238 UpdateOutputs(1, false); |
| 236 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 239 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 237 configurator_.Init(nullptr, false); | 240 configurator_.Init(nullptr, false); |
| 238 | 241 |
| 239 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 242 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 240 configurator_.ForceInitialConfigure(0); | 243 configurator_.ForceInitialConfigure(0); |
| 241 EXPECT_EQ(JoinActions(kInitXRandR, kGrab, | 244 EXPECT_EQ( |
| 242 GetFramebufferAction(small_mode_.size(), &outputs_[0], | 245 JoinActions( |
| 243 NULL).c_str(), | 246 kInitXRandR, kGrab, |
| 244 GetCrtcAction(outputs_[0], &small_mode_, | 247 GetFramebufferAction(small_mode_.size(), outputs_[0].get(), nullptr) |
| 245 gfx::Point(0, 0)).c_str(), | 248 .c_str(), |
| 246 kForceDPMS, kUngrab, NULL), | 249 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 247 log_->GetActionsAndClear()); | 250 kForceDPMS, kUngrab, nullptr), |
| 251 log_->GetActionsAndClear()); |
| 248 } | 252 } |
| 249 | 253 |
| 250 CallbackResult PopCallbackResult() { | 254 CallbackResult PopCallbackResult() { |
| 251 CallbackResult result = callback_result_; | 255 CallbackResult result = callback_result_; |
| 252 callback_result_ = CALLBACK_NOT_CALLED; | 256 callback_result_ = CALLBACK_NOT_CALLED; |
| 253 return result; | 257 return result; |
| 254 } | 258 } |
| 255 | 259 |
| 256 CallbackResult PopDisplayControlResult() { | 260 CallbackResult PopDisplayControlResult() { |
| 257 CallbackResult result = display_control_result_; | 261 CallbackResult result = display_control_result_; |
| 258 display_control_result_ = CALLBACK_NOT_CALLED; | 262 display_control_result_ = CALLBACK_NOT_CALLED; |
| 259 return result; | 263 return result; |
| 260 } | 264 } |
| 261 | 265 |
| 262 base::MessageLoop message_loop_; | 266 base::MessageLoop message_loop_; |
| 263 TestStateController state_controller_; | 267 TestStateController state_controller_; |
| 264 TestMirroringController mirroring_controller_; | 268 TestMirroringController mirroring_controller_; |
| 265 DisplayConfigurator configurator_; | 269 DisplayConfigurator configurator_; |
| 266 TestObserver observer_; | 270 TestObserver observer_; |
| 267 std::unique_ptr<ActionLogger> log_; | 271 std::unique_ptr<ActionLogger> log_; |
| 268 TestNativeDisplayDelegate* native_display_delegate_; // not owned | 272 TestNativeDisplayDelegate* native_display_delegate_; // not owned |
| 269 DisplayConfigurator::TestApi test_api_; | 273 DisplayConfigurator::TestApi test_api_; |
| 270 | 274 |
| 271 bool enable_content_protection_status_; | 275 bool enable_content_protection_status_; |
| 272 int enable_content_protection_call_count_; | 276 int enable_content_protection_call_count_; |
| 273 DisplayConfigurator::QueryProtectionResponse | 277 DisplayConfigurator::QueryProtectionResponse |
| 274 query_content_protection_response_; | 278 query_content_protection_response_; |
| 275 int query_content_protection_call_count_; | 279 int query_content_protection_call_count_; |
| 276 | 280 |
| 277 TestDisplaySnapshot outputs_[3]; | 281 std::unique_ptr<DisplaySnapshot> outputs_[3]; |
| 278 | 282 |
| 279 CallbackResult callback_result_; | 283 CallbackResult callback_result_; |
| 280 CallbackResult display_control_result_; | 284 CallbackResult display_control_result_; |
| 281 | 285 |
| 282 private: | 286 private: |
| 283 DISALLOW_COPY_AND_ASSIGN(DisplayConfiguratorTest); | 287 DISALLOW_COPY_AND_ASSIGN(DisplayConfiguratorTest); |
| 284 }; | 288 }; |
| 285 | 289 |
| 286 } // namespace | 290 } // namespace |
| 287 | 291 |
| 288 TEST_F(DisplayConfiguratorTest, FindDisplayModeMatchingSize) { | 292 TEST_F(DisplayConfiguratorTest, FindDisplayModeMatchingSize) { |
| 289 std::vector<const DisplayMode*> modes; | 293 std::unique_ptr<ui::DisplaySnapshot> output = |
| 294 display::FakeDisplaySnapshot::Builder() |
| 295 .SetId(kDisplayIds[0]) |
| 296 .AddMode(MakeDisplayMode(1920, 1200, false, 60.0)) |
| 297 .SetNativeMode(MakeDisplayMode(1920, 1200, false, 50.0)) |
| 298 // Different rates. |
| 299 .AddMode(MakeDisplayMode(1920, 1080, false, 30.0)) |
| 300 .AddMode(MakeDisplayMode(1920, 1080, false, 50.0)) |
| 301 .AddMode(MakeDisplayMode(1920, 1080, false, 40.0)) |
| 302 .AddMode(MakeDisplayMode(1920, 1080, false, 0.0)) |
| 303 // Interlaced vs non-interlaced. |
| 304 .AddMode(MakeDisplayMode(1280, 720, true, 60.0)) |
| 305 .AddMode(MakeDisplayMode(1280, 720, false, 40.0)) |
| 306 // Interlaced only. |
| 307 .AddMode(MakeDisplayMode(1024, 768, true, 0.0)) |
| 308 .AddMode(MakeDisplayMode(1024, 768, true, 40.0)) |
| 309 .AddMode(MakeDisplayMode(1024, 768, true, 60.0)) |
| 310 // Mixed. |
| 311 .AddMode(MakeDisplayMode(1024, 600, true, 60.0)) |
| 312 .AddMode(MakeDisplayMode(1024, 600, false, 40.0)) |
| 313 .AddMode(MakeDisplayMode(1024, 600, false, 50.0)) |
| 314 // Just one interlaced mode. |
| 315 .AddMode(MakeDisplayMode(640, 480, true, 60.0)) |
| 316 // Refresh rate not available. |
| 317 .AddMode(MakeDisplayMode(320, 200, false, 0.0)) |
| 318 .Build(); |
| 290 | 319 |
| 291 // Fields are width, height, interlaced, refresh rate. | 320 const std::vector<std::unique_ptr<const DisplayMode>>& modes = |
| 292 modes.push_back(new DisplayMode(gfx::Size(1920, 1200), false, 60.0)); | 321 output->modes(); |
| 293 DisplayMode* native_mode = | |
| 294 new DisplayMode(gfx::Size(1920, 1200), false, 50.0); | |
| 295 modes.push_back(native_mode); | |
| 296 // Different rates. | |
| 297 modes.push_back(new DisplayMode(gfx::Size(1920, 1080), false, 30.0)); | |
| 298 modes.push_back(new DisplayMode(gfx::Size(1920, 1080), false, 50.0)); | |
| 299 modes.push_back(new DisplayMode(gfx::Size(1920, 1080), false, 40.0)); | |
| 300 modes.push_back(new DisplayMode(gfx::Size(1920, 1080), false, 0.0)); | |
| 301 // Interlaced vs non-interlaced. | |
| 302 modes.push_back(new DisplayMode(gfx::Size(1280, 720), true, 60.0)); | |
| 303 modes.push_back(new DisplayMode(gfx::Size(1280, 720), false, 40.0)); | |
| 304 // Interlaced only. | |
| 305 modes.push_back(new DisplayMode(gfx::Size(1024, 768), true, 0.0)); | |
| 306 modes.push_back(new DisplayMode(gfx::Size(1024, 768), true, 40.0)); | |
| 307 modes.push_back(new DisplayMode(gfx::Size(1024, 768), true, 60.0)); | |
| 308 // Mixed. | |
| 309 modes.push_back(new DisplayMode(gfx::Size(1024, 600), true, 60.0)); | |
| 310 modes.push_back(new DisplayMode(gfx::Size(1024, 600), false, 40.0)); | |
| 311 modes.push_back(new DisplayMode(gfx::Size(1024, 600), false, 50.0)); | |
| 312 // Just one interlaced mode. | |
| 313 modes.push_back(new DisplayMode(gfx::Size(640, 480), true, 60.0)); | |
| 314 // Refresh rate not available. | |
| 315 modes.push_back(new DisplayMode(gfx::Size(320, 200), false, 0.0)); | |
| 316 | |
| 317 TestDisplaySnapshot output; | |
| 318 std::vector<std::unique_ptr<const DisplayMode>> tmp_modes; | |
| 319 for (const DisplayMode* mode : modes) | |
| 320 tmp_modes.push_back(base::WrapUnique(mode)); | |
| 321 output.set_modes(std::move(tmp_modes)); | |
| 322 output.set_native_mode(native_mode); | |
| 323 | 322 |
| 324 // Should pick native over highest refresh rate. | 323 // Should pick native over highest refresh rate. |
| 325 EXPECT_EQ(modes[1], | 324 EXPECT_EQ(modes[1].get(), DisplayConfigurator::FindDisplayModeMatchingSize( |
| 326 DisplayConfigurator::FindDisplayModeMatchingSize( | 325 *output, gfx::Size(1920, 1200))); |
| 327 output, gfx::Size(1920, 1200))); | |
| 328 | 326 |
| 329 // Should pick highest refresh rate. | 327 // Should pick highest refresh rate. |
| 330 EXPECT_EQ(modes[3], | 328 EXPECT_EQ(modes[3].get(), DisplayConfigurator::FindDisplayModeMatchingSize( |
| 331 DisplayConfigurator::FindDisplayModeMatchingSize( | 329 *output, gfx::Size(1920, 1080))); |
| 332 output, gfx::Size(1920, 1080))); | |
| 333 | 330 |
| 334 // Should pick non-interlaced mode. | 331 // Should pick non-interlaced mode. |
| 335 EXPECT_EQ(modes[7], | 332 EXPECT_EQ(modes[7].get(), DisplayConfigurator::FindDisplayModeMatchingSize( |
| 336 DisplayConfigurator::FindDisplayModeMatchingSize( | 333 *output, gfx::Size(1280, 720))); |
| 337 output, gfx::Size(1280, 720))); | |
| 338 | 334 |
| 339 // Interlaced only. Should pick one with the highest refresh rate in | 335 // Interlaced only. Should pick one with the highest refresh rate in |
| 340 // interlaced mode. | 336 // interlaced mode. |
| 341 EXPECT_EQ(modes[10], | 337 EXPECT_EQ(modes[10].get(), DisplayConfigurator::FindDisplayModeMatchingSize( |
| 342 DisplayConfigurator::FindDisplayModeMatchingSize( | 338 *output, gfx::Size(1024, 768))); |
| 343 output, gfx::Size(1024, 768))); | |
| 344 | 339 |
| 345 // Mixed: Should pick one with the highest refresh rate in | 340 // Mixed: Should pick one with the highest refresh rate in |
| 346 // interlaced mode. | 341 // interlaced mode. |
| 347 EXPECT_EQ(modes[13], | 342 EXPECT_EQ(modes[13].get(), DisplayConfigurator::FindDisplayModeMatchingSize( |
| 348 DisplayConfigurator::FindDisplayModeMatchingSize( | 343 *output, gfx::Size(1024, 600))); |
| 349 output, gfx::Size(1024, 600))); | |
| 350 | 344 |
| 351 // Just one interlaced mode. | 345 // Just one interlaced mode. |
| 352 EXPECT_EQ(modes[14], | 346 EXPECT_EQ(modes[14].get(), DisplayConfigurator::FindDisplayModeMatchingSize( |
| 353 DisplayConfigurator::FindDisplayModeMatchingSize( | 347 *output, gfx::Size(640, 480))); |
| 354 output, gfx::Size(640, 480))); | |
| 355 | 348 |
| 356 // Refresh rate not available. | 349 // Refresh rate not available. |
| 357 EXPECT_EQ(modes[15], | 350 EXPECT_EQ(modes[15].get(), DisplayConfigurator::FindDisplayModeMatchingSize( |
| 358 DisplayConfigurator::FindDisplayModeMatchingSize( | 351 *output, gfx::Size(320, 200))); |
| 359 output, gfx::Size(320, 200))); | |
| 360 | 352 |
| 361 // No mode found. | 353 // No mode found. |
| 362 EXPECT_EQ(NULL, | 354 EXPECT_EQ(nullptr, DisplayConfigurator::FindDisplayModeMatchingSize( |
| 363 DisplayConfigurator::FindDisplayModeMatchingSize( | 355 *output, gfx::Size(1440, 900))); |
| 364 output, gfx::Size(1440, 900))); | |
| 365 } | 356 } |
| 366 | 357 |
| 367 TEST_F(DisplayConfiguratorTest, EnableVirtualDisplay) { | 358 TEST_F(DisplayConfiguratorTest, EnableVirtualDisplay) { |
| 368 InitWithSingleOutput(); | 359 InitWithSingleOutput(); |
| 369 | 360 |
| 370 observer_.Reset(); | 361 observer_.Reset(); |
| 371 const DisplayConfigurator::DisplayStateList& cached = | 362 const DisplayConfigurator::DisplayStateList& cached = |
| 372 configurator_.cached_displays(); | 363 configurator_.cached_displays(); |
| 373 ASSERT_EQ(static_cast<size_t>(1u), cached.size()); | 364 ASSERT_EQ(static_cast<size_t>(1u), cached.size()); |
| 374 EXPECT_EQ(small_mode_.size(), cached[0]->current_mode()->size()); | 365 EXPECT_EQ(small_mode_.size(), cached[0]->current_mode()->size()); |
| 375 | 366 |
| 376 // Add virtual display. | 367 // Add virtual display. |
| 377 int64_t virtual_display_id = | 368 int64_t virtual_display_id = |
| 378 configurator_.AddVirtualDisplay(big_mode_.size()); | 369 configurator_.AddVirtualDisplay(big_mode_.size()); |
| 379 EXPECT_EQ(display::GenerateDisplayID(0x8000, 0x0, 1), virtual_display_id); | 370 EXPECT_EQ(display::GenerateDisplayID(0x8000, 0x0, 1), virtual_display_id); |
| 380 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); | 371 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 381 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, | 372 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |
| 382 configurator_.display_state()); | 373 configurator_.display_state()); |
| 383 | 374 |
| 384 // Virtual should not trigger addition of added crtc but does change FB | 375 // Virtual should not trigger addition of added crtc but does change FB |
| 385 // height. | 376 // height. |
| 386 const int kVirtualHeight = small_mode_.size().height() + | 377 const int kVirtualHeight = small_mode_.size().height() + |
| 387 DisplayConfigurator::kVerticalGap + | 378 DisplayConfigurator::kVerticalGap + |
| 388 big_mode_.size().height(); | 379 big_mode_.size().height(); |
| 389 EXPECT_EQ( | 380 EXPECT_EQ( |
| 390 JoinActions( | 381 JoinActions( |
| 391 kGrab, GetFramebufferAction( | 382 kGrab, GetFramebufferAction( |
| 392 gfx::Size(big_mode_.size().width(), kVirtualHeight), | 383 gfx::Size(big_mode_.size().width(), kVirtualHeight), |
| 393 &outputs_[0], nullptr) | 384 outputs_[0].get(), nullptr) |
| 394 .c_str(), | 385 .c_str(), |
| 395 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 386 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 396 kUngrab, nullptr), | 387 kUngrab, nullptr), |
| 397 log_->GetActionsAndClear()); | 388 log_->GetActionsAndClear()); |
| 398 EXPECT_EQ(1, observer_.num_changes()); | 389 EXPECT_EQ(1, observer_.num_changes()); |
| 399 ASSERT_EQ(static_cast<size_t>(2u), cached.size()); | 390 ASSERT_EQ(static_cast<size_t>(2u), cached.size()); |
| 400 EXPECT_EQ(small_mode_.size(), cached[0]->current_mode()->size()); | 391 EXPECT_EQ(small_mode_.size(), cached[0]->current_mode()->size()); |
| 401 EXPECT_EQ(big_mode_.size(), cached[1]->current_mode()->size()); | 392 EXPECT_EQ(big_mode_.size(), cached[1]->current_mode()->size()); |
| 402 EXPECT_EQ(virtual_display_id, cached[1]->display_id()); | 393 EXPECT_EQ(virtual_display_id, cached[1]->display_id()); |
| 403 | 394 |
| 404 // Remove virtual display. | 395 // Remove virtual display. |
| 405 observer_.Reset(); | 396 observer_.Reset(); |
| 406 EXPECT_TRUE(configurator_.RemoveVirtualDisplay(virtual_display_id)); | 397 EXPECT_TRUE(configurator_.RemoveVirtualDisplay(virtual_display_id)); |
| 407 EXPECT_EQ( | 398 EXPECT_EQ( |
| 408 JoinActions( | 399 JoinActions( |
| 409 kGrab, GetFramebufferAction(small_mode_.size(), &outputs_[0], nullptr) | 400 kGrab, |
| 410 .c_str(), | 401 GetFramebufferAction(small_mode_.size(), outputs_[0].get(), nullptr) |
| 411 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 402 .c_str(), |
| 403 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 412 kUngrab, nullptr), | 404 kUngrab, nullptr), |
| 413 log_->GetActionsAndClear()); | 405 log_->GetActionsAndClear()); |
| 414 EXPECT_EQ(1, observer_.num_changes()); | 406 EXPECT_EQ(1, observer_.num_changes()); |
| 415 ASSERT_EQ(static_cast<size_t>(1u), cached.size()); | 407 ASSERT_EQ(static_cast<size_t>(1u), cached.size()); |
| 416 EXPECT_EQ(small_mode_.size(), cached[0]->current_mode()->size()); | 408 EXPECT_EQ(small_mode_.size(), cached[0]->current_mode()->size()); |
| 417 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, configurator_.display_state()); | 409 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, configurator_.display_state()); |
| 418 } | 410 } |
| 419 | 411 |
| 420 TEST_F(DisplayConfiguratorTest, EnableTwoVirtualDisplays) { | 412 TEST_F(DisplayConfiguratorTest, EnableTwoVirtualDisplays) { |
| 421 InitWithSingleOutput(); | 413 InitWithSingleOutput(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 436 | 428 |
| 437 // Virtual should not trigger addition of added crtc but does change FB | 429 // Virtual should not trigger addition of added crtc but does change FB |
| 438 // height. | 430 // height. |
| 439 const int kSingleVirtualHeight = small_mode_.size().height() + | 431 const int kSingleVirtualHeight = small_mode_.size().height() + |
| 440 DisplayConfigurator::kVerticalGap + | 432 DisplayConfigurator::kVerticalGap + |
| 441 big_mode_.size().height(); | 433 big_mode_.size().height(); |
| 442 EXPECT_EQ( | 434 EXPECT_EQ( |
| 443 JoinActions( | 435 JoinActions( |
| 444 kGrab, GetFramebufferAction( | 436 kGrab, GetFramebufferAction( |
| 445 gfx::Size(big_mode_.size().width(), kSingleVirtualHeight), | 437 gfx::Size(big_mode_.size().width(), kSingleVirtualHeight), |
| 446 &outputs_[0], nullptr) | 438 outputs_[0].get(), nullptr) |
| 447 .c_str(), | 439 .c_str(), |
| 448 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 440 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 449 kUngrab, nullptr), | 441 kUngrab, nullptr), |
| 450 log_->GetActionsAndClear()); | 442 log_->GetActionsAndClear()); |
| 451 EXPECT_EQ(1, observer_.num_changes()); | 443 EXPECT_EQ(1, observer_.num_changes()); |
| 452 ASSERT_EQ(static_cast<size_t>(2), cached.size()); | 444 ASSERT_EQ(static_cast<size_t>(2), cached.size()); |
| 453 EXPECT_EQ(small_mode_.size(), cached[0]->current_mode()->size()); | 445 EXPECT_EQ(small_mode_.size(), cached[0]->current_mode()->size()); |
| 454 EXPECT_EQ(big_mode_.size(), cached[1]->current_mode()->size()); | 446 EXPECT_EQ(big_mode_.size(), cached[1]->current_mode()->size()); |
| 455 EXPECT_EQ(virtual_display_id_1, cached[1]->display_id()); | 447 EXPECT_EQ(virtual_display_id_1, cached[1]->display_id()); |
| 456 | 448 |
| 457 // Add 2nd virtual display | 449 // Add 2nd virtual display |
| 458 int64_t virtual_display_id_2 = | 450 int64_t virtual_display_id_2 = |
| 459 configurator_.AddVirtualDisplay(big_mode_.size()); | 451 configurator_.AddVirtualDisplay(big_mode_.size()); |
| 460 EXPECT_EQ(display::GenerateDisplayID(0x8000, 0x0, 2), virtual_display_id_2); | 452 EXPECT_EQ(display::GenerateDisplayID(0x8000, 0x0, 2), virtual_display_id_2); |
| 461 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); | 453 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 462 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED, | 454 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED, |
| 463 configurator_.display_state()); | 455 configurator_.display_state()); |
| 464 | 456 |
| 465 const int kDualVirtualHeight = | 457 const int kDualVirtualHeight = |
| 466 small_mode_.size().height() + | 458 small_mode_.size().height() + |
| 467 (DisplayConfigurator::kVerticalGap + big_mode_.size().height()) * 2; | 459 (DisplayConfigurator::kVerticalGap + big_mode_.size().height()) * 2; |
| 468 EXPECT_EQ( | 460 EXPECT_EQ( |
| 469 JoinActions( | 461 JoinActions( |
| 470 kGrab, GetFramebufferAction( | 462 kGrab, GetFramebufferAction( |
| 471 gfx::Size(big_mode_.size().width(), kDualVirtualHeight), | 463 gfx::Size(big_mode_.size().width(), kDualVirtualHeight), |
| 472 &outputs_[0], nullptr) | 464 outputs_[0].get(), nullptr) |
| 473 .c_str(), | 465 .c_str(), |
| 474 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 466 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 475 kUngrab, nullptr), | 467 kUngrab, nullptr), |
| 476 log_->GetActionsAndClear()); | 468 log_->GetActionsAndClear()); |
| 477 EXPECT_EQ(2, observer_.num_changes()); | 469 EXPECT_EQ(2, observer_.num_changes()); |
| 478 ASSERT_EQ(static_cast<size_t>(3u), cached.size()); | 470 ASSERT_EQ(static_cast<size_t>(3u), cached.size()); |
| 479 EXPECT_EQ(small_mode_.size(), cached[0]->current_mode()->size()); | 471 EXPECT_EQ(small_mode_.size(), cached[0]->current_mode()->size()); |
| 480 EXPECT_EQ(big_mode_.size(), cached[1]->current_mode()->size()); | 472 EXPECT_EQ(big_mode_.size(), cached[1]->current_mode()->size()); |
| 481 EXPECT_EQ(big_mode_.size(), cached[2]->current_mode()->size()); | 473 EXPECT_EQ(big_mode_.size(), cached[2]->current_mode()->size()); |
| 482 EXPECT_EQ(virtual_display_id_1, cached[1]->display_id()); | 474 EXPECT_EQ(virtual_display_id_1, cached[1]->display_id()); |
| 483 EXPECT_EQ(virtual_display_id_2, cached[2]->display_id()); | 475 EXPECT_EQ(virtual_display_id_2, cached[2]->display_id()); |
| 484 | 476 |
| 485 // Remove 1st virtual display. | 477 // Remove 1st virtual display. |
| 486 observer_.Reset(); | 478 observer_.Reset(); |
| 487 EXPECT_TRUE(configurator_.RemoveVirtualDisplay(virtual_display_id_1)); | 479 EXPECT_TRUE(configurator_.RemoveVirtualDisplay(virtual_display_id_1)); |
| 488 EXPECT_EQ( | 480 EXPECT_EQ( |
| 489 JoinActions( | 481 JoinActions( |
| 490 kGrab, GetFramebufferAction( | 482 kGrab, GetFramebufferAction( |
| 491 gfx::Size(big_mode_.size().width(), kSingleVirtualHeight), | 483 gfx::Size(big_mode_.size().width(), kSingleVirtualHeight), |
| 492 &outputs_[0], nullptr) | 484 outputs_[0].get(), nullptr) |
| 493 .c_str(), | 485 .c_str(), |
| 494 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 486 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 495 kUngrab, nullptr), | 487 kUngrab, nullptr), |
| 496 log_->GetActionsAndClear()); | 488 log_->GetActionsAndClear()); |
| 497 EXPECT_EQ(1, observer_.num_changes()); | 489 EXPECT_EQ(1, observer_.num_changes()); |
| 498 ASSERT_EQ(static_cast<size_t>(2u), cached.size()); | 490 ASSERT_EQ(static_cast<size_t>(2u), cached.size()); |
| 499 EXPECT_EQ(small_mode_.size(), cached[0]->current_mode()->size()); | 491 EXPECT_EQ(small_mode_.size(), cached[0]->current_mode()->size()); |
| 500 EXPECT_EQ(big_mode_.size(), cached[1]->current_mode()->size()); | 492 EXPECT_EQ(big_mode_.size(), cached[1]->current_mode()->size()); |
| 501 EXPECT_EQ(virtual_display_id_2, cached[1]->display_id()); | 493 EXPECT_EQ(virtual_display_id_2, cached[1]->display_id()); |
| 502 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, | 494 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |
| 503 configurator_.display_state()); | 495 configurator_.display_state()); |
| 504 | 496 |
| 505 // Remove 2nd virtual display. | 497 // Remove 2nd virtual display. |
| 506 observer_.Reset(); | 498 observer_.Reset(); |
| 507 EXPECT_TRUE(configurator_.RemoveVirtualDisplay(virtual_display_id_2)); | 499 EXPECT_TRUE(configurator_.RemoveVirtualDisplay(virtual_display_id_2)); |
| 508 EXPECT_EQ( | 500 EXPECT_EQ( |
| 509 JoinActions( | 501 JoinActions( |
| 510 kGrab, GetFramebufferAction(small_mode_.size(), &outputs_[0], nullptr) | 502 kGrab, |
| 511 .c_str(), | 503 GetFramebufferAction(small_mode_.size(), outputs_[0].get(), nullptr) |
| 512 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 504 .c_str(), |
| 505 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 513 kUngrab, nullptr), | 506 kUngrab, nullptr), |
| 514 log_->GetActionsAndClear()); | 507 log_->GetActionsAndClear()); |
| 515 EXPECT_EQ(1, observer_.num_changes()); | 508 EXPECT_EQ(1, observer_.num_changes()); |
| 516 ASSERT_EQ(static_cast<size_t>(1), cached.size()); | 509 ASSERT_EQ(static_cast<size_t>(1), cached.size()); |
| 517 EXPECT_EQ(small_mode_.size(), cached[0]->current_mode()->size()); | 510 EXPECT_EQ(small_mode_.size(), cached[0]->current_mode()->size()); |
| 518 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, configurator_.display_state()); | 511 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, configurator_.display_state()); |
| 519 } | 512 } |
| 520 | 513 |
| 521 TEST_F(DisplayConfiguratorTest, ConnectSecondOutput) { | 514 TEST_F(DisplayConfiguratorTest, ConnectSecondOutput) { |
| 522 InitWithSingleOutput(); | 515 InitWithSingleOutput(); |
| 523 | 516 |
| 524 // Connect a second output and check that the configurator enters | 517 // Connect a second output and check that the configurator enters |
| 525 // extended mode. | 518 // extended mode. |
| 526 observer_.Reset(); | 519 observer_.Reset(); |
| 527 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); | 520 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); |
| 528 UpdateOutputs(2, true); | 521 UpdateOutputs(2, true); |
| 529 const int kDualHeight = small_mode_.size().height() + | 522 const int kDualHeight = small_mode_.size().height() + |
| 530 DisplayConfigurator::kVerticalGap + | 523 DisplayConfigurator::kVerticalGap + |
| 531 big_mode_.size().height(); | 524 big_mode_.size().height(); |
| 532 EXPECT_EQ( | 525 EXPECT_EQ( |
| 533 JoinActions( | 526 JoinActions( |
| 534 kGrab, | 527 kGrab, |
| 535 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), | 528 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), |
| 536 &outputs_[0], | 529 outputs_[0].get(), outputs_[1].get()) |
| 537 &outputs_[1]).c_str(), | |
| 538 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | |
| 539 GetCrtcAction(outputs_[1], | |
| 540 &big_mode_, | |
| 541 gfx::Point(0, | |
| 542 small_mode_.size().height() + | |
| 543 DisplayConfigurator::kVerticalGap)) | |
| 544 .c_str(), | 530 .c_str(), |
| 545 kUngrab, | 531 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 546 NULL), | 532 GetCrtcAction(*outputs_[1], &big_mode_, |
| 533 gfx::Point(0, small_mode_.size().height() + |
| 534 DisplayConfigurator::kVerticalGap)) |
| 535 .c_str(), |
| 536 kUngrab, nullptr), |
| 547 log_->GetActionsAndClear()); | 537 log_->GetActionsAndClear()); |
| 548 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); | 538 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 549 EXPECT_EQ(1, observer_.num_changes()); | 539 EXPECT_EQ(1, observer_.num_changes()); |
| 550 | 540 |
| 551 observer_.Reset(); | 541 observer_.Reset(); |
| 552 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); | 542 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
| 553 EXPECT_EQ( | 543 EXPECT_EQ( |
| 554 JoinActions( | 544 JoinActions( |
| 555 kGrab, | 545 kGrab, GetFramebufferAction(small_mode_.size(), outputs_[0].get(), |
| 556 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) | 546 outputs_[1].get()) |
| 557 .c_str(), | 547 .c_str(), |
| 558 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 548 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 559 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), | 549 GetCrtcAction(*outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 560 kUngrab, | 550 kUngrab, nullptr), |
| 561 NULL), | |
| 562 log_->GetActionsAndClear()); | 551 log_->GetActionsAndClear()); |
| 563 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); | 552 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 564 EXPECT_EQ(1, observer_.num_changes()); | 553 EXPECT_EQ(1, observer_.num_changes()); |
| 565 | 554 |
| 566 // Disconnect the second output. | 555 // Disconnect the second output. |
| 567 observer_.Reset(); | 556 observer_.Reset(); |
| 568 UpdateOutputs(1, true); | 557 UpdateOutputs(1, true); |
| 569 EXPECT_EQ( | 558 EXPECT_EQ( |
| 570 JoinActions( | 559 JoinActions( |
| 571 kGrab, | 560 kGrab, |
| 572 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 561 GetFramebufferAction(small_mode_.size(), outputs_[0].get(), nullptr) |
| 573 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 562 .c_str(), |
| 574 kUngrab, | 563 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 575 NULL), | 564 kUngrab, nullptr), |
| 576 log_->GetActionsAndClear()); | 565 log_->GetActionsAndClear()); |
| 577 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); | 566 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 578 EXPECT_EQ(1, observer_.num_changes()); | 567 EXPECT_EQ(1, observer_.num_changes()); |
| 579 | 568 |
| 580 // Get rid of shared modes to force software mirroring. | 569 // Get rid of shared modes to force software mirroring. |
| 581 std::vector<std::unique_ptr<const DisplayMode>> modes; | 570 outputs_[1] = display::FakeDisplaySnapshot::Builder() |
| 582 modes.push_back(big_mode_.Clone()); | 571 .SetId(kDisplayIds[1]) |
| 583 outputs_[1].set_current_mode(modes.front().get()); | 572 .SetNativeMode(big_mode_.Clone()) |
| 584 outputs_[1].set_native_mode(modes.front().get()); | 573 .SetCurrentMode(big_mode_.Clone()) |
| 585 outputs_[1].set_modes(std::move(modes)); | 574 .SetType(DISPLAY_CONNECTION_TYPE_HDMI) |
| 575 .SetIsAspectPerservingScaling(true) |
| 576 .Build(); |
| 577 |
| 586 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); | 578 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); |
| 587 UpdateOutputs(2, true); | 579 UpdateOutputs(2, true); |
| 588 EXPECT_EQ( | 580 EXPECT_EQ( |
| 589 JoinActions( | 581 JoinActions( |
| 590 kGrab, | 582 kGrab, |
| 591 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), | 583 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), |
| 592 &outputs_[0], | 584 outputs_[0].get(), outputs_[1].get()) |
| 593 &outputs_[1]).c_str(), | |
| 594 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | |
| 595 GetCrtcAction(outputs_[1], | |
| 596 &big_mode_, | |
| 597 gfx::Point(0, | |
| 598 small_mode_.size().height() + | |
| 599 DisplayConfigurator::kVerticalGap)) | |
| 600 .c_str(), | 585 .c_str(), |
| 601 kUngrab, | 586 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 602 NULL), | 587 GetCrtcAction(*outputs_[1], &big_mode_, |
| 588 gfx::Point(0, small_mode_.size().height() + |
| 589 DisplayConfigurator::kVerticalGap)) |
| 590 .c_str(), |
| 591 kUngrab, nullptr), |
| 603 log_->GetActionsAndClear()); | 592 log_->GetActionsAndClear()); |
| 604 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); | 593 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 605 const gfx::Size framebuffer_size = configurator_.framebuffer_size(); | 594 const gfx::Size framebuffer_size = configurator_.framebuffer_size(); |
| 606 DCHECK(!framebuffer_size.IsEmpty()); | 595 DCHECK(!framebuffer_size.IsEmpty()); |
| 607 | 596 |
| 608 observer_.Reset(); | 597 observer_.Reset(); |
| 609 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); | 598 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
| 610 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear()); | 599 EXPECT_EQ(JoinActions(kGrab, kUngrab, nullptr), log_->GetActionsAndClear()); |
| 611 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, | 600 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |
| 612 configurator_.display_state()); | 601 configurator_.display_state()); |
| 613 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); | 602 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 614 EXPECT_EQ(framebuffer_size.ToString(), | 603 EXPECT_EQ(framebuffer_size.ToString(), |
| 615 configurator_.framebuffer_size().ToString()); | 604 configurator_.framebuffer_size().ToString()); |
| 616 | 605 |
| 617 EXPECT_EQ(1, observer_.num_changes()); | 606 EXPECT_EQ(1, observer_.num_changes()); |
| 618 | 607 |
| 619 // Setting MULTIPLE_DISPLAY_STATE_DUAL_MIRROR should try to reconfigure. | 608 // Setting MULTIPLE_DISPLAY_STATE_DUAL_MIRROR should try to reconfigure. |
| 620 observer_.Reset(); | 609 observer_.Reset(); |
| 621 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); | 610 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); |
| 622 EXPECT_EQ(JoinActions(NULL), log_->GetActionsAndClear()); | 611 EXPECT_EQ(JoinActions(nullptr), log_->GetActionsAndClear()); |
| 623 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); | 612 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 624 EXPECT_EQ(1, observer_.num_changes()); | 613 EXPECT_EQ(1, observer_.num_changes()); |
| 625 | 614 |
| 626 // Set back to software mirror mode. | 615 // Set back to software mirror mode. |
| 627 observer_.Reset(); | 616 observer_.Reset(); |
| 628 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); | 617 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
| 629 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear()); | 618 EXPECT_EQ(JoinActions(kGrab, kUngrab, nullptr), log_->GetActionsAndClear()); |
| 630 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, | 619 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |
| 631 configurator_.display_state()); | 620 configurator_.display_state()); |
| 632 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); | 621 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 633 EXPECT_EQ(1, observer_.num_changes()); | 622 EXPECT_EQ(1, observer_.num_changes()); |
| 634 | 623 |
| 635 // Disconnect the second output. | 624 // Disconnect the second output. |
| 636 observer_.Reset(); | 625 observer_.Reset(); |
| 637 UpdateOutputs(1, true); | 626 UpdateOutputs(1, true); |
| 638 EXPECT_EQ( | 627 EXPECT_EQ( |
| 639 JoinActions( | 628 JoinActions( |
| 640 kGrab, | 629 kGrab, |
| 641 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 630 GetFramebufferAction(small_mode_.size(), outputs_[0].get(), nullptr) |
| 642 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 631 .c_str(), |
| 643 kUngrab, | 632 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 644 NULL), | 633 kUngrab, nullptr), |
| 645 log_->GetActionsAndClear()); | 634 log_->GetActionsAndClear()); |
| 646 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); | 635 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 647 EXPECT_EQ(1, observer_.num_changes()); | 636 EXPECT_EQ(1, observer_.num_changes()); |
| 648 } | 637 } |
| 649 | 638 |
| 650 TEST_F(DisplayConfiguratorTest, SetDisplayPower) { | 639 TEST_F(DisplayConfiguratorTest, SetDisplayPower) { |
| 651 InitWithSingleOutput(); | 640 InitWithSingleOutput(); |
| 652 | 641 |
| 653 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); | 642 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
| 654 observer_.Reset(); | 643 observer_.Reset(); |
| 655 UpdateOutputs(2, true); | 644 UpdateOutputs(2, true); |
| 656 EXPECT_EQ( | 645 EXPECT_EQ( |
| 657 JoinActions( | 646 JoinActions( |
| 658 kGrab, | 647 kGrab, GetFramebufferAction(small_mode_.size(), outputs_[0].get(), |
| 659 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) | 648 outputs_[1].get()) |
| 660 .c_str(), | 649 .c_str(), |
| 661 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 650 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 662 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), | 651 GetCrtcAction(*outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 663 kUngrab, | 652 kUngrab, nullptr), |
| 664 NULL), | |
| 665 log_->GetActionsAndClear()); | 653 log_->GetActionsAndClear()); |
| 666 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); | 654 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 667 EXPECT_EQ(1, observer_.num_changes()); | 655 EXPECT_EQ(1, observer_.num_changes()); |
| 668 | 656 |
| 669 // Turning off the internal display should switch the external display to | 657 // Turning off the internal display should switch the external display to |
| 670 // its native mode. | 658 // its native mode. |
| 671 observer_.Reset(); | 659 observer_.Reset(); |
| 672 configurator_.SetDisplayPower( | 660 configurator_.SetDisplayPower( |
| 673 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, | 661 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, |
| 674 DisplayConfigurator::kSetDisplayPowerNoFlags, | 662 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 675 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 663 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, |
| 676 base::Unretained(this))); | 664 base::Unretained(this))); |
| 677 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 665 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
| 678 EXPECT_EQ( | 666 EXPECT_EQ( |
| 679 JoinActions( | 667 JoinActions( |
| 680 kGrab, | 668 kGrab, GetFramebufferAction(big_mode_.size(), outputs_[0].get(), |
| 681 GetFramebufferAction(big_mode_.size(), &outputs_[0], &outputs_[1]) | 669 outputs_[1].get()) |
| 682 .c_str(), | 670 .c_str(), |
| 683 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 671 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), |
| 684 GetCrtcAction(outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(), | 672 GetCrtcAction(*outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(), |
| 685 kForceDPMS, | 673 kForceDPMS, kUngrab, nullptr), |
| 686 kUngrab, | |
| 687 NULL), | |
| 688 log_->GetActionsAndClear()); | 674 log_->GetActionsAndClear()); |
| 689 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, configurator_.display_state()); | 675 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, configurator_.display_state()); |
| 690 EXPECT_EQ(1, observer_.num_changes()); | 676 EXPECT_EQ(1, observer_.num_changes()); |
| 691 | 677 |
| 692 // When all displays are turned off, the framebuffer should switch back | 678 // When all displays are turned off, the framebuffer should switch back |
| 693 // to the mirrored size. | 679 // to the mirrored size. |
| 694 observer_.Reset(); | 680 observer_.Reset(); |
| 695 configurator_.SetDisplayPower( | 681 configurator_.SetDisplayPower( |
| 696 chromeos::DISPLAY_POWER_ALL_OFF, | 682 chromeos::DISPLAY_POWER_ALL_OFF, |
| 697 DisplayConfigurator::kSetDisplayPowerNoFlags, | 683 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 698 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 684 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, |
| 699 base::Unretained(this))); | 685 base::Unretained(this))); |
| 700 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 686 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
| 701 EXPECT_EQ( | 687 EXPECT_EQ( |
| 702 JoinActions(kGrab, | 688 JoinActions( |
| 703 GetFramebufferAction( | 689 kGrab, GetFramebufferAction(small_mode_.size(), outputs_[0].get(), |
| 704 small_mode_.size(), &outputs_[0], &outputs_[1]).c_str(), | 690 outputs_[1].get()) |
| 705 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 691 .c_str(), |
| 706 GetCrtcAction(outputs_[1], NULL, gfx::Point(0, 0)).c_str(), | 692 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), |
| 707 kUngrab, | 693 GetCrtcAction(*outputs_[1], nullptr, gfx::Point(0, 0)).c_str(), |
| 708 NULL), | 694 kUngrab, nullptr), |
| 709 log_->GetActionsAndClear()); | 695 log_->GetActionsAndClear()); |
| 710 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state()); | 696 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state()); |
| 711 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); | 697 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 712 EXPECT_EQ(1, observer_.num_changes()); | 698 EXPECT_EQ(1, observer_.num_changes()); |
| 713 | 699 |
| 714 // Turn all displays on and check that mirroring is still used. | 700 // Turn all displays on and check that mirroring is still used. |
| 715 observer_.Reset(); | 701 observer_.Reset(); |
| 716 configurator_.SetDisplayPower( | 702 configurator_.SetDisplayPower( |
| 717 chromeos::DISPLAY_POWER_ALL_ON, | 703 chromeos::DISPLAY_POWER_ALL_ON, |
| 718 DisplayConfigurator::kSetDisplayPowerNoFlags, | 704 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 719 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 705 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, |
| 720 base::Unretained(this))); | 706 base::Unretained(this))); |
| 721 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 707 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
| 722 EXPECT_EQ( | 708 EXPECT_EQ( |
| 723 JoinActions( | 709 JoinActions( |
| 724 kGrab, | 710 kGrab, GetFramebufferAction(small_mode_.size(), outputs_[0].get(), |
| 725 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) | 711 outputs_[1].get()) |
| 726 .c_str(), | 712 .c_str(), |
| 727 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 713 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 728 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), | 714 GetCrtcAction(*outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 729 kForceDPMS, | 715 kForceDPMS, kUngrab, nullptr), |
| 730 kUngrab, | |
| 731 NULL), | |
| 732 log_->GetActionsAndClear()); | 716 log_->GetActionsAndClear()); |
| 733 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state()); | 717 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state()); |
| 734 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); | 718 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 735 EXPECT_EQ(1, observer_.num_changes()); | 719 EXPECT_EQ(1, observer_.num_changes()); |
| 736 | 720 |
| 737 // Get rid of shared modes to force software mirroring. | 721 // Get rid of shared modes to force software mirroring. |
| 738 std::vector<std::unique_ptr<const DisplayMode>> modes; | 722 outputs_[1] = display::FakeDisplaySnapshot::Builder() |
| 739 modes.push_back(big_mode_.Clone()); | 723 .SetId(kDisplayIds[1]) |
| 740 outputs_[1].set_current_mode(modes.front().get()); | 724 .SetNativeMode(big_mode_.Clone()) |
| 741 outputs_[1].set_native_mode(modes.front().get()); | 725 .SetCurrentMode(big_mode_.Clone()) |
| 742 outputs_[1].set_modes(std::move(modes)); | 726 .SetType(DISPLAY_CONNECTION_TYPE_HDMI) |
| 727 .SetIsAspectPerservingScaling(true) |
| 728 .Build(); |
| 729 |
| 743 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); | 730 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
| 744 observer_.Reset(); | 731 observer_.Reset(); |
| 745 UpdateOutputs(2, true); | 732 UpdateOutputs(2, true); |
| 746 const int kDualHeight = small_mode_.size().height() + | 733 const int kDualHeight = small_mode_.size().height() + |
| 747 DisplayConfigurator::kVerticalGap + | 734 DisplayConfigurator::kVerticalGap + |
| 748 big_mode_.size().height(); | 735 big_mode_.size().height(); |
| 749 EXPECT_EQ( | 736 EXPECT_EQ( |
| 750 JoinActions( | 737 JoinActions( |
| 751 kGrab, | 738 kGrab, |
| 752 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), | 739 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), |
| 753 &outputs_[0], | 740 outputs_[0].get(), outputs_[1].get()) |
| 754 &outputs_[1]).c_str(), | |
| 755 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | |
| 756 GetCrtcAction(outputs_[1], | |
| 757 &big_mode_, | |
| 758 gfx::Point(0, | |
| 759 small_mode_.size().height() + | |
| 760 DisplayConfigurator::kVerticalGap)) | |
| 761 .c_str(), | 741 .c_str(), |
| 762 kUngrab, | 742 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 763 NULL), | 743 GetCrtcAction(*outputs_[1], &big_mode_, |
| 744 gfx::Point(0, small_mode_.size().height() + |
| 745 DisplayConfigurator::kVerticalGap)) |
| 746 .c_str(), |
| 747 kUngrab, nullptr), |
| 764 log_->GetActionsAndClear()); | 748 log_->GetActionsAndClear()); |
| 765 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, | 749 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |
| 766 configurator_.display_state()); | 750 configurator_.display_state()); |
| 767 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); | 751 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 768 EXPECT_EQ(1, observer_.num_changes()); | 752 EXPECT_EQ(1, observer_.num_changes()); |
| 769 | 753 |
| 770 // Turning off the internal display should switch the external display to | 754 // Turning off the internal display should switch the external display to |
| 771 // its native mode. | 755 // its native mode. |
| 772 observer_.Reset(); | 756 observer_.Reset(); |
| 773 configurator_.SetDisplayPower( | 757 configurator_.SetDisplayPower( |
| 774 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, | 758 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, |
| 775 DisplayConfigurator::kSetDisplayPowerNoFlags, | 759 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 776 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 760 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, |
| 777 base::Unretained(this))); | 761 base::Unretained(this))); |
| 778 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 762 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
| 779 EXPECT_EQ( | 763 EXPECT_EQ( |
| 780 JoinActions( | 764 JoinActions( |
| 781 kGrab, | 765 kGrab, GetFramebufferAction(big_mode_.size(), outputs_[0].get(), |
| 782 GetFramebufferAction(big_mode_.size(), &outputs_[0], &outputs_[1]) | 766 outputs_[1].get()) |
| 783 .c_str(), | 767 .c_str(), |
| 784 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 768 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), |
| 785 GetCrtcAction(outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(), | 769 GetCrtcAction(*outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(), |
| 786 kForceDPMS, | 770 kForceDPMS, kUngrab, nullptr), |
| 787 kUngrab, | |
| 788 NULL), | |
| 789 log_->GetActionsAndClear()); | 771 log_->GetActionsAndClear()); |
| 790 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, configurator_.display_state()); | 772 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, configurator_.display_state()); |
| 791 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); | 773 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 792 EXPECT_EQ(1, observer_.num_changes()); | 774 EXPECT_EQ(1, observer_.num_changes()); |
| 793 | 775 |
| 794 // When all displays are turned off, the framebuffer should switch back | 776 // When all displays are turned off, the framebuffer should switch back |
| 795 // to the extended + software mirroring. | 777 // to the extended + software mirroring. |
| 796 observer_.Reset(); | 778 observer_.Reset(); |
| 797 configurator_.SetDisplayPower( | 779 configurator_.SetDisplayPower( |
| 798 chromeos::DISPLAY_POWER_ALL_OFF, | 780 chromeos::DISPLAY_POWER_ALL_OFF, |
| 799 DisplayConfigurator::kSetDisplayPowerNoFlags, | 781 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 800 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 782 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, |
| 801 base::Unretained(this))); | 783 base::Unretained(this))); |
| 802 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 784 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
| 803 EXPECT_EQ( | 785 EXPECT_EQ( |
| 804 JoinActions( | 786 JoinActions( |
| 805 kGrab, | 787 kGrab, |
| 806 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), | 788 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), |
| 807 &outputs_[0], | 789 outputs_[0].get(), outputs_[1].get()) |
| 808 &outputs_[1]).c_str(), | |
| 809 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | |
| 810 GetCrtcAction(outputs_[1], | |
| 811 NULL, | |
| 812 gfx::Point(0, | |
| 813 small_mode_.size().height() + | |
| 814 DisplayConfigurator::kVerticalGap)) | |
| 815 .c_str(), | 790 .c_str(), |
| 816 kUngrab, | 791 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), |
| 817 NULL), | 792 GetCrtcAction(*outputs_[1], nullptr, |
| 793 gfx::Point(0, small_mode_.size().height() + |
| 794 DisplayConfigurator::kVerticalGap)) |
| 795 .c_str(), |
| 796 kUngrab, nullptr), |
| 818 log_->GetActionsAndClear()); | 797 log_->GetActionsAndClear()); |
| 819 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, | 798 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |
| 820 configurator_.display_state()); | 799 configurator_.display_state()); |
| 821 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); | 800 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 822 EXPECT_EQ(1, observer_.num_changes()); | 801 EXPECT_EQ(1, observer_.num_changes()); |
| 823 | 802 |
| 824 // Turn all displays on and check that mirroring is still used. | 803 // Turn all displays on and check that mirroring is still used. |
| 825 observer_.Reset(); | 804 observer_.Reset(); |
| 826 configurator_.SetDisplayPower( | 805 configurator_.SetDisplayPower( |
| 827 chromeos::DISPLAY_POWER_ALL_ON, | 806 chromeos::DISPLAY_POWER_ALL_ON, |
| 828 DisplayConfigurator::kSetDisplayPowerNoFlags, | 807 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 829 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 808 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, |
| 830 base::Unretained(this))); | 809 base::Unretained(this))); |
| 831 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 810 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
| 832 EXPECT_EQ( | 811 EXPECT_EQ( |
| 833 JoinActions( | 812 JoinActions( |
| 834 kGrab, | 813 kGrab, |
| 835 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), | 814 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), |
| 836 &outputs_[0], | 815 outputs_[0].get(), outputs_[1].get()) |
| 837 &outputs_[1]).c_str(), | |
| 838 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | |
| 839 GetCrtcAction(outputs_[1], | |
| 840 &big_mode_, | |
| 841 gfx::Point(0, | |
| 842 small_mode_.size().height() + | |
| 843 DisplayConfigurator::kVerticalGap)) | |
| 844 .c_str(), | 816 .c_str(), |
| 845 kForceDPMS, | 817 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 846 kUngrab, | 818 GetCrtcAction(*outputs_[1], &big_mode_, |
| 847 NULL), | 819 gfx::Point(0, small_mode_.size().height() + |
| 820 DisplayConfigurator::kVerticalGap)) |
| 821 .c_str(), |
| 822 kForceDPMS, kUngrab, nullptr), |
| 848 log_->GetActionsAndClear()); | 823 log_->GetActionsAndClear()); |
| 849 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, | 824 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |
| 850 configurator_.display_state()); | 825 configurator_.display_state()); |
| 851 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); | 826 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 852 EXPECT_EQ(1, observer_.num_changes()); | 827 EXPECT_EQ(1, observer_.num_changes()); |
| 853 } | 828 } |
| 854 | 829 |
| 855 TEST_F(DisplayConfiguratorTest, SuspendAndResume) { | 830 TEST_F(DisplayConfiguratorTest, SuspendAndResume) { |
| 856 InitWithSingleOutput(); | 831 InitWithSingleOutput(); |
| 857 | 832 |
| 858 // No preparation is needed before suspending when the display is already | 833 // No preparation is needed before suspending when the display is already |
| 859 // on. The configurator should still reprobe on resume in case a display | 834 // on. The configurator should still reprobe on resume in case a display |
| 860 // was connected while suspended. | 835 // was connected while suspended. |
| 861 const gfx::Size framebuffer_size = configurator_.framebuffer_size(); | 836 const gfx::Size framebuffer_size = configurator_.framebuffer_size(); |
| 862 DCHECK(!framebuffer_size.IsEmpty()); | 837 DCHECK(!framebuffer_size.IsEmpty()); |
| 863 configurator_.SuspendDisplays(base::Bind( | 838 configurator_.SuspendDisplays(base::Bind( |
| 864 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); | 839 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); |
| 865 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 840 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
| 866 EXPECT_EQ(framebuffer_size.ToString(), | 841 EXPECT_EQ(framebuffer_size.ToString(), |
| 867 configurator_.framebuffer_size().ToString()); | 842 configurator_.framebuffer_size().ToString()); |
| 868 EXPECT_EQ( | 843 EXPECT_EQ(JoinActions( |
| 869 JoinActions( | 844 kGrab, GetFramebufferAction(small_mode_.size(), |
| 870 kGrab, | 845 outputs_[0].get(), nullptr) |
| 871 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 846 .c_str(), |
| 872 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 847 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), |
| 873 kUngrab, | 848 kUngrab, kSync, nullptr), |
| 874 kSync, | 849 log_->GetActionsAndClear()); |
| 875 NULL), | |
| 876 log_->GetActionsAndClear()); | |
| 877 configurator_.ResumeDisplays(); | 850 configurator_.ResumeDisplays(); |
| 878 EXPECT_EQ( | 851 EXPECT_EQ( |
| 879 JoinActions( | 852 JoinActions( |
| 880 kGrab, | 853 kGrab, |
| 881 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 854 GetFramebufferAction(small_mode_.size(), outputs_[0].get(), nullptr) |
| 882 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 855 .c_str(), |
| 883 kForceDPMS, | 856 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 884 kUngrab, | 857 kForceDPMS, kUngrab, nullptr), |
| 885 NULL), | |
| 886 log_->GetActionsAndClear()); | 858 log_->GetActionsAndClear()); |
| 887 | 859 |
| 888 // Now turn the display off before suspending and check that the | 860 // Now turn the display off before suspending and check that the |
| 889 // configurator turns it back on and syncs with the server. | 861 // configurator turns it back on and syncs with the server. |
| 890 configurator_.SetDisplayPower( | 862 configurator_.SetDisplayPower( |
| 891 chromeos::DISPLAY_POWER_ALL_OFF, | 863 chromeos::DISPLAY_POWER_ALL_OFF, |
| 892 DisplayConfigurator::kSetDisplayPowerNoFlags, | 864 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 893 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 865 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, |
| 894 base::Unretained(this))); | 866 base::Unretained(this))); |
| 895 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 867 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
| 896 EXPECT_EQ( | 868 EXPECT_EQ(JoinActions( |
| 897 JoinActions( | 869 kGrab, GetFramebufferAction(small_mode_.size(), |
| 898 kGrab, | 870 outputs_[0].get(), nullptr) |
| 899 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 871 .c_str(), |
| 900 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 872 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), |
| 901 kUngrab, | 873 kUngrab, nullptr), |
| 902 NULL), | 874 log_->GetActionsAndClear()); |
| 903 log_->GetActionsAndClear()); | |
| 904 | 875 |
| 905 configurator_.SuspendDisplays(base::Bind( | 876 configurator_.SuspendDisplays(base::Bind( |
| 906 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); | 877 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); |
| 907 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 878 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
| 908 EXPECT_EQ(kSync, log_->GetActionsAndClear()); | 879 EXPECT_EQ(kSync, log_->GetActionsAndClear()); |
| 909 | 880 |
| 910 configurator_.ResumeDisplays(); | 881 configurator_.ResumeDisplays(); |
| 911 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 882 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 912 | 883 |
| 913 configurator_.SetDisplayPower( | 884 configurator_.SetDisplayPower( |
| 914 chromeos::DISPLAY_POWER_ALL_ON, | 885 chromeos::DISPLAY_POWER_ALL_ON, |
| 915 DisplayConfigurator::kSetDisplayPowerNoFlags, | 886 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 916 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 887 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, |
| 917 base::Unretained(this))); | 888 base::Unretained(this))); |
| 918 EXPECT_EQ( | 889 EXPECT_EQ( |
| 919 JoinActions( | 890 JoinActions( |
| 920 kGrab, | 891 kGrab, |
| 921 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 892 GetFramebufferAction(small_mode_.size(), outputs_[0].get(), nullptr) |
| 922 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 893 .c_str(), |
| 923 kForceDPMS, | 894 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 924 kUngrab, | 895 kForceDPMS, kUngrab, nullptr), |
| 925 NULL), | |
| 926 log_->GetActionsAndClear()); | 896 log_->GetActionsAndClear()); |
| 927 | 897 |
| 928 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); | 898 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
| 929 UpdateOutputs(2, true); | 899 UpdateOutputs(2, true); |
| 930 EXPECT_EQ( | 900 EXPECT_EQ( |
| 931 JoinActions( | 901 JoinActions( |
| 932 kGrab, | 902 kGrab, GetFramebufferAction(small_mode_.size(), outputs_[0].get(), |
| 933 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) | 903 outputs_[1].get()) |
| 934 .c_str(), | 904 .c_str(), |
| 935 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 905 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 936 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), | 906 GetCrtcAction(*outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 937 kUngrab, | 907 kUngrab, nullptr), |
| 938 NULL), | |
| 939 log_->GetActionsAndClear()); | 908 log_->GetActionsAndClear()); |
| 940 | 909 |
| 941 configurator_.SetDisplayPower( | 910 configurator_.SetDisplayPower( |
| 942 chromeos::DISPLAY_POWER_ALL_OFF, | 911 chromeos::DISPLAY_POWER_ALL_OFF, |
| 943 DisplayConfigurator::kSetDisplayPowerNoFlags, | 912 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 944 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 913 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, |
| 945 base::Unretained(this))); | 914 base::Unretained(this))); |
| 946 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 915 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
| 947 EXPECT_EQ( | 916 EXPECT_EQ( |
| 948 JoinActions( | 917 JoinActions( |
| 949 kGrab, | 918 kGrab, GetFramebufferAction(small_mode_.size(), outputs_[0].get(), |
| 950 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) | 919 outputs_[1].get()) |
| 951 .c_str(), | 920 .c_str(), |
| 952 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 921 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), |
| 953 GetCrtcAction(outputs_[1], NULL, gfx::Point(0, 0)).c_str(), | 922 GetCrtcAction(*outputs_[1], nullptr, gfx::Point(0, 0)).c_str(), |
| 954 kUngrab, | 923 kUngrab, nullptr), |
| 955 NULL), | |
| 956 log_->GetActionsAndClear()); | 924 log_->GetActionsAndClear()); |
| 957 | 925 |
| 958 configurator_.SuspendDisplays(base::Bind( | 926 configurator_.SuspendDisplays(base::Bind( |
| 959 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); | 927 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); |
| 960 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 928 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
| 961 EXPECT_EQ(kSync, log_->GetActionsAndClear()); | 929 EXPECT_EQ(kSync, log_->GetActionsAndClear()); |
| 962 | 930 |
| 963 // If a display is disconnected while suspended, the configurator should | 931 // If a display is disconnected while suspended, the configurator should |
| 964 // pick up the change and only turn on the internal display. | 932 // pick up the change and only turn on the internal display. |
| 965 UpdateOutputs(1, false); | 933 UpdateOutputs(1, false); |
| 966 configurator_.ResumeDisplays(); | 934 configurator_.ResumeDisplays(); |
| 967 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 935 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 968 | 936 |
| 969 configurator_.SetDisplayPower( | 937 configurator_.SetDisplayPower( |
| 970 chromeos::DISPLAY_POWER_ALL_ON, | 938 chromeos::DISPLAY_POWER_ALL_ON, |
| 971 DisplayConfigurator::kSetDisplayPowerNoFlags, | 939 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 972 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 940 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, |
| 973 base::Unretained(this))); | 941 base::Unretained(this))); |
| 974 EXPECT_EQ( | 942 EXPECT_EQ( |
| 975 JoinActions( | 943 JoinActions( |
| 976 kGrab, | 944 kGrab, |
| 977 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 945 GetFramebufferAction(small_mode_.size(), outputs_[0].get(), nullptr) |
| 978 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 946 .c_str(), |
| 979 kForceDPMS, | 947 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 980 kUngrab, | 948 kForceDPMS, kUngrab, nullptr), |
| 981 NULL), | |
| 982 log_->GetActionsAndClear()); | 949 log_->GetActionsAndClear()); |
| 983 } | 950 } |
| 984 | 951 |
| 985 TEST_F(DisplayConfiguratorTest, Headless) { | 952 TEST_F(DisplayConfiguratorTest, Headless) { |
| 986 UpdateOutputs(0, false); | 953 UpdateOutputs(0, false); |
| 987 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 954 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 988 Init(false); | 955 Init(false); |
| 989 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 956 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 990 configurator_.ForceInitialConfigure(0); | 957 configurator_.ForceInitialConfigure(0); |
| 991 EXPECT_EQ(JoinActions(kInitXRandR, kGrab, kForceDPMS, kUngrab, NULL), | 958 EXPECT_EQ(JoinActions(kInitXRandR, kGrab, kForceDPMS, kUngrab, nullptr), |
| 992 log_->GetActionsAndClear()); | 959 log_->GetActionsAndClear()); |
| 993 | 960 |
| 994 // Not much should happen when the display power state is changed while | 961 // Not much should happen when the display power state is changed while |
| 995 // no displays are connected. | 962 // no displays are connected. |
| 996 configurator_.SetDisplayPower( | 963 configurator_.SetDisplayPower( |
| 997 chromeos::DISPLAY_POWER_ALL_OFF, | 964 chromeos::DISPLAY_POWER_ALL_OFF, |
| 998 DisplayConfigurator::kSetDisplayPowerNoFlags, | 965 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 999 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 966 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, |
| 1000 base::Unretained(this))); | 967 base::Unretained(this))); |
| 1001 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 968 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
| 1002 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear()); | 969 EXPECT_EQ(JoinActions(kGrab, kUngrab, nullptr), log_->GetActionsAndClear()); |
| 1003 configurator_.SetDisplayPower( | 970 configurator_.SetDisplayPower( |
| 1004 chromeos::DISPLAY_POWER_ALL_ON, | 971 chromeos::DISPLAY_POWER_ALL_ON, |
| 1005 DisplayConfigurator::kSetDisplayPowerNoFlags, | 972 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 1006 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 973 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, |
| 1007 base::Unretained(this))); | 974 base::Unretained(this))); |
| 1008 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 975 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
| 1009 EXPECT_EQ(JoinActions(kGrab, kForceDPMS, kUngrab, NULL), | 976 EXPECT_EQ(JoinActions(kGrab, kForceDPMS, kUngrab, nullptr), |
| 1010 log_->GetActionsAndClear()); | 977 log_->GetActionsAndClear()); |
| 1011 | 978 |
| 1012 // Connect an external display and check that it's configured correctly. | 979 // Connect an external display and check that it's configured correctly. |
| 1013 std::vector<std::unique_ptr<const DisplayMode>> modes; | 980 outputs_[0] = display::FakeDisplaySnapshot::Builder() |
| 1014 for (const std::unique_ptr<const DisplayMode>& mode : outputs_[1].modes()) { | 981 .SetId(kDisplayIds[0]) |
| 1015 modes.push_back(mode->Clone()); | 982 .SetNativeMode(big_mode_.Clone()) |
| 1016 if (mode.get() == outputs_[1].current_mode()) | 983 .SetCurrentMode(big_mode_.Clone()) |
| 1017 outputs_[0].set_current_mode(modes.back().get()); | 984 .AddMode(small_mode_.Clone()) |
| 1018 if (mode.get() == outputs_[1].native_mode()) | 985 .SetType(DISPLAY_CONNECTION_TYPE_INTERNAL) |
| 1019 outputs_[0].set_native_mode(modes.back().get()); | 986 .SetIsAspectPerservingScaling(true) |
| 1020 } | 987 .Build(); |
| 1021 outputs_[0].set_modes(std::move(modes)); | |
| 1022 outputs_[0].set_type(outputs_[1].type()); | |
| 1023 | 988 |
| 1024 UpdateOutputs(1, true); | 989 UpdateOutputs(1, true); |
| 1025 EXPECT_EQ( | 990 EXPECT_EQ( |
| 1026 JoinActions( | 991 JoinActions( |
| 1027 kGrab, | 992 kGrab, |
| 1028 GetFramebufferAction(big_mode_.size(), &outputs_[0], NULL).c_str(), | 993 GetFramebufferAction(big_mode_.size(), outputs_[0].get(), nullptr) |
| 1029 GetCrtcAction(outputs_[0], &big_mode_, gfx::Point(0, 0)).c_str(), | 994 .c_str(), |
| 1030 kUngrab, | 995 GetCrtcAction(*outputs_[0], &big_mode_, gfx::Point(0, 0)).c_str(), |
| 1031 NULL), | 996 kUngrab, nullptr), |
| 1032 log_->GetActionsAndClear()); | 997 log_->GetActionsAndClear()); |
| 1033 const gfx::Size framebuffer_size = configurator_.framebuffer_size(); | 998 const gfx::Size framebuffer_size = configurator_.framebuffer_size(); |
| 1034 DCHECK(!framebuffer_size.IsEmpty()); | 999 DCHECK(!framebuffer_size.IsEmpty()); |
| 1035 | 1000 |
| 1036 UpdateOutputs(0, true); | 1001 UpdateOutputs(0, true); |
| 1037 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear()); | 1002 EXPECT_EQ(JoinActions(kGrab, kUngrab, nullptr), log_->GetActionsAndClear()); |
| 1038 EXPECT_EQ(framebuffer_size.ToString(), | 1003 EXPECT_EQ(framebuffer_size.ToString(), |
| 1039 configurator_.framebuffer_size().ToString()); | 1004 configurator_.framebuffer_size().ToString()); |
| 1040 } | 1005 } |
| 1041 | 1006 |
| 1042 TEST_F(DisplayConfiguratorTest, StartWithTwoOutputs) { | 1007 TEST_F(DisplayConfiguratorTest, StartWithTwoOutputs) { |
| 1043 UpdateOutputs(2, false); | 1008 UpdateOutputs(2, false); |
| 1044 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1009 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1045 Init(false); | 1010 Init(false); |
| 1046 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1011 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1047 | 1012 |
| 1048 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); | 1013 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
| 1049 configurator_.ForceInitialConfigure(0); | 1014 configurator_.ForceInitialConfigure(0); |
| 1050 EXPECT_EQ( | 1015 EXPECT_EQ( |
| 1051 JoinActions( | 1016 JoinActions( |
| 1052 kInitXRandR, kGrab, | 1017 kInitXRandR, kGrab, |
| 1053 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) | 1018 GetFramebufferAction(small_mode_.size(), outputs_[0].get(), |
| 1019 outputs_[1].get()) |
| 1054 .c_str(), | 1020 .c_str(), |
| 1055 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1021 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1056 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), | 1022 GetCrtcAction(*outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1057 kForceDPMS, kUngrab, NULL), | 1023 kForceDPMS, kUngrab, nullptr), |
| 1058 log_->GetActionsAndClear()); | 1024 log_->GetActionsAndClear()); |
| 1059 } | 1025 } |
| 1060 | 1026 |
| 1061 TEST_F(DisplayConfiguratorTest, InvalidMultipleDisplayStates) { | 1027 TEST_F(DisplayConfiguratorTest, InvalidMultipleDisplayStates) { |
| 1062 UpdateOutputs(0, false); | 1028 UpdateOutputs(0, false); |
| 1063 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1029 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1064 Init(false); | 1030 Init(false); |
| 1065 configurator_.ForceInitialConfigure(0); | 1031 configurator_.ForceInitialConfigure(0); |
| 1066 observer_.Reset(); | 1032 observer_.Reset(); |
| 1067 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_HEADLESS); | 1033 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_HEADLESS); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1105 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); | 1071 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
| 1106 configurator_.ForceInitialConfigure(0); | 1072 configurator_.ForceInitialConfigure(0); |
| 1107 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state()); | 1073 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state()); |
| 1108 } | 1074 } |
| 1109 | 1075 |
| 1110 TEST_F(DisplayConfiguratorTest, UpdateCachedOutputsEvenAfterFailure) { | 1076 TEST_F(DisplayConfiguratorTest, UpdateCachedOutputsEvenAfterFailure) { |
| 1111 InitWithSingleOutput(); | 1077 InitWithSingleOutput(); |
| 1112 const DisplayConfigurator::DisplayStateList& cached = | 1078 const DisplayConfigurator::DisplayStateList& cached = |
| 1113 configurator_.cached_displays(); | 1079 configurator_.cached_displays(); |
| 1114 ASSERT_EQ(static_cast<size_t>(1), cached.size()); | 1080 ASSERT_EQ(static_cast<size_t>(1), cached.size()); |
| 1115 EXPECT_EQ(outputs_[0].current_mode(), cached[0]->current_mode()); | 1081 EXPECT_EQ(outputs_[0]->current_mode(), cached[0]->current_mode()); |
| 1116 | 1082 |
| 1117 // After connecting a second output, check that it shows up in | 1083 // After connecting a second output, check that it shows up in |
| 1118 // |cached_displays_| even if an invalid state is requested. | 1084 // |cached_displays_| even if an invalid state is requested. |
| 1119 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_SINGLE); | 1085 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_SINGLE); |
| 1120 UpdateOutputs(2, true); | 1086 UpdateOutputs(2, true); |
| 1121 ASSERT_EQ(static_cast<size_t>(2), cached.size()); | 1087 ASSERT_EQ(static_cast<size_t>(2), cached.size()); |
| 1122 EXPECT_EQ(outputs_[0].current_mode(), cached[0]->current_mode()); | 1088 EXPECT_EQ(outputs_[0]->current_mode(), cached[0]->current_mode()); |
| 1123 EXPECT_EQ(outputs_[1].current_mode(), cached[1]->current_mode()); | 1089 EXPECT_EQ(outputs_[1]->current_mode(), cached[1]->current_mode()); |
| 1124 } | 1090 } |
| 1125 | 1091 |
| 1126 TEST_F(DisplayConfiguratorTest, PanelFitting) { | 1092 TEST_F(DisplayConfiguratorTest, PanelFitting) { |
| 1127 // Configure the internal display to support only the big mode and the | 1093 // Configure the internal display to support only the big mode and the |
| 1128 // external display to support only the small mode. | 1094 // external display to support only the small mode. |
| 1129 std::unique_ptr<const DisplayMode> tmp_mode = big_mode_.Clone(); | 1095 outputs_[0] = display::FakeDisplaySnapshot::Builder() |
| 1130 const DisplayMode* mode = tmp_mode.get(); | 1096 .SetId(kDisplayIds[0]) |
| 1131 std::vector<std::unique_ptr<const DisplayMode>> modes; | 1097 .SetNativeMode(big_mode_.Clone()) |
| 1132 modes.push_back(std::move(tmp_mode)); | 1098 .SetCurrentMode(big_mode_.Clone()) |
| 1133 outputs_[0].set_modes(std::move(modes)); | 1099 .SetType(DISPLAY_CONNECTION_TYPE_INTERNAL) |
| 1134 outputs_[0].set_current_mode(mode); | 1100 .SetIsAspectPerservingScaling(true) |
| 1135 outputs_[0].set_native_mode(mode); | 1101 .Build(); |
| 1136 | 1102 |
| 1137 modes.clear(); | 1103 outputs_[1] = display::FakeDisplaySnapshot::Builder() |
| 1138 tmp_mode = small_mode_.Clone(); | 1104 .SetId(kDisplayIds[1]) |
| 1139 mode = tmp_mode.get(); | 1105 .SetNativeMode(small_mode_.Clone()) |
| 1140 modes.push_back(std::move(tmp_mode)); | 1106 .SetCurrentMode(small_mode_.Clone()) |
| 1141 outputs_[1].set_modes(std::move(modes)); | 1107 .SetType(DISPLAY_CONNECTION_TYPE_HDMI) |
| 1142 outputs_[1].set_current_mode(mode); | 1108 .SetIsAspectPerservingScaling(true) |
| 1143 outputs_[1].set_native_mode(mode); | 1109 .Build(); |
| 1144 | 1110 |
| 1145 // The small mode should be added to the internal output when requesting | 1111 // The small mode should be added to the internal output when requesting |
| 1146 // mirrored mode. | 1112 // mirrored mode. |
| 1147 UpdateOutputs(2, false); | 1113 UpdateOutputs(2, false); |
| 1148 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); | 1114 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
| 1149 Init(true /* is_panel_fitting_enabled */); | 1115 Init(true /* is_panel_fitting_enabled */); |
| 1150 configurator_.ForceInitialConfigure(0); | 1116 configurator_.ForceInitialConfigure(0); |
| 1151 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state()); | 1117 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state()); |
| 1152 EXPECT_EQ( | 1118 EXPECT_EQ( |
| 1153 JoinActions( | 1119 JoinActions( |
| 1154 kInitXRandR, kGrab, | 1120 kInitXRandR, kGrab, |
| 1155 GetAddOutputModeAction(outputs_[0], &small_mode_).c_str(), | 1121 GetAddOutputModeAction(*outputs_[0], &small_mode_).c_str(), |
| 1156 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) | 1122 GetFramebufferAction(small_mode_.size(), outputs_[0].get(), |
| 1123 outputs_[1].get()) |
| 1157 .c_str(), | 1124 .c_str(), |
| 1158 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1125 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1159 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), | 1126 GetCrtcAction(*outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1160 kForceDPMS, kUngrab, NULL), | 1127 kForceDPMS, kUngrab, nullptr), |
| 1161 log_->GetActionsAndClear()); | 1128 log_->GetActionsAndClear()); |
| 1162 | 1129 |
| 1163 // Both outputs should be using the small mode. | 1130 // Both outputs should be using the small mode. |
| 1164 ASSERT_EQ(1, observer_.num_changes()); | 1131 ASSERT_EQ(1, observer_.num_changes()); |
| 1165 ASSERT_EQ(static_cast<size_t>(2), observer_.latest_outputs().size()); | 1132 ASSERT_EQ(static_cast<size_t>(2), observer_.latest_outputs().size()); |
| 1166 EXPECT_EQ(small_mode_.size(), | 1133 EXPECT_EQ(small_mode_.size(), |
| 1167 observer_.latest_outputs()[0]->current_mode()->size()); | 1134 observer_.latest_outputs()[0]->current_mode()->size()); |
| 1168 EXPECT_EQ(small_mode_.size(), | 1135 EXPECT_EQ(small_mode_.size(), |
| 1169 observer_.latest_outputs()[1]->current_mode()->size()); | 1136 observer_.latest_outputs()[1]->current_mode()->size()); |
| 1170 | 1137 |
| 1171 // Also test that there are 2 modes (instead of the initial one) in the | 1138 // Also test that there are 2 modes (instead of the initial one) in the |
| 1172 // snapshot that was passed to the observer (http://crbug.com/289159). | 1139 // snapshot that was passed to the observer (http://crbug.com/289159). |
| 1173 DisplaySnapshot* state = observer_.latest_outputs()[0]; | 1140 DisplaySnapshot* state = observer_.latest_outputs()[0]; |
| 1174 ASSERT_EQ(2UL, state->modes().size()); | 1141 ASSERT_EQ(2UL, state->modes().size()); |
| 1175 } | 1142 } |
| 1176 | 1143 |
| 1177 TEST_F(DisplayConfiguratorTest, ContentProtection) { | 1144 TEST_F(DisplayConfiguratorTest, ContentProtection) { |
| 1178 Init(false); | 1145 Init(false); |
| 1179 configurator_.ForceInitialConfigure(0); | 1146 configurator_.ForceInitialConfigure(0); |
| 1180 EXPECT_NE(kNoActions, log_->GetActionsAndClear()); | 1147 EXPECT_NE(kNoActions, log_->GetActionsAndClear()); |
| 1181 | 1148 |
| 1182 DisplayConfigurator::ContentProtectionClientId id = | 1149 DisplayConfigurator::ContentProtectionClientId id = |
| 1183 configurator_.RegisterContentProtectionClient(); | 1150 configurator_.RegisterContentProtectionClient(); |
| 1184 EXPECT_NE(0u, id); | 1151 EXPECT_NE(0u, id); |
| 1185 | 1152 |
| 1186 // One output. | 1153 // One output. |
| 1187 UpdateOutputs(1, true); | 1154 UpdateOutputs(1, true); |
| 1188 EXPECT_NE(kNoActions, log_->GetActionsAndClear()); | 1155 EXPECT_NE(kNoActions, log_->GetActionsAndClear()); |
| 1189 configurator_.QueryContentProtectionStatus( | 1156 configurator_.QueryContentProtectionStatus( |
| 1190 id, outputs_[0].display_id(), | 1157 id, outputs_[0]->display_id(), |
| 1191 base::Bind(&DisplayConfiguratorTest::QueryContentProtectionCallback, | 1158 base::Bind(&DisplayConfiguratorTest::QueryContentProtectionCallback, |
| 1192 base::Unretained(this))); | 1159 base::Unretained(this))); |
| 1193 EXPECT_EQ(1, query_content_protection_call_count_); | 1160 EXPECT_EQ(1, query_content_protection_call_count_); |
| 1194 EXPECT_TRUE(query_content_protection_response_.success); | 1161 EXPECT_TRUE(query_content_protection_response_.success); |
| 1195 EXPECT_EQ(static_cast<uint32_t>(DISPLAY_CONNECTION_TYPE_INTERNAL), | 1162 EXPECT_EQ(static_cast<uint32_t>(DISPLAY_CONNECTION_TYPE_INTERNAL), |
| 1196 query_content_protection_response_.link_mask); | 1163 query_content_protection_response_.link_mask); |
| 1197 EXPECT_EQ(static_cast<uint32_t>(CONTENT_PROTECTION_METHOD_NONE), | 1164 EXPECT_EQ(static_cast<uint32_t>(CONTENT_PROTECTION_METHOD_NONE), |
| 1198 query_content_protection_response_.protection_mask); | 1165 query_content_protection_response_.protection_mask); |
| 1199 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1166 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1200 | 1167 |
| 1201 // Two outputs. | 1168 // Two outputs. |
| 1202 UpdateOutputs(2, true); | 1169 UpdateOutputs(2, true); |
| 1203 EXPECT_NE(kNoActions, log_->GetActionsAndClear()); | 1170 EXPECT_NE(kNoActions, log_->GetActionsAndClear()); |
| 1204 configurator_.QueryContentProtectionStatus( | 1171 configurator_.QueryContentProtectionStatus( |
| 1205 id, outputs_[1].display_id(), | 1172 id, outputs_[1]->display_id(), |
| 1206 base::Bind(&DisplayConfiguratorTest::QueryContentProtectionCallback, | 1173 base::Bind(&DisplayConfiguratorTest::QueryContentProtectionCallback, |
| 1207 base::Unretained(this))); | 1174 base::Unretained(this))); |
| 1208 EXPECT_EQ(2, query_content_protection_call_count_); | 1175 EXPECT_EQ(2, query_content_protection_call_count_); |
| 1209 EXPECT_TRUE(query_content_protection_response_.success); | 1176 EXPECT_TRUE(query_content_protection_response_.success); |
| 1210 EXPECT_EQ(static_cast<uint32_t>(DISPLAY_CONNECTION_TYPE_HDMI), | 1177 EXPECT_EQ(static_cast<uint32_t>(DISPLAY_CONNECTION_TYPE_HDMI), |
| 1211 query_content_protection_response_.link_mask); | 1178 query_content_protection_response_.link_mask); |
| 1212 EXPECT_EQ(static_cast<uint32_t>(CONTENT_PROTECTION_METHOD_NONE), | 1179 EXPECT_EQ(static_cast<uint32_t>(CONTENT_PROTECTION_METHOD_NONE), |
| 1213 query_content_protection_response_.protection_mask); | 1180 query_content_protection_response_.protection_mask); |
| 1214 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1181 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1215 | 1182 |
| 1216 configurator_.EnableContentProtection( | 1183 configurator_.EnableContentProtection( |
| 1217 id, outputs_[1].display_id(), CONTENT_PROTECTION_METHOD_HDCP, | 1184 id, outputs_[1]->display_id(), CONTENT_PROTECTION_METHOD_HDCP, |
| 1218 base::Bind(&DisplayConfiguratorTest::EnableContentProtectionCallback, | 1185 base::Bind(&DisplayConfiguratorTest::EnableContentProtectionCallback, |
| 1219 base::Unretained(this))); | 1186 base::Unretained(this))); |
| 1220 EXPECT_EQ(1, enable_content_protection_call_count_); | 1187 EXPECT_EQ(1, enable_content_protection_call_count_); |
| 1221 EXPECT_TRUE(enable_content_protection_status_); | 1188 EXPECT_TRUE(enable_content_protection_status_); |
| 1222 EXPECT_EQ(GetSetHDCPStateAction(outputs_[1], HDCP_STATE_DESIRED), | 1189 EXPECT_EQ(GetSetHDCPStateAction(*outputs_[1], HDCP_STATE_DESIRED), |
| 1223 log_->GetActionsAndClear()); | 1190 log_->GetActionsAndClear()); |
| 1224 | 1191 |
| 1225 // Enable protection. | 1192 // Enable protection. |
| 1226 native_display_delegate_->set_hdcp_state(HDCP_STATE_ENABLED); | 1193 native_display_delegate_->set_hdcp_state(HDCP_STATE_ENABLED); |
| 1227 configurator_.QueryContentProtectionStatus( | 1194 configurator_.QueryContentProtectionStatus( |
| 1228 id, outputs_[1].display_id(), | 1195 id, outputs_[1]->display_id(), |
| 1229 base::Bind(&DisplayConfiguratorTest::QueryContentProtectionCallback, | 1196 base::Bind(&DisplayConfiguratorTest::QueryContentProtectionCallback, |
| 1230 base::Unretained(this))); | 1197 base::Unretained(this))); |
| 1231 EXPECT_EQ(3, query_content_protection_call_count_); | 1198 EXPECT_EQ(3, query_content_protection_call_count_); |
| 1232 EXPECT_TRUE(query_content_protection_response_.success); | 1199 EXPECT_TRUE(query_content_protection_response_.success); |
| 1233 EXPECT_EQ(static_cast<uint32_t>(DISPLAY_CONNECTION_TYPE_HDMI), | 1200 EXPECT_EQ(static_cast<uint32_t>(DISPLAY_CONNECTION_TYPE_HDMI), |
| 1234 query_content_protection_response_.link_mask); | 1201 query_content_protection_response_.link_mask); |
| 1235 EXPECT_EQ(static_cast<uint32_t>(CONTENT_PROTECTION_METHOD_HDCP), | 1202 EXPECT_EQ(static_cast<uint32_t>(CONTENT_PROTECTION_METHOD_HDCP), |
| 1236 query_content_protection_response_.protection_mask); | 1203 query_content_protection_response_.protection_mask); |
| 1237 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1204 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1238 | 1205 |
| 1239 // Protections should be disabled after unregister. | 1206 // Protections should be disabled after unregister. |
| 1240 configurator_.UnregisterContentProtectionClient(id); | 1207 configurator_.UnregisterContentProtectionClient(id); |
| 1241 EXPECT_EQ(GetSetHDCPStateAction(outputs_[1], HDCP_STATE_UNDESIRED), | 1208 EXPECT_EQ(GetSetHDCPStateAction(*outputs_[1], HDCP_STATE_UNDESIRED), |
| 1242 log_->GetActionsAndClear()); | 1209 log_->GetActionsAndClear()); |
| 1243 } | 1210 } |
| 1244 | 1211 |
| 1245 TEST_F(DisplayConfiguratorTest, DoNotConfigureWithSuspendedDisplays) { | 1212 TEST_F(DisplayConfiguratorTest, DoNotConfigureWithSuspendedDisplays) { |
| 1246 InitWithSingleOutput(); | 1213 InitWithSingleOutput(); |
| 1247 | 1214 |
| 1248 // The DisplayConfigurator may occasionally receive OnConfigurationChanged() | 1215 // The DisplayConfigurator may occasionally receive OnConfigurationChanged() |
| 1249 // after the displays have been suspended. This event should be ignored since | 1216 // after the displays have been suspended. This event should be ignored since |
| 1250 // the DisplayConfigurator will force a probe and reconfiguration of displays | 1217 // the DisplayConfigurator will force a probe and reconfiguration of displays |
| 1251 // at resume time. | 1218 // at resume time. |
| 1252 configurator_.SuspendDisplays(base::Bind( | 1219 configurator_.SuspendDisplays(base::Bind( |
| 1253 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); | 1220 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); |
| 1254 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 1221 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
| 1255 EXPECT_EQ( | 1222 EXPECT_EQ(JoinActions( |
| 1256 JoinActions( | 1223 kGrab, GetFramebufferAction(small_mode_.size(), |
| 1257 kGrab, | 1224 outputs_[0].get(), nullptr) |
| 1258 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 1225 .c_str(), |
| 1259 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 1226 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), |
| 1260 kUngrab, | 1227 kUngrab, kSync, nullptr), |
| 1261 kSync, | 1228 log_->GetActionsAndClear()); |
| 1262 NULL), | |
| 1263 log_->GetActionsAndClear()); | |
| 1264 | 1229 |
| 1265 // The configuration timer should not be started when the displays | 1230 // The configuration timer should not be started when the displays |
| 1266 // are suspended. | 1231 // are suspended. |
| 1267 configurator_.OnConfigurationChanged(); | 1232 configurator_.OnConfigurationChanged(); |
| 1268 EXPECT_FALSE(test_api_.TriggerConfigureTimeout()); | 1233 EXPECT_FALSE(test_api_.TriggerConfigureTimeout()); |
| 1269 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1234 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1270 | 1235 |
| 1271 // Calls to SetDisplayPower should do nothing if the power state doesn't | 1236 // Calls to SetDisplayPower should do nothing if the power state doesn't |
| 1272 // change. | 1237 // change. |
| 1273 configurator_.SetDisplayPower( | 1238 configurator_.SetDisplayPower( |
| 1274 chromeos::DISPLAY_POWER_ALL_OFF, | 1239 chromeos::DISPLAY_POWER_ALL_OFF, |
| 1275 DisplayConfigurator::kSetDisplayPowerNoFlags, | 1240 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 1276 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 1241 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, |
| 1277 base::Unretained(this))); | 1242 base::Unretained(this))); |
| 1278 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 1243 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
| 1279 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1244 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1280 configurator_.SetDisplayPower( | 1245 configurator_.SetDisplayPower( |
| 1281 chromeos::DISPLAY_POWER_ALL_ON, | 1246 chromeos::DISPLAY_POWER_ALL_ON, |
| 1282 DisplayConfigurator::kSetDisplayPowerNoFlags, | 1247 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 1283 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 1248 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, |
| 1284 base::Unretained(this))); | 1249 base::Unretained(this))); |
| 1285 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 1250 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
| 1286 EXPECT_EQ( | 1251 EXPECT_EQ( |
| 1287 JoinActions( | 1252 JoinActions( |
| 1288 kGrab, | 1253 kGrab, |
| 1289 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 1254 GetFramebufferAction(small_mode_.size(), outputs_[0].get(), nullptr) |
| 1290 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1255 .c_str(), |
| 1291 kForceDPMS, | 1256 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1292 kUngrab, | 1257 kForceDPMS, kUngrab, nullptr), |
| 1293 NULL), | |
| 1294 log_->GetActionsAndClear()); | 1258 log_->GetActionsAndClear()); |
| 1295 | 1259 |
| 1296 UpdateOutputs(2, false); | 1260 UpdateOutputs(2, false); |
| 1297 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); | 1261 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
| 1298 EXPECT_EQ( | 1262 EXPECT_EQ( |
| 1299 JoinActions( | 1263 JoinActions( |
| 1300 kGrab, | 1264 kGrab, GetFramebufferAction(small_mode_.size(), outputs_[0].get(), |
| 1301 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) | 1265 outputs_[1].get()) |
| 1302 .c_str(), | 1266 .c_str(), |
| 1303 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1267 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1304 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), | 1268 GetCrtcAction(*outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1305 kUngrab, | 1269 kUngrab, nullptr), |
| 1306 NULL), | |
| 1307 log_->GetActionsAndClear()); | 1270 log_->GetActionsAndClear()); |
| 1308 | 1271 |
| 1309 // The DisplayConfigurator should do nothing at resume time if there is no | 1272 // The DisplayConfigurator should do nothing at resume time if there is no |
| 1310 // state change. | 1273 // state change. |
| 1311 UpdateOutputs(1, false); | 1274 UpdateOutputs(1, false); |
| 1312 configurator_.ResumeDisplays(); | 1275 configurator_.ResumeDisplays(); |
| 1313 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1276 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1314 | 1277 |
| 1315 // If a configuration task is pending when the displays are suspended, that | 1278 // If a configuration task is pending when the displays are suspended, that |
| 1316 // task should not run either and the timer should be stopped. The displays | 1279 // task should not run either and the timer should be stopped. The displays |
| 1317 // should be turned off by suspend. | 1280 // should be turned off by suspend. |
| 1318 configurator_.OnConfigurationChanged(); | 1281 configurator_.OnConfigurationChanged(); |
| 1319 configurator_.SuspendDisplays(base::Bind( | 1282 configurator_.SuspendDisplays(base::Bind( |
| 1320 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); | 1283 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); |
| 1321 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 1284 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
| 1322 EXPECT_EQ( | 1285 EXPECT_EQ(JoinActions( |
| 1323 JoinActions( | 1286 kGrab, GetFramebufferAction(small_mode_.size(), |
| 1324 kGrab, | 1287 outputs_[0].get(), nullptr) |
| 1325 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 1288 .c_str(), |
| 1326 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 1289 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), |
| 1327 kUngrab, | 1290 kUngrab, kSync, nullptr), |
| 1328 kSync, | 1291 log_->GetActionsAndClear()); |
| 1329 NULL), | |
| 1330 log_->GetActionsAndClear()); | |
| 1331 | 1292 |
| 1332 EXPECT_FALSE(test_api_.TriggerConfigureTimeout()); | 1293 EXPECT_FALSE(test_api_.TriggerConfigureTimeout()); |
| 1333 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1294 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1334 | 1295 |
| 1335 configurator_.ResumeDisplays(); | 1296 configurator_.ResumeDisplays(); |
| 1336 EXPECT_EQ( | 1297 EXPECT_EQ( |
| 1337 JoinActions( | 1298 JoinActions( |
| 1338 kGrab, | 1299 kGrab, |
| 1339 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 1300 GetFramebufferAction(small_mode_.size(), outputs_[0].get(), nullptr) |
| 1340 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1301 .c_str(), |
| 1341 kForceDPMS, | 1302 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1342 kUngrab, | 1303 kForceDPMS, kUngrab, nullptr), |
| 1343 NULL), | |
| 1344 log_->GetActionsAndClear()); | 1304 log_->GetActionsAndClear()); |
| 1345 } | 1305 } |
| 1346 | 1306 |
| 1347 TEST_F(DisplayConfiguratorTest, ContentProtectionTwoClients) { | 1307 TEST_F(DisplayConfiguratorTest, ContentProtectionTwoClients) { |
| 1348 DisplayConfigurator::ContentProtectionClientId client1 = | 1308 DisplayConfigurator::ContentProtectionClientId client1 = |
| 1349 configurator_.RegisterContentProtectionClient(); | 1309 configurator_.RegisterContentProtectionClient(); |
| 1350 DisplayConfigurator::ContentProtectionClientId client2 = | 1310 DisplayConfigurator::ContentProtectionClientId client2 = |
| 1351 configurator_.RegisterContentProtectionClient(); | 1311 configurator_.RegisterContentProtectionClient(); |
| 1352 EXPECT_NE(client1, client2); | 1312 EXPECT_NE(client1, client2); |
| 1353 | 1313 |
| 1354 Init(false); | 1314 Init(false); |
| 1355 configurator_.ForceInitialConfigure(0); | 1315 configurator_.ForceInitialConfigure(0); |
| 1356 UpdateOutputs(2, true); | 1316 UpdateOutputs(2, true); |
| 1357 EXPECT_NE(kNoActions, log_->GetActionsAndClear()); | 1317 EXPECT_NE(kNoActions, log_->GetActionsAndClear()); |
| 1358 | 1318 |
| 1359 // Clients never know state enableness for methods that they didn't request. | 1319 // Clients never know state enableness for methods that they didn't request. |
| 1360 configurator_.EnableContentProtection( | 1320 configurator_.EnableContentProtection( |
| 1361 client1, outputs_[1].display_id(), CONTENT_PROTECTION_METHOD_HDCP, | 1321 client1, outputs_[1]->display_id(), CONTENT_PROTECTION_METHOD_HDCP, |
| 1362 base::Bind(&DisplayConfiguratorTest::EnableContentProtectionCallback, | 1322 base::Bind(&DisplayConfiguratorTest::EnableContentProtectionCallback, |
| 1363 base::Unretained(this))); | 1323 base::Unretained(this))); |
| 1364 EXPECT_EQ(1, enable_content_protection_call_count_); | 1324 EXPECT_EQ(1, enable_content_protection_call_count_); |
| 1365 EXPECT_TRUE(enable_content_protection_status_); | 1325 EXPECT_TRUE(enable_content_protection_status_); |
| 1366 EXPECT_EQ(GetSetHDCPStateAction(outputs_[1], HDCP_STATE_DESIRED).c_str(), | 1326 EXPECT_EQ(GetSetHDCPStateAction(*outputs_[1], HDCP_STATE_DESIRED).c_str(), |
| 1367 log_->GetActionsAndClear()); | 1327 log_->GetActionsAndClear()); |
| 1368 native_display_delegate_->set_hdcp_state(HDCP_STATE_ENABLED); | 1328 native_display_delegate_->set_hdcp_state(HDCP_STATE_ENABLED); |
| 1369 | 1329 |
| 1370 configurator_.QueryContentProtectionStatus( | 1330 configurator_.QueryContentProtectionStatus( |
| 1371 client1, outputs_[1].display_id(), | 1331 client1, outputs_[1]->display_id(), |
| 1372 base::Bind(&DisplayConfiguratorTest::QueryContentProtectionCallback, | 1332 base::Bind(&DisplayConfiguratorTest::QueryContentProtectionCallback, |
| 1373 base::Unretained(this))); | 1333 base::Unretained(this))); |
| 1374 EXPECT_EQ(1, query_content_protection_call_count_); | 1334 EXPECT_EQ(1, query_content_protection_call_count_); |
| 1375 EXPECT_TRUE(query_content_protection_response_.success); | 1335 EXPECT_TRUE(query_content_protection_response_.success); |
| 1376 EXPECT_EQ(static_cast<uint32_t>(DISPLAY_CONNECTION_TYPE_HDMI), | 1336 EXPECT_EQ(static_cast<uint32_t>(DISPLAY_CONNECTION_TYPE_HDMI), |
| 1377 query_content_protection_response_.link_mask); | 1337 query_content_protection_response_.link_mask); |
| 1378 EXPECT_EQ(CONTENT_PROTECTION_METHOD_HDCP, | 1338 EXPECT_EQ(CONTENT_PROTECTION_METHOD_HDCP, |
| 1379 query_content_protection_response_.protection_mask); | 1339 query_content_protection_response_.protection_mask); |
| 1380 | 1340 |
| 1381 configurator_.QueryContentProtectionStatus( | 1341 configurator_.QueryContentProtectionStatus( |
| 1382 client2, outputs_[1].display_id(), | 1342 client2, outputs_[1]->display_id(), |
| 1383 base::Bind(&DisplayConfiguratorTest::QueryContentProtectionCallback, | 1343 base::Bind(&DisplayConfiguratorTest::QueryContentProtectionCallback, |
| 1384 base::Unretained(this))); | 1344 base::Unretained(this))); |
| 1385 EXPECT_EQ(2, query_content_protection_call_count_); | 1345 EXPECT_EQ(2, query_content_protection_call_count_); |
| 1386 EXPECT_TRUE(query_content_protection_response_.success); | 1346 EXPECT_TRUE(query_content_protection_response_.success); |
| 1387 EXPECT_EQ(static_cast<uint32_t>(DISPLAY_CONNECTION_TYPE_HDMI), | 1347 EXPECT_EQ(static_cast<uint32_t>(DISPLAY_CONNECTION_TYPE_HDMI), |
| 1388 query_content_protection_response_.link_mask); | 1348 query_content_protection_response_.link_mask); |
| 1389 EXPECT_EQ(CONTENT_PROTECTION_METHOD_NONE, | 1349 EXPECT_EQ(CONTENT_PROTECTION_METHOD_NONE, |
| 1390 query_content_protection_response_.protection_mask); | 1350 query_content_protection_response_.protection_mask); |
| 1391 | 1351 |
| 1392 // Protections will be disabled only if no more clients request them. | 1352 // Protections will be disabled only if no more clients request them. |
| 1393 configurator_.EnableContentProtection( | 1353 configurator_.EnableContentProtection( |
| 1394 client2, outputs_[1].display_id(), CONTENT_PROTECTION_METHOD_NONE, | 1354 client2, outputs_[1]->display_id(), CONTENT_PROTECTION_METHOD_NONE, |
| 1395 base::Bind(&DisplayConfiguratorTest::EnableContentProtectionCallback, | 1355 base::Bind(&DisplayConfiguratorTest::EnableContentProtectionCallback, |
| 1396 base::Unretained(this))); | 1356 base::Unretained(this))); |
| 1397 EXPECT_EQ(2, enable_content_protection_call_count_); | 1357 EXPECT_EQ(2, enable_content_protection_call_count_); |
| 1398 EXPECT_TRUE(enable_content_protection_status_); | 1358 EXPECT_TRUE(enable_content_protection_status_); |
| 1399 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1359 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1400 | 1360 |
| 1401 configurator_.EnableContentProtection( | 1361 configurator_.EnableContentProtection( |
| 1402 client1, outputs_[1].display_id(), CONTENT_PROTECTION_METHOD_NONE, | 1362 client1, outputs_[1]->display_id(), CONTENT_PROTECTION_METHOD_NONE, |
| 1403 base::Bind(&DisplayConfiguratorTest::EnableContentProtectionCallback, | 1363 base::Bind(&DisplayConfiguratorTest::EnableContentProtectionCallback, |
| 1404 base::Unretained(this))); | 1364 base::Unretained(this))); |
| 1405 EXPECT_EQ(3, enable_content_protection_call_count_); | 1365 EXPECT_EQ(3, enable_content_protection_call_count_); |
| 1406 EXPECT_TRUE(enable_content_protection_status_); | 1366 EXPECT_TRUE(enable_content_protection_status_); |
| 1407 EXPECT_EQ(GetSetHDCPStateAction(outputs_[1], HDCP_STATE_UNDESIRED).c_str(), | 1367 EXPECT_EQ(GetSetHDCPStateAction(*outputs_[1], HDCP_STATE_UNDESIRED).c_str(), |
| 1408 log_->GetActionsAndClear()); | 1368 log_->GetActionsAndClear()); |
| 1409 } | 1369 } |
| 1410 | 1370 |
| 1411 TEST_F(DisplayConfiguratorTest, ContentProtectionTwoClientsEnable) { | 1371 TEST_F(DisplayConfiguratorTest, ContentProtectionTwoClientsEnable) { |
| 1412 DisplayConfigurator::ContentProtectionClientId client1 = | 1372 DisplayConfigurator::ContentProtectionClientId client1 = |
| 1413 configurator_.RegisterContentProtectionClient(); | 1373 configurator_.RegisterContentProtectionClient(); |
| 1414 DisplayConfigurator::ContentProtectionClientId client2 = | 1374 DisplayConfigurator::ContentProtectionClientId client2 = |
| 1415 configurator_.RegisterContentProtectionClient(); | 1375 configurator_.RegisterContentProtectionClient(); |
| 1416 EXPECT_NE(client1, client2); | 1376 EXPECT_NE(client1, client2); |
| 1417 | 1377 |
| 1418 Init(false); | 1378 Init(false); |
| 1419 configurator_.ForceInitialConfigure(0); | 1379 configurator_.ForceInitialConfigure(0); |
| 1420 UpdateOutputs(2, true); | 1380 UpdateOutputs(2, true); |
| 1421 log_->GetActionsAndClear(); | 1381 log_->GetActionsAndClear(); |
| 1422 | 1382 |
| 1423 // Only enable once if HDCP is enabling. | 1383 // Only enable once if HDCP is enabling. |
| 1424 configurator_.EnableContentProtection( | 1384 configurator_.EnableContentProtection( |
| 1425 client1, outputs_[1].display_id(), CONTENT_PROTECTION_METHOD_HDCP, | 1385 client1, outputs_[1]->display_id(), CONTENT_PROTECTION_METHOD_HDCP, |
| 1426 base::Bind(&DisplayConfiguratorTest::EnableContentProtectionCallback, | 1386 base::Bind(&DisplayConfiguratorTest::EnableContentProtectionCallback, |
| 1427 base::Unretained(this))); | 1387 base::Unretained(this))); |
| 1428 EXPECT_EQ(1, enable_content_protection_call_count_); | 1388 EXPECT_EQ(1, enable_content_protection_call_count_); |
| 1429 EXPECT_TRUE(enable_content_protection_status_); | 1389 EXPECT_TRUE(enable_content_protection_status_); |
| 1430 native_display_delegate_->set_hdcp_state(HDCP_STATE_DESIRED); | 1390 native_display_delegate_->set_hdcp_state(HDCP_STATE_DESIRED); |
| 1431 configurator_.EnableContentProtection( | 1391 configurator_.EnableContentProtection( |
| 1432 client2, outputs_[1].display_id(), CONTENT_PROTECTION_METHOD_HDCP, | 1392 client2, outputs_[1]->display_id(), CONTENT_PROTECTION_METHOD_HDCP, |
| 1433 base::Bind(&DisplayConfiguratorTest::EnableContentProtectionCallback, | 1393 base::Bind(&DisplayConfiguratorTest::EnableContentProtectionCallback, |
| 1434 base::Unretained(this))); | 1394 base::Unretained(this))); |
| 1435 EXPECT_EQ(2, enable_content_protection_call_count_); | 1395 EXPECT_EQ(2, enable_content_protection_call_count_); |
| 1436 EXPECT_TRUE(enable_content_protection_status_); | 1396 EXPECT_TRUE(enable_content_protection_status_); |
| 1437 EXPECT_EQ(GetSetHDCPStateAction(outputs_[1], HDCP_STATE_DESIRED).c_str(), | 1397 EXPECT_EQ(GetSetHDCPStateAction(*outputs_[1], HDCP_STATE_DESIRED).c_str(), |
| 1438 log_->GetActionsAndClear()); | 1398 log_->GetActionsAndClear()); |
| 1439 native_display_delegate_->set_hdcp_state(HDCP_STATE_ENABLED); | 1399 native_display_delegate_->set_hdcp_state(HDCP_STATE_ENABLED); |
| 1440 | 1400 |
| 1441 // Don't enable again if HDCP is already active. | 1401 // Don't enable again if HDCP is already active. |
| 1442 configurator_.EnableContentProtection( | 1402 configurator_.EnableContentProtection( |
| 1443 client1, outputs_[1].display_id(), CONTENT_PROTECTION_METHOD_HDCP, | 1403 client1, outputs_[1]->display_id(), CONTENT_PROTECTION_METHOD_HDCP, |
| 1444 base::Bind(&DisplayConfiguratorTest::EnableContentProtectionCallback, | 1404 base::Bind(&DisplayConfiguratorTest::EnableContentProtectionCallback, |
| 1445 base::Unretained(this))); | 1405 base::Unretained(this))); |
| 1446 EXPECT_EQ(3, enable_content_protection_call_count_); | 1406 EXPECT_EQ(3, enable_content_protection_call_count_); |
| 1447 EXPECT_TRUE(enable_content_protection_status_); | 1407 EXPECT_TRUE(enable_content_protection_status_); |
| 1448 configurator_.EnableContentProtection( | 1408 configurator_.EnableContentProtection( |
| 1449 client2, outputs_[1].display_id(), CONTENT_PROTECTION_METHOD_HDCP, | 1409 client2, outputs_[1]->display_id(), CONTENT_PROTECTION_METHOD_HDCP, |
| 1450 base::Bind(&DisplayConfiguratorTest::EnableContentProtectionCallback, | 1410 base::Bind(&DisplayConfiguratorTest::EnableContentProtectionCallback, |
| 1451 base::Unretained(this))); | 1411 base::Unretained(this))); |
| 1452 EXPECT_EQ(4, enable_content_protection_call_count_); | 1412 EXPECT_EQ(4, enable_content_protection_call_count_); |
| 1453 EXPECT_TRUE(enable_content_protection_status_); | 1413 EXPECT_TRUE(enable_content_protection_status_); |
| 1454 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1414 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1455 } | 1415 } |
| 1456 | 1416 |
| 1457 TEST_F(DisplayConfiguratorTest, HandleConfigureCrtcFailure) { | 1417 TEST_F(DisplayConfiguratorTest, HandleConfigureCrtcFailure) { |
| 1458 InitWithSingleOutput(); | 1418 InitWithSingleOutput(); |
| 1459 | 1419 |
| 1460 ScopedVector<const DisplayMode> modes; | 1420 std::vector<std::unique_ptr<const DisplayMode>> modes; |
| 1461 // The first mode is the mode we are requesting DisplayConfigurator to choose. | 1421 // The first mode is the mode we are requesting DisplayConfigurator to choose. |
| 1462 // The test will be setup so that this mode will fail and it will have to | 1422 // The test will be setup so that this mode will fail and it will have to |
| 1463 // choose the next best option. | 1423 // choose the next best option. |
| 1464 modes.push_back(new DisplayMode(gfx::Size(2560, 1600), false, 60.0)); | 1424 modes.push_back(MakeDisplayMode(2560, 1600, false, 60.0)); |
| 1465 modes.push_back(new DisplayMode(gfx::Size(1024, 768), false, 60.0)); | 1425 modes.push_back(MakeDisplayMode(1024, 768, false, 60.0)); |
| 1466 modes.push_back(new DisplayMode(gfx::Size(1280, 720), false, 60.0)); | 1426 modes.push_back(MakeDisplayMode(1280, 720, false, 60.0)); |
| 1467 modes.push_back(new DisplayMode(gfx::Size(1920, 1080), false, 60.0)); | 1427 modes.push_back(MakeDisplayMode(1920, 1080, false, 60.0)); |
| 1468 modes.push_back(new DisplayMode(gfx::Size(1920, 1080), false, 40.0)); | 1428 modes.push_back(MakeDisplayMode(1920, 1080, false, 40.0)); |
| 1469 | 1429 |
| 1470 for (unsigned int i = 0; i < arraysize(outputs_); i++) { | 1430 outputs_[0] = display::FakeDisplaySnapshot::Builder() |
| 1471 std::vector<std::unique_ptr<const DisplayMode>> tmp_modes; | 1431 .SetId(kDisplayIds[0]) |
| 1472 for (const DisplayMode* mode : modes) | 1432 .SetNativeMode(modes[0]->Clone()) |
| 1473 tmp_modes.push_back(mode->Clone()); | 1433 .SetCurrentMode(modes[0]->Clone()) |
| 1474 outputs_[i].set_current_mode(tmp_modes[0].get()); | 1434 .AddMode(modes[1]->Clone()) |
| 1475 outputs_[i].set_native_mode(tmp_modes[0].get()); | 1435 .AddMode(modes[2]->Clone()) |
| 1476 outputs_[i].set_modes(std::move(tmp_modes)); | 1436 .AddMode(modes[3]->Clone()) |
| 1477 } | 1437 .AddMode(modes[4]->Clone()) |
| 1438 .SetType(DISPLAY_CONNECTION_TYPE_INTERNAL) |
| 1439 .SetIsAspectPerservingScaling(true) |
| 1440 .Build(); |
| 1478 | 1441 |
| 1479 // First test simply fails in MULTIPLE_DISPLAY_STATE_SINGLE mode. This is | 1442 // First test simply fails in MULTIPLE_DISPLAY_STATE_SINGLE mode. This is |
| 1480 // probably unrealistic but we want to make sure any assumptions don't creep | 1443 // probably unrealistic but we want to make sure any assumptions don't creep |
| 1481 // in. | 1444 // in. |
| 1482 native_display_delegate_->set_max_configurable_pixels( | 1445 native_display_delegate_->set_max_configurable_pixels( |
| 1483 modes[2]->size().GetArea()); | 1446 modes[2]->size().GetArea()); |
| 1484 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_SINGLE); | 1447 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_SINGLE); |
| 1485 UpdateOutputs(1, true); | 1448 UpdateOutputs(1, true); |
| 1486 | 1449 |
| 1487 EXPECT_EQ( | 1450 EXPECT_EQ( |
| 1488 JoinActions( | 1451 JoinActions( |
| 1489 kGrab, | 1452 kGrab, |
| 1490 GetFramebufferAction(big_mode_.size(), &outputs_[0], NULL).c_str(), | 1453 GetFramebufferAction(big_mode_.size(), outputs_[0].get(), nullptr) |
| 1491 GetCrtcAction(outputs_[0], modes[0], gfx::Point(0, 0)).c_str(), | 1454 .c_str(), |
| 1492 GetCrtcAction(outputs_[0], modes[3], gfx::Point(0, 0)).c_str(), | 1455 GetCrtcAction(*outputs_[0], modes[0].get(), gfx::Point(0, 0)).c_str(), |
| 1493 GetCrtcAction(outputs_[0], modes[2], gfx::Point(0, 0)).c_str(), | 1456 GetCrtcAction(*outputs_[0], modes[3].get(), gfx::Point(0, 0)).c_str(), |
| 1494 kUngrab, | 1457 GetCrtcAction(*outputs_[0], modes[2].get(), gfx::Point(0, 0)).c_str(), |
| 1495 NULL), | 1458 kUngrab, nullptr), |
| 1496 log_->GetActionsAndClear()); | 1459 log_->GetActionsAndClear()); |
| 1497 | 1460 |
| 1461 outputs_[1] = display::FakeDisplaySnapshot::Builder() |
| 1462 .SetId(kDisplayIds[1]) |
| 1463 .SetNativeMode(modes[0]->Clone()) |
| 1464 .SetCurrentMode(modes[0]->Clone()) |
| 1465 .AddMode(modes[1]->Clone()) |
| 1466 .AddMode(modes[2]->Clone()) |
| 1467 .AddMode(modes[3]->Clone()) |
| 1468 .AddMode(modes[4]->Clone()) |
| 1469 .SetType(DISPLAY_CONNECTION_TYPE_HDMI) |
| 1470 .SetIsAspectPerservingScaling(true) |
| 1471 .Build(); |
| 1472 |
| 1498 // This test should attempt to configure a mirror mode that will not succeed | 1473 // This test should attempt to configure a mirror mode that will not succeed |
| 1499 // and should end up in extended mode. | 1474 // and should end up in extended mode. |
| 1500 native_display_delegate_->set_max_configurable_pixels( | 1475 native_display_delegate_->set_max_configurable_pixels( |
| 1501 modes[3]->size().GetArea()); | 1476 modes[3]->size().GetArea()); |
| 1502 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); | 1477 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
| 1503 UpdateOutputs(2, true); | 1478 UpdateOutputs(2, true); |
| 1504 | 1479 |
| 1505 EXPECT_EQ( | 1480 EXPECT_EQ( |
| 1506 JoinActions( | 1481 JoinActions( |
| 1507 kGrab, GetFramebufferAction(modes[0]->size(), &outputs_[0], | 1482 kGrab, GetFramebufferAction(modes[0]->size(), outputs_[0].get(), |
| 1508 &outputs_[1]).c_str(), | 1483 outputs_[1].get()) |
| 1509 GetCrtcAction(outputs_[0], modes[0], gfx::Point(0, 0)).c_str(), | 1484 .c_str(), |
| 1485 GetCrtcAction(*outputs_[0], modes[0].get(), gfx::Point(0, 0)).c_str(), |
| 1510 // Then attempt to configure crtc1 with the first mode. | 1486 // Then attempt to configure crtc1 with the first mode. |
| 1511 GetCrtcAction(outputs_[1], modes[0], gfx::Point(0, 0)).c_str(), | 1487 GetCrtcAction(*outputs_[1], modes[0].get(), gfx::Point(0, 0)).c_str(), |
| 1512 // First mode tried is expected to fail and it will | 1488 // First mode tried is expected to fail and it will |
| 1513 // retry wil the 4th mode in the list. | 1489 // retry wil the 4th mode in the list. |
| 1514 GetCrtcAction(outputs_[0], modes[3], gfx::Point(0, 0)).c_str(), | 1490 GetCrtcAction(*outputs_[0], modes[3].get(), gfx::Point(0, 0)).c_str(), |
| 1515 GetCrtcAction(outputs_[1], modes[3], gfx::Point(0, 0)).c_str(), | 1491 GetCrtcAction(*outputs_[1], modes[3].get(), gfx::Point(0, 0)).c_str(), |
| 1516 // Since it was requested to go into mirror mode | 1492 // Since it was requested to go into mirror mode |
| 1517 // and the configured modes were different, it | 1493 // and the configured modes were different, it |
| 1518 // should now try and setup a valid configurable | 1494 // should now try and setup a valid configurable |
| 1519 // extended mode. | 1495 // extended mode. |
| 1520 GetFramebufferAction( | 1496 GetFramebufferAction( |
| 1521 gfx::Size(modes[0]->size().width(), | 1497 gfx::Size(modes[0]->size().width(), |
| 1522 modes[0]->size().height() + modes[0]->size().height() + | 1498 modes[0]->size().height() + modes[0]->size().height() + |
| 1523 DisplayConfigurator::kVerticalGap), | 1499 DisplayConfigurator::kVerticalGap), |
| 1524 &outputs_[0], &outputs_[1]).c_str(), | 1500 outputs_[0].get(), outputs_[1].get()) |
| 1525 GetCrtcAction(outputs_[0], modes[0], gfx::Point(0, 0)).c_str(), | 1501 .c_str(), |
| 1526 GetCrtcAction(outputs_[1], modes[0], | 1502 GetCrtcAction(*outputs_[0], modes[0].get(), gfx::Point(0, 0)).c_str(), |
| 1503 GetCrtcAction(*outputs_[1], modes[0].get(), |
| 1527 gfx::Point(0, modes[0]->size().height() + | 1504 gfx::Point(0, modes[0]->size().height() + |
| 1528 DisplayConfigurator::kVerticalGap)) | 1505 DisplayConfigurator::kVerticalGap)) |
| 1529 .c_str(), | 1506 .c_str(), |
| 1530 GetCrtcAction(outputs_[0], modes[3], gfx::Point(0, 0)).c_str(), | 1507 GetCrtcAction(*outputs_[0], modes[3].get(), gfx::Point(0, 0)).c_str(), |
| 1531 GetCrtcAction(outputs_[1], modes[3], | 1508 GetCrtcAction(*outputs_[1], modes[3].get(), |
| 1532 gfx::Point(0, modes[0]->size().height() + | 1509 gfx::Point(0, modes[0]->size().height() + |
| 1533 DisplayConfigurator::kVerticalGap)) | 1510 DisplayConfigurator::kVerticalGap)) |
| 1534 .c_str(), | 1511 .c_str(), |
| 1535 kUngrab, NULL), | 1512 kUngrab, nullptr), |
| 1536 log_->GetActionsAndClear()); | 1513 log_->GetActionsAndClear()); |
| 1537 } | 1514 } |
| 1538 | 1515 |
| 1539 // Tests that power state requests are saved after failed configuration attempts | 1516 // Tests that power state requests are saved after failed configuration attempts |
| 1540 // so they can be reused later: http://crosbug.com/p/31571 | 1517 // so they can be reused later: http://crosbug.com/p/31571 |
| 1541 TEST_F(DisplayConfiguratorTest, SaveDisplayPowerStateOnConfigFailure) { | 1518 TEST_F(DisplayConfiguratorTest, SaveDisplayPowerStateOnConfigFailure) { |
| 1542 // Start out with two displays in extended mode. | 1519 // Start out with two displays in extended mode. |
| 1543 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); | 1520 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); |
| 1544 Init(false); | 1521 Init(false); |
| 1545 configurator_.ForceInitialConfigure(0); | 1522 configurator_.ForceInitialConfigure(0); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1568 EXPECT_EQ(CALLBACK_FAILURE, PopCallbackResult()); | 1545 EXPECT_EQ(CALLBACK_FAILURE, PopCallbackResult()); |
| 1569 EXPECT_EQ(1, observer_.num_changes()); | 1546 EXPECT_EQ(1, observer_.num_changes()); |
| 1570 EXPECT_EQ(1, observer_.num_failures()); | 1547 EXPECT_EQ(1, observer_.num_failures()); |
| 1571 log_->GetActionsAndClear(); | 1548 log_->GetActionsAndClear(); |
| 1572 | 1549 |
| 1573 // Simulate the external display getting disconnected and check that the | 1550 // Simulate the external display getting disconnected and check that the |
| 1574 // internal display is turned on (i.e. DISPLAY_POWER_ALL_ON is used) rather | 1551 // internal display is turned on (i.e. DISPLAY_POWER_ALL_ON is used) rather |
| 1575 // than the earlier DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON state. | 1552 // than the earlier DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON state. |
| 1576 native_display_delegate_->set_max_configurable_pixels(0); | 1553 native_display_delegate_->set_max_configurable_pixels(0); |
| 1577 UpdateOutputs(1, true); | 1554 UpdateOutputs(1, true); |
| 1578 EXPECT_EQ(JoinActions(kGrab, GetFramebufferAction(small_mode_.size(), | 1555 EXPECT_EQ( |
| 1579 &outputs_[0], NULL).c_str(), | 1556 JoinActions( |
| 1580 GetCrtcAction(outputs_[0], &small_mode_, | 1557 kGrab, |
| 1581 gfx::Point(0, 0)).c_str(), | 1558 GetFramebufferAction(small_mode_.size(), outputs_[0].get(), nullptr) |
| 1582 kForceDPMS, kUngrab, NULL), | 1559 .c_str(), |
| 1583 log_->GetActionsAndClear()); | 1560 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1561 kForceDPMS, kUngrab, nullptr), |
| 1562 log_->GetActionsAndClear()); |
| 1584 } | 1563 } |
| 1585 | 1564 |
| 1586 // Tests that the SetDisplayPowerState() task posted by HandleResume() doesn't | 1565 // Tests that the SetDisplayPowerState() task posted by HandleResume() doesn't |
| 1587 // use a stale state if a new state is requested before it runs: | 1566 // use a stale state if a new state is requested before it runs: |
| 1588 // http://crosbug.com/p/32393 | 1567 // http://crosbug.com/p/32393 |
| 1589 TEST_F(DisplayConfiguratorTest, DontRestoreStalePowerStateAfterResume) { | 1568 TEST_F(DisplayConfiguratorTest, DontRestoreStalePowerStateAfterResume) { |
| 1590 // Start out with two displays in mirrored mode. | 1569 // Start out with two displays in mirrored mode. |
| 1591 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); | 1570 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
| 1592 Init(false); | 1571 Init(false); |
| 1593 configurator_.ForceInitialConfigure(0); | 1572 configurator_.ForceInitialConfigure(0); |
| 1594 log_->GetActionsAndClear(); | 1573 log_->GetActionsAndClear(); |
| 1595 observer_.Reset(); | 1574 observer_.Reset(); |
| 1596 | 1575 |
| 1597 // Turn off the internal display, simulating docked mode. | 1576 // Turn off the internal display, simulating docked mode. |
| 1598 configurator_.SetDisplayPower( | 1577 configurator_.SetDisplayPower( |
| 1599 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, | 1578 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, |
| 1600 DisplayConfigurator::kSetDisplayPowerNoFlags, | 1579 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 1601 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 1580 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, |
| 1602 base::Unretained(this))); | 1581 base::Unretained(this))); |
| 1603 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 1582 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
| 1604 EXPECT_EQ(1, observer_.num_changes()); | 1583 EXPECT_EQ(1, observer_.num_changes()); |
| 1605 EXPECT_EQ(0, observer_.num_failures()); | 1584 EXPECT_EQ(0, observer_.num_failures()); |
| 1606 EXPECT_EQ( | 1585 EXPECT_EQ( |
| 1607 JoinActions( | 1586 JoinActions( |
| 1608 kGrab, | 1587 kGrab, GetFramebufferAction(big_mode_.size(), outputs_[0].get(), |
| 1609 GetFramebufferAction(big_mode_.size(), &outputs_[0], &outputs_[1]) | 1588 outputs_[1].get()) |
| 1610 .c_str(), | 1589 .c_str(), |
| 1611 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 1590 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), |
| 1612 GetCrtcAction(outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(), | 1591 GetCrtcAction(*outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(), |
| 1613 kForceDPMS, | 1592 kForceDPMS, kUngrab, nullptr), |
| 1614 kUngrab, | |
| 1615 NULL), | |
| 1616 log_->GetActionsAndClear()); | 1593 log_->GetActionsAndClear()); |
| 1617 | 1594 |
| 1618 // Suspend and resume the system. Resuming should restore the previous power | 1595 // Suspend and resume the system. Resuming should restore the previous power |
| 1619 // state and force a probe. Suspend should turn off the displays since an | 1596 // state and force a probe. Suspend should turn off the displays since an |
| 1620 // external monitor is connected. | 1597 // external monitor is connected. |
| 1621 configurator_.SuspendDisplays(base::Bind( | 1598 configurator_.SuspendDisplays(base::Bind( |
| 1622 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); | 1599 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); |
| 1623 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 1600 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
| 1624 EXPECT_EQ(2, observer_.num_changes()); | 1601 EXPECT_EQ(2, observer_.num_changes()); |
| 1625 EXPECT_EQ( | 1602 EXPECT_EQ( |
| 1626 JoinActions( | 1603 JoinActions( |
| 1627 kGrab, | 1604 kGrab, GetFramebufferAction(small_mode_.size(), outputs_[0].get(), |
| 1628 GetFramebufferAction(small_mode_.size(), &outputs_[0], | 1605 outputs_[1].get()) |
| 1629 &outputs_[1]).c_str(), | 1606 .c_str(), |
| 1630 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 1607 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), |
| 1631 GetCrtcAction(outputs_[1], NULL, gfx::Point(0, 0)).c_str(), | 1608 GetCrtcAction(*outputs_[1], nullptr, gfx::Point(0, 0)).c_str(), |
| 1632 kUngrab, | 1609 kUngrab, kSync, nullptr), |
| 1633 kSync, | |
| 1634 NULL), | |
| 1635 log_->GetActionsAndClear()); | 1610 log_->GetActionsAndClear()); |
| 1636 | 1611 |
| 1637 // Before the task runs, exit docked mode. | 1612 // Before the task runs, exit docked mode. |
| 1638 configurator_.SetDisplayPower( | 1613 configurator_.SetDisplayPower( |
| 1639 chromeos::DISPLAY_POWER_ALL_ON, | 1614 chromeos::DISPLAY_POWER_ALL_ON, |
| 1640 DisplayConfigurator::kSetDisplayPowerNoFlags, | 1615 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 1641 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 1616 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, |
| 1642 base::Unretained(this))); | 1617 base::Unretained(this))); |
| 1643 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 1618 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
| 1644 EXPECT_EQ(3, observer_.num_changes()); | 1619 EXPECT_EQ(3, observer_.num_changes()); |
| 1645 EXPECT_EQ(0, observer_.num_failures()); | 1620 EXPECT_EQ(0, observer_.num_failures()); |
| 1646 EXPECT_EQ( | 1621 EXPECT_EQ( |
| 1647 JoinActions( | 1622 JoinActions( |
| 1648 kGrab, | 1623 kGrab, GetFramebufferAction(small_mode_.size(), outputs_[0].get(), |
| 1649 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) | 1624 outputs_[1].get()) |
| 1650 .c_str(), | 1625 .c_str(), |
| 1651 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1626 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1652 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), | 1627 GetCrtcAction(*outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1653 kForceDPMS, | 1628 kForceDPMS, kUngrab, nullptr), |
| 1654 kUngrab, | |
| 1655 NULL), | |
| 1656 log_->GetActionsAndClear()); | 1629 log_->GetActionsAndClear()); |
| 1657 | 1630 |
| 1658 // Check that the display states are not changed after resuming. | 1631 // Check that the display states are not changed after resuming. |
| 1659 configurator_.ResumeDisplays(); | 1632 configurator_.ResumeDisplays(); |
| 1660 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1633 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1661 } | 1634 } |
| 1662 | 1635 |
| 1663 TEST_F(DisplayConfiguratorTest, ExternalControl) { | 1636 TEST_F(DisplayConfiguratorTest, ExternalControl) { |
| 1664 InitWithSingleOutput(); | 1637 InitWithSingleOutput(); |
| 1665 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_SINGLE); | 1638 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_SINGLE); |
| 1666 configurator_.RelinquishControl( | 1639 configurator_.RelinquishControl( |
| 1667 base::Bind(&DisplayConfiguratorTest::OnDisplayControlUpdated, | 1640 base::Bind(&DisplayConfiguratorTest::OnDisplayControlUpdated, |
| 1668 base::Unretained(this))); | 1641 base::Unretained(this))); |
| 1669 EXPECT_EQ(CALLBACK_SUCCESS, PopDisplayControlResult()); | 1642 EXPECT_EQ(CALLBACK_SUCCESS, PopDisplayControlResult()); |
| 1643 EXPECT_EQ(JoinActions(kRelinquishDisplayControl, nullptr), |
| 1644 log_->GetActionsAndClear()); |
| 1645 configurator_.TakeControl( |
| 1646 base::Bind(&DisplayConfiguratorTest::OnDisplayControlUpdated, |
| 1647 base::Unretained(this))); |
| 1648 EXPECT_EQ(CALLBACK_SUCCESS, PopDisplayControlResult()); |
| 1670 EXPECT_EQ( | 1649 EXPECT_EQ( |
| 1671 JoinActions( | 1650 JoinActions( |
| 1672 kRelinquishDisplayControl, | 1651 kTakeDisplayControl, kGrab, |
| 1673 NULL), | 1652 GetFramebufferAction(small_mode_.size(), outputs_[0].get(), nullptr) |
| 1653 .c_str(), |
| 1654 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1655 kUngrab, nullptr), |
| 1674 log_->GetActionsAndClear()); | 1656 log_->GetActionsAndClear()); |
| 1675 configurator_.TakeControl( | |
| 1676 base::Bind(&DisplayConfiguratorTest::OnDisplayControlUpdated, | |
| 1677 base::Unretained(this))); | |
| 1678 EXPECT_EQ(CALLBACK_SUCCESS, PopDisplayControlResult()); | |
| 1679 EXPECT_EQ(JoinActions(kTakeDisplayControl, kGrab, | |
| 1680 GetFramebufferAction(small_mode_.size(), &outputs_[0], | |
| 1681 nullptr).c_str(), | |
| 1682 GetCrtcAction(outputs_[0], &small_mode_, | |
| 1683 gfx::Point(0, 0)).c_str(), | |
| 1684 kUngrab, NULL), | |
| 1685 log_->GetActionsAndClear()); | |
| 1686 } | 1657 } |
| 1687 | 1658 |
| 1688 TEST_F(DisplayConfiguratorTest, | 1659 TEST_F(DisplayConfiguratorTest, |
| 1689 SetDisplayPowerWhilePendingConfigurationTaskRunning) { | 1660 SetDisplayPowerWhilePendingConfigurationTaskRunning) { |
| 1690 // Start out with two displays in extended mode. | 1661 // Start out with two displays in extended mode. |
| 1691 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); | 1662 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); |
| 1692 Init(false); | 1663 Init(false); |
| 1693 configurator_.ForceInitialConfigure(0); | 1664 configurator_.ForceInitialConfigure(0); |
| 1694 log_->GetActionsAndClear(); | 1665 log_->GetActionsAndClear(); |
| 1695 observer_.Reset(); | 1666 observer_.Reset(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1714 EXPECT_EQ(1, observer_.num_changes()); | 1685 EXPECT_EQ(1, observer_.num_changes()); |
| 1715 EXPECT_EQ(0, observer_.num_failures()); | 1686 EXPECT_EQ(0, observer_.num_failures()); |
| 1716 | 1687 |
| 1717 const int kDualHeight = small_mode_.size().height() + | 1688 const int kDualHeight = small_mode_.size().height() + |
| 1718 DisplayConfigurator::kVerticalGap + | 1689 DisplayConfigurator::kVerticalGap + |
| 1719 big_mode_.size().height(); | 1690 big_mode_.size().height(); |
| 1720 EXPECT_EQ( | 1691 EXPECT_EQ( |
| 1721 JoinActions( | 1692 JoinActions( |
| 1722 kGrab, | 1693 kGrab, |
| 1723 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), | 1694 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), |
| 1724 &outputs_[0], &outputs_[1]) | 1695 outputs_[0].get(), outputs_[1].get()) |
| 1725 .c_str(), | 1696 .c_str(), |
| 1726 GetCrtcAction(outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), | 1697 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), |
| 1727 GetCrtcAction(outputs_[1], nullptr, | 1698 GetCrtcAction(*outputs_[1], nullptr, |
| 1728 gfx::Point(0, small_mode_.size().height() + | 1699 gfx::Point(0, small_mode_.size().height() + |
| 1729 DisplayConfigurator::kVerticalGap)) | 1700 DisplayConfigurator::kVerticalGap)) |
| 1730 .c_str(), | 1701 .c_str(), |
| 1731 kUngrab, NULL), | 1702 kUngrab, nullptr), |
| 1732 log_->GetActionsAndClear()); | 1703 log_->GetActionsAndClear()); |
| 1733 | 1704 |
| 1734 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); | 1705 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); |
| 1735 base::RunLoop().RunUntilIdle(); | 1706 base::RunLoop().RunUntilIdle(); |
| 1736 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 1707 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
| 1737 EXPECT_EQ(2, observer_.num_changes()); | 1708 EXPECT_EQ(2, observer_.num_changes()); |
| 1738 EXPECT_EQ(0, observer_.num_failures()); | 1709 EXPECT_EQ(0, observer_.num_failures()); |
| 1739 | 1710 |
| 1740 EXPECT_EQ( | 1711 EXPECT_EQ( |
| 1741 JoinActions( | 1712 JoinActions( |
| 1742 kGrab, | 1713 kGrab, |
| 1743 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), | 1714 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), |
| 1744 &outputs_[0], &outputs_[1]) | 1715 outputs_[0].get(), outputs_[1].get()) |
| 1745 .c_str(), | 1716 .c_str(), |
| 1746 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1717 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1747 GetCrtcAction(outputs_[1], &big_mode_, | 1718 GetCrtcAction(*outputs_[1], &big_mode_, |
| 1748 gfx::Point(0, small_mode_.size().height() + | 1719 gfx::Point(0, small_mode_.size().height() + |
| 1749 DisplayConfigurator::kVerticalGap)) | 1720 DisplayConfigurator::kVerticalGap)) |
| 1750 .c_str(), | 1721 .c_str(), |
| 1751 kForceDPMS, kUngrab, NULL), | 1722 kForceDPMS, kUngrab, nullptr), |
| 1752 log_->GetActionsAndClear()); | 1723 log_->GetActionsAndClear()); |
| 1753 } | 1724 } |
| 1754 | 1725 |
| 1755 TEST_F(DisplayConfiguratorTest, | 1726 TEST_F(DisplayConfiguratorTest, |
| 1756 SetDisplayPowerAfterFailedDisplayConfiguration) { | 1727 SetDisplayPowerAfterFailedDisplayConfiguration) { |
| 1757 // Start out with two displays in extended mode. | 1728 // Start out with two displays in extended mode. |
| 1758 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); | 1729 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); |
| 1759 Init(false); | 1730 Init(false); |
| 1760 configurator_.ForceInitialConfigure(0); | 1731 configurator_.ForceInitialConfigure(0); |
| 1761 log_->GetActionsAndClear(); | 1732 log_->GetActionsAndClear(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1775 EXPECT_EQ(1, observer_.num_failures()); | 1746 EXPECT_EQ(1, observer_.num_failures()); |
| 1776 | 1747 |
| 1777 const int kDualHeight = small_mode_.size().height() + | 1748 const int kDualHeight = small_mode_.size().height() + |
| 1778 DisplayConfigurator::kVerticalGap + | 1749 DisplayConfigurator::kVerticalGap + |
| 1779 big_mode_.size().height(); | 1750 big_mode_.size().height(); |
| 1780 | 1751 |
| 1781 EXPECT_EQ( | 1752 EXPECT_EQ( |
| 1782 JoinActions( | 1753 JoinActions( |
| 1783 kGrab, | 1754 kGrab, |
| 1784 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), | 1755 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), |
| 1785 &outputs_[0], &outputs_[1]) | 1756 outputs_[0].get(), outputs_[1].get()) |
| 1786 .c_str(), | 1757 .c_str(), |
| 1787 GetCrtcAction(outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), | 1758 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), |
| 1788 GetCrtcAction(outputs_[1], nullptr, | 1759 GetCrtcAction(*outputs_[1], nullptr, |
| 1789 gfx::Point(0, small_mode_.size().height() + | 1760 gfx::Point(0, small_mode_.size().height() + |
| 1790 DisplayConfigurator::kVerticalGap)) | 1761 DisplayConfigurator::kVerticalGap)) |
| 1791 .c_str(), | 1762 .c_str(), |
| 1792 kUngrab, NULL), | 1763 kUngrab, nullptr), |
| 1793 log_->GetActionsAndClear()); | 1764 log_->GetActionsAndClear()); |
| 1794 | 1765 |
| 1795 // This configuration should trigger a display configuration since the | 1766 // This configuration should trigger a display configuration since the |
| 1796 // previous configuration failed. | 1767 // previous configuration failed. |
| 1797 configurator_.SetDisplayPower( | 1768 configurator_.SetDisplayPower( |
| 1798 chromeos::DISPLAY_POWER_ALL_ON, | 1769 chromeos::DISPLAY_POWER_ALL_ON, |
| 1799 DisplayConfigurator::kSetDisplayPowerNoFlags, | 1770 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 1800 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 1771 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, |
| 1801 base::Unretained(this))); | 1772 base::Unretained(this))); |
| 1802 | 1773 |
| 1803 EXPECT_EQ(0, observer_.num_changes()); | 1774 EXPECT_EQ(0, observer_.num_changes()); |
| 1804 EXPECT_EQ(2, observer_.num_failures()); | 1775 EXPECT_EQ(2, observer_.num_failures()); |
| 1805 EXPECT_EQ( | 1776 EXPECT_EQ( |
| 1806 JoinActions( | 1777 JoinActions( |
| 1807 kGrab, | 1778 kGrab, |
| 1808 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), | 1779 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), |
| 1809 &outputs_[0], &outputs_[1]) | 1780 outputs_[0].get(), outputs_[1].get()) |
| 1810 .c_str(), | 1781 .c_str(), |
| 1811 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1782 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1812 GetCrtcAction(outputs_[1], &big_mode_, | 1783 GetCrtcAction(*outputs_[1], &big_mode_, |
| 1813 gfx::Point(0, small_mode_.size().height() + | 1784 gfx::Point(0, small_mode_.size().height() + |
| 1814 DisplayConfigurator::kVerticalGap)) | 1785 DisplayConfigurator::kVerticalGap)) |
| 1815 .c_str(), | 1786 .c_str(), |
| 1816 GetCrtcAction(outputs_[1], &small_mode_, | 1787 GetCrtcAction(*outputs_[1], &small_mode_, |
| 1817 gfx::Point(0, small_mode_.size().height() + | 1788 gfx::Point(0, small_mode_.size().height() + |
| 1818 DisplayConfigurator::kVerticalGap)) | 1789 DisplayConfigurator::kVerticalGap)) |
| 1819 .c_str(), | 1790 .c_str(), |
| 1820 kUngrab, NULL), | 1791 kUngrab, nullptr), |
| 1821 log_->GetActionsAndClear()); | 1792 log_->GetActionsAndClear()); |
| 1822 | 1793 |
| 1823 // Allow configuration to succeed. | 1794 // Allow configuration to succeed. |
| 1824 native_display_delegate_->set_max_configurable_pixels(0); | 1795 native_display_delegate_->set_max_configurable_pixels(0); |
| 1825 | 1796 |
| 1826 // Validate that a configuration event has the proper power state (displays | 1797 // Validate that a configuration event has the proper power state (displays |
| 1827 // should be on). | 1798 // should be on). |
| 1828 configurator_.OnConfigurationChanged(); | 1799 configurator_.OnConfigurationChanged(); |
| 1829 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); | 1800 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); |
| 1830 | 1801 |
| 1831 EXPECT_EQ(1, observer_.num_changes()); | 1802 EXPECT_EQ(1, observer_.num_changes()); |
| 1832 EXPECT_EQ(2, observer_.num_failures()); | 1803 EXPECT_EQ(2, observer_.num_failures()); |
| 1833 | 1804 |
| 1834 EXPECT_EQ( | 1805 EXPECT_EQ( |
| 1835 JoinActions( | 1806 JoinActions( |
| 1836 kGrab, | 1807 kGrab, |
| 1837 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), | 1808 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), |
| 1838 &outputs_[0], &outputs_[1]) | 1809 outputs_[0].get(), outputs_[1].get()) |
| 1839 .c_str(), | 1810 .c_str(), |
| 1840 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1811 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1841 GetCrtcAction(outputs_[1], &big_mode_, | 1812 GetCrtcAction(*outputs_[1], &big_mode_, |
| 1842 gfx::Point(0, small_mode_.size().height() + | 1813 gfx::Point(0, small_mode_.size().height() + |
| 1843 DisplayConfigurator::kVerticalGap)) | 1814 DisplayConfigurator::kVerticalGap)) |
| 1844 .c_str(), | 1815 .c_str(), |
| 1845 kUngrab, NULL), | 1816 kUngrab, nullptr), |
| 1846 log_->GetActionsAndClear()); | 1817 log_->GetActionsAndClear()); |
| 1847 } | 1818 } |
| 1848 | 1819 |
| 1849 TEST_F(DisplayConfiguratorTest, TestWithThreeDisplays) { | 1820 TEST_F(DisplayConfiguratorTest, TestWithThreeDisplays) { |
| 1850 // Start out with two displays in extended mode. | 1821 // Start out with two displays in extended mode. |
| 1851 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); | 1822 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); |
| 1852 Init(false); | 1823 Init(false); |
| 1853 configurator_.ForceInitialConfigure(0); | 1824 configurator_.ForceInitialConfigure(0); |
| 1854 log_->GetActionsAndClear(); | 1825 log_->GetActionsAndClear(); |
| 1855 observer_.Reset(); | 1826 observer_.Reset(); |
| 1856 | 1827 |
| 1857 UpdateOutputs(3, true); | 1828 UpdateOutputs(3, true); |
| 1858 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED); | 1829 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED); |
| 1859 | 1830 |
| 1860 const int kDualHeight = small_mode_.size().height() + | 1831 const int kDualHeight = small_mode_.size().height() + |
| 1861 DisplayConfigurator::kVerticalGap + | 1832 DisplayConfigurator::kVerticalGap + |
| 1862 big_mode_.size().height(); | 1833 big_mode_.size().height(); |
| 1863 const int kTripleHeight = 2 * small_mode_.size().height() + | 1834 const int kTripleHeight = 2 * small_mode_.size().height() + |
| 1864 2 * DisplayConfigurator::kVerticalGap + | 1835 2 * DisplayConfigurator::kVerticalGap + |
| 1865 big_mode_.size().height(); | 1836 big_mode_.size().height(); |
| 1866 EXPECT_EQ( | 1837 EXPECT_EQ( |
| 1867 JoinActions( | 1838 JoinActions( |
| 1868 kGrab, GetFramebufferAction( | 1839 kGrab, GetFramebufferAction( |
| 1869 gfx::Size(big_mode_.size().width(), kTripleHeight), | 1840 gfx::Size(big_mode_.size().width(), kTripleHeight), |
| 1870 &outputs_[0], &outputs_[1]) | 1841 outputs_[0].get(), outputs_[1].get()) |
| 1871 .c_str(), | 1842 .c_str(), |
| 1872 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1843 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1873 GetCrtcAction(outputs_[1], &big_mode_, | 1844 GetCrtcAction(*outputs_[1], &big_mode_, |
| 1874 gfx::Point(0, small_mode_.size().height() + | 1845 gfx::Point(0, small_mode_.size().height() + |
| 1875 DisplayConfigurator::kVerticalGap)) | 1846 DisplayConfigurator::kVerticalGap)) |
| 1876 .c_str(), | 1847 .c_str(), |
| 1877 GetCrtcAction( | 1848 GetCrtcAction( |
| 1878 outputs_[2], &small_mode_, | 1849 *outputs_[2], &small_mode_, |
| 1879 gfx::Point(0, small_mode_.size().height() + | 1850 gfx::Point(0, small_mode_.size().height() + |
| 1880 big_mode_.size().height() + | 1851 big_mode_.size().height() + |
| 1881 2 * DisplayConfigurator::kVerticalGap)) | 1852 2 * DisplayConfigurator::kVerticalGap)) |
| 1882 .c_str(), | 1853 .c_str(), |
| 1883 kUngrab, NULL), | 1854 kUngrab, nullptr), |
| 1884 log_->GetActionsAndClear()); | 1855 log_->GetActionsAndClear()); |
| 1885 | 1856 |
| 1886 // Verify that turning the power off works. | 1857 // Verify that turning the power off works. |
| 1887 configurator_.SetDisplayPower( | 1858 configurator_.SetDisplayPower( |
| 1888 chromeos::DISPLAY_POWER_ALL_OFF, | 1859 chromeos::DISPLAY_POWER_ALL_OFF, |
| 1889 DisplayConfigurator::kSetDisplayPowerNoFlags, | 1860 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 1890 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 1861 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, |
| 1891 base::Unretained(this))); | 1862 base::Unretained(this))); |
| 1892 | 1863 |
| 1893 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 1864 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
| 1894 EXPECT_EQ( | 1865 EXPECT_EQ( |
| 1895 JoinActions( | 1866 JoinActions( |
| 1896 kGrab, GetFramebufferAction( | 1867 kGrab, GetFramebufferAction( |
| 1897 gfx::Size(big_mode_.size().width(), kTripleHeight), | 1868 gfx::Size(big_mode_.size().width(), kTripleHeight), |
| 1898 &outputs_[0], &outputs_[1]) | 1869 outputs_[0].get(), outputs_[1].get()) |
| 1899 .c_str(), | 1870 .c_str(), |
| 1900 GetCrtcAction(outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), | 1871 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), |
| 1901 GetCrtcAction(outputs_[1], nullptr, | 1872 GetCrtcAction(*outputs_[1], nullptr, |
| 1902 gfx::Point(0, small_mode_.size().height() + | 1873 gfx::Point(0, small_mode_.size().height() + |
| 1903 DisplayConfigurator::kVerticalGap)) | 1874 DisplayConfigurator::kVerticalGap)) |
| 1904 .c_str(), | 1875 .c_str(), |
| 1905 GetCrtcAction( | 1876 GetCrtcAction( |
| 1906 outputs_[2], nullptr, | 1877 *outputs_[2], nullptr, |
| 1907 gfx::Point(0, small_mode_.size().height() + | 1878 gfx::Point(0, small_mode_.size().height() + |
| 1908 big_mode_.size().height() + | 1879 big_mode_.size().height() + |
| 1909 2 * DisplayConfigurator::kVerticalGap)) | 1880 2 * DisplayConfigurator::kVerticalGap)) |
| 1910 .c_str(), | 1881 .c_str(), |
| 1911 kUngrab, NULL), | 1882 kUngrab, nullptr), |
| 1912 log_->GetActionsAndClear()); | 1883 log_->GetActionsAndClear()); |
| 1913 | 1884 |
| 1914 configurator_.SetDisplayPower( | 1885 configurator_.SetDisplayPower( |
| 1915 chromeos::DISPLAY_POWER_ALL_ON, | 1886 chromeos::DISPLAY_POWER_ALL_ON, |
| 1916 DisplayConfigurator::kSetDisplayPowerNoFlags, | 1887 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 1917 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 1888 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, |
| 1918 base::Unretained(this))); | 1889 base::Unretained(this))); |
| 1919 | 1890 |
| 1920 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 1891 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
| 1921 EXPECT_EQ( | 1892 EXPECT_EQ( |
| 1922 JoinActions( | 1893 JoinActions( |
| 1923 kGrab, GetFramebufferAction( | 1894 kGrab, GetFramebufferAction( |
| 1924 gfx::Size(big_mode_.size().width(), kTripleHeight), | 1895 gfx::Size(big_mode_.size().width(), kTripleHeight), |
| 1925 &outputs_[0], &outputs_[1]) | 1896 outputs_[0].get(), outputs_[1].get()) |
| 1926 .c_str(), | 1897 .c_str(), |
| 1927 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1898 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1928 GetCrtcAction(outputs_[1], &big_mode_, | 1899 GetCrtcAction(*outputs_[1], &big_mode_, |
| 1929 gfx::Point(0, small_mode_.size().height() + | 1900 gfx::Point(0, small_mode_.size().height() + |
| 1930 DisplayConfigurator::kVerticalGap)) | 1901 DisplayConfigurator::kVerticalGap)) |
| 1931 .c_str(), | 1902 .c_str(), |
| 1932 GetCrtcAction( | 1903 GetCrtcAction( |
| 1933 outputs_[2], &small_mode_, | 1904 *outputs_[2], &small_mode_, |
| 1934 gfx::Point(0, small_mode_.size().height() + | 1905 gfx::Point(0, small_mode_.size().height() + |
| 1935 big_mode_.size().height() + | 1906 big_mode_.size().height() + |
| 1936 2 * DisplayConfigurator::kVerticalGap)) | 1907 2 * DisplayConfigurator::kVerticalGap)) |
| 1937 .c_str(), | 1908 .c_str(), |
| 1938 kForceDPMS, kUngrab, NULL), | 1909 kForceDPMS, kUngrab, nullptr), |
| 1939 log_->GetActionsAndClear()); | 1910 log_->GetActionsAndClear()); |
| 1940 | 1911 |
| 1941 // Disconnect the third output. | 1912 // Disconnect the third output. |
| 1942 observer_.Reset(); | 1913 observer_.Reset(); |
| 1943 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); | 1914 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); |
| 1944 UpdateOutputs(2, true); | 1915 UpdateOutputs(2, true); |
| 1945 EXPECT_EQ( | 1916 EXPECT_EQ( |
| 1946 JoinActions( | 1917 JoinActions( |
| 1947 kGrab, | 1918 kGrab, |
| 1948 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), | 1919 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), |
| 1949 &outputs_[0], &outputs_[1]) | 1920 outputs_[0].get(), outputs_[1].get()) |
| 1950 .c_str(), | 1921 .c_str(), |
| 1951 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1922 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1952 GetCrtcAction(outputs_[1], &big_mode_, | 1923 GetCrtcAction(*outputs_[1], &big_mode_, |
| 1953 gfx::Point(0, small_mode_.size().height() + | 1924 gfx::Point(0, small_mode_.size().height() + |
| 1954 DisplayConfigurator::kVerticalGap)) | 1925 DisplayConfigurator::kVerticalGap)) |
| 1955 .c_str(), | 1926 .c_str(), |
| 1956 kUngrab, NULL), | 1927 kUngrab, nullptr), |
| 1957 log_->GetActionsAndClear()); | 1928 log_->GetActionsAndClear()); |
| 1958 } | 1929 } |
| 1959 | 1930 |
| 1960 } // namespace test | 1931 } // namespace test |
| 1961 } // namespace ui | 1932 } // namespace ui |
| OLD | NEW |