Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
a2c9dd81
Unverified
Commit
a2c9dd81
authored
Oct 30, 2018
by
Danny Tuppeny
Committed by
GitHub
Oct 30, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a hot reload test that modifies code and verifies it executes (#23725)
parent
06cc1d9e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
2 deletions
+72
-2
hot_reload_test.dart
packages/flutter_tools/test/integration/hot_reload_test.dart
+17
-2
hot_reload_project.dart
..._tools/test/integration/test_data/hot_reload_project.dart
+54
-0
test_driver.dart
packages/flutter_tools/test/integration/test_driver.dart
+1
-0
No files found.
packages/flutter_tools/test/integration/hot_reload_test.dart
View file @
a2c9dd81
...
...
@@ -2,19 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:async'
;
import
'package:file/file.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:vm_service_client/vm_service_client.dart'
;
import
'../src/common.dart'
;
import
'test_data/
basic
_project.dart'
;
import
'test_data/
hot_reload
_project.dart'
;
import
'test_driver.dart'
;
import
'test_utils.dart'
;
void
main
(
)
{
group
(
'hot'
,
()
{
Directory
tempDir
;
final
BasicProject
_project
=
Basic
Project
();
final
HotReloadProject
_project
=
HotReload
Project
();
FlutterTestDriver
_flutter
;
setUp
(()
async
{
...
...
@@ -33,6 +35,19 @@ void main() {
await
_flutter
.
hotReload
();
});
test
(
'newly added code executes during reload'
,
()
async
{
await
_flutter
.
run
();
_project
.
uncommentHotReloadPrint
();
final
StringBuffer
stdout
=
StringBuffer
();
final
StreamSubscription
<
String
>
sub
=
_flutter
.
stdout
.
listen
(
stdout
.
writeln
);
try
{
await
_flutter
.
hotReload
();
expect
(
stdout
.
toString
(),
contains
(
'(((((RELOAD WORKED)))))'
));
}
finally
{
await
sub
.
cancel
();
}
});
test
(
'restart works without error'
,
()
async
{
await
_flutter
.
run
();
await
_flutter
.
hotRestart
();
...
...
packages/flutter_tools/test/integration/test_data/hot_reload_project.dart
0 → 100644
View file @
a2c9dd81
// 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
);
}
}
packages/flutter_tools/test/integration/test_driver.dart
View file @
a2c9dd81
...
...
@@ -42,6 +42,7 @@ class FlutterTestDriver {
VMServiceClient
vmService
;
String
get
lastErrorInfo
=>
_errorBuffer
.
toString
();
Stream
<
String
>
get
stdout
=>
_stdout
.
stream
;
int
get
vmServicePort
=>
_vmServicePort
;
bool
get
hasExited
=>
_hasExited
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment