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

Side by Side Diff: chrome/browser/cocoa/test_event_utils.mm

Issue 173044: This changelist represents the necessary merger of two others:... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 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 | « chrome/browser/cocoa/test_event_utils.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import <Cocoa/Cocoa.h>
6
7 #include "chrome/browser/cocoa/test_event_utils.h"
8
9 ScopedClassSwizzler::ScopedClassSwizzler(Class target, Class source,
10 SEL selector) {
11 old_selector_impl_ = class_getInstanceMethod(target, selector);
12 new_selector_impl_ = class_getInstanceMethod(source, selector);
13 method_exchangeImplementations(old_selector_impl_, new_selector_impl_);
14 }
15
16 ScopedClassSwizzler::~ScopedClassSwizzler() {
17 method_exchangeImplementations(old_selector_impl_, new_selector_impl_);
18 }
19
20 namespace test_event_utils {
21
22 NSEvent* MakeMouseEvent(NSEventType type, NSUInteger modifiers) {
23 if (type == NSOtherMouseUp) {
24 // To synthesize middle clicks we need to create a CGEvent with the
25 // "center" button flags so that our resulting NSEvent will have the
26 // appropriate buttonNumber field. NSEvent provides no way to create a
27 // mouse event with a buttonNumber directly.
28 CGPoint location = { 0, 0 };
29 CGEventRef event = CGEventCreateMouseEvent(NULL, kCGEventOtherMouseUp,
30 location,
31 kCGMouseButtonCenter);
32 return [NSEvent eventWithCGEvent:event];
33 }
34 return [NSEvent mouseEventWithType:type
35 location:NSMakePoint(0, 0)
36 modifierFlags:modifiers
37 timestamp:0
38 windowNumber:0
39 context:nil
40 eventNumber:0
41 clickCount:1
42 pressure:1.0];
43 }
44
45 } // namespace test_event_utils
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/test_event_utils.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698