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

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

Issue 300023004: Partial implementation of the 'setAnalysisRoots' API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes for review comments. Created 6 years, 6 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';
11 import 'package:analysis_server/src/domain_context.dart'; 11 import 'package:analysis_server/src/domain_context.dart';
12 import 'package:analysis_server/src/protocol.dart'; 12 import 'package:analysis_server/src/protocol.dart';
13 import 'package:analysis_server/src/resource.dart';
13 import 'package:unittest/unittest.dart'; 14 import 'package:unittest/unittest.dart';
14 15
15 import 'mocks.dart'; 16 import 'mocks.dart';
16 17
17 main() { 18 main() {
18 group('ContextDomainHandlerTest', () { 19 group('ContextDomainHandlerTest', () {
19 // TODO(scheglov) remove or move to the 'analysis' domain 20 // TODO(scheglov) remove or move to the 'analysis' domain
20 // test('applyChanges', ContextDomainHandlerTest.applyChanges); 21 // test('applyChanges', ContextDomainHandlerTest.applyChanges);
21 test('createChangeSet', ContextDomainHandlerTest.createChangeSet); 22 test('createChangeSet', ContextDomainHandlerTest.createChangeSet);
22 test('createChangeSet_onlyAdded', ContextDomainHandlerTest.createChangeSet_o nlyAdded); 23 test('createChangeSet_onlyAdded', ContextDomainHandlerTest.createChangeSet_o nlyAdded);
(...skipping 24 matching lines...) Expand all
47 // }); 48 // });
48 // expect(server.contextWorkQueue, isEmpty); 49 // expect(server.contextWorkQueue, isEmpty);
49 // Response response = handler.handleRequest(request); 50 // Response response = handler.handleRequest(request);
50 // expect(server.contextWorkQueue, hasLength(1)); 51 // expect(server.contextWorkQueue, hasLength(1));
51 // expect(response.toJson(), equals({ 52 // expect(response.toJson(), equals({
52 // Response.ID: '0' 53 // Response.ID: '0'
53 // })); 54 // }));
54 // } 55 // }
55 56
56 static void createChangeSet() { 57 static void createChangeSet() {
57 AnalysisServer server = new AnalysisServer(new MockServerChannel()); 58 AnalysisServer server = new AnalysisServer(
59 new MockServerChannel(),
60 PhysicalResourceProvider.INSTANCE);
58 Request request = new Request('0', ContextDomainHandler.APPLY_CHANGES_NAME); 61 Request request = new Request('0', ContextDomainHandler.APPLY_CHANGES_NAME);
59 ContextDomainHandler handler = new ContextDomainHandler(server); 62 ContextDomainHandler handler = new ContextDomainHandler(server);
60 SourceFactory sourceFactory = new SourceFactory([new FileUriResolver()]); 63 SourceFactory sourceFactory = new SourceFactory([new FileUriResolver()]);
61 ChangeSet changeSet = handler.createChangeSet(request, sourceFactory, 64 ChangeSet changeSet = handler.createChangeSet(request, sourceFactory,
62 new RequestDatum(request, ContextDomainHandler.CHANGES_PARAM, { 65 new RequestDatum(request, ContextDomainHandler.CHANGES_PARAM, {
63 ContextDomainHandler.ADDED_PARAM: ['ffile:/one.dart'], 66 ContextDomainHandler.ADDED_PARAM: ['ffile:/one.dart'],
64 ContextDomainHandler.MODIFIED_PARAM: [], 67 ContextDomainHandler.MODIFIED_PARAM: [],
65 ContextDomainHandler.REMOVED_PARAM: ['ffile:/two.dart', 68 ContextDomainHandler.REMOVED_PARAM: ['ffile:/two.dart',
66 'ffile:/three.dart'] 69 'ffile:/three.dart']
67 })); 70 }));
68 expect(changeSet.addedSources, hasLength(equals(1))); 71 expect(changeSet.addedSources, hasLength(equals(1)));
69 expect(changeSet.changedSources, hasLength(equals(0))); 72 expect(changeSet.changedSources, hasLength(equals(0)));
70 expect(changeSet.removedSources, hasLength(equals(2))); 73 expect(changeSet.removedSources, hasLength(equals(2)));
71 } 74 }
72 75
73 static void createChangeSet_onlyAdded() { 76 static void createChangeSet_onlyAdded() {
74 AnalysisServer server = new AnalysisServer(new MockServerChannel()); 77 AnalysisServer server = new AnalysisServer(
78 new MockServerChannel(),
79 PhysicalResourceProvider.INSTANCE);
75 Request request = new Request('0', ContextDomainHandler.APPLY_CHANGES_NAME); 80 Request request = new Request('0', ContextDomainHandler.APPLY_CHANGES_NAME);
76 ContextDomainHandler handler = new ContextDomainHandler(server); 81 ContextDomainHandler handler = new ContextDomainHandler(server);
77 SourceFactory sourceFactory = new SourceFactory([new FileUriResolver()]); 82 SourceFactory sourceFactory = new SourceFactory([new FileUriResolver()]);
78 ChangeSet changeSet = handler.createChangeSet(request, sourceFactory, 83 ChangeSet changeSet = handler.createChangeSet(request, sourceFactory,
79 new RequestDatum(request, ContextDomainHandler.CHANGES_PARAM, { 84 new RequestDatum(request, ContextDomainHandler.CHANGES_PARAM, {
80 ContextDomainHandler.ADDED_PARAM: ['ffile:/one.dart'], 85 ContextDomainHandler.ADDED_PARAM: ['ffile:/one.dart'],
81 })); 86 }));
82 expect(changeSet.addedSources, hasLength(equals(1))); 87 expect(changeSet.addedSources, hasLength(equals(1)));
83 expect(changeSet.changedSources, hasLength(equals(0))); 88 expect(changeSet.changedSources, hasLength(equals(0)));
84 expect(changeSet.removedSources, hasLength(equals(0))); 89 expect(changeSet.removedSources, hasLength(equals(0)));
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 // Request request = new Request('0', ServerDomainHandler.CREATE_CONTEXT_METH OD); 145 // Request request = new Request('0', ServerDomainHandler.CREATE_CONTEXT_METH OD);
141 // request.setParameter(ServerDomainHandler.SDK_DIRECTORY_PARAM, sdkPath); 146 // request.setParameter(ServerDomainHandler.SDK_DIRECTORY_PARAM, sdkPath);
142 // request.setParameter(AnalysisServer.CONTEXT_ID_PARAM, contextId); 147 // request.setParameter(AnalysisServer.CONTEXT_ID_PARAM, contextId);
143 // Response response = handler.handleRequest(request); 148 // Response response = handler.handleRequest(request);
144 // if (response.error != null) { 149 // if (response.error != null) {
145 // fail('Unexpected error: ${response.error.toJson()}'); 150 // fail('Unexpected error: ${response.error.toJson()}');
146 // } 151 // }
147 // return contextId; 152 // return contextId;
148 // } 153 // }
149 } 154 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/domain_analysis_test.dart ('k') | pkg/analysis_server/test/domain_server_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698