Always add a DevFS asset entry for the font manifest (#16650)

The engine expects it to always be there.
This commit is contained in:
Todd Volkert
2018-04-16 21:48:21 -07:00
committed by GitHub
parent 9e0a6107fa
commit c83d24d547
3 changed files with 13 additions and 8 deletions

View File

@@ -204,9 +204,7 @@ class _ManifestAssetBundle implements AssetBundle {
entries[_kAssetManifestJson] = _createAssetManifest(assetVariants);
if (fonts.isNotEmpty)
entries[_kFontManifestJson] = new DevFSStringContent(json.encode(fonts));
entries[_kFontManifestJson] = new DevFSStringContent(json.encode(fonts));
// TODO(ianh): Only do the following line if we've changed packages or if our LICENSE file changed
entries[_kLICENSE] = await _obtainLicenses(packageMap, assetBasePath, reportPackages: reportLicensedPackages);

View File

@@ -123,8 +123,8 @@ $fontsSection
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml');
expect(bundle.entries.length, 2); // LICENSE, AssetManifest
expect(bundle.entries.containsKey('FontManifest.json'), false);
expect(bundle.entries.length, 3); // LICENSE, AssetManifest, FontManifest
expect(bundle.entries.containsKey('FontManifest.json'), isTrue);
});
testUsingContext('App font uses font file from package', () async {

View File

@@ -124,12 +124,16 @@ $assetsSection
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml');
expect(bundle.entries.length, 2); // LICENSE, AssetManifest
expect(bundle.entries.length, 3); // LICENSE, AssetManifest, FontManifest
const String expectedAssetManifest = '{}';
expect(
utf8.decode(await bundle.entries['AssetManifest.json'].contentsAsBytes()),
expectedAssetManifest,
);
expect(
utf8.decode(await bundle.entries['FontManifest.json'].contentsAsBytes()),
'[]',
);
});
testUsingContext('No assets are bundled when the package has an asset that is not listed', () async {
@@ -144,13 +148,16 @@ $assetsSection
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml');
expect(bundle.entries.length, 2); // LICENSE, AssetManifest
expect(bundle.entries.length, 3); // LICENSE, AssetManifest, FontManifest
const String expectedAssetManifest = '{}';
expect(
utf8.decode(await bundle.entries['AssetManifest.json'].contentsAsBytes()),
expectedAssetManifest,
);
expect(
utf8.decode(await bundle.entries['FontManifest.json'].contentsAsBytes()),
'[]',
);
});
testUsingContext('One asset is bundled when the package has and lists one asset its pubspec', () async {