Line data Source code
1 : // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 2 : // for details. All rights reserved. Use of this source code is governed by a 3 : // BSD-style license that can be found in the LICENSE file. 4 : 5 : import 'dart:async'; 6 : 7 : import 'package:async/async.dart'; 8 : 9 : /// The abstract class of environments in which test suites are 10 : /// loaded—specifically, browsers and the Dart VM. 11 : abstract class Environment { 12 : /// Whether this environment supports interactive debugging. 13 : bool get supportsDebugging; 14 : 15 : /// The URL of the Dart VM Observatory for this environment, or `null` if this 16 : /// environment doesn't run the Dart VM or the URL couldn't be detected. 17 : Uri? get observatoryUrl; 18 : 19 : /// The URL of the remote debugger for this environment, or `null` if it isn't 20 : /// enabled. 21 : Uri? get remoteDebuggerUrl; 22 : 23 : /// A broadcast stream that emits a `null` event whenever the user tells the 24 : /// environment to restart the current test once it's finished. 25 : /// 26 : /// Never emits an error, and never closes. 27 : Stream get onRestart; 28 : 29 : /// Displays information indicating that the test runner is paused. 30 : /// 31 : /// The returned operation will complete when the user takes action within the 32 : /// environment that should unpause the runner. If the runner is unpaused 33 : /// elsewhere, the operation should be canceled. 34 : CancelableOperation displayPause(); 35 : } 36 : 37 : /// The default environment for platform plugins. 38 : class PluginEnvironment implements Environment { 39 : @override 40 : final supportsDebugging = false; 41 0 : @override 42 0 : Stream get onRestart => StreamController.broadcast().stream; 43 : 44 0 : const PluginEnvironment(); 45 : 46 0 : @override 47 : Uri? get observatoryUrl => null; 48 : 49 0 : @override 50 : Uri? get remoteDebuggerUrl => null; 51 : 52 0 : @override 53 0 : CancelableOperation displayPause() => throw UnsupportedError( 54 : 'PluginEnvironment.displayPause is not supported.'); 55 : }