Repository navigation
Expand file tree
/
Copy pathTestHDFViewMenu.java
More file actions
130 lines (110 loc) · 4.56 KB
/
Copy pathTestHDFViewMenu.java
File metadata and controls
130 lines (110 loc) · 4.56 KB
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
package test.uitest;
import static org.fest.swing.finder.WindowFinder.findFrame;
import static org.fest.swing.launcher.ApplicationLauncher.application;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.File;
import javax.swing.JFrame;
import org.fest.swing.core.BasicRobot;
import org.fest.swing.core.GenericTypeMatcher;
import org.fest.swing.core.Robot;
import org.fest.swing.edt.FailOnThreadViolationRepaintManager;
import org.fest.swing.finder.JFileChooserFinder;
import org.fest.swing.fixture.FrameFixture;
import org.fest.swing.fixture.JFileChooserFixture;
import org.fest.swing.fixture.JMenuItemFixture;
import org.fest.swing.fixture.JTreeFixture;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
public class TestHDFViewMenu {
private static FrameFixture mainFrameFixture;
@BeforeClass
public static void setUpOnce() {
FailOnThreadViolationRepaintManager.install();
Robot robot = BasicRobot.robotWithNewAwtHierarchy();
application("ncsa.hdf.view.HDFView").start();
mainFrameFixture = findFrame(new GenericTypeMatcher<JFrame>(JFrame.class) {
protected boolean isMatching(JFrame frame) {
return "HDFView".equals(frame.getTitle()) && frame.isShowing();
}
}).withTimeout(10000).using(robot);
mainFrameFixture.robot.waitForIdle();
mainFrameFixture.requireVisible();
}
@AfterClass
public static void finishApplication() {
mainFrameFixture.robot.waitForIdle();
//mainFrameFixture.requireNotVisible();
mainFrameFixture.cleanUp();
}
@Test
public void verifyOpenButtonEnabled() {
mainFrameFixture.button("Open").requireEnabled();
}
@Test
public void verifyCloseButtonEnabled() {
mainFrameFixture.button("Close").requireEnabled();
}
@Test
public void verifyHelpButtonEnabled() {
mainFrameFixture.button("Help").requireEnabled();
}
@Test
public void verifyHDF4ButtonEnabled() {
mainFrameFixture.button("HDF4 library").requireEnabled();
}
@Test
public void verifyHDF5ButtonEnabled() {
mainFrameFixture.button("HDF5 library").requireEnabled();
}
@Test
public void verifyTextInLabelWhenClickingHDF4Button() {
mainFrameFixture.button("HDF4 library").click();
mainFrameFixture.dialog("dialog0").optionPane().requirePlainMessage().requireMessage("HDF 4.2.5");
mainFrameFixture.dialog("dialog0").optionPane().button("OptionPane.button").click();
}
@Test
public void verifyTextInLabelWhenClickingHDF5Button() {
mainFrameFixture.button("HDF5 library").click();
mainFrameFixture.dialog("dialog1").optionPane().requirePlainMessage().requireMessage("HDF5 1.8.7");
mainFrameFixture.dialog("dialog1").optionPane().button("OptionPane.button").click();
}
@Test
public void verifyMenuOpen() {
JMenuItemFixture fileMenuItem = mainFrameFixture.menuItemWithPath("File","Open");
fileMenuItem.robot.waitForIdle();
fileMenuItem.requireVisible();
fileMenuItem.click();
JFileChooserFixture fileChooser = JFileChooserFinder.findFileChooser().using(mainFrameFixture.robot);
fileChooser.cancel();
}
@Test
public void verifyMenuNewHDF4() {
JMenuItemFixture fileMenuItem = mainFrameFixture.menuItemWithPath("File","New","HDF4");
fileMenuItem.robot.waitForIdle();
fileMenuItem.requireVisible();
fileMenuItem.click();
JFileChooserFixture fileChooser = JFileChooserFinder.findFileChooser().using(mainFrameFixture.robot);
fileChooser.fileNameTextBox().requireText("*.hdf");
fileChooser.fileNameTextBox().setText("testfile.hdf");
fileChooser.approve();
File hdf_file = new File("testfile.hdf");
assertTrue(hdf_file.exists());
hdf_file.delete();
}
@Test
public void verifyMenuNewHDF5() {
JMenuItemFixture fileMenuItem = mainFrameFixture.menuItemWithPath("File","New","HDF5");
fileMenuItem.robot.waitForIdle();
fileMenuItem.requireVisible();
fileMenuItem.click();
JFileChooserFixture fileChooser = JFileChooserFinder.findFileChooser().using(mainFrameFixture.robot);
fileChooser.fileNameTextBox().requireText("*.h5");
fileChooser.fileNameTextBox().setText("testfile.h5");
fileChooser.approve();
File hdf_file = new File("testfile.h5");
assertTrue(hdf_file.exists());
hdf_file.delete();
}
}