Chromium Code Reviews

Side by Side Diff: pkg/scheduled_test/test/scheduled_future_matchers_test.dart

Issue 13472016: Split apart several asynchronous tests to reduce timeouts. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
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.
4
5 import 'dart:async';
6 import 'dart:io';
7
8 import 'package:scheduled_test/scheduled_test.dart';
9
10 import 'metatest.dart';
11 import 'utils.dart';
12
13 void main() {
14 metaSetUp(() {
15 // TODO(nweiz): We used to only increase the timeout to 10s for the Windows
16 // bots, but the Linux and Mac bots have started taking upwards of 5s when
17 // running pumpEventQueue, so we're increasing the timeout across the board
18 // (see issue 9248).
19 currentSchedule.timeout = new Duration(seconds: 10);
20 });
21
22 expectTestsPass("expect(..., completes) with a completing future should pass",
23 () {
24 test('test', () {
25 expect(pumpEventQueue(), completes);
26 });
27 });
28
29 expectTestsPass("expect(..., completes) with a failing future should signal "
30 "an out-of-band error", () {
31 var errors;
32 test('test 1', () {
33 currentSchedule.onException.schedule(() {
34 errors = currentSchedule.errors;
35 });
36
37 expect(pumpEventQueue().then((_) {
38 throw 'error';
39 }), completes);
40 });
41
42 test('test 2', () {
43 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
44 expect(errors.map((e) => e.error), equals(['error']));
45 });
46 }, passing: ['test 2']);
47
48 expectTestsPass("expect(..., completion(...)) with a matching future should "
49 "pass", () {
50 test('test', () {
51 expect(pumpEventQueue().then((_) => 'foo'), completion(equals('foo')));
52 });
53 });
54
55 expectTestsPass("expect(..., completion(...)) with a non-matching future "
56 "should signal an out-of-band error", () {
57 var errors;
58 test('test 1', () {
59 currentSchedule.onException.schedule(() {
60 errors = currentSchedule.errors;
61 });
62
63 expect(pumpEventQueue().then((_) => 'foo'), completion(equals('bar')));
64 });
65
66 test('test 2', () {
67 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
68 expect(errors.length, equals(1));
69 expect(errors.first.error, new isInstanceOf<TestFailure>());
70 });
71 }, passing: ['test 2']);
72
73 expectTestsPass("expect(..., completion(...)) with a failing future should "
74 "signal an out-of-band error", () {
75 var errors;
76 test('test 1', () {
77 currentSchedule.onException.schedule(() {
78 errors = currentSchedule.errors;
79 });
80
81 expect(pumpEventQueue().then((_) {
82 throw 'error';
83 }), completion(equals('bar')));
84 });
85
86 test('test 2', () {
87 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
88 expect(errors.map((e) => e.error), equals(['error']));
89 });
90 }, passing: ['test 2']);
91 }
OLDNEW

Powered by Google App Engine