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

Side by Side Diff: pkg/analysis_server/test/domain_analysis_test.dart

Issue 482573004: Change analysis server protocol to omit empty lists when optional. (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.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/analysis_server.dart'; 9 import 'package:analysis_server/src/analysis_server.dart';
10 import 'package:analysis_server/src/constants.dart'; 10 import 'package:analysis_server/src/constants.dart';
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 handler = new AnalysisDomainHandler(server); 43 handler = new AnalysisDomainHandler(server);
44 }); 44 });
45 45
46 group('updateContent', testUpdateContent); 46 group('updateContent', testUpdateContent);
47 group('setSubscriptions', test_setSubscriptions); 47 group('setSubscriptions', test_setSubscriptions);
48 48
49 group('AnalysisDomainHandler', () { 49 group('AnalysisDomainHandler', () {
50 group('setAnalysisRoots', () { 50 group('setAnalysisRoots', () {
51 Response testSetAnalysisRoots(List<String> included, 51 Response testSetAnalysisRoots(List<String> included,
52 List<String> excluded) { 52 List<String> excluded) {
53 Request request = new AnalysisSetAnalysisRootsParams(included, 53 Request request = new AnalysisSetAnalysisRootsParams(included: included,
54 excluded).toRequest('0'); 54 excluded: excluded).toRequest('0');
55 return handler.handleRequest(request); 55 return handler.handleRequest(request);
56 } 56 }
57 57
58 group('excluded', () { 58 group('excluded', () {
59 test('excluded folder', () { 59 test('excluded folder', () {
60 String project = '/project'; 60 String project = '/project';
61 String fileA = '/project/aaa/a.dart'; 61 String fileA = '/project/aaa/a.dart';
62 String fileB = '/project/bbb/b.dart'; 62 String fileB = '/project/bbb/b.dart';
63 resourceProvider.newFolder(project); 63 resourceProvider.newFolder(project);
64 resourceProvider.newFile(fileA, '// a'); 64 resourceProvider.newFile(fileA, '// a');
(...skipping 26 matching lines...) Expand all
91 }); 91 });
92 }); 92 });
93 }); 93 });
94 }); 94 });
95 95
96 group('setPriorityFiles', () { 96 group('setPriorityFiles', () {
97 test('invalid', () { 97 test('invalid', () {
98 // TODO(paulberry): under the "eventual consistency" model this request 98 // TODO(paulberry): under the "eventual consistency" model this request
99 // should not be invalid. 99 // should not be invalid.
100 var request = new AnalysisSetPriorityFilesParams( 100 var request = new AnalysisSetPriorityFilesParams(
101 ['/project/lib.dart']).toRequest('0'); 101 files: ['/project/lib.dart']).toRequest('0');
102 var response = handler.handleRequest(request); 102 var response = handler.handleRequest(request);
103 expect(response, isResponseFailure('0')); 103 expect(response, isResponseFailure('0'));
104 }); 104 });
105 105
106 test('valid', () { 106 test('valid', () {
107 resourceProvider.newFolder('/p1'); 107 resourceProvider.newFolder('/p1');
108 resourceProvider.newFile('/p1/a.dart', 'library a;'); 108 resourceProvider.newFile('/p1/a.dart', 'library a;');
109 resourceProvider.newFolder('/p2'); 109 resourceProvider.newFolder('/p2');
110 resourceProvider.newFile('/p2/b.dart', 'library b;'); 110 resourceProvider.newFile('/p2/b.dart', 'library b;');
111 resourceProvider.newFile('/p2/c.dart', 'library c;'); 111 resourceProvider.newFile('/p2/c.dart', 'library c;');
112 112
113 var setRootsRequest = new AnalysisSetAnalysisRootsParams( 113 var setRootsRequest = new AnalysisSetAnalysisRootsParams(
114 ['/p1', '/p2'], []).toRequest('0'); 114 included: ['/p1', '/p2']).toRequest('0');
115 var setRootsResponse = handler.handleRequest(setRootsRequest); 115 var setRootsResponse = handler.handleRequest(setRootsRequest);
116 expect(setRootsResponse, isResponseSuccess('0')); 116 expect(setRootsResponse, isResponseSuccess('0'));
117 117
118 void setPriorityFiles(List<String> fileList) { 118 void setPriorityFiles(List<String> fileList) {
119 var request = new AnalysisSetPriorityFilesParams( 119 var request = new AnalysisSetPriorityFilesParams(
120 fileList).toRequest('0'); 120 files: fileList).toRequest('0');
121 var response = handler.handleRequest(request); 121 var response = handler.handleRequest(request);
122 expect(response, isResponseSuccess('0')); 122 expect(response, isResponseSuccess('0'));
123 // TODO(brianwilkerson) Enable the line below after getPriorityFiles 123 // TODO(brianwilkerson) Enable the line below after getPriorityFiles
124 // has been implemented. 124 // has been implemented.
125 // expect(server.getPriorityFiles(), unorderedEquals(fileList)); 125 // expect(server.getPriorityFiles(), unorderedEquals(fileList));
126 } 126 }
127 127
128 setPriorityFiles(['/p1/a.dart', '/p2/b.dart']); 128 setPriorityFiles(['/p1/a.dart', '/p2/b.dart']);
129 setPriorityFiles(['/p2/b.dart', '/p2/c.dart']); 129 setPriorityFiles(['/p2/b.dart', '/p2/c.dart']);
130 setPriorityFiles([]); 130 setPriorityFiles([]);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 AnalysisTestHelper helper = new AnalysisTestHelper(); 204 AnalysisTestHelper helper = new AnalysisTestHelper();
205 String initialContent = 'library A;'; 205 String initialContent = 'library A;';
206 helper.createSingleFileProject(initialContent); 206 helper.createSingleFileProject(initialContent);
207 return helper.waitForOperationsFinished().then((_) { 207 return helper.waitForOperationsFinished().then((_) {
208 // no errors initially 208 // no errors initially
209 List<AnalysisError> errors = helper.getTestErrors(); 209 List<AnalysisError> errors = helper.getTestErrors();
210 expect(errors, isEmpty); 210 expect(errors, isEmpty);
211 // Add the file to the cache 211 // Add the file to the cache
212 helper.sendContentChange(new AddContentOverlay(initialContent)); 212 helper.sendContentChange(new AddContentOverlay(initialContent));
213 // update code 213 // update code
214 helper.sendContentChange(new ChangeContentOverlay([ 214 helper.sendContentChange(new ChangeContentOverlay(edits: [
215 new SourceEdit('library '.length, 'A;'.length, 'lib')])); 215 new SourceEdit('library '.length, 'A;'.length, 'lib')]));
216 // wait, there is an error 216 // wait, there is an error
217 return helper.waitForOperationsFinished().then((_) { 217 return helper.waitForOperationsFinished().then((_) {
218 List<AnalysisError> errors = helper.getTestErrors(); 218 List<AnalysisError> errors = helper.getTestErrors();
219 expect(errors, hasLength(1)); 219 expect(errors, hasLength(1));
220 }); 220 });
221 }); 221 });
222 }); 222 });
223 223
224 test('change on disk, normal', () { 224 test('change on disk, normal', () {
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 476
477 void addAnalysisSubscriptionNavigation(String file) { 477 void addAnalysisSubscriptionNavigation(String file) {
478 addAnalysisSubscription(AnalysisService.NAVIGATION, file); 478 addAnalysisSubscription(AnalysisService.NAVIGATION, file);
479 } 479 }
480 480
481 /** 481 /**
482 * Creates an empty project `/project`. 482 * Creates an empty project `/project`.
483 */ 483 */
484 void createEmptyProject() { 484 void createEmptyProject() {
485 resourceProvider.newFolder('/project'); 485 resourceProvider.newFolder('/project');
486 Request request = new AnalysisSetAnalysisRootsParams(['/project'], 486 Request request = new AnalysisSetAnalysisRootsParams(
487 []).toRequest('0'); 487 included: ['/project']).toRequest('0');
488 handleSuccessfulRequest(request); 488 handleSuccessfulRequest(request);
489 } 489 }
490 490
491 /** 491 /**
492 * Creates a project with a single Dart file `/project/bin/test.dart` with 492 * Creates a project with a single Dart file `/project/bin/test.dart` with
493 * the given [code]. 493 * the given [code].
494 */ 494 */
495 void createSingleFileProject(code) { 495 void createSingleFileProject(code) {
496 this.testCode = _getCodeString(code); 496 this.testCode = _getCodeString(code);
497 resourceProvider.newFolder('/project'); 497 resourceProvider.newFolder('/project');
498 resourceProvider.newFile(testFile, testCode); 498 resourceProvider.newFile(testFile, testCode);
499 Request request = new AnalysisSetAnalysisRootsParams(['/project'], 499 Request request = new AnalysisSetAnalysisRootsParams(
500 []).toRequest('0'); 500 included: ['/project']).toRequest('0');
501 handleSuccessfulRequest(request); 501 handleSuccessfulRequest(request);
502 } 502 }
503 503
504 /** 504 /**
505 * Returns the offset of [search] in [testCode]. 505 * Returns the offset of [search] in [testCode].
506 * Fails if not found. 506 * Fails if not found.
507 */ 507 */
508 int findOffset(String search) { 508 int findOffset(String search) {
509 int offset = testCode.indexOf(search); 509 int offset = testCode.indexOf(search);
510 expect(offset, isNot(-1)); 510 expect(offset, isNot(-1));
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 return waitForServerOperationsPerformed(server); 608 return waitForServerOperationsPerformed(server);
609 } 609 }
610 610
611 static String _getCodeString(code) { 611 static String _getCodeString(code) {
612 if (code is List<String>) { 612 if (code is List<String>) {
613 code = code.join('\n'); 613 code = code.join('\n');
614 } 614 }
615 return code as String; 615 return code as String;
616 } 616 }
617 } 617 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698