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

Side by Side Diff: lib/src/runner/browser/content_shell.dart

Issue 1187103004: Allow Suites to be added to an Engine over time. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: 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 unified diff | Download patch
OLDNEW
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.content_shell; 5 library test.runner.browser.content_shell;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
kevmoo 2015/06/17 22:20:04 unused import
nweiz 2015/06/17 22:41:08 Done.
9 import 'dart:io'; 9 import 'dart:io';
10 10
11 import '../../utils.dart';
11 import '../application_exception.dart'; 12 import '../application_exception.dart';
12 import 'browser.dart'; 13 import 'browser.dart';
13 14
14 /// A converter that transforms a byte stream into a stream of lines.
15 final _lines = UTF8.decoder.fuse(const LineSplitter());
16
17 /// A class for running an instance of the Dartium content shell. 15 /// A class for running an instance of the Dartium content shell.
18 /// 16 ///
19 /// Most of the communication with the browser is expected to happen via HTTP, 17 /// Most of the communication with the browser is expected to happen via HTTP,
20 /// so this exposes a bare-bones API. The browser starts as soon as the class is 18 /// so this exposes a bare-bones API. The browser starts as soon as the class is
21 /// constructed, and is killed when [close] is called. 19 /// constructed, and is killed when [close] is called.
22 /// 20 ///
23 /// Any errors starting or running the process are reported through [onExit]. 21 /// Any errors starting or running the process are reported through [onExit].
24 class ContentShell extends Browser { 22 class ContentShell extends Browser {
25 final name = "Content Shell"; 23 final name = "Content Shell";
26 24
27 ContentShell(url, {String executable}) 25 ContentShell(url, {String executable})
28 : super(() => _startBrowser(url, executable)); 26 : super(() => _startBrowser(url, executable));
29 27
30 /// Starts a new instance of content shell open to the given [url], which may 28 /// Starts a new instance of content shell open to the given [url], which may
31 /// be a [Uri] or a [String]. 29 /// be a [Uri] or a [String].
32 /// 30 ///
33 /// If [executable] is passed, it's used as the content shell executable. 31 /// If [executable] is passed, it's used as the content shell executable.
34 /// Otherwise the default executable name for the current OS will be used. 32 /// Otherwise the default executable name for the current OS will be used.
35 static Future<Process> _startBrowser(url, [String executable]) async { 33 static Future<Process> _startBrowser(url, [String executable]) async {
36 if (executable == null) executable = _defaultExecutable(); 34 if (executable == null) executable = _defaultExecutable();
37 35
38 var process = await Process.start( 36 var process = await Process.start(
39 executable, ["--dump-render-tree", url.toString()], 37 executable, ["--dump-render-tree", url.toString()],
40 environment: {"DART_FLAGS": "--checked"}); 38 environment: {"DART_FLAGS": "--checked"});
41 39
42 _lines.bind(process.stderr).listen((line) { 40 lineSplitter.bind(process.stderr).listen((line) {
43 if (line != "[dartToStderr]: Dartium build has expired") return; 41 if (line != "[dartToStderr]: Dartium build has expired") return;
44 42
45 // TODO(nweiz): link to dartlang.org once it has download links for 43 // TODO(nweiz): link to dartlang.org once it has download links for
46 // content shell 44 // content shell
47 // (https://github.com/dart-lang/www.dartlang.org/issues/1164). 45 // (https://github.com/dart-lang/www.dartlang.org/issues/1164).
48 throw new ApplicationException( 46 throw new ApplicationException(
49 "You're using an expired content_shell. Upgrade to the latest " 47 "You're using an expired content_shell. Upgrade to the latest "
50 "version:\n" 48 "version:\n"
51 "http://gsdview.appspot.com/dart-archive/channels/stable/release/" 49 "http://gsdview.appspot.com/dart-archive/channels/stable/release/"
52 "latest/dartium/"); 50 "latest/dartium/");
53 }); 51 });
54 52
55 return process; 53 return process;
56 } 54 }
57 55
58 /// Return the default executable for the current operating system. 56 /// Return the default executable for the current operating system.
59 static String _defaultExecutable() => 57 static String _defaultExecutable() =>
60 Platform.isWindows ? "content_shell.exe" : "content_shell"; 58 Platform.isWindows ? "content_shell.exe" : "content_shell";
61 } 59 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698