add flavor-conditional asset bundling support to flutter test (#140944)
Fixes https://github.com/flutter/flutter/issues/140932
This commit is contained in:
@@ -888,6 +888,45 @@ dev_dependencies:
|
||||
DeviceManager: () => _FakeDeviceManager(<Device>[]),
|
||||
});
|
||||
|
||||
testUsingContext('builds asset bundle using --flavor', () async {
|
||||
final FakeFlutterTestRunner testRunner = FakeFlutterTestRunner(0);
|
||||
fs.file('vanilla.txt').writeAsStringSync('vanilla');
|
||||
fs.file('orange.txt').writeAsStringSync('orange');
|
||||
fs.file('pubspec.yaml').writeAsStringSync('''
|
||||
flutter:
|
||||
assets:
|
||||
- path: vanilla.txt
|
||||
flavors:
|
||||
- vanilla
|
||||
- path: orange.txt
|
||||
flavors:
|
||||
- orange
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
integration_test:
|
||||
sdk: flutter''');
|
||||
final TestCommand testCommand = TestCommand(testRunner: testRunner);
|
||||
final CommandRunner<void> commandRunner = createTestCommandRunner(testCommand);
|
||||
|
||||
await commandRunner.run(const <String>[
|
||||
'test',
|
||||
'--no-pub',
|
||||
'--flavor',
|
||||
'vanilla',
|
||||
]);
|
||||
|
||||
final bool vanillaExists = await fs.isFile(globals.fs.path.join('build', 'unit_test_assets', 'vanilla.txt'));
|
||||
expect(vanillaExists, true, reason: 'vanilla.txt should be bundled');
|
||||
final bool orangeExists = await fs.isFile(globals.fs.path.join('build', 'unit_test_assets', 'orange.txt'));
|
||||
expect(orangeExists, false, reason: 'orange.txt should not be bundled');
|
||||
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
DeviceManager: () => _FakeDeviceManager(<Device>[]),
|
||||
});
|
||||
|
||||
testUsingContext("Don't build the asset manifest if --no-test-assets if informed", () async {
|
||||
final FakeFlutterTestRunner testRunner = FakeFlutterTestRunner(0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user