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 <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "ash/display/display_info.h" | 8 #include "ash/display/display_info.h" |
9 #include "ash/touch/touchscreen_util.h" | 9 #include "ash/touch/touchscreen_util.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 TEST_F(TouchscreenUtilTest, OneToOneMapping) { | 77 TEST_F(TouchscreenUtilTest, OneToOneMapping) { |
78 std::vector<ui::TouchscreenDevice> devices; | 78 std::vector<ui::TouchscreenDevice> devices; |
79 devices.push_back(ui::TouchscreenDevice( | 79 devices.push_back(ui::TouchscreenDevice( |
80 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(800, 600), 0)); | 80 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(800, 600), 0)); |
81 devices.push_back(ui::TouchscreenDevice( | 81 devices.push_back(ui::TouchscreenDevice( |
82 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(1024, 768), 0)); | 82 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(1024, 768), 0)); |
83 | 83 |
84 AssociateTouchscreens(&displays_, devices); | 84 AssociateTouchscreens(&displays_, devices); |
85 | 85 |
86 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id()); | 86 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id()); |
87 EXPECT_EQ(1u, displays_[1].touch_device_id()); | 87 EXPECT_EQ(1, displays_[1].touch_device_id()); |
88 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); | 88 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); |
89 EXPECT_EQ(2u, displays_[3].touch_device_id()); | 89 EXPECT_EQ(2, displays_[3].touch_device_id()); |
90 } | 90 } |
91 | 91 |
92 TEST_F(TouchscreenUtilTest, MapToCorrectDisplaySize) { | 92 TEST_F(TouchscreenUtilTest, MapToCorrectDisplaySize) { |
93 std::vector<ui::TouchscreenDevice> devices; | 93 std::vector<ui::TouchscreenDevice> devices; |
94 devices.push_back(ui::TouchscreenDevice( | 94 devices.push_back(ui::TouchscreenDevice( |
95 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(1024, 768), 0)); | 95 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(1024, 768), 0)); |
96 | 96 |
97 AssociateTouchscreens(&displays_, devices); | 97 AssociateTouchscreens(&displays_, devices); |
98 | 98 |
99 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id()); | 99 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id()); |
100 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[1].touch_device_id()); | 100 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[1].touch_device_id()); |
101 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); | 101 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); |
102 EXPECT_EQ(2u, displays_[3].touch_device_id()); | 102 EXPECT_EQ(2, displays_[3].touch_device_id()); |
103 } | 103 } |
104 | 104 |
105 TEST_F(TouchscreenUtilTest, MapWhenSizeDiffersByOne) { | 105 TEST_F(TouchscreenUtilTest, MapWhenSizeDiffersByOne) { |
106 std::vector<ui::TouchscreenDevice> devices; | 106 std::vector<ui::TouchscreenDevice> devices; |
107 devices.push_back(ui::TouchscreenDevice( | 107 devices.push_back(ui::TouchscreenDevice( |
108 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(801, 600), 0)); | 108 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(801, 600), 0)); |
109 devices.push_back(ui::TouchscreenDevice( | 109 devices.push_back(ui::TouchscreenDevice( |
110 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(1023, 768), 0)); | 110 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(1023, 768), 0)); |
111 | 111 |
112 AssociateTouchscreens(&displays_, devices); | 112 AssociateTouchscreens(&displays_, devices); |
113 | 113 |
114 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id()); | 114 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id()); |
115 EXPECT_EQ(1u, displays_[1].touch_device_id()); | 115 EXPECT_EQ(1, displays_[1].touch_device_id()); |
116 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); | 116 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); |
117 EXPECT_EQ(2u, displays_[3].touch_device_id()); | 117 EXPECT_EQ(2, displays_[3].touch_device_id()); |
118 } | 118 } |
119 | 119 |
120 TEST_F(TouchscreenUtilTest, MapWhenSizesDoNotMatch) { | 120 TEST_F(TouchscreenUtilTest, MapWhenSizesDoNotMatch) { |
121 std::vector<ui::TouchscreenDevice> devices; | 121 std::vector<ui::TouchscreenDevice> devices; |
122 devices.push_back(ui::TouchscreenDevice( | 122 devices.push_back(ui::TouchscreenDevice( |
123 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(1022, 768), 0)); | 123 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(1022, 768), 0)); |
124 devices.push_back(ui::TouchscreenDevice( | 124 devices.push_back(ui::TouchscreenDevice( |
125 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(802, 600), 0)); | 125 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(802, 600), 0)); |
126 | 126 |
127 AssociateTouchscreens(&displays_, devices); | 127 AssociateTouchscreens(&displays_, devices); |
128 | 128 |
129 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id()); | 129 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id()); |
130 EXPECT_EQ(1u, displays_[1].touch_device_id()); | 130 EXPECT_EQ(1, displays_[1].touch_device_id()); |
131 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); | 131 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); |
132 EXPECT_EQ(2u, displays_[3].touch_device_id()); | 132 EXPECT_EQ(2, displays_[3].touch_device_id()); |
133 } | 133 } |
134 | 134 |
135 TEST_F(TouchscreenUtilTest, MapInternalTouchscreen) { | 135 TEST_F(TouchscreenUtilTest, MapInternalTouchscreen) { |
136 std::vector<ui::TouchscreenDevice> devices; | 136 std::vector<ui::TouchscreenDevice> devices; |
137 devices.push_back(ui::TouchscreenDevice( | 137 devices.push_back(ui::TouchscreenDevice( |
138 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(1920, 1080), 0)); | 138 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(1920, 1080), 0)); |
139 devices.push_back(ui::TouchscreenDevice( | 139 devices.push_back(ui::TouchscreenDevice( |
140 2, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, gfx::Size(9999, 888), 0)); | 140 2, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, gfx::Size(9999, 888), 0)); |
141 | 141 |
142 AssociateTouchscreens(&displays_, devices); | 142 AssociateTouchscreens(&displays_, devices); |
143 | 143 |
144 // Internal touchscreen is always mapped to internal display. | 144 // Internal touchscreen is always mapped to internal display. |
145 EXPECT_EQ(2u, displays_[0].touch_device_id()); | 145 EXPECT_EQ(2, displays_[0].touch_device_id()); |
146 EXPECT_EQ(1u, displays_[1].touch_device_id()); | 146 EXPECT_EQ(1, displays_[1].touch_device_id()); |
147 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); | 147 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); |
148 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[3].touch_device_id()); | 148 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[3].touch_device_id()); |
149 } | 149 } |
150 | 150 |
151 } // namespace ash | 151 } // namespace ash |
OLD | NEW |