MacViews: Fix flaky MenuRunnerCocoaTests.

MenuRunnerCocoaTests are currently flaky. When run in parallel with other tests,
the blocks scheduled using CFRunLoopPerformBlock are sometimes not run, causing
the flakiness.

Ideally launching a menu should run the current thread's runloop in
NSEventTrackingRunLoopMode, causing the scheduled blocks to run. However, when
run in parallel with other tests involving UI operations, flakiness probably
occurs because the call to launch a menu may fail midway, causing the scheduled
blocks to not run. Instead of scheduling the block on a runloop, running them as
callbacks on SimpleMenuModel::Delegate::MenuWillShow fixes the flakiness.

BUG=521460

Review URL: https://codereview.chromium.org/1829603002

Cr-Commit-Position: refs/heads/master@{#385940}
1 file changed