[go: nahoru, domu]

Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

[package_info] Support the v2 Android embedder (with e2e tests) #2160

Merged
merged 55 commits into from
Oct 17, 2019

Conversation

collinjackson
Copy link
Contributor
@collinjackson collinjackson commented Oct 7, 2019

Description

  • Migrate the package_info plugin to use the new embedder.
  • Upgraded to AndroidX.
  • Added a unit test.
  • Added Firebase Test Lab compatible e2e testing.

This PR is intended to serve as an example of how to do same-isolate e2e testing of plugins.

To e2e test low-level plugin APIs using Flutter driver:

cd example
flutter drive ../test/<package_name>_e2e.dart

To e2e test the example app itself:

cd example
flutter drive test/<package_name>_e2e.dart

When using flutter driver, to change the binding update the intent filter in AndroidManifest.xml.

To e2e test on a local emulator using Android instrumentation:

./gradlew app:connectedAndroidTest -Ptarget=`pwd`/../test_driver/<package_name>_e2e.dart 

To e2e test using Firebase test lab, follow the instructions on the e2e README or let CI plugin_tools do it for you.

Known issues

  • Although the test results appear in logcat, the instrumentation adapter isn't exiting at the end of the test)
  • instrumentation_adapter package should be renamed e2e (see Rename instrumentation_adapter plugin to e2e plugin #2161)
  • Tests that aren't specific to the example app should be moved to the parent folder's test dir

Related Issues

Fixes flutter/flutter#41843

For a full list of migrations, see https://github.com/flutter/flutter/projects/59

@collinjackson collinjackson changed the title Support the v2 Android embedder [path_provider] Support the v2 Android embedder Oct 7, 2019
@collinjackson collinjackson changed the title [path_provider] Support the v2 Android embedder [package_info] Support the v2 Android embedder Oct 7, 2019
Copy link
Contributor
@amirh amirh left a comment

Choose a reason for hiding this comment

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

LGTM!

I left a few non-blocking nits/questions. The one thing we should figure before landing is whether we need to bump the minimally required flutter SDK.

@@ -1 +1,2 @@
org.gradle.jvmargs=-Xmx1536M
android.enableJetifier=true
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the affect of adding this to a plugin's gradle file? Does this setting gets propagated to all apps who are using the plugin?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Based on the name, I'm hoping that enableJetifier does not imply enableAndroidX, so it should reduce compilation errors without causing compilation errors.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this has any meaning without enableAndroidX, and if it does I think it would also implicitly turn AndroidX on. If AndroidX is enabled and this flag is true, Gradle will attempt to run Jetifier to convert any support references to AndroidX ones. I'm not sure how Gradle handles just this flag with enableAndroidX being undefined.

I'm pretty sure that putting this here means that this subproject and only this subproject would be affected, but there may be some weirdness here on account of our build system.

void main() {
InstrumentationAdapterFlutterBinding.ensureInitialized();

testWidgets('fromPlatform', (WidgetTester tester) async {
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious - does this always needs to be a testWidgets if we're using the instrumentation adapter?

Copy link
Contributor Author
@collinjackson collinjackson Oct 7, 2019

Choose a reason for hiding this comment

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

Currently the e2e adapter doesn't hook at a low enough level to catch calls to test(), but that could be improved in the future. When I talked to Ian about it, it didn't seem like a priority.

packages/package_info/example/pubspec.yaml Outdated Show resolved Hide resolved
@collinjackson collinjackson changed the title [package_info] Support the v2 Android embedder [package_info] Support the v2 Android embedder (with tests) Oct 7, 2019
@collinjackson collinjackson changed the title [package_info] Support the v2 Android embedder (with tests) [package_info] Support the v2 Android embedder (with e2e tests) Oct 7, 2019
super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
public void configureFlutterEngine(FlutterEngine flutterEngine) {
flutterEngine.getPlugins().add(new PackageInfoPlugin());
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: add a TODO to remove this once the generated registrant for the v2 embedder is on stable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@collinjackson collinjackson merged commit dce7169 into flutter:master Oct 17, 2019
mormih pushed a commit to mormih/plugins that referenced this pull request Nov 17, 2019
…ter#2160)

* Migrate the package_info plugin to use the new embedder.
* Upgraded to AndroidX.
* Added a unit test.
* Added Firebase Test Lab compatible e2e testing (including changes to Dockerfile and .cirrus.yml)
sungmin-park pushed a commit to sungmin-park/flutter-plugins that referenced this pull request Dec 17, 2019
…ter#2160)

* Migrate the package_info plugin to use the new embedder.
* Upgraded to AndroidX.
* Added a unit test.
* Added Firebase Test Lab compatible e2e testing (including changes to Dockerfile and .cirrus.yml)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
6 participants