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 "extensions/browser/api/system_display/display_info_provider.h" | 5 #include "extensions/browser/api/system_display/display_info_provider.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 9 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
| 10 #include "ash/common/wm_shell.h" | 10 #include "ash/common/wm_shell.h" |
| (...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1189 bool success = false; | 1189 bool success = false; |
| 1190 std::string error; | 1190 std::string error; |
| 1191 CallSetDisplayUnitInfo(base::Int64ToString(id), info, &success, &error); | 1191 CallSetDisplayUnitInfo(base::Int64ToString(id), info, &success, &error); |
| 1192 ASSERT_TRUE(success); | 1192 ASSERT_TRUE(success); |
| 1193 | 1193 |
| 1194 // Verify that other_mode now matches the active mode. | 1194 // Verify that other_mode now matches the active mode. |
| 1195 active_mode = GetDisplayManager()->GetActiveModeForDisplayId(id); | 1195 active_mode = GetDisplayManager()->GetActiveModeForDisplayId(id); |
| 1196 EXPECT_TRUE(active_mode->IsEquivalent(other_mode_ash)); | 1196 EXPECT_TRUE(active_mode->IsEquivalent(other_mode_ash)); |
| 1197 } | 1197 } |
| 1198 | 1198 |
| 1199 TEST_F(DisplayInfoProviderChromeosTest, SetTouchCalibrationInternal) { | 1199 TEST_F(DisplayInfoProviderChromeosTest, CustomTouchCalibrationInternal) { |
| 1200 UpdateDisplay("1200x600,600x1000*2"); | 1200 UpdateDisplay("1200x600,600x1000*2"); |
| 1201 const int64_t internal_display_id = | 1201 const int64_t internal_display_id = |
| 1202 display::test::DisplayManagerTestApi( | 1202 display::test::DisplayManagerTestApi( |
| 1203 ash::Shell::GetInstance()->display_manager()) | 1203 ash::Shell::GetInstance()->display_manager()) |
| 1204 .SetFirstDisplayAsInternalDisplay(); | 1204 .SetFirstDisplayAsInternalDisplay(); |
| 1205 | 1205 |
| 1206 std::string id = base::Int64ToString(internal_display_id); | 1206 std::string id = base::Int64ToString(internal_display_id); |
| 1207 | 1207 |
| 1208 api::system_display::TouchCalibrationPairQuad pairs; | |
| 1209 api::system_display::Bounds bounds; | |
| 1210 | |
| 1211 bool success = false; | |
| 1212 std::string error; | 1208 std::string error; |
| 1213 std::string expected_err = | 1209 std::string expected_err = |
| 1214 "Display Id(" + id + ") is an internal display." + | 1210 "Display Id(" + id + ") is an internal display." + |
| 1215 " Internal displays cannot be calibrated for touch."; | 1211 " Internal displays cannot be calibrated for touch."; |
| 1216 | 1212 bool success = DisplayInfoProvider::Get()->StartCustomTouchCalibration( |
| 1217 success = DisplayInfoProvider::Get()->TouchCalibrationSet(id, pairs, bounds, | 1213 id, &error); |
| 1218 &error); | |
| 1219 | 1214 |
| 1220 ASSERT_FALSE(success); | 1215 ASSERT_FALSE(success); |
| 1221 EXPECT_EQ(expected_err, error); | 1216 EXPECT_EQ(expected_err, error); |
| 1222 } | 1217 } |
| 1223 | 1218 |
| 1224 TEST_F(DisplayInfoProviderChromeosTest, SetTouchCalibrationNonTouchDisplay) { | 1219 TEST_F(DisplayInfoProviderChromeosTest, CustomTouchCalibrationWithoutStart) { |
| 1220 UpdateDisplay("1200x600,600x1000*2"); | |
| 1221 | |
| 1222 api::system_display::TouchCalibrationPairQuad pairs; | |
| 1223 api::system_display::Bounds bounds; | |
| 1224 | |
| 1225 std::string error; | |
| 1226 std::string expected_err = | |
| 1227 "Please call system.display.startCustomTouchCalibration before calling " | |
| 1228 "this method."; | |
|
stevenjb
2017/01/19 17:19:01
This string should be made public and declared in
malaykeshav
2017/01/19 23:49:07
Done
| |
| 1229 bool success = DisplayInfoProvider::Get()->CompleteCustomTouchCalibration( | |
| 1230 pairs, bounds, &error); | |
| 1231 | |
| 1232 ASSERT_FALSE(success); | |
| 1233 EXPECT_EQ(expected_err, error); | |
| 1234 } | |
| 1235 | |
| 1236 | |
| 1237 TEST_F(DisplayInfoProviderChromeosTest, CustomTouchCalibrationNonTouchDisplay) { | |
| 1225 UpdateDisplay("1200x600,600x1000*2"); | 1238 UpdateDisplay("1200x600,600x1000*2"); |
| 1226 | 1239 |
| 1227 const int64_t internal_display_id = | 1240 const int64_t internal_display_id = |
| 1228 display::test::DisplayManagerTestApi( | 1241 display::test::DisplayManagerTestApi( |
| 1229 ash::Shell::GetInstance()->display_manager()) | 1242 ash::Shell::GetInstance()->display_manager()) |
| 1230 .SetFirstDisplayAsInternalDisplay(); | 1243 .SetFirstDisplayAsInternalDisplay(); |
| 1231 | 1244 |
| 1232 display::DisplayIdList display_id_list = | 1245 display::DisplayIdList display_id_list = |
| 1233 display_manager()->GetCurrentDisplayIdList(); | 1246 display_manager()->GetCurrentDisplayIdList(); |
| 1234 | 1247 |
| 1235 // Pick the non internal display Id. | 1248 // Pick the non internal display Id. |
| 1236 const int64_t display_id = display_id_list[0] == internal_display_id | 1249 const int64_t display_id = display_id_list[0] == internal_display_id |
| 1237 ? display_id_list[1] | 1250 ? display_id_list[1] |
| 1238 : display_id_list[0]; | 1251 : display_id_list[0]; |
| 1239 | 1252 |
| 1240 display::test::DisplayManagerTestApi( | 1253 display::test::DisplayManagerTestApi( |
| 1241 ash::Shell::GetInstance()->display_manager()) | 1254 ash::Shell::GetInstance()->display_manager()) |
| 1242 .SetTouchSupport(display_id, display::Display::TOUCH_SUPPORT_UNAVAILABLE); | 1255 .SetTouchSupport(display_id, display::Display::TOUCH_SUPPORT_UNAVAILABLE); |
| 1243 | 1256 |
| 1244 std::string id = base::Int64ToString(display_id); | 1257 std::string id = base::Int64ToString(display_id); |
| 1245 | 1258 |
| 1246 api::system_display::TouchCalibrationPairQuad pairs; | |
| 1247 api::system_display::Bounds bounds; | |
| 1248 | |
| 1249 bool success = false; | |
| 1250 std::string error; | 1259 std::string error; |
| 1251 std::string expected_err = "Display Id(" + id + ") does not support touch."; | 1260 std::string expected_err = "Display Id(" + id + ") does not support touch."; |
| 1252 | 1261 |
| 1253 success = DisplayInfoProvider::Get()->TouchCalibrationSet(id, pairs, bounds, | 1262 bool success = DisplayInfoProvider::Get()->StartCustomTouchCalibration( |
| 1254 &error); | 1263 id, &error); |
| 1255 | 1264 |
| 1256 ASSERT_FALSE(success); | 1265 ASSERT_FALSE(success); |
| 1257 EXPECT_EQ(expected_err, error); | 1266 EXPECT_EQ(expected_err, error); |
| 1258 } | 1267 } |
| 1259 | 1268 |
| 1260 TEST_F(DisplayInfoProviderChromeosTest, SetTouchCalibrationNegativeBounds) { | 1269 TEST_F(DisplayInfoProviderChromeosTest, CustomTouchCalibrationNegativeBounds) { |
| 1261 UpdateDisplay("1200x600,600x1000*2"); | 1270 UpdateDisplay("1200x600,600x1000*2"); |
| 1262 | 1271 |
| 1263 const int64_t internal_display_id = | 1272 const int64_t internal_display_id = |
| 1264 display::test::DisplayManagerTestApi(display_manager()) | 1273 display::test::DisplayManagerTestApi(display_manager()) |
| 1265 .SetFirstDisplayAsInternalDisplay(); | 1274 .SetFirstDisplayAsInternalDisplay(); |
| 1266 | 1275 |
| 1267 display::DisplayIdList display_id_list = | 1276 display::DisplayIdList display_id_list = |
| 1268 display_manager()->GetCurrentDisplayIdList(); | 1277 display_manager()->GetCurrentDisplayIdList(); |
| 1269 | 1278 |
| 1270 // Pick the non internal display Id. | 1279 // Pick the non internal display Id. |
| 1271 const int64_t display_id = display_id_list[0] == internal_display_id | 1280 const int64_t display_id = display_id_list[0] == internal_display_id |
| 1272 ? display_id_list[1] | 1281 ? display_id_list[1] |
| 1273 : display_id_list[0]; | 1282 : display_id_list[0]; |
| 1274 | 1283 |
| 1275 display::test::DisplayManagerTestApi(display_manager()) | 1284 display::test::DisplayManagerTestApi(display_manager()) |
| 1276 .SetTouchSupport(display_id, display::Display::TOUCH_SUPPORT_AVAILABLE); | 1285 .SetTouchSupport(display_id, display::Display::TOUCH_SUPPORT_AVAILABLE); |
| 1277 | 1286 |
| 1278 std::string id = base::Int64ToString(display_id); | 1287 std::string id = base::Int64ToString(display_id); |
| 1279 | 1288 |
| 1280 api::system_display::TouchCalibrationPairQuad pairs; | 1289 api::system_display::TouchCalibrationPairQuad pairs; |
| 1281 api::system_display::Bounds bounds; | 1290 api::system_display::Bounds bounds; |
| 1282 bounds.width = -1; | 1291 bounds.width = -1; |
| 1283 | 1292 |
| 1284 bool success = false; | |
| 1285 std::string error; | 1293 std::string error; |
| 1286 success = DisplayInfoProvider::Get()->TouchCalibrationSet(id, pairs, bounds, | 1294 DisplayInfoProvider::Get()->StartCustomTouchCalibration(id, &error); |
| 1287 &error); | 1295 error = ""; |
|
stevenjb
2017/01/19 17:19:01
nit: error.clear()
malaykeshav
2017/01/19 23:49:07
Done
| |
| 1296 bool success = DisplayInfoProvider::Get()->CompleteCustomTouchCalibration( | |
| 1297 pairs, bounds, &error); | |
| 1288 | 1298 |
| 1289 std::string expected_err = "Bounds cannot have negative values."; | 1299 std::string expected_err = "Bounds cannot have negative values."; |
| 1290 | 1300 |
| 1291 ASSERT_FALSE(success); | 1301 ASSERT_FALSE(success); |
| 1292 EXPECT_EQ(expected_err, error); | 1302 EXPECT_EQ(expected_err, error); |
| 1293 | 1303 |
| 1294 error.clear(); | 1304 error.clear(); |
| 1295 bounds.width = 0; | 1305 bounds.width = 0; |
| 1296 bounds.height = -1; | 1306 bounds.height = -1; |
| 1297 | 1307 |
| 1298 success = DisplayInfoProvider::Get()->TouchCalibrationSet(id, pairs, bounds, | 1308 DisplayInfoProvider::Get()->StartCustomTouchCalibration(id, &error); |
| 1299 &error); | 1309 error = ""; |
| 1310 success = DisplayInfoProvider::Get()->CompleteCustomTouchCalibration( | |
| 1311 pairs, bounds, &error); | |
| 1300 ASSERT_FALSE(success); | 1312 ASSERT_FALSE(success); |
| 1301 EXPECT_EQ(expected_err, error); | 1313 EXPECT_EQ(expected_err, error); |
| 1302 } | 1314 } |
| 1303 | 1315 |
| 1304 TEST_F(DisplayInfoProviderChromeosTest, SetTouchCalibrationInvalidPoints) { | 1316 TEST_F(DisplayInfoProviderChromeosTest, CustomTouchCalibrationInvalidPoints) { |
| 1305 UpdateDisplay("1200x600,600x1000*2"); | 1317 UpdateDisplay("1200x600,600x1000*2"); |
| 1306 | 1318 |
| 1307 const int64_t internal_display_id = | 1319 const int64_t internal_display_id = |
| 1308 display::test::DisplayManagerTestApi(display_manager()) | 1320 display::test::DisplayManagerTestApi(display_manager()) |
| 1309 .SetFirstDisplayAsInternalDisplay(); | 1321 .SetFirstDisplayAsInternalDisplay(); |
| 1310 | 1322 |
| 1311 display::DisplayIdList display_id_list = | 1323 display::DisplayIdList display_id_list = |
| 1312 display_manager()->GetCurrentDisplayIdList(); | 1324 display_manager()->GetCurrentDisplayIdList(); |
| 1313 | 1325 |
| 1314 // Pick the non internal display Id. | 1326 // Pick the non internal display Id. |
| 1315 const int64_t display_id = display_id_list[0] == internal_display_id | 1327 const int64_t display_id = display_id_list[0] == internal_display_id |
| 1316 ? display_id_list[1] | 1328 ? display_id_list[1] |
| 1317 : display_id_list[0]; | 1329 : display_id_list[0]; |
| 1318 | 1330 |
| 1319 display::test::DisplayManagerTestApi(display_manager()) | 1331 display::test::DisplayManagerTestApi(display_manager()) |
| 1320 .SetTouchSupport(display_id, display::Display::TOUCH_SUPPORT_AVAILABLE); | 1332 .SetTouchSupport(display_id, display::Display::TOUCH_SUPPORT_AVAILABLE); |
| 1321 | 1333 |
| 1322 std::string id = base::Int64ToString(display_id); | 1334 std::string id = base::Int64ToString(display_id); |
| 1323 | 1335 |
| 1324 api::system_display::TouchCalibrationPairQuad pairs; | 1336 api::system_display::TouchCalibrationPairQuad pairs; |
| 1325 api::system_display::Bounds bounds; | 1337 api::system_display::Bounds bounds; |
| 1326 | 1338 |
| 1327 pairs.pair1.display_point.x = -1; | 1339 pairs.pair1.display_point.x = -1; |
| 1328 bool success = false; | |
| 1329 std::string error; | 1340 std::string error; |
| 1330 success = DisplayInfoProvider::Get()->TouchCalibrationSet(id, pairs, bounds, | 1341 DisplayInfoProvider::Get()->StartCustomTouchCalibration(id, &error); |
| 1331 &error); | 1342 error = ""; |
| 1343 bool success = DisplayInfoProvider::Get()->CompleteCustomTouchCalibration( | |
| 1344 pairs, bounds, &error); | |
| 1332 | 1345 |
| 1333 std::string expected_err = "Display points and touch points cannot have " | 1346 std::string expected_err = "Display points and touch points cannot have " |
| 1334 "negative coordinates"; | 1347 "negative coordinates"; |
| 1335 | 1348 |
| 1336 ASSERT_FALSE(success); | 1349 ASSERT_FALSE(success); |
| 1337 EXPECT_EQ(expected_err, error); | 1350 EXPECT_EQ(expected_err, error); |
| 1338 | 1351 |
| 1339 error.clear(); | 1352 error.clear(); |
| 1340 bounds.width = 1; | 1353 bounds.width = 1; |
| 1341 pairs.pair1.display_point.x = 2; | 1354 pairs.pair1.display_point.x = 2; |
| 1342 expected_err = "Display point coordinates cannot be more than size of the " | 1355 expected_err = "Display point coordinates cannot be more than size of the " |
| 1343 "display."; | 1356 "display."; |
| 1344 | 1357 |
| 1345 success = DisplayInfoProvider::Get()->TouchCalibrationSet(id, pairs, bounds, | 1358 DisplayInfoProvider::Get()->StartCustomTouchCalibration(id, &error); |
| 1346 &error); | 1359 error = ""; |
| 1360 success = DisplayInfoProvider::Get()->CompleteCustomTouchCalibration( | |
| 1361 pairs, bounds, &error); | |
| 1347 ASSERT_FALSE(success); | 1362 ASSERT_FALSE(success); |
| 1348 EXPECT_EQ(expected_err, error); | 1363 EXPECT_EQ(expected_err, error); |
| 1349 } | 1364 } |
| 1350 | 1365 |
| 1351 TEST_F(DisplayInfoProviderChromeosTest, SetTouchCalibrationSuccess) { | 1366 TEST_F(DisplayInfoProviderChromeosTest, CustomTouchCalibrationSuccess) { |
| 1352 UpdateDisplay("1200x600,600x1000*2"); | 1367 UpdateDisplay("1200x600,600x1000*2"); |
| 1353 | 1368 |
| 1354 const int64_t internal_display_id = | 1369 const int64_t internal_display_id = |
| 1355 display::test::DisplayManagerTestApi(display_manager()) | 1370 display::test::DisplayManagerTestApi(display_manager()) |
| 1356 .SetFirstDisplayAsInternalDisplay(); | 1371 .SetFirstDisplayAsInternalDisplay(); |
| 1357 | 1372 |
| 1358 display::DisplayIdList display_id_list = | 1373 display::DisplayIdList display_id_list = |
| 1359 display_manager()->GetCurrentDisplayIdList(); | 1374 display_manager()->GetCurrentDisplayIdList(); |
| 1360 | 1375 |
| 1361 // Pick the non internal display Id. | 1376 // Pick the non internal display Id. |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 1385 pairs.pair2.touch_point.x = 22; | 1400 pairs.pair2.touch_point.x = 22; |
| 1386 pairs.pair2.touch_point.y = 23; | 1401 pairs.pair2.touch_point.y = 23; |
| 1387 pairs.pair3.touch_point.x = 24; | 1402 pairs.pair3.touch_point.x = 24; |
| 1388 pairs.pair3.touch_point.y = 25; | 1403 pairs.pair3.touch_point.y = 25; |
| 1389 pairs.pair4.touch_point.x = 26; | 1404 pairs.pair4.touch_point.x = 26; |
| 1390 pairs.pair4.touch_point.y = 27; | 1405 pairs.pair4.touch_point.y = 27; |
| 1391 | 1406 |
| 1392 bounds.width = 600; | 1407 bounds.width = 600; |
| 1393 bounds.height = 1000; | 1408 bounds.height = 1000; |
| 1394 | 1409 |
| 1395 bool success = false; | |
| 1396 std::string error; | 1410 std::string error; |
| 1397 success = DisplayInfoProvider::Get()->TouchCalibrationSet(id, pairs, bounds, | 1411 DisplayInfoProvider::Get()->StartCustomTouchCalibration(id, &error); |
| 1398 &error); | 1412 error = ""; |
| 1413 bool success = DisplayInfoProvider::Get()->CompleteCustomTouchCalibration( | |
| 1414 pairs, bounds, &error); | |
| 1399 | 1415 |
| 1400 ASSERT_TRUE(success); | 1416 ASSERT_TRUE(success); |
| 1401 EXPECT_EQ(error, ""); | 1417 EXPECT_EQ(error, ""); |
| 1402 | 1418 |
| 1403 const display::ManagedDisplayInfo& info = | 1419 const display::ManagedDisplayInfo& info = |
| 1404 display_manager()->GetDisplayInfo(display_id); | 1420 display_manager()->GetDisplayInfo(display_id); |
| 1405 | 1421 |
| 1406 ASSERT_TRUE(info.has_touch_calibration_data()); | 1422 ASSERT_TRUE(info.has_touch_calibration_data()); |
| 1407 const display::TouchCalibrationData& data = info.GetTouchCalibrationData(); | 1423 const display::TouchCalibrationData& data = info.GetTouchCalibrationData(); |
| 1408 | 1424 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 1424 EXPECT_EQ(pairs.pair1.touch_point.y, data.point_pairs[0].second.y()); | 1440 EXPECT_EQ(pairs.pair1.touch_point.y, data.point_pairs[0].second.y()); |
| 1425 EXPECT_EQ(pairs.pair2.touch_point.y, data.point_pairs[1].second.y()); | 1441 EXPECT_EQ(pairs.pair2.touch_point.y, data.point_pairs[1].second.y()); |
| 1426 EXPECT_EQ(pairs.pair3.touch_point.y, data.point_pairs[2].second.y()); | 1442 EXPECT_EQ(pairs.pair3.touch_point.y, data.point_pairs[2].second.y()); |
| 1427 EXPECT_EQ(pairs.pair4.touch_point.y, data.point_pairs[3].second.y()); | 1443 EXPECT_EQ(pairs.pair4.touch_point.y, data.point_pairs[3].second.y()); |
| 1428 | 1444 |
| 1429 EXPECT_EQ(bounds.width, data.bounds.width()); | 1445 EXPECT_EQ(bounds.width, data.bounds.width()); |
| 1430 EXPECT_EQ(bounds.height, data.bounds.height()); | 1446 EXPECT_EQ(bounds.height, data.bounds.height()); |
| 1431 } | 1447 } |
| 1432 } // namespace | 1448 } // namespace |
| 1433 } // namespace extensions | 1449 } // namespace extensions |
| OLD | NEW |