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

Side by Side Diff: tests/try/web/test_case.dart

Issue 2232273004: Delete site/try (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
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.
4
5 library trydart.test_case;
6
7 import 'dart:html' show
8 document;
9
10 import 'dart:async';
11
12 import 'package:async_helper/async_helper.dart';
13
14 typedef void VoidFunction();
15
16 class TestCase {
17 final String description;
18 final VoidFunction setup;
19 final VoidFunction validate;
20
21 TestCase(this.description, this.setup, this.validate);
22 }
23
24 /**
25 * Executes [tests] each test in order using the following approach for each
26 * test:
27 *
28 * 1. Run setup synchronously.
29 *
30 * 2. Schedule a new (async) Future which runs validate followed by the next
31 * test's setup.
32 *
33 * 3. Repeat step 2 until there are no more tests.
34 *
35 * The purpose of this test is to simulate edits (during setup), and then let
36 * the mutation observer to process the mutations followed by validation.
37 */
38 void runTests(List<TestCase> tests) {
39 Completer completer = new Completer();
40 asyncTest(() => completer.future.then((_) {
41 // Clear the DOM to work around a bug in test.dart.
42 document.body.nodes.clear();
43 }));
44
45 void iterateTests(Iterator<TestCase> iterator) {
46 if (iterator.moveNext()) {
47 TestCase test = iterator.current;
48 print('${test.description}\nSetup.');
49 test.setup();
50 new Future(() {
51 test.validate();
52 print('${test.description}\nDone.');
53 iterateTests(iterator);
54 });
55 } else {
56 completer.complete(null);
57 }
58 }
59
60 iterateTests(tests.iterator);
61 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698