| Index: chrome/browser/extensions/display_info_provider_chromeos_unittest.cc
|
| diff --git a/chrome/browser/extensions/display_info_provider_chromeos_unittest.cc b/chrome/browser/extensions/display_info_provider_chromeos_unittest.cc
|
| index ab53176db31f78e430fb754a7fc2a4b6c31b0ff9..efb4524fa15dc7374b9fc5668cfc76f22f4b173b 100644
|
| --- a/chrome/browser/extensions/display_info_provider_chromeos_unittest.cc
|
| +++ b/chrome/browser/extensions/display_info_provider_chromeos_unittest.cc
|
| @@ -1196,5 +1196,238 @@ TEST_F(DisplayInfoProviderChromeosTest, DisplayMode) {
|
| EXPECT_TRUE(active_mode->IsEquivalent(other_mode_ash));
|
| }
|
|
|
| +TEST_F(DisplayInfoProviderChromeosTest, SetTouchCalibrationInternal) {
|
| + UpdateDisplay("1200x600,600x1000*2");
|
| + const int64_t internal_display_id =
|
| + display::test::DisplayManagerTestApi(
|
| + ash::Shell::GetInstance()->display_manager())
|
| + .SetFirstDisplayAsInternalDisplay();
|
| +
|
| + std::string id = base::Int64ToString(internal_display_id);
|
| +
|
| + api::system_display::TouchCalibrationPairQuad pairs;
|
| + api::system_display::Bounds bounds;
|
| +
|
| + bool success = false;
|
| + std::string error;
|
| + std::string expected_err =
|
| + "Display Id(" + id + ") is an internal display." +
|
| + " Internal displays cannot be calibrated for touch.";
|
| +
|
| + success = DisplayInfoProvider::Get()->TouchCalibrationSet(id, pairs, bounds,
|
| + &error);
|
| +
|
| + ASSERT_FALSE(success);
|
| + EXPECT_EQ(expected_err, error);
|
| +}
|
| +
|
| +TEST_F(DisplayInfoProviderChromeosTest, SetTouchCalibrationNonTouchDisplay) {
|
| + UpdateDisplay("1200x600,600x1000*2");
|
| +
|
| + const int64_t internal_display_id =
|
| + display::test::DisplayManagerTestApi(
|
| + ash::Shell::GetInstance()->display_manager())
|
| + .SetFirstDisplayAsInternalDisplay();
|
| +
|
| + display::DisplayIdList display_id_list =
|
| + display_manager()->GetCurrentDisplayIdList();
|
| +
|
| + // Pick the non internal display Id.
|
| + const int64_t display_id = display_id_list[0] == internal_display_id
|
| + ? display_id_list[1]
|
| + : display_id_list[0];
|
| +
|
| + display::test::DisplayManagerTestApi(
|
| + ash::Shell::GetInstance()->display_manager())
|
| + .SetTouchSupport(display_id, display::Display::TOUCH_SUPPORT_UNAVAILABLE);
|
| +
|
| + std::string id = base::Int64ToString(display_id);
|
| +
|
| + api::system_display::TouchCalibrationPairQuad pairs;
|
| + api::system_display::Bounds bounds;
|
| +
|
| + bool success = false;
|
| + std::string error;
|
| + std::string expected_err = "Display Id(" + id + ") does not support touch.";
|
| +
|
| + success = DisplayInfoProvider::Get()->TouchCalibrationSet(id, pairs, bounds,
|
| + &error);
|
| +
|
| + ASSERT_FALSE(success);
|
| + EXPECT_EQ(expected_err, error);
|
| +}
|
| +
|
| +TEST_F(DisplayInfoProviderChromeosTest, SetTouchCalibrationNegativeBounds) {
|
| + UpdateDisplay("1200x600,600x1000*2");
|
| +
|
| + const int64_t internal_display_id =
|
| + display::test::DisplayManagerTestApi(display_manager())
|
| + .SetFirstDisplayAsInternalDisplay();
|
| +
|
| + display::DisplayIdList display_id_list =
|
| + display_manager()->GetCurrentDisplayIdList();
|
| +
|
| + // Pick the non internal display Id.
|
| + const int64_t display_id = display_id_list[0] == internal_display_id
|
| + ? display_id_list[1]
|
| + : display_id_list[0];
|
| +
|
| + display::test::DisplayManagerTestApi(display_manager())
|
| + .SetTouchSupport(display_id, display::Display::TOUCH_SUPPORT_AVAILABLE);
|
| +
|
| + std::string id = base::Int64ToString(display_id);
|
| +
|
| + api::system_display::TouchCalibrationPairQuad pairs;
|
| + api::system_display::Bounds bounds;
|
| + bounds.width = -1;
|
| +
|
| + bool success = false;
|
| + std::string error;
|
| + success = DisplayInfoProvider::Get()->TouchCalibrationSet(id, pairs, bounds,
|
| + &error);
|
| +
|
| + std::string expected_err = "Bounds cannot have negative values.";
|
| +
|
| + ASSERT_FALSE(success);
|
| + EXPECT_EQ(expected_err, error);
|
| +
|
| + error.clear();
|
| + bounds.width = 0;
|
| + bounds.height = -1;
|
| +
|
| + success = DisplayInfoProvider::Get()->TouchCalibrationSet(id, pairs, bounds,
|
| + &error);
|
| + ASSERT_FALSE(success);
|
| + EXPECT_EQ(expected_err, error);
|
| +}
|
| +
|
| +TEST_F(DisplayInfoProviderChromeosTest, SetTouchCalibrationInvalidPoints) {
|
| + UpdateDisplay("1200x600,600x1000*2");
|
| +
|
| + const int64_t internal_display_id =
|
| + display::test::DisplayManagerTestApi(display_manager())
|
| + .SetFirstDisplayAsInternalDisplay();
|
| +
|
| + display::DisplayIdList display_id_list =
|
| + display_manager()->GetCurrentDisplayIdList();
|
| +
|
| + // Pick the non internal display Id.
|
| + const int64_t display_id = display_id_list[0] == internal_display_id
|
| + ? display_id_list[1]
|
| + : display_id_list[0];
|
| +
|
| + display::test::DisplayManagerTestApi(display_manager())
|
| + .SetTouchSupport(display_id, display::Display::TOUCH_SUPPORT_AVAILABLE);
|
| +
|
| + std::string id = base::Int64ToString(display_id);
|
| +
|
| + api::system_display::TouchCalibrationPairQuad pairs;
|
| + api::system_display::Bounds bounds;
|
| +
|
| + pairs.pair1.display_point.x = -1;
|
| + bool success = false;
|
| + std::string error;
|
| + success = DisplayInfoProvider::Get()->TouchCalibrationSet(id, pairs, bounds,
|
| + &error);
|
| +
|
| + std::string expected_err = "Display points and touch points cannot have "
|
| + "negative coordinates";
|
| +
|
| + ASSERT_FALSE(success);
|
| + EXPECT_EQ(expected_err, error);
|
| +
|
| + error.clear();
|
| + bounds.width = 1;
|
| + pairs.pair1.display_point.x = 2;
|
| + expected_err = "Display point coordinates cannot be more than size of the "
|
| + "display.";
|
| +
|
| + success = DisplayInfoProvider::Get()->TouchCalibrationSet(id, pairs, bounds,
|
| + &error);
|
| + ASSERT_FALSE(success);
|
| + EXPECT_EQ(expected_err, error);
|
| +}
|
| +
|
| +TEST_F(DisplayInfoProviderChromeosTest, SetTouchCalibrationSuccess) {
|
| + UpdateDisplay("1200x600,600x1000*2");
|
| +
|
| + const int64_t internal_display_id =
|
| + display::test::DisplayManagerTestApi(display_manager())
|
| + .SetFirstDisplayAsInternalDisplay();
|
| +
|
| + display::DisplayIdList display_id_list =
|
| + display_manager()->GetCurrentDisplayIdList();
|
| +
|
| + // Pick the non internal display Id.
|
| + const int64_t display_id = display_id_list[0] == internal_display_id
|
| + ? display_id_list[1]
|
| + : display_id_list[0];
|
| +
|
| + display::test::DisplayManagerTestApi(display_manager())
|
| + .SetTouchSupport(display_id, display::Display::TOUCH_SUPPORT_AVAILABLE);
|
| +
|
| + std::string id = base::Int64ToString(display_id);
|
| +
|
| + api::system_display::TouchCalibrationPairQuad pairs;
|
| + api::system_display::Bounds bounds;
|
| +
|
| + pairs.pair1.display_point.x = 10;
|
| + pairs.pair1.display_point.y = 11;
|
| + pairs.pair2.display_point.x = 12;
|
| + pairs.pair2.display_point.y = 13;
|
| + pairs.pair3.display_point.x = 14;
|
| + pairs.pair3.display_point.y = 15;
|
| + pairs.pair4.display_point.x = 16;
|
| + pairs.pair4.display_point.y = 17;
|
| +
|
| + pairs.pair1.touch_point.x = 20;
|
| + pairs.pair1.touch_point.y = 21;
|
| + pairs.pair2.touch_point.x = 22;
|
| + pairs.pair2.touch_point.y = 23;
|
| + pairs.pair3.touch_point.x = 24;
|
| + pairs.pair3.touch_point.y = 25;
|
| + pairs.pair4.touch_point.x = 26;
|
| + pairs.pair4.touch_point.y = 27;
|
| +
|
| + bounds.width = 600;
|
| + bounds.height = 1000;
|
| +
|
| + bool success = false;
|
| + std::string error;
|
| + success = DisplayInfoProvider::Get()->TouchCalibrationSet(id, pairs, bounds,
|
| + &error);
|
| +
|
| + ASSERT_TRUE(success);
|
| + EXPECT_EQ(error, "");
|
| +
|
| + const display::ManagedDisplayInfo& info =
|
| + display_manager()->GetDisplayInfo(display_id);
|
| +
|
| + ASSERT_TRUE(info.has_touch_calibration_data());
|
| + const display::TouchCalibrationData& data = info.GetTouchCalibrationData();
|
| +
|
| + EXPECT_EQ(pairs.pair1.display_point.x, data.point_pairs[0].first.x());
|
| + EXPECT_EQ(pairs.pair2.display_point.x, data.point_pairs[1].first.x());
|
| + EXPECT_EQ(pairs.pair3.display_point.x, data.point_pairs[2].first.x());
|
| + EXPECT_EQ(pairs.pair4.display_point.x, data.point_pairs[3].first.x());
|
| +
|
| + EXPECT_EQ(pairs.pair1.display_point.y, data.point_pairs[0].first.y());
|
| + EXPECT_EQ(pairs.pair2.display_point.y, data.point_pairs[1].first.y());
|
| + EXPECT_EQ(pairs.pair3.display_point.y, data.point_pairs[2].first.y());
|
| + EXPECT_EQ(pairs.pair4.display_point.y, data.point_pairs[3].first.y());
|
| +
|
| + EXPECT_EQ(pairs.pair1.touch_point.x, data.point_pairs[0].second.x());
|
| + EXPECT_EQ(pairs.pair2.touch_point.x, data.point_pairs[1].second.x());
|
| + EXPECT_EQ(pairs.pair3.touch_point.x, data.point_pairs[2].second.x());
|
| + EXPECT_EQ(pairs.pair4.touch_point.x, data.point_pairs[3].second.x());
|
| +
|
| + EXPECT_EQ(pairs.pair1.touch_point.y, data.point_pairs[0].second.y());
|
| + EXPECT_EQ(pairs.pair2.touch_point.y, data.point_pairs[1].second.y());
|
| + EXPECT_EQ(pairs.pair3.touch_point.y, data.point_pairs[2].second.y());
|
| + EXPECT_EQ(pairs.pair4.touch_point.y, data.point_pairs[3].second.y());
|
| +
|
| + EXPECT_EQ(bounds.width, data.bounds.width());
|
| + EXPECT_EQ(bounds.height, data.bounds.height());
|
| +}
|
| } // namespace
|
| } // namespace extensions
|
|
|