blob: a8b529ebe32bbba560339fb32aef3d80a08657ff [file] [log] [blame]
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:async';
import 'package:dds/dds.dart';
import 'package:observatory_2/service_io.dart';
import 'package:test/test.dart';
import 'test_helper.dart';
final tests = <VMTest>[
(VM vm) async {
DartDevelopmentService dds;
final waitForDDS = Completer<void>();
final serviceMessageCompleter = Completer<void>();
// The original VM service client is connected.
expect(vm.isConnected, true);
// A service event is sent to all existing clients when DDS connects before
// their connection is closed.
await vm.listenEventStream('Service', (ServiceEvent event) async {
// Wait for dds to be set before checking the server's URI.
await waitForDDS.future;
final message =
'A Dart Developer Service instance has connected and this direct '
'connection to the VM service will now be closed. Please reconnect to '
'the Dart Development Service at ${dds.uri}.';
expect(event.kind, ServiceEvent.kDartDevelopmentServiceConnected);
expect(event.message, message);
expect(event.uri, dds.uri);
// Start DDS, which should result in the original VM service client being
// disconnected from the VM service.
final remote = Uri.parse(;
dds = await DartDevelopmentService.startDartDevelopmentService(
scheme: 'http',
pathSegments: remote.pathSegments.sublist(
remote.pathSegments.length - 1,
expect(dds.isRunning, true);
await serviceMessageCompleter.future;
await vm.onDisconnect;
await dds.shutdown();
main(args) async => runVMTests(
enableDds: false,