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
3c0a74ef
Commit
3c0a74ef
authored
Jan 17, 2019
by
abykov2
Committed by
Mehmet Fidanboylu
Jan 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding a shutdown hook to HotRunnerConfig (#26604)
parent
33bfa6a7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
1 deletion
+57
-1
run_hot.dart
packages/flutter_tools/lib/src/run_hot.dart
+10
-1
hot_test.dart
packages/flutter_tools/test/hot_test.dart
+47
-0
No files found.
packages/flutter_tools/lib/src/run_hot.dart
View file @
3c0a74ef
...
...
@@ -36,6 +36,11 @@ class HotRunnerConfig {
Future
<
bool
>
setupHotRestart
()
async
{
return
true
;
}
/// A hook for implementations to perform any necessary operations right
/// before the runner is about to be shut down.
Future
<
void
>
runPreShutdownOperations
()
async
{
return
;
}
}
HotRunnerConfig
get
hotRunnerConfig
=>
context
[
HotRunnerConfig
];
...
...
@@ -851,6 +856,7 @@ class HotRunner extends ResidentRunner {
@override
Future
<
void
>
cleanupAfterSignal
()
async
{
await
stopEchoingDeviceLog
();
await
hotRunnerConfig
.
runPreShutdownOperations
();
if
(
_didAttach
)
{
appFinished
();
}
else
{
...
...
@@ -859,7 +865,10 @@ class HotRunner extends ResidentRunner {
}
@override
Future
<
void
>
preStop
()
=>
_cleanupDevFS
();
Future
<
void
>
preStop
()
async
{
await
_cleanupDevFS
();
await
hotRunnerConfig
.
runPreShutdownOperations
();
}
@override
Future
<
void
>
cleanupAtFinish
()
async
{
...
...
packages/flutter_tools/test/hot_test.dart
View file @
3c0a74ef
...
...
@@ -228,6 +228,47 @@ void main() {
Artifacts:
()
=>
mockArtifacts
,
HotRunnerConfig:
()
=>
TestHotRunnerConfig
(
successfulSetup:
true
,
computeDartDependencies:
false
),
});
group
(
'shutdown hook tests'
,
()
{
TestHotRunnerConfig
shutdownTestingConfig
;
setUp
(()
{
shutdownTestingConfig
=
TestHotRunnerConfig
(
successfulSetup:
true
,
computeDartDependencies:
false
,
);
});
testUsingContext
(
'shutdown hook called after signal'
,
()
async
{
final
MockDevice
mockDevice
=
MockDevice
();
when
(
mockDevice
.
supportsHotReload
).
thenReturn
(
true
);
when
(
mockDevice
.
supportsHotRestart
).
thenReturn
(
true
);
when
(
mockDevice
.
supportsStopApp
).
thenReturn
(
false
);
final
List
<
FlutterDevice
>
devices
=
<
FlutterDevice
>[
FlutterDevice
(
mockDevice
,
generator:
residentCompiler
,
trackWidgetCreation:
false
)
];
await
HotRunner
(
devices
).
cleanupAfterSignal
();
expect
(
shutdownTestingConfig
.
shutdownHookCalled
,
true
);
},
overrides:
<
Type
,
Generator
>
{
Artifacts:
()
=>
mockArtifacts
,
HotRunnerConfig:
()
=>
shutdownTestingConfig
,
});
testUsingContext
(
'shutdown hook called after app stop'
,
()
async
{
final
MockDevice
mockDevice
=
MockDevice
();
when
(
mockDevice
.
supportsHotReload
).
thenReturn
(
true
);
when
(
mockDevice
.
supportsHotRestart
).
thenReturn
(
true
);
when
(
mockDevice
.
supportsStopApp
).
thenReturn
(
false
);
final
List
<
FlutterDevice
>
devices
=
<
FlutterDevice
>[
FlutterDevice
(
mockDevice
,
generator:
residentCompiler
,
trackWidgetCreation:
false
)
];
await
HotRunner
(
devices
).
preStop
();
expect
(
shutdownTestingConfig
.
shutdownHookCalled
,
true
);
},
overrides:
<
Type
,
Generator
>
{
Artifacts:
()
=>
mockArtifacts
,
HotRunnerConfig:
()
=>
shutdownTestingConfig
,
});
});
});
}
...
...
@@ -247,9 +288,15 @@ class TestHotRunnerConfig extends HotRunnerConfig {
}
bool
successfulSetup
;
bool
shutdownHookCalled
=
false
;
@override
Future
<
bool
>
setupHotRestart
()
async
{
return
successfulSetup
;
}
@override
Future
<
void
>
runPreShutdownOperations
()
async
{
shutdownHookCalled
=
true
;
}
}
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