Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Unified Diff: ui/display/chromeos/display_configurator_unittest.cc

Issue 1949753004: Revert of chromeos: Turn off displays on suspend (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert PS that actually landed: PS#11, not PS#12 Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/display/chromeos/display_configurator.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 aaee7b526b67f0730ee70d3bac89e44ff0a0982c..9a4f2d99f266e3e9e8135a61aeb37ec25218f324 100644
--- a/ui/display/chromeos/display_configurator_unittest.cc
+++ b/ui/display/chromeos/display_configurator_unittest.cc
@@ -841,16 +841,9 @@ TEST_F(DisplayConfiguratorTest, SuspendAndResume) {
EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult());
EXPECT_EQ(framebuffer_size.ToString(),
configurator_.framebuffer_size().ToString());
- 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_EQ(kNoActions, log_->GetActionsAndClear());
configurator_.ResumeDisplays();
+ EXPECT_TRUE(test_api_.TriggerConfigureTimeout());
EXPECT_EQ(
JoinActions(
kGrab,
@@ -881,16 +874,19 @@ TEST_F(DisplayConfiguratorTest, SuspendAndResume) {
configurator_.SuspendDisplays(base::Bind(
&DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this)));
EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult());
- EXPECT_EQ(kSync, log_->GetActionsAndClear());
+ 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());
configurator_.ResumeDisplays();
- EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
-
- configurator_.SetDisplayPower(
- chromeos::DISPLAY_POWER_ALL_ON,
- DisplayConfigurator::kSetDisplayPowerNoFlags,
- base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback,
- base::Unretained(this)));
+ EXPECT_TRUE(test_api_.TriggerConfigureTimeout());
EXPECT_EQ(
JoinActions(
kGrab,
@@ -901,6 +897,8 @@ TEST_F(DisplayConfiguratorTest, SuspendAndResume) {
NULL),
log_->GetActionsAndClear());
+ // If a second, external display is connected, the displays shouldn't be
+ // powered back on before suspending.
state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR);
UpdateOutputs(2, true);
EXPECT_EQ(
@@ -921,38 +919,31 @@ TEST_F(DisplayConfiguratorTest, SuspendAndResume) {
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(kSync, log_->GetActionsAndClear());
+ EXPECT_EQ(JoinActions(kGrab, kUngrab, kSync, NULL),
+ log_->GetActionsAndClear());
// If a display is disconnected while suspended, the configurator should
- // pick up the change and only turn on the internal display.
+ // pick up the change.
UpdateOutputs(1, false);
configurator_.ResumeDisplays();
- EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
-
- configurator_.SetDisplayPower(
- chromeos::DISPLAY_POWER_ALL_ON,
- DisplayConfigurator::kSetDisplayPowerNoFlags,
- base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback,
- base::Unretained(this)));
+ 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,
+ GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(),
kUngrab,
NULL),
log_->GetActionsAndClear());
@@ -1214,15 +1205,7 @@ TEST_F(DisplayConfiguratorTest, DoNotConfigureWithSuspendedDisplays) {
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], NULL, gfx::Point(0, 0)).c_str(),
- kUngrab,
- kSync,
- NULL),
- log_->GetActionsAndClear());
+ EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
// The configuration timer should not be started when the displays
// are suspended.
@@ -1230,15 +1213,21 @@ TEST_F(DisplayConfiguratorTest, DoNotConfigureWithSuspendedDisplays) {
EXPECT_FALSE(test_api_.TriggerConfigureTimeout());
EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
- // Calls to SetDisplayPower should do nothing if the power state doesn't
- // change.
+ // Calls to SetDisplayPower and SetDisplayMode should be successful.
configurator_.SetDisplayPower(
chromeos::DISPLAY_POWER_ALL_OFF,
DisplayConfigurator::kSetDisplayPowerNoFlags,
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,
+ NULL),
+ log_->GetActionsAndClear());
configurator_.SetDisplayPower(
chromeos::DISPLAY_POWER_ALL_ON,
DisplayConfigurator::kSetDisplayPowerNoFlags,
@@ -1268,33 +1257,34 @@ TEST_F(DisplayConfiguratorTest, DoNotConfigureWithSuspendedDisplays) {
NULL),
log_->GetActionsAndClear());
- // The DisplayConfigurator should do nothing at resume time if there is no
- // state change.
+ // The DisplayConfigurator should force a probe and reconfiguration at resume
+ // time.
UpdateOutputs(1, false);
configurator_.ResumeDisplays();
- 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. 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_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,
- kSync,
NULL),
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.
+ configurator_.OnConfigurationChanged();
+ configurator_.SuspendDisplays(base::Bind(
+ &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this)));
+ EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult());
+ EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
+
EXPECT_FALSE(test_api_.TriggerConfigureTimeout());
EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
configurator_.ResumeDisplays();
+ EXPECT_TRUE(test_api_.TriggerConfigureTimeout());
EXPECT_EQ(
JoinActions(
kGrab,
@@ -1574,24 +1564,12 @@ TEST_F(DisplayConfiguratorTest, DontRestoreStalePowerStateAfterResume) {
NULL),
log_->GetActionsAndClear());
- // 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.
+ // Suspend and resume the system. Resuming should post a task to restore the
+ // previous power state, additionally forcing a probe.
configurator_.SuspendDisplays(base::Bind(
&DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this)));
EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult());
- 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());
+ configurator_.ResumeDisplays();
// Before the task runs, exit docked mode.
configurator_.SetDisplayPower(
@@ -1600,7 +1578,7 @@ TEST_F(DisplayConfiguratorTest, DontRestoreStalePowerStateAfterResume) {
base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback,
base::Unretained(this)));
EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult());
- EXPECT_EQ(3, observer_.num_changes());
+ EXPECT_EQ(2, observer_.num_changes());
EXPECT_EQ(0, observer_.num_failures());
EXPECT_EQ(
JoinActions(
@@ -1614,9 +1592,20 @@ TEST_F(DisplayConfiguratorTest, DontRestoreStalePowerStateAfterResume) {
NULL),
log_->GetActionsAndClear());
- // Check that the display states are not changed after resuming.
- configurator_.ResumeDisplays();
- EXPECT_EQ(kNoActions, 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());
}
TEST_F(DisplayConfiguratorTest, ExternalControl) {
« no previous file with comments | « ui/display/chromeos/display_configurator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698