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

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

Issue 1076803003: Change the URL-space exposed by the browser server. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Changelog + pubspec 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
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")
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'package:path/path.dart' as p; 9 import 'package:path/path.dart' as p;
10 import 'package:test/src/backend/state.dart'; 10 import 'package:test/src/backend/state.dart';
(...skipping 15 matching lines...) Expand all
26 26
27 void main() { 27 void main() {
28 test("success", () {}); 28 test("success", () {});
29 test("failure", () => throw new TestFailure('oh no')); 29 test("failure", () => throw new TestFailure('oh no'));
30 test("error", () => throw 'oh no'); 30 test("error", () => throw 'oh no');
31 } 31 }
32 """; 32 """;
33 33
34 void main() { 34 void main() {
35 setUp(() { 35 setUp(() {
36 _sandbox = createTempDir();
36 _loader = new Loader([TestPlatform.chrome], 37 _loader = new Loader([TestPlatform.chrome],
38 root: _sandbox,
37 packageRoot: p.join(packageDir, 'packages')); 39 packageRoot: p.join(packageDir, 'packages'));
38 _sandbox = createTempDir();
39 /// TODO(nweiz): Use scheduled_test for this once it's compatible with this 40 /// TODO(nweiz): Use scheduled_test for this once it's compatible with this
40 /// version of test. 41 /// version of test.
41 new File(p.join(_sandbox, 'a_test.dart')).writeAsStringSync(_tests); 42 new File(p.join(_sandbox, 'a_test.dart')).writeAsStringSync(_tests);
42 }); 43 });
43 44
44 tearDown(() { 45 tearDown(() {
45 new Directory(_sandbox).deleteSync(recursive: true); 46 new Directory(_sandbox).deleteSync(recursive: true);
46 return _loader.close(); 47 return _loader.close();
47 }); 48 });
48 49
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 }); 82 });
82 83
83 test("can load and run a failing test", () { 84 test("can load and run a failing test", () {
84 var liveTest = suite.tests[1].load(suite); 85 var liveTest = suite.tests[1].load(suite);
85 expectSingleFailure(liveTest); 86 expectSingleFailure(liveTest);
86 return liveTest.run().whenComplete(() => liveTest.close()); 87 return liveTest.run().whenComplete(() => liveTest.close());
87 }); 88 });
88 }); 89 });
89 90
90 test("throws a nice error if the package root doesn't exist", () { 91 test("throws a nice error if the package root doesn't exist", () {
91 var loader = new Loader([TestPlatform.chrome]); 92 var loader = new Loader([TestPlatform.chrome], root: _sandbox);
92 expect( 93 expect(
93 loader.loadFile(p.join(_sandbox, 'a_test.dart')).first 94 loader.loadFile(p.join(_sandbox, 'a_test.dart')).first
94 .whenComplete(loader.close), 95 .whenComplete(loader.close),
95 throwsA(isLoadException( 96 throwsA(isLoadException(
96 "Directory ${p.join(_sandbox, 'packages')} does not exist."))); 97 "Directory ${p.join(_sandbox, 'packages')} does not exist.")));
97 }); 98 });
98 99
99 test("loads a suite both in the browser and the VM", () { 100 test("loads a suite both in the browser and the VM", () {
100 var loader = new Loader([TestPlatform.vm, TestPlatform.chrome], 101 var loader = new Loader([TestPlatform.vm, TestPlatform.chrome],
102 root: _sandbox,
101 packageRoot: p.join(packageDir, 'packages')); 103 packageRoot: p.join(packageDir, 'packages'));
102 var path = p.join(_sandbox, 'a_test.dart'); 104 var path = p.join(_sandbox, 'a_test.dart');
103 return loader.loadFile(path).toList().then((suites) { 105 return loader.loadFile(path).toList().then((suites) {
104 expect(suites[0].platform, equals('VM')); 106 expect(suites[0].platform, equals('VM'));
105 expect(suites[0].path, equals(path)); 107 expect(suites[0].path, equals(path));
106 expect(suites[1].platform, equals('Chrome')); 108 expect(suites[1].platform, equals('Chrome'));
107 expect(suites[1].path, equals(path)); 109 expect(suites[1].path, equals(path));
108 110
109 for (var suite in suites) { 111 for (var suite in suites) {
110 expect(suite.tests, hasLength(3)); 112 expect(suite.tests, hasLength(3));
111 expect(suite.tests[0].name, equals("success")); 113 expect(suite.tests[0].name, equals("success"));
112 expect(suite.tests[1].name, equals("failure")); 114 expect(suite.tests[1].name, equals("failure"));
113 expect(suite.tests[2].name, equals("error")); 115 expect(suite.tests[2].name, equals("error"));
114 } 116 }
115 }).whenComplete(loader.close); 117 }).whenComplete(loader.close);
116 }); 118 });
117 } 119 }
OLDNEW
« no previous file with comments | « pubspec.yaml ('k') | test/runner/loader_test.dart » ('j') | test/runner/loader_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698