| 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 <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "ui/events/test/cocoa_test_event_utils.h" | 7 #include "ui/events/test/cocoa_test_event_utils.h" |
| 8 | 8 |
| 9 ScopedClassSwizzler::ScopedClassSwizzler(Class target, Class source, | 9 ScopedClassSwizzler::ScopedClassSwizzler(Class target, Class source, |
| 10 SEL selector) { | 10 SEL selector) { |
| 11 old_selector_impl_ = class_getInstanceMethod(target, selector); | 11 old_selector_impl_ = class_getInstanceMethod(target, selector); |
| 12 new_selector_impl_ = class_getInstanceMethod(source, selector); | 12 new_selector_impl_ = class_getInstanceMethod(source, selector); |
| 13 if (!old_selector_impl_ && !new_selector_impl_) { |
| 14 // Try class methods. |
| 15 old_selector_impl_ = class_getClassMethod(target, selector); |
| 16 new_selector_impl_ = class_getClassMethod(source, selector); |
| 17 } |
| 13 method_exchangeImplementations(old_selector_impl_, new_selector_impl_); | 18 method_exchangeImplementations(old_selector_impl_, new_selector_impl_); |
| 14 } | 19 } |
| 15 | 20 |
| 16 ScopedClassSwizzler::~ScopedClassSwizzler() { | 21 ScopedClassSwizzler::~ScopedClassSwizzler() { |
| 17 method_exchangeImplementations(old_selector_impl_, new_selector_impl_); | 22 method_exchangeImplementations(old_selector_impl_, new_selector_impl_); |
| 18 } | 23 } |
| 19 | 24 |
| 20 namespace cocoa_test_event_utils { | 25 namespace cocoa_test_event_utils { |
| 21 | 26 |
| 22 NSEvent* MouseEventAtPoint(NSPoint point, NSEventType type, | 27 NSEvent* MouseEventAtPoint(NSPoint point, NSEventType type, |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 modifierFlags:0 | 142 modifierFlags:0 |
| 138 timestamp:0 | 143 timestamp:0 |
| 139 windowNumber:0 | 144 windowNumber:0 |
| 140 context:nil | 145 context:nil |
| 141 subtype:0 | 146 subtype:0 |
| 142 data1:0 | 147 data1:0 |
| 143 data2:0]; | 148 data2:0]; |
| 144 } | 149 } |
| 145 | 150 |
| 146 } // namespace cocoa_test_event_utils | 151 } // namespace cocoa_test_event_utils |
| OLD | NEW |