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

Unified Diff: dart/tests/try/test_case.dart

Issue 269343009: Add (failing) source_update_test.dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 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
« no previous file with comments | « dart/tests/try/source_update_test.dart ('k') | dart/tests/try/test_try.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/tests/try/test_case.dart
diff --git a/dart/tests/try/test_case.dart b/dart/tests/try/test_case.dart
new file mode 100644
index 0000000000000000000000000000000000000000..20542f2e514b0ea24774d94f4983f6be22f1260d
--- /dev/null
+++ b/dart/tests/try/test_case.dart
@@ -0,0 +1,61 @@
+// Copyright (c) 2014, 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.
+
+library trydart.test_case;
+
+import 'dart:html' show
+ document;
+
+import 'dart:async';
+
+import '../../pkg/async_helper/lib/async_helper.dart';
+
+typedef void VoidFunction();
+
+class TestCase {
+ final String description;
+ final VoidFunction setup;
+ final VoidFunction validate;
+
+ TestCase(this.description, this.setup, this.validate);
+}
+
+/**
+ * Executes [tests] each test in order using the following approach for each
+ * test:
+ *
+ * 1. Run setup synchronously.
+ *
+ * 2. Schedule a new (async) Future which runs validate followed by the next
+ * test's setup.
+ *
+ * 3. Repeat step 2 until there are no more tests.
+ *
+ * The purpose of this test is to simulate edits (during setup), and then let
+ * the the mutation observer to process the mutations followed by validation.
+ */
+void runTests(List<TestCase> tests) {
+ Completer completer = new Completer();
+ asyncTest(() => completer.future.then((_) {
+ // Clear the DOM to work around a bug in test.dart.
+ document.body.nodes.clear();
+ }));
+
+ void iterateTests(Iterator<TestCase> iterator) {
+ if (iterator.moveNext()) {
+ TestCase test = iterator.current;
+ print('${test.description}\nSetup.');
+ test.setup();
+ new Future(() {
+ test.validate();
+ print('${test.description}\nDone.');
+ iterateTests(iterator);
+ });
+ } else {
+ completer.complete(null);
+ }
+ }
+
+ iterateTests(tests.iterator);
+}
« no previous file with comments | « dart/tests/try/source_update_test.dart ('k') | dart/tests/try/test_try.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698