Skip to content

Commit cde4f66

Browse files
author
a-wallen
committed
Refactor mechanism to read buildInfo
1 parent ec2580f commit cde4f66

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

packages/flutter_tools/test/commands.shard/hermetic/install_test.dart

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
import 'dart:math';
6+
57
import 'package:file/file.dart';
68
import 'package:file/memory.dart';
79
import 'package:flutter_tools/src/android/android_device.dart';
@@ -107,18 +109,15 @@ void main() {
107109
testUsingContext('Passes flavor to application package.', () async {
108110
const String flavor = 'free';
109111
final InstallCommand command = InstallCommand(verboseHelp: false);
110-
command.applicationPackages = FakeApplicationPackageFactory(
111-
FakeIOSApp(),
112-
getPackageForPlatformInterceptor: (TargetPlatform platform, {File? applicationBinary, BuildInfo? buildInfo}) {
113-
expect(buildInfo, isNotNull);
114-
expect(buildInfo!.flavor, flavor);
115-
},
116-
);
112+
final FakeApplicationPackageFactory fakeAppFactory = FakeApplicationPackageFactory(FakeIOSApp());
113+
command.applicationPackages = fakeAppFactory;
117114

118115
final FakeIOSDevice device = FakeIOSDevice();
119116
testDeviceManager.addDevice(device);
120117

121118
await createTestCommandRunner(command).run(<String>['install', '--flavor', flavor]);
119+
expect(fakeAppFactory.buildInfo, isNotNull);
120+
expect(fakeAppFactory.buildInfo!.flavor, flavor);
122121
}, overrides: <Type, Generator>{
123122
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
124123
FileSystem: () => fileSystem,
@@ -128,16 +127,14 @@ void main() {
128127
}
129128

130129
class FakeApplicationPackageFactory extends Fake implements ApplicationPackageFactory {
131-
FakeApplicationPackageFactory(this.app, { this.getPackageForPlatformInterceptor });
130+
FakeApplicationPackageFactory(this.app);
132131

133132
final ApplicationPackage app;
134-
final void Function(TargetPlatform platform, {BuildInfo? buildInfo, File? applicationBinary})? getPackageForPlatformInterceptor;
133+
BuildInfo? buildInfo;
135134

136135
@override
137136
Future<ApplicationPackage> getPackageForPlatform(TargetPlatform platform, {BuildInfo? buildInfo, File? applicationBinary}) async {
138-
if(getPackageForPlatformInterceptor != null) {
139-
getPackageForPlatformInterceptor!(platform, buildInfo: buildInfo, applicationBinary: applicationBinary);
140-
}
137+
this.buildInfo = buildInfo;
141138
return app;
142139
}
143140
}

0 commit comments

Comments
 (0)