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

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

Issue 229453002: Support returning a Future from a setUp or test body in scheduled_test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « pkg/scheduled_test/test/scheduled_test/set_up_test.dart ('k') | no next file » | 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) 2013, the Dart project authors. Please see the AUTHORS file 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 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 import 'package:scheduled_test/scheduled_test.dart'; 5 import 'package:scheduled_test/scheduled_test.dart';
6 import 'package:scheduled_test/src/mock_clock.dart' as mock_clock; 6 import 'package:scheduled_test/src/mock_clock.dart' as mock_clock;
7 7
8 import '../metatest.dart'; 8 import '../metatest.dart';
9 import '../utils.dart'; 9 import '../utils.dart';
10 10
(...skipping 26 matching lines...) Expand all
37 expectTestsPass("wrapFuture should return the value of the wrapped future", 37 expectTestsPass("wrapFuture should return the value of the wrapped future",
38 () { 38 () {
39 test('test', () { 39 test('test', () {
40 schedule(() { 40 schedule(() {
41 expect(wrapFuture(pumpEventQueue().then((_) => 'foo')), 41 expect(wrapFuture(pumpEventQueue().then((_) => 'foo')),
42 completion(equals('foo'))); 42 completion(equals('foo')));
43 }); 43 });
44 }); 44 });
45 }); 45 });
46 46
47 expectTestsPass("a returned future should be implicitly wrapped",
48 () {
49 test('test', () {
50 var futureComplete = false;
51 currentSchedule.onComplete.schedule(() => expect(futureComplete, isTrue));
52
53 return pumpEventQueue().then((_) => futureComplete = true);
54 });
55 });
56
57 expectTestsPass("a returned future should not block the schedule",
58 () {
59 test('test', () {
60 var futureComplete = false;
61 schedule(() => expect(futureComplete, isFalse));
62
63 return pumpEventQueue().then((_) => futureComplete = true);
64 });
65 });
66
47 expectTestsPass("wrapFuture should pass through the error of the wrapped " 67 expectTestsPass("wrapFuture should pass through the error of the wrapped "
48 "future", () { 68 "future", () {
49 var error; 69 var error;
50 test('test 1', () { 70 test('test 1', () {
51 schedule(() { 71 schedule(() {
52 wrapFuture(pumpEventQueue().then((_) { 72 wrapFuture(pumpEventQueue().then((_) {
53 throw 'error'; 73 throw 'error';
54 })).catchError(wrapAsync((e) { 74 })).catchError(wrapAsync((e) {
55 error = e; 75 error = e;
56 })); 76 }));
(...skipping 17 matching lines...) Expand all
74 throw 'error'; 94 throw 'error';
75 })); 95 }));
76 }); 96 });
77 97
78 test('test 2', () { 98 test('test 2', () {
79 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); 99 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
80 expect(errors.map((e) => e.error), equals(['error'])); 100 expect(errors.map((e) => e.error), equals(['error']));
81 }); 101 });
82 }, passing: ['test 2']); 102 }, passing: ['test 2']);
83 } 103 }
OLDNEW
« no previous file with comments | « pkg/scheduled_test/test/scheduled_test/set_up_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698