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
605debfc
Unverified
Commit
605debfc
authored
Mar 10, 2020
by
Zachary Anderson
Committed by
GitHub
Mar 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] Make AndroidConsole check for next line (#52353)
parent
ac6ea52b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
6 deletions
+44
-6
android_console.dart
packages/flutter_tools/lib/src/android/android_console.dart
+14
-6
android_device_test.dart
...tools/test/general.shard/android/android_device_test.dart
+30
-0
No files found.
packages/flutter_tools/lib/src/android/android_console.dart
View file @
605debfc
...
...
@@ -42,21 +42,29 @@ class AndroidConsole {
}
Future
<
String
>
getAvdName
()
async
{
if
(
_queue
==
null
)
{
return
null
;
}
_write
(
'avd name
\n
'
);
return
_readResponse
();
}
void
destroy
()
{
if
(
_socket
!=
null
)
{
_socket
.
destroy
();
_socket
=
null
;
_queue
=
null
;
}
_socket
?.
destroy
();
_socket
=
null
;
_queue
=
null
;
}
Future
<
String
>
_readResponse
()
async
{
if
(
_queue
==
null
)
{
return
null
;
}
final
StringBuffer
output
=
StringBuffer
();
while
(
true
)
{
if
(!
await
_queue
.
hasNext
)
{
destroy
();
return
null
;
}
final
String
text
=
await
_queue
.
next
;
final
String
trimmedText
=
text
.
trim
();
if
(
trimmedText
==
'OK'
)
{
...
...
@@ -72,6 +80,6 @@ class AndroidConsole {
}
void
_write
(
String
text
)
{
_socket
.
add
(
ascii
.
encode
(
text
));
_socket
?
.
add
(
ascii
.
encode
(
text
));
}
}
packages/flutter_tools/test/general.shard/android/android_device_test.dart
View file @
605debfc
...
...
@@ -523,6 +523,8 @@ flutter:
const
String
dummyEmulatorId
=
'dummyEmulatorId'
;
final
Future
<
Socket
>
Function
(
String
host
,
int
port
)
unresponsiveSocket
=
(
String
host
,
int
port
)
async
=>
MockUnresponsiveAndroidConsoleSocket
();
final
Future
<
Socket
>
Function
(
String
host
,
int
port
)
disconnectingSocket
=
(
String
host
,
int
port
)
async
=>
MockDisconnectingAndroidConsoleSocket
();
final
Future
<
Socket
>
Function
(
String
host
,
int
port
)
workingSocket
=
(
String
host
,
int
port
)
async
=>
MockWorkingAndroidConsoleSocket
(
dummyEmulatorId
);
String
hardware
;
...
...
@@ -597,6 +599,14 @@ flutter:
AndroidConsoleSocketFactory:
()
=>
unresponsiveSocket
,
ProcessManager:
()
=>
mockProcessManager
,
});
testUsingContext
(
'returns null on early disconnect'
,
()
async
{
final
AndroidDevice
device
=
AndroidDevice
(
'emulator-5555'
);
expect
(
await
device
.
emulatorId
,
isNull
);
},
overrides:
<
Type
,
Generator
>{
AndroidConsoleSocketFactory:
()
=>
disconnectingSocket
,
ProcessManager:
()
=>
mockProcessManager
,
});
});
group
(
'portForwarder'
,
()
{
...
...
@@ -980,6 +990,26 @@ class MockUnresponsiveAndroidConsoleSocket extends Mock implements Socket {
void
add
(
List
<
int
>
data
)
{}
}
/// An Android console socket that drops all input and returns no output.
class
MockDisconnectingAndroidConsoleSocket
extends
Mock
implements
Socket
{
MockDisconnectingAndroidConsoleSocket
()
{
_controller
.
add
(
'Android Console: Welcome!
\n
'
);
// Include OK in the same packet here. In the response to "avd name"
// it's sent alone to ensure both are handled.
_controller
.
add
(
'Android Console: Some intro text
\n
OK
\n
'
);
}
final
StreamController
<
String
>
_controller
=
StreamController
<
String
>();
@override
Stream
<
E
>
asyncMap
<
E
>(
FutureOr
<
E
>
convert
(
Uint8List
event
))
=>
_controller
.
stream
as
Stream
<
E
>;
@override
void
add
(
List
<
int
>
data
)
{
_controller
.
close
();
}
}
class
AndroidPackageTest
extends
ApplicationPackage
{
AndroidPackageTest
()
:
super
(
id:
'app-id'
);
...
...
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