| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 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 | 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/plugin/protocol/protocol.dart' as server; | 5 import 'package:analysis_server/plugin/protocol/protocol.dart' as server; |
| 6 import 'package:analysis_server/src/plugin/request_converter.dart'; | 6 import 'package:analysis_server/src/plugin/request_converter.dart'; |
| 7 import 'package:analysis_server/src/protocol/protocol_internal.dart' as server; | 7 import 'package:analysis_server/src/protocol/protocol_internal.dart' as server; |
| 8 import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin; | 8 import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin; |
| 9 import 'package:test/test.dart'; | 9 import 'package:test/test.dart'; |
| 10 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 10 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 plugin.AnalysisService.NAVIGATION: server.AnalysisService.NAVIGATION, | 29 plugin.AnalysisService.NAVIGATION: server.AnalysisService.NAVIGATION, |
| 30 plugin.AnalysisService.OCCURRENCES: server.AnalysisService.OCCURRENCES, | 30 plugin.AnalysisService.OCCURRENCES: server.AnalysisService.OCCURRENCES, |
| 31 plugin.AnalysisService.OUTLINE: server.AnalysisService.OUTLINE, | 31 plugin.AnalysisService.OUTLINE: server.AnalysisService.OUTLINE, |
| 32 }; | 32 }; |
| 33 kindMap.forEach( | 33 kindMap.forEach( |
| 34 (plugin.AnalysisService pluginKind, server.AnalysisService serverKind) { | 34 (plugin.AnalysisService pluginKind, server.AnalysisService serverKind) { |
| 35 expect(converter.convertAnalysisService(serverKind), pluginKind); | 35 expect(converter.convertAnalysisService(serverKind), pluginKind); |
| 36 }); | 36 }); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void test_convertAnalysisSetPriorityFilesParams() { |
| 40 List<String> files = <String>['a', 'b', 'c']; |
| 41 plugin.AnalysisSetPriorityFilesParams result = |
| 42 converter.convertAnalysisSetPriorityFilesParams( |
| 43 new server.AnalysisSetPriorityFilesParams(files)); |
| 44 expect(result, isNotNull); |
| 45 expect(result.files, files); |
| 46 } |
| 47 |
| 48 void test_convertAnalysisSetSubscriptionsParams() { |
| 49 Map<server.AnalysisService, List<String>> serverSubscriptions = |
| 50 <server.AnalysisService, List<String>>{ |
| 51 server.AnalysisService.HIGHLIGHTS: <String>['a', 'b'], |
| 52 server.AnalysisService.OUTLINE: <String>['c'], |
| 53 server.AnalysisService.OVERRIDES: <String>['d', 'e'] |
| 54 }; |
| 55 plugin.AnalysisSetSubscriptionsParams result = |
| 56 converter.convertAnalysisSetSubscriptionsParams( |
| 57 new server.AnalysisSetSubscriptionsParams(serverSubscriptions)); |
| 58 expect(result, isNotNull); |
| 59 Map<plugin.AnalysisService, List<String>> pluginSubscriptions = |
| 60 result.subscriptions; |
| 61 expect(pluginSubscriptions, hasLength(2)); |
| 62 expect( |
| 63 pluginSubscriptions[plugin.AnalysisService.HIGHLIGHTS], hasLength(2)); |
| 64 expect(pluginSubscriptions[plugin.AnalysisService.OUTLINE], hasLength(1)); |
| 65 } |
| 66 |
| 67 void test_convertAnalysisUpdateContentParams() { |
| 68 Map<String, dynamic> serverFiles = <String, dynamic>{ |
| 69 'file1': new server.AddContentOverlay('content1'), |
| 70 'file2': new server.AddContentOverlay('content2'), |
| 71 }; |
| 72 plugin.AnalysisUpdateContentParams result = |
| 73 converter.convertAnalysisUpdateContentParams( |
| 74 new server.AnalysisUpdateContentParams(serverFiles)); |
| 75 expect(result, isNotNull); |
| 76 Map<String, dynamic> pluginFiles = result.files; |
| 77 expect(pluginFiles, hasLength(2)); |
| 78 expect(pluginFiles['file1'], new isInstanceOf<plugin.AddContentOverlay>()); |
| 79 expect(pluginFiles['file2'], new isInstanceOf<plugin.AddContentOverlay>()); |
| 80 } |
| 81 |
| 39 void test_convertFileOverlay_add() { | 82 void test_convertFileOverlay_add() { |
| 40 String content = 'content'; | 83 String content = 'content'; |
| 41 plugin.AddContentOverlay result = | 84 plugin.AddContentOverlay result = |
| 42 converter.convertFileOverlay(new server.AddContentOverlay(content)); | 85 converter.convertFileOverlay(new server.AddContentOverlay(content)); |
| 43 expect(result, isNotNull); | 86 expect(result, isNotNull); |
| 44 expect(result.content, content); | 87 expect(result.content, content); |
| 45 } | 88 } |
| 46 | 89 |
| 47 void test_convertFileOverlay_change() { | 90 void test_convertFileOverlay_change() { |
| 48 List<server.SourceEdit> serverEdits = <server.SourceEdit>[ | 91 List<server.SourceEdit> serverEdits = <server.SourceEdit>[ |
| (...skipping 27 matching lines...) Expand all Loading... |
| 76 int length = 3; | 119 int length = 3; |
| 77 String replacement = 'x'; | 120 String replacement = 'x'; |
| 78 plugin.SourceEdit result = converter | 121 plugin.SourceEdit result = converter |
| 79 .convertSourceEdit(new server.SourceEdit(offset, length, replacement)); | 122 .convertSourceEdit(new server.SourceEdit(offset, length, replacement)); |
| 80 expect(result, isNotNull); | 123 expect(result, isNotNull); |
| 81 expect(result.offset, offset); | 124 expect(result.offset, offset); |
| 82 expect(result.length, length); | 125 expect(result.length, length); |
| 83 expect(result.replacement, replacement); | 126 expect(result.replacement, replacement); |
| 84 } | 127 } |
| 85 } | 128 } |
| OLD | NEW |