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
81724bd6
Unverified
Commit
81724bd6
authored
Nov 25, 2019
by
Emmanuel Garcia
Committed by
GitHub
Nov 25, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fallback to protocol discovery if mdns returns null (#45439)
parent
901eb0fc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
9 deletions
+62
-9
attach.dart
packages/flutter_tools/lib/src/commands/attach.dart
+10
-9
attach_test.dart
...utter_tools/test/commands.shard/hermetic/attach_test.dart
+52
-0
No files found.
packages/flutter_tools/lib/src/commands/attach.dart
View file @
81724bd6
...
@@ -233,15 +233,16 @@ class AttachCommand extends FlutterCommand {
...
@@ -233,15 +233,16 @@ class AttachCommand extends FlutterCommand {
rethrow
;
rethrow
;
}
}
}
else
if
((
device
is
IOSDevice
)
||
(
device
is
IOSSimulator
))
{
}
else
if
((
device
is
IOSDevice
)
||
(
device
is
IOSSimulator
))
{
observatoryUri
=
Stream
<
Uri
>
final
Uri
uriFromMdns
=
.
fromFuture
(
await
MDnsObservatoryDiscovery
.
instance
.
getObservatoryUri
(
MDnsObservatoryDiscovery
.
instance
.
getObservatoryUri
(
appId
,
appId
,
device
,
device
,
usesIpv6:
usesIpv6
,
usesIpv6:
usesIpv6
,
deviceVmservicePort:
deviceVmservicePort
,
deviceVmservicePort:
deviceVmservicePort
,
)
);
).
asBroadcastStream
();
observatoryUri
=
uriFromMdns
==
null
?
null
:
Stream
<
Uri
>.
value
(
uriFromMdns
).
asBroadcastStream
();
}
}
// 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.
if
(
observatoryUri
==
null
)
{
if
(
observatoryUri
==
null
)
{
...
...
packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart
View file @
81724bd6
...
@@ -425,6 +425,58 @@ void main() {
...
@@ -425,6 +425,58 @@ void main() {
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
});
});
testUsingContext
(
'fallbacks to protocol observatory if MDNS failed on iOS'
,
()
async
{
const
int
devicePort
=
499
;
const
int
hostPort
=
42
;
final
MockDeviceLogReader
mockLogReader
=
MockDeviceLogReader
();
final
MockPortForwarder
portForwarder
=
MockPortForwarder
();
final
MockIOSDevice
device
=
MockIOSDevice
();
final
MockHotRunner
mockHotRunner
=
MockHotRunner
();
final
MockHotRunnerFactory
mockHotRunnerFactory
=
MockHotRunnerFactory
();
when
(
device
.
portForwarder
).
thenReturn
(
portForwarder
);
when
(
device
.
getLogReader
()).
thenAnswer
((
_
)
=>
mockLogReader
);
when
(
portForwarder
.
forward
(
devicePort
,
hostPort:
anyNamed
(
'hostPort'
)))
.
thenAnswer
((
_
)
async
=>
hostPort
);
when
(
portForwarder
.
forwardedPorts
)
.
thenReturn
(<
ForwardedPort
>[
ForwardedPort
(
hostPort
,
devicePort
)]);
when
(
portForwarder
.
unforward
(
any
))
.
thenAnswer
((
_
)
async
=>
null
);
when
(
mockHotRunner
.
attach
(
appStartedCompleter:
anyNamed
(
'appStartedCompleter'
)))
.
thenAnswer
((
_
)
async
=>
0
);
when
(
mockHotRunnerFactory
.
build
(
any
,
target:
anyNamed
(
'target'
),
debuggingOptions:
anyNamed
(
'debuggingOptions'
),
packagesFilePath:
anyNamed
(
'packagesFilePath'
),
flutterProject:
anyNamed
(
'flutterProject'
),
ipv6:
false
,
)).
thenReturn
(
mockHotRunner
);
when
(
mockHotRunner
.
exited
).
thenReturn
(
false
);
when
(
mockHotRunner
.
isWaitingForObservatory
).
thenReturn
(
false
);
testDeviceManager
.
addDevice
(
device
);
final
File
foo
=
fs
.
file
(
'lib/foo.dart'
)..
createSync
();
// Delete the main.dart file to be sure that attach works without it.
fs
.
file
(
fs
.
path
.
join
(
'lib'
,
'main.dart'
)).
deleteSync
();
final
AttachCommand
command
=
AttachCommand
(
hotRunnerFactory:
mockHotRunnerFactory
);
await
createTestCommandRunner
(
command
).
run
(<
String
>[
'attach'
,
'-t'
,
foo
.
path
,
'-v'
]);
verify
(
mockHotRunnerFactory
.
build
(
any
,
target:
foo
.
path
,
debuggingOptions:
anyNamed
(
'debuggingOptions'
),
packagesFilePath:
anyNamed
(
'packagesFilePath'
),
flutterProject:
anyNamed
(
'flutterProject'
),
ipv6:
false
,
)).
called
(
1
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
testFileSystem
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
});
group
(
'forwarding to given port'
,
()
{
group
(
'forwarding to given port'
,
()
{
const
int
devicePort
=
499
;
const
int
devicePort
=
499
;
const
int
hostPort
=
42
;
const
int
hostPort
=
42
;
...
...
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