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