-
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
Kevin Leiser
authored and
Kevin Leiser
committed
Jun 22, 2018
1 parent
9260b56
commit 325ecaf
Showing
9 changed files
with
301 additions
and
185 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file modified
BIN
+9 Bytes
(100%)
out/production/HW6/cs3500/animator/controller/InteractiveController.class
Binary file not shown.
Binary file modified
BIN
-93 Bytes
(97%)
out/test/HW6/cs3500/animator/InteractiveTest/DummyController.class
Binary file not shown.
Binary file modified
BIN
+2.2 KB
(420%)
out/test/HW6/cs3500/animator/InteractiveTest/InteractiveTests.class
Binary file not shown.
Binary file modified
BIN
+11 Bytes
(100%)
out/test/HW6/cs3500/animator/InteractiveTest/MockView.class
Binary file not shown.
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
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
62 changes: 54 additions & 8 deletions
62
test/cs3500/animator/InteractiveTest/InteractiveTests.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 |
---|---|---|
@@ -1,29 +1,75 @@ | ||
package cs3500.animator.InteractiveTest; | ||
|
||
import javax.swing.*; | ||
import javax.swing.event.ChangeEvent; | ||
import java.awt.event.ActionEvent; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* Test class to test proper function calls are made across view and controller when events occur | ||
* in gui. | ||
*/ | ||
public class InteractiveTests { | ||
|
||
/** | ||
* things to test: | ||
* start/stop | ||
* restart | ||
* loop | ||
* speed | ||
*/ | ||
private final int FPS_MIN = 1; | ||
private final int FPS_MAX = 60; | ||
private final int FPS_INIT = 30; | ||
|
||
private DummyController mockController; | ||
private MockView mockView; | ||
private ActionEvent startStop; | ||
private ActionEvent restart; | ||
private ActionEvent loopToggle; | ||
private ActionEvent export; | ||
private ChangeEvent changeSpeed; | ||
private StringBuilder controlOut; | ||
private StringBuilder viewOut; | ||
|
||
@Before | ||
public void initialize() { | ||
|
||
viewOut = new StringBuilder(); | ||
mockView = new MockView(viewOut); | ||
startStop = new ActionEvent(mockView, ActionEvent.ACTION_FIRST, "start stop button"); | ||
restart = new ActionEvent(mockView, 1, "restart button"); | ||
loopToggle = new ActionEvent(mockView, 2, "toggle looping button"); | ||
export = new ActionEvent(mockView, 3, "export button"); | ||
controlOut = new StringBuilder(); | ||
mockController = new DummyController(null, mockView, controlOut ); | ||
} | ||
|
||
@Test | ||
public void restartTest() { | ||
mockView.actionPerformed(restart); | ||
assertEquals("restart button clicked\n", viewOut.toString()); | ||
} | ||
|
||
@Test | ||
public void startStopTest() { | ||
mockView.actionPerformed(startStop); | ||
assertEquals("start/stop button clicked\n", viewOut.toString()); | ||
} | ||
|
||
@Test | ||
public void setLoopToggleTest() { | ||
mockView.actionPerformed(loopToggle); | ||
assertEquals("looping toggle button clicked\n", viewOut.toString()); | ||
} | ||
|
||
@Test | ||
public void exportTest() { | ||
mockView.actionPerformed(export); | ||
assertEquals("export button clicked\n", viewOut.toString()); | ||
} | ||
|
||
@Test | ||
public void ChangeSpeedTest() { | ||
JSlider slider = new JSlider(JSlider.HORIZONTAL, FPS_MIN, FPS_MAX, FPS_INIT); | ||
changeSpeed = new ChangeEvent(slider); | ||
slider.setValue(35); | ||
mockView.stateChanged(changeSpeed); | ||
assertEquals("Speed changed to 35\n", viewOut.toString()); | ||
} | ||
} |
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