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 { ...@@ -47,9 +47,10 @@ class FlutterDevice {
this.dillOutputPath, this.dillOutputPath,
this.fileSystemRoots, this.fileSystemRoots,
this.fileSystemScheme, this.fileSystemScheme,
ResidentCompiler generator,
}) { }) {
if (previewDart2) { if (previewDart2) {
generator = new ResidentCompiler( this.generator = generator ?? new ResidentCompiler(
artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath), artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath),
trackWidgetCreation: trackWidgetCreation, trackWidgetCreation: trackWidgetCreation,
fileSystemRoots: fileSystemRoots, fileSystemScheme: fileSystemScheme fileSystemRoots: fileSystemRoots, fileSystemScheme: fileSystemScheme
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import 'dart:async'; import 'dart:async';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/resident_runner.dart'; import 'package:flutter_tools/src/resident_runner.dart';
import 'package:flutter_tools/src/run_hot.dart'; import 'package:flutter_tools/src/run_hot.dart';
...@@ -12,6 +13,7 @@ import 'package:mockito/mockito.dart'; ...@@ -12,6 +13,7 @@ import 'package:mockito/mockito.dart';
import 'src/common.dart'; import 'src/common.dart';
import 'src/context.dart'; import 'src/context.dart';
import 'src/mocks.dart';
void main() { void main() {
group('validateReloadReport', () { group('validateReloadReport', () {
...@@ -91,34 +93,41 @@ void main() { ...@@ -91,34 +93,41 @@ void main() {
}); });
group('hotRestart', () { group('hotRestart', () {
final List<FlutterDevice> devices = <FlutterDevice>[]; final MockResidentCompiler residentCompiler = new MockResidentCompiler();
MockLocalEngineArtifacts mockArtifacts;
setUp(() { setUp(() {
devices.add(new FlutterDevice(new MockDevice(), mockArtifacts = new MockLocalEngineArtifacts();
previewDart2: false, trackWidgetCreation: false)); when(mockArtifacts.getArtifactPath(Artifact.flutterPatchedSdkPath)).thenReturn('some/path');
}); });
testUsingContext('no setup', () async { testUsingContext('no setup', () async {
expect((await new HotRunner(devices).restart(fullRestart: true)).isOk, final List<FlutterDevice> devices = <FlutterDevice>[new FlutterDevice(new MockDevice(), generator: residentCompiler, trackWidgetCreation: false, previewDart2: true)];
true); expect((await new HotRunner(devices).restart(fullRestart: true)).isOk, true);
}, overrides: <Type, Generator>{
Artifacts: () => mockArtifacts,
}); });
testUsingContext('setup function succeeds', () async { testUsingContext('setup function succeeds', () async {
expect((await new HotRunner(devices).restart(fullRestart: true)).isOk, final List<FlutterDevice> devices = <FlutterDevice>[new FlutterDevice(new MockDevice(), generator: residentCompiler, trackWidgetCreation: false, previewDart2: true)];
true); expect((await new HotRunner(devices).restart(fullRestart: true)).isOk, true);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Artifacts: () => mockArtifacts,
HotRunnerConfig: () => new TestHotRunnerConfig(successfulSetup: true), HotRunnerConfig: () => new TestHotRunnerConfig(successfulSetup: true),
}); });
testUsingContext('setup function fails', () async { testUsingContext('setup function fails', () async {
expect((await new HotRunner(devices).restart(fullRestart: true)).isOk, final List<FlutterDevice> devices = <FlutterDevice>[new FlutterDevice(new MockDevice(), generator: residentCompiler, trackWidgetCreation: false, previewDart2: true)];
false); expect((await new HotRunner(devices).restart(fullRestart: true)).isOk, false);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Artifacts: () => mockArtifacts,
HotRunnerConfig: () => new TestHotRunnerConfig(successfulSetup: false), HotRunnerConfig: () => new TestHotRunnerConfig(successfulSetup: false),
}); });
}); });
} }
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);
......
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