blob: 1566d07a416a165c894b39f95b6e8a2a5b353240 [file]
// Copyright (c) 2019, 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 'package:test/test.dart';
import 'package:vm_service/vm_service.dart';
import 'common/service_test_common.dart';
import 'get_memory_usage_lib.dart' as testee_lib;
void main([args = const <String>[]]) =>
VMTestHarness('get_memory_usage_lib.dart', args)
.addTest((VmService service) async {
final vm = await service.getVM();
final result = await service.getMemoryUsage(vm.isolates!.first.id!);
expect(result.heapUsage, isPositive);
expect(result.heapCapacity, isPositive);
expect(result.externalUsage, greaterThanOrEqualTo(0));
}).addTest((VmService service) async {
bool? caughtException;
try {
await service.getMemoryUsage('badid');
fail('Unreachable');
} on RPCError catch (e) {
caughtException = true;
expect(
e.details,
contains("getMemoryUsage: invalid 'isolateId' parameter: badid"),
);
}
expect(caughtException, isTrue);
}).run(testeeMain: testee_lib.main);