Files
Danny Tuppeny f50975e3b5 [dds] Bump DDS to 5.0.0, use devtools_shared 11.0.0, and support a second DTD URI for web editors
devtools_shared 11.0.0 updates some signatures to use a new DTDInfo class to support both a local + exposed URI for DTD. A new CLI flag `--dtd-exposed-uri` for `devtools server` allows passing this second URI.

The DevTools server will use `--dtd-uri` to connect to DTD itself, but serve `--dtd-exposed-uri` to the frontend.

`--dtd-exposed-uri` is entirely optional and if not supplied, the value from `--dtd-uri` will be used in its place.

Change-Id: I5ab052ff9c4e7b2b186c1592f1ba2d63b7711113
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383400
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Kenzie Davisson <kenzieschmoll@google.com>
Reviewed-by: Kenzie Davisson <kenzieschmoll@google.com>
2024-09-11 17:05:09 +00:00

92 lines
2.8 KiB
Dart

// Copyright 2024 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:dds/devtools_server.dart';
import 'package:test/test.dart';
import 'utils/server_driver.dart';
void main() {
const dtdUriSwitch = '--${DevToolsServer.argDtdUri}';
const dtdExposedUriSwitch = '--${DevToolsServer.argDtdExposedUri}';
group('Dart Tooling Daemon connection', () {
test('does not start DTD when a DTD uri is passed as an argument',
() async {
final server = await DevToolsServerDriver.create(
additionalArgs: ['$dtdUriSwitch=ws://localhost:123/'],
);
try {
// Ensure the event does not arrive within some reasonable amount of
// time.
final dtdStartedEvent = await server.stdout
.firstWhere(
(map) => map!['event'] == 'server.dtdStarted',
orElse: () => null,
)
.timeout(
Duration(seconds: 3),
onTimeout: () => null,
);
expect(dtdStartedEvent, isNull);
} finally {
server.kill();
}
});
test('starts DTD when no DTD uri is passed as an argument', () async {
final server = await DevToolsServerDriver.create();
try {
final dtdStartedEvent = await server.stdout.firstWhere(
(map) => map!['event'] == 'server.dtdStarted',
orElse: () => null,
);
expect(dtdStartedEvent, isNotNull);
} finally {
server.kill();
}
});
test('rejects invalid URIs for --dtd-uri', () async {
final server = await DevToolsServerDriver.create(
additionalArgs: ['$dtdUriSwitch=some_uri'],
);
try {
final firstLine = await server.stdoutRaw.first;
expect(firstLine, '$dtdUriSwitch must be a valid URI');
} finally {
server.kill();
}
});
test('rejects invalid URIs for --dtd-exposed-uri', () async {
final server = await DevToolsServerDriver.create(
additionalArgs: [
'$dtdUriSwitch=ws://localhost:123/',
'$dtdExposedUriSwitch=some_uri'
],
);
try {
final firstLine = await server.stdoutRaw.first;
expect(firstLine, '$dtdExposedUriSwitch must be a valid URI');
} finally {
server.kill();
}
});
test('rejects --dtd-exposed-uri without --dtd-uri', () async {
final server = await DevToolsServerDriver.create(
additionalArgs: ['$dtdExposedUriSwitch=some_uri'],
);
try {
final firstLine = await server.stdoutRaw.first;
expect(firstLine,
'$dtdExposedUriSwitch can only be supplied with $dtdUriSwitch');
} finally {
server.kill();
}
});
});
}