| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <cstring> | 5 #include <cstring> |
| 6 | 6 |
| 7 #include <X11/extensions/XInput2.h> | 7 #include <X11/extensions/XInput2.h> |
| 8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
| 9 | 9 |
| 10 // Generically-named #defines from Xlib that conflict with symbols in GTest. | 10 // Generically-named #defines from Xlib that conflict with symbols in GTest. |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 EXPECT_LT(offset.y(), 0); | 82 EXPECT_LT(offset.y(), 0); |
| 83 EXPECT_EQ(0, offset.x()); | 83 EXPECT_EQ(0, offset.x()); |
| 84 | 84 |
| 85 // Scroll left. | 85 // Scroll left. |
| 86 InitButtonEvent(&event, true, location, 6, 0); | 86 InitButtonEvent(&event, true, location, 6, 0); |
| 87 EXPECT_EQ(ui::ET_MOUSEWHEEL, ui::EventTypeFromNative(&event)); | 87 EXPECT_EQ(ui::ET_MOUSEWHEEL, ui::EventTypeFromNative(&event)); |
| 88 EXPECT_EQ(0, ui::EventFlagsFromNative(&event)); | 88 EXPECT_EQ(0, ui::EventFlagsFromNative(&event)); |
| 89 EXPECT_EQ(location, ui::EventLocationFromNative(&event)); | 89 EXPECT_EQ(location, ui::EventLocationFromNative(&event)); |
| 90 offset = ui::GetMouseWheelOffset(&event); | 90 offset = ui::GetMouseWheelOffset(&event); |
| 91 EXPECT_EQ(0, offset.y()); | 91 EXPECT_EQ(0, offset.y()); |
| 92 EXPECT_LT(offset.x(), 0); | 92 EXPECT_GT(offset.x(), 0); |
| 93 | 93 |
| 94 // Scroll right. | 94 // Scroll right. |
| 95 InitButtonEvent(&event, true, location, 7, 0); | 95 InitButtonEvent(&event, true, location, 7, 0); |
| 96 EXPECT_EQ(ui::ET_MOUSEWHEEL, ui::EventTypeFromNative(&event)); | 96 EXPECT_EQ(ui::ET_MOUSEWHEEL, ui::EventTypeFromNative(&event)); |
| 97 EXPECT_EQ(0, ui::EventFlagsFromNative(&event)); | 97 EXPECT_EQ(0, ui::EventFlagsFromNative(&event)); |
| 98 EXPECT_EQ(location, ui::EventLocationFromNative(&event)); | 98 EXPECT_EQ(location, ui::EventLocationFromNative(&event)); |
| 99 offset = ui::GetMouseWheelOffset(&event); | 99 offset = ui::GetMouseWheelOffset(&event); |
| 100 EXPECT_EQ(0, offset.y()); | 100 EXPECT_EQ(0, offset.y()); |
| 101 EXPECT_GT(offset.x(), 0); | 101 EXPECT_LT(offset.x(), 0); |
| 102 | 102 |
| 103 // TODO(derat): Test XInput code. | 103 // TODO(derat): Test XInput code. |
| 104 } | 104 } |
| 105 | 105 |
| 106 TEST(EventsXTest, AvoidExtraEventsOnWheelRelease) { | 106 TEST(EventsXTest, AvoidExtraEventsOnWheelRelease) { |
| 107 XEvent event; | 107 XEvent event; |
| 108 gfx::Point location(5, 10); | 108 gfx::Point location(5, 10); |
| 109 | 109 |
| 110 InitButtonEvent(&event, true, location, 4, 0); | 110 InitButtonEvent(&event, true, location, 4, 0); |
| 111 EXPECT_EQ(ui::ET_MOUSEWHEEL, ui::EventTypeFromNative(&event)); | 111 EXPECT_EQ(ui::ET_MOUSEWHEEL, ui::EventTypeFromNative(&event)); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 0, XI_TouchEnd, 6, gfx::Point(200, 200), valuators); | 232 0, XI_TouchEnd, 6, gfx::Point(200, 200), valuators); |
| 233 EXPECT_EQ(ui::ET_TOUCH_RELEASED, ui::EventTypeFromNative(scoped_xevent)); | 233 EXPECT_EQ(ui::ET_TOUCH_RELEASED, ui::EventTypeFromNative(scoped_xevent)); |
| 234 EXPECT_EQ("200,200", ui::EventLocationFromNative(scoped_xevent).ToString()); | 234 EXPECT_EQ("200,200", ui::EventLocationFromNative(scoped_xevent).ToString()); |
| 235 EXPECT_EQ(GetTouchId(scoped_xevent), 1); | 235 EXPECT_EQ(GetTouchId(scoped_xevent), 1); |
| 236 EXPECT_EQ(GetTouchRadiusX(scoped_xevent), 25); | 236 EXPECT_EQ(GetTouchRadiusX(scoped_xevent), 25); |
| 237 EXPECT_FLOAT_EQ(GetTouchAngle(scoped_xevent), 0.45f); | 237 EXPECT_FLOAT_EQ(GetTouchAngle(scoped_xevent), 0.45f); |
| 238 EXPECT_FLOAT_EQ(GetTouchForce(scoped_xevent), 0.5f); | 238 EXPECT_FLOAT_EQ(GetTouchForce(scoped_xevent), 0.5f); |
| 239 } | 239 } |
| 240 #endif | 240 #endif |
| 241 } // namespace ui | 241 } // namespace ui |
| OLD | NEW |