Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 834 // No preparation is needed before suspending when the display is already | 834 // No preparation is needed before suspending when the display is already |
| 835 // on. The configurator should still reprobe on resume in case a display | 835 // on. The configurator should still reprobe on resume in case a display |
| 836 // was connected while suspended. | 836 // was connected while suspended. |
| 837 const gfx::Size framebuffer_size = configurator_.framebuffer_size(); | 837 const gfx::Size framebuffer_size = configurator_.framebuffer_size(); |
| 838 DCHECK(!framebuffer_size.IsEmpty()); | 838 DCHECK(!framebuffer_size.IsEmpty()); |
| 839 configurator_.SuspendDisplays(base::Bind( | 839 configurator_.SuspendDisplays(base::Bind( |
| 840 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); | 840 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); |
| 841 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 841 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
| 842 EXPECT_EQ(framebuffer_size.ToString(), | 842 EXPECT_EQ(framebuffer_size.ToString(), |
| 843 configurator_.framebuffer_size().ToString()); | 843 configurator_.framebuffer_size().ToString()); |
| 844 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | |
| 845 configurator_.ResumeDisplays(); | |
| 846 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); | |
| 847 EXPECT_EQ( | 844 EXPECT_EQ( |
| 848 JoinActions( | 845 JoinActions( |
| 849 kGrab, | 846 kGrab, |
| 847 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | |
| 848 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | |
| 849 kUngrab, | |
| 850 kSync, | |
| 851 NULL), | |
| 852 log_->GetActionsAndClear()); | |
| 853 configurator_.ResumeDisplays(); | |
| 854 EXPECT_EQ( | |
| 855 JoinActions( | |
| 856 kGrab, | |
| 850 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 857 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), |
| 851 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 858 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 852 kForceDPMS, | 859 kForceDPMS, |
| 853 kUngrab, | 860 kUngrab, |
| 854 NULL), | 861 NULL), |
| 855 log_->GetActionsAndClear()); | 862 log_->GetActionsAndClear()); |
| 856 | 863 |
| 857 // Now turn the display off before suspending and check that the | 864 // Now turn the display off before suspending and check that the |
| 858 // configurator turns it back on and syncs with the server. | 865 // configurator turns it back on and syncs with the server. |
| 859 configurator_.SetDisplayPower( | 866 configurator_.SetDisplayPower( |
| 860 chromeos::DISPLAY_POWER_ALL_OFF, | 867 chromeos::DISPLAY_POWER_ALL_OFF, |
| 861 DisplayConfigurator::kSetDisplayPowerNoFlags, | 868 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 862 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 869 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, |
| 863 base::Unretained(this))); | 870 base::Unretained(this))); |
| 864 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 871 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
| 865 EXPECT_EQ( | 872 EXPECT_EQ( |
| 866 JoinActions( | 873 JoinActions( |
| 867 kGrab, | 874 kGrab, |
| 868 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 875 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), |
| 869 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 876 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), |
| 870 kUngrab, | 877 kUngrab, |
| 871 NULL), | 878 NULL), |
| 872 log_->GetActionsAndClear()); | 879 log_->GetActionsAndClear()); |
| 873 | 880 |
| 874 configurator_.SuspendDisplays(base::Bind( | 881 configurator_.SuspendDisplays(base::Bind( |
| 875 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); | 882 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); |
| 876 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 883 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
| 884 EXPECT_EQ(kSync, log_->GetActionsAndClear()); | |
| 885 | |
| 886 configurator_.ResumeDisplays(); | |
| 887 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | |
| 888 | |
| 889 configurator_.SetDisplayPower( | |
| 890 chromeos::DISPLAY_POWER_ALL_ON, | |
| 891 DisplayConfigurator::kSetDisplayPowerNoFlags, | |
| 892 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | |
| 893 base::Unretained(this))); | |
| 877 EXPECT_EQ( | 894 EXPECT_EQ( |
| 878 JoinActions( | 895 JoinActions( |
| 879 kGrab, | 896 kGrab, |
| 880 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | |
| 881 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | |
| 882 kForceDPMS, | |
| 883 kUngrab, | |
| 884 kSync, | |
| 885 NULL), | |
| 886 log_->GetActionsAndClear()); | |
| 887 | |
| 888 configurator_.ResumeDisplays(); | |
| 889 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); | |
| 890 EXPECT_EQ( | |
| 891 JoinActions( | |
| 892 kGrab, | |
| 893 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 897 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), |
| 894 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 898 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 895 kForceDPMS, | 899 kForceDPMS, |
| 896 kUngrab, | 900 kUngrab, |
| 897 NULL), | 901 NULL), |
| 898 log_->GetActionsAndClear()); | 902 log_->GetActionsAndClear()); |
| 899 | 903 |
| 900 // If a second, external display is connected, the displays shouldn't be | 904 // If a second, external display is connected, the displays shouldn't be |
| 901 // powered back on before suspending. | 905 // powered back on before suspending. |
| 902 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); | 906 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
| 903 UpdateOutputs(2, true); | 907 UpdateOutputs(2, true); |
| 904 EXPECT_EQ( | 908 EXPECT_EQ( |
| 905 JoinActions( | 909 JoinActions( |
| 906 kGrab, | 910 kGrab, |
| 907 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) | 911 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) |
| 908 .c_str(), | 912 .c_str(), |
| 909 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 913 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 910 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), | 914 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 911 kUngrab, | 915 kUngrab, |
| 912 NULL), | 916 NULL), |
| 913 log_->GetActionsAndClear()); | 917 log_->GetActionsAndClear()); |
| 914 | 918 |
| 919 // Expect setting the power to off to do nothing if the displays are | |
| 920 // 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
| |
| 915 configurator_.SetDisplayPower( | 921 configurator_.SetDisplayPower( |
| 916 chromeos::DISPLAY_POWER_ALL_OFF, | 922 chromeos::DISPLAY_POWER_ALL_OFF, |
| 917 DisplayConfigurator::kSetDisplayPowerNoFlags, | 923 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 918 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 924 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, |
| 919 base::Unretained(this))); | 925 base::Unretained(this))); |
| 920 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 926 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
| 921 EXPECT_EQ( | 927 EXPECT_EQ( |
| 922 JoinActions(kGrab, | 928 JoinActions( |
| 923 GetFramebufferAction( | 929 kGrab, |
| 924 small_mode_.size(), &outputs_[0], &outputs_[1]).c_str(), | 930 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) |
| 925 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 931 .c_str(), |
| 926 GetCrtcAction(outputs_[1], NULL, gfx::Point(0, 0)).c_str(), | 932 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), |
| 927 kUngrab, | 933 GetCrtcAction(outputs_[1], NULL, gfx::Point(0, 0)).c_str(), |
| 928 NULL), | 934 kUngrab, |
| 935 NULL), | |
| 929 log_->GetActionsAndClear()); | 936 log_->GetActionsAndClear()); |
| 930 | 937 |
| 931 configurator_.SuspendDisplays(base::Bind( | 938 configurator_.SuspendDisplays(base::Bind( |
| 932 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); | 939 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); |
| 933 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 940 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
| 934 EXPECT_EQ(JoinActions(kGrab, kUngrab, kSync, NULL), | 941 EXPECT_EQ(kSync, log_->GetActionsAndClear()); |
| 935 log_->GetActionsAndClear()); | |
| 936 | 942 |
| 937 // If a display is disconnected while suspended, the configurator should | 943 // If a display is disconnected while suspended, the configurator should |
| 938 // pick up the change. | 944 // pick up the change and only turn on the internal display. |
| 939 UpdateOutputs(1, false); | 945 UpdateOutputs(1, false); |
| 940 configurator_.ResumeDisplays(); | 946 configurator_.ResumeDisplays(); |
| 941 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); | 947 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 948 | |
| 949 configurator_.SetDisplayPower( | |
| 950 chromeos::DISPLAY_POWER_ALL_ON, | |
| 951 DisplayConfigurator::kSetDisplayPowerNoFlags, | |
| 952 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | |
| 953 base::Unretained(this))); | |
| 942 EXPECT_EQ( | 954 EXPECT_EQ( |
| 943 JoinActions( | 955 JoinActions( |
| 944 kGrab, | 956 kGrab, |
| 945 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 957 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), |
| 946 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 958 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 959 kForceDPMS, | |
| 947 kUngrab, | 960 kUngrab, |
| 948 NULL), | 961 NULL), |
| 949 log_->GetActionsAndClear()); | 962 log_->GetActionsAndClear()); |
| 950 } | 963 } |
| 951 | 964 |
| 952 TEST_F(DisplayConfiguratorTest, Headless) { | 965 TEST_F(DisplayConfiguratorTest, Headless) { |
| 953 UpdateOutputs(0, false); | 966 UpdateOutputs(0, false); |
| 954 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 967 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 955 Init(false); | 968 Init(false); |
| 956 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 969 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1198 TEST_F(DisplayConfiguratorTest, DoNotConfigureWithSuspendedDisplays) { | 1211 TEST_F(DisplayConfiguratorTest, DoNotConfigureWithSuspendedDisplays) { |
| 1199 InitWithSingleOutput(); | 1212 InitWithSingleOutput(); |
| 1200 | 1213 |
| 1201 // The DisplayConfigurator may occasionally receive OnConfigurationChanged() | 1214 // The DisplayConfigurator may occasionally receive OnConfigurationChanged() |
| 1202 // after the displays have been suspended. This event should be ignored since | 1215 // after the displays have been suspended. This event should be ignored since |
| 1203 // the DisplayConfigurator will force a probe and reconfiguration of displays | 1216 // the DisplayConfigurator will force a probe and reconfiguration of displays |
| 1204 // at resume time. | 1217 // at resume time. |
| 1205 configurator_.SuspendDisplays(base::Bind( | 1218 configurator_.SuspendDisplays(base::Bind( |
| 1206 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); | 1219 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); |
| 1207 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 1220 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
| 1208 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1221 EXPECT_EQ( |
| 1222 JoinActions( | |
| 1223 kGrab, | |
| 1224 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | |
| 1225 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | |
| 1226 kUngrab, | |
| 1227 kSync, | |
| 1228 NULL), | |
| 1229 log_->GetActionsAndClear()); | |
| 1209 | 1230 |
| 1210 // The configuration timer should not be started when the displays | 1231 // The configuration timer should not be started when the displays |
| 1211 // are suspended. | 1232 // are suspended. |
| 1212 configurator_.OnConfigurationChanged(); | 1233 configurator_.OnConfigurationChanged(); |
| 1213 EXPECT_FALSE(test_api_.TriggerConfigureTimeout()); | 1234 EXPECT_FALSE(test_api_.TriggerConfigureTimeout()); |
| 1214 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1235 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1215 | 1236 |
| 1216 // Calls to SetDisplayPower and SetDisplayMode should be successful. | 1237 // Calls to SetDisplayPower should do nothing if the power state doesn't |
| 1238 // change. | |
| 1217 configurator_.SetDisplayPower( | 1239 configurator_.SetDisplayPower( |
| 1218 chromeos::DISPLAY_POWER_ALL_OFF, | 1240 chromeos::DISPLAY_POWER_ALL_OFF, |
| 1219 DisplayConfigurator::kSetDisplayPowerNoFlags, | 1241 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 1220 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 1242 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, |
| 1221 base::Unretained(this))); | 1243 base::Unretained(this))); |
| 1222 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 1244 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
| 1223 EXPECT_EQ( | 1245 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1224 JoinActions( | |
| 1225 kGrab, | |
| 1226 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | |
| 1227 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | |
| 1228 kUngrab, | |
| 1229 NULL), | |
| 1230 log_->GetActionsAndClear()); | |
| 1231 configurator_.SetDisplayPower( | 1246 configurator_.SetDisplayPower( |
| 1232 chromeos::DISPLAY_POWER_ALL_ON, | 1247 chromeos::DISPLAY_POWER_ALL_ON, |
| 1233 DisplayConfigurator::kSetDisplayPowerNoFlags, | 1248 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 1234 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 1249 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, |
| 1235 base::Unretained(this))); | 1250 base::Unretained(this))); |
| 1236 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 1251 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
| 1237 EXPECT_EQ( | 1252 EXPECT_EQ( |
| 1238 JoinActions( | 1253 JoinActions( |
| 1239 kGrab, | 1254 kGrab, |
| 1240 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 1255 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), |
| 1241 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1256 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1242 kForceDPMS, | 1257 kForceDPMS, |
| 1243 kUngrab, | 1258 kUngrab, |
| 1244 NULL), | 1259 NULL), |
| 1245 log_->GetActionsAndClear()); | 1260 log_->GetActionsAndClear()); |
| 1246 | 1261 |
| 1247 UpdateOutputs(2, false); | 1262 UpdateOutputs(2, false); |
| 1248 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); | 1263 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
| 1249 EXPECT_EQ( | 1264 EXPECT_EQ( |
| 1250 JoinActions( | 1265 JoinActions( |
| 1251 kGrab, | 1266 kGrab, |
| 1252 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) | 1267 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) |
| 1253 .c_str(), | 1268 .c_str(), |
| 1254 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1269 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1255 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), | 1270 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1256 kUngrab, | 1271 kUngrab, |
| 1257 NULL), | 1272 NULL), |
| 1258 log_->GetActionsAndClear()); | 1273 log_->GetActionsAndClear()); |
| 1259 | 1274 |
| 1260 // The DisplayConfigurator should force a probe and reconfiguration at resume | 1275 // The DisplayConfigurator should do nothing at resume time if there is no |
| 1261 // time. | 1276 // state change. |
| 1262 UpdateOutputs(1, false); | 1277 UpdateOutputs(1, false); |
| 1263 configurator_.ResumeDisplays(); | 1278 configurator_.ResumeDisplays(); |
| 1264 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); | 1279 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1280 | |
| 1281 // If a configuration task is pending when the displays are suspended, that | |
| 1282 // task should not run either and the timer should be stopped. The displays | |
| 1283 // should be turned off by suspend. | |
| 1284 configurator_.OnConfigurationChanged(); | |
| 1285 configurator_.SuspendDisplays(base::Bind( | |
| 1286 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); | |
| 1287 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | |
| 1265 EXPECT_EQ( | 1288 EXPECT_EQ( |
| 1266 JoinActions( | 1289 JoinActions( |
| 1267 kGrab, | 1290 kGrab, |
| 1268 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 1291 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), |
| 1269 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1292 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), |
| 1270 kForceDPMS, | |
| 1271 kUngrab, | 1293 kUngrab, |
| 1294 kSync, | |
| 1272 NULL), | 1295 NULL), |
| 1273 log_->GetActionsAndClear()); | 1296 log_->GetActionsAndClear()); |
| 1274 | 1297 |
| 1275 // If a configuration task is pending when the displays are suspended, that | |
| 1276 // task should not run either and the timer should be stopped. | |
| 1277 configurator_.OnConfigurationChanged(); | |
| 1278 configurator_.SuspendDisplays(base::Bind( | |
| 1279 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); | |
| 1280 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | |
| 1281 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | |
| 1282 | |
| 1283 EXPECT_FALSE(test_api_.TriggerConfigureTimeout()); | 1298 EXPECT_FALSE(test_api_.TriggerConfigureTimeout()); |
| 1284 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1299 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1285 | 1300 |
| 1286 configurator_.ResumeDisplays(); | 1301 configurator_.ResumeDisplays(); |
| 1287 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); | |
| 1288 EXPECT_EQ( | 1302 EXPECT_EQ( |
| 1289 JoinActions( | 1303 JoinActions( |
| 1290 kGrab, | 1304 kGrab, |
| 1291 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 1305 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), |
| 1292 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1306 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1293 kForceDPMS, | 1307 kForceDPMS, |
| 1294 kUngrab, | 1308 kUngrab, |
| 1295 NULL), | 1309 NULL), |
| 1296 log_->GetActionsAndClear()); | 1310 log_->GetActionsAndClear()); |
| 1297 } | 1311 } |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1557 kGrab, | 1571 kGrab, |
| 1558 GetFramebufferAction(big_mode_.size(), &outputs_[0], &outputs_[1]) | 1572 GetFramebufferAction(big_mode_.size(), &outputs_[0], &outputs_[1]) |
| 1559 .c_str(), | 1573 .c_str(), |
| 1560 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 1574 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), |
| 1561 GetCrtcAction(outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(), | 1575 GetCrtcAction(outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(), |
| 1562 kForceDPMS, | 1576 kForceDPMS, |
| 1563 kUngrab, | 1577 kUngrab, |
| 1564 NULL), | 1578 NULL), |
| 1565 log_->GetActionsAndClear()); | 1579 log_->GetActionsAndClear()); |
| 1566 | 1580 |
| 1567 // Suspend and resume the system. Resuming should post a task to restore the | 1581 // Suspend and resume the system. Resuming should restore the previous power |
| 1568 // previous power state, additionally forcing a probe. | 1582 // state and force a probe. Suspend should turn off the displays since an |
| 1583 // external monitor is connected. | |
| 1569 configurator_.SuspendDisplays(base::Bind( | 1584 configurator_.SuspendDisplays(base::Bind( |
| 1570 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); | 1585 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); |
| 1571 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 1586 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
| 1572 configurator_.ResumeDisplays(); | 1587 EXPECT_EQ(2, observer_.num_changes()); |
| 1588 EXPECT_EQ( | |
| 1589 JoinActions( | |
| 1590 kGrab, | |
| 1591 GetFramebufferAction(small_mode_.size(), &outputs_[0], | |
| 1592 &outputs_[1]).c_str(), | |
| 1593 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | |
| 1594 GetCrtcAction(outputs_[1], NULL, gfx::Point(0, 0)).c_str(), | |
| 1595 kUngrab, | |
| 1596 kSync, | |
| 1597 NULL), | |
| 1598 log_->GetActionsAndClear()); | |
| 1573 | 1599 |
| 1574 // Before the task runs, exit docked mode. | 1600 // Before the task runs, exit docked mode. |
| 1575 configurator_.SetDisplayPower( | 1601 configurator_.SetDisplayPower( |
| 1576 chromeos::DISPLAY_POWER_ALL_ON, | 1602 chromeos::DISPLAY_POWER_ALL_ON, |
| 1577 DisplayConfigurator::kSetDisplayPowerNoFlags, | 1603 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 1578 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 1604 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, |
| 1579 base::Unretained(this))); | 1605 base::Unretained(this))); |
| 1580 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 1606 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); |
| 1581 EXPECT_EQ(2, observer_.num_changes()); | 1607 EXPECT_EQ(3, observer_.num_changes()); |
| 1582 EXPECT_EQ(0, observer_.num_failures()); | 1608 EXPECT_EQ(0, observer_.num_failures()); |
| 1583 EXPECT_EQ( | 1609 EXPECT_EQ( |
| 1584 JoinActions( | 1610 JoinActions( |
| 1585 kGrab, | 1611 kGrab, |
| 1586 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) | 1612 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) |
| 1587 .c_str(), | 1613 .c_str(), |
| 1588 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1614 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1589 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), | 1615 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1590 kForceDPMS, | 1616 kForceDPMS, |
| 1591 kUngrab, | 1617 kUngrab, |
| 1592 NULL), | 1618 NULL), |
| 1593 log_->GetActionsAndClear()); | 1619 log_->GetActionsAndClear()); |
| 1594 | 1620 |
| 1595 // Check that the task doesn't restore the old internal-off-external-on power | 1621 // Check that the display states are not changed after resuming. |
| 1596 // state. | 1622 configurator_.ResumeDisplays(); |
| 1597 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); | 1623 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1598 EXPECT_EQ( | |
| 1599 JoinActions( | |
| 1600 kGrab, | |
| 1601 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) | |
| 1602 .c_str(), | |
| 1603 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | |
| 1604 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), | |
| 1605 kForceDPMS, | |
| 1606 kUngrab, | |
| 1607 NULL), | |
| 1608 log_->GetActionsAndClear()); | |
| 1609 } | 1624 } |
| 1610 | 1625 |
| 1611 TEST_F(DisplayConfiguratorTest, ExternalControl) { | 1626 TEST_F(DisplayConfiguratorTest, ExternalControl) { |
| 1612 InitWithSingleOutput(); | 1627 InitWithSingleOutput(); |
| 1613 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_SINGLE); | 1628 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_SINGLE); |
| 1614 configurator_.RelinquishControl( | 1629 configurator_.RelinquishControl( |
| 1615 base::Bind(&DisplayConfiguratorTest::OnDisplayControlUpdated, | 1630 base::Bind(&DisplayConfiguratorTest::OnDisplayControlUpdated, |
| 1616 base::Unretained(this))); | 1631 base::Unretained(this))); |
| 1617 EXPECT_EQ(CALLBACK_SUCCESS, PopDisplayControlResult()); | 1632 EXPECT_EQ(CALLBACK_SUCCESS, PopDisplayControlResult()); |
| 1618 EXPECT_EQ( | 1633 EXPECT_EQ( |
| 1619 JoinActions( | 1634 JoinActions( |
| 1620 kRelinquishDisplayControl, | 1635 kRelinquishDisplayControl, |
| 1621 NULL), | 1636 NULL), |
| 1622 log_->GetActionsAndClear()); | 1637 log_->GetActionsAndClear()); |
| 1623 configurator_.TakeControl( | 1638 configurator_.TakeControl( |
| 1624 base::Bind(&DisplayConfiguratorTest::OnDisplayControlUpdated, | 1639 base::Bind(&DisplayConfiguratorTest::OnDisplayControlUpdated, |
| 1625 base::Unretained(this))); | 1640 base::Unretained(this))); |
| 1626 EXPECT_EQ(CALLBACK_SUCCESS, PopDisplayControlResult()); | 1641 EXPECT_EQ(CALLBACK_SUCCESS, PopDisplayControlResult()); |
| 1627 EXPECT_EQ(JoinActions(kTakeDisplayControl, kGrab, | 1642 EXPECT_EQ(JoinActions(kTakeDisplayControl, kGrab, |
| 1628 GetFramebufferAction(small_mode_.size(), &outputs_[0], | 1643 GetFramebufferAction(small_mode_.size(), &outputs_[0], |
| 1629 nullptr).c_str(), | 1644 nullptr).c_str(), |
| 1630 GetCrtcAction(outputs_[0], &small_mode_, | 1645 GetCrtcAction(outputs_[0], &small_mode_, |
| 1631 gfx::Point(0, 0)).c_str(), | 1646 gfx::Point(0, 0)).c_str(), |
| 1632 kUngrab, NULL), | 1647 kUngrab, NULL), |
| 1633 log_->GetActionsAndClear()); | 1648 log_->GetActionsAndClear()); |
| 1634 } | 1649 } |
| 1635 | 1650 |
| 1636 } // namespace test | 1651 } // namespace test |
| 1637 } // namespace ui | 1652 } // namespace ui |
| OLD | NEW |