blob: 77d33714919eaafd17f2a828924dbf57157d6aa6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
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"));
}
}
|