source: tmcsimulator/trunk/test/tmcsim/simulationmanager/SimulationManagerSmokeTest.java @ 2

Revision 2, 3.5 KB checked in by jdalbey, 10 years ago (diff)

Initial Import of project files

Line 
1package tmcsim.simulationmanager;
2
3import java.io.File;
4import static junit.framework.Assert.assertEquals;
5import static junit.framework.Assert.assertFalse;
6import static junit.framework.Assert.fail;
7import org.uispec4j.*;
8import org.uispec4j.interception.WindowInterceptor;
9import tmcsim.cadsimulator.CADSimulator;
10import tmcsim.common.ScriptException;
11import tmcsim.common.SimulationException;
12
13/**
14 * Smoke Test of system. Start the CAD server, Start the Sim Mgr, see if the Sim
15 * Mgr view shows "No Script".
16 *
17 * @author jdalbey
18 */
19public class SimulationManagerSmokeTest extends UISpecTestCase
20{
21
22    SimulationManager simMgrApp;
23    CADSimulator engine;
24
25    public SimulationManagerSmokeTest(String testName)
26    {
27        super(testName);
28    }
29
30    /**
31     * Call constructors for both classes
32     */
33    public void testBothGUIs() throws ScriptException, SimulationException
34    {
35        System.out.println("Smoke Test Sim Mgr & CADSimulator");
36
37        Window cadwindow = null;
38        System.setProperty("CAD_SIM_PROPERTIES", "config/cad_simulator_config.properties");
39        if (System.getProperty("CAD_SIM_PROPERTIES") != null)
40        {
41            cadwindow = WindowInterceptor.run(new Trigger()
42            {
43                public void run()
44                {
45                    try
46                    {
47                        engine = new CADSimulator(System.getProperty("CAD_SIM_PROPERTIES"));
48                    } catch (Exception e)
49                    {
50                        fail("Couldn't launch CADSimulator");
51                    }
52                }
53            });
54        } else
55        {
56            fail("CAD_SIM_PROPERTIES system property not defined.");
57        }
58
59        // Check CAD Simulator appears with no script and nothing connected
60        assertEquals("CAD Simulator", cadwindow.getTitle());
61        Panel mainPanel = cadwindow.getPanel("contentPane");
62        TextBox txtStatus = mainPanel.getTextBox("simulationStatus");
63        assertEquals("No Script", txtStatus.getText());
64        TextBox terms = mainPanel.getTextBox("termConnectedTF");
65        assertEquals("0", terms.getText().trim());
66        assertEquals("No", mainPanel.getTextBox("managerConnectedTF").getText().trim());
67
68        Window simMgrWindow = null;
69        System.setProperty("SIM_MGR_PROPERTIES", "config/sim_manager_config.properties");
70        if (System.getProperty("SIM_MGR_PROPERTIES") != null)
71        {
72            simMgrWindow = WindowInterceptor.run(new Trigger()
73            {
74                public void run()
75                {
76                    try
77                    {
78                        simMgrApp = new SimulationManager(System.getProperty("SIM_MGR_PROPERTIES"));
79                    } catch (Exception ex)
80                    {
81                        fail("Couldn't launch Simulation Manager");
82                    }
83                }
84            });
85        } else
86        {
87            fail("SIM_MGR_PROPERTIES system property not defined.");
88        }
89
90        // Check that the Sim Mgr GUI appears without a script loaded yet
91        SimulationManagerView view = simMgrApp.theSimManagerView;
92        assertFalse(view.isSimulationStarted());
93        Window win = new Window(view);
94        Panel contentPanel = win.getPanel("contentPane");
95        TextBox txtSimStatus = contentPanel.getTextBox("simulationStatusText");
96        assertEquals("No Script", txtSimStatus.getText());
97
98        assertEquals("Yes", mainPanel.getTextBox("managerConnectedTF").getText().trim());
99
100        // Quit
101        engine = null;
102        simMgrApp = null;
103    }
104}
Note: See TracBrowser for help on using the repository browser.