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
c0af77bf
Unverified
Commit
c0af77bf
authored
Nov 13, 2019
by
Jonah Williams
Committed by
GitHub
Nov 13, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow specifying device-vmservice-port and host-vmservice-port (#44027)
parent
bcc93bca
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
161 additions
and
47 deletions
+161
-47
android_device.dart
packages/flutter_tools/lib/src/android/android_device.dart
+2
-1
attach.dart
packages/flutter_tools/lib/src/commands/attach.dart
+6
-2
drive.dart
packages/flutter_tools/lib/src/commands/drive.dart
+1
-1
run.dart
packages/flutter_tools/lib/src/commands/run.dart
+2
-1
desktop_device.dart
packages/flutter_tools/lib/src/desktop_device.dart
+5
-1
device.dart
packages/flutter_tools/lib/src/device.dart
+7
-4
devices.dart
packages/flutter_tools/lib/src/ios/devices.dart
+4
-3
simulators.dart
packages/flutter_tools/lib/src/ios/simulators.dart
+6
-2
mdns_discovery.dart
packages/flutter_tools/lib/src/mdns_discovery.dart
+21
-8
protocol_discovery.dart
packages/flutter_tools/lib/src/protocol_discovery.dart
+19
-8
flutter_command.dart
packages/flutter_tools/lib/src/runner/flutter_command.dart
+44
-7
flutter_tester.dart
packages/flutter_tools/lib/src/tester/flutter_tester.dart
+4
-2
attach_test.dart
...utter_tools/test/commands.shard/hermetic/attach_test.dart
+2
-2
devices_test.dart
...es/flutter_tools/test/general.shard/ios/devices_test.dart
+4
-4
protocol_discovery_test.dart
...ter_tools/test/general.shard/protocol_discovery_test.dart
+34
-1
No files found.
packages/flutter_tools/lib/src/android/android_device.dart
View file @
c0af77bf
...
@@ -549,7 +549,8 @@ class AndroidDevice extends Device {
...
@@ -549,7 +549,8 @@ class AndroidDevice extends Device {
observatoryDiscovery
=
ProtocolDiscovery
.
observatory
(
observatoryDiscovery
=
ProtocolDiscovery
.
observatory
(
getLogReader
(),
getLogReader
(),
portForwarder:
portForwarder
,
portForwarder:
portForwarder
,
hostPort:
debuggingOptions
.
observatoryPort
,
hostPort:
debuggingOptions
.
hostVmServicePort
,
devicePort:
debuggingOptions
.
deviceVmServicePort
,
ipv6:
ipv6
,
ipv6:
ipv6
,
);
);
}
}
...
...
packages/flutter_tools/lib/src/commands/attach.dart
View file @
c0af77bf
...
@@ -232,7 +232,8 @@ class AttachCommand extends FlutterCommand {
...
@@ -232,7 +232,8 @@ class AttachCommand extends FlutterCommand {
observatoryUri
=
await
MDnsObservatoryDiscovery
.
instance
.
getObservatoryUri
(
observatoryUri
=
await
MDnsObservatoryDiscovery
.
instance
.
getObservatoryUri
(
appId
,
appId
,
device
,
device
,
usesIpv6
,
usesIpv6:
usesIpv6
,
deviceVmservicePort:
deviceVmservicePort
,
);
);
}
}
// If MDNS discovery fails or we're not on iOS, fallback to ProtocolDiscovery.
// If MDNS discovery fails or we're not on iOS, fallback to ProtocolDiscovery.
...
@@ -242,6 +243,9 @@ class AttachCommand extends FlutterCommand {
...
@@ -242,6 +243,9 @@ class AttachCommand extends FlutterCommand {
observatoryDiscovery
=
ProtocolDiscovery
.
observatory
(
observatoryDiscovery
=
ProtocolDiscovery
.
observatory
(
device
.
getLogReader
(),
device
.
getLogReader
(),
portForwarder:
device
.
portForwarder
,
portForwarder:
device
.
portForwarder
,
ipv6:
ipv6
,
devicePort:
deviceVmservicePort
,
hostPort:
hostVmservicePort
,
);
);
printStatus
(
'Waiting for a connection from Flutter on
${device.name}
...'
);
printStatus
(
'Waiting for a connection from Flutter on
${device.name}
...'
);
observatoryUri
=
await
observatoryDiscovery
.
uri
;
observatoryUri
=
await
observatoryDiscovery
.
uri
;
...
@@ -259,7 +263,7 @@ class AttachCommand extends FlutterCommand {
...
@@ -259,7 +263,7 @@ class AttachCommand extends FlutterCommand {
device
,
device
,
debugUri
?.
host
??
hostname
,
debugUri
?.
host
??
hostname
,
devicePort
??
debugUri
.
port
,
devicePort
??
debugUri
.
port
,
observatory
Port
,
hostVmservice
Port
,
debugUri
?.
path
,
debugUri
?.
path
,
);
);
}
}
...
...
packages/flutter_tools/lib/src/commands/drive.dart
View file @
c0af77bf
...
@@ -273,7 +273,7 @@ Future<LaunchResult> _startApp(DriveCommand command) async {
...
@@ -273,7 +273,7 @@ Future<LaunchResult> _startApp(DriveCommand command) async {
debuggingOptions:
DebuggingOptions
.
enabled
(
debuggingOptions:
DebuggingOptions
.
enabled
(
command
.
getBuildInfo
(),
command
.
getBuildInfo
(),
startPaused:
true
,
startPaused:
true
,
observatoryPort:
command
.
observatory
Port
,
hostVmServicePort:
command
.
hostVmservice
Port
,
verboseSystemLogs:
command
.
verboseSystemLogs
,
verboseSystemLogs:
command
.
verboseSystemLogs
,
cacheSkSL:
command
.
cacheSkSL
,
cacheSkSL:
command
.
cacheSkSL
,
dumpSkpOnShaderCompilation:
command
.
dumpSkpOnShaderCompilation
,
dumpSkpOnShaderCompilation:
command
.
dumpSkpOnShaderCompilation
,
...
...
packages/flutter_tools/lib/src/commands/run.dart
View file @
c0af77bf
...
@@ -315,7 +315,8 @@ class RunCommand extends RunCommandBase {
...
@@ -315,7 +315,8 @@ class RunCommand extends RunCommandBase {
traceSystrace:
argResults
[
'trace-systrace'
],
traceSystrace:
argResults
[
'trace-systrace'
],
dumpSkpOnShaderCompilation:
dumpSkpOnShaderCompilation
,
dumpSkpOnShaderCompilation:
dumpSkpOnShaderCompilation
,
cacheSkSL:
cacheSkSL
,
cacheSkSL:
cacheSkSL
,
observatoryPort:
observatoryPort
,
deviceVmServicePort:
deviceVmservicePort
,
hostVmServicePort:
hostVmservicePort
,
verboseSystemLogs:
argResults
[
'verbose-system-logs'
],
verboseSystemLogs:
argResults
[
'verbose-system-logs'
],
initializePlatform:
argResults
[
'web-initialize-platform'
],
initializePlatform:
argResults
[
'web-initialize-platform'
],
hostname:
featureFlags
.
isWebEnabled
?
argResults
[
'web-hostname'
]
:
''
,
hostname:
featureFlags
.
isWebEnabled
?
argResults
[
'web-hostname'
]
:
''
,
...
...
packages/flutter_tools/lib/src/desktop_device.dart
View file @
c0af77bf
...
@@ -109,7 +109,11 @@ abstract class DesktopDevice extends Device {
...
@@ -109,7 +109,11 @@ abstract class DesktopDevice extends Device {
return
LaunchResult
.
succeeded
();
return
LaunchResult
.
succeeded
();
}
}
_deviceLogReader
.
initializeProcess
(
process
);
_deviceLogReader
.
initializeProcess
(
process
);
final
ProtocolDiscovery
observatoryDiscovery
=
ProtocolDiscovery
.
observatory
(
_deviceLogReader
);
final
ProtocolDiscovery
observatoryDiscovery
=
ProtocolDiscovery
.
observatory
(
_deviceLogReader
,
devicePort:
debuggingOptions
?.
deviceVmServicePort
,
hostPort:
debuggingOptions
?.
hostVmServicePort
,
ipv6:
ipv6
,
);
try
{
try
{
final
Uri
observatoryUri
=
await
observatoryDiscovery
.
uri
;
final
Uri
observatoryUri
=
await
observatoryDiscovery
.
uri
;
onAttached
(
package
,
buildMode
,
process
);
onAttached
(
package
,
buildMode
,
process
);
...
...
packages/flutter_tools/lib/src/device.dart
View file @
c0af77bf
...
@@ -502,7 +502,8 @@ class DebuggingOptions {
...
@@ -502,7 +502,8 @@ class DebuggingOptions {
this
.
cacheSkSL
=
false
,
this
.
cacheSkSL
=
false
,
this
.
useTestFonts
=
false
,
this
.
useTestFonts
=
false
,
this
.
verboseSystemLogs
=
false
,
this
.
verboseSystemLogs
=
false
,
this
.
observatoryPort
,
this
.
hostVmServicePort
,
this
.
deviceVmServicePort
,
this
.
initializePlatform
=
true
,
this
.
initializePlatform
=
true
,
this
.
hostname
,
this
.
hostname
,
this
.
port
,
this
.
port
,
...
@@ -522,7 +523,8 @@ class DebuggingOptions {
...
@@ -522,7 +523,8 @@ class DebuggingOptions {
traceSystrace
=
false
,
traceSystrace
=
false
,
dumpSkpOnShaderCompilation
=
false
,
dumpSkpOnShaderCompilation
=
false
,
verboseSystemLogs
=
false
,
verboseSystemLogs
=
false
,
observatoryPort
=
null
,
hostVmServicePort
=
null
,
deviceVmServicePort
=
null
,
browserLaunch
=
true
,
browserLaunch
=
true
,
vmserviceOutFile
=
null
;
vmserviceOutFile
=
null
;
...
@@ -542,14 +544,15 @@ class DebuggingOptions {
...
@@ -542,14 +544,15 @@ class DebuggingOptions {
final
bool
verboseSystemLogs
;
final
bool
verboseSystemLogs
;
/// Whether to invoke webOnlyInitializePlatform in Flutter for web.
/// Whether to invoke webOnlyInitializePlatform in Flutter for web.
final
bool
initializePlatform
;
final
bool
initializePlatform
;
final
int
observatoryPort
;
final
int
hostVmServicePort
;
final
int
deviceVmServicePort
;
final
String
port
;
final
String
port
;
final
String
hostname
;
final
String
hostname
;
final
bool
browserLaunch
;
final
bool
browserLaunch
;
/// A file where the vmservice uri should be written after the application is started.
/// A file where the vmservice uri should be written after the application is started.
final
String
vmserviceOutFile
;
final
String
vmserviceOutFile
;
bool
get
hasObservatoryPort
=>
observatory
Port
!=
null
;
bool
get
hasObservatoryPort
=>
hostVmService
Port
!=
null
;
}
}
class
LaunchResult
{
class
LaunchResult
{
...
...
packages/flutter_tools/lib/src/ios/devices.dart
View file @
c0af77bf
...
@@ -356,7 +356,8 @@ class IOSDevice extends Device {
...
@@ -356,7 +356,8 @@ class IOSDevice extends Device {
observatoryDiscovery
=
ProtocolDiscovery
.
observatory
(
observatoryDiscovery
=
ProtocolDiscovery
.
observatory
(
getLogReader
(
app:
package
),
getLogReader
(
app:
package
),
portForwarder:
portForwarder
,
portForwarder:
portForwarder
,
hostPort:
debuggingOptions
.
observatoryPort
,
hostPort:
debuggingOptions
.
hostVmServicePort
,
devicePort:
debuggingOptions
.
deviceVmServicePort
,
ipv6:
ipv6
,
ipv6:
ipv6
,
);
);
}
}
...
@@ -383,8 +384,8 @@ class IOSDevice extends Device {
...
@@ -383,8 +384,8 @@ class IOSDevice extends Device {
localUri
=
await
MDnsObservatoryDiscovery
.
instance
.
getObservatoryUri
(
localUri
=
await
MDnsObservatoryDiscovery
.
instance
.
getObservatoryUri
(
packageId
,
packageId
,
this
,
this
,
ipv6
,
usesIpv6:
ipv6
,
debuggingOptions
.
observatory
Port
,
hostVmservicePort:
debuggingOptions
.
hostVmService
Port
,
);
);
if
(
localUri
!=
null
)
{
if
(
localUri
!=
null
)
{
UsageEvent
(
'ios-mdns'
,
'success'
).
send
();
UsageEvent
(
'ios-mdns'
,
'success'
).
send
();
...
...
packages/flutter_tools/lib/src/ios/simulators.dart
View file @
c0af77bf
...
@@ -374,14 +374,18 @@ class IOSSimulator extends Device {
...
@@ -374,14 +374,18 @@ class IOSSimulator extends Device {
if
(
debuggingOptions
.
disableServiceAuthCodes
)
'--disable-service-auth-codes'
,
if
(
debuggingOptions
.
disableServiceAuthCodes
)
'--disable-service-auth-codes'
,
if
(
debuggingOptions
.
skiaDeterministicRendering
)
'--skia-deterministic-rendering'
,
if
(
debuggingOptions
.
skiaDeterministicRendering
)
'--skia-deterministic-rendering'
,
if
(
debuggingOptions
.
useTestFonts
)
'--use-test-fonts'
,
if
(
debuggingOptions
.
useTestFonts
)
'--use-test-fonts'
,
'--observatory-port=
${debuggingOptions.
observatory
Port ?? 0}
'
,
'--observatory-port=
${debuggingOptions.
hostVmService
Port ?? 0}
'
,
],
],
];
];
ProtocolDiscovery
observatoryDiscovery
;
ProtocolDiscovery
observatoryDiscovery
;
if
(
debuggingOptions
.
debuggingEnabled
)
{
if
(
debuggingOptions
.
debuggingEnabled
)
{
observatoryDiscovery
=
ProtocolDiscovery
.
observatory
(
observatoryDiscovery
=
ProtocolDiscovery
.
observatory
(
getLogReader
(
app:
package
),
ipv6:
ipv6
);
getLogReader
(
app:
package
),
ipv6:
ipv6
,
hostPort:
debuggingOptions
.
hostVmServicePort
,
devicePort:
debuggingOptions
.
deviceVmServicePort
,
);
}
}
// Launch the updated application in the simulator.
// Launch the updated application in the simulator.
...
...
packages/flutter_tools/lib/src/mdns_discovery.dart
View file @
c0af77bf
...
@@ -50,7 +50,8 @@ class MDnsObservatoryDiscovery {
...
@@ -50,7 +50,8 @@ class MDnsObservatoryDiscovery {
/// If it is null and there is only one available instance of Observatory,
/// If it is null and there is only one available instance of Observatory,
/// it will return that instance's information regardless of what application
/// it will return that instance's information regardless of what application
/// the Observatory instance is for.
/// the Observatory instance is for.
Future
<
MDnsObservatoryDiscoveryResult
>
query
({
String
applicationId
})
async
{
// TODO(jonahwilliams): use `deviceVmservicePort` to filter mdns results.
Future
<
MDnsObservatoryDiscoveryResult
>
query
({
String
applicationId
,
int
deviceVmservicePort
})
async
{
printTrace
(
'Checking for advertised Dart observatories...'
);
printTrace
(
'Checking for advertised Dart observatories...'
);
try
{
try
{
await
client
.
start
();
await
client
.
start
();
...
@@ -136,14 +137,27 @@ class MDnsObservatoryDiscovery {
...
@@ -136,14 +137,27 @@ class MDnsObservatoryDiscovery {
}
}
}
}
Future
<
Uri
>
getObservatoryUri
(
String
applicationId
,
Device
device
,
[
bool
usesIpv6
=
false
,
int
observatoryPort
])
async
{
Future
<
Uri
>
getObservatoryUri
(
String
applicationId
,
Device
device
,
{
final
MDnsObservatoryDiscoveryResult
result
=
await
query
(
applicationId:
applicationId
);
bool
usesIpv6
=
false
,
int
hostVmservicePort
,
int
deviceVmservicePort
,
})
async
{
final
MDnsObservatoryDiscoveryResult
result
=
await
query
(
applicationId:
applicationId
,
deviceVmservicePort:
deviceVmservicePort
,
);
Uri
observatoryUri
;
Uri
observatoryUri
;
if
(
result
!=
null
)
{
if
(
result
!=
null
)
{
final
String
host
=
usesIpv6
final
String
host
=
usesIpv6
?
InternetAddress
.
loopbackIPv6
.
address
?
InternetAddress
.
loopbackIPv6
.
address
:
InternetAddress
.
loopbackIPv4
.
address
;
:
InternetAddress
.
loopbackIPv4
.
address
;
observatoryUri
=
await
buildObservatoryUri
(
device
,
host
,
result
.
port
,
observatoryPort
,
result
.
authCode
);
observatoryUri
=
await
buildObservatoryUri
(
device
,
host
,
result
.
port
,
hostVmservicePort
,
result
.
authCode
,
);
}
}
return
observatoryUri
;
return
observatoryUri
;
}
}
...
@@ -159,7 +173,7 @@ Future<Uri> buildObservatoryUri(
...
@@ -159,7 +173,7 @@ Future<Uri> buildObservatoryUri(
Device
device
,
Device
device
,
String
host
,
String
host
,
int
devicePort
,
[
int
devicePort
,
[
int
observatory
Port
,
int
hostVmservice
Port
,
String
authCode
,
String
authCode
,
])
async
{
])
async
{
String
path
=
'/'
;
String
path
=
'/'
;
...
@@ -171,7 +185,6 @@ Future<Uri> buildObservatoryUri(
...
@@ -171,7 +185,6 @@ Future<Uri> buildObservatoryUri(
if
(!
path
.
endsWith
(
'/'
))
{
if
(!
path
.
endsWith
(
'/'
))
{
path
+=
'/'
;
path
+=
'/'
;
}
}
final
int
localPort
=
observatoryPort
final
int
actualHostPort
=
await
device
.
portForwarder
.
forward
(
devicePort
,
hostPort:
hostVmservicePort
);
??
await
device
.
portForwarder
.
forward
(
devicePort
);
return
Uri
(
scheme:
'http'
,
host:
host
,
port:
actualHostPort
,
path:
path
);
return
Uri
(
scheme:
'http'
,
host:
host
,
port:
localPort
,
path:
path
);
}
}
packages/flutter_tools/lib/src/protocol_discovery.dart
View file @
c0af77bf
...
@@ -4,6 +4,8 @@
...
@@ -4,6 +4,8 @@
import
'dart:async'
;
import
'dart:async'
;
import
'package:meta/meta.dart'
;
import
'base/io.dart'
;
import
'base/io.dart'
;
import
'device.dart'
;
import
'device.dart'
;
import
'globals.dart'
;
import
'globals.dart'
;
...
@@ -16,6 +18,7 @@ class ProtocolDiscovery {
...
@@ -16,6 +18,7 @@ class ProtocolDiscovery {
this
.
serviceName
,
{
this
.
serviceName
,
{
this
.
portForwarder
,
this
.
portForwarder
,
this
.
hostPort
,
this
.
hostPort
,
this
.
devicePort
,
this
.
ipv6
,
this
.
ipv6
,
})
:
assert
(
logReader
!=
null
)
{
})
:
assert
(
logReader
!=
null
)
{
_deviceLogSubscription
=
logReader
.
logLines
.
listen
(
_handleLine
);
_deviceLogSubscription
=
logReader
.
logLines
.
listen
(
_handleLine
);
...
@@ -24,8 +27,9 @@ class ProtocolDiscovery {
...
@@ -24,8 +27,9 @@ class ProtocolDiscovery {
factory
ProtocolDiscovery
.
observatory
(
factory
ProtocolDiscovery
.
observatory
(
DeviceLogReader
logReader
,
{
DeviceLogReader
logReader
,
{
DevicePortForwarder
portForwarder
,
DevicePortForwarder
portForwarder
,
int
hostPort
,
@required
int
hostPort
,
bool
ipv6
=
false
,
@required
int
devicePort
,
@required
bool
ipv6
,
})
{
})
{
const
String
kObservatoryService
=
'Observatory'
;
const
String
kObservatoryService
=
'Observatory'
;
return
ProtocolDiscovery
.
_
(
return
ProtocolDiscovery
.
_
(
...
@@ -33,6 +37,7 @@ class ProtocolDiscovery {
...
@@ -33,6 +37,7 @@ class ProtocolDiscovery {
kObservatoryService
,
kObservatoryService
,
portForwarder:
portForwarder
,
portForwarder:
portForwarder
,
hostPort:
hostPort
,
hostPort:
hostPort
,
devicePort:
devicePort
,
ipv6:
ipv6
,
ipv6:
ipv6
,
);
);
}
}
...
@@ -41,6 +46,7 @@ class ProtocolDiscovery {
...
@@ -41,6 +46,7 @@ class ProtocolDiscovery {
final
String
serviceName
;
final
String
serviceName
;
final
DevicePortForwarder
portForwarder
;
final
DevicePortForwarder
portForwarder
;
final
int
hostPort
;
final
int
hostPort
;
final
int
devicePort
;
final
bool
ipv6
;
final
bool
ipv6
;
final
Completer
<
Uri
>
_completer
=
Completer
<
Uri
>();
final
Completer
<
Uri
>
_completer
=
Completer
<
Uri
>();
...
@@ -71,17 +77,22 @@ class ProtocolDiscovery {
...
@@ -71,17 +77,22 @@ class ProtocolDiscovery {
if
(
match
!=
null
)
{
if
(
match
!=
null
)
{
try
{
try
{
uri
=
Uri
.
parse
(
match
[
1
]);
uri
=
Uri
.
parse
(
match
[
1
]);
}
catch
(
error
,
stackTrace
)
{
}
on
FormatException
catch
(
error
,
stackTrace
)
{
_stopScrapingLogs
();
_stopScrapingLogs
();
_completer
.
completeError
(
error
,
stackTrace
);
_completer
.
completeError
(
error
,
stackTrace
);
}
}
}
}
if
(
uri
==
null
)
{
if
(
uri
!=
null
)
{
return
;
assert
(!
_completer
.
isCompleted
);
_stopScrapingLogs
();
_completer
.
complete
(
uri
);
}
}
if
(
devicePort
!=
null
&&
uri
.
port
!=
devicePort
)
{
printTrace
(
'skipping potential observatory
$uri
due to device port mismatch'
);
return
;
}
assert
(!
_completer
.
isCompleted
);
_stopScrapingLogs
();
_completer
.
complete
(
uri
);
}
}
Future
<
Uri
>
_forwardPort
(
Uri
deviceUri
)
async
{
Future
<
Uri
>
_forwardPort
(
Uri
deviceUri
)
async
{
...
...
packages/flutter_tools/lib/src/runner/flutter_command.dart
View file @
c0af77bf
...
@@ -216,23 +216,60 @@ abstract class FlutterCommand extends Command<void> {
...
@@ -216,23 +216,60 @@ abstract class FlutterCommand extends Command<void> {
/// Adds options for connecting to the Dart VM observatory port.
/// Adds options for connecting to the Dart VM observatory port.
void
usesPortOptions
()
{
void
usesPortOptions
()
{
argParser
.
addOption
(
observatoryPortOption
,
argParser
.
addOption
(
observatoryPortOption
,
help:
'Listen to the given port for an observatory debugger connection.
\n
'
help:
'(deprecated use host-vmservice-port instead)'
'Listen to the given port for an observatory debugger connection.
\n
'
'Specifying port 0 (the default) will find a random free port.'
,
'Specifying port 0 (the default) will find a random free port.'
,
);
);
argParser
.
addOption
(
'device-vmservice-port'
,
help:
'Look for vmservice connections only from the specified port.
\n
'
'Specifying port 0 (the default) will accept the first vmservice '
'discovered.'
,
);
argParser
.
addOption
(
'host-vmservice-port'
,
help:
'When a device-side vmservice port is forwarded to a host-side '
'port, use this value as the host port.
\n
Specifying port 0 '
'(the default) will find a random free host port.'
);
_usesPortOption
=
true
;
_usesPortOption
=
true
;
}
}
/// Gets the observatory port provided to in the 'observatory-port' option.
/// Gets the vmservice port provided to in the 'observatory-port' or
/// 'host-vmservice-port option.
///
/// Only one of "host-vmservice-port" and "observatory-port" may be
/// specified.
///
/// If no port is set, returns null.
int
get
hostVmservicePort
{
if
(!
_usesPortOption
||
argResults
[
'observatory-port'
]
==
null
||
argResults
[
'host-vmservice-port'
]
==
null
)
{
return
null
;
}
if
(
argResults
.
wasParsed
(
'observatory-port'
)
&&
argResults
.
wasParsed
(
'host-vmservice-port'
))
{
throwToolExit
(
'Only one of "--observatory-port" and '
'"--host-vmservice-port" may be specified.'
);
}
try
{
return
int
.
parse
(
argResults
[
'observatory-port'
]
??
argResults
[
'host-vmservice-port'
]);
}
on
FormatException
catch
(
error
)
{
throwToolExit
(
'Invalid port for `--observatory-port/--host-vmservice-port`:
$error
'
);
}
return
null
;
}
/// Gets the vmservice port provided to in the 'device-vmservice-port' option.
///
///
/// If no port is set, returns null.
/// If no port is set, returns null.
int
get
observatory
Port
{
int
get
deviceVmservice
Port
{
if
(!
_usesPortOption
||
argResults
[
'
observatory
-port'
]
==
null
)
{
if
(!
_usesPortOption
||
argResults
[
'
device-vmservice
-port'
]
==
null
)
{
return
null
;
return
null
;
}
}
try
{
try
{
return
int
.
parse
(
argResults
[
'
observatory
-port'
]);
return
int
.
parse
(
argResults
[
'
device-vmservice
-port'
]);
}
catch
(
error
)
{
}
on
FormatException
catch
(
error
)
{
throwToolExit
(
'Invalid port for `--
observatory
-port`:
$error
'
);
throwToolExit
(
'Invalid port for `--
device-vmservice
-port`:
$error
'
);
}
}
return
null
;
return
null
;
}
}
...
...
packages/flutter_tools/lib/src/tester/flutter_tester.dart
View file @
c0af77bf
...
@@ -134,7 +134,7 @@ class FlutterTesterDevice extends Device {
...
@@ -134,7 +134,7 @@ class FlutterTesterDevice extends Device {
command
.
add
(
'--disable-service-auth-codes'
);
command
.
add
(
'--disable-service-auth-codes'
);
}
}
if
(
debuggingOptions
.
hasObservatoryPort
)
{
if
(
debuggingOptions
.
hasObservatoryPort
)
{
command
.
add
(
'--observatory-port=
${debuggingOptions.
observatory
Port}
'
);
command
.
add
(
'--observatory-port=
${debuggingOptions.
hostVmService
Port}
'
);
}
}
}
}
...
@@ -187,7 +187,9 @@ class FlutterTesterDevice extends Device {
...
@@ -187,7 +187,9 @@ class FlutterTesterDevice extends Device {
final
ProtocolDiscovery
observatoryDiscovery
=
ProtocolDiscovery
.
observatory
(
final
ProtocolDiscovery
observatoryDiscovery
=
ProtocolDiscovery
.
observatory
(
getLogReader
(),
getLogReader
(),
hostPort:
debuggingOptions
.
observatoryPort
,
hostPort:
debuggingOptions
.
hostVmServicePort
,
devicePort:
debuggingOptions
.
deviceVmServicePort
,
ipv6:
ipv6
,
);
);
final
Uri
observatoryUri
=
await
observatoryDiscovery
.
uri
;
final
Uri
observatoryUri
=
await
observatoryDiscovery
.
uri
;
...
...
packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart
View file @
c0af77bf
...
@@ -400,7 +400,7 @@ void main() {
...
@@ -400,7 +400,7 @@ void main() {
],
],
);
);
await
completer
.
future
;
await
completer
.
future
;
verifyNever
(
portForwarder
.
forward
(
devicePort
));
verifyNever
(
portForwarder
.
forward
(
devicePort
,
hostPort:
anyNamed
(
'hostPort'
)
));
await
expectLoggerInterruptEndsTask
(
task
,
logger
);
await
expectLoggerInterruptEndsTask
(
task
,
logger
);
await
loggerSubscription
.
cancel
();
await
loggerSubscription
.
cancel
();
...
@@ -432,7 +432,7 @@ void main() {
...
@@ -432,7 +432,7 @@ void main() {
],
],
);
);
await
completer
.
future
;
await
completer
.
future
;
verifyNever
(
portForwarder
.
forward
(
devicePort
));
verifyNever
(
portForwarder
.
forward
(
devicePort
,
hostPort:
anyNamed
(
'hostPort'
)
));
await
expectLoggerInterruptEndsTask
(
task
,
logger
);
await
expectLoggerInterruptEndsTask
(
task
,
logger
);
await
loggerSubscription
.
cancel
();
await
loggerSubscription
.
cancel
();
...
...
packages/flutter_tools/test/general.shard/ios/devices_test.dart
View file @
c0af77bf
...
@@ -259,7 +259,7 @@ void main() {
...
@@ -259,7 +259,7 @@ void main() {
port:
1234
,
port:
1234
,
path:
'observatory'
,
path:
'observatory'
,
);
);
when
(
mockMDnsObservatoryDiscovery
.
getObservatoryUri
(
any
,
any
,
any
))
when
(
mockMDnsObservatoryDiscovery
.
getObservatoryUri
(
any
,
any
,
usesIpv6:
anyNamed
(
'usesIpv6'
)
))
.
thenAnswer
((
Invocation
invocation
)
=>
Future
<
Uri
>.
value
(
uri
));
.
thenAnswer
((
Invocation
invocation
)
=>
Future
<
Uri
>.
value
(
uri
));
final
LaunchResult
launchResult
=
await
device
.
startApp
(
mockApp
,
final
LaunchResult
launchResult
=
await
device
.
startApp
(
mockApp
,
...
@@ -329,7 +329,7 @@ void main() {
...
@@ -329,7 +329,7 @@ void main() {
mockLogReader
.
addLine
(
'Foo'
);
mockLogReader
.
addLine
(
'Foo'
);
mockLogReader
.
addLine
(
'Observatory listening on http://127.0.0.1:
$devicePort
'
);
mockLogReader
.
addLine
(
'Observatory listening on http://127.0.0.1:
$devicePort
'
);
});
});
when
(
mockMDnsObservatoryDiscovery
.
getObservatoryUri
(
any
,
any
,
any
))
when
(
mockMDnsObservatoryDiscovery
.
getObservatoryUri
(
any
,
any
,
usesIpv6:
anyNamed
(
'usesIpv6'
)
))
.
thenAnswer
((
Invocation
invocation
)
=>
Future
<
Uri
>.
value
(
null
));
.
thenAnswer
((
Invocation
invocation
)
=>
Future
<
Uri
>.
value
(
null
));
final
LaunchResult
launchResult
=
await
device
.
startApp
(
mockApp
,
final
LaunchResult
launchResult
=
await
device
.
startApp
(
mockApp
,
...
@@ -362,7 +362,7 @@ void main() {
...
@@ -362,7 +362,7 @@ void main() {
mockLogReader
.
addLine
(
'Foo'
);
mockLogReader
.
addLine
(
'Foo'
);
mockLogReader
.
addLine
(
'Observatory listening on http:/:/127.0.0.1:
$devicePort
'
);
mockLogReader
.
addLine
(
'Observatory listening on http:/:/127.0.0.1:
$devicePort
'
);
});
});
when
(
mockMDnsObservatoryDiscovery
.
getObservatoryUri
(
any
,
any
,
any
))
when
(
mockMDnsObservatoryDiscovery
.
getObservatoryUri
(
any
,
any
,
usesIpv6:
anyNamed
(
'usesIpv6'
)
))
.
thenAnswer
((
Invocation
invocation
)
=>
Future
<
Uri
>.
value
(
null
));
.
thenAnswer
((
Invocation
invocation
)
=>
Future
<
Uri
>.
value
(
null
));
final
LaunchResult
launchResult
=
await
device
.
startApp
(
mockApp
,
final
LaunchResult
launchResult
=
await
device
.
startApp
(
mockApp
,
...
@@ -411,7 +411,7 @@ void main() {
...
@@ -411,7 +411,7 @@ void main() {
port:
1234
,
port:
1234
,
path:
'observatory'
,
path:
'observatory'
,
);
);
when
(
mockMDnsObservatoryDiscovery
.
getObservatoryUri
(
any
,
any
,
any
))
when
(
mockMDnsObservatoryDiscovery
.
getObservatoryUri
(
any
,
any
,
usesIpv6:
anyNamed
(
'usesIpv6'
)
))
.
thenAnswer
((
Invocation
invocation
)
=>
Future
<
Uri
>.
value
(
uri
));
.
thenAnswer
((
Invocation
invocation
)
=>
Future
<
Uri
>.
value
(
uri
));
List
<
String
>
args
;
List
<
String
>
args
;
...
...
packages/flutter_tools/test/general.shard/protocol_discovery_test.dart
View file @
c0af77bf
...
@@ -17,6 +17,8 @@ void main() {
...
@@ -17,6 +17,8 @@ void main() {
ProtocolDiscovery
discoverer
;
ProtocolDiscovery
discoverer
;
group
(
'no port forwarding'
,
()
{
group
(
'no port forwarding'
,
()
{
int
devicePort
;
/// Performs test set-up functionality that must be performed as part of
/// Performs test set-up functionality that must be performed as part of
/// the `test()` pass and not part of the `setUp()` pass.
/// the `test()` pass and not part of the `setUp()` pass.
///
///
...
@@ -35,7 +37,7 @@ void main() {
...
@@ -35,7 +37,7 @@ void main() {
/// See also: [runZoned]
/// See also: [runZoned]
void
initialize
()
{
void
initialize
()
{
logReader
=
MockDeviceLogReader
();
logReader
=
MockDeviceLogReader
();
discoverer
=
ProtocolDiscovery
.
observatory
(
logReader
);
discoverer
=
ProtocolDiscovery
.
observatory
(
logReader
,
ipv6:
false
,
hostPort:
null
,
devicePort:
devicePort
);
}
}
tearDown
(()
{
tearDown
(()
{
...
@@ -119,6 +121,28 @@ void main() {
...
@@ -119,6 +121,28 @@ void main() {
expect
(
uri
.
port
,
54804
);
expect
(
uri
.
port
,
54804
);
expect
(
'
$uri
'
,
'http://127.0.0.1:54804/PTwjm8Ii8qg=/'
);
expect
(
'
$uri
'
,
'http://127.0.0.1:54804/PTwjm8Ii8qg=/'
);
});
});
testUsingContext
(
'skips uri if port does not match the requested vmservice - requested last'
,
()
async
{
devicePort
=
12346
;
initialize
();
final
Future
<
Uri
>
uriFuture
=
discoverer
.
uri
;
logReader
.
addLine
(
'I/flutter : Observatory listening on http://127.0.0.1:12345/PTwjm8Ii8qg=/'
);
logReader
.
addLine
(
'I/flutter : Observatory listening on http://127.0.0.1:12346/PTwjm8Ii8qg=/'
);
final
Uri
uri
=
await
uriFuture
;
expect
(
uri
.
port
,
12346
);
expect
(
'
$uri
'
,
'http://127.0.0.1:12346/PTwjm8Ii8qg=/'
);
});
testUsingContext
(
'skips uri if port does not match the requested vmservice - requested first'
,
()
async
{
devicePort
=
12346
;
initialize
();
final
Future
<
Uri
>
uriFuture
=
discoverer
.
uri
;
logReader
.
addLine
(
'I/flutter : Observatory listening on http://127.0.0.1:12346/PTwjm8Ii8qg=/'
);
logReader
.
addLine
(
'I/flutter : Observatory listening on http://127.0.0.1:12345/PTwjm8Ii8qg=/'
);
final
Uri
uri
=
await
uriFuture
;
expect
(
uri
.
port
,
12346
);
expect
(
'
$uri
'
,
'http://127.0.0.1:12346/PTwjm8Ii8qg=/'
);
});
});
});
group
(
'port forwarding'
,
()
{
group
(
'port forwarding'
,
()
{
...
@@ -127,6 +151,9 @@ void main() {
...
@@ -127,6 +151,9 @@ void main() {
final
ProtocolDiscovery
discoverer
=
ProtocolDiscovery
.
observatory
(
final
ProtocolDiscovery
discoverer
=
ProtocolDiscovery
.
observatory
(
logReader
,
logReader
,
portForwarder:
MockPortForwarder
(
99
),
portForwarder:
MockPortForwarder
(
99
),
hostPort:
null
,
devicePort:
null
,
ipv6:
false
,
);
);
// Get next port future.
// Get next port future.
...
@@ -146,6 +173,8 @@ void main() {
...
@@ -146,6 +173,8 @@ void main() {
logReader
,
logReader
,
portForwarder:
MockPortForwarder
(
99
),
portForwarder:
MockPortForwarder
(
99
),
hostPort:
1243
,
hostPort:
1243
,
devicePort:
null
,
ipv6:
false
,
);
);
// Get next port future.
// Get next port future.
...
@@ -165,6 +194,8 @@ void main() {
...
@@ -165,6 +194,8 @@ void main() {
logReader
,
logReader
,
portForwarder:
MockPortForwarder
(
99
),
portForwarder:
MockPortForwarder
(
99
),
hostPort:
0
,
hostPort:
0
,
devicePort:
null
,
ipv6:
false
,
);
);
// Get next port future.
// Get next port future.
...
@@ -185,6 +216,7 @@ void main() {
...
@@ -185,6 +216,7 @@ void main() {
portForwarder:
MockPortForwarder
(
99
),
portForwarder:
MockPortForwarder
(
99
),
hostPort:
54777
,
hostPort:
54777
,
ipv6:
true
,
ipv6:
true
,
devicePort:
null
,
);
);
// Get next port future.
// Get next port future.
...
@@ -205,6 +237,7 @@ void main() {
...
@@ -205,6 +237,7 @@ void main() {
portForwarder:
MockPortForwarder
(
99
),
portForwarder:
MockPortForwarder
(
99
),
hostPort:
54777
,
hostPort:
54777
,
ipv6:
true
,
ipv6:
true
,
devicePort:
null
,
);
);
// Get next port future.
// Get next port future.
...
...
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