@@ -2158,6 +2158,73 @@ flutter:
21582158 }) async => FakeVmServiceHost (requests: < VmServiceExpectation > []).vmService,
21592159 }));
21602160
2161+ testUsingContext ('Uses existing DDS URI from exception field' , () => testbed.run (() async {
2162+ fakeVmServiceHost = FakeVmServiceHost (requests: < VmServiceExpectation > []);
2163+ final FakeDevice device = FakeDevice ()
2164+ ..dds = DartDevelopmentService ();
2165+ ddsLauncherCallback = (Uri uri, {bool enableAuthCodes = true , bool ipv6 = false , Uri ? serviceUri, List <String > cachedUserTags = const < String > [], dds.UriConverter ? uriConverter}) {
2166+ throw dds.DartDevelopmentServiceException .existingDdsInstance (
2167+ 'Existing DDS at http://localhost/existingDdsInMessage.' ,
2168+ ddsUri: Uri .parse ('http://localhost/existingDdsInField' ),
2169+ );
2170+ };
2171+ final TestFlutterDevice flutterDevice = TestFlutterDevice (
2172+ device,
2173+ observatoryUris: Stream <Uri >.value (testUri),
2174+ );
2175+ final Completer <void > done = Completer <void >();
2176+ await runZonedGuarded (
2177+ () => flutterDevice.connect (allowExistingDdsInstance: true ).then ((_) => done.complete ()),
2178+ (_, __) => done.complete (),
2179+ );
2180+ await done.future;
2181+ expect (device.dds.uri, Uri .parse ('http://localhost/existingDdsInField' ));
2182+ }, overrides: < Type , Generator > {
2183+ VMServiceConnector : () => (Uri httpUri, {
2184+ ReloadSources ? reloadSources,
2185+ Restart ? restart,
2186+ CompileExpression ? compileExpression,
2187+ GetSkSLMethod ? getSkSLMethod,
2188+ PrintStructuredErrorLogMethod ? printStructuredErrorLogMethod,
2189+ io.CompressionOptions ? compression,
2190+ Device ? device,
2191+ required Logger logger,
2192+ }) async => FakeVmServiceHost (requests: < VmServiceExpectation > []).vmService,
2193+ }));
2194+
2195+ testUsingContext ('Falls back to existing DDS URI from exception message' , () => testbed.run (() async {
2196+ fakeVmServiceHost = FakeVmServiceHost (requests: < VmServiceExpectation > []);
2197+ final FakeDevice device = FakeDevice ()
2198+ ..dds = DartDevelopmentService ();
2199+ ddsLauncherCallback = (Uri uri, {bool enableAuthCodes = true , bool ipv6 = false , Uri ? serviceUri, List <String > cachedUserTags = const < String > [], dds.UriConverter ? uriConverter}) {
2200+ throw dds.DartDevelopmentServiceException .existingDdsInstance (
2201+ 'Existing DDS at http://localhost/existingDdsInMessage.' ,
2202+ );
2203+ };
2204+ final TestFlutterDevice flutterDevice = TestFlutterDevice (
2205+ device,
2206+ observatoryUris: Stream <Uri >.value (testUri),
2207+ );
2208+ final Completer <void >done = Completer <void >();
2209+ await runZonedGuarded (
2210+ () => flutterDevice.connect (allowExistingDdsInstance: true ).then ((_) => done.complete ()),
2211+ (_, __) => done.complete (),
2212+ );
2213+ await done.future;
2214+ expect (device.dds.uri, Uri .parse ('http://localhost/existingDdsInMessage' ));
2215+ }, overrides: < Type , Generator > {
2216+ VMServiceConnector : () => (Uri httpUri, {
2217+ ReloadSources ? reloadSources,
2218+ Restart ? restart,
2219+ CompileExpression ? compileExpression,
2220+ GetSkSLMethod ? getSkSLMethod,
2221+ PrintStructuredErrorLogMethod ? printStructuredErrorLogMethod,
2222+ io.CompressionOptions ? compression,
2223+ Device ? device,
2224+ required Logger logger,
2225+ }) async => FakeVmServiceHost (requests: < VmServiceExpectation > []).vmService,
2226+ }));
2227+
21612228 testUsingContext ('Host VM service ipv6 defaults' , () => testbed.run (() async {
21622229 fakeVmServiceHost = FakeVmServiceHost (requests: < VmServiceExpectation > []);
21632230 final FakeDevice device = FakeDevice ()
0 commit comments