[flutter_tools] even more test fixes (#60156)
Fix tests broken under tester
This commit is contained in:
parent
61b93d25bb
commit
5d61bff294
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter_tools/src/artifacts.dart';
|
||||||
import 'package:flutter_tools/src/build_info.dart';
|
import 'package:flutter_tools/src/build_info.dart';
|
||||||
import 'package:flutter_tools/src/device.dart';
|
import 'package:flutter_tools/src/device.dart';
|
||||||
import 'package:flutter_tools/src/base/io.dart';
|
import 'package:flutter_tools/src/base/io.dart';
|
||||||
@ -25,6 +26,8 @@ void main() {
|
|||||||
final List<Device> devices = <Device>[device1, device2, device3];
|
final List<Device> devices = <Device>[device1, device2, device3];
|
||||||
final DeviceManager deviceManager = TestDeviceManager(devices);
|
final DeviceManager deviceManager = TestDeviceManager(devices);
|
||||||
expect(await deviceManager.getDevices(), devices);
|
expect(await deviceManager.getDevices(), devices);
|
||||||
|
}, overrides: <Type, Generator>{
|
||||||
|
Artifacts: () => Artifacts.test(),
|
||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext('getDeviceById', () async {
|
testUsingContext('getDeviceById', () async {
|
||||||
@ -43,6 +46,8 @@ void main() {
|
|||||||
await expectDevice('Nexus 5', <Device>[device1]);
|
await expectDevice('Nexus 5', <Device>[device1]);
|
||||||
await expectDevice('0553790', <Device>[device1]);
|
await expectDevice('0553790', <Device>[device1]);
|
||||||
await expectDevice('Nexus', <Device>[device1, device2]);
|
await expectDevice('Nexus', <Device>[device1, device2]);
|
||||||
|
}, overrides: <Type, Generator>{
|
||||||
|
Artifacts: () => Artifacts.test(),
|
||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext('getAllConnectedDevices caches', () async {
|
testUsingContext('getAllConnectedDevices caches', () async {
|
||||||
@ -53,6 +58,8 @@ void main() {
|
|||||||
final FakeDevice device2 = FakeDevice('Nexus 5X', '01abfc49119c410e');
|
final FakeDevice device2 = FakeDevice('Nexus 5X', '01abfc49119c410e');
|
||||||
deviceManager.resetDevices(<Device>[device2]);
|
deviceManager.resetDevices(<Device>[device2]);
|
||||||
expect(await deviceManager.getAllConnectedDevices(), <Device>[device1]);
|
expect(await deviceManager.getAllConnectedDevices(), <Device>[device1]);
|
||||||
|
}, overrides: <Type, Generator>{
|
||||||
|
Artifacts: () => Artifacts.test(),
|
||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext('refreshAllConnectedDevices does not cache', () async {
|
testUsingContext('refreshAllConnectedDevices does not cache', () async {
|
||||||
@ -63,6 +70,8 @@ void main() {
|
|||||||
final FakeDevice device2 = FakeDevice('Nexus 5X', '01abfc49119c410e');
|
final FakeDevice device2 = FakeDevice('Nexus 5X', '01abfc49119c410e');
|
||||||
deviceManager.resetDevices(<Device>[device2]);
|
deviceManager.resetDevices(<Device>[device2]);
|
||||||
expect(await deviceManager.refreshAllConnectedDevices(), <Device>[device2]);
|
expect(await deviceManager.refreshAllConnectedDevices(), <Device>[device2]);
|
||||||
|
}, overrides: <Type, Generator>{
|
||||||
|
Artifacts: () => Artifacts.test(),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -83,6 +92,8 @@ void main() {
|
|||||||
expect(pollingDeviceDiscovery.lastPollingTimeout, const Duration(seconds: 30));
|
expect(pollingDeviceDiscovery.lastPollingTimeout, const Duration(seconds: 30));
|
||||||
await pollingDeviceDiscovery.stopPolling();
|
await pollingDeviceDiscovery.stopPolling();
|
||||||
});
|
});
|
||||||
|
}, overrides: <Type, Generator>{
|
||||||
|
Artifacts: () => Artifacts.test(),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -117,6 +128,8 @@ void main() {
|
|||||||
final List<Device> filtered = await deviceManager.findTargetDevices(FlutterProject.current());
|
final List<Device> filtered = await deviceManager.findTargetDevices(FlutterProject.current());
|
||||||
|
|
||||||
expect(filtered.single, ephemeral);
|
expect(filtered.single, ephemeral);
|
||||||
|
}, overrides: <Type, Generator>{
|
||||||
|
Artifacts: () => Artifacts.test(),
|
||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext('does not remove all non-ephemeral', () async {
|
testUsingContext('does not remove all non-ephemeral', () async {
|
||||||
@ -132,6 +145,8 @@ void main() {
|
|||||||
nonEphemeralOne,
|
nonEphemeralOne,
|
||||||
nonEphemeralTwo,
|
nonEphemeralTwo,
|
||||||
]);
|
]);
|
||||||
|
}, overrides: <Type, Generator>{
|
||||||
|
Artifacts: () => Artifacts.test(),
|
||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext('Removes a single unsupported device', () async {
|
testUsingContext('Removes a single unsupported device', () async {
|
||||||
@ -143,6 +158,8 @@ void main() {
|
|||||||
final List<Device> filtered = await deviceManager.findTargetDevices(FlutterProject.current());
|
final List<Device> filtered = await deviceManager.findTargetDevices(FlutterProject.current());
|
||||||
|
|
||||||
expect(filtered, <Device>[]);
|
expect(filtered, <Device>[]);
|
||||||
|
}, overrides: <Type, Generator>{
|
||||||
|
Artifacts: () => Artifacts.test(),
|
||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext('Removes web and fuchsia from --all', () async {
|
testUsingContext('Removes web and fuchsia from --all', () async {
|
||||||
@ -156,6 +173,8 @@ void main() {
|
|||||||
final List<Device> filtered = await deviceManager.findTargetDevices(FlutterProject.current());
|
final List<Device> filtered = await deviceManager.findTargetDevices(FlutterProject.current());
|
||||||
|
|
||||||
expect(filtered, <Device>[]);
|
expect(filtered, <Device>[]);
|
||||||
|
}, overrides: <Type, Generator>{
|
||||||
|
Artifacts: () => Artifacts.test(),
|
||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext('Removes unsupported devices from --all', () async {
|
testUsingContext('Removes unsupported devices from --all', () async {
|
||||||
@ -173,6 +192,8 @@ void main() {
|
|||||||
nonEphemeralOne,
|
nonEphemeralOne,
|
||||||
nonEphemeralTwo,
|
nonEphemeralTwo,
|
||||||
]);
|
]);
|
||||||
|
}, overrides: <Type, Generator>{
|
||||||
|
Artifacts: () => Artifacts.test(),
|
||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext('uses DeviceManager.isDeviceSupportedForProject instead of device.isSupportedForProject', () async {
|
testUsingContext('uses DeviceManager.isDeviceSupportedForProject instead of device.isSupportedForProject', () async {
|
||||||
@ -187,6 +208,8 @@ void main() {
|
|||||||
expect(filtered, <Device>[
|
expect(filtered, <Device>[
|
||||||
unsupported,
|
unsupported,
|
||||||
]);
|
]);
|
||||||
|
}, overrides: <Type, Generator>{
|
||||||
|
Artifacts: () => Artifacts.test(),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
group('ForwardedPort', () {
|
group('ForwardedPort', () {
|
||||||
|
@ -17,6 +17,7 @@ import 'package:flutter_tools/src/base/os.dart';
|
|||||||
import 'package:flutter_tools/src/base/platform.dart';
|
import 'package:flutter_tools/src/base/platform.dart';
|
||||||
import 'package:flutter_tools/src/base/time.dart';
|
import 'package:flutter_tools/src/base/time.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/device.dart';
|
import 'package:flutter_tools/src/device.dart';
|
||||||
import 'package:flutter_tools/src/fuchsia/amber_ctl.dart';
|
import 'package:flutter_tools/src/fuchsia/amber_ctl.dart';
|
||||||
import 'package:flutter_tools/src/fuchsia/application_package.dart';
|
import 'package:flutter_tools/src/fuchsia/application_package.dart';
|
||||||
@ -791,28 +792,36 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext('Correct flutter runner', () async {
|
testUsingContext('Correct flutter runner', () async {
|
||||||
expect(globals.artifacts.getArtifactPath(
|
final MockCache cache = MockCache();
|
||||||
|
final FileSystem fileSystem = MemoryFileSystem.test();
|
||||||
|
when(cache.getArtifactDirectory('flutter_runner')).thenReturn(fileSystem.directory('fuchsia'));
|
||||||
|
final CachedArtifacts artifacts = CachedArtifacts(
|
||||||
|
cache: cache,
|
||||||
|
fileSystem: fileSystem,
|
||||||
|
platform: FakePlatform(operatingSystem: 'linux'),
|
||||||
|
);
|
||||||
|
expect(artifacts.getArtifactPath(
|
||||||
Artifact.fuchsiaFlutterRunner,
|
Artifact.fuchsiaFlutterRunner,
|
||||||
platform: TargetPlatform.fuchsia_x64,
|
platform: TargetPlatform.fuchsia_x64,
|
||||||
mode: BuildMode.debug,
|
mode: BuildMode.debug,
|
||||||
),
|
),
|
||||||
contains('flutter_jit_runner'),
|
contains('flutter_jit_runner'),
|
||||||
);
|
);
|
||||||
expect(globals.artifacts.getArtifactPath(
|
expect(artifacts.getArtifactPath(
|
||||||
Artifact.fuchsiaFlutterRunner,
|
Artifact.fuchsiaFlutterRunner,
|
||||||
platform: TargetPlatform.fuchsia_x64,
|
platform: TargetPlatform.fuchsia_x64,
|
||||||
mode: BuildMode.profile,
|
mode: BuildMode.profile,
|
||||||
),
|
),
|
||||||
contains('flutter_aot_runner'),
|
contains('flutter_aot_runner'),
|
||||||
);
|
);
|
||||||
expect(globals.artifacts.getArtifactPath(
|
expect(artifacts.getArtifactPath(
|
||||||
Artifact.fuchsiaFlutterRunner,
|
Artifact.fuchsiaFlutterRunner,
|
||||||
platform: TargetPlatform.fuchsia_x64,
|
platform: TargetPlatform.fuchsia_x64,
|
||||||
mode: BuildMode.release,
|
mode: BuildMode.release,
|
||||||
),
|
),
|
||||||
contains('flutter_aot_product_runner'),
|
contains('flutter_aot_product_runner'),
|
||||||
);
|
);
|
||||||
expect(globals.artifacts.getArtifactPath(
|
expect(artifacts.getArtifactPath(
|
||||||
Artifact.fuchsiaFlutterRunner,
|
Artifact.fuchsiaFlutterRunner,
|
||||||
platform: TargetPlatform.fuchsia_x64,
|
platform: TargetPlatform.fuchsia_x64,
|
||||||
mode: BuildMode.jitRelease,
|
mode: BuildMode.jitRelease,
|
||||||
@ -1550,3 +1559,4 @@ class MockFuchsiaSdk extends Mock implements FuchsiaSdk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class MockFuchsiaWorkflow extends Mock implements FuchsiaWorkflow {}
|
class MockFuchsiaWorkflow extends Mock implements FuchsiaWorkflow {}
|
||||||
|
class MockCache extends Mock implements Cache {}
|
||||||
|
@ -4,6 +4,10 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:file/memory.dart';
|
||||||
|
import 'package:flutter_tools/src/base/file_system.dart';
|
||||||
|
import 'package:flutter_tools/src/base/platform.dart';
|
||||||
|
import 'package:flutter_tools/src/dart/package_map.dart';
|
||||||
import 'package:vm_service/vm_service.dart' as vm_service;
|
import 'package:vm_service/vm_service.dart' as vm_service;
|
||||||
import 'package:flutter_tools/src/artifacts.dart';
|
import 'package:flutter_tools/src/artifacts.dart';
|
||||||
import 'package:flutter_tools/src/base/io.dart';
|
import 'package:flutter_tools/src/base/io.dart';
|
||||||
@ -131,7 +135,7 @@ void main() {
|
|||||||
group('hotRestart', () {
|
group('hotRestart', () {
|
||||||
final MockResidentCompiler residentCompiler = MockResidentCompiler();
|
final MockResidentCompiler residentCompiler = MockResidentCompiler();
|
||||||
final MockDevFs mockDevFs = MockDevFs();
|
final MockDevFs mockDevFs = MockDevFs();
|
||||||
MockLocalEngineArtifacts mockArtifacts;
|
FileSystem fileSystem;
|
||||||
|
|
||||||
when(mockDevFs.update(
|
when(mockDevFs.update(
|
||||||
mainUri: anyNamed('mainUri'),
|
mainUri: anyNamed('mainUri'),
|
||||||
@ -155,11 +159,13 @@ void main() {
|
|||||||
when(mockDevFs.lastCompiled).thenReturn(DateTime.now());
|
when(mockDevFs.lastCompiled).thenReturn(DateTime.now());
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
mockArtifacts = MockLocalEngineArtifacts();
|
fileSystem = MemoryFileSystem.test();
|
||||||
when(mockArtifacts.getArtifactPath(Artifact.flutterPatchedSdkPath)).thenReturn('some/path');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext('Does not hot restart when device does not support it', () async {
|
testUsingContext('Does not hot restart when device does not support it', () async {
|
||||||
|
fileSystem.file(globalPackagesPath)
|
||||||
|
..createSync(recursive: true)
|
||||||
|
..writeAsStringSync('\n');
|
||||||
// Setup mocks
|
// Setup mocks
|
||||||
final MockDevice mockDevice = MockDevice();
|
final MockDevice mockDevice = MockDevice();
|
||||||
when(mockDevice.supportsHotReload).thenReturn(true);
|
when(mockDevice.supportsHotReload).thenReturn(true);
|
||||||
@ -174,11 +180,17 @@ void main() {
|
|||||||
expect(result.isOk, false);
|
expect(result.isOk, false);
|
||||||
expect(result.message, 'hotRestart not supported');
|
expect(result.message, 'hotRestart not supported');
|
||||||
}, overrides: <Type, Generator>{
|
}, overrides: <Type, Generator>{
|
||||||
Artifacts: () => mockArtifacts,
|
|
||||||
HotRunnerConfig: () => TestHotRunnerConfig(successfulSetup: true),
|
HotRunnerConfig: () => TestHotRunnerConfig(successfulSetup: true),
|
||||||
|
Artifacts: () => Artifacts.test(),
|
||||||
|
FileSystem: () => fileSystem,
|
||||||
|
Platform: () => FakePlatform(operatingSystem: 'linux'),
|
||||||
|
ProcessManager: () => FakeProcessManager.any(),
|
||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext('Does not hot restart when one of many devices does not support it', () async {
|
testUsingContext('Does not hot restart when one of many devices does not support it', () async {
|
||||||
|
fileSystem.file(globalPackagesPath)
|
||||||
|
..createSync(recursive: true)
|
||||||
|
..writeAsStringSync('\n');
|
||||||
// Setup mocks
|
// Setup mocks
|
||||||
final MockDevice mockDevice = MockDevice();
|
final MockDevice mockDevice = MockDevice();
|
||||||
final MockDevice mockHotDevice = MockDevice();
|
final MockDevice mockHotDevice = MockDevice();
|
||||||
@ -196,8 +208,11 @@ void main() {
|
|||||||
expect(result.isOk, false);
|
expect(result.isOk, false);
|
||||||
expect(result.message, 'hotRestart not supported');
|
expect(result.message, 'hotRestart not supported');
|
||||||
}, overrides: <Type, Generator>{
|
}, overrides: <Type, Generator>{
|
||||||
Artifacts: () => mockArtifacts,
|
|
||||||
HotRunnerConfig: () => TestHotRunnerConfig(successfulSetup: true),
|
HotRunnerConfig: () => TestHotRunnerConfig(successfulSetup: true),
|
||||||
|
Artifacts: () => Artifacts.test(),
|
||||||
|
FileSystem: () => fileSystem,
|
||||||
|
Platform: () => FakePlatform(operatingSystem: 'linux'),
|
||||||
|
ProcessManager: () => FakeProcessManager.any(),
|
||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext('Does hot restarts when all devices support it', () async {
|
testUsingContext('Does hot restarts when all devices support it', () async {
|
||||||
@ -294,11 +309,17 @@ void main() {
|
|||||||
expect(result.isOk, true);
|
expect(result.isOk, true);
|
||||||
expect(result.message, isNot('hotRestart not supported'));
|
expect(result.message, isNot('hotRestart not supported'));
|
||||||
}, overrides: <Type, Generator>{
|
}, overrides: <Type, Generator>{
|
||||||
Artifacts: () => mockArtifacts,
|
|
||||||
HotRunnerConfig: () => TestHotRunnerConfig(successfulSetup: true),
|
HotRunnerConfig: () => TestHotRunnerConfig(successfulSetup: true),
|
||||||
|
Artifacts: () => Artifacts.test(),
|
||||||
|
FileSystem: () => fileSystem,
|
||||||
|
Platform: () => FakePlatform(operatingSystem: 'linux'),
|
||||||
|
ProcessManager: () => FakeProcessManager.any(),
|
||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext('setup function fails', () async {
|
testUsingContext('setup function fails', () async {
|
||||||
|
fileSystem.file(globalPackagesPath)
|
||||||
|
..createSync(recursive: true)
|
||||||
|
..writeAsStringSync('\n');
|
||||||
final MockDevice mockDevice = MockDevice();
|
final MockDevice mockDevice = MockDevice();
|
||||||
when(mockDevice.supportsHotReload).thenReturn(true);
|
when(mockDevice.supportsHotReload).thenReturn(true);
|
||||||
when(mockDevice.supportsHotRestart).thenReturn(true);
|
when(mockDevice.supportsHotRestart).thenReturn(true);
|
||||||
@ -310,11 +331,17 @@ void main() {
|
|||||||
expect(result.isOk, false);
|
expect(result.isOk, false);
|
||||||
expect(result.message, 'setupHotRestart failed');
|
expect(result.message, 'setupHotRestart failed');
|
||||||
}, overrides: <Type, Generator>{
|
}, overrides: <Type, Generator>{
|
||||||
Artifacts: () => mockArtifacts,
|
|
||||||
HotRunnerConfig: () => TestHotRunnerConfig(successfulSetup: false),
|
HotRunnerConfig: () => TestHotRunnerConfig(successfulSetup: false),
|
||||||
|
Artifacts: () => Artifacts.test(),
|
||||||
|
FileSystem: () => fileSystem,
|
||||||
|
Platform: () => FakePlatform(operatingSystem: 'linux'),
|
||||||
|
ProcessManager: () => FakeProcessManager.any(),
|
||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext('hot restart supported', () async {
|
testUsingContext('hot restart supported', () async {
|
||||||
|
fileSystem.file(globalPackagesPath)
|
||||||
|
..createSync(recursive: true)
|
||||||
|
..writeAsStringSync('\n');
|
||||||
// Setup mocks
|
// Setup mocks
|
||||||
final FakeVmServiceHost fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
|
final FakeVmServiceHost fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
|
||||||
listViews,
|
listViews,
|
||||||
@ -369,8 +396,11 @@ void main() {
|
|||||||
expect(result.isOk, true);
|
expect(result.isOk, true);
|
||||||
expect(result.message, isNot('setupHotRestart failed'));
|
expect(result.message, isNot('setupHotRestart failed'));
|
||||||
}, overrides: <Type, Generator>{
|
}, overrides: <Type, Generator>{
|
||||||
Artifacts: () => mockArtifacts,
|
|
||||||
HotRunnerConfig: () => TestHotRunnerConfig(successfulSetup: true),
|
HotRunnerConfig: () => TestHotRunnerConfig(successfulSetup: true),
|
||||||
|
Artifacts: () => Artifacts.test(),
|
||||||
|
FileSystem: () => fileSystem,
|
||||||
|
Platform: () => FakePlatform(operatingSystem: 'linux'),
|
||||||
|
ProcessManager: () => FakeProcessManager.any(),
|
||||||
});
|
});
|
||||||
|
|
||||||
group('shutdown hook tests', () {
|
group('shutdown hook tests', () {
|
||||||
@ -383,6 +413,9 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext('shutdown hook called after signal', () async {
|
testUsingContext('shutdown hook called after signal', () async {
|
||||||
|
fileSystem.file(globalPackagesPath)
|
||||||
|
..createSync(recursive: true)
|
||||||
|
..writeAsStringSync('\n');
|
||||||
final MockDevice mockDevice = MockDevice();
|
final MockDevice mockDevice = MockDevice();
|
||||||
when(mockDevice.supportsHotReload).thenReturn(true);
|
when(mockDevice.supportsHotReload).thenReturn(true);
|
||||||
when(mockDevice.supportsHotRestart).thenReturn(true);
|
when(mockDevice.supportsHotRestart).thenReturn(true);
|
||||||
@ -393,11 +426,17 @@ void main() {
|
|||||||
await HotRunner(devices).cleanupAfterSignal();
|
await HotRunner(devices).cleanupAfterSignal();
|
||||||
expect(shutdownTestingConfig.shutdownHookCalled, true);
|
expect(shutdownTestingConfig.shutdownHookCalled, true);
|
||||||
}, overrides: <Type, Generator>{
|
}, overrides: <Type, Generator>{
|
||||||
Artifacts: () => mockArtifacts,
|
|
||||||
HotRunnerConfig: () => shutdownTestingConfig,
|
HotRunnerConfig: () => shutdownTestingConfig,
|
||||||
|
Artifacts: () => Artifacts.test(),
|
||||||
|
FileSystem: () => fileSystem,
|
||||||
|
Platform: () => FakePlatform(operatingSystem: 'linux'),
|
||||||
|
ProcessManager: () => FakeProcessManager.any(),
|
||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext('shutdown hook called after app stop', () async {
|
testUsingContext('shutdown hook called after app stop', () async {
|
||||||
|
fileSystem.file(globalPackagesPath)
|
||||||
|
..createSync(recursive: true)
|
||||||
|
..writeAsStringSync('\n');
|
||||||
final MockDevice mockDevice = MockDevice();
|
final MockDevice mockDevice = MockDevice();
|
||||||
when(mockDevice.supportsHotReload).thenReturn(true);
|
when(mockDevice.supportsHotReload).thenReturn(true);
|
||||||
when(mockDevice.supportsHotRestart).thenReturn(true);
|
when(mockDevice.supportsHotRestart).thenReturn(true);
|
||||||
@ -408,21 +447,28 @@ void main() {
|
|||||||
await HotRunner(devices).preExit();
|
await HotRunner(devices).preExit();
|
||||||
expect(shutdownTestingConfig.shutdownHookCalled, true);
|
expect(shutdownTestingConfig.shutdownHookCalled, true);
|
||||||
}, overrides: <Type, Generator>{
|
}, overrides: <Type, Generator>{
|
||||||
Artifacts: () => mockArtifacts,
|
|
||||||
HotRunnerConfig: () => shutdownTestingConfig,
|
HotRunnerConfig: () => shutdownTestingConfig,
|
||||||
|
Artifacts: () => Artifacts.test(),
|
||||||
|
FileSystem: () => fileSystem,
|
||||||
|
Platform: () => FakePlatform(operatingSystem: 'linux'),
|
||||||
|
ProcessManager: () => FakeProcessManager.any(),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
group('hot attach', () {
|
group('hot attach', () {
|
||||||
MockLocalEngineArtifacts mockArtifacts;
|
FileSystem fileSystem;
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
mockArtifacts = MockLocalEngineArtifacts();
|
fileSystem = MemoryFileSystem.test();
|
||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext('Exits with code 2 when when HttpException is thrown '
|
testUsingContext('Exits with code 2 when when HttpException is thrown '
|
||||||
'during VM service connection', () async {
|
'during VM service connection', () async {
|
||||||
|
fileSystem.file(globalPackagesPath)
|
||||||
|
..createSync(recursive: true)
|
||||||
|
..writeAsStringSync('\n');
|
||||||
|
|
||||||
final MockResidentCompiler residentCompiler = MockResidentCompiler();
|
final MockResidentCompiler residentCompiler = MockResidentCompiler();
|
||||||
final MockDevice mockDevice = MockDevice();
|
final MockDevice mockDevice = MockDevice();
|
||||||
when(mockDevice.supportsHotReload).thenReturn(true);
|
when(mockDevice.supportsHotReload).thenReturn(true);
|
||||||
@ -444,8 +490,11 @@ void main() {
|
|||||||
).attach();
|
).attach();
|
||||||
expect(exitCode, 2);
|
expect(exitCode, 2);
|
||||||
}, overrides: <Type, Generator>{
|
}, overrides: <Type, Generator>{
|
||||||
Artifacts: () => mockArtifacts,
|
|
||||||
HotRunnerConfig: () => TestHotRunnerConfig(successfulSetup: true),
|
HotRunnerConfig: () => TestHotRunnerConfig(successfulSetup: true),
|
||||||
|
Artifacts: () => Artifacts.test(),
|
||||||
|
FileSystem: () => fileSystem,
|
||||||
|
Platform: () => FakePlatform(operatingSystem: 'linux'),
|
||||||
|
ProcessManager: () => FakeProcessManager.any(),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -482,8 +531,6 @@ void main() {
|
|||||||
|
|
||||||
class MockDevFs extends Mock implements DevFS {}
|
class MockDevFs extends Mock implements DevFS {}
|
||||||
|
|
||||||
class MockLocalEngineArtifacts extends Mock implements LocalEngineArtifacts {}
|
|
||||||
|
|
||||||
class MockDevice extends Mock implements Device {
|
class MockDevice extends Mock implements Device {
|
||||||
MockDevice() {
|
MockDevice() {
|
||||||
when(isSupported()).thenReturn(true);
|
when(isSupported()).thenReturn(true);
|
||||||
|
@ -92,6 +92,9 @@ void main() {
|
|||||||
);
|
);
|
||||||
mockXcode = MockXcode();
|
mockXcode = MockXcode();
|
||||||
when(mockXcode.isVersionSatisfactory).thenReturn(true);
|
when(mockXcode.isVersionSatisfactory).thenReturn(true);
|
||||||
|
fileSystem.file('foo/.packages')
|
||||||
|
..createSync(recursive: true)
|
||||||
|
..writeAsStringSync('\n');
|
||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext('with buildable app', () async {
|
testUsingContext('with buildable app', () async {
|
||||||
|
@ -37,6 +37,13 @@ class MockXcode extends Mock implements Xcode {}
|
|||||||
class MockSimControl extends Mock implements SimControl {}
|
class MockSimControl extends Mock implements SimControl {}
|
||||||
class MockPlistUtils extends Mock implements PlistParser {}
|
class MockPlistUtils extends Mock implements PlistParser {}
|
||||||
|
|
||||||
|
final Platform macosPlatform = FakePlatform(
|
||||||
|
operatingSystem: 'macos',
|
||||||
|
environment: <String, String>{
|
||||||
|
'HOME': '/'
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
FakePlatform osx;
|
FakePlatform osx;
|
||||||
FileSystemUtils fsUtils;
|
FileSystemUtils fsUtils;
|
||||||
@ -458,12 +465,11 @@ void main() {
|
|||||||
overrides: <Type, Generator>{
|
overrides: <Type, Generator>{
|
||||||
ProcessManager: () => mockProcessManager,
|
ProcessManager: () => mockProcessManager,
|
||||||
FileSystem: () => fileSystem,
|
FileSystem: () => fileSystem,
|
||||||
Platform: () => FakePlatform(
|
Platform: () => macosPlatform,
|
||||||
operatingSystem: 'macos',
|
FileSystemUtils: () => FileSystemUtils(
|
||||||
environment: <String, String>{
|
fileSystem: fileSystem,
|
||||||
'HOME': '/'
|
platform: macosPlatform,
|
||||||
},
|
)
|
||||||
),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext('unified logging with app name', () async {
|
testUsingContext('unified logging with app name', () async {
|
||||||
|
@ -43,7 +43,6 @@ void main() {
|
|||||||
|
|
||||||
void podsIsInHomeDir() {
|
void podsIsInHomeDir() {
|
||||||
fileSystem.directory(fileSystem.path.join(
|
fileSystem.directory(fileSystem.path.join(
|
||||||
globals.fsUtils.homeDirPath,
|
|
||||||
'.cocoapods',
|
'.cocoapods',
|
||||||
'repos',
|
'repos',
|
||||||
'master',
|
'master',
|
||||||
@ -52,7 +51,6 @@ void main() {
|
|||||||
|
|
||||||
String podsIsInCustomDir({String cocoapodsReposDir}) {
|
String podsIsInCustomDir({String cocoapodsReposDir}) {
|
||||||
cocoapodsReposDir ??= fileSystem.path.join(
|
cocoapodsReposDir ??= fileSystem.path.join(
|
||||||
globals.fsUtils.homeDirPath,
|
|
||||||
'cache',
|
'cache',
|
||||||
'cocoapods',
|
'cocoapods',
|
||||||
'repos',
|
'repos',
|
||||||
@ -292,6 +290,9 @@ void main() {
|
|||||||
|
|
||||||
group('Update xcconfig', () {
|
group('Update xcconfig', () {
|
||||||
testUsingContext('includes Pod config in xcconfig files, if the user manually added Pod dependencies without using Flutter plugins', () async {
|
testUsingContext('includes Pod config in xcconfig files, if the user manually added Pod dependencies without using Flutter plugins', () async {
|
||||||
|
globals.fs.file(globals.fs.path.join('project', 'foo', '.packages'))
|
||||||
|
..createSync(recursive: true)
|
||||||
|
..writeAsStringSync('\n');
|
||||||
projectUnderTest.ios.podfile..createSync()..writeAsStringSync('Custom Podfile');
|
projectUnderTest.ios.podfile..createSync()..writeAsStringSync('Custom Podfile');
|
||||||
projectUnderTest.ios.podfileLock..createSync()..writeAsStringSync('Podfile.lock from user executed `pod install`');
|
projectUnderTest.ios.podfileLock..createSync()..writeAsStringSync('Podfile.lock from user executed `pod install`');
|
||||||
projectUnderTest.packagesFile..createSync()..writeAsStringSync('');
|
projectUnderTest.packagesFile..createSync()..writeAsStringSync('');
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_tools/src/cache.dart';
|
import 'package:flutter_tools/src/cache.dart';
|
||||||
|
import 'package:flutter_tools/src/dart/package_map.dart';
|
||||||
import 'package:vm_service/vm_service.dart' as vm_service;
|
import 'package:vm_service/vm_service.dart' as vm_service;
|
||||||
import 'package:file/memory.dart';
|
import 'package:file/memory.dart';
|
||||||
import 'package:file_testing/file_testing.dart';
|
import 'package:file_testing/file_testing.dart';
|
||||||
@ -92,7 +93,7 @@ void main() {
|
|||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
testbed = Testbed(setup: () {
|
testbed = Testbed(setup: () {
|
||||||
globals.fs.file('.packages').writeAsStringSync('\n');
|
globals.fs.file(globalPackagesPath).writeAsStringSync('\n');
|
||||||
globals.fs.file(globals.fs.path.join('build', 'app.dill'))
|
globals.fs.file(globals.fs.path.join('build', 'app.dill'))
|
||||||
..createSync(recursive: true)
|
..createSync(recursive: true)
|
||||||
..writeAsStringSync('ABC');
|
..writeAsStringSync('ABC');
|
||||||
@ -844,6 +845,11 @@ void main() {
|
|||||||
'data': <String, Object>{'A': 'B'}
|
'data': <String, Object>{'A': 'B'}
|
||||||
});
|
});
|
||||||
expect(fakeVmServiceHost.hasRemainingExpectations, false);
|
expect(fakeVmServiceHost.hasRemainingExpectations, false);
|
||||||
|
}, overrides: <Type, Generator>{
|
||||||
|
FileSystemUtils: () => FileSystemUtils(
|
||||||
|
fileSystem: globals.fs,
|
||||||
|
platform: globals.platform,
|
||||||
|
)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
testUsingContext('ResidentRunner can take screenshot on debug device', () => testbed.run(() async {
|
testUsingContext('ResidentRunner can take screenshot on debug device', () => testbed.run(() async {
|
||||||
|
@ -16,6 +16,7 @@ import 'package:flutter_tools/src/build_info.dart';
|
|||||||
import 'package:flutter_tools/src/build_runner/devfs_web.dart';
|
import 'package:flutter_tools/src/build_runner/devfs_web.dart';
|
||||||
import 'package:flutter_tools/src/build_runner/resident_web_runner.dart';
|
import 'package:flutter_tools/src/build_runner/resident_web_runner.dart';
|
||||||
import 'package:flutter_tools/src/compile.dart';
|
import 'package:flutter_tools/src/compile.dart';
|
||||||
|
import 'package:flutter_tools/src/dart/package_map.dart';
|
||||||
import 'package:flutter_tools/src/dart/pub.dart';
|
import 'package:flutter_tools/src/dart/pub.dart';
|
||||||
import 'package:flutter_tools/src/devfs.dart';
|
import 'package:flutter_tools/src/devfs.dart';
|
||||||
import 'package:flutter_tools/src/device.dart';
|
import 'package:flutter_tools/src/device.dart';
|
||||||
@ -115,6 +116,9 @@ void main() {
|
|||||||
});
|
});
|
||||||
testbed = Testbed(
|
testbed = Testbed(
|
||||||
setup: () {
|
setup: () {
|
||||||
|
globals.fs.file(globalPackagesPath)
|
||||||
|
..createSync(recursive: true)
|
||||||
|
..writeAsStringSync('\n');
|
||||||
residentWebRunner = DwdsWebRunnerFactory().createWebRunner(
|
residentWebRunner = DwdsWebRunnerFactory().createWebRunner(
|
||||||
mockFlutterDevice,
|
mockFlutterDevice,
|
||||||
flutterProject: FlutterProject.current(),
|
flutterProject: FlutterProject.current(),
|
||||||
|
@ -43,7 +43,9 @@ void main() {
|
|||||||
MockHttpServer mockHttpServer;
|
MockHttpServer mockHttpServer;
|
||||||
|
|
||||||
setUpAll(() async {
|
setUpAll(() async {
|
||||||
packages = await loadPackageConfigUri(Uri.base.resolve('.packages'));
|
packages = PackageConfig(<Package>[
|
||||||
|
Package('flutter_tools', Uri.file('/flutter_tools/lib/').normalizePath())
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user