mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-17 06:52:18 +01:00
Adding AutoformatTest
This commit is contained in:
parent
995f0faf46
commit
f7f616c3bb
@ -903,6 +903,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
JMenuItem item;
|
||||
|
||||
item = createToolMenuItem("cc.arduino.packages.formatter.AStyle");
|
||||
item.setName("menuToolsAutoFormat");
|
||||
int modifiers = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
|
||||
item.setAccelerator(KeyStroke.getKeyStroke('T', modifiers));
|
||||
menu.add(item);
|
||||
|
41
app/test/processing/app/AutoformatTest.java
Normal file
41
app/test/processing/app/AutoformatTest.java
Normal file
@ -0,0 +1,41 @@
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user