| 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 #include "ui/events/event_utils.h" | 5 #include "ui/events/event_utils.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include "base/mac/scoped_cftyperef.h" | 9 #include "base/mac/scoped_cftyperef.h" |
| 10 #import "base/mac/scoped_objc_class_swizzler.h" | 10 #import "base/mac/scoped_objc_class_swizzler.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 2, | 102 2, |
| 103 delta_y, | 103 delta_y, |
| 104 delta_x)); | 104 delta_x)); |
| 105 // CGEvents are always in global display coordinates. These are like screen | 105 // CGEvents are always in global display coordinates. These are like screen |
| 106 // coordinates, but flipped. But first the point needs to be converted out | 106 // coordinates, but flipped. But first the point needs to be converted out |
| 107 // of window coordinates (which also requires flipping). | 107 // of window coordinates (which also requires flipping). |
| 108 NSPoint window_point = | 108 NSPoint window_point = |
| 109 NSPointFromCGPoint(Flip(window_location).ToCGPoint()); | 109 NSPointFromCGPoint(Flip(window_location).ToCGPoint()); |
| 110 NSPoint screen_point = [test_window() convertBaseToScreen:window_point]; | 110 NSPoint screen_point = [test_window() convertBaseToScreen:window_point]; |
| 111 CGFloat primary_screen_height = | 111 CGFloat primary_screen_height = |
| 112 NSHeight([[[NSScreen screens] objectAtIndex:0] frame]); | 112 NSHeight([[[NSScreen screens] firstObject] frame]); |
| 113 screen_point.y = primary_screen_height - screen_point.y; | 113 screen_point.y = primary_screen_height - screen_point.y; |
| 114 CGEventSetLocation(scroll, NSPointToCGPoint(screen_point)); | 114 CGEventSetLocation(scroll, NSPointToCGPoint(screen_point)); |
| 115 return [NSEvent eventWithCGEvent:scroll]; | 115 return [NSEvent eventWithCGEvent:scroll]; |
| 116 } | 116 } |
| 117 | 117 |
| 118 private: | 118 private: |
| 119 scoped_ptr<base::mac::ScopedObjCClassSwizzler> swizzler_; | 119 scoped_ptr<base::mac::ScopedObjCClassSwizzler> swizzler_; |
| 120 | 120 |
| 121 DISALLOW_COPY_AND_ASSIGN(EventsMacTest); | 121 DISALLOW_COPY_AND_ASSIGN(EventsMacTest); |
| 122 }; | 122 }; |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 event = cocoa_test_event_utils::MouseEventWithType(NSMouseMoved, 0); | 305 event = cocoa_test_event_utils::MouseEventWithType(NSMouseMoved, 0); |
| 306 EXPECT_EQ(ui::ET_MOUSE_MOVED, ui::EventTypeFromNative(event)); | 306 EXPECT_EQ(ui::ET_MOUSE_MOVED, ui::EventTypeFromNative(event)); |
| 307 | 307 |
| 308 event = cocoa_test_event_utils::EnterExitEventWithType(NSMouseEntered); | 308 event = cocoa_test_event_utils::EnterExitEventWithType(NSMouseEntered); |
| 309 EXPECT_EQ(ui::ET_MOUSE_ENTERED, ui::EventTypeFromNative(event)); | 309 EXPECT_EQ(ui::ET_MOUSE_ENTERED, ui::EventTypeFromNative(event)); |
| 310 event = cocoa_test_event_utils::EnterExitEventWithType(NSMouseExited); | 310 event = cocoa_test_event_utils::EnterExitEventWithType(NSMouseExited); |
| 311 EXPECT_EQ(ui::ET_MOUSE_EXITED, ui::EventTypeFromNative(event)); | 311 EXPECT_EQ(ui::ET_MOUSE_EXITED, ui::EventTypeFromNative(event)); |
| 312 } | 312 } |
| 313 | 313 |
| 314 } // namespace ui | 314 } // namespace ui |
| OLD | NEW |