source: java/main/src/test/java/com/framsticks/gui/BrowserTest.java @ 84

Last change on this file since 84 was 84, checked in by psniegowski, 11 years ago

HIGHLIGHTS:

  • simplification of entities management model
  • cleanup around params (improve hierarchy)
  • migrate from JUnit to TestNG
  • introduce FEST to automatically test GUI
  • improve slider control
  • loosen synchronization between gui tree and backend representation
  • and many other bug fixes

NOTICE:

  • a great many of lines is changed only because of substituting spaces with tabs

CHANGELOG (oldest changes at the bottom):

Some cleaning after fix found.

Fix bug with tree.

More changes with TreeNodes?.

Finally fix issue with tree.

Improve gui tree management.

Decouple update of values from fetch request in gui.

Minor changes.

Minor changes.

Minor change.

Change Path construction wording.

More fixes to SliderControl?.

Fix SliderControl?.

Fix SliderControl?.

Minor improvement.

Several changes.

Make NumberParam? a generic class.

Add robot to the gui test.

Setup common testing logging configuration.

Remove Parameters class.

Remove entityOwner from Parameters.

Move name out from Parameters class.

Move configuration to after the construction.

Simplify observers and endpoints.

Remove superfluous configureEntity overrides.

Add dependency on fest-swing-testng.

Use FEST for final print test.

Use FEST for more concise and readable assertions.

Divide test of F0Parser into multiple methods.

Migrate to TestNG

Minor change.

Change convention from LOGGER to log.

Fix reporting of errors during controls filling.

Bound maximal height of SliderControl?.

Minor improvements.

Improve tooltips for controls.

Also use Delimeted in more places.

Move static control utilities to Gui.

Rename package gui.components to controls.

Some cleaning in controls.

Improve Param classes placing.

Move ValueParam?, PrimitiveParam? and CompositeParam? one package up.

Improve ParamBuilder?.

Move getDef to ValueParam? and PrimitiveParam?.

Move getMax and getDef to ValueParam?.

Move getMin to ValueParam?.

Upgrade to laters apache commons versions.

Use filterInstanceof extensively.

Add instanceof filters.

Make ValueParam? in many places of Param.

Place assertions about ValueParam?.

Add ValueParam?

Rename ValueParam? to PrimitiveParam?

Minor changes.

Several improvements to params types.

Add NumberParam?.

Add TextControl? component.

Add .swp files to .gitignore

Greatly improved slider component.

Some improvements.

Make Param.reassign return also a state.

Add IterableIterator?.

Several changes.

  • Move util classes to better packages.
  • Remove warnings from eclim.

Several improvements.

Fix bug with BooleanParam?.

Some experiments with visualization.

Another fix to panel management.

Improve panel management.

Some refactorization around panels.

Add root class for panel.

File size: 3.1 KB
Line 
1package com.framsticks.gui;
2
3import javax.swing.JFrame;
4
5import org.apache.commons.configuration.PropertiesConfiguration;
6import org.apache.log4j.Logger;
7import org.fest.swing.edt.FailOnThreadViolationRepaintManager;
8import org.fest.swing.edt.GuiActionRunner;
9import org.fest.swing.edt.GuiQuery;
10import org.fest.swing.edt.GuiTask;
11import org.fest.swing.fixture.FrameFixture;
12import org.fest.swing.fixture.JTreeFixture;
13// import static org.fest.swing.edt.GuiActionRunner.*;
14import org.testng.annotations.*;
15
16import com.framsticks.communication.ClientConnection;
17import com.framsticks.remote.RemoteInstance;
18import com.framsticks.test.TestConfiguration;
19
20import static org.fest.assertions.Assertions.*;
21import static org.fest.swing.core.BasicRobot.robotWithNewAwtHierarchy;
22import static org.fest.swing.edt.GuiActionRunner.*;
23import org.fest.swing.core.Robot;
24
25public class BrowserTest extends TestConfiguration {
26        private static final Logger log = Logger.getLogger(BrowserTest.class);
27
28        Browser browser;
29        Robot robot;
30        FrameFixture frame;
31
32        @BeforeClass
33        public void setUp() {
34                FailOnThreadViolationRepaintManager.install();
35                assertThat(executeInEDT()).isTrue();
36
37                robot = robotWithNewAwtHierarchy();
38
39                browser = new Browser();
40                browser.configure(new PropertiesConfiguration());
41
42                RemoteInstance localhost = new RemoteInstance();
43                localhost.setName("localhost");
44                localhost.setConnection(new ClientConnection("localhost:9009"));
45
46                browser.addEndpointForInstance(localhost);
47
48                browser.start();
49                // robot.waitForIdle();
50                frame = new FrameFixture(robot,
51                                GuiActionRunner.execute(new GuiQuery<JFrame>() {
52                                        @Override
53                                        protected JFrame executeInEDT() throws Throwable {
54                                                return browser.getMainFrame();
55                                        }
56                                }));
57
58                log.info("frame fixture done");
59                // frame.show();
60                // log.info("frame fixture shown");
61        }
62
63        public void clickAndExpandPath(JTreeFixture tree, String path) {
64                tree.clickPath(path).expandPath(path);
65                robot.waitForIdle();
66        }
67
68        @Test
69        public void testShow() {
70                log.info("testing");
71                JTreeFixture tree = frame.tree("tree");
72                tree.clickRow(0).expandRow(0);
73                robot.waitForIdle();
74                tree.clickRow(1).expandRow(1);
75                robot.waitForIdle();
76                assertThat(tree.valueAt(1)).isEqualTo("simulator");
77                robot.waitForIdle();
78                execute(new GuiTask() {
79                        @Override
80                        protected void executeInEDT() throws Throwable {
81                                assertThat(frame.panel("o Simulator").component().isVisible())
82                                                .isTrue();
83                        }
84                });
85
86                clickAndExpandPath(tree, "localhost/simulator/genepools");
87                clickAndExpandPath(tree, "localhost/simulator/genepools/groups");
88                clickAndExpandPath(tree, "localhost/simulator/genepools/groups/Genotypes");
89                // tree.clickPath("localhost/simulator/genepools/groups/Genotypes/genotypes");
90                // robot.waitForIdle();
91                // sleep(2);
92                // tree.expandPath("localhost/simulator/genepools/groups/Genotypes/genotypes");
93
94                // tree.expandRow(tree.component().getLeadSelectionRow() + 1);
95                // robot.waitForIdle();
96
97                // sleep(2);
98        }
99
100        public void sleep(int seconds) {
101                try {
102                        Thread.sleep(seconds * 1000, 0);
103                } catch (InterruptedException e) {
104                        e.printStackTrace();
105                }
106        }
107
108        @AfterClass
109        public void tearDown() {
110                // frame.close();
111                frame.cleanUp();
112        }
113
114}
Note: See TracBrowser for help on using the repository browser.