Support specifying a fixed list of assets on the command line (#6857)
This commit is contained in:
@@ -15,6 +15,7 @@ import 'analyze_duplicate_names_test.dart' as analyze_duplicate_names_test;
|
||||
import 'analyze_test.dart' as analyze_test;
|
||||
import 'android_device_test.dart' as android_device_test;
|
||||
import 'android_sdk_test.dart' as android_sdk_test;
|
||||
import 'asset_bundle_test.dart' as asset_bundle_test;
|
||||
import 'application_package_test.dart' as application_package_test;
|
||||
import 'base_utils_test.dart' as base_utils_test;
|
||||
import 'channel_test.dart' as channel_test;
|
||||
@@ -49,6 +50,7 @@ void main() {
|
||||
android_device_test.main();
|
||||
android_sdk_test.main();
|
||||
application_package_test.main();
|
||||
asset_bundle_test.main();
|
||||
base_utils_test.main();
|
||||
channel_test.main();
|
||||
config_test.main();
|
||||
|
||||
60
packages/flutter_tools/test/asset_bundle_test.dart
Normal file
60
packages/flutter_tools/test/asset_bundle_test.dart
Normal file
@@ -0,0 +1,60 @@
|
||||
// Copyright 2016 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:io';
|
||||
import 'dart:convert';
|
||||
import 'package:flutter_tools/src/asset.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
// Create a temporary directory and write a single file into it.
|
||||
Directory tempDir = Directory.systemTemp.createTempSync();
|
||||
String projectRoot = tempDir.path;
|
||||
String assetPath = 'banana.txt';
|
||||
String assetContents = 'banana';
|
||||
File tempFile = new File(path.join(projectRoot, assetPath));
|
||||
tempFile.parent.createSync(recursive: true);
|
||||
tempFile.writeAsBytesSync(UTF8.encode(assetContents));
|
||||
|
||||
// Fixed asset bundle tests.
|
||||
group('AssetBundle.fixed', () {
|
||||
test('empty strings', () async {
|
||||
expect(new AssetBundle.fixed(null, null), isNotNull);
|
||||
expect(new AssetBundle.fixed('', ''), isNotNull);
|
||||
expect(new AssetBundle.fixed(null, null).entries, isEmpty);
|
||||
});
|
||||
test('does not need a rebuild', () async {
|
||||
expect(new AssetBundle.fixed(null, null).needsBuild(), isFalse);
|
||||
});
|
||||
test('single entry', () async {
|
||||
AssetBundle ab = new AssetBundle.fixed('', 'apple.txt');
|
||||
expect(ab.entries, isNotEmpty);
|
||||
expect(ab.entries.length, 1);
|
||||
AssetBundleEntry entry = ab.entries.first;
|
||||
expect(entry, isNotNull);
|
||||
expect(entry.archivePath, 'apple.txt');
|
||||
});
|
||||
test('two entries', () async {
|
||||
AssetBundle ab = new AssetBundle.fixed('', 'apple.txt,packages/flutter_gallery_assets/shrine/products/heels.png');
|
||||
expect(ab.entries, isNotEmpty);
|
||||
expect(ab.entries.length, 2);
|
||||
AssetBundleEntry firstEntry = ab.entries.first;
|
||||
expect(firstEntry, isNotNull);
|
||||
expect(firstEntry.archivePath, 'apple.txt');
|
||||
AssetBundleEntry lastEntry = ab.entries.last;
|
||||
expect(lastEntry, isNotNull);
|
||||
expect(lastEntry.archivePath, 'packages/flutter_gallery_assets/shrine/products/heels.png');
|
||||
});
|
||||
test('file contents', () async {
|
||||
AssetBundle ab = new AssetBundle.fixed(projectRoot, assetPath);
|
||||
expect(ab.entries, isNotEmpty);
|
||||
expect(ab.entries.length, 1);
|
||||
AssetBundleEntry entry = ab.entries.first;
|
||||
expect(entry, isNotNull);
|
||||
expect(entry.archivePath, assetPath);
|
||||
expect(assetContents, UTF8.decode(entry.contentsAsBytes()));
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user