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
6d46ff7e
Unverified
Commit
6d46ff7e
authored
Sep 03, 2020
by
includecmath
Committed by
GitHub
Sep 03, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] flutter run should allow exit when make choose for devices. (#64403)
parent
0b4dad65
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
10 deletions
+49
-10
terminal.dart
packages/flutter_tools/lib/src/base/terminal.dart
+1
-0
user_messages.dart
packages/flutter_tools/lib/src/base/user_messages.dart
+1
-1
device.dart
packages/flutter_tools/lib/src/device.dart
+6
-1
device_test.dart
packages/flutter_tools/test/general.shard/device_test.dart
+41
-8
No files found.
packages/flutter_tools/lib/src/base/terminal.dart
View file @
6d46ff7e
...
@@ -285,6 +285,7 @@ class AnsiTerminal implements Terminal {
...
@@ -285,6 +285,7 @@ class AnsiTerminal implements Terminal {
if
(
displayAcceptedCharacters
)
{
if
(
displayAcceptedCharacters
)
{
logger
.
printStatus
(
' [
${charactersToDisplay.join("|")}
]'
,
newline:
false
);
logger
.
printStatus
(
' [
${charactersToDisplay.join("|")}
]'
,
newline:
false
);
}
}
// prompt ends with ': '
logger
.
printStatus
(
': '
,
emphasis:
true
,
newline:
false
);
logger
.
printStatus
(
': '
,
emphasis:
true
,
newline:
false
);
}
}
choice
=
await
keystrokes
.
first
;
choice
=
await
keystrokes
.
first
;
...
...
packages/flutter_tools/lib/src/base/user_messages.dart
View file @
6d46ff7e
...
@@ -256,7 +256,7 @@ class UserMessages {
...
@@ -256,7 +256,7 @@ class UserMessages {
'Found
$count
devices with name or id matching
$deviceId
:'
;
'Found
$count
devices with name or id matching
$deviceId
:'
;
String
get
flutterMultipleDevicesFound
=>
'Multiple devices found:'
;
String
get
flutterMultipleDevicesFound
=>
'Multiple devices found:'
;
String
flutterChooseDevice
(
int
option
,
String
name
,
String
deviceId
)
=>
'[
$option
]:
$name
(
$deviceId
)'
;
String
flutterChooseDevice
(
int
option
,
String
name
,
String
deviceId
)
=>
'[
$option
]:
$name
(
$deviceId
)'
;
String
get
flutterChooseOne
=>
'Please choose one
:
'
;
String
get
flutterChooseOne
=>
'Please choose one
(To quit, press "q/Q")
'
;
String
get
flutterSpecifyDeviceWithAllOption
=>
String
get
flutterSpecifyDeviceWithAllOption
=>
'More than one device connected; please specify a device with '
'More than one device connected; please specify a device with '
"the '-d <deviceId>' flag, or use '-d all' to act on all devices."
;
"the '-d <deviceId>' flag, or use '-d all' to act on all devices."
;
...
...
packages/flutter_tools/lib/src/device.dart
View file @
6d46ff7e
...
@@ -14,6 +14,7 @@ import 'android/android_sdk.dart';
...
@@ -14,6 +14,7 @@ import 'android/android_sdk.dart';
import
'android/android_workflow.dart'
;
import
'android/android_workflow.dart'
;
import
'application_package.dart'
;
import
'application_package.dart'
;
import
'artifacts.dart'
;
import
'artifacts.dart'
;
import
'base/common.dart'
;
import
'base/config.dart'
;
import
'base/config.dart'
;
import
'base/context.dart'
;
import
'base/context.dart'
;
import
'base/dds.dart'
;
import
'base/dds.dart'
;
...
@@ -283,6 +284,9 @@ abstract class DeviceManager {
...
@@ -283,6 +284,9 @@ abstract class DeviceManager {
Future
<
Device
>
_chooseOneOfAvailableDevices
(
List
<
Device
>
devices
)
async
{
Future
<
Device
>
_chooseOneOfAvailableDevices
(
List
<
Device
>
devices
)
async
{
_displayDeviceOptions
(
devices
);
_displayDeviceOptions
(
devices
);
final
String
userInput
=
await
_readUserInput
(
devices
.
length
);
final
String
userInput
=
await
_readUserInput
(
devices
.
length
);
if
(
userInput
.
toLowerCase
()
==
'q'
)
{
throwToolExit
(
''
);
}
return
devices
[
int
.
parse
(
userInput
)];
return
devices
[
int
.
parse
(
userInput
)];
}
}
...
@@ -297,7 +301,8 @@ abstract class DeviceManager {
...
@@ -297,7 +301,8 @@ abstract class DeviceManager {
Future
<
String
>
_readUserInput
(
int
deviceCount
)
async
{
Future
<
String
>
_readUserInput
(
int
deviceCount
)
async
{
globals
.
terminal
.
usesTerminalUi
=
true
;
globals
.
terminal
.
usesTerminalUi
=
true
;
final
String
result
=
await
globals
.
terminal
.
promptForCharInput
(
final
String
result
=
await
globals
.
terminal
.
promptForCharInput
(
<
String
>[
for
(
int
i
=
0
;
i
<
deviceCount
;
i
++)
'
$i
'
],
<
String
>[
for
(
int
i
=
0
;
i
<
deviceCount
;
i
++)
'
$i
'
,
'q'
,
'Q'
],
displayAcceptedCharacters:
false
,
logger:
globals
.
logger
,
logger:
globals
.
logger
,
prompt:
userMessages
.
flutterChooseOne
);
prompt:
userMessages
.
flutterChooseOne
);
return
result
;
return
result
;
...
...
packages/flutter_tools/test/general.shard/device_test.dart
View file @
6d46ff7e
...
@@ -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/base/logger.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/base/terminal.dart'
;
import
'package:flutter_tools/src/base/terminal.dart'
;
import
'package:flutter_tools/src/artifacts.dart'
;
import
'package:flutter_tools/src/artifacts.dart'
;
...
@@ -208,7 +209,8 @@ void main() {
...
@@ -208,7 +209,8 @@ void main() {
];
];
when
(
mockStdio
.
stdinHasTerminal
).
thenReturn
(
true
);
when
(
mockStdio
.
stdinHasTerminal
).
thenReturn
(
true
);
when
(
globals
.
terminal
.
promptForCharInput
(<
String
>[
'0'
,
'1'
],
when
(
globals
.
terminal
.
promptForCharInput
(<
String
>[
'0'
,
'1'
,
'q'
,
'Q'
],
displayAcceptedCharacters:
false
,
logger:
globals
.
logger
,
logger:
globals
.
logger
,
prompt:
globals
.
userMessages
.
flutterChooseOne
)
prompt:
globals
.
userMessages
.
flutterChooseOne
)
).
thenAnswer
((
Invocation
invocation
)
async
=>
'0'
);
).
thenAnswer
((
Invocation
invocation
)
async
=>
'0'
);
...
@@ -232,7 +234,8 @@ void main() {
...
@@ -232,7 +234,8 @@ void main() {
];
];
when
(
mockStdio
.
stdinHasTerminal
).
thenReturn
(
true
);
when
(
mockStdio
.
stdinHasTerminal
).
thenReturn
(
true
);
when
(
globals
.
terminal
.
promptForCharInput
(<
String
>[
'0'
,
'1'
],
when
(
globals
.
terminal
.
promptForCharInput
(<
String
>[
'0'
,
'1'
,
'q'
,
'Q'
],
displayAcceptedCharacters:
false
,
logger:
globals
.
logger
,
logger:
globals
.
logger
,
prompt:
globals
.
userMessages
.
flutterChooseOne
)
prompt:
globals
.
userMessages
.
flutterChooseOne
)
).
thenAnswer
((
Invocation
invocation
)
async
=>
'1'
);
).
thenAnswer
((
Invocation
invocation
)
async
=>
'1'
);
...
@@ -256,7 +259,8 @@ void main() {
...
@@ -256,7 +259,8 @@ void main() {
];
];
when
(
mockStdio
.
stdinHasTerminal
).
thenReturn
(
true
);
when
(
mockStdio
.
stdinHasTerminal
).
thenReturn
(
true
);
when
(
globals
.
terminal
.
promptForCharInput
(<
String
>[
'0'
,
'1'
],
when
(
globals
.
terminal
.
promptForCharInput
(<
String
>[
'0'
,
'1'
,
'q'
,
'Q'
],
displayAcceptedCharacters:
false
,
logger:
globals
.
logger
,
logger:
globals
.
logger
,
prompt:
globals
.
userMessages
.
flutterChooseOne
)
prompt:
globals
.
userMessages
.
flutterChooseOne
)
).
thenAnswer
((
Invocation
invocation
)
async
=>
'0'
);
).
thenAnswer
((
Invocation
invocation
)
async
=>
'0'
);
...
@@ -280,7 +284,8 @@ void main() {
...
@@ -280,7 +284,8 @@ void main() {
];
];
when
(
mockStdio
.
stdinHasTerminal
).
thenReturn
(
true
);
when
(
mockStdio
.
stdinHasTerminal
).
thenReturn
(
true
);
when
(
globals
.
terminal
.
promptForCharInput
(<
String
>[
'0'
,
'1'
],
when
(
globals
.
terminal
.
promptForCharInput
(<
String
>[
'0'
,
'1'
,
'q'
,
'Q'
],
displayAcceptedCharacters:
false
,
logger:
globals
.
logger
,
logger:
globals
.
logger
,
prompt:
globals
.
userMessages
.
flutterChooseOne
)
prompt:
globals
.
userMessages
.
flutterChooseOne
)
).
thenAnswer
((
Invocation
invocation
)
async
=>
'1'
);
).
thenAnswer
((
Invocation
invocation
)
async
=>
'1'
);
...
@@ -307,7 +312,8 @@ void main() {
...
@@ -307,7 +312,8 @@ void main() {
];
];
when
(
mockStdio
.
stdinHasTerminal
).
thenReturn
(
true
);
when
(
mockStdio
.
stdinHasTerminal
).
thenReturn
(
true
);
when
(
globals
.
terminal
.
promptForCharInput
(<
String
>[
'0'
,
'1'
,
'2'
,
'3'
],
when
(
globals
.
terminal
.
promptForCharInput
(<
String
>[
'0'
,
'1'
,
'2'
,
'3'
,
'q'
,
'Q'
],
displayAcceptedCharacters:
false
,
logger:
globals
.
logger
,
logger:
globals
.
logger
,
prompt:
globals
.
userMessages
.
flutterChooseOne
)
prompt:
globals
.
userMessages
.
flutterChooseOne
)
).
thenAnswer
((
Invocation
invocation
)
async
=>
'2'
);
).
thenAnswer
((
Invocation
invocation
)
async
=>
'2'
);
...
@@ -325,6 +331,33 @@ void main() {
...
@@ -325,6 +331,33 @@ void main() {
Cache:
()
=>
cache
,
Cache:
()
=>
cache
,
});
});
testUsingContext
(
'exit from choose one of available devices'
,
()
async
{
final
List
<
Device
>
devices
=
<
Device
>[
ephemeralOne
,
ephemeralTwo
,
];
when
(
mockStdio
.
stdinHasTerminal
).
thenReturn
(
true
);
when
(
globals
.
terminal
.
promptForCharInput
(<
String
>[
'0'
,
'1'
,
'q'
,
'Q'
],
displayAcceptedCharacters:
false
,
logger:
globals
.
logger
,
prompt:
globals
.
userMessages
.
flutterChooseOne
)
).
thenAnswer
((
Invocation
invocation
)
async
=>
'q'
);
try
{
final
DeviceManager
deviceManager
=
TestDeviceManager
(
devices
);
await
deviceManager
.
findTargetDevices
(
FlutterProject
.
current
());
}
on
ToolExit
catch
(
e
)
{
expect
(
e
.
exitCode
,
null
);
expect
(
e
.
message
,
''
);
}
},
overrides:
<
Type
,
Generator
>{
Stdio:
()
=>
mockStdio
,
AnsiTerminal:
()
=>
MockTerminal
(),
Artifacts:
()
=>
Artifacts
.
test
(),
Cache:
()
=>
cache
,
});
testUsingContext
(
'Removes a single unsupported device'
,
()
async
{
testUsingContext
(
'Removes a single unsupported device'
,
()
async
{
final
List
<
Device
>
devices
=
<
Device
>[
final
List
<
Device
>
devices
=
<
Device
>[
unsupported
,
unsupported
,
...
...
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