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

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

Issue 12753005: Add the ability to abort a scheduled test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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
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 '../lib/scheduled_test.dart'; 9 import '../lib/scheduled_test.dart';
10 import '../lib/src/mock_clock.dart' as mock_clock; 10 import '../lib/src/mock_clock.dart' as mock_clock;
(...skipping 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after
1352 expect(pumpEventQueue().then((_) { 1352 expect(pumpEventQueue().then((_) {
1353 throw 'error'; 1353 throw 'error';
1354 }), completion(equals('bar'))); 1354 }), completion(equals('bar')));
1355 }); 1355 });
1356 1356
1357 test('test 2', () { 1357 test('test 2', () {
1358 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); 1358 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
1359 expect(errors.map((e) => e.error), equals(['error'])); 1359 expect(errors.map((e) => e.error), equals(['error']));
1360 }); 1360 });
1361 }, passing: ['test 2']); 1361 }, passing: ['test 2']);
1362
1363 expectTestsPass("aborting the schedule before it's started running should "
1364 "cause no tasks to be run", () {
1365 test('test', () {
1366 schedule(() {
1367 throw 'error';
1368 });
1369
1370 currentSchedule.abort();
1371 });
1372 });
1373
1374 expectTestsPass("aborting the schedule while it's running should stop future "
1375 "tasks from running", () {
1376 test('test', () {
1377 schedule(currentSchedule.abort);
1378
1379 schedule(() {
1380 throw 'error';
1381 });
1382 });
1383 });
1384
1385 expectTestsPass("aborting the schedule while it's running shouldn't stop "
1386 "tasks in other queues from running", () {
1387 var onCompleteRun = false;
1388 test('test 1', () {
1389 schedule(currentSchedule.abort);
1390
1391 currentSchedule.onComplete.schedule(() {
1392 onCompleteRun = true;
1393 });
1394 });
1395
1396 test('test 2', () {
1397 expect(onCompleteRun, isTrue);
1398 });
1399 });
1400
1401 expectTestsPass("aborting the schedule while it's running shouldn't stop "
1402 "out-of-band callbacks", () {
1403 test('test', () {
1404 var outOfBandFinished = false;
1405 schedule(() {
1406 wrapFuture(pumpEventQueue().then((_) {
1407 outOfBandFinished = true;
1408 }));
1409
1410 currentSchedule.abort();
1411 });
1412
1413 currentSchedule.onComplete.schedule(() {
1414 expect(outOfBandFinished, isTrue);
1415 });
1416 });
1417 });
1418
1419 expectTestsPass("aborting the schedule in a non-tasks queue should stop "
1420 "future tasks from running", () {
1421 test('test', () {
1422 currentSchedule.onComplete.schedule(() {
1423 currentSchedule.abort();
1424 });
1425
1426 currentSchedule.onComplete.schedule(() {
1427 throw 'error';
1428 });
1429 });
1430 });
1431
1432 expectTestsFail("aborting the schedule after an out-of-band error should "
1433 "still surface the error", () {
1434 test('test', () {
1435 schedule(() {
1436 currentSchedule.signalError('error');
1437 currentSchedule.abort();
1438 });
1439 });
1440 });
1362 } 1441 }
OLDNEW
« pkg/scheduled_test/lib/src/schedule.dart ('K') | « pkg/scheduled_test/lib/src/schedule.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698