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

Side by Side Diff: pkg/analyzer/test/src/task/html_test.dart

Issue 2975253002: Format analyzer, analysis_server, analyzer_plugin, front_end and kernel with the latest dartfmt. (Closed)
Patch Set: Created 3 years, 5 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
« no previous file with comments | « pkg/analyzer/test/src/task/dart_test.dart ('k') | pkg/analyzer/test/src/task/options_test.dart » ('j') | 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 library analyzer.test.src.task.html_test; 5 library analyzer.test.src.task.html_test;
6 6
7 import 'package:analyzer/src/generated/source.dart'; 7 import 'package:analyzer/src/generated/source.dart';
8 import 'package:analyzer/src/task/html.dart'; 8 import 'package:analyzer/src/task/html.dart';
9 import 'package:analyzer/task/general.dart'; 9 import 'package:analyzer/task/general.dart';
10 import 'package:analyzer/task/html.dart'; 10 import 'package:analyzer/task/html.dart';
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 test_descriptor() { 61 test_descriptor() {
62 TaskDescriptor descriptor = DartScriptsTask.DESCRIPTOR; 62 TaskDescriptor descriptor = DartScriptsTask.DESCRIPTOR;
63 expect(descriptor, isNotNull); 63 expect(descriptor, isNotNull);
64 } 64 }
65 65
66 void test_perform_embedded_source() { 66 void test_perform_embedded_source() {
67 String content = r''' 67 String content = r'''
68 void buttonPressed() {} 68 void buttonPressed() {}
69 '''; 69 ''';
70 AnalysisTarget target = newSource( 70 AnalysisTarget target = newSource('/test.html', '''
71 '/test.html',
72 '''
73 <!DOCTYPE html> 71 <!DOCTYPE html>
74 <html> 72 <html>
75 <head> 73 <head>
76 <script type='application/dart'>$content</script> 74 <script type='application/dart'>$content</script>
77 </head> 75 </head>
78 <body> 76 <body>
79 </body> 77 </body>
80 </html>'''); 78 </html>''');
81 computeResult(target, REFERENCED_LIBRARIES, matcher: isDartScriptsTask); 79 computeResult(target, REFERENCED_LIBRARIES, matcher: isDartScriptsTask);
82 expect(outputs[REFERENCED_LIBRARIES], hasLength(0)); 80 expect(outputs[REFERENCED_LIBRARIES], hasLength(0));
83 expect(outputs[DART_SCRIPTS], hasLength(1)); 81 expect(outputs[DART_SCRIPTS], hasLength(1));
84 DartScript script = outputs[DART_SCRIPTS][0]; 82 DartScript script = outputs[DART_SCRIPTS][0];
85 expect(script.fragments, hasLength(1)); 83 expect(script.fragments, hasLength(1));
86 ScriptFragment fragment = script.fragments[0]; 84 ScriptFragment fragment = script.fragments[0];
87 expect(fragment.content, content); 85 expect(fragment.content, content);
88 } 86 }
89 87
90 void test_perform_empty_source_reference() { 88 void test_perform_empty_source_reference() {
91 AnalysisTarget target = newSource( 89 AnalysisTarget target = newSource('/test.html', r'''
92 '/test.html',
93 r'''
94 <!DOCTYPE html> 90 <!DOCTYPE html>
95 <html> 91 <html>
96 <head> 92 <head>
97 <script type='application/dart' src=''/> 93 <script type='application/dart' src=''/>
98 </head> 94 </head>
99 <body> 95 <body>
100 </body> 96 </body>
101 </html>'''); 97 </html>''');
102 computeResult(target, REFERENCED_LIBRARIES, matcher: isDartScriptsTask); 98 computeResult(target, REFERENCED_LIBRARIES, matcher: isDartScriptsTask);
103 expect(outputs[REFERENCED_LIBRARIES], hasLength(0)); 99 expect(outputs[REFERENCED_LIBRARIES], hasLength(0));
104 expect(outputs[DART_SCRIPTS], hasLength(0)); 100 expect(outputs[DART_SCRIPTS], hasLength(0));
105 } 101 }
106 102
107 void test_perform_invalid_source_reference() { 103 void test_perform_invalid_source_reference() {
108 AnalysisTarget target = newSource( 104 AnalysisTarget target = newSource('/test.html', r'''
109 '/test.html',
110 r'''
111 <!DOCTYPE html> 105 <!DOCTYPE html>
112 <html> 106 <html>
113 <head> 107 <head>
114 <script type='application/dart' src='an;invalid:[]uri'/> 108 <script type='application/dart' src='an;invalid:[]uri'/>
115 </head> 109 </head>
116 <body> 110 <body>
117 </body> 111 </body>
118 </html>'''); 112 </html>''');
119 computeResult(target, REFERENCED_LIBRARIES, matcher: isDartScriptsTask); 113 computeResult(target, REFERENCED_LIBRARIES, matcher: isDartScriptsTask);
120 expect(outputs[REFERENCED_LIBRARIES], hasLength(0)); 114 expect(outputs[REFERENCED_LIBRARIES], hasLength(0));
121 expect(outputs[DART_SCRIPTS], hasLength(0)); 115 expect(outputs[DART_SCRIPTS], hasLength(0));
122 } 116 }
123 117
124 void test_perform_non_existing_source_reference() { 118 void test_perform_non_existing_source_reference() {
125 AnalysisTarget target = newSource( 119 AnalysisTarget target = newSource('/test.html', r'''
126 '/test.html',
127 r'''
128 <!DOCTYPE html> 120 <!DOCTYPE html>
129 <html> 121 <html>
130 <head> 122 <head>
131 <script type='application/dart' src='does/not/exist.dart'/> 123 <script type='application/dart' src='does/not/exist.dart'/>
132 </head> 124 </head>
133 <body> 125 <body>
134 </body> 126 </body>
135 </html>'''); 127 </html>''');
136 computeResult(target, REFERENCED_LIBRARIES, matcher: isDartScriptsTask); 128 computeResult(target, REFERENCED_LIBRARIES, matcher: isDartScriptsTask);
137 expect(outputs[REFERENCED_LIBRARIES], hasLength(1)); 129 expect(outputs[REFERENCED_LIBRARIES], hasLength(1));
138 expect(outputs[DART_SCRIPTS], hasLength(0)); 130 expect(outputs[DART_SCRIPTS], hasLength(0));
139 } 131 }
140 132
141 test_perform_none() { 133 test_perform_none() {
142 AnalysisTarget target = newSource( 134 AnalysisTarget target = newSource('/test.html', r'''
143 '/test.html',
144 r'''
145 <!DOCTYPE html> 135 <!DOCTYPE html>
146 <html> 136 <html>
147 <head> 137 <head>
148 <title>test page</title> 138 <title>test page</title>
149 </head> 139 </head>
150 <body> 140 <body>
151 Test 141 Test
152 </body> 142 </body>
153 </html> 143 </html>
154 '''); 144 ''');
155 computeResult(target, REFERENCED_LIBRARIES, matcher: isDartScriptsTask); 145 computeResult(target, REFERENCED_LIBRARIES, matcher: isDartScriptsTask);
156 expect(outputs[REFERENCED_LIBRARIES], hasLength(0)); 146 expect(outputs[REFERENCED_LIBRARIES], hasLength(0));
157 expect(outputs[DART_SCRIPTS], hasLength(0)); 147 expect(outputs[DART_SCRIPTS], hasLength(0));
158 } 148 }
159 149
160 void test_perform_referenced_source() { 150 void test_perform_referenced_source() {
161 AnalysisTarget target = newSource( 151 AnalysisTarget target = newSource('/test.html', r'''
162 '/test.html',
163 r'''
164 <!DOCTYPE html> 152 <!DOCTYPE html>
165 <html> 153 <html>
166 <head> 154 <head>
167 <script type='application/dart' src='test.dart'/> 155 <script type='application/dart' src='test.dart'/>
168 </head> 156 </head>
169 <body> 157 <body>
170 </body> 158 </body>
171 </html>'''); 159 </html>''');
172 computeResult(target, REFERENCED_LIBRARIES, matcher: isDartScriptsTask); 160 computeResult(target, REFERENCED_LIBRARIES, matcher: isDartScriptsTask);
173 expect(outputs[REFERENCED_LIBRARIES], hasLength(1)); 161 expect(outputs[REFERENCED_LIBRARIES], hasLength(1));
174 expect(outputs[DART_SCRIPTS], hasLength(0)); 162 expect(outputs[DART_SCRIPTS], hasLength(0));
175 } 163 }
176 } 164 }
177 165
178 @reflectiveTest 166 @reflectiveTest
179 class HtmlErrorsTaskTest extends AbstractContextTest { 167 class HtmlErrorsTaskTest extends AbstractContextTest {
180 fail_perform_htmlErrors() { 168 fail_perform_htmlErrors() {
181 AnalysisTarget target = newSource( 169 AnalysisTarget target = newSource('/test.html', r'''
182 '/test.html',
183 r'''
184 <html> 170 <html>
185 <head> 171 <head>
186 <title>test page</not-title> 172 <title>test page</not-title>
187 </head> 173 </head>
188 <body> 174 <body>
189 Test 175 Test
190 </body> 176 </body>
191 </html> 177 </html>
192 '''); 178 ''');
193 computeResult(target, HTML_ERRORS, matcher: isHtmlErrorsTask); 179 computeResult(target, HTML_ERRORS, matcher: isHtmlErrorsTask);
(...skipping 21 matching lines...) Expand all
215 HtmlErrorsTask task = new HtmlErrorsTask(null, source); 201 HtmlErrorsTask task = new HtmlErrorsTask(null, source);
216 expect(task.description, isNotNull); 202 expect(task.description, isNotNull);
217 } 203 }
218 204
219 test_descriptor() { 205 test_descriptor() {
220 TaskDescriptor descriptor = HtmlErrorsTask.DESCRIPTOR; 206 TaskDescriptor descriptor = HtmlErrorsTask.DESCRIPTOR;
221 expect(descriptor, isNotNull); 207 expect(descriptor, isNotNull);
222 } 208 }
223 209
224 test_perform_dartErrors() { 210 test_perform_dartErrors() {
225 AnalysisTarget target = newSource( 211 AnalysisTarget target = newSource('/test.html', r'''
226 '/test.html',
227 r'''
228 <!DOCTYPE html> 212 <!DOCTYPE html>
229 <html> 213 <html>
230 <head> 214 <head>
231 <title>test page</title> 215 <title>test page</title>
232 <script type='application/dart'> 216 <script type='application/dart'>
233 void buttonPressed() { 217 void buttonPressed() {
234 </script> 218 </script>
235 </head> 219 </head>
236 <body>Test</body> 220 <body>Test</body>
237 </html> 221 </html>
238 '''); 222 ''');
239 computeResult(target, HTML_ERRORS, matcher: isHtmlErrorsTask); 223 computeResult(target, HTML_ERRORS, matcher: isHtmlErrorsTask);
240 expect(outputs[HTML_ERRORS], hasLength(1)); 224 expect(outputs[HTML_ERRORS], hasLength(1));
241 } 225 }
242 226
243 test_perform_noErrors() { 227 test_perform_noErrors() {
244 AnalysisTarget target = newSource( 228 AnalysisTarget target = newSource('/test.html', r'''
245 '/test.html',
246 r'''
247 <!DOCTYPE html> 229 <!DOCTYPE html>
248 <html> 230 <html>
249 <head> 231 <head>
250 <title>test page</title> 232 <title>test page</title>
251 </head> 233 </head>
252 <body> 234 <body>
253 Test 235 Test
254 </body> 236 </body>
255 </html> 237 </html>
256 '''); 238 ''');
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 expect(bodyElement.localName, 'body'); 353 expect(bodyElement.localName, 'body');
372 // actual nodes 354 // actual nodes
373 expect(bodyElement.nodes, hasLength(4)); 355 expect(bodyElement.nodes, hasLength(4));
374 expect((bodyElement.nodes[0] as Element).localName, 'div'); 356 expect((bodyElement.nodes[0] as Element).localName, 'div');
375 expect((bodyElement.nodes[2] as Element).localName, 'span'); 357 expect((bodyElement.nodes[2] as Element).localName, 'span');
376 } 358 }
377 // it's OK to don't have DOCTYPE 359 // it's OK to don't have DOCTYPE
378 expect(outputs[HTML_DOCUMENT_ERRORS], isEmpty); 360 expect(outputs[HTML_DOCUMENT_ERRORS], isEmpty);
379 } 361 }
380 } 362 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/task/dart_test.dart ('k') | pkg/analyzer/test/src/task/options_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698