|
| 1 | +package processing.app; |
| 2 | + |
| 3 | +import org.fest.swing.fixture.JMenuItemFixture; |
| 4 | +import org.junit.Test; |
| 5 | +import processing.app.helpers.JEditTextAreaFixture; |
| 6 | + |
| 7 | +import static org.junit.Assert.assertEquals; |
| 8 | + |
| 9 | +public class AutoformatTest extends AbstractGUITest { |
| 10 | + |
| 11 | + @Test |
| 12 | + public void shouldProduceNicelyFormattedCode() throws Exception { |
| 13 | + JMenuItemFixture menuToolsAutoFormat = window.menuItem("menuToolsAutoFormat"); |
| 14 | + menuToolsAutoFormat.requireEnabled(); |
| 15 | + |
| 16 | + JEditTextAreaFixture editor = window.jEditTextArea("editor"); |
| 17 | + editor.setText("void setup() {\n" + |
| 18 | + "// put your setup code here, to run once:\n" + |
| 19 | + "int foo[] = { 1, 2, 3, 4, 5};\n" + |
| 20 | + "int foo[2][5] = {{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}};\n" + |
| 21 | + "}\n" + |
| 22 | + "\n" + |
| 23 | + "void loop() {\n" + |
| 24 | + "// put your main code here, to run repeatedly:\n" + |
| 25 | + "}"); |
| 26 | + |
| 27 | + menuToolsAutoFormat.click(); |
| 28 | + |
| 29 | + String formattedText = editor.getText(); |
| 30 | + assertEquals("void setup() {\n" + |
| 31 | + " // put your setup code here, to run once:\n" + |
| 32 | + " int foo[] = { 1, 2, 3, 4, 5};\n" + |
| 33 | + " int foo[2][5] = {{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}};\n" + |
| 34 | + "}\n" + |
| 35 | + "\n" + |
| 36 | + "void loop() {\n" + |
| 37 | + " // put your main code here, to run repeatedly:\n" + |
| 38 | + "}", formattedText); |
| 39 | + |
| 40 | + } |
| 41 | +} |
0 commit comments