| 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.domain.analysis; | 5 library test.domain.analysis; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/computer/computer_highlights.dart'; | 9 import 'package:analysis_server/src/computer/computer_highlights.dart'; |
| 10 import 'package:analysis_server/src/analysis_server.dart'; | 10 import 'package:analysis_server/src/analysis_server.dart'; |
| 11 import 'package:analysis_server/src/constants.dart'; | 11 import 'package:analysis_server/src/constants.dart'; |
| 12 import 'package:analysis_server/src/domain_analysis.dart'; | 12 import 'package:analysis_server/src/domain_analysis.dart'; |
| 13 import 'package:analysis_server/src/protocol.dart'; | 13 import 'package:analysis_server/src/protocol.dart'; |
| 14 import 'package:analysis_server/src/resource.dart'; | 14 import 'package:analysis_server/src/resource.dart'; |
| 15 import 'package:unittest/unittest.dart'; | 15 import 'package:unittest/unittest.dart'; |
| 16 | 16 |
| 17 import 'mocks.dart'; | 17 import 'mocks.dart'; |
| 18 import 'analysis_abstract.dart'; |
| 19 import 'reflective_tests.dart'; |
| 18 | 20 |
| 19 | 21 |
| 20 main() { | 22 main() { |
| 21 groupSep = ' | '; | 23 groupSep = ' | '; |
| 22 | 24 |
| 25 runReflectiveTests(AnalysisDomainTest); |
| 26 |
| 23 MockServerChannel serverChannel; | 27 MockServerChannel serverChannel; |
| 24 AnalysisServer server; | 28 AnalysisServer server; |
| 25 AnalysisDomainHandler handler; | 29 AnalysisDomainHandler handler; |
| 26 MemoryResourceProvider resourceProvider = new MemoryResourceProvider(); | 30 MemoryResourceProvider resourceProvider = new MemoryResourceProvider(); |
| 27 | 31 |
| 28 setUp(() { | 32 setUp(() { |
| 29 serverChannel = new MockServerChannel(); | 33 serverChannel = new MockServerChannel(); |
| 30 server = new AnalysisServer(serverChannel, resourceProvider); | 34 server = new AnalysisServer(serverChannel, resourceProvider); |
| 31 server.defaultSdk = new MockSdk(); | 35 server.defaultSdk = new MockSdk(); |
| 32 handler = new AnalysisDomainHandler(server); | 36 handler = new AnalysisDomainHandler(server); |
| (...skipping 1626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1659 // subscribe | 1663 // subscribe |
| 1660 helper.addAnalysisSubscriptionHighlights(helper.testFile); | 1664 helper.addAnalysisSubscriptionHighlights(helper.testFile); |
| 1661 // wait, has regions | 1665 // wait, has regions |
| 1662 return helper.waitForOperationsFinished().then((_) { | 1666 return helper.waitForOperationsFinished().then((_) { |
| 1663 var highlights = helper.getHighlights(helper.testFile); | 1667 var highlights = helper.getHighlights(helper.testFile); |
| 1664 expect(highlights, isNot(isEmpty)); | 1668 expect(highlights, isNot(isEmpty)); |
| 1665 }); | 1669 }); |
| 1666 }); | 1670 }); |
| 1667 }); | 1671 }); |
| 1668 } | 1672 } |
| 1673 |
| 1674 |
| 1675 @ReflectiveTestCase() |
| 1676 class AnalysisDomainTest extends AbstractAnalysisTest { |
| 1677 Map<String, List<AnalysisError>> filesErrors = {}; |
| 1678 |
| 1679 void processNotification(Notification notification) { |
| 1680 if (notification.event == ANALYSIS_ERRORS) { |
| 1681 String file = notification.getParameter(FILE); |
| 1682 List<Map<String, Object>> errorMaps = notification.getParameter(ERRORS); |
| 1683 filesErrors[file] = errorMaps.map(jsonToAnalysisError).toList(); |
| 1684 } |
| 1685 } |
| 1686 |
| 1687 test_setRoots_packages() { |
| 1688 // prepare project with 'packages' folder |
| 1689 String pkgFile = '/project/packages/pkgA/libA.dart'; |
| 1690 resourceProvider.newFile(pkgFile, ''' |
| 1691 library lib_a; |
| 1692 class A {} |
| 1693 '''); |
| 1694 addTestFile(''' |
| 1695 import 'package:pkgA/libA.dart'; |
| 1696 main(A a) { |
| 1697 } |
| 1698 '''); |
| 1699 // create project and wait for analysis |
| 1700 createProject(); |
| 1701 return waitForTasksFinished().then((_) { |
| 1702 // if 'package:pkgA/libA.dart' was resolved, then there are no errors |
| 1703 expect(filesErrors[testFile], isEmpty); |
| 1704 // packages file also was resolved |
| 1705 expect(filesErrors[pkgFile], isEmpty); |
| 1706 }); |
| 1707 } |
| 1708 } |
| OLD | NEW |