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
a18e6361
Unverified
Commit
a18e6361
authored
Apr 27, 2020
by
Jonah Williams
Committed by
GitHub
Apr 27, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] reland migrate FlutterView to new vmservice (#55774)
parent
d40699a3
Changes
13
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
538 additions
and
368 deletions
+538
-368
fuchsia_device.dart
packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
+6
-8
resident_runner.dart
packages/flutter_tools/lib/src/resident_runner.dart
+29
-25
run_hot.dart
packages/flutter_tools/lib/src/run_hot.dart
+73
-73
tracing.dart
packages/flutter_tools/lib/src/tracing.dart
+3
-2
vmservice.dart
packages/flutter_tools/lib/src/vmservice.dart
+82
-112
attach_test.dart
...utter_tools/test/commands.shard/hermetic/attach_test.dart
+33
-7
fuchsia_device_test.dart
...tools/test/general.shard/fuchsia/fuchsia_device_test.dart
+68
-44
hot_test.dart
packages/flutter_tools/test/general.shard/hot_test.dart
+80
-3
resident_runner_test.dart
...lutter_tools/test/general.shard/resident_runner_test.dart
+153
-53
vmservice_test.dart
...ages/flutter_tools/test/general.shard/vmservice_test.dart
+0
-40
hot_reload_test.dart
...flutter_tools/test/integration.shard/hot_reload_test.dart
+1
-0
test_driver.dart
...ges/flutter_tools/test/integration.shard/test_driver.dart
+1
-1
common.dart
packages/flutter_tools/test/src/common.dart
+9
-0
No files found.
packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
View file @
a18e6361
...
...
@@ -620,13 +620,12 @@ class FuchsiaDevice extends Device {
// loopback (::1).
final
Uri
uri
=
Uri
.
parse
(
'http://[
$_ipv6Loopback
]:
$port
'
);
final
VMService
vmService
=
await
VMService
.
connect
(
uri
);
await
vmService
.
getVMOld
();
await
vmService
.
refreshViews
();
for
(
final
FlutterView
flutterView
in
vmService
.
vm
.
views
)
{
final
List
<
FlutterView
>
flutterViews
=
await
vmService
.
getFlutterViews
();
for
(
final
FlutterView
flutterView
in
flutterViews
)
{
if
(
flutterView
.
uiIsolate
==
null
)
{
continue
;
}
final
Uri
address
=
flutterView
.
owner
.
vmService
.
httpAddress
;
final
Uri
address
=
vmService
.
httpAddress
;
if
(
flutterView
.
uiIsolate
.
name
.
contains
(
isolateName
))
{
return
address
.
port
;
}
...
...
@@ -717,13 +716,12 @@ class FuchsiaIsolateDiscoveryProtocol {
continue
;
}
}
await
service
.
getVMOld
();
await
service
.
refreshViews
();
for
(
final
FlutterView
flutterView
in
service
.
vm
.
views
)
{
final
List
<
FlutterView
>
flutterViews
=
await
service
.
getFlutterViews
();
for
(
final
FlutterView
flutterView
in
flutterViews
)
{
if
(
flutterView
.
uiIsolate
==
null
)
{
continue
;
}
final
Uri
address
=
flutterView
.
owner
.
vmS
ervice
.
httpAddress
;
final
Uri
address
=
s
ervice
.
httpAddress
;
if
(
flutterView
.
uiIsolate
.
name
.
contains
(
_isolateName
))
{
_foundUri
.
complete
(
_device
.
ipv6
?
Uri
.
parse
(
'http://[
$_ipv6Loopback
]:
${address.port}
/'
)
...
...
packages/flutter_tools/lib/src/resident_runner.dart
View file @
a18e6361
...
...
@@ -233,18 +233,25 @@ class FlutterDevice {
if
(
vmService
==
null
)
{
return
;
}
await
flutterDeprecatedVmService
.
vm
.
refreshViews
(
waitForViews:
true
);
final
List
<
FlutterView
>
updatedViews
=
await
vmService
.
getFlutterViews
();
_views
..
clear
()
..
addAll
(
updatedViews
);
}
final
List
<
FlutterView
>
_views
=
<
FlutterView
>[];
List
<
FlutterView
>
get
views
{
if
(
vmService
==
null
||
flutterDeprecatedVmService
.
isClosed
)
{
if
(
vmService
==
null
)
{
return
<
FlutterView
>[];
}
return
(
viewFilter
!=
null
?
flutterDeprecatedVmService
.
vm
.
allViewsWithName
(
viewFilter
)
:
flutterDeprecatedVmService
.
vm
.
views
).
toList
();
if
(
viewFilter
!=
null
)
{
return
<
FlutterView
>[
for
(
final
FlutterView
flutterView
in
views
)
if
(
flutterView
.
uiIsolate
.
name
.
contains
(
viewFilter
))
flutterView
];
}
return
_views
;
}
Future
<
void
>
getVMs
()
=>
flutterDeprecatedVmService
.
getVMOld
();
...
...
@@ -254,35 +261,32 @@ class FlutterDevice {
await
device
.
stopApp
(
package
);
return
;
}
final
List
<
FlutterView
>
flutterViews
=
views
;
if
(
flutterViews
==
null
||
flutterV
iews
.
isEmpty
)
{
await
refreshViews
()
;
if
(
views
==
null
||
v
iews
.
isEmpty
)
{
return
;
}
// If any of the flutter views are paused, we might not be able to
// cleanly exit since the service extension may not have been registered.
if
(
flutterViews
.
any
((
FlutterView
view
)
{
return
view
!=
null
&&
view
.
uiIsolate
!=
null
&&
view
.
uiIsolate
.
pauseEvent
!=
null
&&
view
.
uiIsolate
.
pauseEvent
.
isPauseEvent
;
for
(
final
FlutterView
flutterView
in
views
)
{
final
vm_service
.
Isolate
isolate
=
await
vmService
.
getIsolateOrNull
(
flutterView
.
uiIsolate
.
id
);
if
(
isolate
==
null
)
{
continue
;
}
if
(
isPauseEvent
(
isolate
.
pauseEvent
.
kind
))
{
await
device
.
stopApp
(
package
);
return
;
}
))
{
await
device
.
stopApp
(
package
);
return
;
}
final
List
<
Future
<
void
>>
futures
=
<
Future
<
void
>>[];
for
(
final
FlutterView
view
in
flutterViews
)
{
for
(
final
FlutterView
view
in
views
)
{
if
(
view
!=
null
&&
view
.
uiIsolate
!=
null
)
{
assert
(!
view
.
uiIsolate
.
pauseEvent
.
isPauseEvent
);
futures
.
ad
d
(
vmService
.
flutterExit
(
// If successful, there will be no response from flutterExit.
unawaite
d
(
vmService
.
flutterExit
(
isolateId:
view
.
uiIsolate
.
id
,
));
}
}
// The flutterExit message only returns if it fails, so just wait a few
// seconds then assume it worked.
// TODO(ianh): We should make this return once the VM service disconnects.
await
Future
.
wait
(
futures
).
timeout
(
const
Duration
(
seconds:
2
),
onTimeout:
()
=>
<
void
>[]);
return
vmService
.
onDone
;
}
Future
<
Uri
>
setupDevFS
(
...
...
packages/flutter_tools/lib/src/run_hot.dart
View file @
a18e6361
This diff is collapsed.
Click to expand it.
packages/flutter_tools/lib/src/tracing.dart
View file @
a18e6361
...
...
@@ -53,8 +53,9 @@ class Tracing {
}
});
bool
done
=
false
;
for
(
final
FlutterView
view
in
vmService
.
vm
.
views
)
{
if
(
await
view
.
uiIsolate
.
vmService
final
List
<
FlutterView
>
views
=
await
vmService
.
getFlutterViews
();
for
(
final
FlutterView
view
in
views
)
{
if
(
await
vmService
.
flutterAlreadyPaintedFirstUsefulFrame
(
isolateId:
view
.
uiIsolate
.
id
,
))
{
...
...
packages/flutter_tools/lib/src/vmservice.dart
View file @
a18e6361
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart
View file @
a18e6361
...
...
@@ -7,6 +7,7 @@ import 'dart:async';
import
'package:file/memory.dart'
;
import
'package:meta/meta.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:platform/platform.dart'
;
import
'package:process/process.dart'
;
import
'package:quiver/testing/async.dart'
;
import
'package:vm_service/vm_service.dart'
as
vm_service
;
...
...
@@ -34,6 +35,22 @@ import '../../src/context.dart';
import
'../../src/fakes.dart'
;
import
'../../src/mocks.dart'
;
final
vm_service
.
Isolate
fakeUnpausedIsolate
=
vm_service
.
Isolate
(
id:
'1'
,
pauseEvent:
vm_service
.
Event
(
kind:
vm_service
.
EventKind
.
kResume
,
timestamp:
0
),
breakpoints:
<
vm_service
.
Breakpoint
>[],
exceptionPauseMode:
null
,
libraries:
<
vm_service
.
LibraryRef
>[],
livePorts:
0
,
name:
'test'
,
number:
'1'
,
pauseOnExit:
false
,
runnable:
true
,
startTime:
0
,
);
void
main
(
)
{
group
(
'attach'
,
()
{
...
...
@@ -491,7 +508,7 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
testFileSystem
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
}
);
}
,
skip:
const
LocalPlatform
().
isWindows
);
// mDNS does not work on Windows.
group
(
'forwarding to given port'
,
()
{
const
int
devicePort
=
499
;
...
...
@@ -805,11 +822,21 @@ VMServiceConnector getFakeVmServiceFactory({
version:
''
,
);
});
when
(
vm
.
refreshViews
(
waitForViews:
anyNamed
(
'waitForViews'
)))
.
thenAnswer
((
_
)
=>
Future
<
void
>.
value
(
null
));
when
(
vm
.
views
)
.
thenReturn
(<
FlutterView
>[
FlutterViewMock
()]);
when
(
vmService
.
getIsolate
(
any
))
.
thenAnswer
((
Invocation
invocation
)
async
{
return
fakeUnpausedIsolate
;
});
when
(
vmService
.
callMethod
(
kListViewsMethod
))
.
thenAnswer
((
_
)
async
{
return
vm_service
.
Response
.
parse
(<
String
,
Object
>{
'views'
:
<
Object
>[
<
String
,
Object
>{
'id'
:
'1'
,
'isolate'
:
fakeUnpausedIsolate
.
toJson
()
}
]
});
});
when
(
vm
.
createDevFS
(
any
))
.
thenAnswer
((
_
)
=>
Future
<
Map
<
String
,
dynamic
>>.
value
(<
String
,
dynamic
>{
'uri'
:
'/'
,}));
...
...
@@ -859,7 +886,6 @@ class TestHotRunnerFactory extends HotRunnerFactory {
class
VMMock
extends
Mock
implements
VM
{}
class
VMServiceMock
extends
Mock
implements
VMService
{}
class
FlutterViewMock
extends
Mock
implements
FlutterView
{}
class
MockProcessManager
extends
Mock
implements
ProcessManager
{}
class
MockProcess
extends
Mock
implements
Process
{}
class
MockHttpClientRequest
extends
Mock
implements
HttpClientRequest
{}
...
...
packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_test.dart
View file @
a18e6361
...
...
@@ -6,6 +6,12 @@ import 'dart:async';
import
'dart:convert'
;
import
'package:file/memory.dart'
;
import
'package:vm_service/vm_service.dart'
as
vm_service
;
import
'package:meta/meta.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:platform/platform.dart'
;
import
'package:process/process.dart'
;
import
'package:flutter_tools/src/application_package.dart'
;
import
'package:flutter_tools/src/artifacts.dart'
;
import
'package:flutter_tools/src/base/common.dart'
;
...
...
@@ -27,14 +33,27 @@ import 'package:flutter_tools/src/fuchsia/tiles_ctl.dart';
import
'package:flutter_tools/src/globals.dart'
as
globals
;
import
'package:flutter_tools/src/project.dart'
;
import
'package:flutter_tools/src/vmservice.dart'
;
import
'package:meta/meta.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:platform/platform.dart'
;
import
'package:process/process.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
final
vm_service
.
Isolate
fakeIsolate
=
vm_service
.
Isolate
(
id:
'1'
,
pauseEvent:
vm_service
.
Event
(
kind:
vm_service
.
EventKind
.
kResume
,
timestamp:
0
),
breakpoints:
<
vm_service
.
Breakpoint
>[],
exceptionPauseMode:
null
,
libraries:
<
vm_service
.
LibraryRef
>[],
livePorts:
0
,
name:
'wrong name'
,
number:
'1'
,
pauseOnExit:
false
,
runnable:
true
,
startTime:
0
,
);
void
main
(
)
{
group
(
'fuchsia device'
,
()
{
MemoryFileSystem
memoryFileSystem
;
...
...
@@ -607,71 +626,92 @@ void main() {
});
group
(
FuchsiaIsolateDiscoveryProtocol
,
()
{
group
(
'FuchsiaIsolateDiscoveryProtocol'
,
()
{
MockPortForwarder
portForwarder
;
MockVMService
vmService
;
MockVM
vm
;
setUp
(()
{
portForwarder
=
MockPortForwarder
();
vmService
=
MockVMService
();
vm
=
MockVM
();
when
(
vm
.
vmService
).
thenReturn
(
vmService
);
when
(
vmService
.
vm
).
thenReturn
(
vm
);
});
Future
<
Uri
>
findUri
(
List
<
MockFlutterView
>
views
,
String
expectedIsolateName
)
async
{
when
(
vm
.
views
).
thenReturn
(
views
);
for
(
final
MockFlutterView
view
in
views
)
{
when
(
view
.
owner
).
thenReturn
(
vm
);
}
Future
<
Uri
>
findUri
(
List
<
FlutterView
>
views
,
String
expectedIsolateName
)
async
{
final
MockFuchsiaDevice
fuchsiaDevice
=
MockFuchsiaDevice
(
'123'
,
portForwarder
,
false
);
MockFuchsiaDevice
(
'123'
,
portForwarder
,
false
);
final
FuchsiaIsolateDiscoveryProtocol
discoveryProtocol
=
FuchsiaIsolateDiscoveryProtocol
(
FuchsiaIsolateDiscoveryProtocol
(
fuchsiaDevice
,
expectedIsolateName
,
(
Uri
uri
)
async
=>
vmService
,
true
,
// only poll once.
);
when
(
fuchsiaDevice
.
servicePorts
())
.
thenAnswer
((
Invocation
invocation
)
async
=>
<
int
>[
1
]);
when
(
portForwarder
.
forward
(
1
))
.
thenAnswer
((
Invocation
invocation
)
async
=>
2
);
when
(
vmService
.
getVMOld
())
.
thenAnswer
((
Invocation
invocation
)
=>
Future
<
void
>.
value
(
null
));
when
(
vmService
.
refreshViews
())
.
thenAnswer
((
Invocation
invocation
)
=>
Future
<
void
>.
value
(
null
));
when
(
vmService
.
httpAddress
).
thenReturn
(
Uri
.
parse
(
'example'
));
when
(
vmService
.
callMethod
(
kListViewsMethod
)).
thenAnswer
((
Invocation
invocation
)
async
{
return
vm_service
.
Response
.
parse
(<
String
,
Object
>{
'views'
:
<
Object
>[
for
(
FlutterView
view
in
views
)
view
.
toJson
()
],
});
});
return
await
discoveryProtocol
.
uri
;
}
testUsingContext
(
'can find flutter view with matching isolate name'
,
()
async
{
const
String
expectedIsolateName
=
'foobar'
;
final
Uri
uri
=
await
findUri
(<
MockFlutterView
>[
MockFlutterView
(
null
),
// no ui isolate.
MockFlutterView
(
MockIsolate
(
'wrong name'
)),
// wrong name.
MockFlutterView
(
MockIsolate
(
expectedIsolateName
)),
// matching name.
final
Uri
uri
=
await
findUri
(<
FlutterView
>[
// no ui isolate.
FlutterView
(
id:
'1'
,
uiIsolate:
null
),
// wrong name.
FlutterView
(
id:
'2'
,
uiIsolate:
vm_service
.
Isolate
.
parse
(<
String
,
dynamic
>{
...
fakeIsolate
.
toJson
(),
'name'
:
'Wrong name'
,
}),
),
// matching name.
FlutterView
(
id:
'3'
,
uiIsolate:
vm_service
.
Isolate
.
parse
(<
String
,
dynamic
>{
...
fakeIsolate
.
toJson
(),
'name'
:
expectedIsolateName
,
}),
),
],
expectedIsolateName
);
expect
(
uri
.
toString
(),
'http://
${InternetAddress.loopbackIPv4.address}
:0/'
);
});
testUsingContext
(
'can handle flutter view without matching isolate name'
,
()
async
{
const
String
expectedIsolateName
=
'foobar'
;
final
Future
<
Uri
>
uri
=
findUri
(<
MockFlutterView
>[
MockFlutterView
(
null
),
// no ui isolate.
MockFlutterView
(
MockIsolate
(
'wrong name'
)),
// wrong name.
final
Future
<
Uri
>
uri
=
findUri
(<
FlutterView
>[
// no ui isolate.
FlutterView
(
id:
'1'
,
uiIsolate:
null
),
// wrong name.
FlutterView
(
id:
'2'
,
uiIsolate:
vm_service
.
Isolate
.
parse
(<
String
,
Object
>{
...
fakeIsolate
.
toJson
(),
'name'
:
'wrong name'
,
})),
],
expectedIsolateName
);
expect
(
uri
,
throwsException
);
});
testUsingContext
(
'can handle non flutter view'
,
()
async
{
const
String
expectedIsolateName
=
'foobar'
;
final
Future
<
Uri
>
uri
=
findUri
(<
Mock
FlutterView
>[
MockFlutterView
(
null
),
// no ui isolate.
final
Future
<
Uri
>
uri
=
findUri
(<
FlutterView
>[
FlutterView
(
id:
'1'
,
uiIsolate:
null
),
// no ui isolate.
],
expectedIsolateName
);
expect
(
uri
,
throwsException
);
});
});
...
...
@@ -1083,22 +1123,6 @@ class MockPortForwarder extends Mock implements DevicePortForwarder {}
class
MockVMService
extends
Mock
implements
VMService
{}
class
MockVM
extends
Mock
implements
VM
{}
class
MockFlutterView
extends
Mock
implements
FlutterView
{
MockFlutterView
(
this
.
uiIsolate
);
@override
final
Isolate
uiIsolate
;
}
class
MockIsolate
extends
Mock
implements
Isolate
{
MockIsolate
(
this
.
name
);
@override
final
String
name
;
}
class
FuchsiaDeviceWithFakeDiscovery
extends
FuchsiaDevice
{
FuchsiaDeviceWithFakeDiscovery
(
String
id
,
{
String
name
})
:
super
(
id
,
name:
name
);
...
...
packages/flutter_tools/test/general.shard/hot_test.dart
View file @
a18e6361
...
...
@@ -4,6 +4,7 @@
import
'dart:async'
;
import
'package:vm_service/vm_service.dart'
as
vm_service
;
import
'package:flutter_tools/src/artifacts.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/build_info.dart'
;
...
...
@@ -170,6 +171,52 @@ void main() {
});
testUsingContext
(
'Does hot restarts when all devices support it'
,
()
async
{
final
FakeVmServiceHost
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
const
FakeVmServiceRequest
(
id:
'1'
,
method:
kListViewsMethod
,
args:
null
,
jsonResponse:
<
String
,
Object
>{
'views'
:
<
Object
>[],
}
),
const
FakeVmServiceRequest
(
id:
'2'
,
method:
kListViewsMethod
,
args:
null
,
jsonResponse:
<
String
,
Object
>{
'views'
:
<
Object
>[],
}
),
FakeVmServiceRequest
(
id:
'3'
,
method:
'getVM'
,
args:
null
,
jsonResponse:
vm_service
.
VM
.
parse
(<
String
,
Object
>{}).
toJson
()
),
FakeVmServiceRequest
(
id:
'4'
,
method:
'getVM'
,
args:
null
,
jsonResponse:
vm_service
.
VM
.
parse
(<
String
,
Object
>{}).
toJson
()
),
const
FakeVmServiceRequest
(
id:
'5'
,
method:
kListViewsMethod
,
args:
null
,
jsonResponse:
<
String
,
Object
>{
'views'
:
<
Object
>[],
}
),
const
FakeVmServiceRequest
(
id:
'6'
,
method:
kListViewsMethod
,
args:
null
,
jsonResponse:
<
String
,
Object
>{
'views'
:
<
Object
>[],
}
),
]);
// Setup mocks
final
MockDevice
mockDevice
=
MockDevice
();
final
MockDevice
mockHotDevice
=
MockDevice
();
...
...
@@ -179,8 +226,12 @@ void main() {
when
(
mockHotDevice
.
supportsHotRestart
).
thenReturn
(
true
);
// Trigger a restart.
final
List
<
FlutterDevice
>
devices
=
<
FlutterDevice
>[
FlutterDevice
(
mockDevice
,
generator:
residentCompiler
,
buildInfo:
BuildInfo
.
debug
)..
devFS
=
mockDevFs
,
FlutterDevice
(
mockHotDevice
,
generator:
residentCompiler
,
buildInfo:
BuildInfo
.
debug
)..
devFS
=
mockDevFs
,
FlutterDevice
(
mockDevice
,
generator:
residentCompiler
,
buildInfo:
BuildInfo
.
debug
)
..
vmService
=
fakeVmServiceHost
.
vmService
..
devFS
=
mockDevFs
,
FlutterDevice
(
mockHotDevice
,
generator:
residentCompiler
,
buildInfo:
BuildInfo
.
debug
)
..
vmService
=
fakeVmServiceHost
.
vmService
..
devFS
=
mockDevFs
,
];
final
HotRunner
hotRunner
=
HotRunner
(
devices
);
final
OperationResult
result
=
await
hotRunner
.
restart
(
fullRestart:
true
);
...
...
@@ -211,13 +262,39 @@ void main() {
testUsingContext
(
'hot restart supported'
,
()
async
{
// Setup mocks
final
FakeVmServiceHost
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
const
FakeVmServiceRequest
(
id:
'1'
,
method:
kListViewsMethod
,
args:
null
,
jsonResponse:
<
String
,
Object
>{
'views'
:
<
Object
>[],
}
),
FakeVmServiceRequest
(
id:
'2'
,
method:
'getVM'
,
args:
null
,
jsonResponse:
vm_service
.
VM
.
parse
(<
String
,
Object
>{}).
toJson
()
),
const
FakeVmServiceRequest
(
id:
'3'
,
method:
kListViewsMethod
,
args:
null
,
jsonResponse:
<
String
,
Object
>{
'views'
:
<
Object
>[],
}
),
]);
final
MockDevice
mockDevice
=
MockDevice
();
when
(
mockDevice
.
supportsHotReload
).
thenReturn
(
true
);
when
(
mockDevice
.
supportsHotRestart
).
thenReturn
(
true
);
when
(
mockDevice
.
targetPlatform
).
thenAnswer
((
Invocation
_
)
async
=>
TargetPlatform
.
tester
);
// Trigger hot restart.
final
List
<
FlutterDevice
>
devices
=
<
FlutterDevice
>[
FlutterDevice
(
mockDevice
,
generator:
residentCompiler
,
buildInfo:
BuildInfo
.
debug
)..
devFS
=
mockDevFs
,
FlutterDevice
(
mockDevice
,
generator:
residentCompiler
,
buildInfo:
BuildInfo
.
debug
)
..
vmService
=
fakeVmServiceHost
.
vmService
..
devFS
=
mockDevFs
,
];
final
HotRunner
hotRunner
=
HotRunner
(
devices
);
final
OperationResult
result
=
await
hotRunner
.
restart
(
fullRestart:
true
);
...
...
packages/flutter_tools/test/general.shard/resident_runner_test.dart
View file @
a18e6361
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/general.shard/vmservice_test.dart
View file @
a18e6361
...
...
@@ -91,46 +91,6 @@ final Map<String, Object> listViews = <String, dynamic>{
typedef
ServiceCallback
=
Future
<
Map
<
String
,
dynamic
>>
Function
(
Map
<
String
,
Object
>);
void
main
(
)
{
testUsingContext
(
'VMService can refreshViews'
,
()
async
{
final
MockVMService
mockVmService
=
MockVMService
();
final
VMService
vmService
=
VMService
(
null
,
null
,
null
,
null
,
null
,
null
,
null
,
mockVmService
,
Completer
<
void
>(),
const
Stream
<
dynamic
>.
empty
(),
);
verify
(
mockVmService
.
registerService
(
'flutterVersion'
,
'Flutter Tools'
)).
called
(
1
);
when
(
mockVmService
.
callServiceExtension
(
'getVM'
,
args:
anyNamed
(
'args'
),
// Empty
isolateId:
null
)).
thenAnswer
((
Invocation
invocation
)
async
{
return
vm_service
.
Response
.
parse
(
vm
);
});
await
vmService
.
getVMOld
();
when
(
mockVmService
.
callServiceExtension
(
'_flutter.listViews'
,
args:
anyNamed
(
'args'
),
isolateId:
anyNamed
(
'isolateId'
)
)).
thenAnswer
((
Invocation
invocation
)
async
{
return
vm_service
.
Response
.
parse
(
listViews
);
});
await
vmService
.
refreshViews
(
waitForViews:
true
);
expect
(
vmService
.
vm
.
name
,
'vm'
);
expect
(
vmService
.
vm
.
views
.
single
.
id
,
'_flutterView/0x4a4c1f8'
);
},
overrides:
<
Type
,
Generator
>{
Logger:
()
=>
BufferLogger
.
test
()
});
testUsingContext
(
'VmService registers reloadSources'
,
()
{
Future
<
void
>
reloadSources
(
String
isolateId
,
{
bool
pause
,
bool
force
})
async
{}
final
MockVMService
mockVMService
=
MockVMService
();
...
...
packages/flutter_tools/test/integration.shard/hot_reload_test.dart
View file @
a18e6361
...
...
@@ -97,6 +97,7 @@ void main() {
_project
.
scheduledBreakpointUri
,
_project
.
scheduledBreakpointLine
,
);
await
Future
<
void
>.
delayed
(
const
Duration
(
seconds:
2
));
await
_flutter
.
hotReload
();
// reload triggers code which eventually hits the breakpoint
isolate
=
await
_flutter
.
waitForPause
();
expect
(
isolate
.
pauseEvent
.
kind
,
equals
(
EventKind
.
kPauseBreakpoint
));
...
...
packages/flutter_tools/test/integration.shard/test_driver.dart
View file @
a18e6361
...
...
@@ -191,7 +191,7 @@ abstract class FlutterTestDriver {
// ceases to be the case, this code will need changing.
if
(
_flutterIsolateId
==
null
)
{
final
VM
vm
=
await
_vmService
.
getVM
();
_flutterIsolateId
=
vm
.
isolates
.
first
.
id
;
_flutterIsolateId
=
vm
.
isolates
.
single
.
id
;
}
return
_flutterIsolateId
;
}
...
...
packages/flutter_tools/test/src/common.dart
View file @
a18e6361
...
...
@@ -242,6 +242,11 @@ class FakeVmServiceHost {
.
having
((
Map
<
String
,
Object
>
request
)
=>
request
[
'id'
],
'id'
,
fakeRequest
.
id
)
.
having
((
Map
<
String
,
Object
>
request
)
=>
request
[
'params'
],
'args'
,
fakeRequest
.
args
)
);
if
(
fakeRequest
.
close
)
{
_vmService
.
dispose
();
expect
(
_requests
,
isEmpty
);
return
;
}
if
(
fakeRequest
.
errorCode
==
null
)
{
_input
.
add
(
json
.
encode
(<
String
,
Object
>{
'jsonrpc'
:
'2.0'
,
...
...
@@ -298,11 +303,15 @@ class FakeVmServiceRequest implements VmServiceExpectation {
@required
this
.
args
,
this
.
jsonResponse
,
this
.
errorCode
,
this
.
close
=
false
,
});
final
String
method
;
final
String
id
;
/// When true, the vm service is automatically closed.
final
bool
close
;
/// If non-null, the error code for a [vm_service.RPCError] in place of a
/// standard response.
final
int
errorCode
;
...
...
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