@@ -157,12 +157,26 @@ - (void)testLookUpForAssetsFromBundle {
157157 XCTAssertEqualObjects (assetsPath, @" foo/assets/bar" );
158158 }
159159 {
160- // No assets path in info.plist, use default value
160+ // Found assets path in info.plist in main bundle
161161 id mockBundle = OCMClassMock ([NSBundle class ]);
162+ id mockMainBundle = OCMPartialMock (NSBundle .mainBundle );
162163 OCMStub ([mockBundle objectForInfoDictionaryKey: @" FLTAssetsPath" ]).andReturn (nil );
164+ OCMStub ([mockMainBundle objectForInfoDictionaryKey: @" FLTAssetsPath" ]).andReturn (@" foo/assets" );
165+ NSString * assetsPath = [FlutterDartProject lookupKeyForAsset: @" bar" fromBundle: mockBundle];
166+ // This is testing public API, changing this assert is likely to break plugins.
167+ XCTAssertEqualObjects (assetsPath, @" foo/assets/bar" );
168+ [mockBundle stopMocking ];
169+ }
170+ {
171+ // No assets path in both info.plist, use default value
172+ id mockBundle = OCMClassMock ([NSBundle class ]);
173+ id mockMainBundle = OCMPartialMock (NSBundle .mainBundle );
174+ OCMStub ([mockBundle objectForInfoDictionaryKey: @" FLTAssetsPath" ]).andReturn (nil );
175+ OCMStub ([mockMainBundle objectForInfoDictionaryKey: @" FLTAssetsPath" ]).andReturn (nil );
163176 NSString * assetsPath = [FlutterDartProject lookupKeyForAsset: @" bar" fromBundle: mockBundle];
164177 // This is testing public API, changing this assert is likely to break plugins.
165178 XCTAssertEqualObjects (assetsPath, @" Frameworks/App.framework/flutter_assets/bar" );
179+ [mockBundle stopMocking ];
166180 }
167181}
168182
@@ -200,15 +214,31 @@ - (void)testLookUpForAssetsFromPackageFromBundle {
200214 XCTAssertEqualObjects (assetsPath, @" foo/assets/packages/bar_package/bar" );
201215 }
202216 {
217+ // Found assets path in info.plist in main bundle
203218 id mockBundle = OCMClassMock ([NSBundle class ]);
219+ id mockMainBundle = OCMPartialMock (NSBundle .mainBundle );
220+ OCMStub ([mockBundle objectForInfoDictionaryKey: @" FLTAssetsPath" ]).andReturn (nil );
221+ OCMStub ([mockMainBundle objectForInfoDictionaryKey: @" FLTAssetsPath" ]).andReturn (@" foo/assets" );
222+ NSString * assetsPath = [FlutterDartProject lookupKeyForAsset: @" bar"
223+ fromPackage: @" bar_package"
224+ fromBundle: mockBundle];
225+ // This is testing public API, changing this assert is likely to break plugins.
226+ XCTAssertEqualObjects (assetsPath, @" foo/assets/packages/bar_package/bar" );
227+ [mockBundle stopMocking ];
228+ }
229+ {
230+ id mockBundle = OCMClassMock ([NSBundle class ]);
231+ id mockMainBundle = OCMPartialMock (NSBundle .mainBundle );
204232 // No assets path in info.plist, use default value
205233 OCMStub ([mockBundle objectForInfoDictionaryKey: @" FLTAssetsPath" ]).andReturn (nil );
234+ OCMStub ([mockMainBundle objectForInfoDictionaryKey: @" FLTAssetsPath" ]).andReturn (nil );
206235 NSString * assetsPath = [FlutterDartProject lookupKeyForAsset: @" bar"
207236 fromPackage: @" bar_package"
208237 fromBundle: mockBundle];
209238 // This is testing public API, changing this assert is likely to break plugins.
210239 XCTAssertEqualObjects (assetsPath,
211240 @" Frameworks/App.framework/flutter_assets/packages/bar_package/bar" );
241+ [mockBundle stopMocking ];
212242 }
213243}
214244
0 commit comments