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 <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 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 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, | |
|
dnicoara
2014/09/25 13:59:54
It makes me feel a bit uncomfortable that this doe
Daniel Erat
2014/09/25 17:31:06
i've added expectations for the return values to t
dnicoara
2014/09/25 17:50:35
Thank you. I think this should be fine since we're
| |
| 1293 DisplayConfigurator::kSetDisplayPowerNoFlags); | |
| 1294 log_->GetActionsAndClear(); | |
| 1295 | |
| 1296 // Simulate the external display getting disconnected and check that the | |
| 1297 // internal display is turned on (i.e. DISPLAY_POWER_ALL_ON is used) rather | |
| 1298 // than the earlier DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON state. | |
| 1299 native_display_delegate_->set_max_configurable_pixels(0); | |
| 1300 UpdateOutputs(1, true); | |
| 1301 EXPECT_EQ( | |
| 1302 JoinActions( | |
| 1303 kGrab, | |
| 1304 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | |
| 1305 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | |
| 1306 kUngrab, | |
| 1307 NULL), | |
| 1308 log_->GetActionsAndClear()); | |
| 1309 } | |
| 1310 | |
| 1276 } // namespace ui | 1311 } // namespace ui |
| OLD | NEW |