Index: pkg/analysis_server/test/src/utilities/change_builder_core_test.dart |
diff --git a/pkg/analysis_server/test/src/utilities/change_builder_core_test.dart b/pkg/analysis_server/test/src/utilities/change_builder_core_test.dart |
index f2fbf7d90440049a9057d785cb16a7e7ffd7bb5d..7271746fad0bc30a12481563276a639c403a95fc 100644 |
--- a/pkg/analysis_server/test/src/utilities/change_builder_core_test.dart |
+++ b/pkg/analysis_server/test/src/utilities/change_builder_core_test.dart |
@@ -38,6 +38,13 @@ class ChangeBuilderImplTest { |
expect(identical(builder.getLinkedEditGroup('a'), group), isTrue); |
} |
+ void test_setSelection() { |
+ Position position = new Position('test.dart', 3); |
+ ChangeBuilderImpl builder = new ChangeBuilderImpl(); |
+ builder.setSelection(position); |
+ expect(builder.sourceChange.selection, position); |
+ } |
+ |
void test_sourceChange_noChanges() { |
ChangeBuilderImpl builder = new ChangeBuilderImpl(); |
SourceChange sourceChange = builder.sourceChange; |
@@ -102,6 +109,16 @@ class EditBuilderImplTest { |
}); |
} |
+ test_selectHere() async { |
+ ChangeBuilderImpl builder = new ChangeBuilderImpl(); |
+ await builder.addFileEdit(path, 0, (FileEditBuilder builder) { |
+ builder.addInsertion(10, (EditBuilder builder) { |
+ builder.selectHere(); |
+ }); |
+ }); |
+ expect(builder.sourceChange.selection.offset, 10); |
+ } |
+ |
test_write() async { |
ChangeBuilderImpl builder = new ChangeBuilderImpl(); |
int timeStamp = 93; |
@@ -199,6 +216,20 @@ class EditBuilderImplTest { |
class FileEditBuilderImplTest { |
String path = '/test.dart'; |
+ test_addDeletion() async { |
+ int offset = 23; |
+ int length = 7; |
+ ChangeBuilderImpl builder = new ChangeBuilderImpl(); |
+ await builder.addFileEdit(path, 0, (FileEditBuilder builder) { |
+ builder.addDeletion(offset, length); |
+ }); |
+ List<SourceEdit> edits = builder.sourceChange.edits[0].edits; |
+ expect(edits, hasLength(1)); |
+ expect(edits[0].offset, offset); |
+ expect(edits[0].length, length); |
+ expect(edits[0].replacement, isEmpty); |
+ } |
+ |
test_addInsertion() async { |
ChangeBuilderImpl builder = new ChangeBuilderImpl(); |
await builder.addFileEdit(path, 0, (FileEditBuilder builder) { |
@@ -233,6 +264,35 @@ class FileEditBuilderImplTest { |
}); |
} |
+ test_addSimpleInsertion() async { |
+ int offset = 23; |
+ String text = 'xyz'; |
+ ChangeBuilderImpl builder = new ChangeBuilderImpl(); |
+ await builder.addFileEdit(path, 0, (FileEditBuilder builder) { |
+ builder.addSimpleInsertion(offset, text); |
+ }); |
+ List<SourceEdit> edits = builder.sourceChange.edits[0].edits; |
+ expect(edits, hasLength(1)); |
+ expect(edits[0].offset, offset); |
+ expect(edits[0].length, 0); |
+ expect(edits[0].replacement, text); |
+ } |
+ |
+ test_addSimpleReplacement() async { |
+ int offset = 23; |
+ int length = 7; |
+ String text = 'xyz'; |
+ ChangeBuilderImpl builder = new ChangeBuilderImpl(); |
+ await builder.addFileEdit(path, 0, (FileEditBuilder builder) { |
+ builder.addSimpleReplacement(offset, length, text); |
+ }); |
+ List<SourceEdit> edits = builder.sourceChange.edits[0].edits; |
+ expect(edits, hasLength(1)); |
+ expect(edits[0].offset, offset); |
+ expect(edits[0].length, length); |
+ expect(edits[0].replacement, text); |
+ } |
+ |
test_createEditBuilder() async { |
ChangeBuilderImpl builder = new ChangeBuilderImpl(); |
await builder.addFileEdit(path, 0, (FileEditBuilder builder) { |