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 #import "ui/events/test/cocoa_test_event_utils.h" | 5 #import "ui/events/test/cocoa_test_event_utils.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/mac/scoped_cftyperef.h" | 9 #include "base/mac/scoped_cftyperef.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 int32_t wheel1 = static_cast<int>(delta_y); | 146 int32_t wheel1 = static_cast<int>(delta_y); |
147 int32_t wheel2 = static_cast<int>(delta_x); | 147 int32_t wheel2 = static_cast<int>(delta_x); |
148 CGScrollEventUnit units = | 148 CGScrollEventUnit units = |
149 has_precise_deltas ? kCGScrollEventUnitPixel : kCGScrollEventUnitLine; | 149 has_precise_deltas ? kCGScrollEventUnitPixel : kCGScrollEventUnitLine; |
150 base::ScopedCFTypeRef<CGEventRef> scroll(CGEventCreateScrollWheelEvent( | 150 base::ScopedCFTypeRef<CGEventRef> scroll(CGEventCreateScrollWheelEvent( |
151 nullptr, units, wheel_count, wheel1, wheel2)); | 151 nullptr, units, wheel_count, wheel1, wheel2)); |
152 CGEventSetLocation(scroll, ScreenPointFromWindow(window_point, window)); | 152 CGEventSetLocation(scroll, ScreenPointFromWindow(window_point, window)); |
153 | 153 |
154 // Always set event flags, otherwise +[NSEvent eventWithCGEvent:] populates | 154 // Always set event flags, otherwise +[NSEvent eventWithCGEvent:] populates |
155 // flags from current keyboard state which can make tests flaky. | 155 // flags from current keyboard state which can make tests flaky. |
156 CGEventSetFlags(scroll, 0); | 156 CGEventSetFlags(scroll, static_cast<CGEventFlags>(0)); |
157 | 157 |
158 if (has_precise_deltas) { | 158 if (has_precise_deltas) { |
159 // kCGScrollWheelEventIsContinuous is -[NSEvent hasPreciseScrollingDeltas]. | 159 // kCGScrollWheelEventIsContinuous is -[NSEvent hasPreciseScrollingDeltas]. |
160 // CGEventTypes.h says it should be non-zero for pixel-based scrolling. | 160 // CGEventTypes.h says it should be non-zero for pixel-based scrolling. |
161 // Verify that CGEventCreateScrollWheelEvent() set it. | 161 // Verify that CGEventCreateScrollWheelEvent() set it. |
162 DCHECK_EQ(1, CGEventGetIntegerValueField(scroll, | 162 DCHECK_EQ(1, CGEventGetIntegerValueField(scroll, |
163 kCGScrollWheelEventIsContinuous)); | 163 kCGScrollWheelEventIsContinuous)); |
164 } | 164 } |
165 | 165 |
166 // Don't set phase information when neither. | 166 // Don't set phase information when neither. |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 context:nil | 353 context:nil |
354 characters:characters | 354 characters:characters |
355 charactersIgnoringModifiers:charactersIgnoringModifiers | 355 charactersIgnoringModifiers:charactersIgnoringModifiers |
356 isARepeat:NO | 356 isARepeat:NO |
357 keyCode:(unsigned short)macKeycode]; | 357 keyCode:(unsigned short)macKeycode]; |
358 | 358 |
359 return event; | 359 return event; |
360 } | 360 } |
361 | 361 |
362 } // namespace cocoa_test_event_utils | 362 } // namespace cocoa_test_event_utils |
OLD | NEW |