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 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1197 modes.push_back(new DisplayMode(gfx::Size(1280, 720), false, 60.0)); | 1197 modes.push_back(new DisplayMode(gfx::Size(1280, 720), false, 60.0)); |
1198 modes.push_back(new DisplayMode(gfx::Size(1920, 1080), false, 60.0)); | 1198 modes.push_back(new DisplayMode(gfx::Size(1920, 1080), false, 60.0)); |
1199 modes.push_back(new DisplayMode(gfx::Size(1920, 1080), false, 40.0)); | 1199 modes.push_back(new DisplayMode(gfx::Size(1920, 1080), false, 40.0)); |
1200 | 1200 |
1201 for (unsigned int i = 0; i < arraysize(outputs_); i++) { | 1201 for (unsigned int i = 0; i < arraysize(outputs_); i++) { |
1202 outputs_[i].set_modes(modes.get()); | 1202 outputs_[i].set_modes(modes.get()); |
1203 outputs_[i].set_current_mode(modes[0]); | 1203 outputs_[i].set_current_mode(modes[0]); |
1204 outputs_[i].set_native_mode(modes[0]); | 1204 outputs_[i].set_native_mode(modes[0]); |
1205 } | 1205 } |
1206 | 1206 |
1207 configurator_.Init(false); | |
1208 | |
1209 // First test simply fails in MULTIPLE_DISPLAY_STATE_SINGLE mode. This is | 1207 // First test simply fails in MULTIPLE_DISPLAY_STATE_SINGLE mode. This is |
1210 // probably unrealistic but we want to make sure any assumptions don't creep | 1208 // probably unrealistic but we want to make sure any assumptions don't creep |
1211 // in. | 1209 // in. |
1212 native_display_delegate_->set_max_configurable_pixels( | 1210 native_display_delegate_->set_max_configurable_pixels( |
1213 modes[2]->size().GetArea()); | 1211 modes[2]->size().GetArea()); |
1214 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_SINGLE); | 1212 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_SINGLE); |
1215 UpdateOutputs(1, true); | 1213 UpdateOutputs(1, true); |
1216 | 1214 |
1217 EXPECT_EQ( | 1215 EXPECT_EQ( |
1218 JoinActions( | 1216 JoinActions( |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1266 modes[3], | 1264 modes[3], |
1267 gfx::Point(0, | 1265 gfx::Point(0, |
1268 modes[0]->size().height() + | 1266 modes[0]->size().height() + |
1269 DisplayConfigurator::kVerticalGap)) | 1267 DisplayConfigurator::kVerticalGap)) |
1270 .c_str(), | 1268 .c_str(), |
1271 kUngrab, | 1269 kUngrab, |
1272 NULL), | 1270 NULL), |
1273 log_->GetActionsAndClear()); | 1271 log_->GetActionsAndClear()); |
1274 } | 1272 } |
1275 | 1273 |
| 1274 // Tests that power state requests are saved after failed configuration attempts |
| 1275 // so they can be reused later: http://crosbug.com/p/31571 |
| 1276 TEST_F(DisplayConfiguratorTest, SaveDisplayPowerStateOnConfigFailure) { |
| 1277 // Start out with two displays in extended mode. |
| 1278 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); |
| 1279 configurator_.Init(false); |
| 1280 configurator_.ForceInitialConfigure(0); |
| 1281 log_->GetActionsAndClear(); |
| 1282 |
| 1283 // Turn off the internal display, simulating docked mode. |
| 1284 EXPECT_TRUE(configurator_.SetDisplayPower( |
| 1285 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, |
| 1286 DisplayConfigurator::kSetDisplayPowerNoFlags)); |
| 1287 log_->GetActionsAndClear(); |
| 1288 |
| 1289 // Make all subsequent configuration requests fail and try to turn the |
| 1290 // internal display back on. |
| 1291 native_display_delegate_->set_max_configurable_pixels(1); |
| 1292 EXPECT_FALSE(configurator_.SetDisplayPower( |
| 1293 chromeos::DISPLAY_POWER_ALL_ON, |
| 1294 DisplayConfigurator::kSetDisplayPowerNoFlags)); |
| 1295 log_->GetActionsAndClear(); |
| 1296 |
| 1297 // Simulate the external display getting disconnected and check that the |
| 1298 // internal display is turned on (i.e. DISPLAY_POWER_ALL_ON is used) rather |
| 1299 // than the earlier DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON state. |
| 1300 native_display_delegate_->set_max_configurable_pixels(0); |
| 1301 UpdateOutputs(1, true); |
| 1302 EXPECT_EQ( |
| 1303 JoinActions( |
| 1304 kGrab, |
| 1305 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), |
| 1306 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1307 kUngrab, |
| 1308 NULL), |
| 1309 log_->GetActionsAndClear()); |
| 1310 } |
| 1311 |
1276 } // namespace ui | 1312 } // namespace ui |
OLD | NEW |