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

Side by Side Diff: ui/display/chromeos/display_configurator_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698