Skip to content

test: integration tests against the real Facebook SDK on emulator and simulator - #525

Merged
DennisAlund merged 20 commits into
mainfrom
test/native-integration
Nov 17, 2026
Merged

DennisAlund merged 20 commits into
mainfrom
test/native-integration

Conversation

@DennisAlund

@DennisAlund DennisAlund commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Stacked on #524, #523 and #522; merge those first.

Problem

Nothing executed the Kotlin and Swift handlers before release. The tests in test/ mock the method channel, and CI only compiled the native code. That is how issue #516 reached users, and why its fix (#518) was merged without ever having run.

Change

example/integration_test/plugin_test.dart (13 tests) runs the plugin inside the example app, against the real Facebook SDK:

example/integration_test/sdk_start_failure_test.dart (3 tests, Android) covers an SDK that failed to start, the situation in #516: calls report sdkNotInitialized, and initializeSdk() reports sdkInitializationFailed with the SDK's reason.

CI runs them in the existing Flutter stable cells:

  • Android: on an API 34 emulator. A second pass removes the client token from the manifest and runs the start-failure tests on the rebuilt app.
  • iOS (SwiftPM): on an iPhone simulator.

The tests set the flush behavior to explicit-only first and never flush, so no test events are sent to Meta. Initializing the SDK still contacts Meta, as it does whenever the example app runs.

Result

First CI run on this PR: 13 passed on Android, 13 on iOS, 3 start-failure tests passed on Android. This is the first time the #518 behavior and the #523 changes have executed on a device.

Cost

The Android stable cell goes from about 5 to about 10 minutes, and the iOS SwiftPM stable cell gains a simulator build.

Limits

  • One emulator API level and one simulator; no physical devices.
  • The tests assert that calls succeed or fail as documented. They do not check what reaches Meta.
  • iOS has no start-failure scenario: there the plugin's own gate covers it, which plugin_test.dart tests.

.idea/, android/.idea/ and the .iml file are machine-specific, and
because they were tracked they were also published to pub.dev. The
local files stay on disk.
Meta retired Facebook Analytics in 2021; the pubspec description and
podspec summary still named it.
A test checks that pubspec, podspec and the newest CHANGELOG entry
agree on the version, that the Graph API pin is the same in Kotlin,
Swift and the README, and that all three Facebook SDK ranges follow one
major. The publish job also refuses a tag that differs from pubspec.
…stale runs

- Dart checks now run on Flutter 3.41 (floor) as well as stable, with
  flutter analyze on both and a dart format check on stable.
- A new push to a pull request cancels the runs of its older commits.
- Runs on main queue instead of overlapping.
- iOS logPurchase and logProductItem passed any string to the SDK as a
  currency, while Android rejected unknown codes. iOS now validates
  against the ISO 4217 list and returns INVALID_ARGUMENT too.
- Both platforms accept currency codes in any letter case; Android
  only accepted upper case.
- Android logPushNotificationOpen failed on payload values a Bundle
  cannot hold (lists), while iOS accepted them. The SDK only reads the
  fb_push_payload string, so Android now leaves such values out.
Flutter 3.50 reports the example's package:flutter/material.dart import
as a deprecation info. Its replacement is not available on the 3.41
floor, so infos cannot be fatal while both are supported.
Adds a cell that builds with the oldest Xcode expected to work with
Facebook iOS SDK v19, plus a temporary probe on 26.3 that is expected
to fail, to confirm where the floor is before documenting it.
plugin_test.dart drives the plugin inside the example app on a device:
the deferred-initialization gate, getters, user data, events,
purchases, product items, push payloads and the privacy toggles.
sdk_start_failure_test.dart covers an Android SDK that failed to start
(issue #516) and needs a build without the client token.
… platforms

The iOS SDK subscripts the fb_push_payload entry as a dictionary and
calls length on its campaign without checking types, so a JSON string
(how FCM delivers the entry, and the form the Android SDK wants) raised
an Objective-C exception and crashed the app. The iOS handler now
parses a string entry and drops one it cannot bring into shape.

The Android SDK reads the entry as a JSON string and ignored a nested
map; the Android handler now serializes a map to JSON.
…ator

The Flutter stable cells of the Android and iOS (SwiftPM) jobs now run
example/integration_test on a device. The Android cell runs a second
pass without the client token in the manifest, to cover an SDK that
failed to start.
It failed as expected with the SDK's .swiftinterface parse errors,
while the Xcode 26.4 cell built. The 26.4 cell stays.
@DennisAlund
DennisAlund marked this pull request as ready for review November 17, 2026 02:50
The earlier commit with this intent only added the .gitignore entries;
the files themselves stayed tracked.
@DennisAlund
DennisAlund merged commit 38ea4a0 into main Nov 17, 2026
9 checks passed
@DennisAlund
DennisAlund deleted the test/native-integration branch November 17, 2026 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant