Chromium Code Reviews| Index: dart/tests/try/paste_content_rewriting_test.dart |
| diff --git a/dart/tests/try/paste_content_rewriting_test.dart b/dart/tests/try/paste_content_rewriting_test.dart |
| index 6d12d967ae7f9ccc9c4be657c6cf906d116fa3ee..232d272e2ec558f6b40ab155eed106949fa159d4 100644 |
| --- a/dart/tests/try/paste_content_rewriting_test.dart |
| +++ b/dart/tests/try/paste_content_rewriting_test.dart |
| @@ -22,27 +22,58 @@ import '../../site/try/src/user_option.dart' show |
| import '../../pkg/expect/lib/expect.dart'; |
| import '../../pkg/async_helper/lib/async_helper.dart'; |
| -main() { |
| +const Map<String, String> tests = const <String, String> { |
| + '<span><p>//...</p>}</span>': '//...\n}\n', |
| + 'someText': 'someText\n', |
| + '"\$"': '"\$"<DIAGNOSTIC>\n', |
| + '"\$\$"': '"\$\$<DIAGNOSTIC>"<DIAGNOSTIC>\n', |
| + '"\$\$4"': '"\$\$<DIAGNOSTIC>4<DIAGNOSTIC>"\n', |
| + '"\$\$4 "': '"\$\$<DIAGNOSTIC>4<DIAGNOSTIC> "\n', |
| +}; |
| + |
| +List<Node> queryDiagnosticNodes() { |
| + return mainEditorPane.querySelectorAll('a.diagnostic>span'); |
| +} |
| + |
| +Future runTests() { |
| + Iterator<String> keys = tests.keys.iterator; |
| + keys.moveNext(); |
| + mainEditorPane.innerHtml = keys.current; |
| + |
| + Future makeFuture() => new Future(() { |
| + String key = keys.current; |
| + print('Checking $key'); |
| + queryDiagnosticNodes().forEach((Node node) { |
| + node.replaceWith(new Text('<DIAGNOSTIC>')); |
| + observer.takeRecords(); // Discard mutations. |
| + }); |
| + Expect.stringEquals(tests[key], mainEditorPane.text); |
| + if (keys.moveNext()) { |
| + key = keys.current; |
| + print('Setting $key'); |
| + mainEditorPane.innerHtml = key; |
| + return makeFuture(); |
| + } else { |
| + // Clear the DOM to work around a bug in test.dart. |
| + document.body.nodes.clear(); |
| + return null; |
| + } |
| + }); |
| + |
| + return makeFuture(); |
| +} |
| + |
| +void main() { |
| UserOption.storage = {}; |
| var interaction = new InteractionManager(); |
| mainEditorPane = new DivElement(); |
| document.body.append(mainEditorPane); |
| observer = new MutationObserver(interaction.onMutation) |
| - ..observe(mainEditorPane, childList: true, characterData: true, subtree: true); |
| + ..observe( |
| + mainEditorPane, childList: true, characterData: true, subtree: true); |
|
ahe
2014/03/26 12:45:05
You missed this long line :-)
|
| mainEditorPane.innerHtml = "<span><p>//...</p>}</span>"; |
| - asyncTest(() => new Future(() { |
| - print('Welcome to the future'); |
| - Expect.stringEquals('//...\n}\n', mainEditorPane.text); |
| - }).then((_) { |
| - mainEditorPane.innerHtml = 'someText'; |
| - return new Future(() { |
| - Expect.stringEquals('someText\n', mainEditorPane.text); |
| - |
| - // Clear the DOM to work around a bug in test.dart. |
| - document.body.nodes.clear(); |
| - }); |
| - })); |
| + asyncTest(runTests); |
| } |