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

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

Issue 904733003: Rework requests in execution domain (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Clean-up Created 5 years, 10 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.execution; 5 library test.domain.execution;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/analysis_server.dart'; 9 import 'package:analysis_server/src/analysis_server.dart';
10 import 'package:analysis_server/src/constants.dart'; 10 import 'package:analysis_server/src/constants.dart';
11 import 'package:analysis_server/src/domain_execution.dart'; 11 import 'package:analysis_server/src/domain_execution.dart';
12 import 'package:analysis_server/src/protocol.dart'; 12 import 'package:analysis_server/src/protocol.dart';
13 import 'package:analyzer/file_system/memory_file_system.dart'; 13 import 'package:analyzer/file_system/memory_file_system.dart';
14 import 'package:analyzer/instrumentation/instrumentation.dart'; 14 import 'package:analyzer/instrumentation/instrumentation.dart';
15 import 'package:analyzer/src/generated/engine.dart'; 15 import 'package:analyzer/src/generated/engine.dart';
16 import 'package:analyzer/src/generated/source.dart'; 16 import 'package:analyzer/src/generated/source.dart';
17 import 'package:typed_mock/typed_mock.dart'; 17 import 'package:typed_mock/typed_mock.dart';
18 import 'package:unittest/unittest.dart'; 18 import 'package:unittest/unittest.dart';
19 19
20 import 'mock_sdk.dart'; 20 import 'mock_sdk.dart';
21 import 'mocks.dart'; 21 import 'mocks.dart';
22 import 'operation/operation_queue_test.dart'; 22 import 'operation/operation_queue_test.dart';
23 import 'package:analyzer/file_system/file_system.dart';
24 import 'package:analyzer/src/generated/source_io.dart';
23 25
24 /** 26 /**
25 * Return a matcher that will match an [ExecutableFile] if it has the given 27 * Return a matcher that will match an [ExecutableFile] if it has the given
26 * [source] and [kind]. 28 * [source] and [kind].
27 */ 29 */
28 Matcher isExecutableFile(Source source, ExecutableKind kind) { 30 Matcher isExecutableFile(Source source, ExecutableKind kind) {
29 return new IsExecutableFile(source.fullName, kind); 31 return new IsExecutableFile(source.fullName, kind);
30 } 32 }
31 33
32 main() { 34 main() {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 test('delete non-existent context', () { 79 test('delete non-existent context', () {
78 Request request = new ExecutionDeleteContextParams('13').toRequest('0'); 80 Request request = new ExecutionDeleteContextParams('13').toRequest('0');
79 Response response = handler.handleRequest(request); 81 Response response = handler.handleRequest(request);
80 // TODO(brianwilkerson) It isn't currently specified to be an error if a 82 // 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? 83 // client attempts to delete a context that doesn't exist. Should it be?
82 // expect(response, isResponseFailure('0')); 84 // expect(response, isResponseFailure('0'));
83 expect(response, isResponseSuccess('0')); 85 expect(response, isResponseSuccess('0'));
84 }); 86 });
85 }); 87 });
86 88
87 // group('mapUri', () { 89 group('mapUri', () {
88 // String contextId; 90 String contextId;
89 // 91
90 // setUp(() { 92 setUp(() {
91 // Request request = 93 Folder folder = provider.newFile('/a/b.dart', '').parent;
92 // new ExecutionCreateContextParams('/a/b.dart').toRequest('0'); 94 server.folderMap.putIfAbsent(folder, () {
93 // Response response = handler.handleRequest(request); 95 SourceFactory factory = new SourceFactory([new ResourceUriResolver(pro vider)]);
94 // expect(response, isResponseSuccess('0')); 96 AnalysisContext context = AnalysisEngine.instance.createAnalysisContex t();
95 // ExecutionCreateContextResult result = 97 context.sourceFactory = factory;
96 // new ExecutionCreateContextResult.fromResponse(response); 98 return context;
97 // contextId = result.id; 99 });
98 // }); 100 Request request =
99 // 101 new ExecutionCreateContextParams('/a/b.dart').toRequest('0');
100 // tearDown(() { 102 Response response = handler.handleRequest(request);
101 // Request request = 103 expect(response, isResponseSuccess('0'));
102 // new ExecutionDeleteContextParams(contextId).toRequest('1'); 104 ExecutionCreateContextResult result =
103 // Response response = handler.handleRequest(request); 105 new ExecutionCreateContextResult.fromResponse(response);
104 // expect(response, isResponseSuccess('1')); 106 contextId = result.id;
105 // }); 107 });
106 // 108
107 // test('file to URI', () { 109 tearDown(() {
108 // Request request = 110 Request request =
109 // new ExecutionMapUriParams(contextId, file: '/a/b.dart').toRequest( '2'); 111 new ExecutionDeleteContextParams(contextId).toRequest('1');
110 // Response response = handler.handleRequest(request); 112 Response response = handler.handleRequest(request);
111 // expect(response, isResponseSuccess('2')); 113 expect(response, isResponseSuccess('1'));
112 // ExecutionMapUriResult result = 114 });
113 // new ExecutionMapUriResult.fromResponse(response); 115
114 // expect(result.file, isNull); 116 group('file to URI', () {
115 // expect(result.uri, isNotNull); 117 test('does not exist', () {
116 // // TODO(brianwilkerson) Test for the correct result. 118 Request request =
117 // }); 119 new ExecutionMapUriParams(contextId, file: '/a/c.dart').toRequest( '2');
118 // 120 Response response = handler.handleRequest(request);
119 // test('URI to file', () { 121 expect(response, isResponseFailure('2'));
120 // Request request = 122 });
121 // new ExecutionMapUriParams(contextId, uri: '/a/b.dart').toRequest(' 3'); 123
122 // Response response = handler.handleRequest(request); 124 test('does not exist', () {
Paul Berry 2015/02/06 03:55:33 Did you copy/paste the test name from the previous
Brian Wilkerson 2015/02/06 15:49:01 Done
123 // expect(response, isResponseSuccess('3')); 125 provider.newFolder('/a/d');
124 // ExecutionMapUriResult result = 126 Request request =
125 // new ExecutionMapUriResult.fromResponse(response); 127 new ExecutionMapUriParams(contextId, file: '/a/d').toRequest('2');
126 // expect(result.file, isNotNull); 128 Response response = handler.handleRequest(request);
127 // expect(result.uri, isNull); 129 expect(response, isResponseFailure('2'));
128 // // TODO(brianwilkerson) Test for the correct result. 130 });
129 // }); 131
130 // 132 test('valid', () {
131 // test('invalid context id', () { 133 Request request =
132 // Request request = 134 new ExecutionMapUriParams(contextId, file: '/a/b.dart').toRequest( '2');
133 // new ExecutionMapUriParams('xxx', uri: '').toRequest('4'); 135 Response response = handler.handleRequest(request);
134 // Response response = handler.handleRequest(request); 136 expect(response, isResponseSuccess('2'));
135 // expect(response, isResponseFailure('4')); 137 ExecutionMapUriResult result =
136 // }); 138 new ExecutionMapUriResult.fromResponse(response);
137 // 139 expect(result.file, isNull);
138 // test('both file and uri', () { 140 expect(result.uri, 'file:///a/b.dart');
139 // Request request = 141 });
140 // new ExecutionMapUriParams('xxx', file: '', uri: '').toRequest('5') ; 142 });
141 // Response response = handler.handleRequest(request); 143
142 // expect(response, isResponseFailure('5')); 144 group('URI to file', () {
143 // }); 145 test('invalid', () {
144 // }); 146 Request request =
147 new ExecutionMapUriParams(contextId, uri: 'foo:///a/b.dart').toReq uest('2');
148 Response response = handler.handleRequest(request);
149 expect(response, isResponseFailure('2'));
150 });
151
152 test('valid', () {
153 Request request =
154 new ExecutionMapUriParams(contextId, uri: 'file:///a/b.dart').toRe quest('2');
155 Response response = handler.handleRequest(request);
156 expect(response, isResponseSuccess('2'));
157 ExecutionMapUriResult result =
158 new ExecutionMapUriResult.fromResponse(response);
159 expect(result.file, '/a/b.dart');
160 expect(result.uri, isNull);
161 });
162 });
163
164 test('invalid context id', () {
165 Request request =
166 new ExecutionMapUriParams('xxx', uri: '').toRequest('4');
167 Response response = handler.handleRequest(request);
168 expect(response, isResponseFailure('4'));
169 });
170
171 test('both file and uri', () {
Paul Berry 2015/02/06 03:55:33 Should we also have a test for the case where neit
Brian Wilkerson 2015/02/06 15:49:01 Done
172 Request request =
173 new ExecutionMapUriParams('xxx', file: '', uri: '').toRequest('5');
174 Response response = handler.handleRequest(request);
175 expect(response, isResponseFailure('5'));
176 });
177 });
145 178
146 group('setSubscriptions', () { 179 group('setSubscriptions', () {
147 test('failure - invalid service name', () { 180 test('failure - invalid service name', () {
148 expect(handler.onFileAnalyzed, isNull); 181 expect(handler.onFileAnalyzed, isNull);
149 182
150 Request request = new Request('0', EXECUTION_SET_SUBSCRIPTIONS, { 183 Request request = new Request('0', EXECUTION_SET_SUBSCRIPTIONS, {
151 SUBSCRIPTIONS: ['noSuchService'] 184 SUBSCRIPTIONS: ['noSuchService']
152 }); 185 });
153 Response response = handler.handleRequest(request); 186 Response response = handler.handleRequest(request);
154 expect(response, isResponseFailure('0')); 187 expect(response, isResponseFailure('0'));
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 * A [Source] that knows it's [fullName]. 304 * A [Source] that knows it's [fullName].
272 */ 305 */
273 class TestSource implements Source { 306 class TestSource implements Source {
274 String fullName; 307 String fullName;
275 308
276 TestSource(this.fullName); 309 TestSource(this.fullName);
277 310
278 @override 311 @override
279 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 312 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
280 } 313 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698