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

Unified Diff: pkg/scheduled_test/test/scheduled_test/simple_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, 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 side-by-side diff with in-line comments
Download patch
Index: pkg/scheduled_test/test/scheduled_test/simple_test.dart
diff --git a/pkg/scheduled_test/test/scheduled_test/simple_test.dart b/pkg/scheduled_test/test/scheduled_test/simple_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..ea519210111cf0f8421a917bdc838f391f677c60
--- /dev/null
+++ b/pkg/scheduled_test/test/scheduled_test/simple_test.dart
@@ -0,0 +1,123 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:async';
+import 'dart:io';
+
+import 'package:scheduled_test/scheduled_test.dart';
+
+import '../metatest.dart';
+import '../utils.dart';
+
+void main() {
+ setUpTimeout();
+
+ expectTestsPass('a scheduled test with a correct synchronous expectation '
+ 'should pass', () {
+ test('test', () {
+ expect('foo', equals('foo'));
+ });
+ });
+
+ expectTestsFail('a scheduled test with an incorrect synchronous expectation '
+ 'should fail', () {
+ test('test', () {
+ expect('foo', equals('bar'));
+ });
+ });
+
+ expectTestsPass('a scheduled test with a correct asynchronous expectation '
+ 'should pass', () {
+ test('test', () {
+ expect(new Future.immediate('foo'), completion(equals('foo')));
+ });
+ });
+
+ expectTestsFail('a scheduled test with an incorrect asynchronous expectation '
+ 'should fail', () {
+ test('test', () {
+ expect(new Future.immediate('foo'), completion(equals('bar')));
+ });
+ });
+
+ expectTestsPass('a passing scheduled synchronous expect should register', () {
+ test('test', () {
+ schedule(() => expect('foo', equals('foo')));
+ });
+ });
+
+ expectTestsFail('a failing scheduled synchronous expect should register', () {
+ test('test', () {
+ schedule(() => expect('foo', equals('bar')));
+ });
+ });
+
+ expectTestsPass('a passing scheduled asynchronous expect should '
+ 'register', () {
+ test('test', () {
+ schedule(() =>
+ expect(new Future.immediate('foo'), completion(equals('foo'))));
+ });
+ });
+
+ expectTestsFail('a failing scheduled synchronous expect should '
+ 'register', () {
+ test('test', () {
+ schedule(() =>
+ expect(new Future.immediate('foo'), completion(equals('bar'))));
+ });
+ });
+
+ expectTestsPass('scheduled blocks should be run in order after the '
+ 'synchronous setup', () {
+ test('test', () {
+ var list = [1];
+ schedule(() => list.add(2));
+ list.add(3);
+ schedule(() => expect(list, equals([1, 3, 4, 2])));
+ list.add(4);
+ });
+ });
+
+ expectTestsPass('scheduled blocks should forward their return values as '
+ 'Futures', () {
+ test('synchronous value', () {
+ var future = schedule(() => 'value');
+ expect(future, completion(equals('value')));
+ });
+
+ test('asynchronous value', () {
+ var future = schedule(() => new Future.immediate('value'));
+ expect(future, completion(equals('value')));
+ });
+ });
+
+ expectTestsPass('scheduled blocks should wait for their Future return values '
+ 'to complete before proceeding', () {
+ test('test', () {
+ var value = 'unset';
+ schedule(() => pumpEventQueue().then((_) {
+ value = 'set';
+ }));
+ schedule(() => expect(value, equals('set')));
+ });
+ });
+
+ expectTestsFail('a test failure in a chained future in a scheduled block '
+ 'should be registered', () {
+ test('test', () {
+ schedule(() => new Future.immediate('foo')
+ .then((v) => expect(v, equals('bar'))));
+ });
+ });
+
+ expectTestsFail('an error in a chained future in a scheduled block should be '
+ 'registered', () {
+ test('test', () {
+ schedule(() => new Future.immediate(null).then((_) {
+ throw 'error';
+ }));
+ });
+ });
+}

Powered by Google App Engine
This is Rietveld 408576698