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
b1c62245
Unverified
Commit
b1c62245
authored
Jul 03, 2018
by
Mikkel Nygaard Ravn
Committed by
GitHub
Jul 03, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
flutter attach should handle non-singular device gracefully (#19036)
parent
0329f0c1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
attach.dart
packages/flutter_tools/lib/src/commands/attach.dart
+2
-0
attach_test.dart
packages/flutter_tools/test/commands/attach_test.dart
+32
-0
No files found.
packages/flutter_tools/lib/src/commands/attach.dart
View file @
b1c62245
...
@@ -71,6 +71,8 @@ class AttachCommand extends FlutterCommand {
...
@@ -71,6 +71,8 @@ class AttachCommand extends FlutterCommand {
await
_validateArguments
();
await
_validateArguments
();
final
Device
device
=
await
findTargetDevice
();
final
Device
device
=
await
findTargetDevice
();
if
(
device
==
null
)
throwToolExit
(
null
);
final
int
devicePort
=
observatoryPort
;
final
int
devicePort
=
observatoryPort
;
Uri
observatoryUri
;
Uri
observatoryUri
;
if
(
devicePort
==
null
)
{
if
(
devicePort
==
null
)
{
...
...
packages/flutter_tools/test/commands/attach_test.dart
View file @
b1c62245
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
import
'dart:async'
;
import
'dart:async'
;
import
'package:flutter_tools/src/base/common.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/commands/attach.dart'
;
import
'package:flutter_tools/src/commands/attach.dart'
;
import
'package:flutter_tools/src/device.dart'
;
import
'package:flutter_tools/src/device.dart'
;
...
@@ -68,6 +69,37 @@ void main() {
...
@@ -68,6 +69,37 @@ void main() {
verify
(
portForwarder
.
forward
(
devicePort
)).
called
(
1
);
verify
(
portForwarder
.
forward
(
devicePort
)).
called
(
1
);
});
});
testUsingContext
(
'exits when no device connected'
,
()
async
{
final
AttachCommand
command
=
new
AttachCommand
();
await
expectLater
(
createTestCommandRunner
(
command
).
run
(<
String
>[
'attach'
]),
throwsA
(
const
isInstanceOf
<
ToolExit
>()),
);
expect
(
testLogger
.
statusText
,
contains
(
'No connected devices'
));
});
testUsingContext
(
'exits when multiple devices connected'
,
()
async
{
Device
aDeviceWithId
(
String
id
)
{
final
MockAndroidDevice
device
=
new
MockAndroidDevice
();
when
(
device
.
name
).
thenReturn
(
'd
$id
'
);
when
(
device
.
id
).
thenReturn
(
id
);
when
(
device
.
isLocalEmulator
).
thenAnswer
((
_
)
async
=>
false
);
when
(
device
.
sdkNameAndVersion
).
thenAnswer
((
_
)
async
=>
'Android 46'
);
return
device
;
}
final
AttachCommand
command
=
new
AttachCommand
();
testDeviceManager
.
addDevice
(
aDeviceWithId
(
'xx1'
));
testDeviceManager
.
addDevice
(
aDeviceWithId
(
'yy2'
));
await
expectLater
(
createTestCommandRunner
(
command
).
run
(<
String
>[
'attach'
]),
throwsA
(
const
isInstanceOf
<
ToolExit
>()),
);
expect
(
testLogger
.
statusText
,
contains
(
'More than one device'
));
expect
(
testLogger
.
statusText
,
contains
(
'xx1'
));
expect
(
testLogger
.
statusText
,
contains
(
'yy2'
));
});
});
});
}
}
...
...
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