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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/cocoa/test_event_utils.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/test_event_utils.mm
===================================================================
--- chrome/browser/cocoa/test_event_utils.mm (revision 0)
+++ chrome/browser/cocoa/test_event_utils.mm (revision 0)
@@ -0,0 +1,45 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import <Cocoa/Cocoa.h>
+
+#include "chrome/browser/cocoa/test_event_utils.h"
+
+ScopedClassSwizzler::ScopedClassSwizzler(Class target, Class source,
+ SEL selector) {
+ old_selector_impl_ = class_getInstanceMethod(target, selector);
+ new_selector_impl_ = class_getInstanceMethod(source, selector);
+ method_exchangeImplementations(old_selector_impl_, new_selector_impl_);
+}
+
+ScopedClassSwizzler::~ScopedClassSwizzler() {
+ method_exchangeImplementations(old_selector_impl_, new_selector_impl_);
+}
+
+namespace test_event_utils {
+
+NSEvent* MakeMouseEvent(NSEventType type, NSUInteger modifiers) {
+ if (type == NSOtherMouseUp) {
+ // To synthesize middle clicks we need to create a CGEvent with the
+ // "center" button flags so that our resulting NSEvent will have the
+ // appropriate buttonNumber field. NSEvent provides no way to create a
+ // mouse event with a buttonNumber directly.
+ CGPoint location = { 0, 0 };
+ CGEventRef event = CGEventCreateMouseEvent(NULL, kCGEventOtherMouseUp,
+ location,
+ kCGMouseButtonCenter);
+ return [NSEvent eventWithCGEvent:event];
+ }
+ return [NSEvent mouseEventWithType:type
+ location:NSMakePoint(0, 0)
+ modifierFlags:modifiers
+ timestamp:0
+ windowNumber:0
+ context:nil
+ eventNumber:0
+ clickCount:1
+ pressure:1.0];
+}
+
+} // namespace test_event_utils
« 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