mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[ios] Fix default assets url (flutter/engine#46214)
When reverting the default asset url code, the old "flutter_assets" path was also copied in https://github.com/flutter/engine/pull/46073 This PR uses the correct URL. Although I'm unsure why the video player test passed before my change for the asset urls. I'm going to take another look at it but meanwhile this PR can unblock the roll once rolled into the framework. fixes of https://github.com/flutter/flutter/issues/135323 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
parent
7f439ef302
commit
c889e14d4c
@ -54,7 +54,7 @@ NSBundle* FLTFrameworkBundleWithIdentifier(NSString* flutterFrameworkBundleID) {
|
||||
}
|
||||
|
||||
NSString* FLTAssetPath(NSBundle* bundle) {
|
||||
return [bundle objectForInfoDictionaryKey:@"FLTAssetsPath"] ?: @"flutter_assets";
|
||||
return [bundle objectForInfoDictionaryKey:@"FLTAssetsPath"] ?: kDefaultAssetPath;
|
||||
}
|
||||
|
||||
NSString* FLTAssetsPathFromBundle(NSBundle* bundle) {
|
||||
|
||||
@ -102,14 +102,116 @@ FLUTTER_ASSERT_ARC
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
- (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");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user