| 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.analysis.notification_errors; | 5 library test.analysis.notification_errors; |
| 6 | 6 |
| 7 import 'package:analysis_server/plugin/protocol/protocol.dart'; | 7 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
| 8 import 'package:analysis_server/src/constants.dart'; | 8 import 'package:analysis_server/src/constants.dart'; |
| 9 import 'package:analysis_server/src/domain_analysis.dart'; | 9 import 'package:analysis_server/src/domain_analysis.dart'; |
| 10 import 'package:analyzer/src/generated/engine.dart'; | 10 import 'package:analyzer/src/generated/engine.dart'; |
| 11 import 'package:analyzer/src/services/lint.dart'; | 11 import 'package:analyzer/src/services/lint.dart'; |
| 12 import 'package:linter/src/linter.dart'; | 12 import 'package:linter/src/linter.dart'; |
| 13 import 'package:test/test.dart'; |
| 13 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 14 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 14 import 'package:unittest/unittest.dart'; | |
| 15 | 15 |
| 16 import '../analysis_abstract.dart'; | 16 import '../analysis_abstract.dart'; |
| 17 import '../utils.dart'; | 17 import '../utils.dart'; |
| 18 | 18 |
| 19 main() { | 19 main() { |
| 20 initializeTestEnvironment(); | 20 initializeTestEnvironment(); |
| 21 defineReflectiveTests(NotificationErrorsTest); | 21 defineReflectiveSuite(() { |
| 22 defineReflectiveTests(NotificationErrorsTest); |
| 23 }); |
| 22 } | 24 } |
| 23 | 25 |
| 24 @reflectiveTest | 26 @reflectiveTest |
| 25 class NotificationErrorsTest extends AbstractAnalysisTest { | 27 class NotificationErrorsTest extends AbstractAnalysisTest { |
| 26 Map<String, List<AnalysisError>> filesErrors = {}; | 28 Map<String, List<AnalysisError>> filesErrors = {}; |
| 27 | 29 |
| 28 void processNotification(Notification notification) { | 30 void processNotification(Notification notification) { |
| 29 if (notification.event == ANALYSIS_ERRORS) { | 31 if (notification.event == ANALYSIS_ERRORS) { |
| 30 var decoded = new AnalysisErrorsParams.fromNotification(notification); | 32 var decoded = new AnalysisErrorsParams.fromNotification(notification); |
| 31 filesErrors[decoded.file] = decoded.errors; | 33 filesErrors[decoded.file] = decoded.errors; |
| 32 } | 34 } |
| 33 } | 35 } |
| 34 | 36 |
| 35 @override | 37 @override |
| 36 void setUp() { | 38 void setUp() { |
| 37 super.setUp(); | 39 super.setUp(); |
| 38 server.handlers = [new AnalysisDomainHandler(server),]; | 40 server.handlers = [ |
| 41 new AnalysisDomainHandler(server), |
| 42 ]; |
| 39 } | 43 } |
| 40 | 44 |
| 41 test_importError() async { | 45 test_importError() async { |
| 42 createProject(); | 46 createProject(); |
| 43 | 47 |
| 44 addTestFile(''' | 48 addTestFile(''' |
| 45 import 'does_not_exist.dart'; | 49 import 'does_not_exist.dart'; |
| 46 '''); | 50 '''); |
| 47 await waitForTasksFinished(); | 51 await waitForTasksFinished(); |
| 48 List<AnalysisError> errors = filesErrors[testFile]; | 52 List<AnalysisError> errors = filesErrors[testFile]; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 } | 130 } |
| 127 '''); | 131 '''); |
| 128 await waitForTasksFinished(); | 132 await waitForTasksFinished(); |
| 129 List<AnalysisError> errors = filesErrors[testFile]; | 133 List<AnalysisError> errors = filesErrors[testFile]; |
| 130 expect(errors, hasLength(1)); | 134 expect(errors, hasLength(1)); |
| 131 AnalysisError error = errors[0]; | 135 AnalysisError error = errors[0]; |
| 132 expect(error.severity, AnalysisErrorSeverity.WARNING); | 136 expect(error.severity, AnalysisErrorSeverity.WARNING); |
| 133 expect(error.type, AnalysisErrorType.STATIC_WARNING); | 137 expect(error.type, AnalysisErrorType.STATIC_WARNING); |
| 134 } | 138 } |
| 135 } | 139 } |
| OLD | NEW |