| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 const DisplaySnapshot* out1, | 75 const DisplaySnapshot* out1, |
| 76 const DisplaySnapshot* out2) { | 76 const DisplaySnapshot* out2) { |
| 77 return base::StringPrintf( | 77 return base::StringPrintf( |
| 78 "framebuffer(width=%d,height=%d,display1=%s,display2=%s)", | 78 "framebuffer(width=%d,height=%d,display1=%s,display2=%s)", |
| 79 size.width(), | 79 size.width(), |
| 80 size.height(), | 80 size.height(), |
| 81 out1 ? DisplaySnapshotToString(*out1).c_str() : "NULL", | 81 out1 ? DisplaySnapshotToString(*out1).c_str() : "NULL", |
| 82 out2 ? DisplaySnapshotToString(*out2).c_str() : "NULL"); | 82 out2 ? DisplaySnapshotToString(*out2).c_str() : "NULL"); |
| 83 } | 83 } |
| 84 | 84 |
| 85 // Returns a string describing a TestNativeDisplayDelegate::ConfigureCTM() call. | |
| 86 std::string GetCTMAction( | |
| 87 int device_id, | |
| 88 const DisplayConfigurator::CoordinateTransformation& ctm) { | |
| 89 return base::StringPrintf("ctm(id=%d,transform=(%f,%f,%f,%f))", | |
| 90 device_id, | |
| 91 ctm.x_scale, | |
| 92 ctm.x_offset, | |
| 93 ctm.y_scale, | |
| 94 ctm.y_offset); | |
| 95 } | |
| 96 | |
| 97 // Returns a string describing a TestNativeDisplayDelegate::SetHDCPState() call. | 85 // Returns a string describing a TestNativeDisplayDelegate::SetHDCPState() call. |
| 98 std::string GetSetHDCPStateAction(const DisplaySnapshot& output, | 86 std::string GetSetHDCPStateAction(const DisplaySnapshot& output, |
| 99 HDCPState state) { | 87 HDCPState state) { |
| 100 return base::StringPrintf( | 88 return base::StringPrintf( |
| 101 "set_hdcp(id=%" PRId64 ",state=%d)", output.display_id(), state); | 89 "set_hdcp(id=%" PRId64 ",state=%d)", output.display_id(), state); |
| 102 } | 90 } |
| 103 | 91 |
| 104 // Joins a sequence of strings describing actions (e.g. kScreenDim) such | 92 // Joins a sequence of strings describing actions (e.g. kScreenDim) such |
| 105 // that they can be compared against a string returned by | 93 // that they can be compared against a string returned by |
| 106 // ActionLogger::GetActionsAndClear(). The list of actions must be | 94 // ActionLogger::GetActionsAndClear(). The list of actions must be |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 135 |
| 148 class TestTouchscreenDelegate | 136 class TestTouchscreenDelegate |
| 149 : public DisplayConfigurator::TouchscreenDelegate { | 137 : public DisplayConfigurator::TouchscreenDelegate { |
| 150 public: | 138 public: |
| 151 // Ownership of |log| remains with the caller. | 139 // Ownership of |log| remains with the caller. |
| 152 explicit TestTouchscreenDelegate(ActionLogger* log) | 140 explicit TestTouchscreenDelegate(ActionLogger* log) |
| 153 : log_(log), | 141 : log_(log), |
| 154 configure_touchscreens_(false) {} | 142 configure_touchscreens_(false) {} |
| 155 virtual ~TestTouchscreenDelegate() {} | 143 virtual ~TestTouchscreenDelegate() {} |
| 156 | 144 |
| 157 const DisplayConfigurator::CoordinateTransformation& GetCTM( | |
| 158 int touch_device_id) { | |
| 159 return ctms_[touch_device_id]; | |
| 160 } | |
| 161 | |
| 162 void set_configure_touchscreens(bool state) { | 145 void set_configure_touchscreens(bool state) { |
| 163 configure_touchscreens_ = state; | 146 configure_touchscreens_ = state; |
| 164 } | 147 } |
| 165 | 148 |
| 166 // DisplayConfigurator::TouchscreenDelegate implementation: | 149 // DisplayConfigurator::TouchscreenDelegate implementation: |
| 167 virtual void AssociateTouchscreens( | 150 virtual void AssociateTouchscreens( |
| 168 DisplayConfigurator::DisplayStateList* outputs) OVERRIDE { | 151 DisplayConfigurator::DisplayStateList* outputs) OVERRIDE { |
| 169 if (configure_touchscreens_) { | 152 if (configure_touchscreens_) { |
| 170 for (size_t i = 0; i < outputs->size(); ++i) | 153 for (size_t i = 0; i < outputs->size(); ++i) |
| 171 (*outputs)[i].touch_device_id = i + 1; | 154 (*outputs)[i].touch_device_id = i + 1; |
| 172 } | 155 } |
| 173 } | 156 } |
| 174 virtual void ConfigureCTM( | |
| 175 int touch_device_id, | |
| 176 const DisplayConfigurator::CoordinateTransformation& ctm) OVERRIDE { | |
| 177 log_->AppendAction(GetCTMAction(touch_device_id, ctm)); | |
| 178 ctms_[touch_device_id] = ctm; | |
| 179 } | |
| 180 | 157 |
| 181 private: | 158 private: |
| 182 ActionLogger* log_; // Not owned. | 159 ActionLogger* log_; // Not owned. |
| 183 | 160 |
| 184 bool configure_touchscreens_; | 161 bool configure_touchscreens_; |
| 185 | 162 |
| 186 // Most-recently-configured transformation matrices, keyed by touch device ID. | 163 // Most-recently-configured transformation matrices, keyed by touch device ID. |
| 187 std::map<int, DisplayConfigurator::CoordinateTransformation> ctms_; | 164 std::map<int, DisplayConfigurator::CoordinateTransformation> ctms_; |
| 188 | 165 |
| 189 DISALLOW_COPY_AND_ASSIGN(TestTouchscreenDelegate); | 166 DISALLOW_COPY_AND_ASSIGN(TestTouchscreenDelegate); |
| (...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1235 EXPECT_TRUE(configurator_.EnableContentProtection( | 1212 EXPECT_TRUE(configurator_.EnableContentProtection( |
| 1236 client2, outputs_[1].display_id(), CONTENT_PROTECTION_METHOD_NONE)); | 1213 client2, outputs_[1].display_id(), CONTENT_PROTECTION_METHOD_NONE)); |
| 1237 EXPECT_EQ(GetSetHDCPStateAction(outputs_[1], HDCP_STATE_DESIRED).c_str(), | 1214 EXPECT_EQ(GetSetHDCPStateAction(outputs_[1], HDCP_STATE_DESIRED).c_str(), |
| 1238 log_->GetActionsAndClear()); | 1215 log_->GetActionsAndClear()); |
| 1239 EXPECT_TRUE(configurator_.EnableContentProtection( | 1216 EXPECT_TRUE(configurator_.EnableContentProtection( |
| 1240 client1, outputs_[1].display_id(), CONTENT_PROTECTION_METHOD_NONE)); | 1217 client1, outputs_[1].display_id(), CONTENT_PROTECTION_METHOD_NONE)); |
| 1241 EXPECT_EQ(GetSetHDCPStateAction(outputs_[1], HDCP_STATE_UNDESIRED).c_str(), | 1218 EXPECT_EQ(GetSetHDCPStateAction(outputs_[1], HDCP_STATE_UNDESIRED).c_str(), |
| 1242 log_->GetActionsAndClear()); | 1219 log_->GetActionsAndClear()); |
| 1243 } | 1220 } |
| 1244 | 1221 |
| 1245 TEST_F(DisplayConfiguratorTest, CTMForMultiScreens) { | |
| 1246 touchscreen_delegate_->set_configure_touchscreens(true); | |
| 1247 UpdateOutputs(2, false); | |
| 1248 configurator_.Init(false); | |
| 1249 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); | |
| 1250 configurator_.ForceInitialConfigure(0); | |
| 1251 | |
| 1252 const int kDualHeight = small_mode_.size().height() + | |
| 1253 DisplayConfigurator::kVerticalGap + | |
| 1254 big_mode_.size().height(); | |
| 1255 const int kDualWidth = big_mode_.size().width(); | |
| 1256 | |
| 1257 DisplayConfigurator::CoordinateTransformation ctm1 = | |
| 1258 touchscreen_delegate_->GetCTM(1); | |
| 1259 DisplayConfigurator::CoordinateTransformation ctm2 = | |
| 1260 touchscreen_delegate_->GetCTM(2); | |
| 1261 | |
| 1262 EXPECT_EQ(small_mode_.size().height() - 1, | |
| 1263 round((kDualHeight - 1) * ctm1.y_scale)); | |
| 1264 EXPECT_EQ(0, round((kDualHeight - 1) * ctm1.y_offset)); | |
| 1265 | |
| 1266 EXPECT_EQ(big_mode_.size().height() - 1, | |
| 1267 round((kDualHeight - 1) * ctm2.y_scale)); | |
| 1268 EXPECT_EQ(small_mode_.size().height() + DisplayConfigurator::kVerticalGap, | |
| 1269 round((kDualHeight - 1) * ctm2.y_offset)); | |
| 1270 | |
| 1271 EXPECT_EQ(small_mode_.size().width() - 1, | |
| 1272 round((kDualWidth - 1) * ctm1.x_scale)); | |
| 1273 EXPECT_EQ(0, round((kDualWidth - 1) * ctm1.x_offset)); | |
| 1274 | |
| 1275 EXPECT_EQ(big_mode_.size().width() - 1, | |
| 1276 round((kDualWidth - 1) * ctm2.x_scale)); | |
| 1277 EXPECT_EQ(0, round((kDualWidth - 1) * ctm2.x_offset)); | |
| 1278 } | |
| 1279 | |
| 1280 TEST_F(DisplayConfiguratorTest, HandleConfigureCrtcFailure) { | 1222 TEST_F(DisplayConfiguratorTest, HandleConfigureCrtcFailure) { |
| 1281 InitWithSingleOutput(); | 1223 InitWithSingleOutput(); |
| 1282 | 1224 |
| 1283 ScopedVector<const DisplayMode> modes; | 1225 ScopedVector<const DisplayMode> modes; |
| 1284 // The first mode is the mode we are requesting DisplayConfigurator to choose. | 1226 // The first mode is the mode we are requesting DisplayConfigurator to choose. |
| 1285 // The test will be setup so that this mode will fail and it will have to | 1227 // The test will be setup so that this mode will fail and it will have to |
| 1286 // choose the next best option. | 1228 // choose the next best option. |
| 1287 modes.push_back(new DisplayMode(gfx::Size(2560, 1600), false, 60.0)); | 1229 modes.push_back(new DisplayMode(gfx::Size(2560, 1600), false, 60.0)); |
| 1288 modes.push_back(new DisplayMode(gfx::Size(1024, 768), false, 60.0)); | 1230 modes.push_back(new DisplayMode(gfx::Size(1024, 768), false, 60.0)); |
| 1289 modes.push_back(new DisplayMode(gfx::Size(1280, 720), false, 60.0)); | 1231 modes.push_back(new DisplayMode(gfx::Size(1280, 720), false, 60.0)); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1359 gfx::Point(0, | 1301 gfx::Point(0, |
| 1360 modes[0]->size().height() + | 1302 modes[0]->size().height() + |
| 1361 DisplayConfigurator::kVerticalGap)) | 1303 DisplayConfigurator::kVerticalGap)) |
| 1362 .c_str(), | 1304 .c_str(), |
| 1363 kUngrab, | 1305 kUngrab, |
| 1364 NULL), | 1306 NULL), |
| 1365 log_->GetActionsAndClear()); | 1307 log_->GetActionsAndClear()); |
| 1366 } | 1308 } |
| 1367 | 1309 |
| 1368 } // namespace ui | 1310 } // namespace ui |
| OLD | NEW |