mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-30 19:52:13 +01:00
updated tests for new Textarea
This commit is contained in:
parent
1c78ba5f3d
commit
725dffa69e
@ -31,7 +31,7 @@ package processing.app;
|
|||||||
|
|
||||||
import org.fest.swing.fixture.JMenuItemFixture;
|
import org.fest.swing.fixture.JMenuItemFixture;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import processing.app.helpers.JEditTextAreaFixture;
|
import processing.app.helpers.RSyntaxTextAreaFixture;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ public class AutoformatSavesCaretPositionTest extends AbstractGUITest {
|
|||||||
JMenuItemFixture menuToolsAutoFormat = window.menuItem("menuToolsAutoFormat");
|
JMenuItemFixture menuToolsAutoFormat = window.menuItem("menuToolsAutoFormat");
|
||||||
menuToolsAutoFormat.requireEnabled();
|
menuToolsAutoFormat.requireEnabled();
|
||||||
|
|
||||||
JEditTextAreaFixture editor = window.jEditTextArea("editor");
|
RSyntaxTextAreaFixture editor = window.RSyntaxTextArea("editor");
|
||||||
editor.setText("void setup() {\n" +
|
editor.setText("void setup() {\n" +
|
||||||
" // put your setup code here, to run once:\n" +
|
" // put your setup code here, to run once:\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
|
@ -31,7 +31,7 @@ package processing.app;
|
|||||||
|
|
||||||
import org.fest.swing.fixture.JMenuItemFixture;
|
import org.fest.swing.fixture.JMenuItemFixture;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import processing.app.helpers.JEditTextAreaFixture;
|
import processing.app.helpers.RSyntaxTextAreaFixture;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ public class AutoformatTest extends AbstractGUITest {
|
|||||||
JMenuItemFixture menuToolsAutoFormat = window.menuItem("menuToolsAutoFormat");
|
JMenuItemFixture menuToolsAutoFormat = window.menuItem("menuToolsAutoFormat");
|
||||||
menuToolsAutoFormat.requireEnabled();
|
menuToolsAutoFormat.requireEnabled();
|
||||||
|
|
||||||
JEditTextAreaFixture editor = window.jEditTextArea("editor");
|
RSyntaxTextAreaFixture editor = window.RSyntaxTextArea("editor");
|
||||||
editor.setText("void setup() {\n" +
|
editor.setText("void setup() {\n" +
|
||||||
"// put your setup code here, to run once:\n" +
|
"// put your setup code here, to run once:\n" +
|
||||||
"int foo[] = { 1, 2, 3, 4, 5};\n" +
|
"int foo[] = { 1, 2, 3, 4, 5};\n" +
|
||||||
|
@ -29,15 +29,16 @@
|
|||||||
|
|
||||||
package processing.app;
|
package processing.app;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.awt.Frame;
|
||||||
|
|
||||||
import org.fest.swing.edt.GuiActionRunner;
|
import org.fest.swing.edt.GuiActionRunner;
|
||||||
import org.fest.swing.edt.GuiQuery;
|
import org.fest.swing.edt.GuiQuery;
|
||||||
import org.fest.swing.fixture.JMenuItemFixture;
|
import org.fest.swing.fixture.JMenuItemFixture;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import processing.app.helpers.JEditTextAreaFixture;
|
|
||||||
|
|
||||||
import java.awt.*;
|
import processing.app.helpers.RSyntaxTextAreaFixture;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
public class BlockCommentGeneratesOneUndoActionTest extends AbstractGUITest {
|
public class BlockCommentGeneratesOneUndoActionTest extends AbstractGUITest {
|
||||||
|
|
||||||
@ -46,7 +47,7 @@ public class BlockCommentGeneratesOneUndoActionTest extends AbstractGUITest {
|
|||||||
JMenuItemFixture menuEditUndo = window.menuItem("menuEditUndo");
|
JMenuItemFixture menuEditUndo = window.menuItem("menuEditUndo");
|
||||||
menuEditUndo.requireDisabled();
|
menuEditUndo.requireDisabled();
|
||||||
|
|
||||||
JEditTextAreaFixture jEditTextArea = window.jEditTextArea("editor");
|
RSyntaxTextAreaFixture jEditTextArea = window.RSyntaxTextArea("editor");
|
||||||
String previousText = jEditTextArea.getText();
|
String previousText = jEditTextArea.getText();
|
||||||
|
|
||||||
jEditTextArea.selectAll();
|
jEditTextArea.selectAll();
|
||||||
|
@ -33,7 +33,7 @@ import org.fest.swing.core.KeyPressInfo;
|
|||||||
import org.fest.swing.finder.WindowFinder;
|
import org.fest.swing.finder.WindowFinder;
|
||||||
import org.fest.swing.fixture.DialogFixture;
|
import org.fest.swing.fixture.DialogFixture;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import processing.app.helpers.JEditTextAreaFixture;
|
import processing.app.helpers.RSyntaxTextAreaFixture;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
@ -44,7 +44,7 @@ public class HittingEscapeOnCloseConfirmationDialogTest extends AbstractGUITest
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldJustCloseTheDialog() throws Exception {
|
public void shouldJustCloseTheDialog() throws Exception {
|
||||||
JEditTextAreaFixture editor = window.jEditTextArea("editor");
|
RSyntaxTextAreaFixture editor = window.RSyntaxTextArea("editor");
|
||||||
editor.setText("test");
|
editor.setText("test");
|
||||||
|
|
||||||
window.close();
|
window.close();
|
||||||
|
@ -34,7 +34,7 @@ import static org.junit.Assert.assertEquals;
|
|||||||
import org.fest.swing.fixture.JMenuItemFixture;
|
import org.fest.swing.fixture.JMenuItemFixture;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import processing.app.helpers.JEditTextAreaFixture;
|
import processing.app.helpers.RSyntaxTextAreaFixture;
|
||||||
|
|
||||||
public class ReduceIndentWith1CharOnLastLineTest extends AbstractGUITest {
|
public class ReduceIndentWith1CharOnLastLineTest extends AbstractGUITest {
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ public class ReduceIndentWith1CharOnLastLineTest extends AbstractGUITest {
|
|||||||
public void shouldJustCloseTheDialog() throws Exception {
|
public void shouldJustCloseTheDialog() throws Exception {
|
||||||
JMenuItemFixture menuDecreaseIndent = window.menuItem("menuDecreaseIndent");
|
JMenuItemFixture menuDecreaseIndent = window.menuItem("menuDecreaseIndent");
|
||||||
|
|
||||||
JEditTextAreaFixture editor = window.jEditTextArea("editor");
|
RSyntaxTextAreaFixture editor = window.RSyntaxTextArea("editor");
|
||||||
editor.setText("void loop()\n{\n Serial.begin(9600)\n}");
|
editor.setText("void loop()\n{\n Serial.begin(9600)\n}");
|
||||||
|
|
||||||
editor.selectAll();
|
editor.selectAll();
|
||||||
|
@ -31,7 +31,7 @@ package processing.app;
|
|||||||
|
|
||||||
import org.fest.swing.fixture.JMenuItemFixture;
|
import org.fest.swing.fixture.JMenuItemFixture;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import processing.app.helpers.JEditTextAreaFixture;
|
import processing.app.helpers.RSyntaxTextAreaFixture;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
@ -44,19 +44,19 @@ public class ReplacingTextGeneratesTwoUndoActionsTest extends AbstractGUITest {
|
|||||||
JMenuItemFixture menuEditRedo = window.menuItem("menuEditRedo");
|
JMenuItemFixture menuEditRedo = window.menuItem("menuEditRedo");
|
||||||
menuEditRedo.requireDisabled();
|
menuEditRedo.requireDisabled();
|
||||||
|
|
||||||
JEditTextAreaFixture jEditTextArea = window.jEditTextArea("editor");
|
RSyntaxTextAreaFixture RSyntaxTextArea = window.RSyntaxTextArea("editor");
|
||||||
|
|
||||||
jEditTextArea.setText("fake text");
|
RSyntaxTextArea.setText("fake text");
|
||||||
|
|
||||||
menuEditUndo.requireEnabled();
|
menuEditUndo.requireEnabled();
|
||||||
menuEditUndo.click();
|
menuEditUndo.click();
|
||||||
|
|
||||||
assertEquals("", jEditTextArea.getText());
|
assertEquals("", RSyntaxTextArea.getText());
|
||||||
|
|
||||||
menuEditRedo.requireEnabled();
|
menuEditRedo.requireEnabled();
|
||||||
menuEditRedo.click();
|
menuEditRedo.click();
|
||||||
|
|
||||||
//assertEquals("fake text", jEditTextArea.getText());
|
//assertEquals("fake text", RSyntaxTextArea.getText());
|
||||||
|
|
||||||
menuEditUndo.requireEnabled();
|
menuEditUndo.requireEnabled();
|
||||||
menuEditUndo.click();
|
menuEditUndo.click();
|
||||||
|
@ -30,8 +30,9 @@
|
|||||||
package processing.app.helpers;
|
package processing.app.helpers;
|
||||||
|
|
||||||
import org.fest.swing.fixture.FrameFixture;
|
import org.fest.swing.fixture.FrameFixture;
|
||||||
|
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
||||||
|
|
||||||
import processing.app.Editor;
|
import processing.app.Editor;
|
||||||
import processing.app.syntax.JEditTextArea;
|
|
||||||
|
|
||||||
public class ArduinoFrameFixture extends FrameFixture {
|
public class ArduinoFrameFixture extends FrameFixture {
|
||||||
|
|
||||||
@ -42,8 +43,8 @@ public class ArduinoFrameFixture extends FrameFixture {
|
|||||||
this.editor = editor;
|
this.editor = editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JEditTextAreaFixture jEditTextArea(String name) {
|
public RSyntaxTextAreaFixture RSyntaxTextArea(String name) {
|
||||||
return new JEditTextAreaFixture(robot, (JEditTextArea) this.robot.finder().find(new JEditTextAreaComponentMatcher(name)));
|
return new RSyntaxTextAreaFixture(robot, (RSyntaxTextArea) this.robot.finder().find(new RSyntaxTextAreaComponentMatcher(name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Editor getEditor() {
|
public Editor getEditor() {
|
||||||
|
@ -0,0 +1,79 @@
|
|||||||
|
package processing.app.helpers;
|
||||||
|
|
||||||
|
import org.fest.swing.core.Robot;
|
||||||
|
import org.fest.swing.driver.JComponentDriver;
|
||||||
|
import org.fest.swing.edt.GuiActionRunner;
|
||||||
|
import org.fest.swing.edt.GuiQuery;
|
||||||
|
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
||||||
|
|
||||||
|
public class RSyntaxTextAreaComponentDriver extends JComponentDriver {
|
||||||
|
|
||||||
|
public RSyntaxTextAreaComponentDriver(Robot robot) {
|
||||||
|
super(robot);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void enterText(RSyntaxTextArea target, String text) {
|
||||||
|
focusAndWaitForFocusGain(target);
|
||||||
|
robot.enterText(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setText(final RSyntaxTextArea target, final String text) {
|
||||||
|
focusAndWaitForFocusGain(target);
|
||||||
|
GuiActionRunner.execute(new GuiQuery<RSyntaxTextArea>() {
|
||||||
|
|
||||||
|
protected RSyntaxTextArea executeInEDT() {
|
||||||
|
target.setText(text);
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
robot.waitForIdle();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getText(final RSyntaxTextArea target) {
|
||||||
|
focusAndWaitForFocusGain(target);
|
||||||
|
return GuiActionRunner.execute(new GuiQuery<String>() {
|
||||||
|
|
||||||
|
protected String executeInEDT() {
|
||||||
|
return target.getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public RSyntaxTextArea selectAll(final RSyntaxTextArea target) {
|
||||||
|
return GuiActionRunner.execute(new GuiQuery<RSyntaxTextArea>() {
|
||||||
|
|
||||||
|
protected RSyntaxTextArea executeInEDT() {
|
||||||
|
target.selectAll();
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getCaretPosition(final RSyntaxTextArea target) {
|
||||||
|
focusAndWaitForFocusGain(target);
|
||||||
|
return GuiActionRunner.execute(new GuiQuery<Integer>() {
|
||||||
|
|
||||||
|
protected Integer executeInEDT() {
|
||||||
|
return target.getCaretPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCaretPosition(final RSyntaxTextArea target, final int caretPosition) {
|
||||||
|
focusAndWaitForFocusGain(target);
|
||||||
|
GuiActionRunner.execute(new GuiQuery<RSyntaxTextArea>() {
|
||||||
|
|
||||||
|
protected RSyntaxTextArea executeInEDT() {
|
||||||
|
target.setCaretPosition(caretPosition);
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
robot.waitForIdle();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package processing.app.helpers;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
|
|
||||||
|
import org.fest.swing.core.ComponentMatcher;
|
||||||
|
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
||||||
|
|
||||||
|
public class RSyntaxTextAreaComponentMatcher implements ComponentMatcher {
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
public RSyntaxTextAreaComponentMatcher(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean matches(Component component) {
|
||||||
|
return component instanceof RSyntaxTextArea && name.equals(component.getName());
|
||||||
|
}
|
||||||
|
}
|
52
app/test/processing/app/helpers/RSyntaxTextAreaFixture.java
Normal file
52
app/test/processing/app/helpers/RSyntaxTextAreaFixture.java
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
package processing.app.helpers;
|
||||||
|
|
||||||
|
import org.fest.swing.core.Robot;
|
||||||
|
import org.fest.swing.fixture.ComponentFixture;
|
||||||
|
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
||||||
|
|
||||||
|
public class RSyntaxTextAreaFixture extends ComponentFixture {
|
||||||
|
|
||||||
|
private final RSyntaxTextAreaComponentDriver driver;
|
||||||
|
|
||||||
|
public RSyntaxTextAreaFixture(Robot robot, Class type) {
|
||||||
|
super(robot, type);
|
||||||
|
this.driver = new RSyntaxTextAreaComponentDriver(robot);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RSyntaxTextAreaFixture(Robot robot, String name, Class type) {
|
||||||
|
super(robot, name, type);
|
||||||
|
this.driver = new RSyntaxTextAreaComponentDriver(robot);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RSyntaxTextAreaFixture(Robot robot, RSyntaxTextArea target) {
|
||||||
|
super(robot, target);
|
||||||
|
this.driver = new RSyntaxTextAreaComponentDriver(robot);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RSyntaxTextAreaFixture enterText(String text) {
|
||||||
|
driver.enterText((RSyntaxTextArea) target, text);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RSyntaxTextAreaFixture setText(String text) {
|
||||||
|
driver.setText((RSyntaxTextArea) target, text);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getText() {
|
||||||
|
return driver.getText((RSyntaxTextArea) target);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RSyntaxTextAreaFixture selectAll() {
|
||||||
|
driver.selectAll((RSyntaxTextArea) target);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCaretPosition() {
|
||||||
|
return driver.getCaretPosition((RSyntaxTextArea) target);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCaretPosition(int caretPosition) {
|
||||||
|
driver.setCaretPosition((RSyntaxTextArea) target, caretPosition);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user