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 "base/memory/scoped_vector.h" | 7 #include "base/memory/scoped_vector.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "ui/display/chromeos/test/action_logger_util.h" | 10 #include "ui/display/chromeos/test/action_logger_util.h" |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 } | 652 } |
653 | 653 |
654 TEST_F(DisplayConfiguratorTest, SuspendAndResume) { | 654 TEST_F(DisplayConfiguratorTest, SuspendAndResume) { |
655 InitWithSingleOutput(); | 655 InitWithSingleOutput(); |
656 | 656 |
657 // No preparation is needed before suspending when the display is already | 657 // No preparation is needed before suspending when the display is already |
658 // on. The configurator should still reprobe on resume in case a display | 658 // on. The configurator should still reprobe on resume in case a display |
659 // was connected while suspended. | 659 // was connected while suspended. |
660 const gfx::Size framebuffer_size = configurator_.framebuffer_size(); | 660 const gfx::Size framebuffer_size = configurator_.framebuffer_size(); |
661 DCHECK(!framebuffer_size.IsEmpty()); | 661 DCHECK(!framebuffer_size.IsEmpty()); |
662 configurator_.SuspendDisplays(); | 662 configurator_.SuspendDisplays(base::Bind( |
| 663 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); |
| 664 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
663 EXPECT_EQ(framebuffer_size.ToString(), | 665 EXPECT_EQ(framebuffer_size.ToString(), |
664 configurator_.framebuffer_size().ToString()); | 666 configurator_.framebuffer_size().ToString()); |
665 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 667 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
666 configurator_.ResumeDisplays(); | 668 configurator_.ResumeDisplays(); |
667 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); | 669 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); |
668 EXPECT_EQ( | 670 EXPECT_EQ( |
669 JoinActions( | 671 JoinActions( |
670 kGrab, | 672 kGrab, |
671 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 673 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), |
672 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 674 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
(...skipping 12 matching lines...) Expand all Loading... |
685 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 687 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
686 EXPECT_EQ( | 688 EXPECT_EQ( |
687 JoinActions( | 689 JoinActions( |
688 kGrab, | 690 kGrab, |
689 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 691 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), |
690 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 692 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), |
691 kUngrab, | 693 kUngrab, |
692 NULL), | 694 NULL), |
693 log_->GetActionsAndClear()); | 695 log_->GetActionsAndClear()); |
694 | 696 |
695 configurator_.SuspendDisplays(); | 697 configurator_.SuspendDisplays(base::Bind( |
| 698 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); |
| 699 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
696 EXPECT_EQ( | 700 EXPECT_EQ( |
697 JoinActions( | 701 JoinActions( |
698 kGrab, | 702 kGrab, |
699 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 703 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), |
700 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 704 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
701 kForceDPMS, | 705 kForceDPMS, |
702 kUngrab, | 706 kUngrab, |
703 kSync, | 707 kSync, |
704 NULL), | 708 NULL), |
705 log_->GetActionsAndClear()); | 709 log_->GetActionsAndClear()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 EXPECT_EQ( | 744 EXPECT_EQ( |
741 JoinActions(kGrab, | 745 JoinActions(kGrab, |
742 GetFramebufferAction( | 746 GetFramebufferAction( |
743 small_mode_.size(), &outputs_[0], &outputs_[1]).c_str(), | 747 small_mode_.size(), &outputs_[0], &outputs_[1]).c_str(), |
744 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 748 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), |
745 GetCrtcAction(outputs_[1], NULL, gfx::Point(0, 0)).c_str(), | 749 GetCrtcAction(outputs_[1], NULL, gfx::Point(0, 0)).c_str(), |
746 kUngrab, | 750 kUngrab, |
747 NULL), | 751 NULL), |
748 log_->GetActionsAndClear()); | 752 log_->GetActionsAndClear()); |
749 | 753 |
750 configurator_.SuspendDisplays(); | 754 configurator_.SuspendDisplays(base::Bind( |
| 755 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); |
| 756 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
751 EXPECT_EQ(JoinActions(kGrab, kUngrab, kSync, NULL), | 757 EXPECT_EQ(JoinActions(kGrab, kUngrab, kSync, NULL), |
752 log_->GetActionsAndClear()); | 758 log_->GetActionsAndClear()); |
753 | 759 |
754 // If a display is disconnected while suspended, the configurator should | 760 // If a display is disconnected while suspended, the configurator should |
755 // pick up the change. | 761 // pick up the change. |
756 UpdateOutputs(1, false); | 762 UpdateOutputs(1, false); |
757 configurator_.ResumeDisplays(); | 763 configurator_.ResumeDisplays(); |
758 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); | 764 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); |
759 EXPECT_EQ( | 765 EXPECT_EQ( |
760 JoinActions( | 766 JoinActions( |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1013 log_->GetActionsAndClear()); | 1019 log_->GetActionsAndClear()); |
1014 } | 1020 } |
1015 | 1021 |
1016 TEST_F(DisplayConfiguratorTest, DoNotConfigureWithSuspendedDisplays) { | 1022 TEST_F(DisplayConfiguratorTest, DoNotConfigureWithSuspendedDisplays) { |
1017 InitWithSingleOutput(); | 1023 InitWithSingleOutput(); |
1018 | 1024 |
1019 // The DisplayConfigurator may occasionally receive OnConfigurationChanged() | 1025 // The DisplayConfigurator may occasionally receive OnConfigurationChanged() |
1020 // after the displays have been suspended. This event should be ignored since | 1026 // after the displays have been suspended. This event should be ignored since |
1021 // the DisplayConfigurator will force a probe and reconfiguration of displays | 1027 // the DisplayConfigurator will force a probe and reconfiguration of displays |
1022 // at resume time. | 1028 // at resume time. |
1023 configurator_.SuspendDisplays(); | 1029 configurator_.SuspendDisplays(base::Bind( |
| 1030 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); |
| 1031 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
1024 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1032 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
1025 | 1033 |
1026 // The configuration timer should not be started when the displays | 1034 // The configuration timer should not be started when the displays |
1027 // are suspended. | 1035 // are suspended. |
1028 configurator_.OnConfigurationChanged(); | 1036 configurator_.OnConfigurationChanged(); |
1029 EXPECT_FALSE(test_api_.TriggerConfigureTimeout()); | 1037 EXPECT_FALSE(test_api_.TriggerConfigureTimeout()); |
1030 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1038 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
1031 | 1039 |
1032 // Calls to SetDisplayPower and SetDisplayMode should be successful. | 1040 // Calls to SetDisplayPower and SetDisplayMode should be successful. |
1033 configurator_.SetDisplayPower( | 1041 configurator_.SetDisplayPower( |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1084 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 1092 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), |
1085 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1093 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
1086 kForceDPMS, | 1094 kForceDPMS, |
1087 kUngrab, | 1095 kUngrab, |
1088 NULL), | 1096 NULL), |
1089 log_->GetActionsAndClear()); | 1097 log_->GetActionsAndClear()); |
1090 | 1098 |
1091 // If a configuration task is pending when the displays are suspended, that | 1099 // If a configuration task is pending when the displays are suspended, that |
1092 // task should not run either and the timer should be stopped. | 1100 // task should not run either and the timer should be stopped. |
1093 configurator_.OnConfigurationChanged(); | 1101 configurator_.OnConfigurationChanged(); |
1094 configurator_.SuspendDisplays(); | 1102 configurator_.SuspendDisplays(base::Bind( |
| 1103 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); |
| 1104 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
1095 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1105 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
1096 | 1106 |
1097 EXPECT_FALSE(test_api_.TriggerConfigureTimeout()); | 1107 EXPECT_FALSE(test_api_.TriggerConfigureTimeout()); |
1098 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1108 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
1099 | 1109 |
1100 configurator_.ResumeDisplays(); | 1110 configurator_.ResumeDisplays(); |
1101 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); | 1111 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); |
1102 EXPECT_EQ( | 1112 EXPECT_EQ( |
1103 JoinActions( | 1113 JoinActions( |
1104 kGrab, | 1114 kGrab, |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1373 .c_str(), | 1383 .c_str(), |
1374 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 1384 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), |
1375 GetCrtcAction(outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(), | 1385 GetCrtcAction(outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(), |
1376 kForceDPMS, | 1386 kForceDPMS, |
1377 kUngrab, | 1387 kUngrab, |
1378 NULL), | 1388 NULL), |
1379 log_->GetActionsAndClear()); | 1389 log_->GetActionsAndClear()); |
1380 | 1390 |
1381 // Suspend and resume the system. Resuming should post a task to restore the | 1391 // Suspend and resume the system. Resuming should post a task to restore the |
1382 // previous power state, additionally forcing a probe. | 1392 // previous power state, additionally forcing a probe. |
1383 configurator_.SuspendDisplays(); | 1393 configurator_.SuspendDisplays(base::Bind( |
| 1394 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); |
| 1395 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
1384 configurator_.ResumeDisplays(); | 1396 configurator_.ResumeDisplays(); |
1385 | 1397 |
1386 // Before the task runs, exit docked mode. | 1398 // Before the task runs, exit docked mode. |
1387 configurator_.SetDisplayPower( | 1399 configurator_.SetDisplayPower( |
1388 chromeos::DISPLAY_POWER_ALL_ON, | 1400 chromeos::DISPLAY_POWER_ALL_ON, |
1389 DisplayConfigurator::kSetDisplayPowerNoFlags, | 1401 DisplayConfigurator::kSetDisplayPowerNoFlags, |
1390 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 1402 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, |
1391 base::Unretained(this))); | 1403 base::Unretained(this))); |
1392 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 1404 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
1393 EXPECT_EQ(2, observer_.num_changes()); | 1405 EXPECT_EQ(2, observer_.num_changes()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1434 GetFramebufferAction(small_mode_.size(), &outputs_[0], | 1446 GetFramebufferAction(small_mode_.size(), &outputs_[0], |
1435 nullptr).c_str(), | 1447 nullptr).c_str(), |
1436 GetCrtcAction(outputs_[0], &small_mode_, | 1448 GetCrtcAction(outputs_[0], &small_mode_, |
1437 gfx::Point(0, 0)).c_str(), | 1449 gfx::Point(0, 0)).c_str(), |
1438 kUngrab, NULL), | 1450 kUngrab, NULL), |
1439 log_->GetActionsAndClear()); | 1451 log_->GetActionsAndClear()); |
1440 } | 1452 } |
1441 | 1453 |
1442 } // namespace test | 1454 } // namespace test |
1443 } // namespace ui | 1455 } // namespace ui |
OLD | NEW |