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

Side by Side Diff: test/runner/browser/safari_test.dart

Issue 1062683004: Preliminary safari support. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Polish 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 unified diff | Download patch
« no previous file with comments | « test/runner/browser/runner_test.dart ('k') | test/runner/runner_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 @TestOn("vm") 5 @TestOn("vm && mac-os")
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'package:test/test.dart'; 10 import 'package:test/test.dart';
11 import 'package:test/src/runner/browser/chrome.dart'; 11 import 'package:test/src/runner/browser/safari.dart';
12 import 'package:test/src/util/io.dart'; 12 import 'package:test/src/util/io.dart';
13 import 'package:shelf/shelf.dart' as shelf; 13 import 'package:shelf/shelf.dart' as shelf;
14 import 'package:shelf/shelf_io.dart' as shelf_io; 14 import 'package:shelf/shelf_io.dart' as shelf_io;
15 import 'package:shelf_web_socket/shelf_web_socket.dart'; 15 import 'package:shelf_web_socket/shelf_web_socket.dart';
16 16
17 void main() { 17 void main() {
18 group("running JavaScript", () { 18 group("running JavaScript", () {
19 // The JavaScript to serve in the server. We use actual JavaScript here to 19 // The JavaScript to serve in the server. We use actual JavaScript here to
20 // avoid the pain of compiling to JS in a test 20 // avoid the pain of compiling to JS in a test
21 var javaScript; 21 var javaScript;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 }); 60 });
61 61
62 tearDown(() { 62 tearDown(() {
63 if (server != null) server.close(); 63 if (server != null) server.close();
64 64
65 javaScript = null; 65 javaScript = null;
66 server = null; 66 server = null;
67 webSockets = null; 67 webSockets = null;
68 }); 68 });
69 69
70 test("starts Chrome with the given URL", () { 70 test("starts Safari with the given URL", () {
71 javaScript = ''' 71 javaScript = '''
72 var webSocket = new WebSocket(window.location.href.replace("http://", "ws://")); 72 var webSocket = new WebSocket(window.location.href.replace("http://", "ws://"));
73 webSocket.addEventListener("open", function() { 73 webSocket.addEventListener("open", function() {
74 webSocket.send("loaded!"); 74 webSocket.send("loaded!");
75 }); 75 });
76 '''; 76 ''';
77 var chrome = new Chrome(baseUrlForAddress(server.address, server.port)); 77 var safari = new Safari(baseUrlForAddress(server.address, server.port));
78 78
79 return webSockets.first.then((webSocket) { 79 return webSockets.first.then((webSocket) {
80 return webSocket.first.then( 80 return webSocket.first.then(
81 (message) => expect(message, equals("loaded!"))); 81 (message) => expect(message, equals("loaded!")));
82 }).whenComplete(chrome.close); 82 }).whenComplete(safari.close);
83 }); 83 });
84 84
85 test("doesn't preserve state across runs", () { 85 test("doesn't preserve state across runs", () {
86 javaScript = ''' 86 javaScript = '''
87 localStorage.setItem("data", "value"); 87 localStorage.setItem("data", "value");
88 88
89 var webSocket = new WebSocket(window.location.href.replace("http://", "ws://")); 89 var webSocket = new WebSocket(window.location.href.replace("http://", "ws://"));
90 webSocket.addEventListener("open", function() { 90 webSocket.addEventListener("open", function() {
91 webSocket.send("done"); 91 webSocket.send("done");
92 }); 92 });
93 '''; 93 ''';
94 var chrome = new Chrome(baseUrlForAddress(server.address, server.port)); 94 var safari = new Safari(baseUrlForAddress(server.address, server.port));
95 95
96 var first = true; 96 var first = true;
97 webSockets.listen(expectAsync((webSocket) { 97 webSockets.listen(expectAsync((webSocket) {
98 if (first) { 98 if (first) {
99 // The first request will set local storage data. We can't kill the 99 // The first request will set local storage data. We can't kill the
100 // old chrome and start a new one until we're sure that that has 100 // old safari and start a new one until we're sure that that has
101 // finished. 101 // finished.
102 webSocket.first.then((_) { 102 webSocket.first.then((_) {
103 chrome.close(); 103 safari.close();
104 104
105 javaScript = ''' 105 javaScript = '''
106 var webSocket = new WebSocket(window.location.href.replace("http://", "ws://")); 106 var webSocket = new WebSocket(window.location.href.replace("http://", "ws://"));
107 webSocket.addEventListener("open", function() { 107 webSocket.addEventListener("open", function() {
108 webSocket.send(localStorage.getItem("data")); 108 webSocket.send(localStorage.getItem("data"));
109 }); 109 });
110 '''; 110 ''';
111 chrome = new Chrome(baseUrlForAddress(server.address, server.port)); 111 safari = new Safari(baseUrlForAddress(server.address, server.port));
112 first = false; 112 first = false;
113 }); 113 });
114 } else { 114 } else {
115 // The second request will return the local storage data. This should 115 // The second request will return the local storage data. This should
116 // be null, indicating that no data was saved between runs. 116 // be null, indicating that no data was saved between runs.
117 expect( 117 expect(
118 webSocket.first 118 webSocket.first
119 .then((message) => expect(message, equals('null'))) 119 .then((message) => expect(message, equals('null')))
120 .whenComplete(chrome.close), 120 .whenComplete(safari.close),
121 completes); 121 completes);
122 } 122 }
123 }, count: 2)); 123 }, count: 2));
124 }); 124 });
125 }); 125 });
126 126
127 test("a process can be killed synchronously after it's started", () { 127 test("a process can be killed synchronously after it's started", () {
128 return shelf_io.serve(expectAsync((_) {}, count: 0), 'localhost', 0) 128 return shelf_io.serve(expectAsync((_) {}, count: 0), 'localhost', 0)
129 .then((server) { 129 .then((server) {
130 var chrome = new Chrome(baseUrlForAddress(server.address, server.port)); 130 var safari = new Safari(baseUrlForAddress(server.address, server.port));
131 return chrome.close().whenComplete(server.close); 131 return safari.close().whenComplete(server.close);
132 }); 132 });
133 }); 133 });
134 134
135 test("reports an error in onExit", () { 135 test("reports an error in onExit", () {
136 var chrome = new Chrome("http://dart-lang.org", 136 var safari = new Safari("http://dart-lang.org",
137 executable: "_does_not_exist"); 137 executable: "_does_not_exist");
138 expect(chrome.onExit, throwsA(new isInstanceOf<ProcessException>())); 138 expect(safari.onExit, throwsA(new isInstanceOf<ProcessException>()));
139 }); 139 });
140 } 140 }
OLDNEW
« no previous file with comments | « test/runner/browser/runner_test.dart ('k') | test/runner/runner_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698