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

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

Issue 407263002: Implementation of the 'analysis.getErrors' API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library test.analysis.get_errors;
6
7 import 'dart:async';
8
9 import 'package:analysis_server/src/computer/error.dart';
10 import 'package:analysis_server/src/constants.dart';
11 import 'package:analysis_server/src/domain_analysis.dart';
12 import 'package:analysis_server/src/protocol.dart';
13 import 'package:analysis_services/constants.dart';
14 import 'package:analysis_testing/reflective_tests.dart';
15 import 'package:unittest/unittest.dart';
16
17 import '../analysis_abstract.dart';
18
19
20 main() {
21 group('notification.hover', () {
22 runReflectiveTests(GetErrorsTest);
23 });
24 }
25
26
27 @ReflectiveTestCase()
28 class GetErrorsTest extends AbstractAnalysisTest {
29 Future<List<AnalysisError>> getErrors() {
30 return getErrorsForFile(testFile);
31 }
32
33 Future<List<AnalysisError>> getErrorsForFile(String file) {
34 return waitForTasksFinished().then((_) {
35 String requestId = 'test-getError';
36 // send the Request
37 Request request = new Request(requestId, ANALYSIS_GET_ERRORS);
38 request.setParameter(FILE, file);
39 server.handleRequest(request);
40 // wait for the Response
41 waitForResponse() {
42 for (Response response in serverChannel.responsesReceived) {
43 if (response.id == requestId) {
44 List errorsJsons = response.getResult(ERRORS);
45 return errorsJsons.map(AnalysisError.fromJson).toList();
46 }
47 }
48 return new Future(waitForResponse);
49 }
50 return new Future(waitForResponse);
51 });
52 }
53
54 @override
55 void setUp() {
56 super.setUp();
57 server.handlers = [new AnalysisDomainHandler(server),];
58 createProject();
59 }
60
61 test_hasErrors() {
62 addTestFile('''
63 main() {
64 print(42)
65 }
66 ''');
67 return getErrors().then((List<AnalysisError> errors) {
68 expect(errors, hasLength(1));
69 {
70 AnalysisError error = errors[0];
71 expect(error.severity, 'ERROR');
72 expect(error.type, 'SYNTACTIC_ERROR');
73 expect(error.location.file, testFile);
74 expect(error.location.startLine, 2);
75 }
76 });
77 }
78
79 test_noErrors() {
80 addTestFile('''
81 main() {
82 print(42);
83 }
84 ''');
85 return getErrors().then((List<AnalysisError> errors) {
86 expect(errors, isEmpty);
87 });
88 }
89
90 test_fileWithoutContext() {
91 String file = '/outside.dart';
92 addFile(file, '''
93 main() {
94 print(42);
95 }
96 ''');
97 return getErrorsForFile(file).then((List<AnalysisError> errors) {
98 expect(errors, isEmpty);
99 });
100 }
101 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698