| 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 <string> |
| 5 #include <vector> | 6 #include <vector> |
| 6 | 7 |
| 7 #include "ash/display/display_info.h" | 8 #include "ash/display/display_info.h" |
| 8 #include "ash/touch/touchscreen_util.h" | 9 #include "ash/touch/touchscreen_util.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "ui/events/input_device.h" |
| 10 | 12 |
| 11 namespace ash { | 13 namespace ash { |
| 12 | 14 |
| 13 class TouchscreenUtilTest : public testing::Test { | 15 class TouchscreenUtilTest : public testing::Test { |
| 14 public: | 16 public: |
| 15 TouchscreenUtilTest() {} | 17 TouchscreenUtilTest() {} |
| 16 virtual ~TouchscreenUtilTest() {} | 18 virtual ~TouchscreenUtilTest() {} |
| 17 | 19 |
| 18 virtual void SetUp() override { | 20 virtual void SetUp() override { |
| 19 // Internal display will always match to internal touchscreen. If internal | 21 // Internal display will always match to internal touchscreen. If internal |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 std::vector<ui::TouchscreenDevice> devices; | 71 std::vector<ui::TouchscreenDevice> devices; |
| 70 AssociateTouchscreens(&displays_, devices); | 72 AssociateTouchscreens(&displays_, devices); |
| 71 | 73 |
| 72 for (size_t i = 0; i < displays_.size(); ++i) | 74 for (size_t i = 0; i < displays_.size(); ++i) |
| 73 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, | 75 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, |
| 74 displays_[i].touch_device_id()); | 76 displays_[i].touch_device_id()); |
| 75 } | 77 } |
| 76 | 78 |
| 77 TEST_F(TouchscreenUtilTest, OneToOneMapping) { | 79 TEST_F(TouchscreenUtilTest, OneToOneMapping) { |
| 78 std::vector<ui::TouchscreenDevice> devices; | 80 std::vector<ui::TouchscreenDevice> devices; |
| 79 devices.push_back(ui::TouchscreenDevice(1, gfx::Size(800, 600), false)); | 81 devices.push_back(ui::TouchscreenDevice(1, ui::InputDeviceType::EXTERNAL, |
| 80 devices.push_back(ui::TouchscreenDevice(2, gfx::Size(1024, 768), false)); | 82 "", gfx::Size(800, 600))); |
| 83 devices.push_back(ui::TouchscreenDevice(2, ui::InputDeviceType::EXTERNAL, |
| 84 "", gfx::Size(1024, 768))); |
| 81 | 85 |
| 82 AssociateTouchscreens(&displays_, devices); | 86 AssociateTouchscreens(&displays_, devices); |
| 83 | 87 |
| 84 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id()); | 88 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id()); |
| 85 EXPECT_EQ(1, displays_[1].touch_device_id()); | 89 EXPECT_EQ(1, displays_[1].touch_device_id()); |
| 86 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); | 90 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); |
| 87 EXPECT_EQ(2, displays_[3].touch_device_id()); | 91 EXPECT_EQ(2, displays_[3].touch_device_id()); |
| 88 } | 92 } |
| 89 | 93 |
| 90 TEST_F(TouchscreenUtilTest, MapToCorrectDisplaySize) { | 94 TEST_F(TouchscreenUtilTest, MapToCorrectDisplaySize) { |
| 91 std::vector<ui::TouchscreenDevice> devices; | 95 std::vector<ui::TouchscreenDevice> devices; |
| 92 devices.push_back(ui::TouchscreenDevice(2, gfx::Size(1024, 768), false)); | 96 devices.push_back(ui::TouchscreenDevice(2, ui::InputDeviceType::EXTERNAL, |
| 97 "", gfx::Size(1024, 768))); |
| 93 | 98 |
| 94 AssociateTouchscreens(&displays_, devices); | 99 AssociateTouchscreens(&displays_, devices); |
| 95 | 100 |
| 96 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id()); | 101 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id()); |
| 97 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[1].touch_device_id()); | 102 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[1].touch_device_id()); |
| 98 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); | 103 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); |
| 99 EXPECT_EQ(2, displays_[3].touch_device_id()); | 104 EXPECT_EQ(2, displays_[3].touch_device_id()); |
| 100 } | 105 } |
| 101 | 106 |
| 102 TEST_F(TouchscreenUtilTest, MapWhenSizeDiffersByOne) { | 107 TEST_F(TouchscreenUtilTest, MapWhenSizeDiffersByOne) { |
| 103 std::vector<ui::TouchscreenDevice> devices; | 108 std::vector<ui::TouchscreenDevice> devices; |
| 104 devices.push_back(ui::TouchscreenDevice(1, gfx::Size(801, 600), false)); | 109 devices.push_back(ui::TouchscreenDevice(1, ui::InputDeviceType::EXTERNAL, |
| 105 devices.push_back(ui::TouchscreenDevice(2, gfx::Size(1023, 768), false)); | 110 "", gfx::Size(801, 600))); |
| 111 devices.push_back(ui::TouchscreenDevice(2, ui::InputDeviceType::EXTERNAL, |
| 112 "", gfx::Size(1023, 768))); |
| 106 | 113 |
| 107 AssociateTouchscreens(&displays_, devices); | 114 AssociateTouchscreens(&displays_, devices); |
| 108 | 115 |
| 109 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id()); | 116 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id()); |
| 110 EXPECT_EQ(1, displays_[1].touch_device_id()); | 117 EXPECT_EQ(1, displays_[1].touch_device_id()); |
| 111 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); | 118 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); |
| 112 EXPECT_EQ(2, displays_[3].touch_device_id()); | 119 EXPECT_EQ(2, displays_[3].touch_device_id()); |
| 113 } | 120 } |
| 114 | 121 |
| 115 TEST_F(TouchscreenUtilTest, MapWhenSizesDoNotMatch) { | 122 TEST_F(TouchscreenUtilTest, MapWhenSizesDoNotMatch) { |
| 116 std::vector<ui::TouchscreenDevice> devices; | 123 std::vector<ui::TouchscreenDevice> devices; |
| 117 devices.push_back(ui::TouchscreenDevice(1, gfx::Size(1022, 768), false)); | 124 devices.push_back(ui::TouchscreenDevice(1, ui::InputDeviceType::EXTERNAL, |
| 118 devices.push_back(ui::TouchscreenDevice(2, gfx::Size(802, 600), false)); | 125 "", gfx::Size(1022, 768))); |
| 126 devices.push_back(ui::TouchscreenDevice(2, ui::InputDeviceType::EXTERNAL, |
| 127 "", gfx::Size(802, 600))); |
| 119 | 128 |
| 120 AssociateTouchscreens(&displays_, devices); | 129 AssociateTouchscreens(&displays_, devices); |
| 121 | 130 |
| 122 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id()); | 131 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id()); |
| 123 EXPECT_EQ(1, displays_[1].touch_device_id()); | 132 EXPECT_EQ(1, displays_[1].touch_device_id()); |
| 124 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); | 133 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); |
| 125 EXPECT_EQ(2, displays_[3].touch_device_id()); | 134 EXPECT_EQ(2, displays_[3].touch_device_id()); |
| 126 } | 135 } |
| 127 | 136 |
| 128 TEST_F(TouchscreenUtilTest, MapInternalTouchscreen) { | 137 TEST_F(TouchscreenUtilTest, MapInternalTouchscreen) { |
| 129 std::vector<ui::TouchscreenDevice> devices; | 138 std::vector<ui::TouchscreenDevice> devices; |
| 130 devices.push_back(ui::TouchscreenDevice(1, gfx::Size(1920, 1080), false)); | 139 devices.push_back(ui::TouchscreenDevice(1, ui::InputDeviceType::EXTERNAL, |
| 131 devices.push_back(ui::TouchscreenDevice(2, gfx::Size(9999, 888), true)); | 140 "", gfx::Size(1920, 1080))); |
| 141 devices.push_back(ui::TouchscreenDevice(2, ui::InputDeviceType::INTERNAL, |
| 142 "", gfx::Size(9999, 888))); |
| 132 | 143 |
| 133 AssociateTouchscreens(&displays_, devices); | 144 AssociateTouchscreens(&displays_, devices); |
| 134 | 145 |
| 135 // Internal touchscreen is always mapped to internal display. | 146 // Internal touchscreen is always mapped to internal display. |
| 136 EXPECT_EQ(2, displays_[0].touch_device_id()); | 147 EXPECT_EQ(2, displays_[0].touch_device_id()); |
| 137 EXPECT_EQ(1, displays_[1].touch_device_id()); | 148 EXPECT_EQ(1, displays_[1].touch_device_id()); |
| 138 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); | 149 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); |
| 139 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[3].touch_device_id()); | 150 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[3].touch_device_id()); |
| 140 } | 151 } |
| 141 | 152 |
| 142 } // namespace ash | 153 } // namespace ash |
| OLD | NEW |