Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(286)

Side by Side Diff: ui/events/test/cocoa_test_event_utils.h

Issue 345243007: Add ScopedObjCClassSwizzler in base/mac, absorbs objc_method_swizzle and ScopedClassSwizzler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Inlude in shiny new gn base_unittests target Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/events/cocoa/events_mac_unittest.mm ('k') | ui/events/test/cocoa_test_event_utils.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef UI_EVENTS_TEST_COCOA_TEST_EVENT_UTILS_H_ 5 #ifndef UI_EVENTS_TEST_COCOA_TEST_EVENT_UTILS_H_
6 #define UI_EVENTS_TEST_COCOA_TEST_EVENT_UTILS_H_ 6 #define UI_EVENTS_TEST_COCOA_TEST_EVENT_UTILS_H_
7 7
8 #include <utility> 8 #include <utility>
9 9
10 #import <objc/objc-class.h> 10 #import <objc/objc-class.h>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 13
14 // Within a given scope, replace the selector |selector| on |target| with that
15 // from |source|.
16 class ScopedClassSwizzler {
17 public:
18 ScopedClassSwizzler(Class target, Class source, SEL selector);
19 ~ScopedClassSwizzler();
20
21 private:
22 Method old_selector_impl_;
23 Method new_selector_impl_;
24
25 DISALLOW_COPY_AND_ASSIGN(ScopedClassSwizzler);
26 };
27
28 namespace cocoa_test_event_utils { 14 namespace cocoa_test_event_utils {
29 15
30 // Create synthetic mouse events for testing. Currently these are very 16 // Create synthetic mouse events for testing. Currently these are very
31 // basic, flesh out as needed. Points are all in window coordinates; 17 // basic, flesh out as needed. Points are all in window coordinates;
32 // where the window is not specified, coordinate system is undefined 18 // where the window is not specified, coordinate system is undefined
33 // (but will be repeated when the event is queried). 19 // (but will be repeated when the event is queried).
34 NSEvent* MouseEventWithType(NSEventType type, NSUInteger modifiers); 20 NSEvent* MouseEventWithType(NSEventType type, NSUInteger modifiers);
35 NSEvent* MouseEventAtPoint(NSPoint point, NSEventType type, 21 NSEvent* MouseEventAtPoint(NSPoint point, NSEventType type,
36 NSUInteger modifiers); 22 NSUInteger modifiers);
37 NSEvent* LeftMouseDownAtPoint(NSPoint point); 23 NSEvent* LeftMouseDownAtPoint(NSPoint point);
(...skipping 20 matching lines...) Expand all
58 44
59 // Returns a mouse enter/exit event with the given type. 45 // Returns a mouse enter/exit event with the given type.
60 NSEvent* EnterExitEventWithType(NSEventType event_type); 46 NSEvent* EnterExitEventWithType(NSEventType event_type);
61 47
62 // Return an "other" event with the given type. 48 // Return an "other" event with the given type.
63 NSEvent* OtherEventWithType(NSEventType event_type); 49 NSEvent* OtherEventWithType(NSEventType event_type);
64 50
65 } // namespace cocoa_test_event_utils 51 } // namespace cocoa_test_event_utils
66 52
67 #endif // UI_EVENTS_TEST_COCOA_TEST_EVENT_UTILS_H_ 53 #endif // UI_EVENTS_TEST_COCOA_TEST_EVENT_UTILS_H_
OLDNEW
« no previous file with comments | « ui/events/cocoa/events_mac_unittest.mm ('k') | ui/events/test/cocoa_test_event_utils.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698