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

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

Issue 245113006: Consistently type check analysis server request parameters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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.context; 5 library test.domain.context;
6 6
7 import 'package:analyzer/src/generated/engine.dart'; 7 import 'package:analyzer/src/generated/engine.dart';
8 import 'package:analyzer/src/generated/source.dart'; 8 import 'package:analyzer/src/generated/source.dart';
9 import 'package:analyzer/src/generated/source_io.dart'; 9 import 'package:analyzer/src/generated/source_io.dart';
10 import 'package:analysis_server/src/analysis_server.dart'; 10 import 'package:analysis_server/src/analysis_server.dart';
(...skipping 18 matching lines...) Expand all
29 static int contextIdCounter = 0; 29 static int contextIdCounter = 0;
30 30
31 static void applyChanges() { 31 static void applyChanges() {
32 AnalysisServer server = new AnalysisServer(new MockServerChannel()); 32 AnalysisServer server = new AnalysisServer(new MockServerChannel());
33 String contextId = _createContext(server); 33 String contextId = _createContext(server);
34 ChangeSet changeSet = new ChangeSet(); 34 ChangeSet changeSet = new ChangeSet();
35 ContextDomainHandler handler = new ContextDomainHandler(server); 35 ContextDomainHandler handler = new ContextDomainHandler(server);
36 36
37 Request request = new Request('0', ContextDomainHandler.APPLY_CHANGES_NAME); 37 Request request = new Request('0', ContextDomainHandler.APPLY_CHANGES_NAME);
38 request.setParameter(ContextDomainHandler.CONTEXT_ID_PARAM, contextId); 38 request.setParameter(ContextDomainHandler.CONTEXT_ID_PARAM, contextId);
39 request.setParameter(ContextDomainHandler.SOURCES_PARAM, []);
39 request.setParameter(ContextDomainHandler.CHANGES_PARAM, { 40 request.setParameter(ContextDomainHandler.CHANGES_PARAM, {
40 ContextDomainHandler.ADDED_PARAM : ['ffile:/one.dart'], 41 ContextDomainHandler.ADDED_PARAM : ['ffile:/one.dart'],
41 ContextDomainHandler.MODIFIED_PARAM : ['ffile:/two.dart'], 42 ContextDomainHandler.MODIFIED_PARAM : ['ffile:/two.dart'],
42 ContextDomainHandler.REMOVED_PARAM : ['ffile:/three.dart'] 43 ContextDomainHandler.REMOVED_PARAM : ['ffile:/three.dart']
43 }); 44 });
44 Response response = handler.handleRequest(request); 45 Response response = handler.handleRequest(request);
45 expect(response.toJson(), equals({ 46 expect(response.toJson(), equals({
46 Response.ID: '0', 47 Response.ID: '0',
47 Response.ERROR: null 48 Response.ERROR: null
48 })); 49 }));
49 } 50 }
50 51
51 static void createChangeSet() { 52 static void createChangeSet() {
52 AnalysisServer server = new AnalysisServer(new MockServerChannel()); 53 AnalysisServer server = new AnalysisServer(new MockServerChannel());
53 Request request = new Request('0', ContextDomainHandler.APPLY_CHANGES_NAME); 54 Request request = new Request('0', ContextDomainHandler.APPLY_CHANGES_NAME);
54 ContextDomainHandler handler = new ContextDomainHandler(server); 55 ContextDomainHandler handler = new ContextDomainHandler(server);
55 SourceFactory sourceFactory = new SourceFactory([new FileUriResolver()]); 56 SourceFactory sourceFactory = new SourceFactory([new FileUriResolver()]);
56 ChangeSet changeSet = handler.createChangeSet(request, sourceFactory, { 57 ChangeSet changeSet = handler.createChangeSet(request, sourceFactory,
57 ContextDomainHandler.ADDED_PARAM : ['ffile:/one.dart'], 58 new RequestDatum(request, ContextDomainHandler.CHANGES_PARAM, {
58 ContextDomainHandler.MODIFIED_PARAM : [], 59 ContextDomainHandler.ADDED_PARAM: ['ffile:/one.dart'],
59 ContextDomainHandler.REMOVED_PARAM : ['ffile:/two.dart', 'ffile:/three.dar t'] 60 ContextDomainHandler.MODIFIED_PARAM: [],
60 }); 61 ContextDomainHandler.REMOVED_PARAM: ['ffile:/two.dart',
62 'ffile:/three.dart']
63 }));
61 expect(changeSet.addedSources, hasLength(equals(1))); 64 expect(changeSet.addedSources, hasLength(equals(1)));
62 expect(changeSet.changedSources, hasLength(equals(0))); 65 expect(changeSet.changedSources, hasLength(equals(0)));
63 expect(changeSet.removedSources, hasLength(equals(2))); 66 expect(changeSet.removedSources, hasLength(equals(2)));
64 } 67 }
65 68
66 static void setOptions() { 69 static void setOptions() {
67 AnalysisServer server = new AnalysisServer(new MockServerChannel()); 70 AnalysisServer server = new AnalysisServer(new MockServerChannel());
68 String contextId = _createContext(server); 71 String contextId = _createContext(server);
69 Map<String, Object> options = new Map<String, Object>(); 72 Map<String, Object> options = new Map<String, Object>();
70 ContextDomainHandler handler = new ContextDomainHandler(server); 73 ContextDomainHandler handler = new ContextDomainHandler(server);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 Request request = new Request('0', ServerDomainHandler.CREATE_CONTEXT_METHOD ); 121 Request request = new Request('0', ServerDomainHandler.CREATE_CONTEXT_METHOD );
119 request.setParameter(ServerDomainHandler.SDK_DIRECTORY_PARAM, sdkPath); 122 request.setParameter(ServerDomainHandler.SDK_DIRECTORY_PARAM, sdkPath);
120 request.setParameter(ServerDomainHandler.CONTEXT_ID_PARAM, contextId); 123 request.setParameter(ServerDomainHandler.CONTEXT_ID_PARAM, contextId);
121 Response response = handler.handleRequest(request); 124 Response response = handler.handleRequest(request);
122 if (response.error != null) { 125 if (response.error != null) {
123 fail('Unexpected error: ${response.error.toJson()}'); 126 fail('Unexpected error: ${response.error.toJson()}');
124 } 127 }
125 return contextId; 128 return contextId;
126 } 129 }
127 } 130 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698