summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.classpath5
-rw-r--r--lib/guava-18.0.jarbin0 -> 2256213 bytes
-rw-r--r--lib/hamcrest-all-1.3.jarbin0 -> 306578 bytes
-rw-r--r--lib/testFx-3.1.2.jarbin0 -> 63667 bytes
-rw-r--r--src/de/fhswf/in/inf/upnfx/view/MainView.fxml58
-rw-r--r--test/gui/CalculatorTest.java144
6 files changed, 178 insertions, 29 deletions
diff --git a/.classpath b/.classpath
index ac4a647..de370b8 100644
--- a/.classpath
+++ b/.classpath
@@ -1,7 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.fx.ide.jdt.core.JAVAFX_CONTAINER"/>
+ <classpathentry kind="lib" path="lib/guava-18.0.jar"/>
+ <classpathentry kind="lib" path="lib/hamcrest-all-1.3.jar"/>
+ <classpathentry kind="lib" path="lib/testFx-3.1.2.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/lib/guava-18.0.jar b/lib/guava-18.0.jar
new file mode 100644
index 0000000..8f89e49
--- /dev/null
+++ b/lib/guava-18.0.jar
Binary files differ
diff --git a/lib/hamcrest-all-1.3.jar b/lib/hamcrest-all-1.3.jar
new file mode 100644
index 0000000..6f62ba0
--- /dev/null
+++ b/lib/hamcrest-all-1.3.jar
Binary files differ
diff --git a/lib/testFx-3.1.2.jar b/lib/testFx-3.1.2.jar
new file mode 100644
index 0000000..1f8a17f
--- /dev/null
+++ b/lib/testFx-3.1.2.jar
Binary files differ
diff --git a/src/de/fhswf/in/inf/upnfx/view/MainView.fxml b/src/de/fhswf/in/inf/upnfx/view/MainView.fxml
index a1a0349..a1b5add 100644
--- a/src/de/fhswf/in/inf/upnfx/view/MainView.fxml
+++ b/src/de/fhswf/in/inf/upnfx/view/MainView.fxml
@@ -9,35 +9,35 @@
<children>
<GridPane AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
- <TextField fx:id="txtField" alignment="CENTER_RIGHT" editable="false" GridPane.columnSpan="4" GridPane.halignment="CENTER" />
- <Button fx:id="btnLn" disable="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleOpLn" text="LN" GridPane.halignment="CENTER" GridPane.rowIndex="1" />
- <Button fx:id="btnSin" disable="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleOpSin" text="SIN" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="1" />
- <Button fx:id="btnCos" disable="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleOpCos" text="COS" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="1" />
- <Button fx:id="btnTan" disable="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleOpTan" text="TAN" GridPane.columnIndex="3" GridPane.halignment="CENTER" GridPane.rowIndex="1" />
- <Button maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleInvert" text="+/-" GridPane.halignment="CENTER" GridPane.rowIndex="2" />
- <Button fx:id="btn1DivX" disable="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handle1DivX" text="1/X" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="2" />
- <Button fx:id="btnPow" disable="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleOpPow" text="Y^X" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="2" />
- <Button fx:id="btnSqr" disable="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleOpSqr" text="SQR" GridPane.columnIndex="3" GridPane.halignment="CENTER" GridPane.rowIndex="2" />
- <Button maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleLstX" text="LstX" GridPane.halignment="CENTER" GridPane.rowIndex="3" />
- <Button fx:id="btnXY" disable="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleXY" text="X&lt;&gt;Y" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="3" />
- <Button maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleClr" text="CLR" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="3" />
- <Button maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleClx" text="CLX" GridPane.columnIndex="3" GridPane.halignment="CENTER" GridPane.rowIndex="3" />
- <Button maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleNumber7" text="7" GridPane.halignment="CENTER" GridPane.rowIndex="4" />
- <Button maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleNumber8" text="8" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="4" />
- <Button maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleNumber9" text="9" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="4" />
- <Button fx:id="btnDiv" disable="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleOpDiv" text="/" GridPane.columnIndex="3" GridPane.halignment="CENTER" GridPane.rowIndex="4" />
- <Button maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleNumber4" text="4" GridPane.halignment="CENTER" GridPane.rowIndex="5" />
- <Button maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleNumber5" text="5" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="5" />
- <Button maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleNumber6" text="6" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="5" />
- <Button fx:id="btnMul" disable="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleOpMult" text="*" GridPane.columnIndex="3" GridPane.halignment="CENTER" GridPane.rowIndex="5" />
- <Button maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleNumber1" text="1" GridPane.halignment="CENTER" GridPane.rowIndex="6" />
- <Button maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleNumber2" text="2" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="6" />
- <Button maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleNumber3" text="3" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="6" />
- <Button fx:id="btnMinus" disable="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleOpMinus" text="-" GridPane.columnIndex="3" GridPane.halignment="CENTER" GridPane.rowIndex="6" />
- <Button fx:id="btnZero" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleNumber0" text="0" GridPane.halignment="CENTER" GridPane.rowIndex="7" />
- <Button fx:id="btnComma" disable="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleNumberComma" text="." GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="7" />
- <Button maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleEnt" text="ENT" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="7" />
- <Button fx:id="btnPlus" disable="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleOpPlus" text="+" GridPane.columnIndex="3" GridPane.halignment="CENTER" GridPane.rowIndex="7" />
+ <TextField id="display" fx:id="txtField" alignment="CENTER_RIGHT" editable="false" GridPane.columnSpan="4" GridPane.halignment="CENTER" />
+ <Button id="LN" fx:id="btnLn" disable="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleOpLn" text="LN" GridPane.halignment="CENTER" GridPane.rowIndex="1" />
+ <Button id="SIN" fx:id="btnSin" disable="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleOpSin" text="SIN" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="1" />
+ <Button id="COS" fx:id="btnCos" disable="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleOpCos" text="COS" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="1" />
+ <Button id="TAN" fx:id="btnTan" disable="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleOpTan" text="TAN" GridPane.columnIndex="3" GridPane.halignment="CENTER" GridPane.rowIndex="1" />
+ <Button id="+/-" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleInvert" text="+/-" GridPane.halignment="CENTER" GridPane.rowIndex="2" />
+ <Button id="1/X" fx:id="btn1DivX" disable="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handle1DivX" text="1/X" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="2" />
+ <Button id="Y^X" fx:id="btnPow" disable="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleOpPow" text="Y^X" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="2" />
+ <Button id="SQR" fx:id="btnSqr" disable="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleOpSqr" text="SQR" GridPane.columnIndex="3" GridPane.halignment="CENTER" GridPane.rowIndex="2" />
+ <Button id="LstX" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleLstX" text="LstX" GridPane.halignment="CENTER" GridPane.rowIndex="3" />
+ <Button id="X&lt;&gt;Y" fx:id="btnXY" disable="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleXY" text="X&lt;&gt;Y" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="3" />
+ <Button id="CLR" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleClr" text="CLR" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="3" />
+ <Button id="CLX" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleClx" text="CLX" GridPane.columnIndex="3" GridPane.halignment="CENTER" GridPane.rowIndex="3" />
+ <Button id="7" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleNumber7" text="7" GridPane.halignment="CENTER" GridPane.rowIndex="4" />
+ <Button id="8" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleNumber8" text="8" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="4" />
+ <Button id="9" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleNumber9" text="9" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="4" />
+ <Button id="/" fx:id="btnDiv" disable="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleOpDiv" text="/" GridPane.columnIndex="3" GridPane.halignment="CENTER" GridPane.rowIndex="4" />
+ <Button id="4" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleNumber4" text="4" GridPane.halignment="CENTER" GridPane.rowIndex="5" />
+ <Button id="5" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleNumber5" text="5" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="5" />
+ <Button id="6" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleNumber6" text="6" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="5" />
+ <Button id="*" fx:id="btnMul" disable="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleOpMult" text="*" GridPane.columnIndex="3" GridPane.halignment="CENTER" GridPane.rowIndex="5" />
+ <Button id="1" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleNumber1" text="1" GridPane.halignment="CENTER" GridPane.rowIndex="6" />
+ <Button id="2" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleNumber2" text="2" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="6" />
+ <Button id="3" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleNumber3" text="3" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="6" />
+ <Button id="-" fx:id="btnMinus" disable="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleOpMinus" text="-" GridPane.columnIndex="3" GridPane.halignment="CENTER" GridPane.rowIndex="6" />
+ <Button id="0" fx:id="btnZero" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleNumber0" text="0" GridPane.halignment="CENTER" GridPane.rowIndex="7" />
+ <Button id="," fx:id="btnComma" disable="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleNumberComma" text="." GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="7" />
+ <Button id="ENT" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleEnt" text="ENT" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="7" />
+ <Button id="+" fx:id="btnPlus" disable="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#handleOpPlus" text="+" GridPane.columnIndex="3" GridPane.halignment="CENTER" GridPane.rowIndex="7" />
</children>
<rowConstraints>
<RowConstraints vgrow="ALWAYS" />
diff --git a/test/gui/CalculatorTest.java b/test/gui/CalculatorTest.java
new file mode 100644
index 0000000..77d3371
--- /dev/null
+++ b/test/gui/CalculatorTest.java
@@ -0,0 +1,144 @@
+/*
+ * $RCSFile$
+ *
+ * Created on 07.01.2010
+ * for Project:
+ * by steins
+ *
+ * (C) 2005-2006 by
+ */
+package gui;
+
+//import gui.CalculatorFrame;
+
+import static org.loadui.testfx.Assertions.verifyThat;
+import static org.loadui.testfx.controls.Commons.hasText;
+
+import java.io.IOException;
+import javafx.fxml.FXMLLoader;
+import javafx.scene.Parent;
+import javafx.scene.control.Button;
+
+import org.junit.Test;
+import org.loadui.testfx.GuiTest;
+
+public class CalculatorTest extends GuiTest
+{
+ @Override
+ public Parent getRootNode()
+ {
+ try
+ {
+ return FXMLLoader
+ .load(CalculatorTest.class
+ .getResource("/de/fhswf/in/inf/upnfx/view/MainView.fxml"));
+ }
+ catch (IOException e)
+ {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ @Test
+ public void testNullAndComma()
+ {
+ Button button = find("#0");
+ click(button);
+ button = find("#0");
+ click(button);
+ button = find("#,");
+ click(button);
+ button = find("#,");
+ click(button);
+ button = find("#0");
+ click(button);
+ button = find("#0");
+ click(button);
+ button = find("#1");
+ click(button);
+ verifyThat("#display", hasText("0.001"));
+ }
+
+ @Test
+ public void testNumbers()
+ {
+ Button button = find("#0");
+ click(button);
+ button = find("#1");
+ click(button);
+ button = find("#2");
+ click(button);
+ button = find("#3");
+ click(button);
+ button = find("#4");
+ click(button);
+ button = find("#5");
+ click(button);
+ button = find("#6");
+ click(button);
+ button = find("#7");
+ click(button);
+ button = find("#8");
+ click(button);
+ button = find("#9");
+ click(button);
+ verifyThat("#display", hasText("123456789"));
+ }
+
+ @Test
+ public void testAdd()
+ {
+ Button button = find("#1");
+ click(button);
+ button = find("#ENT");
+ click(button);
+ button = find("#2");
+ click(button);
+ button = find("#+");
+ click(button);
+ verifyThat("#display", hasText("3.0"));
+ }
+
+ @Test
+ public void testSub()
+ {
+ Button button = find("#1");
+ click(button);
+ button = find("#ENT");
+ click(button);
+ button = find("#2");
+ click(button);
+ button = find("#-");
+ click(button);
+ verifyThat("#display", hasText("-1.0"));
+ }
+
+ @Test
+ public void testMul()
+ {
+ Button button = find("#3");
+ click(button);
+ button = find("#ENT");
+ click(button);
+ button = find("#2");
+ click(button);
+ button = find("#*");
+ click(button);
+ verifyThat("#display", hasText("6.0"));
+ }
+
+ @Test
+ public void testDiv()
+ {
+ Button button = find("#1");
+ click(button);
+ button = find("#ENT");
+ click(button);
+ button = find("#2");
+ click(button);
+ button = find("#/");
+ click(button);
+ verifyThat("#display", hasText("0.5"));
+ }
+
+}