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

Side by Side Diff: pkg/analysis_server/test/analysis/notification_errors_test.dart

Issue 486003003: Start using code-generated protocol classes in analysis server. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
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/src/computer/error.dart';
8 import 'package:analysis_server/src/constants.dart'; 7 import 'package:analysis_server/src/constants.dart';
9 import 'package:analysis_server/src/domain_analysis.dart'; 8 import 'package:analysis_server/src/domain_analysis.dart';
10 import 'package:analysis_server/src/protocol.dart'; 9 import 'package:analysis_server/src/protocol.dart';
10 import 'package:analysis_server/src/protocol2.dart';
11 import 'package:analysis_testing/reflective_tests.dart'; 11 import 'package:analysis_testing/reflective_tests.dart';
12 import 'package:unittest/unittest.dart'; 12 import 'package:unittest/unittest.dart';
13 13
14 import '../analysis_abstract.dart'; 14 import '../analysis_abstract.dart';
15 15
16 16
17 main() { 17 main() {
18 groupSep = ' | '; 18 groupSep = ' | ';
19 runReflectiveTests(NotificationErrorsTest); 19 runReflectiveTests(NotificationErrorsTest);
20 } 20 }
21 21
22 22
23 @ReflectiveTestCase() 23 @ReflectiveTestCase()
24 class NotificationErrorsTest extends AbstractAnalysisTest { 24 class NotificationErrorsTest extends AbstractAnalysisTest {
25 Map<String, List<AnalysisError>> filesErrors = {}; 25 Map<String, List<AnalysisError>> filesErrors = {};
26 26
27 void processNotification(Notification notification) { 27 void processNotification(Notification notification) {
28 if (notification.event == ANALYSIS_ERRORS) { 28 if (notification.event == ANALYSIS_ERRORS) {
29 String file = notification.getParameter(FILE); 29 var decoded = new AnalysisErrorsParams.fromNotification(notification);
30 List<Map<String, Object>> errorMaps = notification.getParameter(ERRORS); 30 filesErrors[decoded.file] = decoded.errors;
31 filesErrors[file] = errorMaps.map(AnalysisError.fromJson).toList();
32 } 31 }
33 } 32 }
34 33
35 @override 34 @override
36 void setUp() { 35 void setUp() {
37 super.setUp(); 36 super.setUp();
38 server.handlers = [new AnalysisDomainHandler(server),]; 37 server.handlers = [new AnalysisDomainHandler(server),];
39 } 38 }
40 39
41 test_ParserError() { 40 test_ParserError() {
42 createProject(); 41 createProject();
43 addTestFile('library lib'); 42 addTestFile('library lib');
44 return waitForTasksFinished().then((_) { 43 return waitForTasksFinished().then((_) {
45 List<AnalysisError> errors = filesErrors[testFile]; 44 List<AnalysisError> errors = filesErrors[testFile];
46 expect(errors, hasLength(1)); 45 expect(errors, hasLength(1));
47 AnalysisError error = errors[0]; 46 AnalysisError error = errors[0];
48 expect(error.location.file, '/project/bin/test.dart'); 47 expect(error.location.file, '/project/bin/test.dart');
49 expect(error.location.offset, isPositive); 48 expect(error.location.offset, isPositive);
50 expect(error.location.length, isNonNegative); 49 expect(error.location.length, isNonNegative);
51 expect(error.severity, 'ERROR'); 50 expect(error.severity, ErrorSeverity.ERROR);
52 expect(error.type, 'SYNTACTIC_ERROR'); 51 expect(error.type, ErrorType.SYNTACTIC_ERROR);
53 expect(error.message, isNotNull); 52 expect(error.message, isNotNull);
54 }); 53 });
55 } 54 }
56 55
57 test_StaticWarning() { 56 test_StaticWarning() {
58 createProject(); 57 createProject();
59 addTestFile(''' 58 addTestFile('''
60 main() { 59 main() {
61 print(UNKNOWN); 60 print(UNKNOWN);
62 } 61 }
63 '''); 62 ''');
64 return waitForTasksFinished().then((_) { 63 return waitForTasksFinished().then((_) {
65 List<AnalysisError> errors = filesErrors[testFile]; 64 List<AnalysisError> errors = filesErrors[testFile];
66 expect(errors, hasLength(1)); 65 expect(errors, hasLength(1));
67 AnalysisError error = errors[0]; 66 AnalysisError error = errors[0];
68 expect(error.severity, 'WARNING'); 67 expect(error.severity, ErrorSeverity.WARNING);
69 expect(error.type, 'STATIC_WARNING'); 68 expect(error.type, ErrorType.STATIC_WARNING);
70 }); 69 });
71 } 70 }
72 71
73 test_notInAnalysisRoot() { 72 test_notInAnalysisRoot() {
74 createProject(); 73 createProject();
75 String otherFile = '/other.dart'; 74 String otherFile = '/other.dart';
76 addFile(otherFile, 'UnknownType V;'); 75 addFile(otherFile, 'UnknownType V;');
77 addTestFile(''' 76 addTestFile('''
78 import '/other.dart'; 77 import '/other.dart';
79 78
80 main() { 79 main() {
81 print(V); 80 print(V);
82 } 81 }
83 '''); 82 ''');
84 return waitForTasksFinished().then((_) { 83 return waitForTasksFinished().then((_) {
85 expect(filesErrors[otherFile], isNull); 84 expect(filesErrors[otherFile], isNull);
86 }); 85 });
87 } 86 }
88 } 87 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/analysis/get_errors_test.dart ('k') | pkg/analysis_server/test/analysis_abstract.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698