OLD | NEW |
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 import 'package:analysis_server/protocol/protocol.dart'; | 5 import 'package:analysis_server/protocol/protocol.dart'; |
6 import 'package:analysis_server/protocol/protocol_generated.dart'; | 6 import 'package:analysis_server/protocol/protocol_generated.dart'; |
7 import 'package:analysis_server/src/analysis_server.dart'; | 7 import 'package:analysis_server/src/analysis_server.dart'; |
8 import 'package:analysis_server/src/constants.dart'; | |
9 import 'package:analysis_server/src/domain_execution.dart'; | 8 import 'package:analysis_server/src/domain_execution.dart'; |
10 import 'package:analysis_server/src/plugin/server_plugin.dart'; | 9 import 'package:analysis_server/src/plugin/server_plugin.dart'; |
11 import 'package:analyzer/file_system/file_system.dart'; | |
12 import 'package:analyzer/file_system/memory_file_system.dart'; | 10 import 'package:analyzer/file_system/memory_file_system.dart'; |
13 import 'package:analyzer/instrumentation/instrumentation.dart'; | 11 import 'package:analyzer/instrumentation/instrumentation.dart'; |
14 import 'package:analyzer/src/generated/engine.dart'; | |
15 import 'package:analyzer/src/generated/sdk.dart'; | 12 import 'package:analyzer/src/generated/sdk.dart'; |
16 import 'package:analyzer/src/generated/source.dart'; | 13 import 'package:analyzer/src/generated/source.dart'; |
17 import 'package:analyzer/src/generated/source_io.dart'; | 14 import 'package:analyzer/src/generated/source_io.dart'; |
18 import 'package:plugin/manager.dart'; | 15 import 'package:plugin/manager.dart'; |
19 import 'package:test/test.dart'; | 16 import 'package:test/test.dart'; |
20 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 17 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
21 | 18 |
22 import 'analysis_abstract.dart'; | 19 import 'analysis_abstract.dart'; |
23 import 'mocks.dart'; | 20 import 'mocks.dart'; |
24 | 21 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 test('delete non-existent context', () { | 74 test('delete non-existent context', () { |
78 Request request = new ExecutionDeleteContextParams('13').toRequest('0'); | 75 Request request = new ExecutionDeleteContextParams('13').toRequest('0'); |
79 Response response = handler.handleRequest(request); | 76 Response response = handler.handleRequest(request); |
80 // TODO(brianwilkerson) It isn't currently specified to be an error if a | 77 // TODO(brianwilkerson) It isn't currently specified to be an error if a |
81 // client attempts to delete a context that doesn't exist. Should it be? | 78 // client attempts to delete a context that doesn't exist. Should it be? |
82 // expect(response, isResponseFailure('0')); | 79 // expect(response, isResponseFailure('0')); |
83 expect(response, isResponseSuccess('0')); | 80 expect(response, isResponseSuccess('0')); |
84 }); | 81 }); |
85 }); | 82 }); |
86 | 83 |
87 group('mapUri', () { | 84 // TODO(brianwilkerson) Re-enable these tests if we re-enable the |
88 String contextId; | 85 // execution.mapUri request. |
89 | 86 // group('mapUri', () { |
90 void createExecutionContextIdForFile(String path) { | 87 // String contextId; |
91 Request request = new ExecutionCreateContextParams(path).toRequest('0'); | 88 // |
92 Response response = handler.handleRequest(request); | 89 // void createExecutionContextIdForFile(String path) { |
93 expect(response, isResponseSuccess('0')); | 90 // Request request = new ExecutionCreateContextParams(path).toRequest('0'
); |
94 ExecutionCreateContextResult result = | 91 // Response response = handler.handleRequest(request); |
95 new ExecutionCreateContextResult.fromResponse(response); | 92 // expect(response, isResponseSuccess('0')); |
96 contextId = result.id; | 93 // ExecutionCreateContextResult result = |
97 } | 94 // new ExecutionCreateContextResult.fromResponse(response); |
98 | 95 // contextId = result.id; |
99 setUp(() { | 96 // } |
100 Folder folder = provider.newFile('/a/b.dart', '').parent; | 97 // |
101 server.folderMap.putIfAbsent(folder, () { | 98 // setUp(() { |
102 SourceFactory factory = | 99 // Folder folder = provider.newFile('/a/b.dart', '').parent; |
103 new SourceFactory([new ResourceUriResolver(provider)]); | 100 // server.folderMap.putIfAbsent(folder, () { |
104 AnalysisContext context = | 101 // SourceFactory factory = |
105 AnalysisEngine.instance.createAnalysisContext(); | 102 // new SourceFactory([new ResourceUriResolver(provider)]); |
106 context.sourceFactory = factory; | 103 // AnalysisContext context = |
107 return context; | 104 // AnalysisEngine.instance.createAnalysisContext(); |
108 }); | 105 // context.sourceFactory = factory; |
109 createExecutionContextIdForFile('/a/b.dart'); | 106 // return context; |
110 }); | 107 // }); |
111 | 108 // createExecutionContextIdForFile('/a/b.dart'); |
112 tearDown(() { | 109 // }); |
113 Request request = | 110 // |
114 new ExecutionDeleteContextParams(contextId).toRequest('1'); | 111 // tearDown(() { |
115 Response response = handler.handleRequest(request); | 112 // Request request = |
116 expect(response, isResponseSuccess('1')); | 113 // new ExecutionDeleteContextParams(contextId).toRequest('1'); |
117 }); | 114 // Response response = handler.handleRequest(request); |
118 | 115 // expect(response, isResponseSuccess('1')); |
119 group('file to URI', () { | 116 // }); |
120 test('does not exist', () { | 117 // |
121 Request request = | 118 // group('file to URI', () { |
122 new ExecutionMapUriParams(contextId, file: '/a/c.dart') | 119 // test('does not exist', () { |
123 .toRequest('2'); | 120 // Request request = |
124 Response response = handler.handleRequest(request); | 121 // new ExecutionMapUriParams(contextId, file: '/a/c.dart') |
125 expect(response, isResponseFailure('2')); | 122 // .toRequest('2'); |
126 }); | 123 // Response response = handler.handleRequest(request); |
127 | 124 // expect(response, isResponseFailure('2')); |
128 test('directory', () { | 125 // }); |
129 provider.newFolder('/a/d'); | 126 // |
130 Request request = | 127 // test('directory', () { |
131 new ExecutionMapUriParams(contextId, file: '/a/d').toRequest('2'); | 128 // provider.newFolder('/a/d'); |
132 Response response = handler.handleRequest(request); | 129 // Request request = |
133 expect(response, isResponseFailure('2')); | 130 // new ExecutionMapUriParams(contextId, file: '/a/d').toRequest('2'
); |
134 }); | 131 // Response response = handler.handleRequest(request); |
135 }); | 132 // expect(response, isResponseFailure('2')); |
136 | 133 // }); |
137 group('URI to file', () { | 134 // }); |
138 test('invalid', () { | 135 // |
139 Request request = | 136 // group('URI to file', () { |
140 new ExecutionMapUriParams(contextId, uri: 'foo:///a/b.dart') | 137 // test('invalid', () { |
141 .toRequest('2'); | 138 // Request request = |
142 Response response = handler.handleRequest(request); | 139 // new ExecutionMapUriParams(contextId, uri: 'foo:///a/b.dart') |
143 expect(response, isResponseFailure('2')); | 140 // .toRequest('2'); |
144 }); | 141 // Response response = handler.handleRequest(request); |
145 }); | 142 // expect(response, isResponseFailure('2')); |
146 | 143 // }); |
147 test('invalid context id', () { | 144 // }); |
148 Request request = | 145 // |
149 new ExecutionMapUriParams('xxx', uri: '').toRequest('4'); | 146 // test('invalid context id', () { |
150 Response response = handler.handleRequest(request); | 147 // Request request = |
151 expect(response, isResponseFailure('4')); | 148 // new ExecutionMapUriParams('xxx', uri: '').toRequest('4'); |
152 }); | 149 // Response response = handler.handleRequest(request); |
153 | 150 // expect(response, isResponseFailure('4')); |
154 test('both file and uri', () { | 151 // }); |
155 Request request = | 152 // |
156 new ExecutionMapUriParams('xxx', file: '', uri: '').toRequest('5'); | 153 // test('both file and uri', () { |
157 Response response = handler.handleRequest(request); | 154 // Request request = |
158 expect(response, isResponseFailure('5')); | 155 // new ExecutionMapUriParams('xxx', file: '', uri: '').toRequest('5')
; |
159 }); | 156 // Response response = handler.handleRequest(request); |
160 | 157 // expect(response, isResponseFailure('5')); |
161 test('neither file nor uri', () { | 158 // }); |
162 Request request = new ExecutionMapUriParams('xxx').toRequest('6'); | 159 // |
163 Response response = handler.handleRequest(request); | 160 // test('neither file nor uri', () { |
164 expect(response, isResponseFailure('6')); | 161 // Request request = new ExecutionMapUriParams('xxx').toRequest('6'); |
165 }); | 162 // Response response = handler.handleRequest(request); |
166 }); | 163 // expect(response, isResponseFailure('6')); |
167 | 164 // }); |
168 group('setSubscriptions', () { | 165 // }); |
169 test('failure - invalid service name', () { | |
170 expect(handler.onFileAnalyzed, isNull); | |
171 | |
172 Request request = new Request('0', EXECUTION_SET_SUBSCRIPTIONS, { | |
173 SUBSCRIPTIONS: ['noSuchService'] | |
174 }); | |
175 Response response = handler.handleRequest(request); | |
176 expect(response, isResponseFailure('0')); | |
177 expect(handler.onFileAnalyzed, isNull); | |
178 }); | |
179 | |
180 test('success - setting and clearing', () { | |
181 expect(handler.onFileAnalyzed, isNull); | |
182 | |
183 Request request = | |
184 new ExecutionSetSubscriptionsParams([ExecutionService.LAUNCH_DATA]) | |
185 .toRequest('0'); | |
186 Response response = handler.handleRequest(request); | |
187 expect(response, isResponseSuccess('0')); | |
188 expect(handler.onFileAnalyzed, isNotNull); | |
189 | |
190 request = new ExecutionSetSubscriptionsParams([]).toRequest('0'); | |
191 response = handler.handleRequest(request); | |
192 expect(response, isResponseSuccess('0')); | |
193 expect(handler.onFileAnalyzed, isNull); | |
194 }); | |
195 }); | |
196 }); | 166 }); |
197 } | 167 } |
198 | 168 |
199 @reflectiveTest | 169 @reflectiveTest |
200 class ExecutionDomainTest extends AbstractAnalysisTest { | 170 class ExecutionDomainTest extends AbstractAnalysisTest { |
201 String contextId; | 171 String contextId; |
202 | 172 |
203 @override | 173 @override |
204 void setUp() { | 174 void setUp() { |
205 super.setUp(); | 175 super.setUp(); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 * A [Source] that knows it's [fullName]. | 241 * A [Source] that knows it's [fullName]. |
272 */ | 242 */ |
273 class TestSource implements Source { | 243 class TestSource implements Source { |
274 String fullName; | 244 String fullName; |
275 | 245 |
276 TestSource(this.fullName); | 246 TestSource(this.fullName); |
277 | 247 |
278 @override | 248 @override |
279 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 249 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
280 } | 250 } |
OLD | NEW |