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
d4830fcf
Unverified
Commit
d4830fcf
authored
Nov 08, 2017
by
Yegor
Committed by
GitHub
Nov 08, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
smoke test VM service connection before returning VMService object (#12914)
parent
e1cbbc1c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
14 deletions
+39
-14
fuchsia_reload.dart
packages/flutter_tools/lib/src/commands/fuchsia_reload.dart
+4
-4
screenshot.dart
packages/flutter_tools/lib/src/commands/screenshot.dart
+1
-1
trace.dart
packages/flutter_tools/lib/src/commands/trace.dart
+3
-3
resident_runner.dart
packages/flutter_tools/lib/src/resident_runner.dart
+3
-3
vmservice.dart
packages/flutter_tools/lib/src/vmservice.dart
+7
-3
vmservice_test.dart
packages/flutter_tools/test/vmservice_test.dart
+21
-0
No files found.
packages/flutter_tools/lib/src/commands/fuchsia_reload.dart
View file @
d4830fcf
...
...
@@ -155,11 +155,11 @@ class FuchsiaReloadCommand extends FlutterCommand {
// A cache of VMService connections.
final
HashMap
<
int
,
VMService
>
_vmServiceCache
=
new
HashMap
<
int
,
VMService
>();
VMService
_getVMService
(
int
port
)
{
Future
<
VMService
>
_getVMService
(
int
port
)
async
{
if
(!
_vmServiceCache
.
containsKey
(
port
))
{
final
String
addr
=
'http://
$ipv4Loopback
:
$port
'
;
final
Uri
uri
=
Uri
.
parse
(
addr
);
final
VMService
vmService
=
VMService
.
connect
(
uri
);
final
VMService
vmService
=
await
VMService
.
connect
(
uri
);
_vmServiceCache
[
port
]
=
vmService
;
}
return
_vmServiceCache
[
port
];
...
...
@@ -183,7 +183,7 @@ class FuchsiaReloadCommand extends FlutterCommand {
for
(
int
port
in
ports
)
{
if
(!
await
_checkPort
(
port
))
continue
;
final
VMService
vmService
=
_getVMService
(
port
);
final
VMService
vmService
=
await
_getVMService
(
port
);
await
vmService
.
getVM
();
await
vmService
.
waitForViews
();
views
.
addAll
(
vmService
.
vm
.
views
);
...
...
@@ -283,7 +283,7 @@ class FuchsiaReloadCommand extends FlutterCommand {
Future
<
Null
>
_listVMs
(
List
<
int
>
ports
)
async
{
for
(
int
port
in
ports
)
{
final
VMService
vmService
=
_getVMService
(
port
);
final
VMService
vmService
=
await
_getVMService
(
port
);
await
vmService
.
getVM
();
await
vmService
.
waitForViews
();
printStatus
(
_vmServiceToString
(
vmService
));
...
...
packages/flutter_tools/lib/src/commands/screenshot.dart
View file @
d4830fcf
...
...
@@ -80,7 +80,7 @@ class ScreenshotCommand extends FlutterCommand {
Future
<
Null
>
runSkia
(
File
outputFile
)
async
{
final
Uri
observatoryUri
=
new
Uri
(
scheme:
'http'
,
host:
'127.0.0.1'
,
port:
int
.
parse
(
argResults
[
_kSkia
]));
final
VMService
vmService
=
VMService
.
connect
(
observatoryUri
);
final
VMService
vmService
=
await
VMService
.
connect
(
observatoryUri
);
final
Map
<
String
,
dynamic
>
skp
=
await
vmService
.
vm
.
invokeRpcRaw
(
'_flutter.screenshotSkp'
);
outputFile
??=
getUniqueFile
(
fs
.
currentDirectory
,
'flutter'
,
'skp'
);
...
...
packages/flutter_tools/lib/src/commands/trace.dart
View file @
d4830fcf
...
...
@@ -55,7 +55,7 @@ class TraceCommand extends FlutterCommand {
Tracing
tracing
;
try
{
tracing
=
Tracing
.
connect
(
observatoryUri
);
tracing
=
await
Tracing
.
connect
(
observatoryUri
);
}
catch
(
error
)
{
throwToolExit
(
'Error connecting to observatory:
$error
'
);
}
...
...
@@ -97,8 +97,8 @@ class TraceCommand extends FlutterCommand {
class
Tracing
{
Tracing
(
this
.
vmService
);
static
Tracing
connect
(
Uri
uri
)
{
final
VMService
observatory
=
VMService
.
connect
(
uri
);
static
Future
<
Tracing
>
connect
(
Uri
uri
)
async
{
final
VMService
observatory
=
await
VMService
.
connect
(
uri
);
return
new
Tracing
(
observatory
);
}
...
...
packages/flutter_tools/lib/src/resident_runner.dart
View file @
d4830fcf
...
...
@@ -53,12 +53,12 @@ class FlutterDevice {
/// code of the running application (a.k.a. HotReload).
/// This ensures that the reload process follows the normal orchestration of
/// the Flutter Tools and not just the VM internal service.
void
connect
({
ReloadSources
reloadSources
})
{
Future
<
Null
>
_connect
({
ReloadSources
reloadSources
})
async
{
if
(
vmServices
!=
null
)
return
;
vmServices
=
new
List
<
VMService
>(
observatoryUris
.
length
);
for
(
int
i
=
0
;
i
<
observatoryUris
.
length
;
i
++)
{
vmServices
[
i
]
=
VMService
.
connect
(
observatoryUris
[
i
],
vmServices
[
i
]
=
await
VMService
.
connect
(
observatoryUris
[
i
],
reloadSources:
reloadSources
);
printTrace
(
'Connected to service protocol:
${observatoryUris[i]}
'
);
}
...
...
@@ -599,7 +599,7 @@ abstract class ResidentRunner {
bool
viewFound
=
false
;
for
(
FlutterDevice
device
in
flutterDevices
)
{
device
.
viewFilter
=
viewFilter
;
device
.
connect
(
reloadSources:
reloadSources
);
await
device
.
_
connect
(
reloadSources:
reloadSources
);
await
device
.
getVMs
();
await
device
.
waitForViews
();
if
(
device
.
views
==
null
)
...
...
packages/flutter_tools/lib/src/vmservice.dart
View file @
d4830fcf
...
...
@@ -140,15 +140,19 @@ class VMService {
/// protocol itself.
///
/// See: https://github.com/dart-lang/sdk/commit/df8bf384eb815cf38450cb50a0f4b62230fba217
static
VMService
connect
(
static
Future
<
VMService
>
connect
(
Uri
httpUri
,
{
Duration
requestTimeout:
kDefaultRequestTimeout
,
ReloadSources
reloadSources
,
})
{
})
async
{
final
Uri
wsUri
=
httpUri
.
replace
(
scheme:
'ws'
,
path:
fs
.
path
.
join
(
httpUri
.
path
,
'ws'
));
final
StreamChannel
<
String
>
channel
=
_openChannel
(
wsUri
);
final
rpc
.
Peer
peer
=
new
rpc
.
Peer
.
withoutJson
(
jsonDocument
.
bind
(
channel
));
return
new
VMService
.
_
(
peer
,
httpUri
,
wsUri
,
requestTimeout
,
reloadSources
);
final
VMService
service
=
new
VMService
.
_
(
peer
,
httpUri
,
wsUri
,
requestTimeout
,
reloadSources
);
// This call is to ensure we are able to establish a connection instead of
// keeping on trucking and failing farther down the process.
await
service
.
_sendRequest
(
'getVersion'
,
const
<
String
,
dynamic
>{});
return
service
;
}
final
Uri
httpAddress
;
...
...
packages/flutter_tools/test/vmservice_test.dart
0 → 100644
View file @
d4830fcf
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:web_socket_channel/web_socket_channel.dart'
;
import
'package:test/test.dart'
;
import
'package:flutter_tools/src/base/port_scanner.dart'
;
import
'package:flutter_tools/src/vmservice.dart'
;
void
main
(
)
{
group
(
'VMService'
,
()
{
test
(
'fails connection eagerly in the connect() method'
,
()
async
{
final
int
port
=
await
const
HostPortScanner
().
findAvailablePort
();
expect
(
VMService
.
connect
(
Uri
.
parse
(
'http://localhost:
$port
'
)),
throwsA
(
const
isInstanceOf
<
WebSocketChannelException
>()),
);
});
});
}
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