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

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

HIGHLIGHTS:

  • FramsClass? and contained Param are now immutable classes (like String),

which allows to refer to them concurrently without synchronization
(which for example in turn simplifies GUI management)

  • also make Path immutable (which was earlier only assumed)
  • add global cache for FramsClasses? created solely and automatically

on base of Java classes.

representations basing on given FramsClass?

  • above changes greatly improved GUI responsivness during browsing
  • furtherly improve Param class hierarchy
  • allow to inject actions on state changes into MultiParamLoader?
  • add more tests

CHANGELOG:

Add StatusListener? to MultiParamLoader?.

Minor refactorization in MultiParamLoader?.

First step with auto append.

Add SchemaTest?.

Improve Registry.

Clean up in Registry.

Work out Registry.

Use annotations for Param.

Fix ListChange?.

Improve fluent interface of the FramsClassBuilder?.

Done caching of ReflectionAccess?.Backend

Fix hashCode of Pair.

A step on a way to cache ReflectionAccess?.Backend

Make SimpleAbstractAccess?.framsClass a final field.

Add static cache for FramsClasses? based on java.

Only classes created strictly and automatically
based on java classes are using this cache.

Make all Params immutable.

Many improvement to make Param immutable.

Make PrimitiveParam? generic type.

Several changes to make Param immutable.

Make FramsClass? immutable.

Another improvement to Path immutability.

Several improvements to Path.

Improve PathTest?.

Configurarable MutabilityDetector?.

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