| Index: ui/display/chromeos/display_configurator_unittest.cc
|
| diff --git a/ui/display/chromeos/display_configurator_unittest.cc b/ui/display/chromeos/display_configurator_unittest.cc
|
| index 9a4f2d99f266e3e9e8135a61aeb37ec25218f324..aaee7b526b67f0730ee70d3bac89e44ff0a0982c 100644
|
| --- a/ui/display/chromeos/display_configurator_unittest.cc
|
| +++ b/ui/display/chromeos/display_configurator_unittest.cc
|
| @@ -841,9 +841,16 @@
|
| EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult());
|
| EXPECT_EQ(framebuffer_size.ToString(),
|
| configurator_.framebuffer_size().ToString());
|
| - EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
|
| + EXPECT_EQ(
|
| + JoinActions(
|
| + kGrab,
|
| + GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(),
|
| + GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(),
|
| + kUngrab,
|
| + kSync,
|
| + NULL),
|
| + log_->GetActionsAndClear());
|
| configurator_.ResumeDisplays();
|
| - EXPECT_TRUE(test_api_.TriggerConfigureTimeout());
|
| EXPECT_EQ(
|
| JoinActions(
|
| kGrab,
|
| @@ -874,6 +881,16 @@
|
| configurator_.SuspendDisplays(base::Bind(
|
| &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this)));
|
| EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult());
|
| + EXPECT_EQ(kSync, log_->GetActionsAndClear());
|
| +
|
| + configurator_.ResumeDisplays();
|
| + EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
|
| +
|
| + configurator_.SetDisplayPower(
|
| + chromeos::DISPLAY_POWER_ALL_ON,
|
| + DisplayConfigurator::kSetDisplayPowerNoFlags,
|
| + base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback,
|
| + base::Unretained(this)));
|
| EXPECT_EQ(
|
| JoinActions(
|
| kGrab,
|
| @@ -881,24 +898,9 @@
|
| GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
|
| kForceDPMS,
|
| kUngrab,
|
| - kSync,
|
| - NULL),
|
| - log_->GetActionsAndClear());
|
| -
|
| - configurator_.ResumeDisplays();
|
| - EXPECT_TRUE(test_api_.TriggerConfigureTimeout());
|
| - EXPECT_EQ(
|
| - JoinActions(
|
| - kGrab,
|
| - GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(),
|
| - GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
|
| - kForceDPMS,
|
| - kUngrab,
|
| - NULL),
|
| - log_->GetActionsAndClear());
|
| -
|
| - // If a second, external display is connected, the displays shouldn't be
|
| - // powered back on before suspending.
|
| + NULL),
|
| + log_->GetActionsAndClear());
|
| +
|
| state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR);
|
| UpdateOutputs(2, true);
|
| EXPECT_EQ(
|
| @@ -919,31 +921,38 @@
|
| base::Unretained(this)));
|
| EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult());
|
| EXPECT_EQ(
|
| - JoinActions(kGrab,
|
| - GetFramebufferAction(
|
| - small_mode_.size(), &outputs_[0], &outputs_[1]).c_str(),
|
| - GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(),
|
| - GetCrtcAction(outputs_[1], NULL, gfx::Point(0, 0)).c_str(),
|
| - kUngrab,
|
| - NULL),
|
| + JoinActions(
|
| + kGrab,
|
| + GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1])
|
| + .c_str(),
|
| + GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(),
|
| + GetCrtcAction(outputs_[1], NULL, gfx::Point(0, 0)).c_str(),
|
| + kUngrab,
|
| + NULL),
|
| log_->GetActionsAndClear());
|
|
|
| configurator_.SuspendDisplays(base::Bind(
|
| &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this)));
|
| EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult());
|
| - EXPECT_EQ(JoinActions(kGrab, kUngrab, kSync, NULL),
|
| - log_->GetActionsAndClear());
|
| + EXPECT_EQ(kSync, log_->GetActionsAndClear());
|
|
|
| // If a display is disconnected while suspended, the configurator should
|
| - // pick up the change.
|
| + // pick up the change and only turn on the internal display.
|
| UpdateOutputs(1, false);
|
| configurator_.ResumeDisplays();
|
| - EXPECT_TRUE(test_api_.TriggerConfigureTimeout());
|
| + EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
|
| +
|
| + configurator_.SetDisplayPower(
|
| + chromeos::DISPLAY_POWER_ALL_ON,
|
| + DisplayConfigurator::kSetDisplayPowerNoFlags,
|
| + base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback,
|
| + base::Unretained(this)));
|
| EXPECT_EQ(
|
| JoinActions(
|
| kGrab,
|
| GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(),
|
| - GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(),
|
| + GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
|
| + kForceDPMS,
|
| kUngrab,
|
| NULL),
|
| log_->GetActionsAndClear());
|
| @@ -1205,7 +1214,15 @@
|
| configurator_.SuspendDisplays(base::Bind(
|
| &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this)));
|
| EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult());
|
| - EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
|
| + EXPECT_EQ(
|
| + JoinActions(
|
| + kGrab,
|
| + GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(),
|
| + GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(),
|
| + kUngrab,
|
| + kSync,
|
| + NULL),
|
| + log_->GetActionsAndClear());
|
|
|
| // The configuration timer should not be started when the displays
|
| // are suspended.
|
| @@ -1213,21 +1230,15 @@
|
| EXPECT_FALSE(test_api_.TriggerConfigureTimeout());
|
| EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
|
|
|
| - // Calls to SetDisplayPower and SetDisplayMode should be successful.
|
| + // Calls to SetDisplayPower should do nothing if the power state doesn't
|
| + // change.
|
| configurator_.SetDisplayPower(
|
| chromeos::DISPLAY_POWER_ALL_OFF,
|
| DisplayConfigurator::kSetDisplayPowerNoFlags,
|
| base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback,
|
| base::Unretained(this)));
|
| EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult());
|
| - EXPECT_EQ(
|
| - JoinActions(
|
| - kGrab,
|
| - GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(),
|
| - GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(),
|
| - kUngrab,
|
| - NULL),
|
| - log_->GetActionsAndClear());
|
| + EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
|
| configurator_.SetDisplayPower(
|
| chromeos::DISPLAY_POWER_ALL_ON,
|
| DisplayConfigurator::kSetDisplayPowerNoFlags,
|
| @@ -1257,34 +1268,33 @@
|
| NULL),
|
| log_->GetActionsAndClear());
|
|
|
| - // The DisplayConfigurator should force a probe and reconfiguration at resume
|
| - // time.
|
| + // The DisplayConfigurator should do nothing at resume time if there is no
|
| + // state change.
|
| UpdateOutputs(1, false);
|
| configurator_.ResumeDisplays();
|
| - EXPECT_TRUE(test_api_.TriggerConfigureTimeout());
|
| - EXPECT_EQ(
|
| - JoinActions(
|
| - kGrab,
|
| - GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(),
|
| - GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
|
| - kForceDPMS,
|
| - kUngrab,
|
| - NULL),
|
| - log_->GetActionsAndClear());
|
| + EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
|
|
|
| // If a configuration task is pending when the displays are suspended, that
|
| - // task should not run either and the timer should be stopped.
|
| + // task should not run either and the timer should be stopped. The displays
|
| + // should be turned off by suspend.
|
| configurator_.OnConfigurationChanged();
|
| configurator_.SuspendDisplays(base::Bind(
|
| &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this)));
|
| EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult());
|
| - EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
|
| + EXPECT_EQ(
|
| + JoinActions(
|
| + kGrab,
|
| + GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(),
|
| + GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(),
|
| + kUngrab,
|
| + kSync,
|
| + NULL),
|
| + log_->GetActionsAndClear());
|
|
|
| EXPECT_FALSE(test_api_.TriggerConfigureTimeout());
|
| EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
|
|
|
| configurator_.ResumeDisplays();
|
| - EXPECT_TRUE(test_api_.TriggerConfigureTimeout());
|
| EXPECT_EQ(
|
| JoinActions(
|
| kGrab,
|
| @@ -1564,12 +1574,24 @@
|
| NULL),
|
| log_->GetActionsAndClear());
|
|
|
| - // Suspend and resume the system. Resuming should post a task to restore the
|
| - // previous power state, additionally forcing a probe.
|
| + // Suspend and resume the system. Resuming should restore the previous power
|
| + // state and force a probe. Suspend should turn off the displays since an
|
| + // external monitor is connected.
|
| configurator_.SuspendDisplays(base::Bind(
|
| &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this)));
|
| EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult());
|
| - configurator_.ResumeDisplays();
|
| + EXPECT_EQ(2, observer_.num_changes());
|
| + EXPECT_EQ(
|
| + JoinActions(
|
| + kGrab,
|
| + GetFramebufferAction(small_mode_.size(), &outputs_[0],
|
| + &outputs_[1]).c_str(),
|
| + GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(),
|
| + GetCrtcAction(outputs_[1], NULL, gfx::Point(0, 0)).c_str(),
|
| + kUngrab,
|
| + kSync,
|
| + NULL),
|
| + log_->GetActionsAndClear());
|
|
|
| // Before the task runs, exit docked mode.
|
| configurator_.SetDisplayPower(
|
| @@ -1578,7 +1600,7 @@
|
| base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback,
|
| base::Unretained(this)));
|
| EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult());
|
| - EXPECT_EQ(2, observer_.num_changes());
|
| + EXPECT_EQ(3, observer_.num_changes());
|
| EXPECT_EQ(0, observer_.num_failures());
|
| EXPECT_EQ(
|
| JoinActions(
|
| @@ -1592,20 +1614,9 @@
|
| NULL),
|
| log_->GetActionsAndClear());
|
|
|
| - // Check that the task doesn't restore the old internal-off-external-on power
|
| - // state.
|
| - EXPECT_TRUE(test_api_.TriggerConfigureTimeout());
|
| - EXPECT_EQ(
|
| - JoinActions(
|
| - kGrab,
|
| - GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1])
|
| - .c_str(),
|
| - GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
|
| - GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(),
|
| - kForceDPMS,
|
| - kUngrab,
|
| - NULL),
|
| - log_->GetActionsAndClear());
|
| + // Check that the display states are not changed after resuming.
|
| + configurator_.ResumeDisplays();
|
| + EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
|
| }
|
|
|
| TEST_F(DisplayConfiguratorTest, ExternalControl) {
|
|
|