forked from umontreal-diro/Makelangelo-software
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d0685cc
commit 66fbcba
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
...om/marginallyclever/makelangelo/plotter/plottercontrols/TestTextInterfaceToListeners.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.marginallyclever.makelangelo.plotter.plottercontrols; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import java.awt.event.ActionEvent; | ||
import java.awt.event.ActionListener; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class TestTextInterfaceToListeners { | ||
|
||
private TextInterfaceToListeners textInterface; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
textInterface = new TextInterfaceToListeners(); | ||
} | ||
|
||
@Test | ||
public void testSendCommand() { | ||
ActionListener listener = new ActionListener() { | ||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
assertEquals("test command", e.getActionCommand()); | ||
} | ||
}; | ||
textInterface.addActionListener(listener); | ||
textInterface.sendCommand("test command"); | ||
textInterface.removeActionListener(listener); | ||
} | ||
|
||
@Test | ||
public void testSendNow() { | ||
ActionListener listener = new ActionListener() { | ||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
assertEquals("test command", e.getActionCommand()); | ||
} | ||
}; | ||
textInterface.addActionListener(listener); | ||
textInterface.setCommand("test command"); | ||
textInterface.sendNow(); | ||
textInterface.removeActionListener(listener); | ||
} | ||
|
||
@Test | ||
public void testGetCommand() { | ||
textInterface.setCommand("test command"); | ||
assertEquals("test command", textInterface.getCommand()); | ||
} | ||
} | ||
|