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

Unified Diff: test/runner/browser/dartium_test.dart

Issue 1080103002: Add support for running tests on Dartium. (Closed) Base URL: git@github.com:dart-lang/test@wip.dartium
Patch Set: Code review changes Created 5 years, 8 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 | « pubspec.yaml ('k') | test/runner/browser/runner_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/runner/browser/dartium_test.dart
diff --git a/test/runner/browser/firefox_test.dart b/test/runner/browser/dartium_test.dart
similarity index 56%
copy from test/runner/browser/firefox_test.dart
copy to test/runner/browser/dartium_test.dart
index 6453f0dd53c470db1f0b20a94bbd0b6b8d5600d5..b83e42486b31c4f44f1b8624677faf315f0fc54e 100644
--- a/test/runner/browser/firefox_test.dart
+++ b/test/runner/browser/dartium_test.dart
@@ -7,38 +7,39 @@
import 'dart:async';
import 'dart:io';
-import 'package:test/test.dart';
-import 'package:test/src/runner/browser/firefox.dart';
-import 'package:test/src/util/io.dart';
import 'package:shelf/shelf.dart' as shelf;
import 'package:shelf/shelf_io.dart' as shelf_io;
import 'package:shelf_web_socket/shelf_web_socket.dart';
+import 'package:test/src/runner/browser/dartium.dart';
+import 'package:test/src/util/io.dart';
+import 'package:test/src/utils.dart';
+import 'package:test/test.dart';
void main() {
- group("running JavaScript", () {
- // The JavaScript to serve in the server. We use actual JavaScript here to
- // avoid the pain of compiling to JS in a test
- var javaScript;
+ group("running Dart", () {
+ // The Dart to serve in the server.
+ var dart;
var servePage = (request) {
- var path = request.url.path;
-
- // We support both shelf 0.5.x and 0.6.x. The former has a leading "/"
- // here, the latter does not.
- if (path.startsWith("/")) path = path.substring(1);
+ var path = shelfUrl(request).path;
if (path.isEmpty) {
return new shelf.Response.ok("""
<!doctype html>
<html>
<head>
- <script src="index.js"></script>
+ <script type="application/dart" src="index.dart"></script>
</head>
</html>
""", headers: {'content-type': 'text/html'});
- } else if (path == "index.js") {
- return new shelf.Response.ok(javaScript,
- headers: {'content-type': 'application/javascript'});
+ } else if (path == "index.dart") {
+ return new shelf.Response.ok('''
+import "dart:html";
+
+void main() {
+ $dart
+}
+''', headers: {'content-type': 'application/dart'});
} else {
return new shelf.Response.notFound(null);
}
@@ -62,53 +63,52 @@ void main() {
tearDown(() {
if (server != null) server.close();
- javaScript = null;
+ dart = null;
server = null;
webSockets = null;
});
- test("starts Firefox with the given URL", () {
- javaScript = '''
-var webSocket = new WebSocket(window.location.href.replace("http://", "ws://"));
-webSocket.addEventListener("open", function() {
- webSocket.send("loaded!");
-});
+ test("starts Dartium with the given URL", () {
+ dart = '''
+var webSocket = new WebSocket(
+ window.location.href.replaceFirst("http://", "ws://"));
+webSocket.onOpen.first.then((_) => webSocket.send("loaded!"));
''';
- var firefox = new Firefox(baseUrlForAddress(server.address, server.port));
+ var dartium = new Dartium(baseUrlForAddress(server.address, server.port));
return webSockets.first.then((webSocket) {
return webSocket.first.then(
(message) => expect(message, equals("loaded!")));
- }).whenComplete(firefox.close);
+ }).whenComplete(dartium.close);
});
test("doesn't preserve state across runs", () {
- javaScript = '''
-localStorage.setItem("data", "value");
+ dart = '''
+window.localStorage["data"] = "value";
-var webSocket = new WebSocket(window.location.href.replace("http://", "ws://"));
-webSocket.addEventListener("open", function() {
- webSocket.send("done");
-});
+var webSocket = new WebSocket(
+ window.location.href.replaceFirst("http://", "ws://"));
+webSocket.onOpen.first.then((_) => webSocket.send("done"));
''';
- var firefox = new Firefox(baseUrlForAddress(server.address, server.port));
+ var dartium = new Dartium(baseUrlForAddress(server.address, server.port));
var first = true;
webSockets.listen(expectAsync((webSocket) {
if (first) {
// The first request will set local storage data. We can't kill the
- // old firefox and start a new one until we're sure that that has
+ // old Dartium and start a new one until we're sure that that has
// finished.
webSocket.first.then((_) {
- firefox.close();
+ dartium.close();
- javaScript = '''
-var webSocket = new WebSocket(window.location.href.replace("http://", "ws://"));
-webSocket.addEventListener("open", function() {
- webSocket.send(localStorage.getItem("data"));
-});
+ dart = '''
+var webSocket = new WebSocket(
+ window.location.href.replaceFirst("http://", "ws://"));
+webSocket.onOpen.first.then((_) =>
+ webSocket.send(window.localStorage["data"].toString()));
''';
- firefox = new Firefox(baseUrlForAddress(server.address, server.port));
+ dartium = new Dartium(
+ baseUrlForAddress(server.address, server.port));
first = false;
});
} else {
@@ -117,7 +117,7 @@ webSocket.addEventListener("open", function() {
expect(
webSocket.first
.then((message) => expect(message, equals('null')))
- .whenComplete(firefox.close),
+ .whenComplete(dartium.close),
completes);
}
}, count: 2));
@@ -127,14 +127,14 @@ webSocket.addEventListener("open", function() {
test("a process can be killed synchronously after it's started", () {
return shelf_io.serve(expectAsync((_) {}, count: 0), 'localhost', 0)
.then((server) {
- var firefox = new Firefox(baseUrlForAddress(server.address, server.port));
- return firefox.close().whenComplete(server.close);
+ var dartium = new Dartium(baseUrlForAddress(server.address, server.port));
+ return dartium.close().whenComplete(server.close);
});
});
test("reports an error in onExit", () {
- var firefox = new Firefox("http://dart-lang.org",
+ var dartium = new Dartium("http://dart-lang.org",
executable: "_does_not_exist");
- expect(firefox.onExit, throwsA(new isInstanceOf<ProcessException>()));
+ expect(dartium.onExit, throwsA(new isInstanceOf<ProcessException>()));
});
}
« no previous file with comments | « pubspec.yaml ('k') | test/runner/browser/runner_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698