-
Notifications
You must be signed in to change notification settings - Fork 27.2k
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
[flutter_tools] Add namespace getter in Android project; use namespace as fallback #121416
[flutter_tools] Add namespace getter in Android project; use namespace as fallback #121416
Conversation
…r package attribute in Manifest
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
@christopherfujino Could you give me a hint for a test? I'd want to have a stub I just don't know how to do that exactly. Edit: I think I got it, except for a remaining |
|
||
expect(processManager, hasNoRemainingExpectations); | ||
|
||
// TODO: verify the packageId of the built APK equals the namespace value |
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.
So this test verifies that building an APK using the namespace works, but I'd like to assert that the namespace value is also correct. Any tips on how to do that? Or is that not required (as the test already validates that the APK is built without errors)
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 think this test validates your change--I reverted your lib/src changes and this test still passes.
Can you test AndroidApk.fromAndroidProject()
?
@@ -486,9 +487,15 @@ class AndroidProject extends FlutterProjectPlatform { | |||
} | |||
|
|||
File get appManifestFile { | |||
return isUsingGradle |
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.
@christopherfujino I had mismatching results when originally running this test.
The fileSystem
created in the test would report that the appManifestFile
exists, but the globals.fs
file system in this getter reported that it did not exist.
According to a doc comment I can override globals.fs
in tests. I don't see the setUp((){})
doing something like that. What would be the right thing to do here?
A) Override globals.fs
in the test
B) Fix the getter to use hostAppGradleRoot
, which does use the fileSystem
that was set up in the specific test (which is what I did here)
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.
Good find. Looks like whatever test you copy-pasted this from was also leaking the real file system. The whole purpose of the testUsingContext()
function you're calling is that it allows you to provide overrides
to the Zone/context getters (globals.fs
is essentially calling `context.get();).
Here is an example of constructing a FileSystem in setUp
and then providing it as a context override for a testUsingContext
invocation: https://github.com/flutter/flutter/blob/master/packages/flutter_tools/test/commands.shard/hermetic/build_test.dart#L60
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.
although if it makes sense, what you did here is probably better (it looks cleaner)
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.
Thanks for the tip, I'll update the test with an override for the file system. I'll keep that in mind for the next time I need to write tests like this.
packages/flutter_tools/test/general.shard/android/android_gradle_builder_test.dart
Show resolved
Hide resolved
packages/flutter_tools/test/general.shard/android/android_gradle_builder_test.dart
Outdated
Show resolved
Hide resolved
@christopherfujino fixed the test (forgot the activity tag, woops) and now it no longer hangs when running the tests. |
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! Thanks for sticking through, I know this was tricky to test.
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.
👍
…namespace as fallback (flutter/flutter#121416)
…namespace as fallback (flutter/flutter#121416)
…namespace as fallback (flutter/flutter#121416)
…e as fallback (flutter#121416) [flutter_tools] Add namespace getter in Android project; use namespace as fallback
…namespace as fallback (flutter/flutter#121416)
…namespace as fallback (flutter/flutter#121416)
…namespace as fallback (flutter/flutter#121416)
…namespace as fallback (flutter/flutter#121416)
For newer Android projects the
package
attribute in the Manifest has been replaced with anamespace
attribute under theandroid
section of the build.gradle file.List which issues are fixed by this PR. You must list at least one issue.
Fixes: #121404
If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.
N/A
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.