| OLD | NEW |
| 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 library test.src.context.context_test; | 5 library test.src.context.context_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analyzer/src/cancelable_future.dart'; | 9 import 'package:analyzer/src/cancelable_future.dart'; |
| 10 import 'package:analyzer/src/context/cache.dart'; | 10 import 'package:analyzer/src/context/cache.dart'; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 import 'package:analyzer/task/dart.dart'; | 38 import 'package:analyzer/task/dart.dart'; |
| 39 import 'package:analyzer/task/model.dart'; | 39 import 'package:analyzer/task/model.dart'; |
| 40 import 'package:html/dom.dart' show Document; | 40 import 'package:html/dom.dart' show Document; |
| 41 import 'package:unittest/unittest.dart'; | 41 import 'package:unittest/unittest.dart'; |
| 42 import 'package:watcher/src/utils.dart'; | 42 import 'package:watcher/src/utils.dart'; |
| 43 | 43 |
| 44 import '../../generated/engine_test.dart'; | 44 import '../../generated/engine_test.dart'; |
| 45 import '../../generated/test_support.dart'; | 45 import '../../generated/test_support.dart'; |
| 46 import '../../reflective_tests.dart'; | 46 import '../../reflective_tests.dart'; |
| 47 import 'abstract_context.dart'; | 47 import 'abstract_context.dart'; |
| 48 import 'package:analyzer/src/task/html.dart'; |
| 48 | 49 |
| 49 main() { | 50 main() { |
| 50 groupSep = ' | '; | 51 groupSep = ' | '; |
| 51 runReflectiveTests(AnalysisContextImplTest); | 52 runReflectiveTests(AnalysisContextImplTest); |
| 52 runReflectiveTests(LimitedInvalidateTest); | 53 runReflectiveTests(LimitedInvalidateTest); |
| 53 } | 54 } |
| 54 | 55 |
| 55 @reflectiveTest | 56 @reflectiveTest |
| 56 class AnalysisContextImplTest extends AbstractContextTest { | 57 class AnalysisContextImplTest extends AbstractContextTest { |
| 57 void fail_parseHtmlUnit_resolveDirectives() { | 58 void test_parseHtmlUnit_resolveDirectives() { |
| 58 Source libSource = addSource("/lib.dart", r''' | 59 Source libSource = addSource("/lib.dart", r''' |
| 59 library lib; | 60 library lib; |
| 60 class ClassA {}'''); | 61 class ClassA {}'''); |
| 61 Source source = addSource("/lib.html", r''' | 62 Source source = addSource("/lib.html", r''' |
| 62 <!DOCTYPE html> | 63 <!DOCTYPE html> |
| 63 <html> | 64 <html> |
| 64 <head> | 65 <head> |
| 65 <script type='application/dart'> | 66 <script type='application/dart'> |
| 66 import 'lib.dart'; | 67 import 'lib.dart'; |
| 67 ClassA v = null; | 68 ClassA v = null; |
| 68 </script> | 69 </script> |
| 69 </head> | 70 </head> |
| 70 <body> | 71 <body> |
| 71 </body> | 72 </body> |
| 72 </html>'''); | 73 </html>'''); |
| 73 // TODO(brianwilkerson) Rewrite this. We need a way to get the AST for the | 74 Document document = context.parseHtmlDocument(source); |
| 74 // script. | 75 expect(document, isNotNull); |
| 75 // Document document = context.parseHtmlDocument(source); | 76 List<DartScript> scripts = context.computeResult(source, DART_SCRIPTS); |
| 76 // expect(document, isNotNull); | 77 expect(scripts, hasLength(1)); |
| 77 // List<DartScript> scripts = context.computeResult(source, DART_SCRIPTS); | 78 CompilationUnit unit = context.computeResult(scripts[0], PARSED_UNIT); |
| 78 // expect(scripts, hasLength(1)); | 79 ImportDirective importNode = unit.directives[0] as ImportDirective; |
| 79 // CompilationUnit unit = context.computeResult(scripts[0], PARSED_AST); | |
| 80 // ImportDirective importNode = unit.directives[0] as ImportDirective; | |
| 81 // expect(importNode.uriContent, isNotNull); | |
| 82 // expect(importNode.source, libSource); | |
| 83 | |
| 84 ht.HtmlUnit unit = context.parseHtmlUnit(source); | |
| 85 expect(unit, isNotNull); | |
| 86 // import directive should be resolved | |
| 87 ht.XmlTagNode htmlNode = unit.tagNodes[0]; | |
| 88 ht.XmlTagNode headNode = htmlNode.tagNodes[0]; | |
| 89 ht.HtmlScriptTagNode scriptNode = headNode.tagNodes[0]; | |
| 90 CompilationUnit script = scriptNode.script; | |
| 91 ImportDirective importNode = script.directives[0] as ImportDirective; | |
| 92 expect(importNode.uriContent, isNotNull); | 80 expect(importNode.uriContent, isNotNull); |
| 93 expect(importNode.source, libSource); | 81 expect(importNode.source, libSource); |
| 94 } | 82 } |
| 95 | 83 |
| 96 void fail_performAnalysisTask_importedLibraryDelete_html() { | 84 void fail_performAnalysisTask_importedLibraryDelete_html() { |
| 97 // NOTE: This was failing before converting to the new task model. | 85 // NOTE: This was failing before converting to the new task model. |
| 98 Source htmlSource = addSource("/page.html", r''' | 86 Source htmlSource = addSource("/page.html", r''' |
| 99 <html><body><script type="application/dart"> | 87 <html><body><script type="application/dart"> |
| 100 import 'libB.dart'; | 88 import 'libB.dart'; |
| 101 main() {print('hello dart');} | 89 main() {print('hello dart');} |
| (...skipping 2163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2265 } | 2253 } |
| 2266 } | 2254 } |
| 2267 | 2255 |
| 2268 class _AnalysisContextImplTest_test_applyChanges_removeContainer | 2256 class _AnalysisContextImplTest_test_applyChanges_removeContainer |
| 2269 implements SourceContainer { | 2257 implements SourceContainer { |
| 2270 Source libB; | 2258 Source libB; |
| 2271 _AnalysisContextImplTest_test_applyChanges_removeContainer(this.libB); | 2259 _AnalysisContextImplTest_test_applyChanges_removeContainer(this.libB); |
| 2272 @override | 2260 @override |
| 2273 bool contains(Source source) => source == libB; | 2261 bool contains(Source source) => source == libB; |
| 2274 } | 2262 } |
| OLD | NEW |