Chrome Version : 56.0.2906.0
OS Version: OS X 10.12.1
AppKit provides limited methods for creating dummy NSEvent objects for testing. The third mouse button and trackpad scrolling events are particularly problematic.
cocoa_test_event_utils::TestScrollEvent is evolving support for trackpad scroll event sequences. Currently used in:
events_mac_unittest -- EventsMacTest::TrackpadScrollSequence(), and
ui/views/test/event_generator_delegate_mac - used to make mousewheel scroll events
Some limitations of the current setup:
- Only event_generator_delegate_mac::MouseEventAtPoint has support for a middle click. (MouseEventAtPointInWindow will silently fail to create middle-click events -- these should use a common codepath; possibly:
- EventsMacTest::TestMouseEvent(), which creates events with both -[NSEvent window] and middle clicks, but it gets dispatched differently :/ -- see https://codereview.chromium.org/2484863004/
- A Mighty Mouse makes a special scroll sequence that we don't have tests for
- Making test NSEvents with +[NSEvent eventWithCGEvent:] requires a special dance, e.g., for coordinate conversion
- See https://codereview.chromium.org/2486643002/
- cocoa_test_event_utils.mm's `AttachWindowToCGEvent` uses KVO to set the -[NSEvent window] argument -- it "works" but it doesn't feel right. E.g. the events get dispatched differently if sending to NSApp (but they seem to go fine if they're dispatched directly to NSWindow).
Comment 1 by sheriffbot@chromium.org
, Nov 9 2017Status: Untriaged (was: Available)