1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-30 16:24:09 +03:00

Formatter: cursor position is saved when invoking autoformat. Fixes #2293

This commit is contained in:
Federico Fissore
2014-09-30 17:17:13 +02:00
parent 170816181a
commit 1b783fa48c
5 changed files with 91 additions and 1 deletions

View File

@ -0,0 +1,46 @@
package processing.app;
import org.fest.swing.fixture.JMenuItemFixture;
import org.junit.Test;
import processing.app.helpers.JEditTextAreaFixture;
import static org.junit.Assert.assertEquals;
public class AutoformatSavesCaretPositionTest extends AbstractGUITest {
@Test
public void shouldSaveCaretPositionAfterAutoformat() {
JMenuItemFixture menuToolsAutoFormat = window.menuItem("menuToolsAutoFormat");
menuToolsAutoFormat.requireEnabled();
JEditTextAreaFixture editor = window.jEditTextArea("editor");
editor.setText("void setup() {\n" +
" // put your setup code here, to run once:\n" +
"\n" +
"}\n" +
"\n" +
"void loop() {\n" +
" // put your main code here, to run repeatedly:\n" +
"\n" +
"}");
editor.setCaretPosition(29); // right before the first // (double slash)
menuToolsAutoFormat.click();
String formattedText = editor.getText();
assertEquals("void setup() {\n" +
" // put your setup code here, to run once:\n" +
"\n" +
"}\n" +
"\n" +
"void loop() {\n" +
" // put your main code here, to run repeatedly:\n" +
"\n" +
"}", formattedText);
assertEquals(29, editor.getCaretPosition());
}
}