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

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

Issue 12223122: Fix the expected error messages for scheduled tests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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 | « no previous file | 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 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 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 currentSchedule.onException.schedule(() { 768 currentSchedule.onException.schedule(() {
769 errors = currentSchedule.errors; 769 errors = currentSchedule.errors;
770 }); 770 });
771 771
772 schedule(() => sleep(2)); 772 schedule(() => sleep(2));
773 }); 773 });
774 774
775 test('test 2', () { 775 test('test 2', () {
776 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); 776 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
777 expect(errors.map((e) => e.error), equals(["The schedule timed out after " 777 expect(errors.map((e) => e.error), equals(["The schedule timed out after "
778 "1ms of inactivity."])); 778 "0:00:00.001 of inactivity."]));
779 }); 779 });
780 }, passing: ['test 2']); 780 }, passing: ['test 2']);
781 781
782 expectTestsPass("an out-of-band callback that takes too long will cause a " 782 expectTestsPass("an out-of-band callback that takes too long will cause a "
783 "timeout error", () { 783 "timeout error", () {
784 mock_clock.mock().run(); 784 mock_clock.mock().run();
785 var errors; 785 var errors;
786 test('test 1', () { 786 test('test 1', () {
787 currentSchedule.timeout = new Duration(milliseconds: 1); 787 currentSchedule.timeout = new Duration(milliseconds: 1);
788 788
789 currentSchedule.onException.schedule(() { 789 currentSchedule.onException.schedule(() {
790 errors = currentSchedule.errors; 790 errors = currentSchedule.errors;
791 }); 791 });
792 792
793 sleep(2).then(wrapAsync((_) => expect('foo', equals('foo')))); 793 sleep(2).then(wrapAsync((_) => expect('foo', equals('foo'))));
794 }); 794 });
795 795
796 test('test 2', () { 796 test('test 2', () {
797 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); 797 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
798 expect(errors.map((e) => e.error), equals(["The schedule timed out after " 798 expect(errors.map((e) => e.error), equals(["The schedule timed out after "
799 "1ms of inactivity."])); 799 "0:00:00.001 of inactivity."]));
800 }); 800 });
801 }, passing: ['test 2']); 801 }, passing: ['test 2']);
802 802
803 expectTestsPass("each task resets the timeout timer", () { 803 expectTestsPass("each task resets the timeout timer", () {
804 mock_clock.mock().run(); 804 mock_clock.mock().run();
805 test('test', () { 805 test('test', () {
806 currentSchedule.timeout = new Duration(milliseconds: 2); 806 currentSchedule.timeout = new Duration(milliseconds: 2);
807 807
808 schedule(() => sleep(1)); 808 schedule(() => sleep(1));
809 schedule(() => sleep(1)); 809 schedule(() => sleep(1));
(...skipping 24 matching lines...) Expand all
834 }); 834 });
835 835
836 sleep(4).then(wrapAsync((_) { 836 sleep(4).then(wrapAsync((_) {
837 throw 'out-of-band'; 837 throw 'out-of-band';
838 })); 838 }));
839 }); 839 });
840 840
841 test('test 2', () { 841 test('test 2', () {
842 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); 842 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
843 expect(errors.map((e) => e.error), equals([ 843 expect(errors.map((e) => e.error), equals([
844 "The schedule timed out after 3ms of inactivity.", 844 "The schedule timed out after 0:00:00.003 of inactivity.",
845 "out-of-band" 845 "out-of-band"
846 ])); 846 ]));
847 }); 847 });
848 }, passing: ['test 2']); 848 }, passing: ['test 2']);
849 849
850 expectTestsPass("an out-of-band error that's signaled after a timeout but " 850 expectTestsPass("an out-of-band error that's signaled after a timeout but "
851 "before the test completes plays nicely with other out-of-band callbacks", 851 "before the test completes plays nicely with other out-of-band callbacks",
852 () { 852 () {
853 mock_clock.mock().run(); 853 mock_clock.mock().run();
854 var errors; 854 var errors;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 }); 889 });
890 890
891 schedule(() => sleep(4)); 891 schedule(() => sleep(4));
892 sleep(1).then((_) => currentSchedule.signalError('out-of-band')); 892 sleep(1).then((_) => currentSchedule.signalError('out-of-band'));
893 }); 893 });
894 894
895 test('test 2', () { 895 test('test 2', () {
896 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); 896 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
897 expect(errors.map((e) => e.error), equals([ 897 expect(errors.map((e) => e.error), equals([
898 "out-of-band", 898 "out-of-band",
899 "The schedule timed out after 2ms of inactivity." 899 "The schedule timed out after 0:00:00.002 of inactivity."
900 ])); 900 ]));
901 }); 901 });
902 }, passing: ['test 2']); 902 }, passing: ['test 2']);
903 903
904 expectTestsPass("currentSchedule.heartbeat resets the timeout timer", () { 904 expectTestsPass("currentSchedule.heartbeat resets the timeout timer", () {
905 mock_clock.mock().run(); 905 mock_clock.mock().run();
906 test('test', () { 906 test('test', () {
907 currentSchedule.timeout = new Duration(milliseconds: 3); 907 currentSchedule.timeout = new Duration(milliseconds: 3);
908 908
909 schedule(() { 909 schedule(() {
910 return sleep(2).then((_) { 910 return sleep(2).then((_) {
911 currentSchedule.heartbeat(); 911 currentSchedule.heartbeat();
912 return sleep(2); 912 return sleep(2);
913 }); 913 });
914 }); 914 });
915 }); 915 });
916 }); 916 });
917 917
918 // TODO(nweiz): test out-of-band post-timeout errors that are detected after 918 // TODO(nweiz): test out-of-band post-timeout errors that are detected after
919 // the test finishes once we can detect top-level errors (issue 8417). 919 // the test finishes once we can detect top-level errors (issue 8417).
920 } 920 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698