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

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

Issue 1861593002: chromeos: Turn off displays on suspend (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: chromeos: Turn off displays on suspend Created 4 years, 8 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 9a4f2d99f266e3e9e8135a61aeb37ec25218f324..14ff27ede10485ec5ee5bb126d2fc5720b9e9ac9 100644
--- a/ui/display/chromeos/display_configurator_unittest.cc
+++ b/ui/display/chromeos/display_configurator_unittest.cc
@@ -841,9 +841,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,
@@ -874,19 +881,16 @@ 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(kNoActions, log_->GetActionsAndClear());
+
+ configurator_.SetDisplayPower(
+ chromeos::DISPLAY_POWER_ALL_ON,
+ DisplayConfigurator::kSetDisplayPowerNoFlags,
+ base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback,
+ base::Unretained(this)));
EXPECT_EQ(
JoinActions(
kGrab,
@@ -912,6 +916,8 @@ TEST_F(DisplayConfiguratorTest, SuspendAndResume) {
NULL),
log_->GetActionsAndClear());
+ // Expect setting the power to off to do nothing if the displays are
+ // suspended.
Daniel Erat 2016/04/25 21:10:00 this comment is a bit off, right? i don't think th
dbasehore 2016/04/25 21:13:23 Removed the above comment too since it doesn't mak
configurator_.SetDisplayPower(
chromeos::DISPLAY_POWER_ALL_OFF,
DisplayConfigurator::kSetDisplayPowerNoFlags,
@@ -919,31 +925,38 @@ 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(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 +1218,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.
@@ -1213,21 +1234,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,
@@ -1257,34 +1272,33 @@ TEST_F(DisplayConfiguratorTest, DoNotConfigureWithSuspendedDisplays) {
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(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_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,
+ 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,
@@ -1564,12 +1578,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(
@@ -1578,7 +1604,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(
@@ -1592,20 +1618,9 @@ 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());
- 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) {
« 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