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

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

Issue 1182303006: Re-enable and add new HTML support (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Move a private constant Created 5 years, 6 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
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 test.src.task.html_test; 5 library 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/html.dart';
9 import 'package:analyzer/task/model.dart'; 10 import 'package:analyzer/task/model.dart';
10 import 'package:unittest/unittest.dart'; 11 import 'package:unittest/unittest.dart';
11 12
12 import '../../reflective_tests.dart'; 13 import '../../reflective_tests.dart';
13 import '../context/abstract_context.dart'; 14 import '../context/abstract_context.dart';
14 15
15 main() { 16 main() {
16 groupSep = ' | '; 17 groupSep = ' | ';
18 runReflectiveTests(HtmlErrorsTaskTest);
17 runReflectiveTests(ParseHtmlTaskTest); 19 runReflectiveTests(ParseHtmlTaskTest);
20 runReflectiveTests(ReferencedLibrariesTaskTest);
21 }
22
23 @reflectiveTest
24 class HtmlErrorsTaskTest extends AbstractContextTest {
25 test_buildInputs() {
26 Source source = newSource('/test.html');
27 Map<String, TaskInput> inputs = HtmlErrorsTask.buildInputs(source);
28 expect(inputs, isNotNull);
29 expect(
30 inputs.keys, unorderedEquals([HtmlErrorsTask.DOCUMENT_ERRORS_INPUT]));
31 }
32
33 test_constructor() {
34 Source source = newSource('/test.html');
35 HtmlErrorsTask task = new HtmlErrorsTask(context, source);
36 expect(task, isNotNull);
37 expect(task.context, context);
38 expect(task.target, source);
39 }
40
41 test_createTask() {
42 Source source = newSource('/test.html');
43 HtmlErrorsTask task = HtmlErrorsTask.createTask(context, source);
44 expect(task, isNotNull);
45 expect(task.context, context);
46 expect(task.target, source);
47 }
48
49 test_description() {
50 Source source = newSource('/test.html');
51 HtmlErrorsTask task = new HtmlErrorsTask(null, source);
52 expect(task.description, isNotNull);
53 }
54
55 test_descriptor() {
56 TaskDescriptor descriptor = HtmlErrorsTask.DESCRIPTOR;
57 expect(descriptor, isNotNull);
58 }
59
60 test_perform() {
61 AnalysisTarget target = newSource('/test.html', r'''
62 <!DOCTYPE html>
63 <html>
64 <head>
65 <title>test page</title>
66 </head>
67 <body>
68 Test
69 </body>
70 </html>
71 ''');
72 computeResult(target, HTML_ERRORS);
73 expect(task, new isInstanceOf<HtmlErrorsTask>());
74 expect(outputs[HTML_ERRORS], isEmpty);
75 }
18 } 76 }
19 77
20 @reflectiveTest 78 @reflectiveTest
21 class ParseHtmlTaskTest extends AbstractContextTest { 79 class ParseHtmlTaskTest extends AbstractContextTest {
22 fail_perform() {
23 fail('Could not parse the HTML');
24 // AnalysisTarget target = newSource('/test.html', r'''
25 //<html>
26 // <head>
27 // <title 'test page'/>
28 // </head>
29 // <body>
30 // Test
31 // </body>
32 //</html>
33 //''');
34 // computeResult(target, DOCUMENT);
35 // expect(task, new isInstanceOf<ParseHtmlTask>());
36 // expect(outputs[DOCUMENT], isNotNull);
37 // expect(outputs[DOCUMENT_ERRORS], isNotEmpty);
38 }
39
40 test_buildInputs() { 80 test_buildInputs() {
41 Source source = newSource('/test.html'); 81 Source source = newSource('/test.html');
42 Map<String, TaskInput> inputs = ParseHtmlTask.buildInputs(source); 82 Map<String, TaskInput> inputs = ParseHtmlTask.buildInputs(source);
43 expect(inputs, isNotNull); 83 expect(inputs, isNotNull);
44 expect(inputs.keys, unorderedEquals([ParseHtmlTask.CONTENT_INPUT_NAME])); 84 expect(inputs.keys, unorderedEquals([ParseHtmlTask.CONTENT_INPUT_NAME]));
45 } 85 }
46 86
47 test_constructor() { 87 test_constructor() {
48 Source source = newSource('/test.html'); 88 Source source = newSource('/test.html');
49 ParseHtmlTask task = new ParseHtmlTask(context, source); 89 ParseHtmlTask task = new ParseHtmlTask(context, source);
(...skipping 13 matching lines...) Expand all
63 test_description() { 103 test_description() {
64 Source source = newSource('/test.html'); 104 Source source = newSource('/test.html');
65 ParseHtmlTask task = new ParseHtmlTask(null, source); 105 ParseHtmlTask task = new ParseHtmlTask(null, source);
66 expect(task.description, isNotNull); 106 expect(task.description, isNotNull);
67 } 107 }
68 108
69 test_descriptor() { 109 test_descriptor() {
70 TaskDescriptor descriptor = ParseHtmlTask.DESCRIPTOR; 110 TaskDescriptor descriptor = ParseHtmlTask.DESCRIPTOR;
71 expect(descriptor, isNotNull); 111 expect(descriptor, isNotNull);
72 } 112 }
113
114 test_perform() {
115 AnalysisTarget target = newSource('/test.html', r'''
116 <!DOCTYPE html>
117 <html>
118 <head>
119 <title>test page</title>
120 </head>
121 <body>
122 <h1 Test>
123 </body>
124 </html>
125 ''');
126 computeResult(target, DOCUMENT);
127 expect(task, new isInstanceOf<ParseHtmlTask>());
128 expect(outputs[DOCUMENT], isNotNull);
129 expect(outputs[DOCUMENT_ERRORS], isNotEmpty);
130 }
73 } 131 }
132
133 @reflectiveTest
134 class ReferencedLibrariesTaskTest extends AbstractContextTest {
135 test_buildInputs() {
136 Source source = newSource('/test.html');
137 Map<String, TaskInput> inputs = ReferencedLibrariesTask.buildInputs(source);
138 expect(inputs, isNotNull);
139 expect(
140 inputs.keys, unorderedEquals([ReferencedLibrariesTask.DOCUMENT_INPUT]));
141 }
142
143 test_constructor() {
144 Source source = newSource('/test.html');
145 ReferencedLibrariesTask task = new ReferencedLibrariesTask(context, source);
146 expect(task, isNotNull);
147 expect(task.context, context);
148 expect(task.target, source);
149 }
150
151 test_createTask() {
152 Source source = newSource('/test.html');
153 ReferencedLibrariesTask task =
154 ReferencedLibrariesTask.createTask(context, source);
155 expect(task, isNotNull);
156 expect(task.context, context);
157 expect(task.target, source);
158 }
159
160 test_description() {
161 Source source = newSource('/test.html');
162 ReferencedLibrariesTask task = new ReferencedLibrariesTask(null, source);
163 expect(task.description, isNotNull);
164 }
165
166 test_descriptor() {
167 TaskDescriptor descriptor = ReferencedLibrariesTask.DESCRIPTOR;
168 expect(descriptor, isNotNull);
169 }
170
171 void test_perform_embedded_source() {
172 AnalysisTarget target = newSource('/test.html', r'''
173 <!DOCTYPE html>
174 <html>
175 <head>
176 <script type='application/dart'>
177 void buttonPressed() {}
178 </script>
179 </head>
180 <body>
181 </body>
182 </html>''');
183 computeResult(target, REFERENCED_LIBRARIES);
184 expect(task, new isInstanceOf<ReferencedLibrariesTask>());
185 expect(outputs[REFERENCED_LIBRARIES], hasLength(0));
186 }
187
188 void test_perform_empty_source_reference() {
189 AnalysisTarget target = newSource('/test.html', r'''
190 <!DOCTYPE html>
191 <html>
192 <head>
193 <script type='application/dart' src=''/>
194 </head>
195 <body>
196 </body>
197 </html>''');
198 computeResult(target, REFERENCED_LIBRARIES);
199 expect(task, new isInstanceOf<ReferencedLibrariesTask>());
200 expect(outputs[REFERENCED_LIBRARIES], hasLength(0));
201 }
202
203 void test_perform_invalid_source_reference() {
204 AnalysisTarget target = newSource('/test.html', r'''
205 <!DOCTYPE html>
206 <html>
207 <head>
208 <script type='application/dart' src='an;invalid:[]uri'/>
209 </head>
210 <body>
211 </body>
212 </html>''');
213 computeResult(target, REFERENCED_LIBRARIES);
214 expect(task, new isInstanceOf<ReferencedLibrariesTask>());
215 expect(outputs[REFERENCED_LIBRARIES], hasLength(0));
216 }
217
218 void test_perform_non_existing_source_reference() {
219 AnalysisTarget target = newSource('/test.html', r'''
220 <!DOCTYPE html>
221 <html>
222 <head>
223 <script type='application/dart' src='does/not/exist.dart'/>
224 </head>
225 <body>
226 </body>
227 </html>''');
228 computeResult(target, REFERENCED_LIBRARIES);
229 expect(task, new isInstanceOf<ReferencedLibrariesTask>());
230 expect(outputs[REFERENCED_LIBRARIES], hasLength(1));
231 }
232
233 test_perform_none() {
234 AnalysisTarget target = newSource('/test.html', r'''
235 <!DOCTYPE html>
236 <html>
237 <head>
238 <title>test page</title>
239 </head>
240 <body>
241 Test
242 </body>
243 </html>
244 ''');
245 computeResult(target, REFERENCED_LIBRARIES);
246 expect(task, new isInstanceOf<ReferencedLibrariesTask>());
247 expect(outputs[REFERENCED_LIBRARIES], isEmpty);
248 }
249
250 void test_perform_referenced_source() {
251 AnalysisTarget target = newSource('/test.html', r'''
252 <!DOCTYPE html>
253 <html>
254 <head>
255 <script type='application/dart' src='test.dart'/>
256 </head>
257 <body>
258 </body>
259 </html>''');
260 computeResult(target, REFERENCED_LIBRARIES);
261 expect(task, new isInstanceOf<ReferencedLibrariesTask>());
262 expect(outputs[REFERENCED_LIBRARIES], hasLength(1));
263 }
264 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698