Add a hot reload test that modifies code and verifies it executes (#23725)

This commit is contained in:
Danny Tuppeny
2018-10-30 16:59:49 +00:00
committed by GitHub
parent 06cc1d9ec0
commit a2c9dd8180
3 changed files with 72 additions and 2 deletions

View File

@@ -0,0 +1,54 @@
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter_tools/src/base/file_system.dart';
import '../test_utils.dart';
import 'test_project.dart';
class HotReloadProject extends TestProject {
@override
final String pubspec = '''
name: test
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
''';
@override
final String main = r'''
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
// Do not remove this line, it's uncommented by a test to verify that hot
// reloading worked.
// printHotReloadWorked();
return new MaterialApp( // BREAKPOINT
title: 'Flutter Demo',
home: new Container(),
);
}
}
printHotReloadWorked() {
// The call to this function is uncommented by a test to verify that hot
// reloading worked.
print('(((((RELOAD WORKED)))))');
}
''';
void uncommentHotReloadPrint() {
final String newMainContents = main.replaceAll(
'// printHotReloadWorked();', 'printHotReloadWorked();');
writeFile(fs.path.join(dir.path, 'lib', 'main.dart'), newMainContents);
}
}