private void checkCommentSelection(
String text, String expected, int line1, int column1, int line2, int column2,
int expectedLine1, int expectedColumn1, int expectedLine2, int expectedColumn2) {
MockAutocompleterEnvironment helper = new MockAutocompleterEnvironment();
helper.setup(new PathUtil("test.js"), text, line1, column1, false);
final Editor editor = helper.editor;
editor.getInput().getActionExecutor().addDelegate(
LanguageHelperResolver.getHelper(SyntaxType.JS).getActionExecutor());
LineFinder lineFinder = editor.getDocument().getLineFinder();
editor.getSelection().setSelection(
lineFinder.findLine(line1), column1, lineFinder.findLine(line2), column2);
final JsonArray<Scheduler.ScheduledCommand> scheduled = JsonCollections.createArray();
TestSchedulerImpl.AngryScheduler scheduler = new TestSchedulerImpl.AngryScheduler() {
@Override
public void scheduleDeferred(ScheduledCommand scheduledCommand) {
scheduled.add(scheduledCommand);
}
};
final TestSignalEvent ctrlSlashTriger = new TestSignalEvent(
KeyboardEvent.KeyCode.SLASH, SignalEvent.KeySignalType.INPUT,
ModifierKeys.ACTION);
Runnable ctrlShiftSlashClicker = new Runnable() {
@Override
public void run() {
editor.getInput().processSignalEvent(ctrlSlashTriger);
}
};
TestSchedulerImpl.runWithSpecificScheduler(ctrlShiftSlashClicker, scheduler);
while (!scheduled.isEmpty()) {
Scheduler.ScheduledCommand command = scheduled.remove(0);
command.execute();
}
String result = editor.getDocument().asText();
assertEquals("textual result", expected, result);
Position[] selectionRange = editor.getSelection().getSelectionRange(false);
assertEquals("selection start line", expectedLine1, selectionRange[0].getLineNumber());
assertEquals("selection start column", expectedColumn1, selectionRange[0].getColumn());
assertEquals("selection end line", expectedLine2, selectionRange[1].getLineNumber());
assertEquals("selection end column", expectedColumn2, selectionRange[1].getColumn());
}