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

Unified Diff: ui/events/test/cocoa_test_event_utils.h

Issue 2226933004: Mac: Share kScrollbarPixelsPerCocoaTick between ui:: and blink:: events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unconsolidate! NSApp sendEvent is too magical Created 4 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
Index: ui/events/test/cocoa_test_event_utils.h
diff --git a/ui/events/test/cocoa_test_event_utils.h b/ui/events/test/cocoa_test_event_utils.h
index 0b9992c2ab84d9f433bd2ffe10c99acf4e7c1582..5e138878f7de54ce3bf64e6b6a499f5c0314408b 100644
--- a/ui/events/test/cocoa_test_event_utils.h
+++ b/ui/events/test/cocoa_test_event_utils.h
@@ -15,6 +15,15 @@
namespace cocoa_test_event_utils {
+// Converts |window_point| in |window| coordinates (origin at bottom left of
+// window frame) to a point in global display coordinates for a CGEvent (origin
+// at top left of primary screen).
+CGPoint ScreenPointFromWindow(NSPoint window_point, NSWindow* window);
+
+// Converts |event| to an NSEvent with a timestamp from ui::EventTimeForNow(),
+// and attaches |window| to it.
+NSEvent* AttachWindowToCGEvent(CGEventRef event, NSWindow* window);
+
// Create synthetic mouse events for testing. Currently these are very
// basic, flesh out as needed. Points are all in window coordinates;
// where the window is not specified, coordinate system is undefined
@@ -41,6 +50,16 @@ std::pair<NSEvent*, NSEvent*> MouseClickInView(NSView* view,
std::pair<NSEvent*, NSEvent*> RightMouseClickInView(NSView* view,
NSUInteger clickCount);
+// Creates a test scroll event. Currently only events for a "real" mouse wheel
+// are supported (-hasPreciseScrollingDeltas is NO). If |window| is nil,
+// |location| is assumed to be AppKit screen coordinates (origin in bottom left
+// of primary screen).
+// TODO(tapted): Add event phase arguments to support trackpad scrolls also.
+NSEvent* TestScrollEvent(NSPoint location,
+ NSWindow* window,
+ CGFloat delta_x,
+ CGFloat delta_y);
+
// Returns a key event with the given character.
NSEvent* KeyEventWithCharacter(unichar c);

Powered by Google App Engine
This is Rietveld 408576698