OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/display/chromeos/display_configurator.h" | 5 #include "ui/display/chromeos/display_configurator.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <cmath> | 9 #include <cmath> |
10 #include <cstdarg> | 10 #include <cstdarg> |
(...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1331 EXPECT_EQ( | 1331 EXPECT_EQ( |
1332 JoinActions( | 1332 JoinActions( |
1333 kGrab, | 1333 kGrab, |
1334 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 1334 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), |
1335 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1335 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
1336 kUngrab, | 1336 kUngrab, |
1337 NULL), | 1337 NULL), |
1338 log_->GetActionsAndClear()); | 1338 log_->GetActionsAndClear()); |
1339 } | 1339 } |
1340 | 1340 |
| 1341 // Tests that the SetDisplayPowerState() task posted by HandleResume() doesn't |
| 1342 // use a stale state if a new state is requested before it runs: |
| 1343 // http://crosbug.com/p/32393 |
| 1344 TEST_F(DisplayConfiguratorTest, DontRestoreStalePowerStateAfterResume) { |
| 1345 // Start out with two displays in mirrored mode. |
| 1346 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
| 1347 configurator_.Init(false); |
| 1348 configurator_.ForceInitialConfigure(0); |
| 1349 log_->GetActionsAndClear(); |
| 1350 |
| 1351 // Turn off the internal display, simulating docked mode. |
| 1352 EXPECT_TRUE(configurator_.SetDisplayPower( |
| 1353 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, |
| 1354 DisplayConfigurator::kSetDisplayPowerNoFlags)); |
| 1355 EXPECT_EQ( |
| 1356 JoinActions( |
| 1357 kGrab, |
| 1358 GetFramebufferAction(big_mode_.size(), &outputs_[0], &outputs_[1]) |
| 1359 .c_str(), |
| 1360 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), |
| 1361 GetCrtcAction(outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(), |
| 1362 kForceDPMS, |
| 1363 kUngrab, |
| 1364 NULL), |
| 1365 log_->GetActionsAndClear()); |
| 1366 |
| 1367 // Suspend and resume the system. Resuming should post a task to restore the |
| 1368 // previous power state, additionally forcing a probe. |
| 1369 configurator_.SuspendDisplays(); |
| 1370 configurator_.ResumeDisplays(); |
| 1371 |
| 1372 // Before the task runs, exit docked mode. |
| 1373 EXPECT_TRUE(configurator_.SetDisplayPower( |
| 1374 chromeos::DISPLAY_POWER_ALL_ON, |
| 1375 DisplayConfigurator::kSetDisplayPowerNoFlags)); |
| 1376 EXPECT_EQ( |
| 1377 JoinActions( |
| 1378 kGrab, |
| 1379 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) |
| 1380 .c_str(), |
| 1381 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1382 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1383 kForceDPMS, |
| 1384 kUngrab, |
| 1385 NULL), |
| 1386 log_->GetActionsAndClear()); |
| 1387 |
| 1388 // Check that the task doesn't restore the old internal-off-external-on power |
| 1389 // state. |
| 1390 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); |
| 1391 EXPECT_EQ( |
| 1392 JoinActions( |
| 1393 kGrab, |
| 1394 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) |
| 1395 .c_str(), |
| 1396 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1397 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1398 kForceDPMS, |
| 1399 kUngrab, |
| 1400 NULL), |
| 1401 log_->GetActionsAndClear()); |
| 1402 } |
| 1403 |
1341 } // namespace ui | 1404 } // namespace ui |
OLD | NEW |