Skip to content

[ios] Record OCMReject expectations before the stimulus in FlutterPluginAppLifeCycleDelegateTest - #193011

Merged
auto-submit[bot] merged 4 commits into
flutter:masterfrom
okorohelijah:fix/lifecycle-delegate-test-ocmreject-order
Nov 20, 2026
Merged

auto-submit[bot] merged 4 commits into
flutter:masterfrom
okorohelijah:fix/lifecycle-delegate-test-ocmreject-order

Conversation

@okorohelijah

@okorohelijah okorohelijah commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

OCMReject is an expectation in OCMock's expect-run-verify model (OCMock reference): it must be recorded before the code under test runs. With OCMock 3.7.1 (pinned in DEPS) a rejected selector raises NSInternalInconsistencyException: explicitly disallowed method invoked at the moment the mock receives it. Recording the reject after the invocation tests nothing.

All 13 OCMReject calls in engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegateTest.mm were recorded after the stimulus — after the scene...Fallback call, or after waitForExpectations: in the notification-driven tests — so none of the "unnecessary fallback" / "WithUIScene" negative tests could ever fail, even if FlutterPluginAppLifeCycleDelegate started forwarding application events to scene-aware plugins or to plugins in a UIScene app.

This PR moves each reject up to right after the mock/plugin wiring and before the stimulus. It is a test-only change: no production code is modified, and no reject is removed, weakened, or left in its vacuous position. It follows the same fix already made to FlutterAppDelegateTest.mm for #192143.

Per-site summary

For each site, the reject now precedes the listed stimulus. I traced FlutterPluginAppLifeCycleDelegate.mm for each one to confirm the production code legitimately does not invoke the rejected selector, so the tests are expected to keep passing (now meaningfully):

Test Stimulus the reject now precedes Why the rejected selector is not invoked
testSceneWillConnectFallbackSkippedSupportsScenes -sceneWillConnectFallback: Plugin conforms to FlutterSceneLifeCycleDelegate; skipped by -pluginSupportsSceneLifecycle: in the isFallbackForScene:YES loop.
testSceneWillConnectFallbackSkippedNoOptions -sceneWillConnectFallback: ConvertConnectionOptions() yields an empty dictionary (unstubbed UISceneConnectionOptions mock), so the fallback returns NO before dispatching.
testDidEnterBackgroundWithUIScene UIApplicationDidEnterBackgroundNotification post (synchronous) +[FlutterSharedApplication hasSceneDelegate] stubbed YES → -handleDidEnterBackground: returns early via -appSupportsSceneLifecycle.
testWillEnterForegroundWithUIScene UIApplicationWillEnterForegroundNotification post Same early return in -handleWillEnterForeground:.
testWillResignActiveWithUIScene UIApplicationWillResignActiveNotification post Same early return in -handleWillResignActive:.
testDidBecomeActiveWithUIScene UIApplicationDidBecomeActiveNotification post Same early return in -handleDidBecomeActive:.
testUnnecessarySceneDidEnterBackgroundFallback -sceneDidEnterBackgroundFallback OCMProtocolMock(TestFlutterPluginWithSceneEvents) reports conformance to FlutterSceneLifeCycleDelegate (protocol_conformsToProtocol), so the plugin is skipped.
testUnnecessarySceneWillEnterForegroundFallback -sceneWillEnterForegroundFallback Same.
testUnnecessarySceneWillResignActiveFallback -sceneWillResignActiveFallback Same.
testUnnecessarySceneDidBecomeActiveFallback -sceneDidBecomeActiveFallback Same.
testUnnecessarySceneFallbackOpenURLContexts -sceneFallbackOpenURLContexts: OCMPartialMock(FakeTestFlutterPluginWithSceneEvents) reports conformance via class_conformsToProtocol on the mocked class, so the plugin is skipped.
testUnnecessarySceneFallbackContinueUserActivity -sceneFallbackContinueUserActivity: Same.
testUnnecessarySceneFallbackPerformActionForShortcutItem -sceneFallbackPerformActionForShortcutItem:completionHandler: Same.

Notes on the four ...WithUIScene tests: the IosUnitTests host app is UIScene-based (UIApplicationSceneManifest + SceneDelegate in testing/ios/IosUnitTests/App/Info.plist), so hasSceneDelegate is naturally YES there. The positive counterparts (testDidEnterBackground etc.) already depend on the FlutterSharedApplication class-method stub returning NO, which demonstrates that stubbing works; the negative tests now depend on the YES stub (and would pass even without it in this host). The notification is delivered synchronously on the posting thread, so the reject is live during dispatch.

Related: #192143 (same class of bug in FlutterAppDelegateTest.mm).

With the help of Gemini

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

…ginAppLifeCycleDelegateTest

`OCMReject` is an expectation in OCMock's expect-run-verify model: it
must be recorded before the code under test runs. With OCMock 3.7.1
(pinned in DEPS) a rejected selector raises
`NSInternalInconsistencyException: explicitly disallowed method invoked`
at the moment the mock receives it. Recording the reject after the
invocation tests nothing.

All 13 `OCMReject` calls in FlutterPluginAppLifeCycleDelegateTest.mm
were recorded after the stimulus (after the `scene...Fallback` call or
after `waitForExpectations:`), so none of the "unnecessary fallback" /
"WithUIScene" negative tests could ever fail. Move each reject up to
right after the mock/plugin wiring and before the stimulus. No
production code is changed and no reject is removed or weakened.

Per-site summary (test -> stimulus the reject now precedes -> why the
production code legitimately does not invoke the rejected selector):

- testSceneWillConnectFallbackSkippedSupportsScenes
    -> -sceneWillConnectFallback:
    -> plugin conforms to FlutterSceneLifeCycleDelegate; skipped by
       -pluginSupportsSceneLifecycle: in the isFallbackForScene:YES loop.
- testSceneWillConnectFallbackSkippedNoOptions
    -> -sceneWillConnectFallback:
    -> ConvertConnectionOptions() yields an empty dictionary, so the
       fallback returns NO before dispatching to any plugin.
- testDidEnterBackgroundWithUIScene
- testWillEnterForegroundWithUIScene
- testWillResignActiveWithUIScene
- testDidBecomeActiveWithUIScene
    -> the UIApplication*Notification post (delivered synchronously)
    -> +[FlutterSharedApplication hasSceneDelegate] is stubbed YES, so
       -handle*: returns early via -appSupportsSceneLifecycle.
- testUnnecessarySceneDidEnterBackgroundFallback
- testUnnecessarySceneWillEnterForegroundFallback
- testUnnecessarySceneWillResignActiveFallback
- testUnnecessarySceneDidBecomeActiveFallback
    -> the matching -scene*Fallback call
    -> OCMProtocolMock(TestFlutterPluginWithSceneEvents) reports
       conformance to FlutterSceneLifeCycleDelegate
       (protocol_conformsToProtocol), so the plugin is skipped.
- testUnnecessarySceneFallbackOpenURLContexts
- testUnnecessarySceneFallbackContinueUserActivity
- testUnnecessarySceneFallbackPerformActionForShortcutItem
    -> the matching -sceneFallback... call
    -> OCMPartialMock(FakeTestFlutterPluginWithSceneEvents) reports
       conformance via class_conformsToProtocol on the mocked class,
       so the plugin is skipped.

Not run locally (Linux host; XCTest requires macOS). Relies on the
`Mac mac_unopt` presubmit, which runs `ios_test_flutter` via
`testing/run_tests.py --type objc`.

Follows the same fix made to FlutterAppDelegateTest.mm for
flutter#192143.
@github-actions github-actions Bot added platform-ios iOS applications specifically engine flutter/engine related. See also e: labels. team-ios Owned by iOS platform team labels Sep 18, 2026
@okorohelijah
okorohelijah marked this pull request as ready for review October 21, 2026 12:36
@okorohelijah
okorohelijah requested a review from a team as a code owner October 21, 2026 12:36

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates several test cases in FlutterPluginAppLifeCycleDelegateTest.mm by moving the OCMReject expectation setups to occur before the respective delegate methods are invoked or notifications are posted. This ensures that the mock rejections are properly registered before the actions under test are executed. No review comments were provided, and there is no additional feedback.

@okorohelijah okorohelijah added the CICD Run CI/CD label Oct 21, 2026
@jmagman

jmagman commented Oct 30, 2026

Copy link
Copy Markdown
Member
  error • The named parameter 'templateRenderer' is required, but there's no corresponding argument. Try adding the required argument • packages/flutter_tools/test/general.shard/test/flutter_web_platform_canvaskit_test.dart:46:71 • missing_required_argument

@cbracken

cbracken commented Nov 5, 2026

Copy link
Copy Markdown
Member

@okorohelijah friendly ping :)

@LouiseHsu

Copy link
Copy Markdown
Contributor

@okorohelijah gentle ping :)

@okorohelijah okorohelijah added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 18, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 18, 2026
@auto-submit

auto-submit Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/193011, because - The status or check suite Presubmit has failed. Please fix the issues identified (or deflake) before re-applying this label.

@okorohelijah okorohelijah added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 19, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Nov 19, 2026
Merged via the queue into flutter:master with commit 1b0de66 Nov 20, 2026
23 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 20, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Nov 20, 2026
Roll Flutter from e8cc6f3451b7 to b34b017b48ad (36 revisions)

flutter/flutter@e8cc6f3...b34b017

2026-11-20 [email protected] Fix OverflowBox dry layout when deferToChild overrides the constraints (flutter/flutter#196839)
2026-11-20 [email protected] Roll Dart SDK from f118f476ebce to 3b5f45d812f8 (1 revision) (flutter/flutter#197048)
2026-11-20 [email protected] [macOS] Register plugins in multiple_windows example (flutter/flutter#196068)
2026-11-20 [email protected] Roll Skia from 87027a9d4659 to a1edf5c2ea5c (1 revision) (flutter/flutter#197045)
2026-11-20 [email protected] Add highp directives to UberSDF to prevent overflow (flutter/flutter#196997)
2026-11-20 [email protected] [Impeller] Cap the Vulkan command pool recycler cache (flutter/flutter#194793)
2026-11-20 [email protected] Roll Skia from 12610b69511d to 87027a9d4659 (4 revisions) (flutter/flutter#197037)
2026-11-20 [email protected] [macOS] Unregister nil binary message handlers (flutter/flutter#193672)
2026-11-20 [email protected] Roll Dart SDK from b803c3ec01de to f118f476ebce (2 revisions) (flutter/flutter#197034)
2026-11-20 [email protected] Roll Skia from 2f1436ba8e64 to 12610b69511d (3 revisions) (flutter/flutter#197030)
2026-11-20 [email protected] [Android] Do not use the HCPP external view embedder from its platform tasks (flutter/flutter#196490)
2026-11-20 [email protected] Roll Dart SDK from 849e17ad3ae6 to b803c3ec01de (1 revision) (flutter/flutter#197012)
2026-11-20 [email protected] [iOS a11y] Synchronize hit-test children when replacing semantics objects (flutter/flutter#196439)
2026-11-20 [email protected] Sync CHANGELOG.md from stable (flutter/flutter#197019)
2026-11-19 [email protected] [flutter_tools] Reland "Extract Windows archives using native tar" (flutter/flutter#193515)
2026-11-19 [email protected] [Reland][flutter_tools] Migrate lib/runner.dart off runInContext and overrides (flutter/flutter#196931)
2026-11-19 [email protected] Include assigned issues in Android incoming triage link (flutter/flutter#197008)
2026-11-19 [email protected] [Flutter GPU] Record on the UI thread, encode and submit on the raster thread (flutter/flutter#194882)
2026-11-19 [email protected] Add Pixel 7 Pro Impeller benchmarks without fixed-performance mode (flutter/flutter#197010)
2026-11-19 [email protected] Reduce time of uiscene_plugin_lifecycle_test_ios (flutter/flutter#196363)
2026-11-19 [email protected] [native assets] Respect Apple deployment targets (flutter/flutter#194146)
2026-11-19 [email protected] iOS: Represent platform view frames as FlutterPlatformViewFrames (flutter/flutter#196955)
2026-11-19 [email protected] Roll Skia from 0bf961e4ff05 to 2f1436ba8e64 (3 revisions) (flutter/flutter#196999)
2026-11-19 [email protected] [ios] Record OCMReject expectations before the stimulus in FlutterPluginAppLifeCycleDelegateTest (flutter/flutter#193011)
2026-11-19 [email protected] Fix post-monorepo doc rot in docs/infra and dev/bots/README.md (flutter/flutter#193010)
2026-11-19 [email protected] Roll Skia from c3567e170362 to 0bf961e4ff05 (4 revisions) (flutter/flutter#196994)
2026-11-19 [email protected] Close Linux popups when their parent loses focuses (flutter/flutter#196825)
2026-11-19 [email protected] Roll Packages from dca2e58 to 81b7c44 (6 revisions) (flutter/flutter#196992)
2026-11-19 [email protected] Roll Dart SDK from d8d40cf9c21b to 849e17ad3ae6 (1 revision) (flutter/flutter#196986)
2026-11-19 [email protected] Fix RouteObserver didPushNext not firing when routes are pushed synchronously (flutter/flutter#189057)
2026-11-19 [email protected] [Impeller] Reuse render targets on text shadow cache misses (flutter/flutter#194769)
2026-11-19 [email protected] Roll Skia from 81de64af9806 to c3567e170362 (3 revisions) (flutter/flutter#196982)
2026-11-19 [email protected] Reland: "Move macOS desktop builds to ThinLTO" (flutter/flutter#196928)
2026-11-19 [email protected] [Linux] Desynchronize the Wayland subsurface so frames don't redraw the GTK window (flutter/flutter#195287)
2026-11-19 [email protected] Roll Skia from 3dfb69d709c7 to 81de64af9806 (1 revision) (flutter/flutter#196975)
2026-11-19 [email protected] Update `ProxyAnimation.didStartListening` and `ProxyAnimation. didStopListening` to use dart's `Conditional member access` (flutter/flutter#195762)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD engine flutter/engine related. See also e: labels. platform-ios iOS applications specifically team-ios Owned by iOS platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants