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

Side by Side Diff: chrome/browser/extensions/display_info_provider_chromeos_unittest.cc

Issue 2638903003: Updates touch calibration API and plumbs through the native touch calibration method (Closed)
Patch Set: Created 3 years, 11 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
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 "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
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 bool success = false;
Reilly Grant (use Gerrit) 2017/01/18 21:35:56 Declare |success| where it is assigned.
malaykeshav 2017/01/19 01:30:51 Done
1209 std::string error;
1210 std::string expected_err =
1211 "Display Id(" + id + ") is an internal display." +
1212 " Internal displays cannot be calibrated for touch.";
1213 success = DisplayInfoProvider::Get()->StartCustomTouchCalibration(id, &error);
1214
1215 ASSERT_FALSE(success);
1216 EXPECT_EQ(expected_err, error);
1217 }
1218
1219 TEST_F(DisplayInfoProviderChromeosTest, CustomTouchCalibrationWithoutStart) {
1220 UpdateDisplay("1200x600,600x1000*2");
1221
1208 api::system_display::TouchCalibrationPairQuad pairs; 1222 api::system_display::TouchCalibrationPairQuad pairs;
1209 api::system_display::Bounds bounds; 1223 api::system_display::Bounds bounds;
1210 1224
1211 bool success = false; 1225 bool success = false;
1212 std::string error; 1226 std::string error;
1213 std::string expected_err = 1227 std::string expected_err =
1214 "Display Id(" + id + ") is an internal display." + 1228 "Please call StartCustomTouchCalibration() before calling this method.";
1215 " Internal displays cannot be calibrated for touch."; 1229 success = DisplayInfoProvider::Get()->CompleteCustomTouchCalibration(pairs,
1216 1230 bounds,
1217 success = DisplayInfoProvider::Get()->TouchCalibrationSet(id, pairs, bounds, 1231 &error);
1218 &error);
1219 1232
1220 ASSERT_FALSE(success); 1233 ASSERT_FALSE(success);
1221 EXPECT_EQ(expected_err, error); 1234 EXPECT_EQ(expected_err, error);
1222 } 1235 }
1223 1236
1224 TEST_F(DisplayInfoProviderChromeosTest, SetTouchCalibrationNonTouchDisplay) { 1237
1238 TEST_F(DisplayInfoProviderChromeosTest, CustomTouchCalibrationNonTouchDisplay) {
1225 UpdateDisplay("1200x600,600x1000*2"); 1239 UpdateDisplay("1200x600,600x1000*2");
1226 1240
1227 const int64_t internal_display_id = 1241 const int64_t internal_display_id =
1228 display::test::DisplayManagerTestApi( 1242 display::test::DisplayManagerTestApi(
1229 ash::Shell::GetInstance()->display_manager()) 1243 ash::Shell::GetInstance()->display_manager())
1230 .SetFirstDisplayAsInternalDisplay(); 1244 .SetFirstDisplayAsInternalDisplay();
1231 1245
1232 display::DisplayIdList display_id_list = 1246 display::DisplayIdList display_id_list =
1233 display_manager()->GetCurrentDisplayIdList(); 1247 display_manager()->GetCurrentDisplayIdList();
1234 1248
1235 // Pick the non internal display Id. 1249 // Pick the non internal display Id.
1236 const int64_t display_id = display_id_list[0] == internal_display_id 1250 const int64_t display_id = display_id_list[0] == internal_display_id
1237 ? display_id_list[1] 1251 ? display_id_list[1]
1238 : display_id_list[0]; 1252 : display_id_list[0];
1239 1253
1240 display::test::DisplayManagerTestApi( 1254 display::test::DisplayManagerTestApi(
1241 ash::Shell::GetInstance()->display_manager()) 1255 ash::Shell::GetInstance()->display_manager())
1242 .SetTouchSupport(display_id, display::Display::TOUCH_SUPPORT_UNAVAILABLE); 1256 .SetTouchSupport(display_id, display::Display::TOUCH_SUPPORT_UNAVAILABLE);
1243 1257
1244 std::string id = base::Int64ToString(display_id); 1258 std::string id = base::Int64ToString(display_id);
1245 1259
1246 api::system_display::TouchCalibrationPairQuad pairs;
1247 api::system_display::Bounds bounds;
1248
1249 bool success = false; 1260 bool success = false;
1250 std::string error; 1261 std::string error;
1251 std::string expected_err = "Display Id(" + id + ") does not support touch."; 1262 std::string expected_err = "Display Id(" + id + ") does not support touch.";
1252 1263
1253 success = DisplayInfoProvider::Get()->TouchCalibrationSet(id, pairs, bounds, 1264 success = DisplayInfoProvider::Get()->StartCustomTouchCalibration(id, &error);
1254 &error);
1255 1265
1256 ASSERT_FALSE(success); 1266 ASSERT_FALSE(success);
1257 EXPECT_EQ(expected_err, error); 1267 EXPECT_EQ(expected_err, error);
1258 } 1268 }
1259 1269
1260 TEST_F(DisplayInfoProviderChromeosTest, SetTouchCalibrationNegativeBounds) { 1270 TEST_F(DisplayInfoProviderChromeosTest, CustomTouchCalibrationNegativeBounds) {
1261 UpdateDisplay("1200x600,600x1000*2"); 1271 UpdateDisplay("1200x600,600x1000*2");
1262 1272
1263 const int64_t internal_display_id = 1273 const int64_t internal_display_id =
1264 display::test::DisplayManagerTestApi(display_manager()) 1274 display::test::DisplayManagerTestApi(display_manager())
1265 .SetFirstDisplayAsInternalDisplay(); 1275 .SetFirstDisplayAsInternalDisplay();
1266 1276
1267 display::DisplayIdList display_id_list = 1277 display::DisplayIdList display_id_list =
1268 display_manager()->GetCurrentDisplayIdList(); 1278 display_manager()->GetCurrentDisplayIdList();
1269 1279
1270 // Pick the non internal display Id. 1280 // Pick the non internal display Id.
1271 const int64_t display_id = display_id_list[0] == internal_display_id 1281 const int64_t display_id = display_id_list[0] == internal_display_id
1272 ? display_id_list[1] 1282 ? display_id_list[1]
1273 : display_id_list[0]; 1283 : display_id_list[0];
1274 1284
1275 display::test::DisplayManagerTestApi(display_manager()) 1285 display::test::DisplayManagerTestApi(display_manager())
1276 .SetTouchSupport(display_id, display::Display::TOUCH_SUPPORT_AVAILABLE); 1286 .SetTouchSupport(display_id, display::Display::TOUCH_SUPPORT_AVAILABLE);
1277 1287
1278 std::string id = base::Int64ToString(display_id); 1288 std::string id = base::Int64ToString(display_id);
1279 1289
1280 api::system_display::TouchCalibrationPairQuad pairs; 1290 api::system_display::TouchCalibrationPairQuad pairs;
1281 api::system_display::Bounds bounds; 1291 api::system_display::Bounds bounds;
1282 bounds.width = -1; 1292 bounds.width = -1;
1283 1293
1284 bool success = false; 1294 bool success = false;
1285 std::string error; 1295 std::string error;
1286 success = DisplayInfoProvider::Get()->TouchCalibrationSet(id, pairs, bounds, 1296 DisplayInfoProvider::Get()->StartCustomTouchCalibration(id, &error);
1287 &error); 1297 error = "";
1298 success = DisplayInfoProvider::Get()->CompleteCustomTouchCalibration(
1299 pairs, bounds, &error);
1288 1300
1289 std::string expected_err = "Bounds cannot have negative values."; 1301 std::string expected_err = "Bounds cannot have negative values.";
1290 1302
1291 ASSERT_FALSE(success); 1303 ASSERT_FALSE(success);
1292 EXPECT_EQ(expected_err, error); 1304 EXPECT_EQ(expected_err, error);
1293 1305
1294 error.clear(); 1306 error.clear();
1295 bounds.width = 0; 1307 bounds.width = 0;
1296 bounds.height = -1; 1308 bounds.height = -1;
1297 1309
1298 success = DisplayInfoProvider::Get()->TouchCalibrationSet(id, pairs, bounds, 1310 DisplayInfoProvider::Get()->StartCustomTouchCalibration(id, &error);
1299 &error); 1311 error = "";
1312 success = DisplayInfoProvider::Get()->CompleteCustomTouchCalibration(
1313 pairs, bounds, &error);
1300 ASSERT_FALSE(success); 1314 ASSERT_FALSE(success);
1301 EXPECT_EQ(expected_err, error); 1315 EXPECT_EQ(expected_err, error);
1302 } 1316 }
1303 1317
1304 TEST_F(DisplayInfoProviderChromeosTest, SetTouchCalibrationInvalidPoints) { 1318 TEST_F(DisplayInfoProviderChromeosTest, CustomTouchCalibrationInvalidPoints) {
1305 UpdateDisplay("1200x600,600x1000*2"); 1319 UpdateDisplay("1200x600,600x1000*2");
1306 1320
1307 const int64_t internal_display_id = 1321 const int64_t internal_display_id =
1308 display::test::DisplayManagerTestApi(display_manager()) 1322 display::test::DisplayManagerTestApi(display_manager())
1309 .SetFirstDisplayAsInternalDisplay(); 1323 .SetFirstDisplayAsInternalDisplay();
1310 1324
1311 display::DisplayIdList display_id_list = 1325 display::DisplayIdList display_id_list =
1312 display_manager()->GetCurrentDisplayIdList(); 1326 display_manager()->GetCurrentDisplayIdList();
1313 1327
1314 // Pick the non internal display Id. 1328 // Pick the non internal display Id.
1315 const int64_t display_id = display_id_list[0] == internal_display_id 1329 const int64_t display_id = display_id_list[0] == internal_display_id
1316 ? display_id_list[1] 1330 ? display_id_list[1]
1317 : display_id_list[0]; 1331 : display_id_list[0];
1318 1332
1319 display::test::DisplayManagerTestApi(display_manager()) 1333 display::test::DisplayManagerTestApi(display_manager())
1320 .SetTouchSupport(display_id, display::Display::TOUCH_SUPPORT_AVAILABLE); 1334 .SetTouchSupport(display_id, display::Display::TOUCH_SUPPORT_AVAILABLE);
1321 1335
1322 std::string id = base::Int64ToString(display_id); 1336 std::string id = base::Int64ToString(display_id);
1323 1337
1324 api::system_display::TouchCalibrationPairQuad pairs; 1338 api::system_display::TouchCalibrationPairQuad pairs;
1325 api::system_display::Bounds bounds; 1339 api::system_display::Bounds bounds;
1326 1340
1327 pairs.pair1.display_point.x = -1; 1341 pairs.pair1.display_point.x = -1;
1328 bool success = false; 1342 bool success = false;
1329 std::string error; 1343 std::string error;
1330 success = DisplayInfoProvider::Get()->TouchCalibrationSet(id, pairs, bounds, 1344 DisplayInfoProvider::Get()->StartCustomTouchCalibration(id, &error);
1331 &error); 1345 error = "";
1346 success = DisplayInfoProvider::Get()->CompleteCustomTouchCalibration(
1347 pairs, bounds, &error);
1332 1348
1333 std::string expected_err = "Display points and touch points cannot have " 1349 std::string expected_err = "Display points and touch points cannot have "
1334 "negative coordinates"; 1350 "negative coordinates";
1335 1351
1336 ASSERT_FALSE(success); 1352 ASSERT_FALSE(success);
1337 EXPECT_EQ(expected_err, error); 1353 EXPECT_EQ(expected_err, error);
1338 1354
1339 error.clear(); 1355 error.clear();
1340 bounds.width = 1; 1356 bounds.width = 1;
1341 pairs.pair1.display_point.x = 2; 1357 pairs.pair1.display_point.x = 2;
1342 expected_err = "Display point coordinates cannot be more than size of the " 1358 expected_err = "Display point coordinates cannot be more than size of the "
1343 "display."; 1359 "display.";
1344 1360
1345 success = DisplayInfoProvider::Get()->TouchCalibrationSet(id, pairs, bounds, 1361 DisplayInfoProvider::Get()->StartCustomTouchCalibration(id, &error);
1346 &error); 1362 error = "";
1363 success = DisplayInfoProvider::Get()->CompleteCustomTouchCalibration(
1364 pairs, bounds, &error);
1347 ASSERT_FALSE(success); 1365 ASSERT_FALSE(success);
1348 EXPECT_EQ(expected_err, error); 1366 EXPECT_EQ(expected_err, error);
1349 } 1367 }
1350 1368
1351 TEST_F(DisplayInfoProviderChromeosTest, SetTouchCalibrationSuccess) { 1369 TEST_F(DisplayInfoProviderChromeosTest, CustomTouchCalibrationSuccess) {
1352 UpdateDisplay("1200x600,600x1000*2"); 1370 UpdateDisplay("1200x600,600x1000*2");
1353 1371
1354 const int64_t internal_display_id = 1372 const int64_t internal_display_id =
1355 display::test::DisplayManagerTestApi(display_manager()) 1373 display::test::DisplayManagerTestApi(display_manager())
1356 .SetFirstDisplayAsInternalDisplay(); 1374 .SetFirstDisplayAsInternalDisplay();
1357 1375
1358 display::DisplayIdList display_id_list = 1376 display::DisplayIdList display_id_list =
1359 display_manager()->GetCurrentDisplayIdList(); 1377 display_manager()->GetCurrentDisplayIdList();
1360 1378
1361 // Pick the non internal display Id. 1379 // Pick the non internal display Id.
(...skipping 25 matching lines...) Expand all
1387 pairs.pair3.touch_point.x = 24; 1405 pairs.pair3.touch_point.x = 24;
1388 pairs.pair3.touch_point.y = 25; 1406 pairs.pair3.touch_point.y = 25;
1389 pairs.pair4.touch_point.x = 26; 1407 pairs.pair4.touch_point.x = 26;
1390 pairs.pair4.touch_point.y = 27; 1408 pairs.pair4.touch_point.y = 27;
1391 1409
1392 bounds.width = 600; 1410 bounds.width = 600;
1393 bounds.height = 1000; 1411 bounds.height = 1000;
1394 1412
1395 bool success = false; 1413 bool success = false;
1396 std::string error; 1414 std::string error;
1397 success = DisplayInfoProvider::Get()->TouchCalibrationSet(id, pairs, bounds, 1415 DisplayInfoProvider::Get()->StartCustomTouchCalibration(id, &error);
1398 &error); 1416 error = "";
1417 success = DisplayInfoProvider::Get()->CompleteCustomTouchCalibration(
1418 pairs, bounds, &error);
1399 1419
1400 ASSERT_TRUE(success); 1420 ASSERT_TRUE(success);
1401 EXPECT_EQ(error, ""); 1421 EXPECT_EQ(error, "");
1402 1422
1403 const display::ManagedDisplayInfo& info = 1423 const display::ManagedDisplayInfo& info =
1404 display_manager()->GetDisplayInfo(display_id); 1424 display_manager()->GetDisplayInfo(display_id);
1405 1425
1406 ASSERT_TRUE(info.has_touch_calibration_data()); 1426 ASSERT_TRUE(info.has_touch_calibration_data());
1407 const display::TouchCalibrationData& data = info.GetTouchCalibrationData(); 1427 const display::TouchCalibrationData& data = info.GetTouchCalibrationData();
1408 1428
(...skipping 15 matching lines...) Expand all
1424 EXPECT_EQ(pairs.pair1.touch_point.y, data.point_pairs[0].second.y()); 1444 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()); 1445 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()); 1446 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()); 1447 EXPECT_EQ(pairs.pair4.touch_point.y, data.point_pairs[3].second.y());
1428 1448
1429 EXPECT_EQ(bounds.width, data.bounds.width()); 1449 EXPECT_EQ(bounds.width, data.bounds.width());
1430 EXPECT_EQ(bounds.height, data.bounds.height()); 1450 EXPECT_EQ(bounds.height, data.bounds.height());
1431 } 1451 }
1432 } // namespace 1452 } // namespace
1433 } // namespace extensions 1453 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698