Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pigeon] Add Flutter API integration tests #3066

Merged

Conversation

stuartmorgan
Copy link
Contributor

Adds callFlutter* wrappers for all of the recently-add Flutter API echo* methods in core_tests.dart, and adds integration tests driving them all.

This doesn't fix any of the exposed issues; they are all runtime rather than compile time, so I opted to file issues for each of them instead so they can be fixed on a per-generator basis (and so fixing them won't block getting the tests in place).

Part of flutter/flutter#116374

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 relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

@stuartmorgan stuartmorgan added override: no versioning needed Override the check requiring version bumps for most changes override: no changelog needed Override the check requiring CHANGELOG updates for most changes labels Jan 18, 2023
@@ -280,7 +340,7 @@ abstract class FlutterIntegrationCoreApi {

/// Returns the passed map, to test serialization and deserialization.
@ObjCSelector('echoNullableMap:')
Map<String?, Object?> echoNullableMap(Map<String?, Object?> aMap);
Map<String?, Object?>? echoNullableMap(Map<String?, Object?>? aMap);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This fixes a mistake I made when first adding it, and noticed while implementing the tests.

// echoObject.mapWithAnnotations, genericAllTypes.mapWithAnnotations),
// true);
// expect(
// mapEquals(echoObject.mapWithObject, genericAllTypes.mapWithObject), true);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was outdated; it only applies to AllNullableTypes now.

},
// TODO(stuartmorgan): Fix and re-enable.
// See https://github.com/flutter/flutter/issues/118726
skip: targetGenerator == TargetGenerator.kotlin);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure what happened here; I didn't change anything that should have affected this, but this test was failing for me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, it looks like we're not running Kotlin tests in CI by mistake; the only _integration_test hit in the CI output is Swift. I'll look into that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh right, that's flutter/flutter#111505 🤦🏻

@stuartmorgan stuartmorgan changed the title [pigeon] Add [pigeon] Add Flutter API integration tests Jan 18, 2023
@@ -270,7 +270,22 @@ interface HostIntegrationCoreApi {
/** Returns the passed string asynchronously. */
fun echoAsyncString(aString: String, callback: (String) -> Unit)
fun callFlutterNoop(callback: () -> Unit)
fun callFlutterEchoAllTypes(everything: AllTypes, callback: (AllTypes) -> Unit)
fun callFlutterSendMultipleNullableTypes(aNullableBool: Boolean?, aNullableInt: Long?, aNullableString: String?, callback: (AllNullableTypes) -> Unit)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have a linter/formatter for kotlin? Is this something we can roll in to our tools?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't have one; filed flutter/flutter#118756

@@ -281,7 +281,22 @@ protocol HostIntegrationCoreApi {
/// Returns the passed string asynchronously.
func echoAsyncString(aString: String, completion: @escaping (String) -> Void)
func callFlutterNoop(completion: @escaping () -> Void)
func callFlutterEchoAllTypes(everything: AllTypes, completion: @escaping (AllTypes) -> Void)
func callFlutterSendMultipleNullableTypes(aNullableBool: Bool?, aNullableInt: Int32?, aNullableString: String?, completion: @escaping (AllNullableTypes) -> Void)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same with swift

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tracked by flutter/flutter#41129; hopefully we'll have that fairly soon.

@stuartmorgan
Copy link
Contributor Author

Per offline discussion the Java implementation could potentially be a little less verbose by using a shared generic result class. I'm going to go ahead and land it as-is since that's a minor detail in test-only code that shouldn't need to change, but I'll see if it's easy and if so do a follow-up later with it.

@stuartmorgan stuartmorgan added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 18, 2023
@auto-submit auto-submit bot merged commit 88859a8 into flutter:main Jan 18, 2023
Maatteogekko pushed a commit to Maatteogekko/packages that referenced this pull request Feb 4, 2023
* Add the new wrapper APIs

* Regenerate files

* Add the new integration tests

* macOS Swift implementation

* iOS Swift implementation

* Android Kotlin implementation; some tests disabled

* Android Java implementation

* iOS Obj-C implementation

* Windows C++ implementation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App override: no changelog needed Override the check requiring CHANGELOG updates for most changes override: no versioning needed Override the check requiring version bumps for most changes p: pigeon
Projects
None yet
2 participants