Unverified Commit 4a010665 authored by Chris Bracken's avatar Chris Bracken Committed by GitHub

Migrate hot reload tests to Dart 2 (#21290)

parent 4d0f09a2
......@@ -47,9 +47,10 @@ class FlutterDevice {
this.dillOutputPath,
this.fileSystemRoots,
this.fileSystemScheme,
ResidentCompiler generator,
}) {
if (previewDart2) {
generator = new ResidentCompiler(
this.generator = generator ?? new ResidentCompiler(
artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath),
trackWidgetCreation: trackWidgetCreation,
fileSystemRoots: fileSystemRoots, fileSystemScheme: fileSystemScheme
......
......@@ -4,6 +4,7 @@
import 'dart:async';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/resident_runner.dart';
import 'package:flutter_tools/src/run_hot.dart';
......@@ -12,6 +13,7 @@ import 'package:mockito/mockito.dart';
import 'src/common.dart';
import 'src/context.dart';
import 'src/mocks.dart';
void main() {
group('validateReloadReport', () {
......@@ -91,34 +93,41 @@ void main() {
});
group('hotRestart', () {
final List<FlutterDevice> devices = <FlutterDevice>[];
final MockResidentCompiler residentCompiler = new MockResidentCompiler();
MockLocalEngineArtifacts mockArtifacts;
setUp(() {
devices.add(new FlutterDevice(new MockDevice(),
previewDart2: false, trackWidgetCreation: false));
mockArtifacts = new MockLocalEngineArtifacts();
when(mockArtifacts.getArtifactPath(Artifact.flutterPatchedSdkPath)).thenReturn('some/path');
});
testUsingContext('no setup', () async {
expect((await new HotRunner(devices).restart(fullRestart: true)).isOk,
true);
final List<FlutterDevice> devices = <FlutterDevice>[new FlutterDevice(new MockDevice(), generator: residentCompiler, trackWidgetCreation: false, previewDart2: true)];
expect((await new HotRunner(devices).restart(fullRestart: true)).isOk, true);
}, overrides: <Type, Generator>{
Artifacts: () => mockArtifacts,
});
testUsingContext('setup function succeeds', () async {
expect((await new HotRunner(devices).restart(fullRestart: true)).isOk,
true);
final List<FlutterDevice> devices = <FlutterDevice>[new FlutterDevice(new MockDevice(), generator: residentCompiler, trackWidgetCreation: false, previewDart2: true)];
expect((await new HotRunner(devices).restart(fullRestart: true)).isOk, true);
}, overrides: <Type, Generator>{
Artifacts: () => mockArtifacts,
HotRunnerConfig: () => new TestHotRunnerConfig(successfulSetup: true),
});
testUsingContext('setup function fails', () async {
expect((await new HotRunner(devices).restart(fullRestart: true)).isOk,
false);
final List<FlutterDevice> devices = <FlutterDevice>[new FlutterDevice(new MockDevice(), generator: residentCompiler, trackWidgetCreation: false, previewDart2: true)];
expect((await new HotRunner(devices).restart(fullRestart: true)).isOk, false);
}, overrides: <Type, Generator>{
Artifacts: () => mockArtifacts,
HotRunnerConfig: () => new TestHotRunnerConfig(successfulSetup: false),
});
});
}
class MockLocalEngineArtifacts extends Mock implements LocalEngineArtifacts {}
class MockDevice extends Mock implements Device {
MockDevice() {
when(isSupported()).thenReturn(true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment