diff options
| author | Stefan Suhren <suhren.stefan@fh-swf.de> | 2015-06-15 15:04:26 +0200 |
|---|---|---|
| committer | Stefan Suhren <suhren.stefan@fh-swf.de> | 2015-06-15 16:19:28 +0200 |
| commit | 09e970553f6c32b52a927aa882b3ac282797c0a8 (patch) | |
| tree | b40c649da1eb4cad7d432aaf7da400ee47ce3326 /test/gui/CalculatorTest.java | |
| parent | da2478e2e84c7b6e68715c98e6c8a39e20125736 (diff) | |
| download | UpnFx-09e970553f6c32b52a927aa882b3ac282797c0a8.tar.gz UpnFx-09e970553f6c32b52a927aa882b3ac282797c0a8.zip | |
Add various tests for the FXML interface
Diffstat (limited to 'test/gui/CalculatorTest.java')
| -rw-r--r-- | test/gui/CalculatorTest.java | 218 |
1 files changed, 218 insertions, 0 deletions
diff --git a/test/gui/CalculatorTest.java b/test/gui/CalculatorTest.java index 98c6516..5946bd4 100644 --- a/test/gui/CalculatorTest.java +++ b/test/gui/CalculatorTest.java @@ -83,6 +83,224 @@ public class CalculatorTest extends GuiTest } @Test + public void testClr() + { + Button button = find("#1"); + click(button); + button = find("#2"); + click(button); + button = find("#3"); + click(button); + button = find("#ENT"); + click(button); + verifyThat("#display", hasText("123.0")); + button = find("#4"); + click(button); + button = find("#5"); + click(button); + button = find("#6"); + click(button); + verifyThat("#display", hasText("456")); + button = find("#CLR"); + click(button); + verifyThat("#display", hasText("")); + } + + @Test + public void testSwapXY() + { + Button button = find("#1"); + click(button); + button = find("#2"); + click(button); + button = find("#3"); + click(button); + button = find("#ENT"); + click(button); + verifyThat("#display", hasText("123.0")); + button = find("#4"); + click(button); + button = find("#5"); + click(button); + button = find("#6"); + click(button); + verifyThat("#display", hasText("456")); + button = find("#SwapXY"); + click(button); + verifyThat("#display", hasText("123.0")); + click(button); + verifyThat("#display", hasText("456.0")); + } + + @Test + public void testLstX() + { + Button button = find("#1"); + click(button); + button = find("#0"); + click(button); + click(button); + button = find("#ENT"); + click(button); + verifyThat("#display", hasText("100.0")); + button = find("#2"); + click(button); + button = find("#0"); + click(button); + click(button); + verifyThat("#display", hasText("200")); + button = find("#+"); + click(button); + verifyThat("#display", hasText("300.0")); + button = find("#LstX"); + click(button); + verifyThat("#display", hasText("200.0")); + button = find("#+"); + click(button); + verifyThat("#display", hasText("500.0")); + } + + @Test + public void testSqr() + { + Button button = find("#9"); + click(button); + button = find("#SQR"); + click(button); + verifyThat("#display", hasText("3.0")); + } + + @Test + public void testYhochX() + { + Button button = find("#2"); + click(button); + button = find("#ENT"); + click(button); + verifyThat("#display", hasText("2.0")); + button = find("#3"); + click(button); + verifyThat("#display", hasText("3")); + button = find("#YhochX"); + click(button); + verifyThat("#display", hasText("8.0")); + click(button); + verifyThat("#display", hasText("8.0")); + } + + @Test + public void test1div0() + { + Button button = find("#0"); + click(button); + button = find("#ENT"); + click(button); + verifyThat("#display", hasText("0.0")); + button = find("#1divX"); + click(button); + verifyThat("#display", hasText("")); + } + + @Test + public void test1divX() + { + Button button = find("#2"); + click(button); + verifyThat("#display", hasText("2")); + button = find("#1divX"); + click(button); + verifyThat("#display", hasText("0.5")); + } + + @Test + public void testInverseNoEnt() + { + Button button = find("#2"); + click(button); + verifyThat("#display", hasText("2")); + button = find("#+-"); + click(button); + verifyThat("#display", hasText("-2")); + } + + @Test + public void testInverseWithEnt() + { + Button button = find("#2"); + click(button); + button = find("#ENT"); + click(button); + verifyThat("#display", hasText("2.0")); + button = find("#+-"); + click(button); + verifyThat("#display", hasText("-2.0")); + } + + @Test + public void testLn() + { + String strE = Double.toString(Math.E); + Button button; + + for (int i = 0; i < strE.length(); ++i) + { + button = find(("#" + strE.charAt(i)).replace(".", ",")); + click(button); + } + button = find("#LN"); + click(button); + verifyThat("#display", hasText(Double.toString(Math.log(Math.E)))); + } + + @Test + public void testSin() + { + String strPi = Double.toString(Math.PI); + Button button; + + for (int i = 0; i < strPi.length(); ++i) + { + button = find(("#" + strPi.charAt(i)).replace(".", ",")); + click(button); + } + button = find("#SIN"); + click(button); + verifyThat("#display", hasText(Double.toString(Math.sin(Math.PI)))); + } + + @Test + public void testCos() + { + String strPi = Double.toString(Math.PI); + Button button; + + for (int i = 0; i < strPi.length(); ++i) + { + button = find(("#" + strPi.charAt(i)).replace(".", ",")); + click(button); + } + button = find("#COS"); + click(button); + verifyThat("#display", hasText(Double.toString(Math.cos(Math.PI)))); + } + + @Test + public void testTan() + { + String strPi = Double.toString(Math.PI); + Button button; + + for (int i = 0; i < strPi.length(); ++i) + { + button = find(("#" + strPi.charAt(i)).replace(".", ",")); + click(button); + } + button = find("#TAN"); + click(button); + verifyThat("#display", hasText(Double.toString(Math.tan(Math.PI)))); + } + + @Test public void testNumbers() { Button button = find("#0"); |
