replace package:vm_service_client with package:vm_service in the devicelab project (#41646)
This commit is contained in:
committed by
Jonah Williams
parent
2713ee61f0
commit
4de496a4e5
@@ -6,12 +6,12 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:vm_service_client/vm_service_client.dart';
|
||||
|
||||
import 'package:flutter_devicelab/framework/adb.dart';
|
||||
import 'package:flutter_devicelab/framework/framework.dart';
|
||||
import 'package:flutter_devicelab/framework/utils.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:vm_service/vm_service.dart';
|
||||
import 'package:vm_service/vm_service_io.dart';
|
||||
|
||||
void main() {
|
||||
task(() async {
|
||||
@@ -56,7 +56,7 @@ void main() {
|
||||
if (!ok)
|
||||
throw 'Failed to run test app.';
|
||||
|
||||
final VMServiceClient client = VMServiceClient.connect('ws://localhost:$vmServicePort/ws');
|
||||
final VmService client = await vmServiceConnectUri('ws://localhost:$vmServicePort/ws');
|
||||
|
||||
final DriveHelper driver = DriveHelper(vmServicePort);
|
||||
|
||||
@@ -96,7 +96,7 @@ void main() {
|
||||
if (result != 0)
|
||||
throw 'Received unexpected exit code $result from run process.';
|
||||
print('test: validating that the app has in fact closed...');
|
||||
await client.done.timeout(const Duration(seconds: 5));
|
||||
await client.onDone.timeout(const Duration(seconds: 5));
|
||||
});
|
||||
return TaskResult.success(null);
|
||||
});
|
||||
|
||||
@@ -6,12 +6,12 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:vm_service_client/vm_service_client.dart';
|
||||
|
||||
import 'package:flutter_devicelab/framework/adb.dart';
|
||||
import 'package:flutter_devicelab/framework/framework.dart';
|
||||
import 'package:flutter_devicelab/framework/utils.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:vm_service/vm_service.dart';
|
||||
import 'package:vm_service/vm_service_io.dart';
|
||||
|
||||
void main() {
|
||||
Map<String, dynamic> parseFlutterResponse(String line) {
|
||||
@@ -84,7 +84,7 @@ void main() {
|
||||
if (!ok)
|
||||
throw 'Failed to run test app.';
|
||||
|
||||
final VMServiceClient client = VMServiceClient.connect(vmServiceUri);
|
||||
final VmService client = await vmServiceConnectUri(vmServiceUri.toString());
|
||||
|
||||
int id = 1;
|
||||
Future<Map<String, dynamic>> sendRequest(String method, dynamic params) async {
|
||||
@@ -159,7 +159,7 @@ void main() {
|
||||
if (result != 0)
|
||||
throw 'Received unexpected exit code $result from run process.';
|
||||
print('test: validating that the app has in fact closed...');
|
||||
await client.done;
|
||||
await client.onDone;
|
||||
});
|
||||
return TaskResult.success(null);
|
||||
});
|
||||
|
||||
@@ -10,7 +10,8 @@ import 'package:flutter_devicelab/framework/adb.dart';
|
||||
import 'package:flutter_devicelab/framework/framework.dart';
|
||||
import 'package:flutter_devicelab/framework/utils.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:vm_service_client/vm_service_client.dart';
|
||||
import 'package:vm_service/vm_service.dart';
|
||||
import 'package:vm_service/vm_service_io.dart';
|
||||
|
||||
void main() {
|
||||
task(() async {
|
||||
@@ -53,52 +54,56 @@ void main() {
|
||||
if (!ok)
|
||||
throw 'Failed to run test app.';
|
||||
|
||||
final VMServiceClient client = VMServiceClient.connect('ws://localhost:$vmServicePort/ws');
|
||||
final VmService client = await vmServiceConnectUri('ws://localhost:$vmServicePort/ws');
|
||||
final VM vm = await client.getVM();
|
||||
final VMIsolateRef isolate = vm.isolates.first;
|
||||
final IsolateRef isolateRef = vm.isolates.first;
|
||||
|
||||
final StreamController<VMExtensionEvent> frameEventsController = StreamController<VMExtensionEvent>();
|
||||
final StreamController<VMExtensionEvent> navigationEventsController = StreamController<VMExtensionEvent>();
|
||||
isolate.onExtensionEvent.listen((VMExtensionEvent event) {
|
||||
if (event.kind == 'Flutter.Frame') {
|
||||
client.streamListen(EventStreams.kExtension);
|
||||
|
||||
final StreamController<Event> frameEventsController = StreamController<Event>();
|
||||
final StreamController<Event> navigationEventsController = StreamController<Event>();
|
||||
client.onExtensionEvent.listen((Event event) {
|
||||
if (event.extensionKind == 'Flutter.Frame') {
|
||||
frameEventsController.add(event);
|
||||
} else if (event.kind == 'Flutter.Navigation') {
|
||||
} else if (event.extensionKind == 'Flutter.Navigation') {
|
||||
navigationEventsController.add(event);
|
||||
}
|
||||
});
|
||||
|
||||
final Stream<VMExtensionEvent> frameEvents = frameEventsController.stream;
|
||||
final Stream<VMExtensionEvent> navigationEvents = navigationEventsController.stream;
|
||||
final Stream<Event> frameEvents = frameEventsController.stream;
|
||||
final Stream<Event> navigationEvents = navigationEventsController.stream;
|
||||
|
||||
print('reassembling app...');
|
||||
final Future<VMExtensionEvent> frameFuture = frameEvents.first;
|
||||
await isolate.invokeExtension('ext.flutter.reassemble');
|
||||
final Future<Event> frameFuture = frameEvents.first;
|
||||
await client.callServiceExtension('ext.flutter.reassemble', isolateId: isolateRef.id);
|
||||
|
||||
// ensure we get an event
|
||||
final VMExtensionEvent event = await frameFuture;
|
||||
print('${event.kind}: ${event.data}');
|
||||
final Event event = await frameFuture;
|
||||
print('${event.extensionKind}: ${event.extensionData}');
|
||||
|
||||
final Map<String, dynamic> eventData = event.extensionData.data.cast<String, dynamic>();
|
||||
|
||||
// validate the fields
|
||||
// {number: 8, startTime: 0, elapsed: 1437, build: 600, raster: 800}
|
||||
expect(event.data['number'] is int);
|
||||
expect(event.data['number'] >= 0);
|
||||
expect(event.data['startTime'] is int);
|
||||
expect(event.data['startTime'] >= 0);
|
||||
expect(event.data['elapsed'] is int);
|
||||
expect(event.data['elapsed'] >= 0);
|
||||
expect(event.data['build'] is int);
|
||||
expect(event.data['build'] >= 0);
|
||||
expect(event.data['raster'] is int);
|
||||
expect(event.data['raster'] >= 0);
|
||||
expect(eventData['number'] is int);
|
||||
expect(eventData['number'] >= 0);
|
||||
expect(eventData['startTime'] is int);
|
||||
expect(eventData['startTime'] >= 0);
|
||||
expect(eventData['elapsed'] is int);
|
||||
expect(eventData['elapsed'] >= 0);
|
||||
expect(eventData['build'] is int);
|
||||
expect(eventData['build'] >= 0);
|
||||
expect(eventData['raster'] is int);
|
||||
expect(eventData['raster'] >= 0);
|
||||
|
||||
final Future<VMExtensionEvent> navigationFuture = navigationEvents.first;
|
||||
final Future<Event> navigationFuture = navigationEvents.first;
|
||||
// This tap triggers a navigation event.
|
||||
device.tap(100, 200);
|
||||
|
||||
final VMExtensionEvent navigationEvent = await navigationFuture;
|
||||
final Event navigationEvent = await navigationFuture;
|
||||
// validate the fields
|
||||
expect(navigationEvent.data['route'] is Map<dynamic, dynamic>);
|
||||
final Map<dynamic, dynamic> route = navigationEvent.data['route'];
|
||||
expect(navigationEvent.extensionData.data['route'] is Map<dynamic, dynamic>);
|
||||
final Map<dynamic, dynamic> route = navigationEvent.extensionData.data['route'];
|
||||
expect(route['description'] is String);
|
||||
expect(route['settings'] is Map<dynamic, dynamic>);
|
||||
final Map<dynamic, dynamic> settings = route['settings'];
|
||||
|
||||
Reference in New Issue
Block a user