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

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

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