OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library test.runner.browser.browser; | 5 library test.runner.browser.browser; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 | 9 |
10 import 'package:stack_trace/stack_trace.dart'; | 10 import 'package:stack_trace/stack_trace.dart'; |
11 | 11 |
12 import '../../utils.dart'; | 12 import '../../utils.dart'; |
13 import '../application_exception.dart'; | 13 import '../application_exception.dart'; |
14 | 14 |
15 typedef Future<Process> StartBrowserFn(); | 15 typedef Future<Process> StartBrowserFn(); |
16 | 16 |
17 /// An interface for running browser instances. | 17 /// An interface for running browser instances. |
18 /// | 18 /// |
19 /// This is intentionally coarse-grained: browsers are controlled primary from | 19 /// This is intentionally coarse-grained: browsers are controlled primary from |
20 /// inside a single tab. Thus this interface only provides support for closing | 20 /// inside a single tab. Thus this interface only provides support for closing |
21 /// the browser and seeing if it closes itself. | 21 /// the browser and seeing if it closes itself. |
22 /// | 22 /// |
23 /// Any errors starting or running the browser process are reported through | 23 /// Any errors starting or running the browser process are reported through |
24 /// [onExit]. | 24 /// [onExit]. |
25 abstract class Browser { | 25 abstract class Browser { |
26 String get name; | 26 String get name; |
27 | 27 |
| 28 Future<Uri> get observatoryUrl => |
| 29 throw new UnsupportedError("$name doesn't support Observatory."); |
| 30 |
28 /// The underlying process. | 31 /// The underlying process. |
29 /// | 32 /// |
30 /// This will fire once the process has started successfully. | 33 /// This will fire once the process has started successfully. |
31 Future<Process> get _process => _processCompleter.future; | 34 Future<Process> get _process => _processCompleter.future; |
32 final _processCompleter = new Completer<Process>(); | 35 final _processCompleter = new Completer<Process>(); |
33 | 36 |
34 /// Whether [close] has been called. | 37 /// Whether [close] has been called. |
35 var _closed = false; | 38 var _closed = false; |
36 | 39 |
37 /// A future that completes when the browser exits. | 40 /// A future that completes when the browser exits. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 /// Returns the same [Future] as [onExit], except that it won't emit | 100 /// Returns the same [Future] as [onExit], except that it won't emit |
98 /// exceptions. | 101 /// exceptions. |
99 Future close() { | 102 Future close() { |
100 _closed = true; | 103 _closed = true; |
101 _process.then((process) => process.kill()); | 104 _process.then((process) => process.kill()); |
102 | 105 |
103 // Swallow exceptions. The user should explicitly use [onExit] for these. | 106 // Swallow exceptions. The user should explicitly use [onExit] for these. |
104 return onExit.catchError((_) {}); | 107 return onExit.catchError((_) {}); |
105 } | 108 } |
106 } | 109 } |
OLD | NEW |