| OLD | NEW |
| 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/general.dart'; | 9 import 'package:analyzer/task/general.dart'; |
| 10 import 'package:analyzer/task/html.dart'; | 10 import 'package:analyzer/task/html.dart'; |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 </body> | 170 </body> |
| 171 </html>'''); | 171 </html>'''); |
| 172 computeResult(target, REFERENCED_LIBRARIES, matcher: isDartScriptsTask); | 172 computeResult(target, REFERENCED_LIBRARIES, matcher: isDartScriptsTask); |
| 173 expect(outputs[REFERENCED_LIBRARIES], hasLength(1)); | 173 expect(outputs[REFERENCED_LIBRARIES], hasLength(1)); |
| 174 expect(outputs[DART_SCRIPTS], hasLength(0)); | 174 expect(outputs[DART_SCRIPTS], hasLength(0)); |
| 175 } | 175 } |
| 176 } | 176 } |
| 177 | 177 |
| 178 @reflectiveTest | 178 @reflectiveTest |
| 179 class HtmlErrorsTaskTest extends AbstractContextTest { | 179 class HtmlErrorsTaskTest extends AbstractContextTest { |
| 180 fail_perform_htmlErrors() { |
| 181 AnalysisTarget target = newSource( |
| 182 '/test.html', |
| 183 r''' |
| 184 <html> |
| 185 <head> |
| 186 <title>test page</not-title> |
| 187 </head> |
| 188 <body> |
| 189 Test |
| 190 </body> |
| 191 </html> |
| 192 '''); |
| 193 computeResult(target, HTML_ERRORS, matcher: isHtmlErrorsTask); |
| 194 expect(outputs[HTML_ERRORS], hasLength(1)); |
| 195 } |
| 196 |
| 180 test_constructor() { | 197 test_constructor() { |
| 181 Source source = newSource('/test.html'); | 198 Source source = newSource('/test.html'); |
| 182 HtmlErrorsTask task = new HtmlErrorsTask(context, source); | 199 HtmlErrorsTask task = new HtmlErrorsTask(context, source); |
| 183 expect(task, isNotNull); | 200 expect(task, isNotNull); |
| 184 expect(task.context, context); | 201 expect(task.context, context); |
| 185 expect(task.target, source); | 202 expect(task.target, source); |
| 186 } | 203 } |
| 187 | 204 |
| 188 test_createTask() { | 205 test_createTask() { |
| 189 Source source = newSource('/test.html'); | 206 Source source = newSource('/test.html'); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 216 void buttonPressed() { | 233 void buttonPressed() { |
| 217 </script> | 234 </script> |
| 218 </head> | 235 </head> |
| 219 <body>Test</body> | 236 <body>Test</body> |
| 220 </html> | 237 </html> |
| 221 '''); | 238 '''); |
| 222 computeResult(target, HTML_ERRORS, matcher: isHtmlErrorsTask); | 239 computeResult(target, HTML_ERRORS, matcher: isHtmlErrorsTask); |
| 223 expect(outputs[HTML_ERRORS], hasLength(1)); | 240 expect(outputs[HTML_ERRORS], hasLength(1)); |
| 224 } | 241 } |
| 225 | 242 |
| 226 test_perform_htmlErrors() { | |
| 227 AnalysisTarget target = newSource( | |
| 228 '/test.html', | |
| 229 r''' | |
| 230 <html> | |
| 231 <head> | |
| 232 <title>test page</not-title> | |
| 233 </head> | |
| 234 <body> | |
| 235 Test | |
| 236 </body> | |
| 237 </html> | |
| 238 '''); | |
| 239 computeResult(target, HTML_ERRORS, matcher: isHtmlErrorsTask); | |
| 240 expect(outputs[HTML_ERRORS], hasLength(1)); | |
| 241 } | |
| 242 | |
| 243 test_perform_noErrors() { | 243 test_perform_noErrors() { |
| 244 AnalysisTarget target = newSource( | 244 AnalysisTarget target = newSource( |
| 245 '/test.html', | 245 '/test.html', |
| 246 r''' | 246 r''' |
| 247 <!DOCTYPE html> | 247 <!DOCTYPE html> |
| 248 <html> | 248 <html> |
| 249 <head> | 249 <head> |
| 250 <title>test page</title> | 250 <title>test page</title> |
| 251 </head> | 251 </head> |
| 252 <body> | 252 <body> |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 } | 296 } |
| 297 | 297 |
| 298 test_perform() { | 298 test_perform() { |
| 299 String code = r''' | 299 String code = r''' |
| 300 <!DOCTYPE html> | 300 <!DOCTYPE html> |
| 301 <html> | 301 <html> |
| 302 <head> | 302 <head> |
| 303 <title>test page</title> | 303 <title>test page</title> |
| 304 </head> | 304 </head> |
| 305 <body> | 305 <body> |
| 306 <h1 Test> | 306 <h1>Test</h1> |
| 307 </body> | 307 </body> |
| 308 </html> | 308 </html> |
| 309 '''; | 309 '''; |
| 310 AnalysisTarget target = newSource('/test.html', code); | 310 AnalysisTarget target = newSource('/test.html', code); |
| 311 computeResult(target, HTML_DOCUMENT); | 311 computeResult(target, HTML_DOCUMENT); |
| 312 expect(task, isParseHtmlTask); | 312 expect(task, isParseHtmlTask); |
| 313 expect(outputs[HTML_DOCUMENT], isNotNull); | 313 expect(outputs[HTML_DOCUMENT], isNotNull); |
| 314 expect(outputs[HTML_DOCUMENT_ERRORS], isNotEmpty); | 314 expect(outputs[HTML_DOCUMENT_ERRORS], isEmpty); |
| 315 // LINE_INFO | 315 // LINE_INFO |
| 316 { | 316 { |
| 317 LineInfo lineInfo = outputs[LINE_INFO]; | 317 LineInfo lineInfo = outputs[LINE_INFO]; |
| 318 expect(lineInfo, isNotNull); | 318 expect(lineInfo, isNotNull); |
| 319 { | 319 { |
| 320 int offset = code.indexOf('<!DOCTYPE'); | 320 int offset = code.indexOf('<!DOCTYPE'); |
| 321 LineInfo_Location location = lineInfo.getLocation(offset); | 321 LineInfo_Location location = lineInfo.getLocation(offset); |
| 322 expect(location.lineNumber, 1); | 322 expect(location.lineNumber, 1); |
| 323 expect(location.columnNumber, 1); | 323 expect(location.columnNumber, 1); |
| 324 } | 324 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 expect(bodyElement.localName, 'body'); | 359 expect(bodyElement.localName, 'body'); |
| 360 // actual nodes | 360 // actual nodes |
| 361 expect(bodyElement.nodes, hasLength(4)); | 361 expect(bodyElement.nodes, hasLength(4)); |
| 362 expect((bodyElement.nodes[0] as Element).localName, 'div'); | 362 expect((bodyElement.nodes[0] as Element).localName, 'div'); |
| 363 expect((bodyElement.nodes[2] as Element).localName, 'span'); | 363 expect((bodyElement.nodes[2] as Element).localName, 'span'); |
| 364 } | 364 } |
| 365 // it's OK to don't have DOCTYPE | 365 // it's OK to don't have DOCTYPE |
| 366 expect(outputs[HTML_DOCUMENT_ERRORS], isEmpty); | 366 expect(outputs[HTML_DOCUMENT_ERRORS], isEmpty); |
| 367 } | 367 } |
| 368 } | 368 } |
| OLD | NEW |