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
6b17840c
Unverified
Commit
6b17840c
authored
Jul 15, 2019
by
Jonah Williams
Committed by
GitHub
Jul 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't try to flutterExit if isolate is still paused (#36199)
parent
1387e7fe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
1 deletion
+64
-1
resident_runner.dart
packages/flutter_tools/lib/src/resident_runner.dart
+12
-0
resident_runner_test.dart
...lutter_tools/test/general.shard/resident_runner_test.dart
+52
-1
No files found.
packages/flutter_tools/lib/src/resident_runner.dart
View file @
6b17840c
...
@@ -175,8 +175,20 @@ class FlutterDevice {
...
@@ -175,8 +175,20 @@ class FlutterDevice {
if
(
flutterViews
==
null
||
flutterViews
.
isEmpty
)
if
(
flutterViews
==
null
||
flutterViews
.
isEmpty
)
return
;
return
;
final
List
<
Future
<
void
>>
futures
=
<
Future
<
void
>>[];
final
List
<
Future
<
void
>>
futures
=
<
Future
<
void
>>[];
// If any of the flutter views are paused, we might not be able to
// cleanly exit since the service extension may not have been registered.
if
(
flutterViews
.
any
((
FlutterView
view
)
{
return
view
!=
null
&&
view
.
uiIsolate
!=
null
&&
view
.
uiIsolate
.
pauseEvent
.
isPauseEvent
;
}
))
{
await
device
.
stopApp
(
package
);
return
;
}
for
(
FlutterView
view
in
flutterViews
)
{
for
(
FlutterView
view
in
flutterViews
)
{
if
(
view
!=
null
&&
view
.
uiIsolate
!=
null
)
{
if
(
view
!=
null
&&
view
.
uiIsolate
!=
null
)
{
assert
(!
view
.
uiIsolate
.
pauseEvent
.
isPauseEvent
);
futures
.
add
(
view
.
uiIsolate
.
flutterExit
());
futures
.
add
(
view
.
uiIsolate
.
flutterExit
());
}
}
}
}
...
...
packages/flutter_tools/test/general.shard/resident_runner_test.dart
View file @
6b17840c
...
@@ -28,6 +28,7 @@ void main() {
...
@@ -28,6 +28,7 @@ void main() {
MockFlutterView
mockFlutterView
;
MockFlutterView
mockFlutterView
;
ResidentRunner
residentRunner
;
ResidentRunner
residentRunner
;
MockDevice
mockDevice
;
MockDevice
mockDevice
;
MockIsolate
mockIsolate
;
setUp
(()
{
setUp
(()
{
testbed
=
Testbed
(
setup:
()
{
testbed
=
Testbed
(
setup:
()
{
...
@@ -44,6 +45,7 @@ void main() {
...
@@ -44,6 +45,7 @@ void main() {
mockVMService
=
MockVMService
();
mockVMService
=
MockVMService
();
mockDevFS
=
MockDevFS
();
mockDevFS
=
MockDevFS
();
mockFlutterView
=
MockFlutterView
();
mockFlutterView
=
MockFlutterView
();
mockIsolate
=
MockIsolate
();
// DevFS Mocks
// DevFS Mocks
when
(
mockDevFS
.
lastCompiled
).
thenReturn
(
DateTime
(
2000
));
when
(
mockDevFS
.
lastCompiled
).
thenReturn
(
DateTime
(
2000
));
when
(
mockDevFS
.
sources
).
thenReturn
(<
Uri
>[]);
when
(
mockDevFS
.
sources
).
thenReturn
(<
Uri
>[]);
...
@@ -73,7 +75,7 @@ void main() {
...
@@ -73,7 +75,7 @@ void main() {
mockFlutterView
mockFlutterView
]);
]);
when
(
mockFlutterDevice
.
device
).
thenReturn
(
mockDevice
);
when
(
mockFlutterDevice
.
device
).
thenReturn
(
mockDevice
);
when
(
mockFlutterView
.
uiIsolate
).
thenReturn
(
MockIsolate
()
);
when
(
mockFlutterView
.
uiIsolate
).
thenReturn
(
mockIsolate
);
when
(
mockFlutterDevice
.
stopEchoingDeviceLog
()).
thenAnswer
((
Invocation
invocation
)
async
{
});
when
(
mockFlutterDevice
.
stopEchoingDeviceLog
()).
thenAnswer
((
Invocation
invocation
)
async
{
});
when
(
mockFlutterDevice
.
observatoryUris
).
thenReturn
(<
Uri
>[
when
(
mockFlutterDevice
.
observatoryUris
).
thenReturn
(<
Uri
>[
testUri
,
testUri
,
...
@@ -97,6 +99,12 @@ void main() {
...
@@ -97,6 +99,12 @@ void main() {
final
Completer
<
void
>
result
=
Completer
<
void
>.
sync
();
final
Completer
<
void
>
result
=
Completer
<
void
>.
sync
();
return
result
.
future
;
return
result
.
future
;
});
});
when
(
mockIsolate
.
resume
()).
thenAnswer
((
Invocation
invocation
)
{
return
Future
<
Map
<
String
,
Object
>>.
value
(
null
);
});
when
(
mockIsolate
.
flutterExit
()).
thenAnswer
((
Invocation
invocation
)
{
return
Future
<
Map
<
String
,
Object
>>.
value
(
null
);
});
});
});
test
(
'Can attach to device successfully'
,
()
=>
testbed
.
run
(()
async
{
test
(
'Can attach to device successfully'
,
()
=>
testbed
.
run
(()
async
{
...
@@ -203,6 +211,40 @@ void main() {
...
@@ -203,6 +211,40 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
Usage:
()
=>
MockUsage
(),
Usage:
()
=>
MockUsage
(),
}));
}));
group
(
'FlutterDevice'
,
()
{
test
(
'Will not exit a paused isolate'
,
()
=>
testbed
.
run
(()
async
{
final
TestFlutterDevice
flutterDevice
=
TestFlutterDevice
(
mockDevice
,
<
FlutterView
>[
mockFlutterView
],
);
final
MockServiceEvent
mockServiceEvent
=
MockServiceEvent
();
when
(
mockServiceEvent
.
isPauseEvent
).
thenReturn
(
true
);
when
(
mockIsolate
.
pauseEvent
).
thenReturn
(
mockServiceEvent
);
when
(
mockDevice
.
supportsFlutterExit
).
thenReturn
(
true
);
await
flutterDevice
.
exitApps
();
verifyNever
(
mockIsolate
.
flutterExit
());
verify
(
mockDevice
.
stopApp
(
any
)).
called
(
1
);
}));
test
(
'Will exit an un-paused isolate'
,
()
=>
testbed
.
run
(()
async
{
final
TestFlutterDevice
flutterDevice
=
TestFlutterDevice
(
mockDevice
,
<
FlutterView
>
[
mockFlutterView
],
);
final
MockServiceEvent
mockServiceEvent
=
MockServiceEvent
();
when
(
mockServiceEvent
.
isPauseEvent
).
thenReturn
(
false
);
when
(
mockIsolate
.
pauseEvent
).
thenReturn
(
mockServiceEvent
);
when
(
mockDevice
.
supportsFlutterExit
).
thenReturn
(
true
);
await
flutterDevice
.
exitApps
();
verify
(
mockIsolate
.
flutterExit
()).
called
(
1
);
}));
});
});
});
}
}
...
@@ -213,3 +255,12 @@ class MockDevFS extends Mock implements DevFS {}
...
@@ -213,3 +255,12 @@ class MockDevFS extends Mock implements DevFS {}
class
MockIsolate
extends
Mock
implements
Isolate
{}
class
MockIsolate
extends
Mock
implements
Isolate
{}
class
MockDevice
extends
Mock
implements
Device
{}
class
MockDevice
extends
Mock
implements
Device
{}
class
MockUsage
extends
Mock
implements
Usage
{}
class
MockUsage
extends
Mock
implements
Usage
{}
class
MockServiceEvent
extends
Mock
implements
ServiceEvent
{}
class
TestFlutterDevice
extends
FlutterDevice
{
TestFlutterDevice
(
Device
device
,
this
.
views
)
:
super
(
device
,
buildMode:
BuildMode
.
debug
,
trackWidgetCreation:
false
);
@override
final
List
<
FlutterView
>
views
;
}
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