2
2
// Use of this source code is governed by a BSD-style license that can be
3
3
// found in the LICENSE file.
4
4
5
+ import 'dart:math' ;
6
+
5
7
import 'package:file/file.dart' ;
6
8
import 'package:file/memory.dart' ;
7
9
import 'package:flutter_tools/src/android/android_device.dart' ;
@@ -107,18 +109,15 @@ void main() {
107
109
testUsingContext ('Passes flavor to application package.' , () async {
108
110
const String flavor = 'free' ;
109
111
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;
117
114
118
115
final FakeIOSDevice device = FakeIOSDevice ();
119
116
testDeviceManager.addDevice (device);
120
117
121
118
await createTestCommandRunner (command).run (< String > ['install' , '--flavor' , flavor]);
119
+ expect (fakeAppFactory.buildInfo, isNotNull);
120
+ expect (fakeAppFactory.buildInfo! .flavor, flavor);
122
121
}, overrides: < Type , Generator > {
123
122
Cache : () => Cache .test (processManager: FakeProcessManager .any ()),
124
123
FileSystem : () => fileSystem,
@@ -128,16 +127,14 @@ void main() {
128
127
}
129
128
130
129
class FakeApplicationPackageFactory extends Fake implements ApplicationPackageFactory {
131
- FakeApplicationPackageFactory (this .app, { this .getPackageForPlatformInterceptor } );
130
+ FakeApplicationPackageFactory (this .app);
132
131
133
132
final ApplicationPackage app;
134
- final void Function ( TargetPlatform platform, { BuildInfo ? buildInfo, File ? applicationBinary}) ? getPackageForPlatformInterceptor ;
133
+ BuildInfo ? buildInfo;
135
134
136
135
@override
137
136
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;
141
138
return app;
142
139
}
143
140
}
0 commit comments