Adds vmservices for getting iOS build options (#121736)
Adds vmservices for getting iOS build options
This commit is contained in:
@@ -11,6 +11,7 @@ import 'package:flutter_tools/src/build_system/targets/shader_compiler.dart';
|
||||
import 'package:flutter_tools/src/compile.dart';
|
||||
import 'package:flutter_tools/src/devfs.dart';
|
||||
import 'package:flutter_tools/src/device.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/resident_runner.dart';
|
||||
import 'package:flutter_tools/src/run_cold.dart';
|
||||
import 'package:flutter_tools/src/tracing.dart';
|
||||
@@ -213,6 +214,7 @@ class TestFlutterDevice extends FlutterDevice {
|
||||
Restart? restart,
|
||||
CompileExpression? compileExpression,
|
||||
GetSkSLMethod? getSkSLMethod,
|
||||
FlutterProject? flutterProject,
|
||||
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
|
||||
bool enableDds = true,
|
||||
bool cacheStartupProfile = false,
|
||||
|
||||
@@ -15,6 +15,7 @@ import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/convert.dart';
|
||||
import 'package:flutter_tools/src/device.dart';
|
||||
import 'package:flutter_tools/src/drive/drive_service.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/resident_runner.dart';
|
||||
import 'package:flutter_tools/src/version.dart';
|
||||
import 'package:flutter_tools/src/vmservice.dart';
|
||||
@@ -443,6 +444,7 @@ FlutterDriverService setUpDriverService({
|
||||
Restart? restart,
|
||||
CompileExpression? compileExpression,
|
||||
GetSkSLMethod? getSkSLMethod,
|
||||
FlutterProject? flutterProject,
|
||||
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
|
||||
io.CompressionOptions compression = io.CompressionOptions.compressionDefault,
|
||||
Device? device,
|
||||
|
||||
@@ -16,6 +16,7 @@ import 'package:flutter_tools/src/build_system/targets/shader_compiler.dart';
|
||||
import 'package:flutter_tools/src/compile.dart';
|
||||
import 'package:flutter_tools/src/devfs.dart';
|
||||
import 'package:flutter_tools/src/device.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
import 'package:flutter_tools/src/resident_devtools_handler.dart';
|
||||
import 'package:flutter_tools/src/resident_runner.dart';
|
||||
@@ -678,6 +679,7 @@ class TestFlutterDevice extends FlutterDevice {
|
||||
Restart? restart,
|
||||
CompileExpression? compileExpression,
|
||||
GetSkSLMethod? getSkSLMethod,
|
||||
FlutterProject? flutterProject,
|
||||
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
|
||||
bool disableServiceAuthCodes = false,
|
||||
bool enableDds = true,
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'package:flutter_tools/src/base/io.dart' as io;
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/device.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/test/integration_test_device.dart';
|
||||
import 'package:flutter_tools/src/test/test_device.dart';
|
||||
import 'package:flutter_tools/src/vmservice.dart';
|
||||
@@ -135,6 +136,7 @@ void main() {
|
||||
Restart? restart,
|
||||
CompileExpression? compileExpression,
|
||||
GetSkSLMethod? getSkSLMethod,
|
||||
FlutterProject? flutterProject,
|
||||
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
|
||||
io.CompressionOptions? compression,
|
||||
Device? device,
|
||||
@@ -154,6 +156,7 @@ void main() {
|
||||
Restart? restart,
|
||||
CompileExpression? compileExpression,
|
||||
GetSkSLMethod? getSkSLMethod,
|
||||
FlutterProject? flutterProject,
|
||||
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
|
||||
io.CompressionOptions? compression,
|
||||
Device? device,
|
||||
@@ -184,6 +187,7 @@ void main() {
|
||||
Restart? restart,
|
||||
CompileExpression? compileExpression,
|
||||
GetSkSLMethod? getSkSLMethod,
|
||||
FlutterProject? flutterProject,
|
||||
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
|
||||
io.CompressionOptions? compression,
|
||||
Device? device,
|
||||
@@ -213,6 +217,7 @@ void main() {
|
||||
Restart? restart,
|
||||
CompileExpression? compileExpression,
|
||||
GetSkSLMethod? getSkSLMethod,
|
||||
FlutterProject? flutterProject,
|
||||
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
|
||||
io.CompressionOptions? compression,
|
||||
Device? device,
|
||||
@@ -230,6 +235,7 @@ void main() {
|
||||
Restart? restart,
|
||||
CompileExpression? compileExpression,
|
||||
GetSkSLMethod? getSkSLMethod,
|
||||
FlutterProject? flutterProject,
|
||||
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
|
||||
io.CompressionOptions? compression,
|
||||
Device? device,
|
||||
|
||||
@@ -27,6 +27,7 @@ import 'package:flutter_tools/src/device.dart';
|
||||
import 'package:flutter_tools/src/device_port_forwarder.dart';
|
||||
import 'package:flutter_tools/src/features.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
import 'package:flutter_tools/src/resident_devtools_handler.dart';
|
||||
import 'package:flutter_tools/src/resident_runner.dart';
|
||||
@@ -2147,6 +2148,7 @@ flutter:
|
||||
Restart? restart,
|
||||
CompileExpression? compileExpression,
|
||||
GetSkSLMethod? getSkSLMethod,
|
||||
FlutterProject? flutterProject,
|
||||
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
|
||||
io.CompressionOptions? compression,
|
||||
Device? device,
|
||||
@@ -2181,6 +2183,7 @@ flutter:
|
||||
Restart? restart,
|
||||
CompileExpression? compileExpression,
|
||||
GetSkSLMethod? getSkSLMethod,
|
||||
FlutterProject? flutterProject,
|
||||
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
|
||||
io.CompressionOptions? compression,
|
||||
Device? device,
|
||||
@@ -2214,6 +2217,7 @@ flutter:
|
||||
Restart? restart,
|
||||
CompileExpression? compileExpression,
|
||||
GetSkSLMethod? getSkSLMethod,
|
||||
FlutterProject? flutterProject,
|
||||
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
|
||||
io.CompressionOptions? compression,
|
||||
Device? device,
|
||||
@@ -2248,6 +2252,7 @@ flutter:
|
||||
Restart? restart,
|
||||
CompileExpression? compileExpression,
|
||||
GetSkSLMethod? getSkSLMethod,
|
||||
FlutterProject? flutterProject,
|
||||
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
|
||||
io.CompressionOptions? compression,
|
||||
Device? device,
|
||||
@@ -2289,6 +2294,7 @@ flutter:
|
||||
Restart? restart,
|
||||
CompileExpression? compileExpression,
|
||||
GetSkSLMethod? getSkSLMethod,
|
||||
FlutterProject? flutterProject,
|
||||
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
|
||||
io.CompressionOptions compression = io.CompressionOptions.compressionDefault,
|
||||
Device? device,
|
||||
@@ -2344,6 +2350,7 @@ flutter:
|
||||
Restart? restart,
|
||||
CompileExpression? compileExpression,
|
||||
GetSkSLMethod? getSkSLMethod,
|
||||
FlutterProject? flutterProject,
|
||||
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
|
||||
io.CompressionOptions compression = io.CompressionOptions.compressionDefault,
|
||||
Device? device,
|
||||
@@ -2576,6 +2583,7 @@ class FakeFlutterDevice extends Fake implements FlutterDevice {
|
||||
Restart? restart,
|
||||
CompileExpression? compileExpression,
|
||||
GetSkSLMethod? getSkSLMethod,
|
||||
FlutterProject? flutterProject,
|
||||
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
|
||||
int? hostVmServicePort,
|
||||
int? ddsPort,
|
||||
@@ -2629,6 +2637,7 @@ class FakeDelegateFlutterDevice extends FlutterDevice {
|
||||
bool ipv6 = false,
|
||||
CompileExpression? compileExpression,
|
||||
GetSkSLMethod? getSkSLMethod,
|
||||
FlutterProject? flutterProject,
|
||||
int? hostVmServicePort,
|
||||
int? ddsPort,
|
||||
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
|
||||
|
||||
@@ -74,6 +74,10 @@ const List<VmServiceExpectation> kAttachIsolateExpectations =
|
||||
'service': 'flutterMemoryInfo',
|
||||
'alias': 'Flutter Tools',
|
||||
}),
|
||||
FakeVmServiceRequest(method: 'registerService', args: <String, Object>{
|
||||
'service': 'flutterGetIOSBuildOptions',
|
||||
'alias': 'Flutter Tools',
|
||||
}),
|
||||
FakeVmServiceRequest(
|
||||
method: 'streamListen',
|
||||
args: <String, Object>{
|
||||
@@ -1637,6 +1641,7 @@ class FakeFlutterDevice extends Fake implements FlutterDevice {
|
||||
Restart? restart,
|
||||
CompileExpression? compileExpression,
|
||||
GetSkSLMethod? getSkSLMethod,
|
||||
FlutterProject? flutterProject,
|
||||
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
|
||||
int? hostVmServicePort,
|
||||
int? ddsPort,
|
||||
|
||||
@@ -9,6 +9,8 @@ import 'package:flutter_tools/src/base/io.dart' as io;
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/convert.dart';
|
||||
import 'package:flutter_tools/src/device.dart';
|
||||
import 'package:flutter_tools/src/ios/xcodeproj.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/vmservice.dart';
|
||||
import 'package:test/fake.dart';
|
||||
import 'package:vm_service/vm_service.dart' as vm_service;
|
||||
@@ -64,13 +66,8 @@ void main() {
|
||||
|
||||
final MockVMService mockVMService = MockVMService();
|
||||
await setUpVmService(
|
||||
reloadSources,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
mockVMService,
|
||||
reloadSources: reloadSources,
|
||||
vmService: mockVMService,
|
||||
);
|
||||
|
||||
expect(mockVMService.services, containsPair('reloadSources', 'Flutter Tools'));
|
||||
@@ -81,28 +78,31 @@ void main() {
|
||||
|
||||
final MockVMService mockVMService = MockVMService();
|
||||
await setUpVmService(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
mockDevice,
|
||||
null,
|
||||
null,
|
||||
mockVMService,
|
||||
device: mockDevice,
|
||||
vmService: mockVMService,
|
||||
);
|
||||
|
||||
expect(mockVMService.services, containsPair('flutterMemoryInfo', 'Flutter Tools'));
|
||||
});
|
||||
|
||||
testWithoutContext('VmService registers flutterGetIOSBuildOptions service', () async {
|
||||
final MockVMService mockVMService = MockVMService();
|
||||
final FlutterProject mockedVMService = MockFlutterProject(
|
||||
mockedIos: MockIosProject(),
|
||||
);
|
||||
await setUpVmService(
|
||||
flutterProject: mockedVMService,
|
||||
vmService: mockVMService,
|
||||
);
|
||||
|
||||
expect(mockVMService.services, containsPair('flutterGetIOSBuildOptions', 'Flutter Tools'));
|
||||
});
|
||||
|
||||
testWithoutContext('VM Service registers flutterGetSkSL service', () async {
|
||||
final MockVMService mockVMService = MockVMService();
|
||||
await setUpVmService(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
() async => 'hello',
|
||||
null,
|
||||
mockVMService,
|
||||
skSLMethod: () async => 'hello',
|
||||
vmService: mockVMService,
|
||||
);
|
||||
|
||||
expect(mockVMService.services, containsPair('flutterGetSkSL', 'Flutter Tools'));
|
||||
@@ -113,13 +113,8 @@ void main() {
|
||||
..errorOnRegisterService = true;
|
||||
|
||||
await expectLater(() async => setUpVmService(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
() async => 'hello',
|
||||
null,
|
||||
mockVMService,
|
||||
skSLMethod: () async => 'hello',
|
||||
vmService: mockVMService,
|
||||
), throwsToolExit());
|
||||
});
|
||||
|
||||
@@ -128,26 +123,17 @@ void main() {
|
||||
..errorOnRegisterService = true;
|
||||
|
||||
await expectLater(() async => setUpVmService(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
() async => 'hello',
|
||||
(vm_service.Event event) { },
|
||||
mockVMService,
|
||||
skSLMethod: () async => 'hello',
|
||||
printStructuredErrorLogMethod: (vm_service.Event event) { },
|
||||
vmService: mockVMService,
|
||||
), throwsToolExit());
|
||||
});
|
||||
|
||||
testWithoutContext('VM Service registers flutterPrintStructuredErrorLogMethod', () async {
|
||||
final MockVMService mockVMService = MockVMService();
|
||||
await setUpVmService(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
(vm_service.Event event) async => 'hello',
|
||||
mockVMService,
|
||||
printStructuredErrorLogMethod: (vm_service.Event event) async => 'hello',
|
||||
vmService: mockVMService,
|
||||
);
|
||||
expect(mockVMService.listenedStreams, contains(vm_service.EventStreams.kExtension));
|
||||
});
|
||||
@@ -155,13 +141,7 @@ void main() {
|
||||
testWithoutContext('VM Service returns correct FlutterVersion', () async {
|
||||
final MockVMService mockVMService = MockVMService();
|
||||
await setUpVmService(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
mockVMService,
|
||||
vmService: mockVMService,
|
||||
);
|
||||
|
||||
expect(mockVMService.services, containsPair('flutterVersion', 'Flutter Tools'));
|
||||
@@ -299,6 +279,50 @@ void main() {
|
||||
]));
|
||||
});
|
||||
|
||||
testWithoutContext('VmService forward flutterGetIOSBuildOptions request and response correctly', () async {
|
||||
final MockVMService vmService = MockVMService();
|
||||
final XcodeProjectInfo expectedProjectInfo = XcodeProjectInfo(
|
||||
<String>['target1', 'target2'],
|
||||
<String>['config1', 'config2'],
|
||||
<String>['scheme1', 'scheme2'],
|
||||
MockLogger(),
|
||||
);
|
||||
final FlutterProject mockedVMService = MockFlutterProject(
|
||||
mockedIos: MockIosProject(mockedInfo: expectedProjectInfo),
|
||||
);
|
||||
await setUpVmService(
|
||||
flutterProject: mockedVMService,
|
||||
vmService: vmService
|
||||
);
|
||||
final vm_service.ServiceCallback cb = vmService.serviceCallBacks['flutterGetIOSBuildOptions']!;
|
||||
|
||||
final Map<String, dynamic> response = await cb(<String, dynamic>{});
|
||||
final Map<String, dynamic> result = response['result']! as Map<String, dynamic>;
|
||||
expect(result[kResultType], kResultTypeSuccess);
|
||||
expect(result['targets'], expectedProjectInfo.targets);
|
||||
expect(result['buildConfigurations'], expectedProjectInfo.buildConfigurations);
|
||||
expect(result['schemes'], expectedProjectInfo.schemes);
|
||||
});
|
||||
|
||||
testWithoutContext('VmService forward flutterGetIOSBuildOptions request and response correctly when no iOS project', () async {
|
||||
final MockVMService vmService = MockVMService();
|
||||
final FlutterProject mockedVMService = MockFlutterProject(
|
||||
mockedIos: MockIosProject(),
|
||||
);
|
||||
await setUpVmService(
|
||||
flutterProject: mockedVMService,
|
||||
vmService: vmService
|
||||
);
|
||||
final vm_service.ServiceCallback cb = vmService.serviceCallBacks['flutterGetIOSBuildOptions']!;
|
||||
|
||||
final Map<String, dynamic> response = await cb(<String, dynamic>{});
|
||||
final Map<String, dynamic> result = response['result']! as Map<String, dynamic>;
|
||||
expect(result[kResultType], kResultTypeSuccess);
|
||||
expect(result['targets'], isNull);
|
||||
expect(result['buildConfigurations'], isNull);
|
||||
expect(result['schemes'], isNull);
|
||||
});
|
||||
|
||||
testWithoutContext('runInView forwards arguments correctly', () async {
|
||||
final FakeVmServiceHost fakeVmServiceHost = FakeVmServiceHost(
|
||||
requests: <VmServiceExpectation>[
|
||||
@@ -846,13 +870,36 @@ void main() {
|
||||
});
|
||||
}
|
||||
|
||||
class MockFlutterProject extends Fake implements FlutterProject {
|
||||
MockFlutterProject({
|
||||
required IosProject mockedIos
|
||||
}) : ios = mockedIos;
|
||||
|
||||
@override
|
||||
final IosProject ios;
|
||||
}
|
||||
|
||||
class MockIosProject extends Fake implements IosProject {
|
||||
MockIosProject({this.mockedInfo});
|
||||
|
||||
final XcodeProjectInfo? mockedInfo;
|
||||
|
||||
@override
|
||||
Future<XcodeProjectInfo?> projectInfo() async => mockedInfo;
|
||||
}
|
||||
|
||||
class MockLogger extends Fake implements Logger { }
|
||||
|
||||
class MockVMService extends Fake implements vm_service.VmService {
|
||||
final Map<String, String> services = <String, String>{};
|
||||
final Map<String, vm_service.ServiceCallback> serviceCallBacks = <String, vm_service.ServiceCallback>{};
|
||||
final Set<String> listenedStreams = <String>{};
|
||||
bool errorOnRegisterService = false;
|
||||
|
||||
@override
|
||||
void registerServiceCallback(String service, vm_service.ServiceCallback cb) {}
|
||||
void registerServiceCallback(String service, vm_service.ServiceCallback cb) {
|
||||
serviceCallBacks[service] = cb;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<vm_service.Success> registerService(String service, String alias) async {
|
||||
|
||||
@@ -55,7 +55,13 @@ void main() {
|
||||
|
||||
testWithoutContext('flutterMemoryInfo can be called', () async {
|
||||
final Response response =
|
||||
await vmService.callServiceExtension('s0.flutterMemoryInfo');
|
||||
await vmService.callServiceExtension('s0.flutterMemoryInfo');
|
||||
expect(response.type, 'Success');
|
||||
});
|
||||
|
||||
testWithoutContext('flutterGetIOSBuildOptions can be called', () async {
|
||||
final Response response =
|
||||
await vmService.callServiceExtension('s0.flutterGetIOSBuildOptions');
|
||||
expect(response.type, 'Success');
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user