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

Side by Side Diff: dart/tests/try/paste_content_rewriting_test.dart

Issue 258673002: Easier-to-read expectations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 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 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 // SharedOptions=--package-root=sdk/lib/_internal/ 5 // SharedOptions=--package-root=sdk/lib/_internal/
6 6
7 library trydart.paste_test; 7 library trydart.paste_test;
8 8
9 import 'dart:html'; 9 import 'dart:html';
10 import 'dart:async'; 10 import 'dart:async';
11 11
12 import '../../site/try/src/interaction_manager.dart' show 12 import '../../site/try/src/interaction_manager.dart' show
13 InteractionManager; 13 InteractionManager;
14 14
15 import '../../site/try/src/ui.dart' show 15 import '../../site/try/src/ui.dart' show
16 mainEditorPane, 16 mainEditorPane,
17 observer; 17 observer;
18 18
19 import '../../site/try/src/user_option.dart' show 19 import '../../site/try/src/user_option.dart' show
20 UserOption; 20 UserOption;
21 21
22 import '../../pkg/expect/lib/expect.dart'; 22 import '../../pkg/expect/lib/expect.dart';
23 import '../../pkg/async_helper/lib/async_helper.dart'; 23 import '../../pkg/async_helper/lib/async_helper.dart';
24 24
25 const Map<String, String> tests = const <String, String> { 25 const Map<String, String> tests = const <String, String> {
26 '<span><p>//...</p>}</span>': '//...\n}\n', 26 '<span><p>//...</p>}</span>': '//...\n}\n',
27 'someText': 'someText\n', 27 'someText': 'someText\n',
28 '"\$"': '"\$<DIAGNOSTIC>"\n', 28 '"\$"': '"<DIAGNOSTIC>\$</DIAGNOSTIC>"\n',
29 '"\$\$"': '"\$<DIAGNOSTIC>\$<DIAGNOSTIC>"\n', 29 '"\$\$"': '"<DIAGNOSTIC>\$</DIAGNOSTIC><DIAGNOSTIC>\$</DIAGNOSTIC>"\n',
30 '"\$\$4"': '"\$<DIAGNOSTIC>\$<DIAGNOSTIC>4"\n', 30 '"\$\$4"': '"<DIAGNOSTIC>\$</DIAGNOSTIC><DIAGNOSTIC>\$</DIAGNOSTIC>4"\n',
31 '"\$\$4 "': '"\$<DIAGNOSTIC>\$<DIAGNOSTIC>4 "\n', 31 '"\$\$4 "': '"<DIAGNOSTIC>\$</DIAGNOSTIC><DIAGNOSTIC>\$</DIAGNOSTIC>4 "\n',
32 '1e': '1e<DIAGNOSTIC>\n', 32 '1e': '<DIAGNOSTIC>1e</DIAGNOSTIC>\n',
33 }; 33 };
34 34
35 List<Node> queryDiagnosticNodes() { 35 List<Node> queryDiagnosticNodes() {
36 return mainEditorPane.querySelectorAll('a.diagnostic>span'); 36 return mainEditorPane.querySelectorAll('a.diagnostic>span');
37 } 37 }
38 38
39 Future runTests() { 39 Future runTests() {
40 Iterator<String> keys = tests.keys.iterator; 40 Iterator<String> keys = tests.keys.iterator;
41 keys.moveNext(); 41 keys.moveNext();
42 mainEditorPane.innerHtml = keys.current; 42 mainEditorPane.innerHtml = keys.current;
43 43
44 Future makeFuture() => new Future(() { 44 Future makeFuture() => new Future(() {
45 String key = keys.current; 45 String key = keys.current;
46 print('Checking $key'); 46 print('Checking $key');
47 queryDiagnosticNodes().forEach((Node node) { 47 queryDiagnosticNodes().forEach((Node node) {
48 node.replaceWith(new Text('<DIAGNOSTIC>')); 48 node.parent.insertBefore(
49 new Text('<DIAGNOSTIC>'), node.parent.firstChild);
50 node.replaceWith(new Text('</DIAGNOSTIC>'));
49 observer.takeRecords(); // Discard mutations. 51 observer.takeRecords(); // Discard mutations.
50 }); 52 });
51 Expect.stringEquals(tests[key], mainEditorPane.text); 53 Expect.stringEquals(tests[key], mainEditorPane.text);
52 if (keys.moveNext()) { 54 if (keys.moveNext()) {
53 key = keys.current; 55 key = keys.current;
54 print('Setting $key'); 56 print('Setting $key');
55 mainEditorPane.innerHtml = key; 57 mainEditorPane.innerHtml = key;
56 return makeFuture(); 58 return makeFuture();
57 } else { 59 } else {
58 // Clear the DOM to work around a bug in test.dart. 60 // Clear the DOM to work around a bug in test.dart.
(...skipping 12 matching lines...) Expand all
71 mainEditorPane = new DivElement(); 73 mainEditorPane = new DivElement();
72 document.body.append(mainEditorPane); 74 document.body.append(mainEditorPane);
73 observer = new MutationObserver(interaction.onMutation) 75 observer = new MutationObserver(interaction.onMutation)
74 ..observe( 76 ..observe(
75 mainEditorPane, childList: true, characterData: true, subtree: true); 77 mainEditorPane, childList: true, characterData: true, subtree: true);
76 78
77 mainEditorPane.innerHtml = "<span><p>//...</p>}</span>"; 79 mainEditorPane.innerHtml = "<span><p>//...</p>}</span>";
78 80
79 asyncTest(runTests); 81 asyncTest(runTests);
80 } 82 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698