Files
sdk/pkg/dds/test/devtools_server/remote_control_test.dart
T
Ben Konyi 1771c55238 [ DDS ] Split DevTools server tests into smaller pieces
Should resolve timeout issues, particularly around server connection
tests

Change-Id: Ic06d1179b09a17497e38de9aa19549f66ff79d2c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240180
Reviewed-by: Kenzie Davisson <kenzieschmoll@google.com>
2022-04-04 22:07:21 +00:00

83 lines
2.7 KiB
Dart

// Copyright 2022 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:test/test.dart';
import 'utils/server_driver.dart';
late final DevToolsServerTestController testController;
void main() {
testController = DevToolsServerTestController();
setUp(() async {
await testController.setUp();
});
tearDown(() async {
await testController.tearDown();
});
for (final bool useVmService in [true, false]) {
group('Server (${useVmService ? 'VM Service' : 'API'})', () {
test('can launch on a specific page', () async {
// Register the VM.
await testController.send(
'vm.register',
{'uri': testController.appFixture.serviceUri.toString()},
);
// Send a request to launch at a certain page.
await testController.sendLaunchDevToolsRequest(
useVmService: useVmService,
page: 'memory',
);
final serverResponse =
await testController.waitForClients(requiredPage: 'memory');
expect(serverResponse, isNotNull);
expect(serverResponse['clients'], hasLength(1));
expect(serverResponse['clients'][0]['hasConnection'], isTrue);
expect(
serverResponse['clients'][0]['vmServiceUri'],
testController.appFixture.serviceUri.toString(),
);
expect(serverResponse['clients'][0]['currentPage'], 'memory');
}, timeout: const Timeout.factor(10));
test('can switch page', () async {
await testController.send(
'vm.register',
{'uri': testController.appFixture.serviceUri.toString()},
);
// Launch on the memory page and wait for the connection.
await testController.sendLaunchDevToolsRequest(
useVmService: useVmService,
page: 'memory',
);
await testController.waitForClients(requiredPage: 'memory');
// Re-launch, allowing reuse and with a different page.
await testController.sendLaunchDevToolsRequest(
useVmService: useVmService,
reuseWindows: true,
page: 'logging',
);
final serverResponse =
await testController.waitForClients(requiredPage: 'logging');
expect(serverResponse, isNotNull);
expect(serverResponse['clients'], hasLength(1));
expect(serverResponse['clients'][0]['hasConnection'], isTrue);
expect(
serverResponse['clients'][0]['vmServiceUri'],
testController.appFixture.serviceUri.toString(),
);
expect(serverResponse['clients'][0]['currentPage'], 'logging');
}, timeout: const Timeout.factor(20));
});
}
}