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

Issue 322893005: MacViews: Add WidgetEventGenerator to abstract platform-specific event generation for tests. (Closed)

Created:
6 years, 6 months ago by tapted
Modified:
6 years, 4 months ago
CC:
chromium-reviews, tfarina, ben+views_chromium.org, tdanderson+views_chromium.org, chrome-apps-syd-reviews_chromium.org, mac-views-reviews_chromium.org, scottmg, Dirk Pranke
Visibility:
Public.

Description

MacViews: Enhance aura's EventGenerator to abstract platform-specific event generation for tests. The focus of this CL is to get widget_unittest.cc compiling on MacViews. To achieve this, aura::test::EventGenerator is moved to ui/events/test and constructed with a delegate class that abstracts away the platform-specific event targeting and coordinate conversions. ui::test::EventGenerator::CreateDefaultPlatformDelegate(..) allows a default platform-specific EventGeneratorDelegate to be provided so that this detail is hidden from tests. On Mac, this delegate wraps a single NSWindow and targets NSEvents at that window. On Aura, the delegate is a thin wrapper to find and target events at an aura::Window, using the aura root window as the initial target. For Mac, NativeWidgetPrivate::IsMouseButtonDown and NSView mouse event handling in BridgedContentView is implemented to put the Mac event generator in context. Adds views_unittest WidgetTest.MouseEventTypesViaGenerator to ensure event generation is consistent across platforms (which currently passes on Mac). Allows an additional 67 tests to compile on Mac (49 pass). After this, widget_unittests.cc compiles on Mac. views_unittests has: Before: 358 tests run 10 tests failed 16 tests crashed. After: 425 tests run 24 tests failed 20 tests crashed. BUG=378134 TEST=views_unittests Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=283694

Patch Set 1 : rebase onto crrev/329743002 #

Patch Set 2 : cull orthogonal stuff, add WidgetTest.MouseEventTypesViaGenerator #

Total comments: 12

Patch Set 3 : respond to comments, fix aura #

Patch Set 4 : Rebase on crrev/334573008 #

Total comments: 4

Patch Set 5 : respond to comments: common EventGeneratorBase #

Patch Set 6 : rebase at r282511 #

Total comments: 5

Patch Set 7 : Move to events/test. ui:: stripping deferred. fix new win64 warnings (enabled in events) #

Total comments: 2

Patch Set 8 : rebase for r283070 conflict #

Patch Set 9 : self review + related fix for r283070 #

Total comments: 2

Patch Set 10 : just a rebase (views.gyp conflict and `context` now a NativeWindow) #

Patch Set 11 : No inheritance #

Total comments: 4

Patch Set 12 : -> event_generator_delegate_mac.mm, comment fixes #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+741 lines, -1109 lines) Patch
M ash/extended_desktop_unittest.cc View 1 2 3 4 5 6 2 chunks +4 lines, -4 lines 0 comments Download
M ash/test/ash_test_base.h View 1 2 3 4 5 6 7 8 9 10 3 chunks +8 lines, -6 lines 0 comments Download
M ash/test/ash_test_base.cc View 1 2 3 4 5 6 7 8 9 10 2 chunks +5 lines, -4 lines 0 comments Download
M chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc View 1 2 3 4 5 6 7 8 1 chunk +3 lines, -2 lines 0 comments Download
M ui/aura/test/event_generator.h View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +24 lines, -327 lines 0 comments Download
M ui/aura/test/event_generator.cc View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +48 lines, -589 lines 0 comments Download
M ui/events/events.gyp View 1 2 3 4 5 6 7 8 9 10 2 chunks +9 lines, -0 lines 0 comments Download
M ui/events/test/cocoa_test_event_utils.mm View 1 1 chunk +5 lines, -0 lines 0 comments Download
A + ui/events/test/event_generator.h View 1 2 3 4 5 6 7 8 9 10 11 12 chunks +66 lines, -56 lines 0 comments Download
A + ui/events/test/event_generator.cc View 1 2 3 4 5 6 7 8 9 10 16 chunks +35 lines, -83 lines 2 comments Download
M ui/views/cocoa/bridged_content_view.mm View 1 2 3 4 5 5 chunks +68 lines, -0 lines 0 comments Download
M ui/views/controls/button/menu_button_unittest.cc View 1 2 3 4 5 6 7 8 9 10 5 chunks +5 lines, -12 lines 0 comments Download
M ui/views/controls/slider_unittest.cc View 1 2 3 4 5 6 7 8 9 10 4 chunks +5 lines, -7 lines 0 comments Download
A ui/views/test/event_generator_delegate_mac.mm View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +341 lines, -0 lines 0 comments Download
M ui/views/views.gyp View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +2 lines, -2 lines 0 comments Download
M ui/views/widget/native_widget_mac.mm View 1 2 3 4 5 6 7 1 chunk +1 line, -2 lines 0 comments Download
M ui/views/widget/widget_unittest.cc View 1 2 3 4 5 6 7 8 9 10 9 chunks +112 lines, -15 lines 0 comments Download

Messages

Total messages: 28 (0 generated)
Andre
https://codereview.chromium.org/322893005/diff/80001/ui/views/test/widget_event_generator.h File ui/views/test/widget_event_generator.h (right): https://codereview.chromium.org/322893005/diff/80001/ui/views/test/widget_event_generator.h#newcode16 ui/views/test/widget_event_generator.h:16: #if defined(OS_MACOSX) The typedef below uses #elif, why is ...
6 years, 6 months ago (2014-06-17 21:17:57 UTC) #1
tapted
split off some stuff into http://crrev.com/334573008/ and http://crrev.com/346463003/. https://codereview.chromium.org/322893005/diff/80001/ui/views/test/widget_event_generator.h File ui/views/test/widget_event_generator.h (right): https://codereview.chromium.org/322893005/diff/80001/ui/views/test/widget_event_generator.h#newcode16 ui/views/test/widget_event_generator.h:16: #if ...
6 years, 6 months ago (2014-06-18 08:28:06 UTC) #2
tapted
Hi Scott and Robert - please take a look. Hopefully the idea here is not ...
6 years, 6 months ago (2014-06-18 08:38:27 UTC) #3
Robert Sesek
https://codereview.chromium.org/322893005/diff/200001/ui/views/test/widget_event_generator_mac.h File ui/views/test/widget_event_generator_mac.h (right): https://codereview.chromium.org/322893005/diff/200001/ui/views/test/widget_event_generator_mac.h#newcode23 ui/views/test/widget_event_generator_mac.h:23: class WidgetEventGeneratorMac { Could this be made an interface ...
6 years, 6 months ago (2014-06-18 16:43:02 UTC) #4
sky
sky->ben (to balance my load)
6 years, 6 months ago (2014-06-18 17:18:01 UTC) #5
tapted
https://codereview.chromium.org/322893005/diff/200001/ui/views/test/widget_event_generator_mac.h File ui/views/test/widget_event_generator_mac.h (right): https://codereview.chromium.org/322893005/diff/200001/ui/views/test/widget_event_generator_mac.h#newcode23 ui/views/test/widget_event_generator_mac.h:23: class WidgetEventGeneratorMac { On 2014/06/18 16:43:02, rsesek wrote: > ...
6 years, 6 months ago (2014-06-19 11:23:21 UTC) #6
Robert Sesek
cocoa bits LGTM
6 years, 6 months ago (2014-06-19 13:55:49 UTC) #7
Andre
lgtm
6 years, 6 months ago (2014-06-19 19:10:52 UTC) #8
tapted
ben (ping): PTAL for OWNERS when you get a chance
6 years, 6 months ago (2014-06-19 23:46:59 UTC) #9
tapted
ben: ping? (OWNERS)
6 years, 6 months ago (2014-06-23 22:08:08 UTC) #10
tapted
ben: hopeful ping?
6 years, 5 months ago (2014-07-09 22:45:27 UTC) #11
Ben Goodger (Google)
Hey sadrul check out my comment below. The app list guys want to use the ...
6 years, 5 months ago (2014-07-11 18:26:50 UTC) #12
sadrul
https://codereview.chromium.org/322893005/diff/280001/ui/aura/test/event_generator.h File ui/aura/test/event_generator.h (right): https://codereview.chromium.org/322893005/diff/280001/ui/aura/test/event_generator.h#newcode307 ui/aura/test/event_generator.h:307: WindowTreeHost* current_host_; On 2014/07/11 18:26:49, Ben Goodger (Google) wrote: ...
6 years, 5 months ago (2014-07-12 07:10:54 UTC) #13
tapted
wow - PTAL. I think this turned out pretty neat :) I fleshed out the ...
6 years, 5 months ago (2014-07-14 11:37:47 UTC) #14
tapted
https://codereview.chromium.org/322893005/diff/400001/ui/aura/test/event_generator.cc File ui/aura/test/event_generator.cc (right): https://codereview.chromium.org/322893005/diff/400001/ui/aura/test/event_generator.cc#newcode37 ui/aura/test/event_generator.cc:37: class TestKeyEvent : public ui::KeyEvent { oops - this ...
6 years, 5 months ago (2014-07-14 11:42:12 UTC) #15
tapted
(also rebased for a WidgetTest added in r283070 that used EventGenerator and would want a ...
6 years, 5 months ago (2014-07-15 12:43:27 UTC) #16
Ben Goodger (Google)
https://codereview.chromium.org/322893005/diff/480001/ui/views/test/widget_event_generator.h File ui/views/test/widget_event_generator.h (right): https://codereview.chromium.org/322893005/diff/480001/ui/views/test/widget_event_generator.h#newcode33 ui/views/test/widget_event_generator.h:33: class WidgetEventGenerator : public PlatformEventGenerator { Now that you've ...
6 years, 5 months ago (2014-07-15 16:22:20 UTC) #17
tapted
https://codereview.chromium.org/322893005/diff/480001/ui/views/test/widget_event_generator.h File ui/views/test/widget_event_generator.h (right): https://codereview.chromium.org/322893005/diff/480001/ui/views/test/widget_event_generator.h#newcode33 ui/views/test/widget_event_generator.h:33: class WidgetEventGenerator : public PlatformEventGenerator { On 2014/07/15 16:22:20, ...
6 years, 5 months ago (2014-07-16 07:56:07 UTC) #18
Ben Goodger (Google)
This is an awesome change and a huge improvement to EventGenerator. Thanks for doing this! ...
6 years, 5 months ago (2014-07-16 15:05:14 UTC) #19
tapted
Thanks all! https://codereview.chromium.org/322893005/diff/620001/ui/aura/test/event_generator.h File ui/aura/test/event_generator.h (right): https://codereview.chromium.org/322893005/diff/620001/ui/aura/test/event_generator.h#newcode5 ui/aura/test/event_generator.h:5: #ifndef UI_AURA_TEST_EVENT_GENERATOR_H_ On 2014/07/16 15:05:14, Ben Goodger ...
6 years, 5 months ago (2014-07-17 03:42:34 UTC) #20
tapted
The CQ bit was checked by tapted@chromium.org
6 years, 5 months ago (2014-07-17 03:42:57 UTC) #21
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/tapted@chromium.org/322893005/640001
6 years, 5 months ago (2014-07-17 03:46:28 UTC) #22
commit-bot: I haz the power
Change committed as 283694
6 years, 5 months ago (2014-07-17 07:36:44 UTC) #23
sadrul
Very nice! LGTM!
6 years, 5 months ago (2014-07-17 16:18:51 UTC) #24
tfarina
https://codereview.chromium.org/322893005/diff/640001/ui/events/test/event_generator.cc File ui/events/test/event_generator.cc (right): https://codereview.chromium.org/322893005/diff/640001/ui/events/test/event_generator.cc#newcode62 ui/events/test/event_generator.cc:62: : delegate_(CreateDefaultPlatformDelegate(this, root_window, NULL)), So now, with this, events_test_support ...
6 years, 4 months ago (2014-07-31 00:20:19 UTC) #25
tfarina
https://codereview.chromium.org/322893005/diff/640001/ui/events/test/event_generator.cc File ui/events/test/event_generator.cc (right): https://codereview.chromium.org/322893005/diff/640001/ui/events/test/event_generator.cc#newcode62 ui/events/test/event_generator.cc:62: : delegate_(CreateDefaultPlatformDelegate(this, root_window, NULL)), On 2014/07/31 00:20:19, tfarina wrote: ...
6 years, 4 months ago (2014-07-31 00:49:24 UTC) #26
brettw
I only looked briefly, but it looks like Thiago is correct and that the layering ...
6 years, 4 months ago (2014-07-31 17:45:04 UTC) #27
tapted
6 years, 4 months ago (2014-07-31 23:17:04 UTC) #28
Message was sent while issue was closed.
On 2014/07/31 17:45:04, brettw wrote:
> I only looked briefly, but it looks like Thiago is correct and that the
layering
> is wrong here. We we prioritize cleaning this up?

I followed up in http://crbug.com/399106 with a short-term fix. I agree this is
not ideal. The test_support target gets away with it because it is statically
linked, but the GN file didn't have it that way. I think I have a fix for the
layering that's neater than the helper classes I had here in patchset 9. I'll
try it out.

Powered by Google App Engine
This is Rietveld 408576698