Reverts "Launch DDS from Dart SDK and prepare to serve DevTools from DDS (#146593)" (#151781)

Reverts: flutter/flutter#146593
Initiated by: zanderso
Reason for reverting: Consistently failing `Windows_android native_assets_android` as in https://ci.chromium.org/ui/p/flutter/builders/prod/Windows_android%20native_assets_android/2533/overview 
Original PR Author: bkonyi

Reviewed By: {christopherfujino, kenzieschmoll}

This change reverts the following previous change:
This change is a major step towards moving away from shipping DDS via Pub.

The first component of this PR is the move away from importing package:dds to launch DDS. Instead, DDS is launched out of process using the `dart development-service` command shipped with the Dart SDK. This makes Flutter's handling of DDS consistent with the standalone Dart VM.

The second component of this PR is the initial work to prepare for the removal of instances of DevTools being served manually by the flutter_tool, instead relying on DDS to serve DevTools. This will be consistent with how the standalone Dart VM serves DevTools, tying the DevTools lifecycle to a live DDS instance. This will allow for the removal of much of the logic needed to properly manage the lifecycle of the DevTools server in a future PR. Also, by serving DevTools from DDS, users will no longer need to forward a secondary port in remote workflows as DevTools will be available on the DDS port.

There's two remaining circumstances that will prevent us from removing DevtoolsRunner completely:

 - The daemon's `devtools.serve` endpoint
 - `flutter drive`'s `--profile-memory` flag used for recording memory profiles

This PR also includes some refactoring around `DebuggingOptions` to reduce the number of debugging related arguments being passed as parameters adjacent to a `DebuggingOptions` instance.
This commit is contained in:
auto-submit[bot]
2024-07-15 19:55:18 +00:00
committed by GitHub
parent f023430859
commit 7cdc23b3e1
57 changed files with 752 additions and 925 deletions

View File

@@ -73,7 +73,7 @@ void main() {
artifacts = Artifacts.test(fileSystem: testFileSystem);
stdio = FakeStdio();
terminal = FakeTerminal();
signals = FakeSignals();
signals = Signals.test();
processInfo = FakeProcessInfo();
testDeviceManager = TestDeviceManager(logger: logger);
});
@@ -802,13 +802,6 @@ void main() {
ProcessManager: () => FakeProcessManager.any(),
Logger: () => logger,
DeviceManager: () => testDeviceManager,
MDnsVmServiceDiscovery: () => MDnsVmServiceDiscovery(
mdnsClient: FakeMDnsClient(<PtrResourceRecord>[], <String, List<SrvResourceRecord>>{}),
preliminaryMDnsClient: FakeMDnsClient(<PtrResourceRecord>[], <String, List<SrvResourceRecord>>{}),
logger: logger,
flutterUsage: TestUsage(),
analytics: const NoOpAnalytics(),
),
});
testUsingContext('exits when vm-service-port is specified and debug-port is not', () async {
@@ -1401,14 +1394,11 @@ class FakeDartDevelopmentService extends Fake implements DartDevelopmentService
@override
Future<void> startDartDevelopmentService(
Uri vmServiceUri, {
int? ddsPort,
FlutterDevice? device,
required Logger logger,
int? hostPort,
bool? ipv6,
bool? disableServiceAuthCodes,
bool enableDevTools = false,
bool cacheStartupProfile = false,
String? google3WorkspaceRoot,
Uri? devToolsServerAddress,
}) async {}
@override

View File

@@ -695,22 +695,17 @@ void main() {
'deviceId': 'device',
'disableServiceAuthCodes': false,
'vmServiceUri': 'http://fake_uri/auth_code',
// TODO(bkonyi): uncomment when ready to serve DevTools from DDS.
// 'enableDevTools': true,
},
}));
final Stream<DaemonMessage> broadcastOutput = daemonStreams.outputs.stream.asBroadcastStream();
final DaemonMessage startResponse = await broadcastOutput.firstWhere(_notEvent);
expect(startResponse.data['id'], 0);
expect(startResponse.data['error'], isNull);
final Map<String, Object?>? result = startResponse.data['result'] as Map<String, Object?>?;
final String? ddsUri = result!['ddsUri'] as String?;
final String? ddsUri = startResponse.data['result'] as String?;
expect(ddsUri, fakeDdsUri.toString());
expect(device.dds.startCalled, true);
expect(device.dds.startDisableServiceAuthCodes, false);
expect(device.dds.startVMServiceUri, Uri.parse('http://fake_uri/auth_code'));
// TODO(bkonyi): uncomment when ready to serve DevTools from DDS.
// expect(device.dds.enableDevTools, true);
// dds.done event should be sent to the client.
ddsDoneCompleter.complete();
@@ -1241,8 +1236,6 @@ class FakeDartDevelopmentService extends Fake implements DartDevelopmentService
bool? startDisableServiceAuthCodes;
bool shutdownCalled = false;
// TODO(bkonyi): uncomment when ready to serve DevTools from DDS.
// bool enableDevTools = false;
@override
late Future<void> done;
@@ -1250,32 +1243,18 @@ class FakeDartDevelopmentService extends Fake implements DartDevelopmentService
@override
Uri? uri;
// TODO(bkonyi): uncomment when ready to serve DevTools from DDS.
/*
@override
Uri? devToolsUri;
@override
Uri? dtdUri;
*/
@override
Future<void> startDartDevelopmentService(
Uri vmServiceUri, {
int? ddsPort,
FlutterDevice? device,
required Logger logger,
int? hostPort,
bool? ipv6,
bool? disableServiceAuthCodes,
bool enableDevTools = false,
bool cacheStartupProfile = false,
String? google3WorkspaceRoot,
Uri? devToolsServerAddress,
}) async {
startCalled = true;
startVMServiceUri = vmServiceUri;
startDisableServiceAuthCodes = disableServiceAuthCodes;
// TODO(bkonyi): uncomment when ready to serve DevTools from DDS.
// this.enableDevTools = enableDevTools;
}
@override

View File

@@ -640,7 +640,7 @@ class NeverEndingDriverService extends Fake implements DriverService {
final void Function() callback;
@override
Future<void> reuseApplication(Uri vmServiceUri, Device device, DebuggingOptions debuggingOptions) async { }
Future<void> reuseApplication(Uri vmServiceUri, Device device, DebuggingOptions debuggingOptions, bool ipv6) async { }
@override
Future<int> startTest(
@@ -670,7 +670,7 @@ class FailingFakeFlutterDriverFactory extends Fake implements FlutterDriverFacto
class FailingFakeDriverService extends Fake implements DriverService {
@override
Future<void> reuseApplication(Uri vmServiceUri, Device device, DebuggingOptions debuggingOptions) async { }
Future<void> reuseApplication(Uri vmServiceUri, Device device, DebuggingOptions debuggingOptions, bool ipv6) async { }
@override
Future<int> startTest(

View File

@@ -1544,13 +1544,16 @@ class CapturingAppDomain extends AppDomain {
String? projectRootPath,
String? packagesFilePath,
String? dillOutputPath,
bool ipv6 = false,
String? isolateFilter,
bool machine = true,
String? userIdentifier,
required HotRunnerNativeAssetsBuilder? nativeAssetsBuilder,
bool enableDevTools = true,
String? flavor,
HotRunnerNativeAssetsBuilder? nativeAssetsBuilder,
}) async {
this.userIdentifier = userIdentifier;
enableDevTools = options.enableDevTools;
this.enableDevTools = enableDevTools;
throwToolExit('');
}
}

View File

@@ -213,9 +213,13 @@ class TestFlutterDevice extends FlutterDevice {
GetSkSLMethod? getSkSLMethod,
FlutterProject? flutterProject,
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
required DebuggingOptions debuggingOptions,
bool enableDds = true,
bool cacheStartupProfile = false,
bool disableServiceAuthCodes = false,
int? hostVmServicePort,
required bool allowExistingDdsInstance,
int? ddsPort,
bool? ipv6 = false,
bool allowExistingDdsInstance = false,
}) async {
throw exception;
}

View File

@@ -932,13 +932,13 @@ void main() {
testWithoutContext('Get launch arguments for physical device with iPv6 network connection', () {
final DebuggingOptions original = DebuggingOptions.enabled(
BuildInfo.debug,
ipv6: true,
);
final List<String> launchArguments = original.getIOSLaunchArguments(
EnvironmentType.physical,
null,
<String, Object?>{},
ipv6: true,
interfaceType: DeviceConnectionInterface.wireless,
);

View File

@@ -33,8 +33,6 @@ void main() {
'Artifact.engineDartBinary',
'devtools',
'--no-launch-browser',
// TODO(bkonyi): does this need to be removed?
// '--print-dtd',
],
stdout: 'Serving DevTools at http://127.0.0.1:9100.\n',
completer: completer,
@@ -51,7 +49,6 @@ void main() {
expect(launcher.printDtdUri, false);
});
// TODO(bkonyi): this test can be removed when DevTools is served from DDS.
testWithoutContext('DevtoolsLauncher saves the Dart Tooling Daemon uri', () async {
final (BufferLogger logger, Artifacts artifacts) = getTestState();
final Completer<void> completer = Completer<void>();
@@ -98,7 +95,6 @@ Serving DevTools at http://127.0.0.1:9100.
'Artifact.engineDartBinary',
'devtools',
'--no-launch-browser',
// '--print-dtd',
],
stdout: 'Serving DevTools at http://127.0.0.1:9100.\n',
completer: completer,
@@ -124,7 +120,6 @@ Serving DevTools at http://127.0.0.1:9100.
'Artifact.engineDartBinary',
'devtools',
'--no-launch-browser',
// '--print-dtd',
'--vm-uri=localhost:8181/abcdefg',
'--profile-memory=foo',
],
@@ -156,7 +151,6 @@ Serving DevTools at http://127.0.0.1:9100.
'Artifact.engineDartBinary',
'devtools',
'--no-launch-browser',
// '--print-dtd',
'--vm-uri=http://127.0.0.1:1234/abcdefg',
],
exception: ProcessException('pub', <String>[]),
@@ -182,7 +176,6 @@ Serving DevTools at http://127.0.0.1:9100.
'Artifact.engineDartBinary',
'devtools',
'--no-launch-browser',
// '--print-dtd',
],
stdout: 'Serving DevTools at http://127.0.0.1:9100.\n',
completer: completer,

View File

@@ -93,7 +93,7 @@ void main() {
final Device device = FakeDevice(LaunchResult.failed());
expect(
() => driverService.start(BuildInfo.profile, device, DebuggingOptions.enabled(BuildInfo.profile, ipv6: true)),
() => driverService.start(BuildInfo.profile, device, DebuggingOptions.enabled(BuildInfo.profile), true),
throwsToolExit(message: 'Application failed to start. Will not run test. Quitting.'),
);
});
@@ -118,7 +118,7 @@ void main() {
))..failOnce = true;
await expectLater(
() async => driverService.start(BuildInfo.profile, device, DebuggingOptions.enabled(BuildInfo.profile, ipv6: true)),
() async => driverService.start(BuildInfo.profile, device, DebuggingOptions.enabled(BuildInfo.profile), true),
returnsNormally,
);
});
@@ -142,7 +142,7 @@ void main() {
vmServiceUri: Uri.parse('http://127.0.0.1:63426/1UasC_ihpXY=/'),
));
await driverService.start(BuildInfo.profile, device, DebuggingOptions.enabled(BuildInfo.profile, ipv6: true));
await driverService.start(BuildInfo.profile, device, DebuggingOptions.enabled(BuildInfo.profile), true);
final int testResult = await driverService.startTest(
'foo.test',
<String>['--enable-experiment=non-nullable'],
@@ -173,7 +173,7 @@ void main() {
vmServiceUri: Uri.parse('http://127.0.0.1:63426/1UasC_ihpXY=/'),
));
await driverService.start(BuildInfo.profile, device, DebuggingOptions.enabled(BuildInfo.profile, ipv6: true));
await driverService.start(BuildInfo.profile, device, DebuggingOptions.enabled(BuildInfo.profile), true);
final int testResult = await driverService.startTest(
'foo.test',
<String>['--enable-experiment=non-nullable'],
@@ -205,7 +205,7 @@ void main() {
vmServiceUri: Uri.parse('http://127.0.0.1:63426/1UasC_ihpXY=/'),
));
await driverService.start(BuildInfo.profile, device, DebuggingOptions.enabled(BuildInfo.profile, ipv6: true));
await driverService.start(BuildInfo.profile, device, DebuggingOptions.enabled(BuildInfo.profile), true);
final int testResult = await driverService.startTest(
'foo.test',
<String>['--enable-experiment=non-nullable'],
@@ -237,7 +237,7 @@ void main() {
final FakeDartDevelopmentService dds = device.dds as FakeDartDevelopmentService;
expect(dds.started, false);
await driverService.start(BuildInfo.profile, device, DebuggingOptions.enabled(BuildInfo.profile, enableDds: false, ipv6: true));
await driverService.start(BuildInfo.profile, device, DebuggingOptions.enabled(BuildInfo.profile, enableDds: false), true);
expect(dds.started, false);
final int testResult = await driverService.startTest(
@@ -261,7 +261,7 @@ void main() {
vmServiceUri: Uri.parse('http://127.0.0.1:63426/1UasC_ihpXY=/'),
));
await driverService.start(BuildInfo.profile, device, DebuggingOptions.enabled(BuildInfo.profile, ipv6: true));
await driverService.start(BuildInfo.profile, device, DebuggingOptions.enabled(BuildInfo.profile), true);
await driverService.stop();
expect(device.didStopApp, true);
@@ -293,7 +293,7 @@ void main() {
vmServiceUri: Uri.parse('http://127.0.0.1:63426/1UasC_ihpXY=/'),
));
await driverService.start(BuildInfo.profile, device, DebuggingOptions.enabled(BuildInfo.profile, ipv6: true));
await driverService.start(BuildInfo.profile, device, DebuggingOptions.enabled(BuildInfo.profile), true);
await driverService.stop(writeSkslOnExit: fileSystem.file('out.json'));
expect(device.didStopApp, true);
@@ -327,6 +327,7 @@ void main() {
Uri.parse('http://127.0.0.1:63426/1UasC_ihpXY=/'),
device,
DebuggingOptions.enabled(BuildInfo.debug),
false,
);
await driverService.stop();
});
@@ -350,6 +351,7 @@ void main() {
Uri.parse('ws://127.0.0.1:63426/1UasC_ihpXY=/ws/'),
device,
DebuggingOptions.enabled(BuildInfo.debug),
false,
);
await driverService.stop();
});
@@ -373,6 +375,7 @@ void main() {
Uri.parse('ws://127.0.0.1:63426/1UasC_ihpXY=/ws'),
device,
DebuggingOptions.enabled(BuildInfo.debug),
false,
);
await driverService.stop();
});
@@ -396,6 +399,7 @@ void main() {
Uri.parse('ws://127.0.0.1:63426/wsasC_ihpXY=/ws'),
device,
DebuggingOptions.enabled(BuildInfo.debug),
false,
);
await driverService.stop();
});
@@ -412,6 +416,7 @@ void main() {
Uri.parse('http://127.0.0.1:63426/1UasC_ihpXY=/'),
device,
DebuggingOptions.enabled(BuildInfo.debug),
false,
);
await driverService.stop();
});
@@ -535,9 +540,7 @@ class FakeDevice extends Fake implements Device {
}
}
class FakeDartDevelopmentService extends Fake
with DartDevelopmentServiceLocalOperationsMixin
implements DartDevelopmentService {
class FakeDartDevelopmentService extends Fake implements DartDevelopmentService {
bool started = false;
bool disposed = false;
@@ -547,14 +550,11 @@ class FakeDartDevelopmentService extends Fake
@override
Future<void> startDartDevelopmentService(
Uri vmServiceUri, {
FlutterDevice? device,
int? ddsPort,
required Logger logger,
int? hostPort,
bool? ipv6,
bool? disableServiceAuthCodes,
bool enableDevTools = false,
bool cacheStartupProfile = false,
String? google3WorkspaceRoot,
Uri? devToolsServerAddress,
}) async {
started = true;
}

View File

@@ -248,7 +248,7 @@ void main() {
testUsingContext('WebDriverService starts and stops an app', () async {
final WebDriverService service = setUpDriverService();
final FakeDevice device = FakeDevice();
await service.start(BuildInfo.profile, device, DebuggingOptions.enabled(BuildInfo.profile, ipv6: true));
await service.start(BuildInfo.profile, device, DebuggingOptions.enabled(BuildInfo.profile), true);
await service.stop();
expect(FakeResidentRunner.instance.callLog, <String>[
'run',
@@ -263,7 +263,7 @@ void main() {
final WebDriverService service = setUpDriverService();
final FakeDevice device = FakeDevice();
const String testUrl = 'http://localhost:1234/test';
await service.start(BuildInfo.profile, device, DebuggingOptions.enabled(BuildInfo.profile, webLaunchUrl: testUrl, ipv6: true));
await service.start(BuildInfo.profile, device, DebuggingOptions.enabled(BuildInfo.profile, webLaunchUrl: testUrl), true);
await service.stop();
expect(service.webUri, Uri.parse(testUrl));
}, overrides: <Type, Generator>{
@@ -275,7 +275,7 @@ void main() {
final FakeDevice device = FakeDevice();
const String invalidTestUrl = '::INVALID_URL::';
await expectLater(
service.start(BuildInfo.profile, device, DebuggingOptions.enabled(BuildInfo.profile, webLaunchUrl: invalidTestUrl, ipv6: true)),
service.start(BuildInfo.profile, device, DebuggingOptions.enabled(BuildInfo.profile, webLaunchUrl: invalidTestUrl), true),
throwsA(isA<FormatException>()),
);
}, overrides: <Type, Generator>{
@@ -286,7 +286,7 @@ void main() {
final WebDriverService service = setUpDriverService();
final Device device = FakeDevice();
await expectLater(
service.start(BuildInfo.profile, device, DebuggingOptions.enabled(BuildInfo.profile, ipv6: true)),
service.start(BuildInfo.profile, device, DebuggingOptions.enabled(BuildInfo.profile), true),
throwsA('This is a test error'),
);
}, overrides: <Type, Generator>{

View File

@@ -102,6 +102,7 @@ void main() {
platformPluginRegistration: (FlutterPlatform platform) {
capturedPlatform = platform;
},
uriConverter: (String input) => '$input/test',
);
expect(identical(capturedPlatform, flutterPlatform), equals(true));
@@ -118,6 +119,7 @@ void main() {
expect(flutterPlatform.updateGoldens, equals(true));
expect(flutterPlatform.testAssetDirectory, '/build/test');
expect(flutterPlatform.icudtlPath, equals('ghi'));
expect(flutterPlatform.uriConverter?.call('hello'), 'hello/test');
});
});

View File

@@ -4,8 +4,8 @@
import 'dart:async';
import 'package:dds/dds.dart';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/dds.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart';
@@ -48,6 +48,7 @@ void main() {
processManager: processManager,
enableVmService: enableVmService,
dartEntrypointArgs: dartEntrypointArgs,
uriConverter: (String input) => '$input/converted',
enableImpeller: enableImpeller,
);
@@ -197,7 +198,6 @@ void main() {
});
group('DDS', () {
late DDSLauncherCallback originalDdsLauncher;
setUp(() {
processManager = FakeProcessManager.list(<FakeCommand>[
const FakeCommand(
@@ -221,30 +221,26 @@ void main() {
),
]);
device = createDevice(enableVmService: true);
originalDdsLauncher = ddsLauncherCallback;
ddsLauncherCallback = (Uri remoteVmServiceUri, {
required bool enableAuthCodes,
required bool ipv6,
required bool enableDevTools,
required List<String> cachedUserTags,
Uri? serviceUri,
String? google3WorkspaceRoot,
Uri? devToolsServerAddress,
}) async {
return (process: null, serviceUri: Uri.parse('http://localhost:1234'), devToolsUri: null, dtdUri: null);
};
});
tearDown(() {
ddsLauncherCallback = originalDdsLauncher;
});
testUsingContext('skips setting VM Service port and uses the input port for DDS instead', () async {
await device.start('example.dill');
await device.vmServiceUri;
final Uri? uri = await (device as TestFlutterTesterDevice).vmServiceUri;
expect(uri!.port, 1234);
final Uri uri = await (device as TestFlutterTesterDevice).ddsServiceUriFuture();
expect(uri.port, 1234);
});
testUsingContext('sets up UriConverter from context', () async {
await device.start('example.dill');
await device.vmServiceUri;
final FakeDartDevelopmentService dds = (device as TestFlutterTesterDevice).dds
as FakeDartDevelopmentService;
final String? result = dds
.uriConverter
?.call('test');
expect(result, 'test/converted');
});
});
}
@@ -259,6 +255,7 @@ class TestFlutterTesterDevice extends FlutterTesterTestDevice {
required super.processManager,
required super.enableVmService,
required List<String> dartEntrypointArgs,
required UriConverter uriConverter,
required bool enableImpeller,
}) : super(
id: 999,
@@ -282,7 +279,27 @@ class TestFlutterTesterDevice extends FlutterTesterTestDevice {
icudtlPath: null,
compileExpression: null,
fontConfigManager: FontConfigManager(),
uriConverter: uriConverter,
);
late DartDevelopmentService dds;
final Completer<Uri> _ddsServiceUriCompleter = Completer<Uri>();
Future<Uri> ddsServiceUriFuture() => _ddsServiceUriCompleter.future;
@override
Future<DartDevelopmentService> startDds(
Uri uri, {
UriConverter? uriConverter,
}) async {
_ddsServiceUriCompleter.complete(uri);
dds = FakeDartDevelopmentService(
Uri.parse('http://localhost:${debuggingOptions.hostVmServicePort}'),
Uri.parse('http://localhost:8080'),
uriConverter: uriConverter,
);
return dds;
}
@override
Future<FlutterVmService> connectToVmServiceImpl(
@@ -302,6 +319,18 @@ class TestFlutterTesterDevice extends FlutterTesterTestDevice {
Future<StreamChannel<String>> get remoteChannel async => StreamChannelController<String>().foreign;
}
class FakeDartDevelopmentService extends Fake implements DartDevelopmentService {
FakeDartDevelopmentService(this.uri, this.original, {this.uriConverter});
final Uri original;
final UriConverter? uriConverter;
@override
final Uri uri;
@override
Uri get remoteVmServiceUri => original;
}
class FakeHttpServer extends Fake implements HttpServer {
@override
int get port => 0;

View File

@@ -9,7 +9,6 @@ import 'package:file/memory.dart';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/os.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/build_info.dart';
@@ -39,7 +38,6 @@ void main() {
late FakeProcessManager fakeSuccessfulProcessManager;
late FakeProcessManager fakeFailedProcessManagerForHostAddress;
late File sshConfig;
final Logger logger = FakeLogger();
setUp(() {
memoryFileSystem = MemoryFileSystem.test();
@@ -116,7 +114,7 @@ void main() {
required BuildMode mode,
}) async {
const String appName = 'app_name';
final FuchsiaDevice device = FuchsiaDeviceWithFakeDiscovery('123', logger: logger);
final FuchsiaDevice device = FuchsiaDeviceWithFakeDiscovery('123');
globals.fs.directory('fuchsia').createSync(recursive: true);
final File pubspecFile = globals.fs.file('pubspec.yaml')..createSync();
pubspecFile.writeAsStringSync('name: $appName');
@@ -188,7 +186,7 @@ void main() {
'start and stop prebuilt in release mode fails without session',
() async {
const String appName = 'app_name';
final FuchsiaDevice device = FuchsiaDeviceWithFakeDiscovery('123', logger: logger);
final FuchsiaDevice device = FuchsiaDeviceWithFakeDiscovery('123');
globals.fs.directory('fuchsia').createSync(recursive: true);
final File pubspecFile = globals.fs.file('pubspec.yaml')..createSync();
pubspecFile.writeAsStringSync('name: $appName');
@@ -218,7 +216,7 @@ void main() {
testUsingContext('start and stop prebuilt in release mode with session',
() async {
const String appName = 'app_name';
final FuchsiaDevice device = FuchsiaDeviceWithFakeDiscovery('123', logger: logger);
final FuchsiaDevice device = FuchsiaDeviceWithFakeDiscovery('123');
globals.fs.directory('fuchsia').createSync(recursive: true);
final File pubspecFile = globals.fs.file('pubspec.yaml')..createSync();
pubspecFile.writeAsStringSync('name: $appName');
@@ -411,7 +409,7 @@ void main() {
});
testUsingContext('fail when cant get host address', () async {
expect(() async => FuchsiaDeviceWithFakeDiscovery('123', logger: logger).hostAddress,
expect(() async => FuchsiaDeviceWithFakeDiscovery('123').hostAddress,
throwsToolExit(message: 'Failed to get local address, aborting.'));
}, overrides: <Type, Generator>{
Artifacts: () => artifacts,
@@ -481,7 +479,7 @@ Process _createFakeProcess({
}
class FuchsiaDeviceWithFakeDiscovery extends FuchsiaDevice {
FuchsiaDeviceWithFakeDiscovery(super.id, {super.name = '', required super.logger});
FuchsiaDeviceWithFakeDiscovery(super.id, {super.name = ''});
@override
FuchsiaIsolateDiscoveryProtocol getIsolateDiscoveryProtocol(

View File

@@ -26,7 +26,6 @@ import 'package:flutter_tools/src/fuchsia/fuchsia_sdk.dart';
import 'package:flutter_tools/src/fuchsia/fuchsia_workflow.dart';
import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/resident_runner.dart';
import 'package:flutter_tools/src/vmservice.dart';
import 'package:test/fake.dart';
import 'package:vm_service/vm_service.dart' as vm_service;
@@ -59,7 +58,6 @@ void main() {
late MemoryFileSystem memoryFileSystem;
late File sshConfig;
late FakeProcessManager processManager;
final Logger logger = FakeLogger();
setUp(() {
memoryFileSystem = MemoryFileSystem.test();
@@ -70,7 +68,7 @@ void main() {
testWithoutContext('stores the requested id and name', () {
const String deviceId = 'e80::0000:a00a:f00f:2002/3';
const String name = 'halfbaked';
final FuchsiaDevice device = FuchsiaDevice(deviceId, name: name, logger: logger);
final FuchsiaDevice device = FuchsiaDevice(deviceId, name: name);
expect(device.id, deviceId);
expect(device.name, name);
@@ -79,7 +77,7 @@ void main() {
testWithoutContext('supports all runtime modes besides jitRelease', () {
const String deviceId = 'e80::0000:a00a:f00f:2002/3';
const String name = 'halfbaked';
final FuchsiaDevice device = FuchsiaDevice(deviceId, name: name, logger: logger);
final FuchsiaDevice device = FuchsiaDevice(deviceId, name: name);
expect(device.supportsRuntimeMode(BuildMode.debug), true);
expect(device.supportsRuntimeMode(BuildMode.profile), true);
@@ -159,7 +157,7 @@ void main() {
testUsingContext('disposing device disposes the portForwarder', () async {
final FakePortForwarder portForwarder = FakePortForwarder();
final FuchsiaDevice device = FuchsiaDevice('123', name: 'device', logger: logger);
final FuchsiaDevice device = FuchsiaDevice('123', name: 'device');
device.portForwarder = portForwarder;
await device.dispose();
@@ -167,7 +165,7 @@ void main() {
});
testWithoutContext('default capabilities', () async {
final FuchsiaDevice device = FuchsiaDevice('123', name: 'device', logger: logger);
final FuchsiaDevice device = FuchsiaDevice('123', name: 'device');
final FlutterProject project =
FlutterProject.fromDirectoryTest(memoryFileSystem.currentDirectory);
memoryFileSystem.directory('fuchsia').createSync(recursive: true);
@@ -180,13 +178,13 @@ void main() {
});
test('is ephemeral', () {
final FuchsiaDevice device = FuchsiaDevice('123', name: 'device', logger: logger);
final FuchsiaDevice device = FuchsiaDevice('123', name: 'device');
expect(device.ephemeral, true);
});
testWithoutContext('supported for project', () async {
final FuchsiaDevice device = FuchsiaDevice('123', name: 'device', logger: logger);
final FuchsiaDevice device = FuchsiaDevice('123', name: 'device');
final FlutterProject project =
FlutterProject.fromDirectoryTest(memoryFileSystem.currentDirectory);
memoryFileSystem.directory('fuchsia').createSync(recursive: true);
@@ -196,7 +194,7 @@ void main() {
});
testWithoutContext('not supported for project', () async {
final FuchsiaDevice device = FuchsiaDevice('123', name: 'device', logger: logger);
final FuchsiaDevice device = FuchsiaDevice('123', name: 'device');
final FlutterProject project =
FlutterProject.fromDirectoryTest(memoryFileSystem.currentDirectory);
memoryFileSystem.file('pubspec.yaml').createSync();
@@ -206,7 +204,7 @@ void main() {
testUsingContext('targetPlatform does not throw when sshConfig is missing',
() async {
final FuchsiaDevice device = FuchsiaDevice('123', name: 'device', logger: logger);
final FuchsiaDevice device = FuchsiaDevice('123', name: 'device');
expect(await device.targetPlatform, TargetPlatform.fuchsia_arm64);
}, overrides: <Type, Generator>{
@@ -221,7 +219,7 @@ void main() {
stdout: 'aarch64',
));
final FuchsiaDevice device = FuchsiaDevice('123', name: 'device', logger: logger);
final FuchsiaDevice device = FuchsiaDevice('123', name: 'device');
expect(await device.targetPlatform, TargetPlatform.fuchsia_arm64);
}, overrides: <Type, Generator>{
FuchsiaArtifacts: () => FuchsiaArtifacts(sshConfig: sshConfig),
@@ -235,7 +233,7 @@ void main() {
stdout: 'x86_64',
));
final FuchsiaDevice device = FuchsiaDevice('123', name: 'device', logger: logger);
final FuchsiaDevice device = FuchsiaDevice('123', name: 'device');
expect(await device.targetPlatform, TargetPlatform.fuchsia_x64);
}, overrides: <Type, Generator>{
FuchsiaArtifacts: () => FuchsiaArtifacts(sshConfig: sshConfig),
@@ -256,7 +254,7 @@ void main() {
'fe80::8c6c:2fff:fe3d:c5e1%ethp0003 50666 fe80::5054:ff:fe63:5e7a%ethp0003 22',
));
final FuchsiaDevice device = FuchsiaDevice('id', name: 'device', logger: logger);
final FuchsiaDevice device = FuchsiaDevice('id', name: 'device');
expect(await device.hostAddress, 'fe80::8c6c:2fff:fe3d:c5e1%25ethp0003');
}, overrides: <Type, Generator>{
FuchsiaArtifacts: () => FuchsiaArtifacts(sshConfig: sshConfig),
@@ -277,7 +275,7 @@ void main() {
exitCode: 1,
));
final FuchsiaDevice device = FuchsiaDevice('id', name: 'device', logger: logger);
final FuchsiaDevice device = FuchsiaDevice('id', name: 'device');
await expectLater(() => device.hostAddress, throwsToolExit());
}, overrides: <Type, Generator>{
FuchsiaArtifacts: () => FuchsiaArtifacts(sshConfig: sshConfig),
@@ -297,7 +295,7 @@ void main() {
],
));
final FuchsiaDevice device = FuchsiaDevice('id', name: 'device', logger: logger);
final FuchsiaDevice device = FuchsiaDevice('id', name: 'device');
expect(() async => device.hostAddress, throwsToolExit());
}, overrides: <Type, Generator>{
FuchsiaArtifacts: () => FuchsiaArtifacts(sshConfig: sshConfig),
@@ -309,7 +307,6 @@ void main() {
group('displays friendly error when', () {
late File artifactFile;
late FakeProcessManager processManager;
final Logger logger = FakeLogger();
setUp(() {
processManager = FakeProcessManager.empty();
@@ -326,7 +323,7 @@ void main() {
'find /hub -name vmservice-port'
],
));
final FuchsiaDevice device = FuchsiaDevice('id', name: 'device', logger: logger);
final FuchsiaDevice device = FuchsiaDevice('id', name: 'device');
await expectLater(
device.servicePorts,
@@ -355,7 +352,6 @@ void main() {
late FakeProcessManager processManager;
late File ffx;
late File sshConfig;
final Logger logger = FakeLogger();
setUp(() {
processManager = FakeProcessManager.empty();
@@ -378,7 +374,7 @@ void main() {
stdout: exampleUtcLogs,
completer: lock,
));
final FuchsiaDevice device = FuchsiaDevice('id', name: 'tester', logger: logger);
final FuchsiaDevice device = FuchsiaDevice('id', name: 'tester');
final DeviceLogReader reader =
device.getLogReader(app: FuchsiaModulePackage(name: 'example_app'));
final List<String> logLines = <String>[];
@@ -415,7 +411,7 @@ void main() {
stdout: exampleUtcLogs,
completer: lock,
));
final FuchsiaDevice device = FuchsiaDevice('id', name: 'tester', logger: logger);
final FuchsiaDevice device = FuchsiaDevice('id', name: 'tester');
final DeviceLogReader reader =
device.getLogReader(app: FuchsiaModulePackage(name: 'example_app'));
final List<String> logLines = <String>[];
@@ -450,7 +446,7 @@ void main() {
stdout: exampleUtcLogs,
completer: lock,
));
final FuchsiaDevice device = FuchsiaDevice('id', name: 'tester', logger: logger);
final FuchsiaDevice device = FuchsiaDevice('id', name: 'tester');
final DeviceLogReader reader = device.getLogReader();
final List<String> logLines = <String>[];
reader.logLines.listen((String line) {
@@ -479,14 +475,13 @@ void main() {
group('screenshot', () {
late FakeProcessManager processManager;
final Logger logger = FakeLogger();
setUp(() {
processManager = FakeProcessManager.empty();
});
testUsingContext('is supported on posix platforms', () {
final FuchsiaDevice device = FuchsiaDevice('id', name: 'tester', logger: logger);
final FuchsiaDevice device = FuchsiaDevice('id', name: 'tester');
expect(device.supportsScreenshot, true);
}, overrides: <Type, Generator>{
Platform: () => FakePlatform(),
@@ -494,7 +489,7 @@ void main() {
});
testUsingContext('is not supported on Windows', () {
final FuchsiaDevice device = FuchsiaDevice('id', name: 'tester', logger: logger);
final FuchsiaDevice device = FuchsiaDevice('id', name: 'tester');
expect(device.supportsScreenshot, false);
}, overrides: <Type, Generator>{
@@ -505,7 +500,7 @@ void main() {
});
test("takeScreenshot throws if file isn't .ppm", () async {
final FuchsiaDevice device = FuchsiaDevice('id', name: 'tester', logger: logger);
final FuchsiaDevice device = FuchsiaDevice('id', name: 'tester');
await expectLater(
() => device.takeScreenshot(globals.fs.file('file.invalid')),
throwsA(isA<Exception>().having(
@@ -523,7 +518,7 @@ void main() {
'0.0.0.0',
'screencap > /tmp/screenshot.ppm',
], exitCode: 1, stderr: '<error-message>'));
final FuchsiaDevice device = FuchsiaDevice('0.0.0.0', name: 'tester', logger: logger);
final FuchsiaDevice device = FuchsiaDevice('0.0.0.0', name: 'tester');
await expectLater(
() => device.takeScreenshot(globals.fs.file('file.ppm')),
@@ -545,7 +540,7 @@ void main() {
});
testUsingContext('takeScreenshot throws if scp failed', () async {
final FuchsiaDevice device = FuchsiaDevice('0.0.0.0', name: 'tester', logger: logger);
final FuchsiaDevice device = FuchsiaDevice('0.0.0.0', name: 'tester');
processManager.addCommand(const FakeCommand(
command: <String>[
'ssh',
@@ -598,7 +593,7 @@ void main() {
testUsingContext(
"takeScreenshot prints error if can't delete file from device",
() async {
final FuchsiaDevice device = FuchsiaDevice('0.0.0.0', name: 'tester', logger: logger);
final FuchsiaDevice device = FuchsiaDevice('0.0.0.0', name: 'tester');
processManager.addCommand(const FakeCommand(
command: <String>[
'ssh',
@@ -647,7 +642,7 @@ void main() {
}, testOn: 'posix');
testUsingContext('takeScreenshot returns', () async {
final FuchsiaDevice device = FuchsiaDevice('0.0.0.0', name: 'tester', logger: logger);
final FuchsiaDevice device = FuchsiaDevice('0.0.0.0', name: 'tester');
processManager.addCommand(const FakeCommand(
command: <String>[
'ssh',
@@ -693,7 +688,6 @@ void main() {
group('portForwarder', () {
late FakeProcessManager processManager;
late File sshConfig;
final Logger logger = FakeLogger();
setUp(() {
processManager = FakeProcessManager.empty();
@@ -703,7 +697,7 @@ void main() {
testUsingContext(
'`unforward` prints stdout and stderr if ssh command failed', () async {
final FuchsiaDevice device = FuchsiaDevice('id', name: 'tester', logger: logger);
final FuchsiaDevice device = FuchsiaDevice('id', name: 'tester');
processManager.addCommand(const FakeCommand(
command: <String>[
'ssh',
@@ -867,7 +861,6 @@ void main() {
group('sdkNameAndVersion: ', () {
late File sshConfig;
late FakeProcessManager processManager;
final Logger logger = FakeLogger();
setUp(() {
sshConfig = MemoryFileSystem.test().file('ssh_config')
@@ -876,7 +869,7 @@ void main() {
});
testUsingContext('does not throw on non-existent ssh config', () async {
final FuchsiaDevice device = FuchsiaDevice('123', name: 'device', logger: logger);
final FuchsiaDevice device = FuchsiaDevice('123', name: 'device');
expect(await device.sdkNameAndVersion, equals('Fuchsia'));
}, overrides: <Type, Generator>{
@@ -894,7 +887,7 @@ void main() {
'123',
'cat /pkgfs/packages/build-info/0/data/version'
], stdout: 'version'));
final FuchsiaDevice device = FuchsiaDevice('123', name: 'device', logger: logger);
final FuchsiaDevice device = FuchsiaDevice('123', name: 'device');
expect(await device.sdkNameAndVersion, equals('Fuchsia version'));
}, overrides: <Type, Generator>{
@@ -914,7 +907,7 @@ void main() {
],
exitCode: 1,
));
final FuchsiaDevice device = FuchsiaDevice('123', name: 'device', logger: logger);
final FuchsiaDevice device = FuchsiaDevice('123', name: 'device');
expect(await device.sdkNameAndVersion, equals('Fuchsia'));
}, overrides: <Type, Generator>{
@@ -934,7 +927,7 @@ void main() {
'cat /pkgfs/packages/build-info/0/data/version'
],
));
final FuchsiaDevice device = FuchsiaDevice('123', name: 'device', logger: logger);
final FuchsiaDevice device = FuchsiaDevice('123', name: 'device');
expect(await device.sdkNameAndVersion, equals('Fuchsia'));
}, overrides: <Type, Generator>{
@@ -1048,14 +1041,11 @@ class FakeDartDevelopmentService extends Fake
@override
Future<void> startDartDevelopmentService(
Uri vmServiceUri, {
FlutterDevice? device,
int? ddsPort,
required Logger logger,
int? hostPort,
bool? ipv6,
bool? disableServiceAuthCodes,
bool cacheStartupProfile = false,
bool enableDevTools = false,
String? google3WorkspaceRoot,
Uri? devToolsServerAddress,
}) async {}
@override

View File

@@ -128,10 +128,6 @@ class FakeFlutterDevice extends Fake implements FlutterDevice {
required PackageConfig packageConfig,
}) => updateDevFSReportCallback();
// TODO(bkonyi): uncomment when ready to serve DevTools from DDS.
// @override
// Future<void> handleHotRestart() async {}
@override
TargetPlatform? get targetPlatform => device._targetPlatform;
}
@@ -154,10 +150,12 @@ class TestFlutterDevice extends FlutterDevice {
GetSkSLMethod? getSkSLMethod,
FlutterProject? flutterProject,
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
required DebuggingOptions debuggingOptions,
int? hostVmServicePort,
bool disableServiceAuthCodes = false,
bool enableDds = true,
bool cacheStartupProfile = false,
bool? ipv6 = false,
bool enableDevTools = false,
int? hostVmServicePort,
int? ddsPort,
bool allowExistingDdsInstance = false,
}) async {
throw exception;

View File

@@ -137,7 +137,8 @@ void main() {
..writeAsStringSync('\n');
final FakeDevice device = FakeDevice();
final List<FlutterDevice> devices = <FlutterDevice>[
FakeFlutterDevice(device),
FlutterDevice(device, generator: residentCompiler, buildInfo: BuildInfo.debug, developmentShaderCompiler: const FakeShaderCompiler())
..devFS = FakeDevFs(),
];
final OperationResult result = await HotRunner(
devices,
@@ -145,6 +146,7 @@ void main() {
target: 'main.dart',
devtoolsHandler: createNoOpHandler,
analytics: fakeAnalytics,
).restart(fullRestart: true);
expect(result.isOk, false);
expect(result.message, 'setupHotRestart failed');

View File

@@ -37,7 +37,6 @@ void main() {
late FakePlatform osx;
late FileSystemUtils fsUtils;
late MemoryFileSystem fileSystem;
final Logger logger = FakeLogger();
setUp(() {
osx = FakePlatform(
@@ -63,7 +62,6 @@ void main() {
name: 'iPhone 11',
simControl: simControl,
simulatorCategory: 'com.apple.CoreSimulator.SimRuntime.iOS-14-4',
logger: logger,
);
final DevicePortForwarder portForwarder = simulator.portForwarder;
await portForwarder.forward(123);
@@ -89,7 +87,6 @@ void main() {
name: 'iPhone 11',
simControl: FakeSimControl(),
simulatorCategory: 'com.apple.CoreSimulator.SimRuntime.iOS-14-4',
logger: logger,
);
expect(simulator.supportsRuntimeMode(BuildMode.debug), true);
@@ -116,7 +113,6 @@ void main() {
name: 'iPhone 11',
simControl: simControl,
simulatorCategory: 'com.apple.CoreSimulator.SimRuntime.iOS-14-4',
logger: logger,
);
expect(simulator.logFilePath, '/foo/bar/Library/Logs/CoreSimulator/123/system.log');
}, overrides: <Type, Generator>{
@@ -134,7 +130,6 @@ void main() {
name: 'iPhone 11',
simControl: simControl,
simulatorCategory: 'com.apple.CoreSimulator.SimRuntime.iOS-14-4',
logger: logger,
);
expect(simulator.logFilePath, '/baz/qux/456/system.log');
}, overrides: <Type, Generator>{
@@ -159,7 +154,6 @@ void main() {
name: 'iPhone SE',
simulatorCategory: 'com.apple.CoreSimulator.SimRuntime.iOS-11-3',
simControl: simControl,
logger: logger,
);
expect(await device.sdkMajorVersion, 11);
@@ -171,7 +165,6 @@ void main() {
name: 'iPhone SE',
simulatorCategory: 'iOS 11.2',
simControl: simControl,
logger: logger,
);
expect(await device.sdkMajorVersion, 11);
@@ -183,7 +176,6 @@ void main() {
name: 'iPhone SE',
simulatorCategory: 'iOS 11.2',
simControl: simControl,
logger: logger,
);
expect(device.category, Category.mobile);
@@ -203,7 +195,6 @@ void main() {
name: 'Apple TV',
simControl: simControl,
simulatorCategory: 'com.apple.CoreSimulator.SimRuntime.tvOS-14-5',
logger: logger,
);
expect(simulator.isSupported(), false);
}, overrides: <Type, Generator>{
@@ -218,7 +209,6 @@ void main() {
name: 'Apple Watch',
simControl: simControl,
simulatorCategory: 'com.apple.CoreSimulator.SimRuntime.watchOS-8-0',
logger: logger,
).isSupported(), false);
}, overrides: <Type, Generator>{
Platform: () => osx,
@@ -232,7 +222,6 @@ void main() {
name: 'iPad 2',
simControl: simControl,
simulatorCategory: 'com.apple.CoreSimulator.SimRuntime.iOS-11-3',
logger: logger,
).isSupported(), true);
}, overrides: <Type, Generator>{
Platform: () => osx,
@@ -246,7 +235,6 @@ void main() {
name: 'iPad Retina',
simControl: simControl,
simulatorCategory: 'com.apple.CoreSimulator.SimRuntime.iOS-11-3',
logger: logger,
).isSupported(), true);
}, overrides: <Type, Generator>{
Platform: () => osx,
@@ -260,7 +248,6 @@ void main() {
name: 'iPhone 5',
simControl: simControl,
simulatorCategory: 'com.apple.CoreSimulator.SimRuntime.iOS-11-3',
logger: logger,
).isSupported(), true);
}, overrides: <Type, Generator>{
Platform: () => osx,
@@ -274,7 +261,6 @@ void main() {
name: 'iPhone 5s',
simControl: simControl,
simulatorCategory: 'com.apple.CoreSimulator.SimRuntime.iOS-11-3',
logger: logger,
).isSupported(), true);
}, overrides: <Type, Generator>{
Platform: () => osx,
@@ -288,7 +274,6 @@ void main() {
name: 'iPhone SE',
simControl: simControl,
simulatorCategory: 'com.apple.CoreSimulator.SimRuntime.iOS-11-3',
logger: logger,
).isSupported(), true);
}, overrides: <Type, Generator>{
Platform: () => osx,
@@ -302,7 +287,6 @@ void main() {
name: 'iPhone 7 Plus',
simControl: simControl,
simulatorCategory: 'com.apple.CoreSimulator.SimRuntime.iOS-11-3',
logger: logger,
).isSupported(), true);
}, overrides: <Type, Generator>{
Platform: () => osx,
@@ -316,7 +300,6 @@ void main() {
name: 'iPhone X',
simControl: simControl,
simulatorCategory: 'com.apple.CoreSimulator.SimRuntime.iOS-11-3',
logger: logger,
).isSupported(), true);
}, overrides: <Type, Generator>{
Platform: () => osx,
@@ -354,7 +337,6 @@ void main() {
name: 'iPhone SE',
simControl: simControl,
simulatorCategory: 'com.apple.CoreSimulator.SimRuntime.iOS-11-3',
logger: logger,
);
final File screenshot = MemoryFileSystem.test().file('screenshot.png');
@@ -378,7 +360,6 @@ void main() {
name: 'iPhone SE',
simulatorCategory: 'iOS 9.3',
simControl: simControl,
logger: logger,
);
fakeProcessManager.addCommand(const FakeCommand(command: <String>[
'tail',
@@ -406,7 +387,6 @@ void main() {
name: 'iPhone SE',
simulatorCategory: 'iOS 11.0',
simControl: simControl,
logger: logger,
);
const String expectedPredicate = 'eventType = logEvent AND '
'processImagePath ENDSWITH "My Super Awesome App" AND '
@@ -441,7 +421,6 @@ void main() {
name: 'iPhone SE',
simulatorCategory: 'iOS 11.0',
simControl: simControl,
logger: logger,
);
const String expectedPredicate = 'eventType = logEvent AND '
'(senderImagePath ENDSWITH "/Flutter" OR senderImagePath ENDSWITH "/libswiftCore.dylib" OR processImageUUID == senderImageUUID) AND '
@@ -506,7 +485,6 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
name: 'iPhone 11',
simulatorCategory: 'iOS 10.0',
simControl: simControl,
logger: logger,
);
final DeviceLogReader logReader = device.getLogReader(
app: await BuildableIOSApp.fromProject(mockIosProject, null),
@@ -542,7 +520,6 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
name: 'iPhone 11',
simulatorCategory: 'iOS 10.3',
simControl: simControl,
logger: logger,
);
final DeviceLogReader logReader = device.getLogReader(
app: await BuildableIOSApp.fromProject(mockIosProject, null),
@@ -591,7 +568,6 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
name: 'iPhone 11',
simulatorCategory: 'iOS 10.3',
simControl: simControl,
logger: logger,
);
final DeviceLogReader logReader = device.getLogReader(
app: await BuildableIOSApp.fromProject(mockIosProject, null),
@@ -664,7 +640,6 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
name: 'iPhone 11',
simulatorCategory: 'iOS 11.0',
simControl: simControl,
logger: logger,
);
final DeviceLogReader logReader = device.getLogReader(
app: await BuildableIOSApp.fromProject(mockIosProject, null),
@@ -708,7 +683,6 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
name: 'iPhone 11',
simulatorCategory: 'iOS 11.0',
simControl: simControl,
logger: logger,
);
final DeviceLogReader logReader = device.getLogReader(
app: await BuildableIOSApp.fromProject(mockIosProject, null),
@@ -850,7 +824,6 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
name: 'Testo',
simulatorCategory: 'NaN',
simControl: simControl,
logger: logger,
);
expect(await iosSimulatorA.sdkMajorVersion, 11);
@@ -935,7 +908,6 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
name: 'Testo',
simulatorCategory: 'NaN',
simControl: simControl,
logger: logger,
);
expect(await iosSimulator.stopApp(null), isFalse);
@@ -1114,7 +1086,6 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
name: 'iPhone SE',
simulatorCategory: 'iOS 11.2',
simControl: simControl,
logger: logger,
);
testPlistParser.setProperty('CFBundleIdentifier', 'correct');
@@ -1144,7 +1115,6 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
name: 'iPhone SE',
simulatorCategory: 'iOS 11.2',
simControl: simControl,
logger: logger,
);
final Directory mockDir = globals.fs.currentDirectory;
@@ -1176,7 +1146,6 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
name: 'iPhone SE',
simulatorCategory: 'iOS 11.2',
simControl: simControl,
logger: logger,
);
testPlistParser.setProperty('CFBundleIdentifier', 'correct');
@@ -1249,7 +1218,6 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
name: 'iPhone SE',
simulatorCategory: 'iOS 11.2',
simControl: simControl,
logger: logger,
);
testPlistParser.setProperty('CFBundleIdentifier', 'correct');
@@ -1300,7 +1268,6 @@ flutter:
name: 'iPhone 11',
simControl: simControl,
simulatorCategory: 'com.apple.CoreSimulator.SimRuntime.iOS-11-3',
logger: logger,
);
expect(simulator.isSupportedForProject(flutterProject), true);
}, overrides: <Type, Generator>{
@@ -1321,7 +1288,6 @@ flutter:
name: 'iPhone 11',
simControl: simControl,
simulatorCategory: 'com.apple.CoreSimulator.SimRuntime.iOS-11-3',
logger: logger,
);
expect(simulator.isSupportedForProject(flutterProject), true);
}, overrides: <Type, Generator>{
@@ -1340,7 +1306,6 @@ flutter:
name: 'iPhone 11',
simControl: simControl,
simulatorCategory: 'com.apple.CoreSimulator.SimRuntime.iOS-11-3',
logger: logger,
);
expect(simulator.isSupportedForProject(flutterProject), false);
}, overrides: <Type, Generator>{
@@ -1355,7 +1320,6 @@ flutter:
name: 'iPhone 11',
simControl: simControl,
simulatorCategory: 'com.apple.CoreSimulator.SimRuntime.iOS-11-3',
logger: logger,
);
expect(simulator.createDevFSWriter(null, ''), isA<LocalDevFSWriter>());

View File

@@ -17,7 +17,6 @@ import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/device_vm_service_discovery_for_attach.dart';
import 'package:flutter_tools/src/proxied_devices/devices.dart';
import 'package:flutter_tools/src/proxied_devices/file_transfer.dart';
import 'package:flutter_tools/src/resident_runner.dart';
import 'package:test/fake.dart';
import '../../src/common.dart';
@@ -645,8 +644,9 @@ void main() {
final Future<void> startFuture = dds.startDartDevelopmentService(
Uri.parse('http://127.0.0.1:100/fake'),
disableServiceAuthCodes: true,
ddsPort: 150,
hostPort: 150,
ipv6: false,
logger: bufferLogger,
);
final DaemonMessage startMessage = await broadcastOutput.first;
@@ -656,13 +656,9 @@ void main() {
'deviceId': 'test_id',
'vmServiceUri': 'http://127.0.0.1:200/fake',
'disableServiceAuthCodes': true,
// TODO(bkonyi): uncomment when ready to serve DevTools from DDS.
// 'enableDevTools': false,
});
serverDaemonConnection.sendResponse( startMessage.data['id']!, const <String, Object?>{
'ddsUri': 'http://127.0.0.1:300/remote',
});
serverDaemonConnection.sendResponse(startMessage.data['id']!, 'http://127.0.0.1:300/remote');
await startFuture;
expect(portForwarder.receivedLocalForwardedPort, 100);
@@ -705,8 +701,9 @@ void main() {
final Future<void> startFuture = dds.startDartDevelopmentService(
Uri.parse('http://127.0.0.1:100/fake'),
disableServiceAuthCodes: true,
ddsPort: 150,
hostPort: 150,
ipv6: false,
logger: bufferLogger,
);
final DaemonMessage startMessage = await broadcastOutput.first;
@@ -716,13 +713,9 @@ void main() {
'deviceId': 'test_id',
'vmServiceUri': 'http://127.0.0.1:200/fake',
'disableServiceAuthCodes': true,
// TODO(bkonyi): uncomment when ready to serve DevTools from DDS.
// 'enableDevTools': false,
});
serverDaemonConnection.sendResponse(startMessage.data['id']!, <String, Object?>{
'ddsUri': 'http://127.0.0.1:300/remote',
});
serverDaemonConnection.sendResponse(startMessage.data['id']!, 'http://127.0.0.1:300/remote');
await startFuture;
expect(portForwarder.receivedLocalForwardedPort, 100);
@@ -765,8 +758,9 @@ void main() {
await dds.startDartDevelopmentService(
Uri.parse('http://127.0.0.1:100/fake'),
disableServiceAuthCodes: true,
ddsPort: 150,
hostPort: 150,
ipv6: false,
logger: bufferLogger,
);
expect(localDds.startCalled, true);
@@ -803,8 +797,9 @@ void main() {
final Future<void> startFuture = dds.startDartDevelopmentService(
Uri.parse('http://127.0.0.1:100/fake'),
disableServiceAuthCodes: true,
ddsPort: 150,
hostPort: 150,
ipv6: false,
logger: bufferLogger,
);
expect(localDds.startCalled, false);
@@ -815,8 +810,6 @@ void main() {
'deviceId': 'test_id',
'vmServiceUri': 'http://127.0.0.1:200/fake',
'disableServiceAuthCodes': true,
// TODO(bkonyi): uncomment when ready to serve DevTools from DDS.
// 'enableDevTools': false,
});
serverDaemonConnection.sendErrorResponse(startMessage.data['id']!, 'command not understood: device.startDartDevelopmentService', StackTrace.current);
@@ -1185,14 +1178,11 @@ class FakeDartDevelopmentService extends Fake implements DartDevelopmentService
@override
Future<void> startDartDevelopmentService(
Uri vmServiceUri, {
FlutterDevice? device,
int? ddsPort,
required Logger logger,
int? hostPort,
bool? ipv6,
bool? disableServiceAuthCodes,
bool enableDevTools = false,
bool cacheStartupProfile = false,
String? google3WorkspaceRoot,
Uri? devToolsServerAddress,
}) async {
startCalled = true;
startUri = vmServiceUri;
@@ -1200,10 +1190,6 @@ class FakeDartDevelopmentService extends Fake implements DartDevelopmentService
@override
Future<void> shutdown() async => shutdownCalled = true;
// TODO(bkonyi): uncomment when ready to serve DevTools from DDS.
// @override
// Future<void> invokeServiceExtensions(FlutterDevice? device) async {}
}
class FakePrebuiltApplicationPackage extends Fake implements PrebuiltApplicationPackage {

View File

@@ -469,14 +469,12 @@ class FakeDartDevelopmentService extends Fake implements DartDevelopmentService
@override
Future<void> startDartDevelopmentService(
Uri vmServiceUri, {
int? ddsPort,
bool? disableServiceAuthCodes,
Uri observatoryUri, {
required Logger logger,
int? hostPort,
bool? ipv6,
bool enableDevTools = true,
bool? disableServiceAuthCodes,
bool cacheStartupProfile = false,
String? google3WorkspaceRoot,
Uri? devToolsServerAddress,
}) async {
started = true;
}
@@ -485,4 +483,7 @@ class FakeDartDevelopmentService extends Fake implements DartDevelopmentService
Future<void> shutdown() async {
disposed = true;
}
@override
void setExternalDevToolsUri(Uri uri) {}
}

View File

@@ -4,6 +4,7 @@
import 'dart:async';
import 'package:dds/dds.dart' as dds;
import 'package:flutter_tools/src/application_package.dart';
import 'package:flutter_tools/src/asset.dart';
import 'package:flutter_tools/src/base/dds.dart';
@@ -150,44 +151,33 @@ const FakeVmServiceRequest evictShader = FakeVmServiceRequest(
}
);
const DartDevelopmentServiceInstance fakeDartDevelopmentServiceInstance = (
process: null,
serviceUri: null,
devToolsUri: null,
dtdUri: null,
);
final Uri testUri = Uri.parse('foo://bar');
class FakeDartDevelopmentService extends Fake with DartDevelopmentServiceLocalOperationsMixin implements DartDevelopmentService {
// This implements [dds.DartDevelopmentService], not the [DartDevelopmentService]
// interface from package:flutter_tools.
class FakeDartDevelopmentService extends Fake implements dds.DartDevelopmentService {
@override
Future<void> get done => Future<void>.value();
@override
Uri? get uri => null;
// TODO(bkonyi): uncomment when ready to serve DevTools from DDS>
/*
@override
Uri? get devToolsUri => null;
@override
Uri? get dtdUri => null;
@override
Future<void> handleHotRestart(FlutterDevice? device) async {}
*/
}
class FakeDartDevelopmentServiceException implements DartDevelopmentServiceException {
class FakeDartDevelopmentServiceException implements dds.DartDevelopmentServiceException {
FakeDartDevelopmentServiceException({this.message = defaultMessage});
@override
final int errorCode = DartDevelopmentServiceException.existingDdsInstanceError;
final int errorCode = dds.DartDevelopmentServiceException.existingDdsInstanceError;
@override
final String message;
static const String defaultMessage = 'A DDS instance is already connected at http://localhost:8181';
@override
Map<String, Object?> toJson() => <String, Object?>{
'error_code': errorCode,
'message': message,
};
}
class TestFlutterDevice extends FlutterDevice {
@@ -282,10 +272,13 @@ class FakeFlutterDevice extends Fake implements FlutterDevice {
GetSkSLMethod? getSkSLMethod,
FlutterProject? flutterProject,
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
required DebuggingOptions debuggingOptions,
int? hostVmServicePort,
bool? ipv6 = false,
bool allowExistingDdsInstance = false,
int? ddsPort,
bool disableServiceAuthCodes = false,
bool enableDds = true,
bool cacheStartupProfile = false,
required bool allowExistingDdsInstance,
bool ipv6 = false,
}) async { }
@override
@@ -310,10 +303,6 @@ class FakeFlutterDevice extends Fake implements FlutterDevice {
@override
Future<void> updateReloadStatus(bool wasReloadSuccessful) async { }
// TODO(bkonyi): uncomment when ready to serve DevTools from DDS.
// @override
// Future<void> handleHotRestart() async {}
}
class FakeDelegateFlutterDevice extends FlutterDevice {
@@ -328,13 +317,16 @@ class FakeDelegateFlutterDevice extends FlutterDevice {
Future<void> connect({
ReloadSources? reloadSources,
Restart? restart,
bool enableDds = true,
bool cacheStartupProfile = false,
bool disableServiceAuthCodes = false,
bool ipv6 = false,
CompileExpression? compileExpression,
GetSkSLMethod? getSkSLMethod,
FlutterProject? flutterProject,
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
required DebuggingOptions debuggingOptions,
int? hostVmServicePort,
bool? ipv6 = false,
int? ddsPort,
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
bool allowExistingDdsInstance = false,
}) async { }
@@ -443,7 +435,7 @@ class FakeDevice extends Fake implements Device {
String get name => 'FakeDevice';
@override
late DartDevelopmentService dds = FakeDartDevelopmentService();
late DartDevelopmentService dds;
@override
Future<void> dispose() async {

View File

@@ -4,10 +4,12 @@
import 'dart:async';
import 'package:dds/dds.dart' as dds;
import 'package:file/memory.dart';
import 'package:file_testing/file_testing.dart';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/command_help.dart';
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/dds.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart' as io;
@@ -63,8 +65,8 @@ void main() {
stayResident: false,
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
target: 'main.dart',
analytics: fakeAnalytics,
devtoolsHandler: createNoOpHandler,
analytics: globals.analytics,
);
}, overrides: <Type, Generator>{
Analytics: () => FakeAnalytics(),
@@ -88,6 +90,7 @@ void main() {
final Future<int?> result = residentRunner.attach(
appStartedCompleter: futureAppStart,
connectionInfoCompleter: futureConnectionInfo,
enableDevTools: true,
);
final Future<DebugConnectionInfo> connectionInfo = futureConnectionInfo.future;
@@ -119,7 +122,7 @@ void main() {
);
flutterDevice.generator = residentCompiler;
expect(await residentRunner.run(), 0);
expect(await residentRunner.run(enableDevTools: true), 0);
expect(residentCompiler.didSuppressErrors, true);
expect(fakeVmServiceHost?.hasRemainingExpectations, false);
}));
@@ -213,7 +216,7 @@ void main() {
);
flutterDevice.generator = residentCompiler;
expect(await residentRunner.run(), 0);
expect(await residentRunner.run(enableDevTools: true), 0);
expect(residentCompiler.didSuppressErrors, false);
expect(fakeVmServiceHost?.hasRemainingExpectations, false);
}));
@@ -276,6 +279,7 @@ void main() {
final Future<int?> result = residentRunner.attach(
appStartedCompleter: futureAppStart,
connectionInfoCompleter: futureConnectionInfo,
enableDevTools: true,
);
final Future<DebugConnectionInfo> connectionInfo = futureConnectionInfo.future;
@@ -297,6 +301,7 @@ void main() {
unawaited(residentRunner.attach(
appStartedCompleter: futureAppStart,
connectionInfoCompleter: futureConnectionInfo,
enableDevTools: true,
));
await futureAppStart.future;
flutterDevice.reportError = vm_service.RPCError('something bad happened', 666, '');
@@ -338,6 +343,7 @@ void main() {
unawaited(residentRunner.attach(
appStartedCompleter: futureAppStart,
connectionInfoCompleter: futureConnectionInfo,
enableDevTools: true,
));
await futureAppStart.future;
@@ -383,6 +389,7 @@ void main() {
unawaited(residentRunner.attach(
appStartedCompleter: futureAppStart,
connectionInfoCompleter: futureConnectionInfo,
enableDevTools: true,
));
await futureAppStart.future;
flutterDevice.reportError = vm_service.RPCError('something bad happened', kIsolateReloadBarred, '');
@@ -426,15 +433,13 @@ void main() {
],
stayResident: false,
target: 'main.dart',
debuggingOptions: DebuggingOptions.enabled(
const BuildInfo(
BuildMode.debug, '', treeShakeIcons: false, extraFrontEndOptions: <String>[
'--enable-experiment=non-nullable',
],
packageConfigPath: '.dart_tool/package_config.json',
),
enableDevTools: false,
),
debuggingOptions: DebuggingOptions.enabled(const BuildInfo(
BuildMode.debug, '', treeShakeIcons: false, extraFrontEndOptions: <String>[
'--enable-experiment=non-nullable',
],
packageConfigPath: '.dart_tool/package_config.json'
)),
devtoolsHandler: createNoOpHandler,
analytics: fakeAnalytics,
);
final Completer<DebugConnectionInfo> futureConnectionInfo = Completer<DebugConnectionInfo>.sync();
@@ -442,6 +447,7 @@ void main() {
unawaited(residentRunner.attach(
appStartedCompleter: futureAppStart,
connectionInfoCompleter: futureConnectionInfo,
enableDevTools: true,
));
await futureAppStart.future;
flutterDevice.reportError = vm_service.RPCError('something bad happened', 666, '');
@@ -506,6 +512,7 @@ void main() {
unawaited(residentRunner.attach(
appStartedCompleter: futureAppStart,
connectionInfoCompleter: futureConnectionInfo,
enableDevTools: true,
));
await futureAppStart.future;
flutterDevice.report = UpdateFSReport(success: true);
@@ -563,6 +570,7 @@ void main() {
unawaited(residentRunner.attach(
appStartedCompleter: futureAppStart,
connectionInfoCompleter: futureConnectionInfo,
enableDevTools: true,
));
await futureAppStart.future;
flutterDevice.report = UpdateFSReport(success: true, invalidatedSourcesCount: 1);
@@ -626,6 +634,7 @@ void main() {
unawaited(residentRunner.attach(
appStartedCompleter: futureAppStart,
connectionInfoCompleter: futureConnectionInfo,
enableDevTools: true,
));
await futureAppStart.future;
flutterDevice.report = UpdateFSReport(success: true, invalidatedSourcesCount: 1);
@@ -685,6 +694,7 @@ void main() {
unawaited(residentRunner.attach(
appStartedCompleter: futureAppStart,
connectionInfoCompleter: futureConnectionInfo,
enableDevTools: true,
));
await futureAppStart.future;
@@ -775,6 +785,7 @@ void main() {
unawaited(residentRunner.attach(
appStartedCompleter: futureAppStart,
connectionInfoCompleter: futureConnectionInfo,
enableDevTools: true,
));
await futureAppStart.future;
@@ -836,6 +847,7 @@ void main() {
unawaited(residentRunner.attach(
appStartedCompleter: futureAppStart,
connectionInfoCompleter: futureConnectionInfo,
enableDevTools: true,
));
final OperationResult result = await residentRunner.restart(fullRestart: true);
@@ -925,6 +937,7 @@ void main() {
unawaited(residentRunner.attach(
appStartedCompleter: futureAppStart,
connectionInfoCompleter: futureConnectionInfo,
enableDevTools: true,
));
final OperationResult result = await residentRunner.restart(fullRestart: true);
@@ -1045,6 +1058,7 @@ void main() {
unawaited(residentRunner.attach(
appStartedCompleter: futureAppStart,
connectionInfoCompleter: futureConnectionInfo,
enableDevTools: true,
));
await residentRunner.restart(fullRestart: true);
@@ -1064,6 +1078,7 @@ void main() {
unawaited(residentRunner.attach(
appStartedCompleter: futureAppStart,
connectionInfoCompleter: futureConnectionInfo,
enableDevTools: true,
));
await futureAppStart.future;
flutterDevice.reportError = vm_service.RPCError('something bad happened', 666, '');
@@ -1506,7 +1521,7 @@ flutter:
flutterDevice,
],
stayResident: false,
debuggingOptions: DebuggingOptions.enabled(BuildInfo.profile, vmserviceOutFile: 'foo', enableDevTools: false),
debuggingOptions: DebuggingOptions.enabled(BuildInfo.profile, vmserviceOutFile: 'foo'),
target: 'main.dart',
devtoolsHandler: createNoOpHandler,
);
@@ -1556,7 +1571,7 @@ flutter:
analytics: fakeAnalytics,
);
await residentRunner.run();
await residentRunner.run(enableDevTools: true);
expect(fakeVmServiceHost?.hasRemainingExpectations, false);
expect(await globals.fs.file('foo').readAsString(), testUri.toString());
@@ -1587,7 +1602,7 @@ flutter:
);
residentRunner.artifactDirectory.childFile('app.dill').writeAsStringSync('ABC');
await residentRunner.run();
await residentRunner.run(enableDevTools: true);
expect(await globals.fs.file(globals.fs.path.join('build', 'cache.dill')).readAsString(), 'ABC');
}));
@@ -1618,7 +1633,7 @@ flutter:
);
residentRunner.artifactDirectory.childFile('app.dill').writeAsStringSync('ABC');
await residentRunner.run();
await residentRunner.run(enableDevTools: true);
expect(await globals.fs.file(globals.fs.path.join(
'build', '187ef4436122d1cc2f40dc2b92f0eba0.cache.dill')).readAsString(), 'ABC');
@@ -1650,7 +1665,7 @@ flutter:
);
residentRunner.artifactDirectory.childFile('app.dill').writeAsStringSync('ABC');
await residentRunner.run();
await residentRunner.run(enableDevTools: true);
expect(await globals.fs.file(globals.fs.path.join(
'build', 'cache.dill')).readAsString(), 'ABC');
@@ -1674,7 +1689,7 @@ flutter:
);
residentRunner.artifactDirectory.childFile('app.dill').writeAsStringSync('ABC');
await residentRunner.run();
await residentRunner.run(enableDevTools: true);
expect(await globals.fs.file(globals.fs.path.join(
'build', 'cache.dill.track.dill')).readAsString(), 'ABC');
@@ -1699,7 +1714,7 @@ flutter:
);
residentRunner.artifactDirectory.childFile('app.dill').writeAsStringSync('ABC');
await residentRunner.run();
await residentRunner.run(enableDevTools: true);
expect(globals.fs.file(globals.fs.path.join('build', 'cache.dill')), isNot(exists));
}));
@@ -1728,7 +1743,7 @@ flutter:
);
residentRunner.artifactDirectory.childFile('app.dill').writeAsStringSync('ABC');
await residentRunner.run();
await residentRunner.run(enableDevTools: true);
expect(await globals.fs.file(globals.fs.path.join('build', 'cache.dill.track.dill')).readAsString(), 'ABC');
}));
@@ -1771,7 +1786,7 @@ flutter:
analytics: fakeAnalytics,
);
await residentRunner.run();
await residentRunner.run(enableDevTools: true);
expect(testLogger.errorText, contains('Failed to write vmservice-out-file at foo'));
expect(fakeVmServiceHost?.hasRemainingExpectations, false);
@@ -1790,11 +1805,11 @@ flutter:
],
stayResident: false,
debuggingOptions: DebuggingOptions.enabled(BuildInfo.profile, vmserviceOutFile: 'foo'),
devtoolsHandler: createNoOpHandler,
target: 'main.dart',
devtoolsHandler: createNoOpHandler,
);
await residentRunner.run();
await residentRunner.run(enableDevTools: true);
expect(await globals.fs.file('foo').readAsString(), testUri.toString());
expect(fakeVmServiceHost?.hasRemainingExpectations, false);
@@ -1960,19 +1975,61 @@ flutter:
ProcessManager: () => FakeProcessManager.any(),
});
testUsingContext('Handle existing VM service clients DDS error', () => testbed.run(() async {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
final FakeDevice device = FakeDevice()
..dds = DartDevelopmentService();
ddsLauncherCallback = (Uri uri, {bool enableAuthCodes = true, bool ipv6 = false, Uri? serviceUri, List<String> cachedUserTags = const <String>[], dds.UriConverter? uriConverter}) {
expect(uri, Uri(scheme: 'foo', host: 'bar'));
expect(enableAuthCodes, isTrue);
expect(ipv6, isFalse);
expect(serviceUri, Uri(scheme: 'http', host: '127.0.0.1', port: 0));
expect(cachedUserTags, isEmpty);
expect(uriConverter, isNull);
throw FakeDartDevelopmentServiceException(message:
'Existing VM service clients prevent DDS from taking control.',
);
};
final TestFlutterDevice flutterDevice = TestFlutterDevice(
device,
vmServiceUris: Stream<Uri>.value(testUri),
);
bool caught = false;
final Completer<void>done = Completer<void>();
runZonedGuarded(() {
flutterDevice.connect(allowExistingDdsInstance: true).then((_) => done.complete());
}, (Object e, StackTrace st) {
expect(e, isA<ToolExit>());
expect((e as ToolExit).message,
contains('Existing VM service clients prevent DDS from taking control.',
));
done.complete();
caught = true;
});
await done.future;
if (!caught) {
fail('Expected ToolExit to be thrown.');
}
}, overrides: <Type, Generator>{
VMServiceConnector: () => (Uri httpUri, {
ReloadSources? reloadSources,
Restart? restart,
CompileExpression? compileExpression,
GetSkSLMethod? getSkSLMethod,
FlutterProject? flutterProject,
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
io.CompressionOptions? compression,
Device? device,
required Logger logger,
}) async => FakeVmServiceHost(requests: <VmServiceExpectation>[]).vmService,
}));
testUsingContext('Uses existing DDS URI from exception field', () => testbed.run(() async {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
final FakeDevice device = FakeDevice()
..dds = DartDevelopmentService(logger: testLogger);
ddsLauncherCallback = (Uri uri,
{bool enableDevTools = false,
bool enableAuthCodes = true,
bool ipv6 = false, Uri? serviceUri,
List<String> cachedUserTags = const <String>[],
String? google3WorkspaceRoot,
Uri? devToolsServerAddress,
}) {
throw DartDevelopmentServiceException.existingDdsInstance(
..dds = DartDevelopmentService();
ddsLauncherCallback = (Uri uri, {bool enableAuthCodes = true, bool ipv6 = false, Uri? serviceUri, List<String> cachedUserTags = const <String>[], dds.UriConverter? uriConverter}) {
throw dds.DartDevelopmentServiceException.existingDdsInstance(
'Existing DDS at http://localhost/existingDdsInMessage.',
ddsUri: Uri.parse('http://localhost/existingDdsInField'),
);
@@ -1983,10 +2040,7 @@ flutter:
);
final Completer<void> done = Completer<void>();
unawaited(runZonedGuarded(
() => flutterDevice.connect(
allowExistingDdsInstance: true,
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
).then((_) => done.complete()),
() => flutterDevice.connect(allowExistingDdsInstance: true).then((_) => done.complete()),
(_, __) => done.complete(),
));
await done.future;
@@ -1998,7 +2052,41 @@ flutter:
CompileExpression? compileExpression,
GetSkSLMethod? getSkSLMethod,
FlutterProject? flutterProject,
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
io.CompressionOptions? compression,
Device? device,
required Logger logger,
}) async => FakeVmServiceHost(requests: <VmServiceExpectation>[]).vmService,
}));
testUsingContext('Falls back to existing DDS URI from exception message', () => testbed.run(() async {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
final FakeDevice device = FakeDevice()
..dds = DartDevelopmentService();
ddsLauncherCallback = (Uri uri, {bool enableAuthCodes = true, bool ipv6 = false, Uri? serviceUri, List<String> cachedUserTags = const <String>[], dds.UriConverter? uriConverter}) {
throw dds.DartDevelopmentServiceException.existingDdsInstance(
'Existing DDS at http://localhost/existingDdsInMessage.',
);
};
final TestFlutterDevice flutterDevice = TestFlutterDevice(
device,
vmServiceUris: Stream<Uri>.value(testUri),
);
final Completer<void>done = Completer<void>();
unawaited(runZonedGuarded(
() => flutterDevice.connect(allowExistingDdsInstance: true).then((_) => done.complete()),
(_, __) => done.complete(),
));
await done.future;
expect(device.dds.uri, Uri.parse('http://localhost/existingDdsInMessage'));
}, overrides: <Type, Generator>{
VMServiceConnector: () => (Uri httpUri, {
ReloadSources? reloadSources,
Restart? restart,
CompileExpression? compileExpression,
GetSkSLMethod? getSkSLMethod,
FlutterProject? flutterProject,
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
io.CompressionOptions? compression,
Device? device,
required Logger logger,
@@ -2008,34 +2096,23 @@ flutter:
testUsingContext('Host VM service ipv6 defaults', () => testbed.run(() async {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
final FakeDevice device = FakeDevice()
..dds = DartDevelopmentService(logger: testLogger);
..dds = DartDevelopmentService();
final Completer<void>done = Completer<void>();
ddsLauncherCallback = (Uri uri,
{bool enableDevTools = false,
bool enableAuthCodes = true,
bool ipv6 = false, Uri? serviceUri,
List<String> cachedUserTags = const <String>[],
String? google3WorkspaceRoot,
Uri? devToolsServerAddress,
}) async {
ddsLauncherCallback = (Uri uri, {bool enableAuthCodes = true, bool ipv6 = false, Uri? serviceUri, List<String> cachedUserTags = const <String>[], dds.UriConverter? uriConverter}) async {
expect(uri, Uri(scheme: 'foo', host: 'bar'));
expect(enableAuthCodes, isFalse);
expect(ipv6, isTrue);
expect(serviceUri, Uri(scheme: 'http', host: '::1', port: 0));
expect(cachedUserTags, isEmpty);
expect(uriConverter, isNull);
done.complete();
return fakeDartDevelopmentServiceInstance;
return FakeDartDevelopmentService();
};
final TestFlutterDevice flutterDevice = TestFlutterDevice(
device,
vmServiceUris: Stream<Uri>.value(testUri),
);
await flutterDevice.connect(
allowExistingDdsInstance: true,
debuggingOptions: DebuggingOptions.enabled(
BuildInfo.debug, disableServiceAuthCodes: true, ipv6: true,
)
);
await flutterDevice.connect(allowExistingDdsInstance: true, ipv6: true, disableServiceAuthCodes: true);
await done.future;
}, overrides: <Type, Generator>{
VMServiceConnector: () => (Uri httpUri, {
@@ -2051,25 +2128,67 @@ flutter:
}) async => FakeVmServiceHost(requests: <VmServiceExpectation>[]).vmService,
}));
testUsingContext('Failed DDS start outputs error message', () => testbed.run(() async {
// See https://github.com/flutter/flutter/issues/72385 for context.
testUsingContext('Context includes URI converter', () => testbed.run(() async {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
final FakeDevice device = FakeDevice()
..dds = DartDevelopmentService(logger: testLogger);
..dds = DartDevelopmentService();
final Completer<void>done = Completer<void>();
ddsLauncherCallback = (
Uri uri, {
bool enableDevTools = false,
bool enableAuthCodes = false,
bool ipv6 = false,
Uri? serviceUri,
List<String> cachedUserTags = const <String>[],
String? google3WorkspaceRoot,
Uri? devToolsServerAddress,
dds.UriConverter? uriConverter,
}) async {
expect(uri, Uri(scheme: 'foo', host: 'bar'));
expect(enableAuthCodes, isFalse);
expect(ipv6, isTrue);
expect(serviceUri, Uri(scheme: 'http', host: '::1', port: 0));
expect(cachedUserTags, isEmpty);
expect(uriConverter, isNotNull);
done.complete();
return FakeDartDevelopmentService();
};
final TestFlutterDevice flutterDevice = TestFlutterDevice(
device,
vmServiceUris: Stream<Uri>.value(testUri),
);
await flutterDevice.connect(allowExistingDdsInstance: true, ipv6: true, disableServiceAuthCodes: true);
await done.future;
}, overrides: <Type, Generator>{
VMServiceConnector: () => (Uri httpUri, {
ReloadSources? reloadSources,
Restart? restart,
CompileExpression? compileExpression,
GetSkSLMethod? getSkSLMethod,
FlutterProject? flutterProject,
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
io.CompressionOptions compression = io.CompressionOptions.compressionDefault,
Device? device,
required Logger logger,
}) async => FakeVmServiceHost(requests: <VmServiceExpectation>[]).vmService,
dds.UriConverter: () => (String uri) => 'test',
}));
testUsingContext('Failed DDS start outputs error message', () => testbed.run(() async {
// See https://github.com/flutter/flutter/issues/72385 for context.
final FakeDevice device = FakeDevice()
..dds = DartDevelopmentService();
ddsLauncherCallback = (
Uri uri, {
bool enableAuthCodes = false,
bool ipv6 = false,
Uri? serviceUri,
List<String> cachedUserTags = const <String>[],
dds.UriConverter? uriConverter,
}) {
expect(uri, Uri(scheme: 'foo', host: 'bar'));
expect(enableAuthCodes, isTrue);
expect(ipv6, isFalse);
expect(serviceUri, Uri(scheme: 'http', host: '127.0.0.1', port: 0));
expect(cachedUserTags, isEmpty);
expect(uriConverter, isNull);
throw FakeDartDevelopmentServiceException(message: 'No URI');
};
final TestFlutterDevice flutterDevice = TestFlutterDevice(
@@ -2079,10 +2198,7 @@ flutter:
bool caught = false;
final Completer<void>done = Completer<void>();
runZonedGuarded(() {
flutterDevice.connect(
allowExistingDdsInstance: true,
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug, enableDevTools: false),
).then((_) => done.complete());
flutterDevice.connect(allowExistingDdsInstance: true).then((_) => done.complete());
}, (Object e, StackTrace st) {
expect(e, isA<StateError>());
expect((e as StateError).message, contains('No URI'));
@@ -2120,7 +2236,6 @@ flutter:
expect(() => nextPlatform('unknown'), throwsAssertionError);
});
// TODO(bkonyi): remove when ready to serve DevTools from DDS.
testUsingContext('cleanupAtFinish shuts down resident devtools handler', () => testbed.run(() async {
residentRunner = HotRunner(
<FlutterDevice>[

View File

@@ -50,6 +50,7 @@ void main() {
mockFlutterDevice,
flutterProject: project,
debuggingOptions: DebuggingOptions.disabled(BuildInfo.release),
ipv6: true,
fileSystem: fileSystem,
logger: BufferLogger.test(),
systemClock: SystemClock.fixed(DateTime(0, 0, 0)),
@@ -80,6 +81,7 @@ void main() {
mockFlutterDevice,
flutterProject: project,
debuggingOptions: DebuggingOptions.disabled(BuildInfo.release),
ipv6: true,
fileSystem: fileSystem,
logger: BufferLogger.test(),
systemClock: SystemClock.fixed(DateTime(0, 0, 0)),
@@ -105,6 +107,7 @@ void main() {
mockFlutterDevice,
flutterProject: project,
debuggingOptions: DebuggingOptions.disabled(BuildInfo.release),
ipv6: true,
fileSystem: fileSystem,
logger: BufferLogger.test(),
systemClock: SystemClock.fixed(DateTime(0, 0, 0)),
@@ -129,6 +132,7 @@ void main() {
mockFlutterDevice,
flutterProject: project,
debuggingOptions: DebuggingOptions.disabled(BuildInfo.release),
ipv6: true,
fileSystem: fileSystem,
logger: BufferLogger.test(),
systemClock: SystemClock.fixed(DateTime(0, 0, 0)),
@@ -158,6 +162,7 @@ void main() {
mockFlutterDevice,
flutterProject: project,
debuggingOptions: DebuggingOptions.disabled(BuildInfo.release),
ipv6: true,
fileSystem: fileSystem,
logger: BufferLogger.test(),
systemClock: SystemClock.fixed(DateTime(0, 0, 0)),
@@ -240,8 +245,4 @@ class FakeFlutterDevice extends Fake implements FlutterDevice {
@override
FlutterVmService? vmService;
// TODO(bkonyi): uncomment when ready to serve DevTools from DDS.
// @override
// Future<void> handleHotRestart() async {}
}

View File

@@ -162,6 +162,7 @@ void main() {
flutterProject:
FlutterProject.fromDirectoryTest(fileSystem.currentDirectory),
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
ipv6: true,
fileSystem: fileSystem,
logger: BufferLogger.test(),
usage: globals.flutterUsage,
@@ -194,6 +195,7 @@ void main() {
FlutterProject.fromDirectoryTest(fileSystem.currentDirectory),
debuggingOptions:
DebuggingOptions.enabled(BuildInfo.debug, startPaused: true),
ipv6: true,
fileSystem: fileSystem,
logger: BufferLogger.test(),
usage: globals.flutterUsage,
@@ -213,6 +215,7 @@ void main() {
flutterProject:
FlutterProject.fromDirectoryTest(fileSystem.currentDirectory),
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
ipv6: true,
fileSystem: fileSystem,
logger: BufferLogger.test(),
usage: globals.flutterUsage,
@@ -226,6 +229,7 @@ void main() {
flutterProject:
FlutterProject.fromDirectoryTest(fileSystem.currentDirectory),
debuggingOptions: DebuggingOptions.enabled(BuildInfo.profile),
ipv6: true,
fileSystem: fileSystem,
logger: BufferLogger.test(),
usage: globals.flutterUsage,
@@ -358,13 +362,13 @@ void main() {
flutterProject:
FlutterProject.fromDirectoryTest(fileSystem.currentDirectory),
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
ipv6: true,
stayResident: false,
fileSystem: fileSystem,
logger: logger,
usage: globals.flutterUsage,
analytics: globals.analytics,
systemClock: globals.systemClock,
devtoolsHandler: createNoOpHandler,
);
expect(await residentWebRunner.run(), 0);
@@ -385,13 +389,13 @@ void main() {
flutterProject:
FlutterProject.fromDirectoryTest(fileSystem.currentDirectory),
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
ipv6: true,
stayResident: false,
fileSystem: fileSystem,
logger: BufferLogger.test(),
usage: globals.flutterUsage,
analytics: globals.analytics,
systemClock: globals.systemClock,
devtoolsHandler: createNoOpHandler,
);
expect(await residentWebRunner.run(), 0);
@@ -587,12 +591,12 @@ void main() {
FlutterProject.fromDirectoryTest(fileSystem.currentDirectory),
debuggingOptions:
DebuggingOptions.enabled(BuildInfo.debug, startPaused: true),
ipv6: true,
fileSystem: fileSystem,
logger: BufferLogger.test(),
usage: globals.flutterUsage,
analytics: globals.analytics,
systemClock: globals.systemClock,
devtoolsHandler: createNoOpHandler,
);
fakeVmServiceHost =
FakeVmServiceHost(requests: kAttachExpectations.toList());
@@ -1008,7 +1012,7 @@ void main() {
testUsingContext('cleanup of resources is safe to call multiple times',
() async {
final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice);
mockDevice.dds = DartDevelopmentService(logger: test_fakes.FakeLogger());
mockDevice.dds = DartDevelopmentService();
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
...kAttachExpectations,
]);
@@ -1111,12 +1115,12 @@ void main() {
flutterProject:
FlutterProject.fromDirectoryTest(fileSystem.currentDirectory),
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
ipv6: true,
fileSystem: fileSystem,
logger: logger,
usage: globals.flutterUsage,
analytics: globals.analytics,
systemClock: globals.systemClock,
devtoolsHandler: createNoOpHandler,
);
final Completer<DebugConnectionInfo> connectionInfoCompleter =
@@ -1160,12 +1164,12 @@ void main() {
flutterProject:
FlutterProject.fromDirectoryTest(fileSystem.currentDirectory),
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
ipv6: true,
fileSystem: fileSystem,
logger: logger,
usage: globals.flutterUsage,
analytics: globals.analytics,
systemClock: globals.systemClock,
devtoolsHandler: createNoOpHandler,
);
final Completer<DebugConnectionInfo> connectionInfoCompleter =
@@ -1202,13 +1206,13 @@ void main() {
flutterProject:
FlutterProject.fromDirectoryTest(fileSystem.currentDirectory),
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
ipv6: true,
stayResident: false,
fileSystem: fileSystem,
logger: BufferLogger.test(),
usage: globals.flutterUsage,
analytics: globals.analytics,
systemClock: globals.systemClock,
devtoolsHandler: createNoOpHandler,
);
// Create necessary files.
@@ -1406,6 +1410,7 @@ ResidentRunner setUpResidentRunner(
FlutterProject.fromDirectoryTest(globals.fs.currentDirectory),
debuggingOptions:
debuggingOptions ?? DebuggingOptions.enabled(BuildInfo.debug),
ipv6: true,
usage: globals.flutterUsage,
analytics: globals.analytics,
systemClock: systemClock ?? SystemClock.fixed(DateTime.now()),
@@ -1714,11 +1719,13 @@ class FakeFlutterDevice extends Fake implements FlutterDevice {
GetSkSLMethod? getSkSLMethod,
FlutterProject? flutterProject,
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
required DebuggingOptions debuggingOptions,
int? hostVmServicePort,
int? ddsPort,
bool disableServiceAuthCodes = false,
bool enableDds = true,
bool cacheStartupProfile = false,
required bool allowExistingDdsInstance,
bool? ipv6 = false,
bool enableDevTools = false,
bool allowExistingDdsInstance = false,
}) async {}
@override
@@ -1744,10 +1751,6 @@ class FakeFlutterDevice extends Fake implements FlutterDevice {
@override
Future<void> updateReloadStatus(bool wasReloadSuccessful) async {}
// TODO(bkonyi): uncomment when ready to serve DevTools from DDS.
// @override
// Future<void> handleHotRestart() async {}
}
class FakeShaderCompiler implements DevelopmentShaderCompiler {

View File

@@ -191,7 +191,6 @@ void main() {
Analytics: () => fakeAnalytics,
});
// TODO(bkonyi): remove when ready to serve DevTools from DDS.
group('${FlutterGlobalOptions.kPrintDtd} flag', () {
testUsingContext('sets DevtoolsLauncher.printDtdUri to false when not present', () async {
final FlutterCommandRunner runner = createTestCommandRunner(DummyFlutterCommand()) as FlutterCommandRunner;

View File

@@ -7,7 +7,6 @@ import 'dart:async';
import 'package:file/file.dart';
import 'package:file/memory.dart';
import 'package:file_testing/file_testing.dart';
import 'package:flutter_tools/src/base/dds.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/signals.dart';
@@ -26,7 +25,6 @@ import 'package:vm_service/vm_service.dart' as vm_service;
import '../src/common.dart';
import '../src/fake_vm_services.dart';
import '../src/fakes.dart';
final vm_service.Isolate fakeUnpausedIsolate = vm_service.Isolate(
id: '1',
@@ -834,20 +832,8 @@ void main() {
final FakeResidentDevtoolsHandler devtoolsHandler = runner.residentDevtoolsHandler as FakeResidentDevtoolsHandler;
expect(devtoolsHandler.calledLaunchDevToolsInBrowser, isFalse);
// TODO(bkonyi): uncomment these checks and remove existing checks when ready to
// serve DevTools from DDS.
/*
for (final FlutterDevice? device in runner.flutterDevices) {
expect(device!.device!.dds.calledLaunchDevToolsInBrowser, isFalse);
}
*/
await terminalHandler.processTerminalInput('v');
expect(devtoolsHandler.calledLaunchDevToolsInBrowser, isTrue);
/*
for (final FlutterDevice? device in runner.flutterDevices) {
expect(device!.device!.dds.calledLaunchDevToolsInBrowser, isTrue);
}
*/
});
testWithoutContext('w,W - debugDumpApp without service protocol is skipped', () async {
@@ -1322,13 +1308,11 @@ class FakeResidentRunner extends ResidentHandlers {
return OperationResult(reloadExitCode, '', fatal: fatalReloadError);
}
// TODO(bkonyi): remove when ready to serve DevTools from DDS.
@override
ResidentDevtoolsHandler get residentDevtoolsHandler => _residentDevtoolsHandler;
final ResidentDevtoolsHandler _residentDevtoolsHandler = FakeResidentDevtoolsHandler();
}
// TODO(bkonyi): remove when ready to serve DevTools from DDS.
class FakeResidentDevtoolsHandler extends Fake implements ResidentDevtoolsHandler {
bool calledLaunchDevToolsInBrowser = false;
@@ -1348,9 +1332,6 @@ class FakeDevice extends Fake implements Device {
@override
String get name => 'Fake Device';
@override
DartDevelopmentService dds = DartDevelopmentService(logger: FakeLogger());
@override
Future<void> takeScreenshot(File file) async {
if (!supportsScreenshot) {
@@ -1358,6 +1339,7 @@ class FakeDevice extends Fake implements Device {
}
file.writeAsBytesSync(<int>[1, 2, 3, 4]);
}
}
TerminalHandler setUpTerminalHandler(List<FakeVmServiceRequest> requests, {

View File

@@ -9,8 +9,6 @@ import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/project.dart';
import 'fakes.dart';
/// A list of fake devices to test JSON serialization
/// (`Device.toJson()` and `--machine` flag for `devices` command)
List<FakeDeviceJsonData> fakeDevices = <FakeDeviceJsonData>[
@@ -131,7 +129,6 @@ class FakeDevice extends Device {
platformType: type,
category: Category.mobile,
ephemeral: ephemeral,
logger: FakeLogger(),
);
final bool _isSupported;

View File

@@ -741,12 +741,6 @@ class FakeDevtoolsLauncher extends Fake implements DevtoolsLauncher {
}
}
/// A fake [Logger] that throws the [Invocation] for any method call.
class FakeLogger implements Logger {
@override
dynamic noSuchMethod(Invocation invocation) => throw invocation; // ignore: only_throw_errors
}
class ClosedStdinController extends Fake implements StreamSink<List<int>> {
@override
Future<Object?> addStream(Stream<List<int>> stream) async => throw const SocketException('Bad pipe');