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

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
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..c7990660052aba4972bdd2eb92c56957eb1e0c0d 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,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,
@@ -931,19 +928,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());
@@ -1205,7 +1201,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 +1217,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,
@@ -1261,7 +1259,6 @@ TEST_F(DisplayConfiguratorTest, DoNotConfigureWithSuspendedDisplays) {
// time.
UpdateOutputs(1, false);
configurator_.ResumeDisplays();
- EXPECT_TRUE(test_api_.TriggerConfigureTimeout());
EXPECT_EQ(
JoinActions(
kGrab,
@@ -1273,18 +1270,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,
@@ -1564,12 +1569,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 +1595,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,9 +1609,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,
« ui/display/chromeos/display_configurator.cc ('K') | « ui/display/chromeos/display_configurator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698