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

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

Issue 288013003: allow client to specify any combination of add/modified/removed (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge and address comments Created 6 years, 7 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
« no previous file with comments | « pkg/analysis_server/lib/src/protocol.dart ('k') | pkg/analysis_server/test/protocol_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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';
11 import 'package:analysis_server/src/domain_context.dart'; 11 import 'package:analysis_server/src/domain_context.dart';
12 import 'package:analysis_server/src/domain_server.dart'; 12 import 'package:analysis_server/src/domain_server.dart';
13 import 'package:analysis_server/src/protocol.dart'; 13 import 'package:analysis_server/src/protocol.dart';
14 import 'package:unittest/unittest.dart'; 14 import 'package:unittest/unittest.dart';
15 15
16 import 'mocks.dart'; 16 import 'mocks.dart';
17 17
18 main() { 18 main() {
19 group('ContextDomainHandlerTest', () { 19 group('ContextDomainHandlerTest', () {
20 test('applyChanges', ContextDomainHandlerTest.applyChanges); 20 test('applyChanges', ContextDomainHandlerTest.applyChanges);
21 test('createChangeSet', ContextDomainHandlerTest.createChangeSet); 21 test('createChangeSet', ContextDomainHandlerTest.createChangeSet);
22 test('createChangeSet_onlyAdded', ContextDomainHandlerTest.createChangeSet_o nlyAdded);
22 test('setOptions', ContextDomainHandlerTest.setOptions); 23 test('setOptions', ContextDomainHandlerTest.setOptions);
23 test('setPrioritySources_empty', ContextDomainHandlerTest.setPrioritySources _empty); 24 test('setPrioritySources_empty', ContextDomainHandlerTest.setPrioritySources _empty);
24 test('setPrioritySources_nonEmpty', ContextDomainHandlerTest.setPrioritySour ces_nonEmpty); 25 test('setPrioritySources_nonEmpty', ContextDomainHandlerTest.setPrioritySour ces_nonEmpty);
25 }); 26 });
26 } 27 }
27 28
28 class ContextDomainHandlerTest { 29 class ContextDomainHandlerTest {
29 static int contextIdCounter = 0; 30 static int contextIdCounter = 0;
30 31
31 static void applyChanges() { 32 static void applyChanges() {
(...skipping 28 matching lines...) Expand all
60 ContextDomainHandler.ADDED_PARAM: ['ffile:/one.dart'], 61 ContextDomainHandler.ADDED_PARAM: ['ffile:/one.dart'],
61 ContextDomainHandler.MODIFIED_PARAM: [], 62 ContextDomainHandler.MODIFIED_PARAM: [],
62 ContextDomainHandler.REMOVED_PARAM: ['ffile:/two.dart', 63 ContextDomainHandler.REMOVED_PARAM: ['ffile:/two.dart',
63 'ffile:/three.dart'] 64 'ffile:/three.dart']
64 })); 65 }));
65 expect(changeSet.addedSources, hasLength(equals(1))); 66 expect(changeSet.addedSources, hasLength(equals(1)));
66 expect(changeSet.changedSources, hasLength(equals(0))); 67 expect(changeSet.changedSources, hasLength(equals(0)));
67 expect(changeSet.removedSources, hasLength(equals(2))); 68 expect(changeSet.removedSources, hasLength(equals(2)));
68 } 69 }
69 70
71 static void createChangeSet_onlyAdded() {
72 AnalysisServer server = new AnalysisServer(new MockServerChannel());
73 Request request = new Request('0', ContextDomainHandler.APPLY_CHANGES_NAME);
74 ContextDomainHandler handler = new ContextDomainHandler(server);
75 SourceFactory sourceFactory = new SourceFactory([new FileUriResolver()]);
76 ChangeSet changeSet = handler.createChangeSet(request, sourceFactory,
77 new RequestDatum(request, ContextDomainHandler.CHANGES_PARAM, {
78 ContextDomainHandler.ADDED_PARAM: ['ffile:/one.dart'],
79 }));
80 expect(changeSet.addedSources, hasLength(equals(1)));
81 expect(changeSet.changedSources, hasLength(equals(0)));
82 expect(changeSet.removedSources, hasLength(equals(0)));
83 }
84
70 static void setOptions() { 85 static void setOptions() {
71 AnalysisServer server = new AnalysisServer(new MockServerChannel()); 86 AnalysisServer server = new AnalysisServer(new MockServerChannel());
72 String contextId = _createContext(server); 87 String contextId = _createContext(server);
73 Map<String, Object> options = new Map<String, Object>(); 88 Map<String, Object> options = new Map<String, Object>();
74 ContextDomainHandler handler = new ContextDomainHandler(server); 89 ContextDomainHandler handler = new ContextDomainHandler(server);
75 90
76 Request request = new Request('0', ContextDomainHandler.SET_OPTIONS_NAME); 91 Request request = new Request('0', ContextDomainHandler.SET_OPTIONS_NAME);
77 request.setParameter(ContextDomainHandler.CONTEXT_ID_PARAM, contextId); 92 request.setParameter(ContextDomainHandler.CONTEXT_ID_PARAM, contextId);
78 request.setParameter(ContextDomainHandler.OPTIONS_PARAM, options); 93 request.setParameter(ContextDomainHandler.OPTIONS_PARAM, options);
79 Response response = handler.handleRequest(request); 94 Response response = handler.handleRequest(request);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 Request request = new Request('0', ServerDomainHandler.CREATE_CONTEXT_METHOD ); 134 Request request = new Request('0', ServerDomainHandler.CREATE_CONTEXT_METHOD );
120 request.setParameter(ServerDomainHandler.SDK_DIRECTORY_PARAM, sdkPath); 135 request.setParameter(ServerDomainHandler.SDK_DIRECTORY_PARAM, sdkPath);
121 request.setParameter(ServerDomainHandler.CONTEXT_ID_PARAM, contextId); 136 request.setParameter(ServerDomainHandler.CONTEXT_ID_PARAM, contextId);
122 Response response = handler.handleRequest(request); 137 Response response = handler.handleRequest(request);
123 if (response.error != null) { 138 if (response.error != null) {
124 fail('Unexpected error: ${response.error.toJson()}'); 139 fail('Unexpected error: ${response.error.toJson()}');
125 } 140 }
126 return contextId; 141 return contextId;
127 } 142 }
128 } 143 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/protocol.dart ('k') | pkg/analysis_server/test/protocol_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698