[flutter_tools] remove mocks from run.dart (#83184)
This commit is contained in:
parent
e989d6b1fa
commit
149309013e
@ -18,6 +18,7 @@ import 'package:flutter_tools/src/base/user_messages.dart';
|
|||||||
import 'package:flutter_tools/src/build_info.dart';
|
import 'package:flutter_tools/src/build_info.dart';
|
||||||
import 'package:flutter_tools/src/cache.dart';
|
import 'package:flutter_tools/src/cache.dart';
|
||||||
import 'package:flutter_tools/src/commands/run.dart';
|
import 'package:flutter_tools/src/commands/run.dart';
|
||||||
|
import 'package:flutter_tools/src/devfs.dart';
|
||||||
import 'package:flutter_tools/src/device.dart';
|
import 'package:flutter_tools/src/device.dart';
|
||||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||||
import 'package:flutter_tools/src/project.dart';
|
import 'package:flutter_tools/src/project.dart';
|
||||||
@ -26,7 +27,7 @@ import 'package:flutter_tools/src/resident_runner.dart';
|
|||||||
import 'package:flutter_tools/src/runner/flutter_command.dart';
|
import 'package:flutter_tools/src/runner/flutter_command.dart';
|
||||||
import 'package:flutter_tools/src/vmservice.dart';
|
import 'package:flutter_tools/src/vmservice.dart';
|
||||||
import 'package:meta/meta.dart';
|
import 'package:meta/meta.dart';
|
||||||
import 'package:mockito/mockito.dart';
|
import 'package:test/fake.dart';
|
||||||
import 'package:vm_service/vm_service.dart';
|
import 'package:vm_service/vm_service.dart';
|
||||||
|
|
||||||
import '../../src/common.dart';
|
import '../../src/common.dart';
|
||||||
@ -37,7 +38,7 @@ import '../../src/test_flutter_command_runner.dart';
|
|||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
group('run', () {
|
group('run', () {
|
||||||
MockDeviceManager mockDeviceManager;
|
FakeDeviceManager mockDeviceManager;
|
||||||
FileSystem fileSystem;
|
FileSystem fileSystem;
|
||||||
|
|
||||||
setUpAll(() {
|
setUpAll(() {
|
||||||
@ -45,7 +46,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
mockDeviceManager = MockDeviceManager();
|
mockDeviceManager = FakeDeviceManager();
|
||||||
fileSystem = MemoryFileSystem.test();
|
fileSystem = MemoryFileSystem.test();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -138,42 +139,32 @@ void main() {
|
|||||||
group('run app', () {
|
group('run app', () {
|
||||||
MemoryFileSystem fs;
|
MemoryFileSystem fs;
|
||||||
Artifacts artifacts;
|
Artifacts artifacts;
|
||||||
MockCache mockCache;
|
|
||||||
TestUsage usage;
|
TestUsage usage;
|
||||||
Directory tempDir;
|
|
||||||
|
setUpAll(() {
|
||||||
|
Cache.disableLocking();
|
||||||
|
});
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
artifacts = Artifacts.test();
|
artifacts = Artifacts.test();
|
||||||
mockCache = MockCache();
|
|
||||||
usage = TestUsage();
|
usage = TestUsage();
|
||||||
fs = MemoryFileSystem.test();
|
fs = MemoryFileSystem.test();
|
||||||
|
|
||||||
tempDir = fs.systemTempDirectory.createTempSync('flutter_run_test.');
|
fs.currentDirectory.childFile('pubspec.yaml')
|
||||||
fs.currentDirectory = tempDir;
|
|
||||||
|
|
||||||
tempDir.childFile('pubspec.yaml')
|
|
||||||
.writeAsStringSync('name: flutter_app');
|
.writeAsStringSync('name: flutter_app');
|
||||||
tempDir.childFile('.packages')
|
fs.currentDirectory.childFile('.packages')
|
||||||
.writeAsStringSync('# Generated by pub on 2019-11-25 12:38:01.801784.');
|
.writeAsStringSync('# Generated by pub on 2019-11-25 12:38:01.801784.');
|
||||||
final Directory libDir = tempDir.childDirectory('lib');
|
final Directory libDir = fs.currentDirectory.childDirectory('lib');
|
||||||
libDir.createSync();
|
libDir.createSync();
|
||||||
final File mainFile = libDir.childFile('main.dart');
|
final File mainFile = libDir.childFile('main.dart');
|
||||||
mainFile.writeAsStringSync('void main() {}');
|
mainFile.writeAsStringSync('void main() {}');
|
||||||
|
|
||||||
when(mockDeviceManager.hasSpecifiedDeviceId).thenReturn(false);
|
|
||||||
when(mockDeviceManager.hasSpecifiedAllDevices).thenReturn(false);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext('exits with a user message when no supported devices attached', () async {
|
testUsingContext('exits with a user message when no supported devices attached', () async {
|
||||||
final RunCommand command = RunCommand();
|
final RunCommand command = RunCommand();
|
||||||
|
mockDeviceManager
|
||||||
const List<Device> noDevices = <Device>[];
|
..devices = <Device>[]
|
||||||
when(mockDeviceManager.getDevices()).thenAnswer(
|
..targetDevices = <Device>[];
|
||||||
(Invocation invocation) => Future<List<Device>>.value(noDevices)
|
|
||||||
);
|
|
||||||
when(mockDeviceManager.findTargetDevices(any, timeout: anyNamed('timeout'))).thenAnswer(
|
|
||||||
(Invocation invocation) => Future<List<Device>>.value(noDevices)
|
|
||||||
);
|
|
||||||
|
|
||||||
await expectLater(
|
await expectLater(
|
||||||
() => createTestCommandRunner(command).run(<String>[
|
() => createTestCommandRunner(command).run(<String>[
|
||||||
@ -192,24 +183,18 @@ void main() {
|
|||||||
DeviceManager: () => mockDeviceManager,
|
DeviceManager: () => mockDeviceManager,
|
||||||
FileSystem: () => fs,
|
FileSystem: () => fs,
|
||||||
ProcessManager: () => FakeProcessManager.any(),
|
ProcessManager: () => FakeProcessManager.any(),
|
||||||
|
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
|
||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext('fails when targeted device is not Android with --device-user', () async {
|
testUsingContext('fails when targeted device is not Android with --device-user', () async {
|
||||||
globals.fs.file('pubspec.yaml').createSync();
|
fs.file('pubspec.yaml').createSync();
|
||||||
globals.fs.file('.packages').writeAsStringSync('\n');
|
fs.file('.packages').writeAsStringSync('\n');
|
||||||
globals.fs.file('lib/main.dart').createSync(recursive: true);
|
fs.file('lib/main.dart').createSync(recursive: true);
|
||||||
final FakeDevice device = FakeDevice(isLocalEmulator: true);
|
final FakeDevice device = FakeDevice(isLocalEmulator: true);
|
||||||
when(mockDeviceManager.getAllConnectedDevices()).thenAnswer((Invocation invocation) async {
|
|
||||||
return <Device>[device];
|
mockDeviceManager
|
||||||
});
|
..devices = <Device>[device]
|
||||||
when(mockDeviceManager.getDevices()).thenAnswer((Invocation invocation) async {
|
..targetDevices = <Device>[device];
|
||||||
return <Device>[device];
|
|
||||||
});
|
|
||||||
when(mockDeviceManager.findTargetDevices(any, timeout: anyNamed('timeout'))).thenAnswer((Invocation invocation) async {
|
|
||||||
return <Device>[device];
|
|
||||||
});
|
|
||||||
when(mockDeviceManager.hasSpecifiedAllDevices).thenReturn(false);
|
|
||||||
when(mockDeviceManager.deviceDiscoverers).thenReturn(<DeviceDiscovery>[]);
|
|
||||||
|
|
||||||
final RunCommand command = RunCommand();
|
final RunCommand command = RunCommand();
|
||||||
await expectLater(createTestCommandRunner(command).run(<String>[
|
await expectLater(createTestCommandRunner(command).run(<String>[
|
||||||
@ -219,35 +204,19 @@ void main() {
|
|||||||
'10',
|
'10',
|
||||||
]), throwsToolExit(message: '--device-user is only supported for Android. At least one Android device is required.'));
|
]), throwsToolExit(message: '--device-user is only supported for Android. At least one Android device is required.'));
|
||||||
}, overrides: <Type, Generator>{
|
}, overrides: <Type, Generator>{
|
||||||
FileSystem: () => MemoryFileSystem.test(),
|
FileSystem: () => fs,
|
||||||
ProcessManager: () => FakeProcessManager.any(),
|
ProcessManager: () => FakeProcessManager.any(),
|
||||||
DeviceManager: () => mockDeviceManager,
|
DeviceManager: () => mockDeviceManager,
|
||||||
Stdio: () => FakeStdio(),
|
Stdio: () => FakeStdio(),
|
||||||
|
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
|
||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext('shows unsupported devices when no supported devices are found', () async {
|
testUsingContext('shows unsupported devices when no supported devices are found', () async {
|
||||||
final RunCommand command = RunCommand();
|
final RunCommand command = RunCommand();
|
||||||
|
final FakeDevice mockDevice = FakeDevice(targetPlatform: TargetPlatform.android_arm, isLocalEmulator: true, sdkNameAndVersion: 'api-14');
|
||||||
final MockDevice mockDevice = MockDevice(TargetPlatform.android_arm);
|
mockDeviceManager
|
||||||
when(mockDevice.isLocalEmulator).thenAnswer((Invocation invocation) => Future<bool>.value(true));
|
..devices = <Device>[mockDevice]
|
||||||
when(mockDevice.isSupported()).thenAnswer((Invocation invocation) => true);
|
..targetDevices = <Device>[];
|
||||||
when(mockDevice.supportsFastStart).thenReturn(true);
|
|
||||||
when(mockDevice.id).thenReturn('mock-id');
|
|
||||||
when(mockDevice.name).thenReturn('mock-name');
|
|
||||||
when(mockDevice.platformType).thenReturn(PlatformType.android);
|
|
||||||
when(mockDevice.targetPlatformDisplayName)
|
|
||||||
.thenAnswer((Invocation invocation) async => 'mock-platform');
|
|
||||||
when(mockDevice.sdkNameAndVersion).thenAnswer((Invocation invocation) => Future<String>.value('api-14'));
|
|
||||||
|
|
||||||
when(mockDeviceManager.getDevices()).thenAnswer((Invocation invocation) {
|
|
||||||
return Future<List<Device>>.value(<Device>[
|
|
||||||
mockDevice,
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
when(mockDeviceManager.findTargetDevices(any, timeout: anyNamed('timeout'))).thenAnswer(
|
|
||||||
(Invocation invocation) => Future<List<Device>>.value(<Device>[]),
|
|
||||||
);
|
|
||||||
|
|
||||||
await expectLater(
|
await expectLater(
|
||||||
() => createTestCommandRunner(command).run(<String>[
|
() => createTestCommandRunner(command).run(<String>[
|
||||||
@ -278,88 +247,24 @@ void main() {
|
|||||||
DeviceManager: () => mockDeviceManager,
|
DeviceManager: () => mockDeviceManager,
|
||||||
FileSystem: () => fs,
|
FileSystem: () => fs,
|
||||||
ProcessManager: () => FakeProcessManager.any(),
|
ProcessManager: () => FakeProcessManager.any(),
|
||||||
});
|
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
|
||||||
|
|
||||||
testUsingContext('updates cache before checking for devices', () async {
|
|
||||||
final RunCommand command = RunCommand();
|
|
||||||
|
|
||||||
// Called as part of requiredArtifacts()
|
|
||||||
when(mockDeviceManager.getDevices()).thenAnswer(
|
|
||||||
(Invocation invocation) => Future<List<Device>>.value(<Device>[])
|
|
||||||
);
|
|
||||||
// No devices are attached, we just want to verify update the cache
|
|
||||||
// BEFORE checking for devices
|
|
||||||
const Duration timeout = Duration(seconds: 10);
|
|
||||||
when(mockDeviceManager.findTargetDevices(any, timeout: timeout)).thenAnswer(
|
|
||||||
(Invocation invocation) => Future<List<Device>>.value(<Device>[])
|
|
||||||
);
|
|
||||||
|
|
||||||
try {
|
|
||||||
await createTestCommandRunner(command).run(<String>[
|
|
||||||
'run',
|
|
||||||
'--no-pub',
|
|
||||||
'--device-timeout',
|
|
||||||
'10',
|
|
||||||
]);
|
|
||||||
fail('Exception expected');
|
|
||||||
} on ToolExit catch (e) {
|
|
||||||
// We expect a ToolExit because no devices are attached
|
|
||||||
expect(e.message, null);
|
|
||||||
} on Exception catch (e) {
|
|
||||||
fail('ToolExit expected, got $e');
|
|
||||||
}
|
|
||||||
|
|
||||||
verifyInOrder(<void>[
|
|
||||||
// cache update
|
|
||||||
mockCache.updateAll(<DevelopmentArtifact>{DevelopmentArtifact.universal}),
|
|
||||||
// as part of gathering `requiredArtifacts`
|
|
||||||
mockDeviceManager.getDevices(),
|
|
||||||
// in validateCommand()
|
|
||||||
mockDeviceManager.findTargetDevices(any, timeout: anyNamed('timeout')),
|
|
||||||
]);
|
|
||||||
}, overrides: <Type, Generator>{
|
|
||||||
Cache: () => mockCache,
|
|
||||||
DeviceManager: () => mockDeviceManager,
|
|
||||||
FileSystem: () => fs,
|
|
||||||
ProcessManager: () => FakeProcessManager.any(),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext('passes device target platform to usage', () async {
|
testUsingContext('passes device target platform to usage', () async {
|
||||||
final RunCommand command = RunCommand();
|
final RunCommand command = RunCommand();
|
||||||
final MockDevice mockDevice = MockDevice(TargetPlatform.ios);
|
final FakeDevice mockDevice = FakeDevice(targetPlatform: TargetPlatform.ios, sdkNameAndVersion: 'iOS 13')
|
||||||
when(mockDevice.supportsRuntimeMode(any)).thenAnswer((Invocation invocation) => true);
|
..startAppSuccess = false;
|
||||||
when(mockDevice.isLocalEmulator).thenAnswer((Invocation invocation) => Future<bool>.value(false));
|
|
||||||
when(mockDevice.getLogReader(app: anyNamed('app'))).thenReturn(FakeDeviceLogReader());
|
|
||||||
when(mockDevice.supportsFastStart).thenReturn(true);
|
|
||||||
when(mockDevice.sdkNameAndVersion).thenAnswer((Invocation invocation) => Future<String>.value('iOS 13'));
|
|
||||||
// App fails to start because we're only interested in usage
|
|
||||||
when(mockDevice.startApp(
|
|
||||||
any,
|
|
||||||
mainPath: anyNamed('mainPath'),
|
|
||||||
debuggingOptions: anyNamed('debuggingOptions'),
|
|
||||||
platformArgs: anyNamed('platformArgs'),
|
|
||||||
route: anyNamed('route'),
|
|
||||||
prebuiltApplication: anyNamed('prebuiltApplication'),
|
|
||||||
ipv6: anyNamed('ipv6'),
|
|
||||||
userIdentifier: anyNamed('userIdentifier'),
|
|
||||||
)).thenAnswer((Invocation invocation) => Future<LaunchResult>.value(LaunchResult.failed()));
|
|
||||||
|
|
||||||
when(mockDeviceManager.getDevices()).thenAnswer(
|
mockDeviceManager
|
||||||
(Invocation invocation) => Future<List<Device>>.value(<Device>[mockDevice])
|
..devices = <Device>[
|
||||||
);
|
mockDevice,
|
||||||
|
]
|
||||||
|
..targetDevices = <Device>[
|
||||||
|
mockDevice,
|
||||||
|
];
|
||||||
|
|
||||||
when(mockDeviceManager.findTargetDevices(any, timeout: anyNamed('timeout'))).thenAnswer(
|
// Causes swift to be detected in the analytics.
|
||||||
(Invocation invocation) => Future<List<Device>>.value(<Device>[mockDevice])
|
fs.currentDirectory.childDirectory('ios').childFile('AppDelegate.swift').createSync(recursive: true);
|
||||||
);
|
|
||||||
|
|
||||||
final Directory tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_run_test.');
|
|
||||||
tempDir.childDirectory('ios').childFile('AppDelegate.swift').createSync(recursive: true);
|
|
||||||
tempDir.childFile('.packages').createSync();
|
|
||||||
tempDir.childDirectory('lib').childFile('main.dart').createSync(recursive: true);
|
|
||||||
tempDir.childFile('pubspec.yaml')
|
|
||||||
..createSync()
|
|
||||||
..writeAsStringSync('# Hello, World');
|
|
||||||
globals.fs.currentDirectory = tempDir;
|
|
||||||
|
|
||||||
await expectToolExitLater(createTestCommandRunner(command).run(<String>[
|
await expectToolExitLater(createTestCommandRunner(command).run(<String>[
|
||||||
'run',
|
'run',
|
||||||
@ -384,34 +289,24 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext('should only request artifacts corresponding to connected devices', () async {
|
testUsingContext('should only request artifacts corresponding to connected devices', () async {
|
||||||
when(mockDeviceManager.getDevices()).thenAnswer((Invocation invocation) {
|
mockDeviceManager.devices = <Device>[FakeDevice(targetPlatform: TargetPlatform.android_arm)];
|
||||||
return Future<List<Device>>.value(<Device>[
|
|
||||||
MockDevice(TargetPlatform.android_arm),
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(await RunCommand().requiredArtifacts, unorderedEquals(<DevelopmentArtifact>{
|
expect(await RunCommand().requiredArtifacts, unorderedEquals(<DevelopmentArtifact>{
|
||||||
DevelopmentArtifact.universal,
|
DevelopmentArtifact.universal,
|
||||||
DevelopmentArtifact.androidGenSnapshot,
|
DevelopmentArtifact.androidGenSnapshot,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
when(mockDeviceManager.getDevices()).thenAnswer((Invocation invocation) {
|
mockDeviceManager.devices = <Device>[FakeDevice(targetPlatform: TargetPlatform.ios)];
|
||||||
return Future<List<Device>>.value(<Device>[
|
|
||||||
MockDevice(TargetPlatform.ios),
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(await RunCommand().requiredArtifacts, unorderedEquals(<DevelopmentArtifact>{
|
expect(await RunCommand().requiredArtifacts, unorderedEquals(<DevelopmentArtifact>{
|
||||||
DevelopmentArtifact.universal,
|
DevelopmentArtifact.universal,
|
||||||
DevelopmentArtifact.iOS,
|
DevelopmentArtifact.iOS,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
when(mockDeviceManager.getDevices()).thenAnswer((Invocation invocation) {
|
mockDeviceManager.devices = <Device>[
|
||||||
return Future<List<Device>>.value(<Device>[
|
FakeDevice(targetPlatform: TargetPlatform.ios),
|
||||||
MockDevice(TargetPlatform.ios),
|
FakeDevice(targetPlatform: TargetPlatform.android_arm),
|
||||||
MockDevice(TargetPlatform.android_arm),
|
];
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(await RunCommand().requiredArtifacts, unorderedEquals(<DevelopmentArtifact>{
|
expect(await RunCommand().requiredArtifacts, unorderedEquals(<DevelopmentArtifact>{
|
||||||
DevelopmentArtifact.universal,
|
DevelopmentArtifact.universal,
|
||||||
@ -419,11 +314,9 @@ void main() {
|
|||||||
DevelopmentArtifact.androidGenSnapshot,
|
DevelopmentArtifact.androidGenSnapshot,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
when(mockDeviceManager.getDevices()).thenAnswer((Invocation invocation) {
|
mockDeviceManager.devices = <Device>[
|
||||||
return Future<List<Device>>.value(<Device>[
|
FakeDevice(targetPlatform: TargetPlatform.web_javascript),
|
||||||
MockDevice(TargetPlatform.web_javascript),
|
];
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(await RunCommand().requiredArtifacts, unorderedEquals(<DevelopmentArtifact>{
|
expect(await RunCommand().requiredArtifacts, unorderedEquals(<DevelopmentArtifact>{
|
||||||
DevelopmentArtifact.universal,
|
DevelopmentArtifact.universal,
|
||||||
@ -431,6 +324,9 @@ void main() {
|
|||||||
}));
|
}));
|
||||||
}, overrides: <Type, Generator>{
|
}, overrides: <Type, Generator>{
|
||||||
DeviceManager: () => mockDeviceManager,
|
DeviceManager: () => mockDeviceManager,
|
||||||
|
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
|
||||||
|
FileSystem: () => MemoryFileSystem.test(),
|
||||||
|
ProcessManager: () => FakeProcessManager.any(),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -485,6 +381,10 @@ void main() {
|
|||||||
'run',
|
'run',
|
||||||
'--no-pub',
|
'--no-pub',
|
||||||
]), contains('Lost connection to device.'));
|
]), contains('Lost connection to device.'));
|
||||||
|
}, overrides: <Type, Generator>{
|
||||||
|
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
|
||||||
|
FileSystem: () => MemoryFileSystem.test(),
|
||||||
|
ProcessManager: () => FakeProcessManager.any(),
|
||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext('Flutter run does not catch other RPC errors', () async {
|
testUsingContext('Flutter run does not catch other RPC errors', () async {
|
||||||
@ -497,6 +397,10 @@ void main() {
|
|||||||
'run',
|
'run',
|
||||||
'--no-pub',
|
'--no-pub',
|
||||||
]), throwsA(isA<RPCError>()));
|
]), throwsA(isA<RPCError>()));
|
||||||
|
}, overrides: <Type, Generator>{
|
||||||
|
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
|
||||||
|
FileSystem: () => MemoryFileSystem.test(),
|
||||||
|
ProcessManager: () => FakeProcessManager.any(),
|
||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext('Passes sksl bundle info the build options', () async {
|
testUsingContext('Passes sksl bundle info the build options', () async {
|
||||||
@ -507,6 +411,10 @@ void main() {
|
|||||||
'--no-pub',
|
'--no-pub',
|
||||||
'--bundle-sksl-path=foo.json',
|
'--bundle-sksl-path=foo.json',
|
||||||
]), throwsToolExit(message: 'No SkSL shader bundle found at foo.json'));
|
]), throwsToolExit(message: 'No SkSL shader bundle found at foo.json'));
|
||||||
|
}, overrides: <Type, Generator>{
|
||||||
|
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
|
||||||
|
FileSystem: () => MemoryFileSystem.test(),
|
||||||
|
ProcessManager: () => FakeProcessManager.any(),
|
||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext('Configures web connection options to use web sockets by default', () async {
|
testUsingContext('Configures web connection options to use web sockets by default', () async {
|
||||||
@ -521,21 +429,38 @@ void main() {
|
|||||||
expect(options.webUseSseForDebugBackend, false);
|
expect(options.webUseSseForDebugBackend, false);
|
||||||
expect(options.webUseSseForDebugProxy, false);
|
expect(options.webUseSseForDebugProxy, false);
|
||||||
expect(options.webUseSseForInjectedClient, false);
|
expect(options.webUseSseForInjectedClient, false);
|
||||||
|
}, overrides: <Type, Generator>{
|
||||||
|
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
|
||||||
|
FileSystem: () => MemoryFileSystem.test(),
|
||||||
|
ProcessManager: () => FakeProcessManager.any(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
class MockCache extends Mock implements Cache {}
|
class FakeDeviceManager extends Fake implements DeviceManager {
|
||||||
|
List<Device> devices = <Device>[];
|
||||||
class MockDeviceManager extends Mock implements DeviceManager {}
|
List<Device> targetDevices = <Device>[];
|
||||||
class MockDevice extends Mock implements Device {
|
|
||||||
MockDevice(this._targetPlatform);
|
|
||||||
|
|
||||||
final TargetPlatform _targetPlatform;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<TargetPlatform> get targetPlatform async => Future<TargetPlatform>.value(_targetPlatform);
|
String specifiedDeviceId;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool hasSpecifiedAllDevices = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool hasSpecifiedDeviceId = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<List<Device>> getDevices() async {
|
||||||
|
return devices;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<List<Device>> findTargetDevices(FlutterProject flutterProject, {Duration timeout}) async {
|
||||||
|
return targetDevices;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class TestRunCommand extends RunCommand {
|
class TestRunCommand extends RunCommand {
|
||||||
@override
|
@override
|
||||||
// ignore: must_call_super
|
// ignore: must_call_super
|
||||||
@ -545,13 +470,19 @@ class TestRunCommand extends RunCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class FakeDevice extends Fake implements Device {
|
class FakeDevice extends Fake implements Device {
|
||||||
FakeDevice({bool isLocalEmulator = false})
|
FakeDevice({bool isLocalEmulator = false, TargetPlatform targetPlatform = TargetPlatform.ios, String sdkNameAndVersion = ''})
|
||||||
: _isLocalEmulator = isLocalEmulator;
|
: _isLocalEmulator = isLocalEmulator,
|
||||||
|
_targetPlatform = targetPlatform,
|
||||||
|
_sdkNameAndVersion = sdkNameAndVersion;
|
||||||
|
|
||||||
static const int kSuccess = 1;
|
static const int kSuccess = 1;
|
||||||
static const int kFailure = -1;
|
static const int kFailure = -1;
|
||||||
final TargetPlatform _targetPlatform = TargetPlatform.ios;
|
final TargetPlatform _targetPlatform;
|
||||||
final bool _isLocalEmulator;
|
final bool _isLocalEmulator;
|
||||||
|
final String _sdkNameAndVersion;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Category get category => Category.mobile;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get id => 'fake_device';
|
String get id => 'fake_device';
|
||||||
@ -570,8 +501,20 @@ class FakeDevice extends Fake implements Device {
|
|||||||
@override
|
@override
|
||||||
bool get supportsFastStart => false;
|
bool get supportsFastStart => false;
|
||||||
|
|
||||||
|
bool supported = true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<String> get sdkNameAndVersion => Future<String>.value('');
|
bool isSupportedForProject(FlutterProject flutterProject) => true;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool isSupported() => supported;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<String> get sdkNameAndVersion => Future<String>.value(_sdkNameAndVersion);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<String> get targetPlatformDisplayName async =>
|
||||||
|
getNameForTargetPlatform(await targetPlatform);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
DeviceLogReader getLogReader({
|
DeviceLogReader getLogReader({
|
||||||
@ -590,6 +533,16 @@ class FakeDevice extends Fake implements Device {
|
|||||||
@override
|
@override
|
||||||
final PlatformType platformType = PlatformType.ios;
|
final PlatformType platformType = PlatformType.ios;
|
||||||
|
|
||||||
|
bool startAppSuccess = true;
|
||||||
|
|
||||||
|
@override
|
||||||
|
DevFSWriter createDevFSWriter(
|
||||||
|
covariant ApplicationPackage app,
|
||||||
|
String userIdentifier,
|
||||||
|
) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<LaunchResult> startApp(
|
Future<LaunchResult> startApp(
|
||||||
ApplicationPackage package, {
|
ApplicationPackage package, {
|
||||||
@ -602,6 +555,9 @@ class FakeDevice extends Fake implements Device {
|
|||||||
bool ipv6 = false,
|
bool ipv6 = false,
|
||||||
String userIdentifier,
|
String userIdentifier,
|
||||||
}) async {
|
}) async {
|
||||||
|
if (!startAppSuccess) {
|
||||||
|
return LaunchResult.failed();
|
||||||
|
}
|
||||||
final String dartFlags = debuggingOptions.dartFlags;
|
final String dartFlags = debuggingOptions.dartFlags;
|
||||||
// In release mode, --dart-flags should be set to the empty string and
|
// In release mode, --dart-flags should be set to the empty string and
|
||||||
// provided flags should be dropped. In debug and profile modes,
|
// provided flags should be dropped. In debug and profile modes,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user