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

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

Issue 308003009: Add ServerOperation and queue. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove some priorities 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
(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.domain.context;
6
7 import 'package:analyzer/src/generated/engine.dart';
8 import 'package:analyzer/src/generated/source.dart';
9 import 'package:analyzer/src/generated/source_io.dart';
10 import 'package:analysis_server/src/analysis_server.dart';
11 import 'package:analysis_server/src/constants.dart';
12 import 'package:analysis_server/src/domain_context.dart';
13 import 'package:analysis_server/src/protocol.dart';
14 import 'package:analysis_server/src/resource.dart';
15 import 'package:unittest/unittest.dart';
16
17 import 'mocks.dart';
18
19 main() {
20 group('ContextDomainHandlerTest', () {
21 // TODO(scheglov) remove or move to the 'analysis' domain
22 // test('applyChanges', ContextDomainHandlerTest.applyChanges);
23 test('createChangeSet', ContextDomainHandlerTest.createChangeSet);
24 test('createChangeSet_onlyAdded', ContextDomainHandlerTest.createChangeSet_o nlyAdded);
25 // TODO(scheglov) remove or move to the 'analysis' domain
26 // test('setOptions', ContextDomainHandlerTest.setOptions);
27 // test('setPrioritySources_empty', ContextDomainHandlerTest.setPrioritySourc es_empty);
28 // test('setPrioritySources_nonEmpty', ContextDomainHandlerTest.setPrioritySo urces_nonEmpty);
29 });
30 }
31
32 class ContextDomainHandlerTest {
33 static int contextIdCounter = 0;
34
35 // TODO(scheglov) remove or move to the 'analysis' domain
36 // static void applyChanges() {
37 // AnalysisServer server = new AnalysisServer(new MockServerChannel());
38 // String contextId = _createContext(server);
39 // ChangeSet changeSet = new ChangeSet();
40 // ContextDomainHandler handler = new ContextDomainHandler(server);
41 //
42 // Request request = new Request('0', ContextDomainHandler.APPLY_CHANGES_NAME );
43 // request.setParameter(ContextDomainHandler.CONTEXT_ID_PARAM, contextId);
44 // request.setParameter(ContextDomainHandler.SOURCES_PARAM, []);
45 // request.setParameter(ContextDomainHandler.CHANGES_PARAM, {
46 // ContextDomainHandler.ADDED_PARAM : ['ffile:/one.dart'],
47 // ContextDomainHandler.MODIFIED_PARAM : ['ffile:/two.dart'],
48 // ContextDomainHandler.REMOVED_PARAM : ['ffile:/three.dart']
49 // });
50 // expect(server.contextWorkQueue, isEmpty);
51 // Response response = handler.handleRequest(request);
52 // expect(server.contextWorkQueue, hasLength(1));
53 // expect(response.toJson(), equals({
54 // Response.ID: '0'
55 // }));
56 // }
57
58 static void createChangeSet() {
59 AnalysisServer server = new AnalysisServer(
60 new MockServerChannel(),
61 PhysicalResourceProvider.INSTANCE);
62 Request request = new Request('0', APPLY_CHANGES_NAME);
63 ContextDomainHandler handler = new ContextDomainHandler(server);
64 SourceFactory sourceFactory = new SourceFactory([new FileUriResolver()]);
65 ChangeSet changeSet = handler.createChangeSet(request, sourceFactory,
66 new RequestDatum(request, CHANGES_PARAM, {
67 ADDED: ['ffile:/one.dart'],
68 MODIFIED_PARAM: [],
69 REMOVED: ['ffile:/two.dart', 'ffile:/three.dart']
70 }));
71 expect(changeSet.addedSources, hasLength(equals(1)));
72 expect(changeSet.changedSources, hasLength(equals(0)));
73 expect(changeSet.removedSources, hasLength(equals(2)));
74 }
75
76 static void createChangeSet_onlyAdded() {
77 AnalysisServer server = new AnalysisServer(
78 new MockServerChannel(),
79 PhysicalResourceProvider.INSTANCE);
80 Request request = new Request('0', APPLY_CHANGES_NAME);
81 ContextDomainHandler handler = new ContextDomainHandler(server);
82 SourceFactory sourceFactory = new SourceFactory([new FileUriResolver()]);
83 ChangeSet changeSet = handler.createChangeSet(request, sourceFactory,
84 new RequestDatum(request, CHANGES_PARAM, {
85 ADDED: ['ffile:/one.dart'],
86 }));
87 expect(changeSet.addedSources, hasLength(equals(1)));
88 expect(changeSet.changedSources, hasLength(equals(0)));
89 expect(changeSet.removedSources, hasLength(equals(0)));
90 }
91
92 // TODO(scheglov) remove or move to the 'analysis' domain
93 // static void setOptions() {
94 // AnalysisServer server = new AnalysisServer(new MockServerChannel());
95 // String contextId = _createContext(server);
96 // Map<String, Object> options = new Map<String, Object>();
97 // ContextDomainHandler handler = new ContextDomainHandler(server);
98 //
99 // Request request = new Request('0', ContextDomainHandler.SET_OPTIONS_NAME);
100 // request.setParameter(ContextDomainHandler.CONTEXT_ID_PARAM, contextId);
101 // request.setParameter(ContextDomainHandler.OPTIONS_PARAM, options);
102 // Response response = handler.handleRequest(request);
103 // expect(response.toJson(), equals({
104 // Response.ID: '0'
105 // }));
106 // }
107
108 // TODO(scheglov) remove or move to the 'analysis' domain
109 // static void setPrioritySources_empty() {
110 // AnalysisServer server = new AnalysisServer(new MockServerChannel());
111 // String contextId = _createContext(server);
112 // List<String> sources = new List<String>();
113 // ContextDomainHandler handler = new ContextDomainHandler(server);
114 //
115 // Request request = new Request('0', ContextDomainHandler.SET_PRIORITY_SOURC ES_NAME);
116 // request.setParameter(ContextDomainHandler.CONTEXT_ID_PARAM, contextId);
117 // request.setParameter(ContextDomainHandler.SOURCES_PARAM, sources);
118 // Response response = handler.handleRequest(request);
119 // expect(response.toJson(), equals({
120 // Response.ID: '0'
121 // }));
122 // }
123
124 // TODO(scheglov) remove or move to the 'analysis' domain
125 // static void setPrioritySources_nonEmpty() {
126 // AnalysisServer server = new AnalysisServer(new MockServerChannel());
127 // String contextId = _createContext(server);
128 // List<String> sources = new List<String>();
129 // sources.add("foo.dart");
130 // ContextDomainHandler handler = new ContextDomainHandler(server);
131 //
132 // Request request = new Request('0', ContextDomainHandler.SET_PRIORITY_SOURC ES_NAME);
133 // request.setParameter(ContextDomainHandler.CONTEXT_ID_PARAM, contextId);
134 // request.setParameter(ContextDomainHandler.SOURCES_PARAM, sources);
135 // Response response = handler.handleRequest(request);
136 // expect(response.toJson(), equals({
137 // Response.ID: '0'
138 // }));
139 // }
140
141 // TODO(scheglov) remove or move to the 'analysis' domain
142 // static String _createContext(AnalysisServer server) {
143 // String contextId = "context${contextIdCounter++}";
144 // ServerDomainHandler handler = new ServerDomainHandler(server);
145 // Request request = new Request('0', ServerDomainHandler.CREATE_CONTEXT_METH OD);
146 // request.setParameter(ServerDomainHandler.SDK_DIRECTORY_PARAM, sdkPath);
147 // request.setParameter(AnalysisServer.CONTEXT_ID_PARAM, contextId);
148 // Response response = handler.handleRequest(request);
149 // if (response.error != null) {
150 // fail('Unexpected error: ${response.error.toJson()}');
151 // }
152 // return contextId;
153 // }
154 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698