-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[quick_actions] Extract the Android implementation into a separate package #4698
[quick_actions] Extract the Android implementation into a separate package #4698
Conversation
8a8b20a
to
64c79c7
Compare
64c79c7
to
6bb9d11
Compare
@@ -15,12 +19,16 @@ flutter: | |||
android: | |||
package: io.flutter.plugins.quickactions | |||
pluginClass: QuickActionsPlugin |
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.
Remove these two lines.
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
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 believe this file is for native unit tests, in which case it should be a move.
(Actually... is this even used? Java unit tests should be in the main source, not the example, and it looks like we already have that. So this file is likely a mistake. Try making it always fail and see if anything actually fails, and if not—which I expect is the case—you can just remove this, both here and the original.)
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 is an interesting one. First of all the test is indeed run and will fail the tree if I force it to fail. Inside this file there is only one test that seems to verify if the QuickActions plugin is part of the engine.getPlugins()
collection:
public void imagePickerPluginIsAdded() {
final ActivityScenario<QuickActionsTestActivity> scenario =
ActivityScenario.launch(QuickActionsTestActivity.class);
scenario.onActivity(
activity -> {
assertTrue(activity.engine.getPlugins().has(QuickActionsPlugin.class));
});
}
Not sure if this test has a lot of value, I assume that loading the plugin it self is widely tested in the engine code it self, so the only thing it verifies now is that the plugin is added to the pubspec.yaml
file (which I this doesn't really need a test).
If this test does have value, it should remain part of the example App since it tests if the plugin is loaded as part of the example App. It doesn't test any logic that is part of the native Java implementation. And doesn't it also make sense to keep the test in both the quick_actions_android and quick_actions example Apps? Both package contain their own example Apps which load the Android plugin in a slightly different way (meaning the registration in the pubspec.yaml
is different).
Would like to hear your opinion on this issue.
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.
Sorry, I misremembered the file locations for different kinds of tests. This is the harness for running native Android UI (espresso) tests. So we do want this file to exist, but it should be a move since we want native integration tests to only be in the implementation package.
Not sure if this test has a lot of value
It's a placeholder, from the project to make sure we had test harnesses in place for all the kinds of tests we want to be running (so that we'd stop having PRs blocked on tests that couldn't be written without someone first learning how to set up the infrastructure for that kind of test).
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
// @dart = 2.9 |
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.
As with iOS, can we remove this?
icon: 'AppIcon', | ||
), | ||
// NOTE: This second action icon will only work on Android. | ||
// In a real world project keep the same file name for both platforms. |
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.
Same comments here as for iOS but reversed.
sdk: flutter | ||
quick_actions_android: | ||
# When depending on this package from a real application you should use: | ||
# quick_actions: ^x.y.z |
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.
quick_actions_android
integration_test: | ||
sdk: flutter | ||
mockito: ^5.0.0 | ||
pedantic: ^1.11.0 |
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.
Remove
sdk: flutter | ||
integration_test: | ||
sdk: flutter | ||
mockito: ^5.0.0 |
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 missed this on the iOS side... are we actually using mockito anywhere in this package?
TestWidgetsFlutterBinding.ensureInitialized(); | ||
|
||
group('$QuickActionsAndroid', () { | ||
final QuickActionsAndroid quickActions = QuickActionsAndroid(); |
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 missed this on the iOS side, but probably applies there too: please put this line in each test. Having the object under test be stateful across the tests is an antipattern and leads to a variety of problems (including tests passing when they shouldn't).
group('$QuickActionsAndroid', () { | ||
final QuickActionsAndroid quickActions = QuickActionsAndroid(); | ||
|
||
final List<MethodCall> log = <MethodCall>[]; |
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.
Prefer making this late
and created in setUp
instead of being final
and cleared in setUp
, to reduce statefulness.
# TODO(mvanbeusekom): Remove the exclusion of the quick_actions_android and | ||
# once the native implementation is removed from the | ||
# quick_actions package. | ||
- quick_actions_android |
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 shouldn't be necessary now.
Creates a new `quick_actions_android` directory and adds the following meta-data files: - `AUTHORS`: copied from the `quick_actions` package and added my name; - `CHANGELOG.md`: new file adding description for release 0.6.0+9; - `LICENSE`: copied from the `quick_actions` package; - `README.md`: new file adding the standard platform implementation description; - `pubspec.yaml`: new file adding package meta-data for the `quick_actions_android` package.
A one to one copy of the `quick_actions/android` folder to `quick_actions_android/` using the following command: ``` cp -R ./quick_actions/android ./quick_actions_android/ ```
This commit makes a direct copy of the `quick_actions/example` app to the `quick_actions_android` package. After the copy the `example/ios` folder is removed as it doesn't serve a purpose in the Android specific package. Commands run where: ``` cp -R ./quick_actions/example ./quick_actions_android/ rm -rf ./quick_actions_android/example/ios ```
This commit updates the example App and integration tests so they directly use the Android specific quick_actions_android package.
Duplicates the method channel implementation in the platform interface package into the Android specific package (see issue flutter/flutter#94224). Also updated the example project and renamed the channels on native and Dart side.
Duplicates the method channel implementation tests and update them so they test the `QuickActionsAndroid` class (see also issue flutter/flutter#94224).
Exclude the quick_actions_android package from the build all plugins app CI step as it currently conflicts with the android implementation that is still part of the quick_actions package.
6bb9d11
to
104af9c
Compare
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 once QuickActionsTest.java
is converted to a move.
5e34739
to
7cc4fe4
Compare
Done, added |
This pull request is not suitable for automatic merging in its current state.
|
7cc4fe4
to
6a2f1c8
Compare
39938e2
to
5d7671f
Compare
Moves the native Android implementation from the quick_actions package into its own quick_actions_android package. I also duplicated the method channel implementation as suggested in issue flutter/flutter#94224.
Temporarily marks quick_actions as unpublishable to allow the implementations to be moved, rather than copied and deleted, in order to better preserve git history. A follow-up PR will restore it to publishable form.
Pre-launch Checklist
dart format
.)[shared_preferences]
///
).