summaryrefslogtreecommitdiffstats
path: root/test/gui/CalculatorTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'test/gui/CalculatorTest.java')
-rw-r--r--test/gui/CalculatorTest.java144
1 files changed, 144 insertions, 0 deletions
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"));
+ }
+
+}