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

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

HIGHLIGHTS:

  • loading f0 schema with XmlLoader?
  • use XmlLoader? to load configuration
  • introduce unified fork-join model of various entities

(Instances, Connections, GUI Frames, etc.),
all those entities clean up gracefully on
shutdown, which may be initialized by user
or by some entity

  • basing on above, simplify several organizing classes

(Observer, main class)

(to host native frams server process from Java level)

CHANGELOG:
Remove redundant Observer class.

Clean up in AbstractJoinable?.

Update ExternalProcess? class to changes in joining model.

Another sweep through code with FindBugs?.

Find bug with not joining RemoteInstance?.

Joining almost works.

Much improved joining model.

More improvement to joining model.

Add logging messages around joinable operations.

Rename methods in AbstractJoinable?.

Improve Joinable.

Rewrite of entity structure.

More simplifications with entities.

Further improve joinables.

Let Frame compose from JFrame instead of inheriting.

Add join classes.

Improvements of closing.

Add Builder interface.

Add FramsServerTest?.xml

FramsServer? may be configured through xml.

Make Framsticks main class an Observer of Entities.

Make Observer a generic type.

Remove variables regarding to removed endpoint.

Simplify observer (remove endpoints).

More changes to Observer and Endpoint.

Minor improvements.

Add OutputListener? to ExternalProcess?.

Improve testing of ExternalProcess?.

Add ExternalProcess? runner.

Rename the Program class to Framsticks.

Migrate Program to use XmlLoader? configuration.

First steps with configuration using XmlLoader?.

Fix several bugs.

Move all f0 classes to apriopriate package.

XmlLoader? is able to load Schema.

XmlLoader? is loading classes and props.

Add GroupBuilder?.

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