| 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 4cf8fadf92689e46778bbf969ffe8cc0eb80ae66..1c06953803d85204f31d26d717a25efce87b4755 100644
|
| --- a/ui/display/chromeos/display_configurator_unittest.cc
|
| +++ b/ui/display/chromeos/display_configurator_unittest.cc
|
| @@ -835,9 +835,16 @@ TEST_F(DisplayConfiguratorTest, SuspendAndResume) {
|
| 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,
|
| @@ -868,19 +875,9 @@ TEST_F(DisplayConfiguratorTest, SuspendAndResume) {
|
| configurator_.SuspendDisplays(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], &small_mode_, gfx::Point(0, 0)).c_str(),
|
| - kForceDPMS,
|
| - kUngrab,
|
| - kSync,
|
| - NULL),
|
| - log_->GetActionsAndClear());
|
| + EXPECT_EQ(kSync, log_->GetActionsAndClear());
|
|
|
| configurator_.ResumeDisplays();
|
| - EXPECT_TRUE(test_api_.TriggerConfigureTimeout());
|
| EXPECT_EQ(
|
| JoinActions(
|
| kGrab,
|
| @@ -925,19 +922,18 @@ TEST_F(DisplayConfiguratorTest, SuspendAndResume) {
|
| 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(
|
| 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());
|
| @@ -1199,7 +1195,15 @@ TEST_F(DisplayConfiguratorTest, DoNotConfigureWithSuspendedDisplays) {
|
| 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.
|
| @@ -1207,21 +1211,15 @@ TEST_F(DisplayConfiguratorTest, DoNotConfigureWithSuspendedDisplays) {
|
| 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,
|
| @@ -1255,7 +1253,6 @@ TEST_F(DisplayConfiguratorTest, DoNotConfigureWithSuspendedDisplays) {
|
| // time.
|
| UpdateOutputs(1, false);
|
| configurator_.ResumeDisplays();
|
| - EXPECT_TRUE(test_api_.TriggerConfigureTimeout());
|
| EXPECT_EQ(
|
| JoinActions(
|
| kGrab,
|
| @@ -1267,18 +1264,26 @@ TEST_F(DisplayConfiguratorTest, DoNotConfigureWithSuspendedDisplays) {
|
| 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,
|
| @@ -1558,12 +1563,24 @@ TEST_F(DisplayConfiguratorTest, DontRestoreStalePowerStateAfterResume) {
|
| 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(
|
| @@ -1572,7 +1589,7 @@ TEST_F(DisplayConfiguratorTest, DontRestoreStalePowerStateAfterResume) {
|
| 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(
|
| @@ -1586,9 +1603,8 @@ TEST_F(DisplayConfiguratorTest, DontRestoreStalePowerStateAfterResume) {
|
| NULL),
|
| log_->GetActionsAndClear());
|
|
|
| - // Check that the task doesn't restore the old internal-off-external-on power
|
| - // state.
|
| - EXPECT_TRUE(test_api_.TriggerConfigureTimeout());
|
| + // Check that the display states are not changed after resuming.
|
| + configurator_.ResumeDisplays();
|
| EXPECT_EQ(
|
| JoinActions(
|
| kGrab,
|
|
|