| OLD | NEW |
| 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 library scheduled_test_test; | 5 library scheduled_test_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:scheduled_test/scheduled_test.dart'; | 9 import 'package:scheduled_test/scheduled_test.dart'; |
| 10 import 'package:scheduled_test/src/mock_clock.dart' as mock_clock; | 10 import 'package:scheduled_test/src/mock_clock.dart' as mock_clock; |
| (...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 currentSchedule.onException.schedule(() { | 870 currentSchedule.onException.schedule(() { |
| 871 errors = currentSchedule.errors; | 871 errors = currentSchedule.errors; |
| 872 }); | 872 }); |
| 873 | 873 |
| 874 schedule(() => sleep(2)); | 874 schedule(() => sleep(2)); |
| 875 }); | 875 }); |
| 876 | 876 |
| 877 test('test 2', () { | 877 test('test 2', () { |
| 878 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); | 878 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); |
| 879 expect(errors.map((e) => e.error), equals(["The schedule timed out after " | 879 expect(errors.map((e) => e.error), equals(["The schedule timed out after " |
| 880 "0:00:00.001 of inactivity."])); | 880 "0:00:00.001000 of inactivity."])); |
| 881 }); | 881 }); |
| 882 }, passing: ['test 2']); | 882 }, passing: ['test 2']); |
| 883 | 883 |
| 884 expectTestsPass("an out-of-band callback that takes too long will cause a " | 884 expectTestsPass("an out-of-band callback that takes too long will cause a " |
| 885 "timeout error", () { | 885 "timeout error", () { |
| 886 mock_clock.mock().run(); | 886 mock_clock.mock().run(); |
| 887 var errors; | 887 var errors; |
| 888 test('test 1', () { | 888 test('test 1', () { |
| 889 currentSchedule.timeout = new Duration(milliseconds: 1); | 889 currentSchedule.timeout = new Duration(milliseconds: 1); |
| 890 | 890 |
| 891 currentSchedule.onException.schedule(() { | 891 currentSchedule.onException.schedule(() { |
| 892 errors = currentSchedule.errors; | 892 errors = currentSchedule.errors; |
| 893 }); | 893 }); |
| 894 | 894 |
| 895 sleep(2).then(wrapAsync((_) => expect('foo', equals('foo')))); | 895 sleep(2).then(wrapAsync((_) => expect('foo', equals('foo')))); |
| 896 }); | 896 }); |
| 897 | 897 |
| 898 test('test 2', () { | 898 test('test 2', () { |
| 899 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); | 899 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); |
| 900 expect(errors.map((e) => e.error), equals(["The schedule timed out after " | 900 expect(errors.map((e) => e.error), equals(["The schedule timed out after " |
| 901 "0:00:00.001 of inactivity."])); | 901 "0:00:00.001000 of inactivity."])); |
| 902 }); | 902 }); |
| 903 }, passing: ['test 2']); | 903 }, passing: ['test 2']); |
| 904 | 904 |
| 905 expectTestsPass("each task resets the timeout timer", () { | 905 expectTestsPass("each task resets the timeout timer", () { |
| 906 mock_clock.mock().run(); | 906 mock_clock.mock().run(); |
| 907 test('test', () { | 907 test('test', () { |
| 908 currentSchedule.timeout = new Duration(milliseconds: 2); | 908 currentSchedule.timeout = new Duration(milliseconds: 2); |
| 909 | 909 |
| 910 schedule(() => sleep(1)); | 910 schedule(() => sleep(1)); |
| 911 schedule(() => sleep(1)); | 911 schedule(() => sleep(1)); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 936 }); | 936 }); |
| 937 | 937 |
| 938 sleep(4).then(wrapAsync((_) { | 938 sleep(4).then(wrapAsync((_) { |
| 939 throw 'out-of-band'; | 939 throw 'out-of-band'; |
| 940 })); | 940 })); |
| 941 }); | 941 }); |
| 942 | 942 |
| 943 test('test 2', () { | 943 test('test 2', () { |
| 944 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); | 944 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); |
| 945 expect(errors.map((e) => e.error), equals([ | 945 expect(errors.map((e) => e.error), equals([ |
| 946 "The schedule timed out after 0:00:00.003 of inactivity.", | 946 "The schedule timed out after 0:00:00.003000 of inactivity.", |
| 947 "out-of-band" | 947 "out-of-band" |
| 948 ])); | 948 ])); |
| 949 }); | 949 }); |
| 950 }, passing: ['test 2']); | 950 }, passing: ['test 2']); |
| 951 | 951 |
| 952 expectTestsPass("an out-of-band error that's signaled after a timeout but " | 952 expectTestsPass("an out-of-band error that's signaled after a timeout but " |
| 953 "before the test completes plays nicely with other out-of-band callbacks", | 953 "before the test completes plays nicely with other out-of-band callbacks", |
| 954 () { | 954 () { |
| 955 mock_clock.mock().run(); | 955 mock_clock.mock().run(); |
| 956 var errors; | 956 var errors; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 991 }); | 991 }); |
| 992 | 992 |
| 993 schedule(() => sleep(4)); | 993 schedule(() => sleep(4)); |
| 994 sleep(1).then((_) => currentSchedule.signalError('out-of-band')); | 994 sleep(1).then((_) => currentSchedule.signalError('out-of-band')); |
| 995 }); | 995 }); |
| 996 | 996 |
| 997 test('test 2', () { | 997 test('test 2', () { |
| 998 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); | 998 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); |
| 999 expect(errors.map((e) => e.error), equals([ | 999 expect(errors.map((e) => e.error), equals([ |
| 1000 "out-of-band", | 1000 "out-of-band", |
| 1001 "The schedule timed out after 0:00:00.002 of inactivity." | 1001 "The schedule timed out after 0:00:00.002000 of inactivity." |
| 1002 ])); | 1002 ])); |
| 1003 }); | 1003 }); |
| 1004 }, passing: ['test 2']); | 1004 }, passing: ['test 2']); |
| 1005 | 1005 |
| 1006 expectTestsPass("currentSchedule.heartbeat resets the timeout timer", () { | 1006 expectTestsPass("currentSchedule.heartbeat resets the timeout timer", () { |
| 1007 mock_clock.mock().run(); | 1007 mock_clock.mock().run(); |
| 1008 test('test', () { | 1008 test('test', () { |
| 1009 currentSchedule.timeout = new Duration(milliseconds: 3); | 1009 currentSchedule.timeout = new Duration(milliseconds: 3); |
| 1010 | 1010 |
| 1011 schedule(() { | 1011 schedule(() { |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1167 parentTaskFinished = true; | 1167 parentTaskFinished = true; |
| 1168 }); | 1168 }); |
| 1169 }); | 1169 }); |
| 1170 }); | 1170 }); |
| 1171 | 1171 |
| 1172 test('test 2', () { | 1172 test('test 2', () { |
| 1173 expect(parentTaskFinishedBeforeOnComplete, isTrue); | 1173 expect(parentTaskFinishedBeforeOnComplete, isTrue); |
| 1174 }); | 1174 }); |
| 1175 }, passing: ['test 2']); | 1175 }, passing: ['test 2']); |
| 1176 } | 1176 } |
| OLD | NEW |