This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
[ios] Fix default assets url #46214
Merged
Merged
[ios] Fix default assets url #46214
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,14 +102,116 @@ - (void)testFLTAssetsURLFromBundle { | |
| id mockBundle = OCMClassMock([NSBundle class]); | ||
| id mockMainBundle = OCMPartialMock([NSBundle mainBundle]); | ||
| NSString* resultAssetsPath = @"path/to/foo/assets"; | ||
| OCMStub([mockBundle pathForResource:@"flutter_assets" ofType:@""]).andReturn(nil); | ||
| OCMStub([mockMainBundle pathForResource:@"flutter_assets" ofType:@""]) | ||
| OCMStub([mockBundle pathForResource:@"Frameworks/App.framework/flutter_assets" ofType:@""]) | ||
| .andReturn(nil); | ||
| OCMStub([mockMainBundle pathForResource:@"Frameworks/App.framework/flutter_assets" ofType:@""]) | ||
| .andReturn(resultAssetsPath); | ||
| NSString* path = FLTAssetsPathFromBundle(mockBundle); | ||
| XCTAssertEqualObjects(path, @"path/to/foo/assets"); | ||
| } | ||
| } | ||
|
|
||
| - (void)testFLTAssetPathReturnsTheCorrectValue { | ||
| { | ||
| // Found assets path in info.plist | ||
| id mockBundle = OCMClassMock([NSBundle class]); | ||
| OCMStub([mockBundle objectForInfoDictionaryKey:@"FLTAssetsPath"]).andReturn(@"foo/assets"); | ||
| XCTAssertEqualObjects(FLTAssetPath(mockBundle), @"foo/assets"); | ||
| } | ||
| { | ||
| // No assets path in info.plist, use default value | ||
| id mockBundle = OCMClassMock([NSBundle class]); | ||
| OCMStub([mockBundle objectForInfoDictionaryKey:@"FLTAssetsPath"]).andReturn(nil); | ||
| XCTAssertEqualObjects(FLTAssetPath(mockBundle), kDefaultAssetPath); | ||
| } | ||
| } | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These tests are both of a private helper method; there's nothing about the structure here that would indicate that someone making a change like your recent change couldn't just change these tests if they broke. The deeper problem is that we appear to have no tests of the public |
||
| - (void)testLookUpForAssets { | ||
| { | ||
| id mockBundle = OCMPartialMock([NSBundle mainBundle]); | ||
| // Found assets path in info.plist | ||
| OCMStub([mockBundle objectForInfoDictionaryKey:@"FLTAssetsPath"]).andReturn(@"foo/assets"); | ||
| NSString* assetsPath = [FlutterDartProject lookupKeyForAsset:@"bar"]; | ||
| // This is testing public API, changing this assert is likely to break plugins. | ||
| XCTAssertEqualObjects(assetsPath, @"foo/assets/bar"); | ||
| [mockBundle stopMocking]; | ||
| } | ||
| { | ||
| id mockBundle = OCMPartialMock([NSBundle mainBundle]); | ||
| // No assets path in info.plist, use default value | ||
| OCMStub([mockBundle objectForInfoDictionaryKey:@"FLTAssetsPath"]).andReturn(nil); | ||
| NSString* assetsPath = [FlutterDartProject lookupKeyForAsset:@"bar"]; | ||
| // This is testing public API, changing this assert is likely to break plugins. | ||
| XCTAssertEqualObjects(assetsPath, @"Frameworks/App.framework/flutter_assets/bar"); | ||
| [mockBundle stopMocking]; | ||
| } | ||
| } | ||
|
|
||
| - (void)testLookUpForAssetsFromBundle { | ||
| { | ||
| id mockBundle = OCMClassMock([NSBundle class]); | ||
| // Found assets path in info.plist | ||
| OCMStub([mockBundle objectForInfoDictionaryKey:@"FLTAssetsPath"]).andReturn(@"foo/assets"); | ||
| NSString* assetsPath = [FlutterDartProject lookupKeyForAsset:@"bar" fromBundle:mockBundle]; | ||
| // This is testing public API, changing this assert is likely to break plugins. | ||
| XCTAssertEqualObjects(assetsPath, @"foo/assets/bar"); | ||
| } | ||
| { | ||
| // No assets path in info.plist, use default value | ||
| id mockBundle = OCMClassMock([NSBundle class]); | ||
| OCMStub([mockBundle objectForInfoDictionaryKey:@"FLTAssetsPath"]).andReturn(nil); | ||
| NSString* assetsPath = [FlutterDartProject lookupKeyForAsset:@"bar" fromBundle:mockBundle]; | ||
| // This is testing public API, changing this assert is likely to break plugins. | ||
| XCTAssertEqualObjects(assetsPath, @"Frameworks/App.framework/flutter_assets/bar"); | ||
| } | ||
| } | ||
|
|
||
| - (void)testLookUpForAssetsFromPackage { | ||
| { | ||
| id mockBundle = OCMPartialMock([NSBundle mainBundle]); | ||
| // Found assets path in info.plist | ||
| OCMStub([mockBundle objectForInfoDictionaryKey:@"FLTAssetsPath"]).andReturn(@"foo/assets"); | ||
| NSString* assetsPath = [FlutterDartProject lookupKeyForAsset:@"bar" fromPackage:@"bar_package"]; | ||
| // This is testing public API, changing this assert is likely to break plugins. | ||
| XCTAssertEqualObjects(assetsPath, @"foo/assets/packages/bar_package/bar"); | ||
| [mockBundle stopMocking]; | ||
| } | ||
| { | ||
| id mockBundle = OCMPartialMock([NSBundle mainBundle]); | ||
| // No assets path in info.plist, use default value | ||
| OCMStub([mockBundle objectForInfoDictionaryKey:@"FLTAssetsPath"]).andReturn(nil); | ||
| NSString* assetsPath = [FlutterDartProject lookupKeyForAsset:@"bar" fromPackage:@"bar_package"]; | ||
| // This is testing public API, changing this assert is likely to break plugins. | ||
| XCTAssertEqualObjects(assetsPath, | ||
| @"Frameworks/App.framework/flutter_assets/packages/bar_package/bar"); | ||
| [mockBundle stopMocking]; | ||
| } | ||
| } | ||
|
|
||
| - (void)testLookUpForAssetsFromPackageFromBundle { | ||
| { | ||
| id mockBundle = OCMClassMock([NSBundle class]); | ||
| // Found assets path in info.plist | ||
| OCMStub([mockBundle objectForInfoDictionaryKey:@"FLTAssetsPath"]).andReturn(@"foo/assets"); | ||
| NSString* assetsPath = [FlutterDartProject lookupKeyForAsset:@"bar" | ||
| fromPackage:@"bar_package" | ||
| fromBundle:mockBundle]; | ||
| // This is testing public API, changing this assert is likely to break plugins. | ||
| XCTAssertEqualObjects(assetsPath, @"foo/assets/packages/bar_package/bar"); | ||
| } | ||
| { | ||
| id mockBundle = OCMClassMock([NSBundle class]); | ||
| // No assets path in info.plist, use default value | ||
| OCMStub([mockBundle objectForInfoDictionaryKey:@"FLTAssetsPath"]).andReturn(nil); | ||
| NSString* assetsPath = [FlutterDartProject lookupKeyForAsset:@"bar" | ||
| fromPackage:@"bar_package" | ||
| fromBundle:mockBundle]; | ||
| // This is testing public API, changing this assert is likely to break plugins. | ||
| XCTAssertEqualObjects(assetsPath, | ||
| @"Frameworks/App.framework/flutter_assets/packages/bar_package/bar"); | ||
| } | ||
| } | ||
|
|
||
| - (void)testDisableImpellerSettingIsCorrectlyParsed { | ||
| id mockMainBundle = OCMPartialMock([NSBundle mainBundle]); | ||
| OCMStub([mockMainBundle objectForInfoDictionaryKey:@"FLTEnableImpeller"]).andReturn(@"NO"); | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 actually going to fail the g3 roll again. It turned out I was wrong about changing the API to using NSString fixing the issue. The root cause is when the full relative path is used, unloaded-bundle returns a nil path for assets. we have to use "flutter_assets" directly for unloaded-bundles.
Because I reverted to @"flutter_assets" in #46073, the roll was fixed.
The fix should be trying to load from kDefaultAssetPath first, if not successful, then try @"flutter_assets" for unloaded bundles.
I will create a PR to fix this with an integration test.
cc @stuartmorgan @XilaiZhang
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 this was already rolled in by @CaseyHillers
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.
Interesting. Maybe it works for XCUITests but not for app extension? That's good to know, we need to fix it for app extensions anyway