Enable Android integration tests in remaining plugins #4514
Conversation
Looks like a number of these either aren't set up quite right or are failing tests; I think it would be easier to split them into one PR per plugin. (Looks like video_player worked, so that one we can land easily.) |
I've been trying to do |
@@ -5,4 +5,10 @@ | |||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" | |||
android:exported="false"/> | |||
</application> | |||
<queries> | |||
<intent> | |||
<action android:name="android.intent.action.SENDTO" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was causing an issue in Android 11
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For which scheme? It sounds like we may need to update the README.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Android manifests are aggregated. There's no need for manual instructions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SENDTO works for SMS and emails
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Android manifests are aggregated. There's no need for manual instructions.
Oh, I thought this was in the example app. I don't think we should add this here, because we don't know what schemes someone is going to use. We should instead document this query in the README for people who need it, as we are currently doing (but without this scheme). And then add this to the example instead, so that the test passes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I don't know why not adding them to the plugin AndroidManifest.xml automatically. I think the idea is to have 3p dependencies auto-configuring themselves when possible unless there's some major concern that prevents these from being the default.
I'm not sure if these concerns exist, or if we didn't know that the Android Gradle plugin merges manifests automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why not adding them to the plugin AndroidManifest.xml automatically.
It is entirely possible to use url_launcher
without any permissions (just use launch
without canLaunch
), and almost nobody would use the entire set of possible queries that canLaunch
could require. We shouldn't force people using a plugin to have their app require permissions they aren't using. Especially since the guidance from the stores is always to use the minimal permission set.
if we didn't know that the Android Gradle plugin merges manifests automatically
I didn't know that certainly, and it's good to know 🙂 . We should audit our READMEs for cases where the advice is "you must add X if you use this plugin" rather than "you might need X if you are using this plugin to do Y", and for the former, put it in the plugin manifest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven’t used this plugin, but if canLaunch isn’t required, then the API seems very confusing. I assumed that canLaunch means that if it returns false, then never launch the intent, and handle it differently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updating the docs is on my TODO list, because the example shown in the README (await canLaunch(_url) ? await launch(_url) : throw 'Could not launch $_url';
) is pointless; it's just a slower and more cumbersome way of writing
if (!(await launch(_url))) throw 'Could not launch $_url';
and handle it differently
This is where canLaunch
is actually useful, yes. But with https
URLs, for instance, I would be willing to bet that nobody has fallback code in their application that handles the case where someone's device does not have a browser, so calling canLaunch
in that cirumstance is pointless.
@stuartmorgan this is ready for another review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like camera
is still broken. Per my earlier comment: is there a reason not to split that out so we can land the rest now while that's worked out?
packages/in_app_purchase/in_app_purchase/example/integration_test/in_app_purchase_test.dart
Outdated
Show resolved
Hide resolved
packages/url_launcher/url_launcher/example/integration_test/url_launcher_test.dart
Outdated
Show resolved
Hide resolved
@@ -5,4 +5,10 @@ | |||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" | |||
android:exported="false"/> | |||
</application> | |||
<queries> | |||
<intent> | |||
<action android:name="android.intent.action.SENDTO" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For which scheme? It sounds like we may need to update the README.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with some nits. Thanks for getting all of these working!
dartMessenger.sendCameraClosingEvent(); | ||
super.onClosed(camera); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default implementation of onClosed
does nothing. For callbacks, I'd be very surprised if there was an API that has a super implementation that does something. It'd be incorrect to call it a callback.
https://developer.android.com/reference/android/hardware/camera2/CameraDevice.StateCallback#onClosed(android.hardware.camera2.CameraDevice)
packages/camera/camera/example/integration_test/camera_test.dart
Outdated
Show resolved
Hide resolved
packages/shared_preferences/shared_preferences/example/android/app/src/main/AndroidManifest.xml
Outdated
Show resolved
Hide resolved
packages/url_launcher/url_launcher/example/integration_test/url_launcher_test.dart
Outdated
Show resolved
Hide resolved
@blasten I wrote up https://github.com/flutter/flutter/wiki/Plugin-Tests#enabling-android-ui-tests based on everything I learned from my trial and error on (My goal is to eventually make all of this part of the plugin template, but until then I want to make sure the process for all of our non-trivial test setup is clearly documented.) |
@stuartmorgan yup. That's pretty much it |
Fixes flutter/flutter#86749