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

Side by Side Diff: pkg/analysis_server/test/src/plugin/request_converter_test.dart

Issue 2830903004: Add support for converting from server to plugin protocol objects (Closed)
Patch Set: Created 3 years, 8 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
OLDNEW
(Empty)
1 // Copyright (c) 2017, 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 import 'package:analysis_server/plugin/protocol/protocol.dart' as server;
6 import 'package:analysis_server/src/plugin/request_converter.dart';
7 import 'package:analysis_server/src/protocol/protocol_internal.dart' as server;
8 import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin;
9 import 'package:test/test.dart';
10 import 'package:test_reflective_loader/test_reflective_loader.dart';
11
12 import 'protocol_test_utilities.dart';
13
14 main() {
15 defineReflectiveSuite(() {
16 defineReflectiveTests(RequestConverterTest);
17 });
18 }
19
20 @reflectiveTest
21 class RequestConverterTest extends ProtocolTestUtilities {
22 RequestConverter converter = new RequestConverter();
23
24 void test_convertAnalysisService() {
25 Map<plugin.AnalysisService, server.AnalysisService> kindMap =
26 <plugin.AnalysisService, server.AnalysisService>{
27 plugin.AnalysisService.FOLDING: server.AnalysisService.FOLDING,
28 plugin.AnalysisService.HIGHLIGHTS: server.AnalysisService.HIGHLIGHTS,
29 plugin.AnalysisService.NAVIGATION: server.AnalysisService.NAVIGATION,
30 plugin.AnalysisService.OCCURRENCES: server.AnalysisService.OCCURRENCES,
31 plugin.AnalysisService.OUTLINE: server.AnalysisService.OUTLINE,
32 };
33 kindMap.forEach(
34 (plugin.AnalysisService pluginKind, server.AnalysisService serverKind) {
35 expect(converter.convertAnalysisService(serverKind), pluginKind);
36 });
37 }
38
39 void test_convertFileOverlay_add() {
40 String content = 'content';
41 plugin.AddContentOverlay result =
42 converter.convertFileOverlay(new server.AddContentOverlay(content));
43 expect(result, isNotNull);
44 expect(result.content, content);
45 }
46
47 void test_convertFileOverlay_change() {
48 List<server.SourceEdit> serverEdits = <server.SourceEdit>[
49 new server.SourceEdit(10, 5, 'a'),
50 new server.SourceEdit(20, 6, 'b'),
51 new server.SourceEdit(30, 7, 'c'),
52 ];
53 plugin.ChangeContentOverlay result = converter
54 .convertFileOverlay(new server.ChangeContentOverlay(serverEdits));
55 expect(result, isNotNull);
56 List<plugin.SourceEdit> pluginEdits = result.edits;
57 int editCount = serverEdits.length;
58 expect(pluginEdits, hasLength(editCount));
59 for (int i = 0; i < editCount; i++) {
60 server.SourceEdit serverEdit = serverEdits[i];
61 plugin.SourceEdit pluginEdit = pluginEdits[i];
62 expect(pluginEdit.offset, serverEdit.offset);
63 expect(pluginEdit.length, serverEdit.length);
64 expect(pluginEdit.replacement, serverEdit.replacement);
65 }
66 }
67
68 void test_convertFileOverlay_remove() {
69 plugin.RemoveContentOverlay result =
70 converter.convertFileOverlay(new server.RemoveContentOverlay());
71 expect(result, isNotNull);
72 }
73
74 void test_convertSourceEdit() {
75 int offset = 5;
76 int length = 3;
77 String replacement = 'x';
78 plugin.SourceEdit result = converter
79 .convertSourceEdit(new server.SourceEdit(offset, length, replacement));
80 expect(result, isNotNull);
81 expect(result.offset, offset);
82 expect(result.length, length);
83 expect(result.replacement, replacement);
84 }
85 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/plugin/request_converter.dart ('k') | pkg/analysis_server/test/src/plugin/test_all.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698