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
a317c2c0
Unverified
Commit
a317c2c0
authored
Jul 29, 2020
by
Lau Ching Jun
Committed by
GitHub
Jul 29, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wrap launching devtools in DevtoolsLauncher (#62364)
parent
78efd3eb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
20 deletions
+51
-20
resident_runner.dart
packages/flutter_tools/lib/src/resident_runner.dart
+36
-20
resident_runner_test.dart
...lutter_tools/test/general.shard/resident_runner_test.dart
+15
-0
No files found.
packages/flutter_tools/lib/src/resident_runner.dart
View file @
a317c2c0
...
...
@@ -14,6 +14,7 @@ import 'artifacts.dart';
import
'asset.dart'
;
import
'base/command_help.dart'
;
import
'base/common.dart'
;
import
'base/context.dart'
;
import
'base/file_system.dart'
;
import
'base/io.dart'
as
io
;
import
'base/logger.dart'
;
...
...
@@ -799,7 +800,7 @@ abstract class ResidentRunner {
final
CommandHelp
commandHelp
;
final
bool
machine
;
io
.
HttpServer
_devtoolsServ
er
;
DevtoolsLauncher
_devtoolsLaunch
er
;
bool
_exited
=
false
;
Completer
<
int
>
_finished
=
Completer
<
int
>();
...
...
@@ -1254,28 +1255,14 @@ abstract class ResidentRunner {
}
Future
<
void
>
launchDevTools
()
async
{
try
{
assert
(
supportsServiceProtocol
);
_devtoolsServer
??=
await
devtools_server
.
serveDevTools
(
enableStdinCommands:
false
,
);
await
devtools_server
.
launchDevTools
(
<
String
,
dynamic
>{
'reuseWindows'
:
true
,
},
flutterDevices
.
first
.
vmService
.
httpAddress
,
'http://
${_devtoolsServer.address.host}
:
${_devtoolsServer.port}
'
,
false
,
// headless mode,
false
,
// machine mode
);
}
on
Exception
catch
(
e
,
st
)
{
globals
.
printTrace
(
'Failed to launch DevTools:
$e
\n
$st
'
);
}
assert
(
supportsServiceProtocol
);
_devtoolsLauncher
??=
DevtoolsLauncher
.
instance
;
return
_devtoolsLauncher
.
launch
(
flutterDevices
.
first
.
vmService
.
httpAddress
);
}
Future
<
void
>
shutdownDevtools
()
async
{
await
_devtools
Serv
er
?.
close
();
_devtools
Serv
er
=
null
;
await
_devtools
Launch
er
?.
close
();
_devtools
Launch
er
=
null
;
}
Future
<
void
>
_serviceProtocolDone
(
dynamic
object
)
async
{
...
...
@@ -1720,3 +1707,32 @@ String nextPlatform(String currentPlatform, FeatureFlags featureFlags) {
return
'android'
;
}
}
class
DevtoolsLauncher
{
io
.
HttpServer
_devtoolsServer
;
Future
<
void
>
launch
(
Uri
observatoryAddress
)
async
{
try
{
_devtoolsServer
??=
await
devtools_server
.
serveDevTools
(
enableStdinCommands:
false
,
);
await
devtools_server
.
launchDevTools
(
<
String
,
dynamic
>{
'reuseWindows'
:
true
,
},
observatoryAddress
,
'http://
${_devtoolsServer.address.host}
:
${_devtoolsServer.port}
'
,
false
,
// headless mode,
false
,
// machine mode
);
}
on
Exception
catch
(
e
,
st
)
{
globals
.
printTrace
(
'Failed to launch DevTools:
$e
\n
$st
'
);
}
}
Future
<
void
>
close
()
async
{
await
_devtoolsServer
?.
close
();
_devtoolsServer
=
null
;
}
static
DevtoolsLauncher
get
instance
=>
context
.
get
<
DevtoolsLauncher
>()
??
DevtoolsLauncher
();
}
packages/flutter_tools/test/general.shard/resident_runner_test.dart
View file @
a317c2c0
...
...
@@ -122,6 +122,7 @@ void main() {
ResidentRunner
residentRunner
;
MockDevice
mockDevice
;
FakeVmServiceHost
fakeVmServiceHost
;
MockDevtoolsLauncher
mockDevtoolsLauncher
;
setUp
(()
{
testbed
=
Testbed
(
setup:
()
{
...
...
@@ -142,6 +143,7 @@ void main() {
mockDevice
=
MockDevice
();
mockVMService
=
MockVMService
();
mockDevFS
=
MockDevFS
();
mockDevtoolsLauncher
=
MockDevtoolsLauncher
();
// DevFS Mocks
when
(
mockDevFS
.
lastCompiled
).
thenReturn
(
DateTime
(
2000
));
...
...
@@ -1298,6 +1300,18 @@ void main() {
)
}));
testUsingContext
(
'ResidentRunner invokes DevtoolsLauncher when launching and shutting down Devtools'
,
()
=>
testbed
.
run
(()
async
{
when
(
mockFlutterDevice
.
vmService
).
thenReturn
(
fakeVmServiceHost
.
vmService
);
setHttpAddress
(
testUri
,
fakeVmServiceHost
.
vmService
);
await
residentRunner
.
launchDevTools
();
verify
(
mockDevtoolsLauncher
.
launch
(
testUri
)).
called
(
1
);
await
residentRunner
.
shutdownDevtools
();
verify
(
mockDevtoolsLauncher
.
close
()).
called
(
1
);
}),
overrides:
<
Type
,
Generator
>{
DevtoolsLauncher:
()
=>
mockDevtoolsLauncher
,
});
testUsingContext
(
'ResidentRunner can take screenshot on debug device'
,
()
=>
testbed
.
run
(()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
listViews
,
...
...
@@ -2076,6 +2090,7 @@ class MockDevFS extends Mock implements DevFS {}
class
MockDevice
extends
Mock
implements
Device
{}
class
MockDeviceLogReader
extends
Mock
implements
DeviceLogReader
{}
class
MockDevicePortForwarder
extends
Mock
implements
DevicePortForwarder
{}
class
MockDevtoolsLauncher
extends
Mock
implements
DevtoolsLauncher
{}
class
MockUsage
extends
Mock
implements
Usage
{}
class
MockProcessManager
extends
Mock
implements
ProcessManager
{}
class
MockResidentCompiler
extends
Mock
implements
ResidentCompiler
{}
...
...
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