OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 | 5 |
6 #include "base/sys_info.h" | 6 #include "base/sys_info.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "ui/aura/test/aura_test_base.h" | 8 #include "ui/aura/test/aura_test_base.h" |
9 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
10 #include "ui/aura/window_event_dispatcher.h" | 10 #include "ui/aura/window_event_dispatcher.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 ui::ScopedXI2Event scoped_xevent; | 159 ui::ScopedXI2Event scoped_xevent; |
160 scoped_xevent.InitTouchEvent( | 160 scoped_xevent.InitTouchEvent( |
161 0, XI_TouchBegin, 5, gfx::Point(1500, 2500), valuators); | 161 0, XI_TouchBegin, 5, gfx::Point(1500, 2500), valuators); |
162 window_tree_host1->Dispatch(scoped_xevent); | 162 window_tree_host1->Dispatch(scoped_xevent); |
163 window_tree_host2->Dispatch(scoped_xevent); | 163 window_tree_host2->Dispatch(scoped_xevent); |
164 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); | 164 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); |
165 EXPECT_EQ(-1, handler1->last_touch_id()); | 165 EXPECT_EQ(-1, handler1->last_touch_id()); |
166 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); | 166 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); |
167 EXPECT_EQ(ui::ET_TOUCH_PRESSED, handler2->last_touch_type()); | 167 EXPECT_EQ(ui::ET_TOUCH_PRESSED, handler2->last_touch_type()); |
168 EXPECT_EQ(0, handler2->last_touch_id()); | 168 EXPECT_EQ(0, handler2->last_touch_id()); |
169 EXPECT_EQ(gfx::Point(1500, 2500 - host2_y_offset), | 169 EXPECT_EQ(gfx::Point(1500, 2500), handler2->last_touch_location()); |
170 handler2->last_touch_location()); | |
171 | 170 |
172 scoped_xevent.InitTouchEvent( | 171 scoped_xevent.InitTouchEvent( |
173 0, XI_TouchBegin, 6, gfx::Point(1600, 2600), valuators); | 172 0, XI_TouchBegin, 6, gfx::Point(1600, 2600), valuators); |
174 window_tree_host1->Dispatch(scoped_xevent); | 173 window_tree_host1->Dispatch(scoped_xevent); |
175 window_tree_host2->Dispatch(scoped_xevent); | 174 window_tree_host2->Dispatch(scoped_xevent); |
176 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); | 175 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); |
177 EXPECT_EQ(-1, handler1->last_touch_id()); | 176 EXPECT_EQ(-1, handler1->last_touch_id()); |
178 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); | 177 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); |
179 EXPECT_EQ(ui::ET_TOUCH_PRESSED, handler2->last_touch_type()); | 178 EXPECT_EQ(ui::ET_TOUCH_PRESSED, handler2->last_touch_type()); |
180 EXPECT_EQ(1, handler2->last_touch_id()); | 179 EXPECT_EQ(1, handler2->last_touch_id()); |
181 EXPECT_EQ(gfx::Point(1600, 2600 - host2_y_offset), | 180 EXPECT_EQ(gfx::Point(1600, 2600), handler2->last_touch_location()); |
182 handler2->last_touch_location()); | |
183 | 181 |
184 scoped_xevent.InitTouchEvent( | 182 scoped_xevent.InitTouchEvent( |
185 0, XI_TouchUpdate, 5, gfx::Point(1500, 2550), valuators); | 183 0, XI_TouchUpdate, 5, gfx::Point(1500, 2550), valuators); |
186 window_tree_host1->Dispatch(scoped_xevent); | 184 window_tree_host1->Dispatch(scoped_xevent); |
187 window_tree_host2->Dispatch(scoped_xevent); | 185 window_tree_host2->Dispatch(scoped_xevent); |
188 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); | 186 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); |
189 EXPECT_EQ(-1, handler1->last_touch_id()); | 187 EXPECT_EQ(-1, handler1->last_touch_id()); |
190 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); | 188 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); |
191 EXPECT_EQ(ui::ET_TOUCH_MOVED, handler2->last_touch_type()); | 189 EXPECT_EQ(ui::ET_TOUCH_MOVED, handler2->last_touch_type()); |
192 EXPECT_EQ(0, handler2->last_touch_id()); | 190 EXPECT_EQ(0, handler2->last_touch_id()); |
193 EXPECT_EQ(gfx::Point(1500, 2550 - host2_y_offset), | 191 EXPECT_EQ(gfx::Point(1500, 2550), handler2->last_touch_location()); |
194 handler2->last_touch_location()); | |
195 | 192 |
196 scoped_xevent.InitTouchEvent( | 193 scoped_xevent.InitTouchEvent( |
197 0, XI_TouchUpdate, 6, gfx::Point(1600, 2650), valuators); | 194 0, XI_TouchUpdate, 6, gfx::Point(1600, 2650), valuators); |
198 window_tree_host1->Dispatch(scoped_xevent); | 195 window_tree_host1->Dispatch(scoped_xevent); |
199 window_tree_host2->Dispatch(scoped_xevent); | 196 window_tree_host2->Dispatch(scoped_xevent); |
200 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); | 197 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); |
201 EXPECT_EQ(-1, handler1->last_touch_id()); | 198 EXPECT_EQ(-1, handler1->last_touch_id()); |
202 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); | 199 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); |
203 EXPECT_EQ(ui::ET_TOUCH_MOVED, handler2->last_touch_type()); | 200 EXPECT_EQ(ui::ET_TOUCH_MOVED, handler2->last_touch_type()); |
204 EXPECT_EQ(1, handler2->last_touch_id()); | 201 EXPECT_EQ(1, handler2->last_touch_id()); |
205 EXPECT_EQ(gfx::Point(1600, 2650 - host2_y_offset), | 202 EXPECT_EQ(gfx::Point(1600, 2650), handler2->last_touch_location()); |
206 handler2->last_touch_location()); | |
207 | 203 |
208 scoped_xevent.InitTouchEvent( | 204 scoped_xevent.InitTouchEvent( |
209 0, XI_TouchEnd, 5, gfx::Point(1500, 2550), valuators); | 205 0, XI_TouchEnd, 5, gfx::Point(1500, 2550), valuators); |
210 window_tree_host1->Dispatch(scoped_xevent); | 206 window_tree_host1->Dispatch(scoped_xevent); |
211 window_tree_host2->Dispatch(scoped_xevent); | 207 window_tree_host2->Dispatch(scoped_xevent); |
212 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); | 208 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); |
213 EXPECT_EQ(-1, handler1->last_touch_id()); | 209 EXPECT_EQ(-1, handler1->last_touch_id()); |
214 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); | 210 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); |
215 EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler2->last_touch_type()); | 211 EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler2->last_touch_type()); |
216 EXPECT_EQ(0, handler2->last_touch_id()); | 212 EXPECT_EQ(0, handler2->last_touch_id()); |
217 EXPECT_EQ(gfx::Point(1500, 2550 - host2_y_offset), | 213 EXPECT_EQ(gfx::Point(1500, 2550), handler2->last_touch_location()); |
218 handler2->last_touch_location()); | |
219 | 214 |
220 scoped_xevent.InitTouchEvent( | 215 scoped_xevent.InitTouchEvent( |
221 0, XI_TouchEnd, 6, gfx::Point(1600, 2650), valuators); | 216 0, XI_TouchEnd, 6, gfx::Point(1600, 2650), valuators); |
222 window_tree_host1->Dispatch(scoped_xevent); | 217 window_tree_host1->Dispatch(scoped_xevent); |
223 window_tree_host2->Dispatch(scoped_xevent); | 218 window_tree_host2->Dispatch(scoped_xevent); |
224 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); | 219 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); |
225 EXPECT_EQ(-1, handler1->last_touch_id()); | 220 EXPECT_EQ(-1, handler1->last_touch_id()); |
226 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); | 221 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); |
227 EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler2->last_touch_type()); | 222 EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler2->last_touch_type()); |
228 EXPECT_EQ(1, handler2->last_touch_id()); | 223 EXPECT_EQ(1, handler2->last_touch_id()); |
229 EXPECT_EQ(gfx::Point(1600, 2650 - host2_y_offset), | 224 EXPECT_EQ(gfx::Point(1600, 2650), handler2->last_touch_location()); |
230 handler2->last_touch_location()); | |
231 | 225 |
232 // Revert the CrOS testing env otherwise the following non-CrOS aura | 226 // Revert the CrOS testing env otherwise the following non-CrOS aura |
233 // tests will fail. | 227 // tests will fail. |
234 // Fake a ChromeOS running env. | 228 // Fake a ChromeOS running env. |
235 kLsbRelease = ""; | 229 kLsbRelease = ""; |
236 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); | 230 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); |
237 } | 231 } |
238 #endif // defined(OS_CHROMEOS) | 232 #endif // defined(OS_CHROMEOS) |
239 | 233 |
240 } // namespace aura | 234 } // namespace aura |
OLD | NEW |