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

Side by Side Diff: ash/touch/touchscreen_util_unittest.cc

Issue 845413002: touch: Change how touch-screen capability is processed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 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 <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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 std::vector<ui::TouchscreenDevice> devices; 71 std::vector<ui::TouchscreenDevice> devices;
72 AssociateTouchscreens(&displays_, devices); 72 AssociateTouchscreens(&displays_, devices);
73 73
74 for (size_t i = 0; i < displays_.size(); ++i) 74 for (size_t i = 0; i < displays_.size(); ++i)
75 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, 75 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId,
76 displays_[i].touch_device_id()); 76 displays_[i].touch_device_id());
77 } 77 }
78 78
79 TEST_F(TouchscreenUtilTest, OneToOneMapping) { 79 TEST_F(TouchscreenUtilTest, OneToOneMapping) {
80 std::vector<ui::TouchscreenDevice> devices; 80 std::vector<ui::TouchscreenDevice> devices;
81 devices.push_back(ui::TouchscreenDevice( 81 devices.push_back(
82 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "", gfx::Size(800, 600))); 82 ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "",
83 devices.push_back(ui::TouchscreenDevice( 83 gfx::Size(800, 600), 0));
84 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "", gfx::Size(1024, 768))); 84 devices.push_back(
85 ui::TouchscreenDevice(2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "",
86 gfx::Size(1024, 768), 0));
85 87
86 AssociateTouchscreens(&displays_, devices); 88 AssociateTouchscreens(&displays_, devices);
87 89
88 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id()); 90 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id());
89 EXPECT_EQ(1u, displays_[1].touch_device_id()); 91 EXPECT_EQ(1u, displays_[1].touch_device_id());
90 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); 92 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id());
91 EXPECT_EQ(2u, displays_[3].touch_device_id()); 93 EXPECT_EQ(2u, displays_[3].touch_device_id());
92 } 94 }
93 95
94 TEST_F(TouchscreenUtilTest, MapToCorrectDisplaySize) { 96 TEST_F(TouchscreenUtilTest, MapToCorrectDisplaySize) {
95 std::vector<ui::TouchscreenDevice> devices; 97 std::vector<ui::TouchscreenDevice> devices;
96 devices.push_back(ui::TouchscreenDevice( 98 devices.push_back(
97 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "", gfx::Size(1024, 768))); 99 ui::TouchscreenDevice(2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "",
100 gfx::Size(1024, 768), 0));
98 101
99 AssociateTouchscreens(&displays_, devices); 102 AssociateTouchscreens(&displays_, devices);
100 103
101 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id()); 104 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id());
102 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[1].touch_device_id()); 105 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[1].touch_device_id());
103 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); 106 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id());
104 EXPECT_EQ(2u, displays_[3].touch_device_id()); 107 EXPECT_EQ(2u, displays_[3].touch_device_id());
105 } 108 }
106 109
107 TEST_F(TouchscreenUtilTest, MapWhenSizeDiffersByOne) { 110 TEST_F(TouchscreenUtilTest, MapWhenSizeDiffersByOne) {
108 std::vector<ui::TouchscreenDevice> devices; 111 std::vector<ui::TouchscreenDevice> devices;
109 devices.push_back(ui::TouchscreenDevice( 112 devices.push_back(
110 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "", gfx::Size(801, 600))); 113 ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "",
111 devices.push_back(ui::TouchscreenDevice( 114 gfx::Size(801, 600), 0));
112 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "", gfx::Size(1023, 768))); 115 devices.push_back(
116 ui::TouchscreenDevice(2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "",
117 gfx::Size(1023, 768), 0));
113 118
114 AssociateTouchscreens(&displays_, devices); 119 AssociateTouchscreens(&displays_, devices);
115 120
116 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id()); 121 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id());
117 EXPECT_EQ(1u, displays_[1].touch_device_id()); 122 EXPECT_EQ(1u, displays_[1].touch_device_id());
118 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); 123 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id());
119 EXPECT_EQ(2u, displays_[3].touch_device_id()); 124 EXPECT_EQ(2u, displays_[3].touch_device_id());
120 } 125 }
121 126
122 TEST_F(TouchscreenUtilTest, MapWhenSizesDoNotMatch) { 127 TEST_F(TouchscreenUtilTest, MapWhenSizesDoNotMatch) {
123 std::vector<ui::TouchscreenDevice> devices; 128 std::vector<ui::TouchscreenDevice> devices;
124 devices.push_back(ui::TouchscreenDevice( 129 devices.push_back(
125 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "", gfx::Size(1022, 768))); 130 ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "",
126 devices.push_back(ui::TouchscreenDevice( 131 gfx::Size(1022, 768), 0));
127 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "", gfx::Size(802, 600))); 132 devices.push_back(
133 ui::TouchscreenDevice(2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "",
134 gfx::Size(802, 600), 0));
128 135
129 AssociateTouchscreens(&displays_, devices); 136 AssociateTouchscreens(&displays_, devices);
130 137
131 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id()); 138 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id());
132 EXPECT_EQ(1u, displays_[1].touch_device_id()); 139 EXPECT_EQ(1u, displays_[1].touch_device_id());
133 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); 140 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id());
134 EXPECT_EQ(2u, displays_[3].touch_device_id()); 141 EXPECT_EQ(2u, displays_[3].touch_device_id());
135 } 142 }
136 143
137 TEST_F(TouchscreenUtilTest, MapInternalTouchscreen) { 144 TEST_F(TouchscreenUtilTest, MapInternalTouchscreen) {
138 std::vector<ui::TouchscreenDevice> devices; 145 std::vector<ui::TouchscreenDevice> devices;
139 devices.push_back( 146 devices.push_back(
140 ui::TouchscreenDevice(1, 147 ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "",
141 ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, 148 gfx::Size(1920, 1080), 0));
142 "", 149 devices.push_back(
143 gfx::Size(1920, 1080))); 150 ui::TouchscreenDevice(2, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "",
144 devices.push_back(ui::TouchscreenDevice( 151 gfx::Size(9999, 888), 0));
145 2, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "", gfx::Size(9999, 888)));
146 152
147 AssociateTouchscreens(&displays_, devices); 153 AssociateTouchscreens(&displays_, devices);
148 154
149 // Internal touchscreen is always mapped to internal display. 155 // Internal touchscreen is always mapped to internal display.
150 EXPECT_EQ(2u, displays_[0].touch_device_id()); 156 EXPECT_EQ(2u, displays_[0].touch_device_id());
151 EXPECT_EQ(1u, displays_[1].touch_device_id()); 157 EXPECT_EQ(1u, displays_[1].touch_device_id());
152 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); 158 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id());
153 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[3].touch_device_id()); 159 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[3].touch_device_id());
154 } 160 }
155 161
156 } // namespace ash 162 } // namespace ash
OLDNEW
« no previous file with comments | « ash/touch/touch_transformer_controller_unittest.cc ('k') | ash/virtual_keyboard_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698