mirror of
https://github.com/flutter/flutter.git
synced 2026-02-13 22:31:34 +08:00
Pass URI converter from context to DDS (#106840)
* Pass URI converter from context to DDS * Match change that will be merged * Revert SDK web change
This commit is contained in:
parent
b1410c2ce7
commit
118248bcc5
@ -8,6 +8,7 @@ import 'package:dds/dds.dart' as dds;
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import 'common.dart';
|
||||
import 'context.dart';
|
||||
import 'io.dart' as io;
|
||||
import 'logger.dart';
|
||||
|
||||
@ -18,6 +19,7 @@ Future<dds.DartDevelopmentService> Function(
|
||||
bool ipv6,
|
||||
Uri? serviceUri,
|
||||
List<String> cachedUserTags,
|
||||
dds.UriConverter? uriConverter,
|
||||
}) ddsLauncherCallback = dds.DartDevelopmentService.startDartDevelopmentService;
|
||||
|
||||
/// Helper class to launch a [dds.DartDevelopmentService]. Allows for us to
|
||||
@ -56,6 +58,7 @@ class DartDevelopmentService {
|
||||
ipv6: ipv6 ?? false,
|
||||
// Enables caching of CPU samples collected during application startup.
|
||||
cachedUserTags: cacheStartupProfile ? const <String>['AppStartUp'] : const <String>[],
|
||||
uriConverter: context.get<dds.UriConverter>(),
|
||||
);
|
||||
unawaited(_ddsInstance?.done.whenComplete(() {
|
||||
if (!_completer.isCompleted) {
|
||||
|
||||
@ -2035,12 +2035,13 @@ flutter:
|
||||
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
|
||||
final FakeDevice device = FakeDevice()
|
||||
..dds = DartDevelopmentService();
|
||||
ddsLauncherCallback = (Uri uri, {bool enableAuthCodes, bool ipv6, Uri serviceUri, List<String> cachedUserTags}) {
|
||||
ddsLauncherCallback = (Uri uri, {bool enableAuthCodes, bool ipv6, Uri serviceUri, List<String> cachedUserTags, 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.',
|
||||
);
|
||||
@ -2083,12 +2084,13 @@ flutter:
|
||||
final FakeDevice device = FakeDevice()
|
||||
..dds = DartDevelopmentService();
|
||||
final Completer<void>done = Completer<void>();
|
||||
ddsLauncherCallback = (Uri uri, {bool enableAuthCodes, bool ipv6, Uri serviceUri, List<String> cachedUserTags}) async {
|
||||
ddsLauncherCallback = (Uri uri, {bool enableAuthCodes, bool ipv6, Uri serviceUri, List<String> cachedUserTags, 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 null;
|
||||
};
|
||||
@ -2111,16 +2113,52 @@ flutter:
|
||||
}) async => FakeVmServiceHost(requests: <VmServiceExpectation>[]).vmService,
|
||||
}));
|
||||
|
||||
testUsingContext('Context includes URI converter', () => testbed.run(() async {
|
||||
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
|
||||
final FakeDevice device = FakeDevice()
|
||||
..dds = DartDevelopmentService();
|
||||
final Completer<void>done = Completer<void>();
|
||||
ddsLauncherCallback = (Uri uri, {bool enableAuthCodes, bool ipv6, Uri serviceUri, List<String> cachedUserTags, 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 null;
|
||||
};
|
||||
final TestFlutterDevice flutterDevice = TestFlutterDevice(
|
||||
device,
|
||||
observatoryUris: 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,
|
||||
PrintStructuredErrorLogMethod printStructuredErrorLogMethod,
|
||||
io.CompressionOptions compression,
|
||||
Device device,
|
||||
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, bool ipv6, Uri serviceUri, List<String> cachedUserTags}) {
|
||||
ddsLauncherCallback = (Uri uri, {bool enableAuthCodes, bool ipv6, Uri serviceUri, List<String> cachedUserTags, 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(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user