Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(591)

Unified Diff: lib/src/runner/browser/internet_explorer.dart

Issue 1175163003: Factor out some common logic from the launchers. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: fix test Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/runner/browser/firefox.dart ('k') | lib/src/runner/browser/phantom_js.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/runner/browser/internet_explorer.dart
diff --git a/lib/src/runner/browser/internet_explorer.dart b/lib/src/runner/browser/internet_explorer.dart
index 920b375cb18f8f75141cc957d862afec0800aeb7..0d034b15fa4b7a567aa90dc7f42c15f38de38e57 100644
--- a/lib/src/runner/browser/internet_explorer.dart
+++ b/lib/src/runner/browser/internet_explorer.dart
@@ -5,81 +5,33 @@
library test.runner.browser.internet_explorer;
import 'dart:async';
-import 'dart:convert';
import 'dart:io';
import 'package:path/path.dart' as p;
-import 'package:stack_trace/stack_trace.dart';
-import '../../utils.dart';
-import '../application_exception.dart';
import 'browser.dart';
/// A class for running an instance of Internet Explorer.
///
/// Any errors starting or running the process are reported through [onExit].
-class InternetExplorer implements Browser {
- /// The underlying process.
- Process _process;
+class InternetExplorer extends Browser {
+ final name = "Internet Explorer";
- Future get onExit => _onExitCompleter.future;
- final _onExitCompleter = new Completer();
-
- /// A future that completes when the browser process has started.
- ///
- /// This is used to ensure that [close] works regardless of when it's called.
- Future get _onProcessStarted => _onProcessStartedCompleter.future;
- final _onProcessStartedCompleter = new Completer();
+ InternetExplorer(url, {String executable})
+ : super(() => _startBrowser(url, executable));
/// Starts a new instance of Internet Explorer open to the given [url], which
/// may be a [Uri] or a [String].
///
/// If [executable] is passed, it's used as the Internet Explorer executable.
- /// Otherwise the default executable name will be used.
- InternetExplorer(url, {String executable}) {
+ /// Otherwise the default executable name for the current OS will be used.
+ static Future<Process> _startBrowser(url, [String executable]) {
if (executable == null) executable = _defaultExecutable();
-
- // Don't return a Future here because there's no need for the caller to wait
- // for the process to actually start. They should just wait for the HTTP
- // request instead.
- invoke(() async {
- try {
- var process = await Process.start(
- executable, ['-extoff', url.toString()]);
-
- _process = process;
- _onProcessStartedCompleter.complete();
-
- // TODO(nweiz): the browser's standard output is almost always useless
- // noise, but we should allow the user to opt in to seeing it.
- var exitCode = await _process.exitCode;
- if (exitCode != 0) {
- var error = await UTF8.decodeStream(_process.stderr);
- throw new ApplicationException(
- "Internet Explorer failed with exit code $exitCode:\n$error");
- }
-
- _onExitCompleter.complete();
- } catch (error, stackTrace) {
- if (stackTrace == null) stackTrace = new Trace.current();
- _onExitCompleter.completeError(
- new ApplicationException(
- "Failed to start Internet Explorer: "
- "${getErrorMessage(error)}."),
- stackTrace);
- }
- });
- }
-
- Future close() {
- _onProcessStarted.then((_) => _process.kill());
-
- // Swallow exceptions. The user should explicitly use [onExit] for these.
- return onExit.catchError((_) {});
+ return Process.start(executable, ['-extoff', url.toString()]);
}
/// Return the default executable for the current operating system.
- String _defaultExecutable() {
+ static String _defaultExecutable() {
// Internet Explorer could be installed in several places on Windows. The
// only way to find it is to check.
var prefixes = [
« no previous file with comments | « lib/src/runner/browser/firefox.dart ('k') | lib/src/runner/browser/phantom_js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698