1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-12-13 23:48:46 +01:00
Arduino/app/test/processing/app/AutoformatTest.java
2013-10-15 18:09:09 +02:00

42 lines
1.3 KiB
Java

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 AutoformatTest extends AbstractGUITest {
@Test
public void shouldProduceNicelyFormattedCode() throws Exception {
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" +
"int foo[] = { 1, 2, 3, 4, 5};\n" +
"int foo[2][5] = {{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}};\n" +
"}\n" +
"\n" +
"void loop() {\n" +
"// put your main code here, to run repeatedly:\n" +
"}");
menuToolsAutoFormat.click();
String formattedText = editor.getText();
assertEquals("void setup() {\n" +
" // put your setup code here, to run once:\n" +
" int foo[] = { 1, 2, 3, 4, 5};\n" +
" int foo[2][5] = {{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}};\n" +
"}\n" +
"\n" +
"void loop() {\n" +
" // put your main code here, to run repeatedly:\n" +
"}", formattedText);
}
}